diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..5c459fd2 --- /dev/null +++ b/.clang-format @@ -0,0 +1,39 @@ +BasedOnStyle: WebKit +AccessModifierOffset: '-4' +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: 'true' +AlignTrailingComments: 'true' +AllowAllArgumentsOnNextLine: 'true' +AllowAllParametersOfDeclarationOnNextLine: 'true' +AllowShortBlocksOnASingleLine: 'false' +AllowShortCaseLabelsOnASingleLine: 'true' +AllowShortEnumsOnASingleLine: 'false' +AllowShortFunctionsOnASingleLine: None +AlwaysBreakTemplateDeclarations: 'No' +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: true + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakConstructorInitializers: BeforeColon +ColumnLimit: '120' +CommentPragmas: '"^!|^:"' +ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' +ConstructorInitializerIndentWidth: '4' +ContinuationIndentWidth: '8' +IndentPPDirectives: BeforeHash +NamespaceIndentation: All +PenaltyExcessCharacter: '10' +PointerAlignment: Right +SortIncludes: 'true' +SpaceAfterTemplateKeyword: 'false' +Standard: Auto diff --git a/.clang-format-ignore b/.clang-format-ignore new file mode 100644 index 00000000..4019357f --- /dev/null +++ b/.clang-format-ignore @@ -0,0 +1,20 @@ +/client/3rd +/client/3rd-prebuild +/client/android +/client/cmake +/client/core/serialization +/client/daemon +/client/fonts +/client/images +/client/ios +/client/mozilla +/client/platforms/dummy +/client/platforms/linux +/client/platforms/macos +/client/platforms/windows +/client/server_scripts +/client/translations +/deploy +/docs +/metadata +/service/src diff --git a/.gitattributes b/.gitattributes index 7dc1509d..44b9d8f3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,5 @@ deploy/data/windows/x64/tap/windows_7/OemVista.inf eol=crlf deploy/data/windows/x64/tap/windows_10/OemVista.inf eol=crlf deploy/data/windows/x32/tap/windows_7/OemVista.inf eol=crlf deploy/data/windows/x32/tap/windows_10/OemVista.inf eol=crlf +client/3rd/* linguist-vendored +client/android/gradlew.bat eol=crlf diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..04e9030a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,42 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Log files** +Attach log files to help explain your problem. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. Windows 10] + - Version [e.g. 2.1.2] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Version [e.g. 2.1.2] + +**Server (please complete the following information):** + - OS: [e.g. Ubuntu 22.04] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ca7ac87d..0c9dfb32 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,16 +1,27 @@ name: 'Deploy workflow' +on: + push: + branches: + - '**' -on: [push] +env: + QT_MIRROR: https://mirrors.ocf.berkeley.edu/qt/ # https://download.qt.io/static/mirrorlist/ jobs: Build-Linux-Ubuntu: - name: 'Build-Linux-Ubuntu' - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 env: - QT_VERSION: 6.4.1 - QIF_VERSION: 4.5 + QT_VERSION: 6.6.2 + QIF_VERSION: 4.7 + PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }} + PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }} + DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }} + DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }} + DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }} + FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }} + PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }} steps: - name: 'Install Qt' @@ -25,10 +36,10 @@ jobs: setup-python: 'true' tools: 'tools_ifw' set-env: 'true' - extra: '--external 7z' + extra: '--external 7z --base ${{ env.QT_MIRROR }}' - name: 'Get sources' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'true' fetch-depth: 10 @@ -43,33 +54,50 @@ jobs: export QIF_BIN_DIR=${{ runner.temp }}/Qt/Tools/QtInstallerFramework/${{ env.QIF_VERSION }}/bin bash deploy/build_linux.sh + - name: 'Pack installer' + run: cd deploy && tar -cf AmneziaVPN_Linux_Installer.tar AmneziaVPN_Linux_Installer.bin + - name: 'Upload installer artifact' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: AmneziaVPN_Linux_installer - path: deploy/AmneziaVPN_Linux_Installer + name: AmneziaVPN_Linux_installer.tar + path: deploy/AmneziaVPN_Linux_Installer.tar retention-days: 7 + - name: 'Upload unpacked artifact' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: AmneziaVPN_Linux_unpacked path: deploy/AppDir retention-days: 7 + - name: 'Upload translations artifact' + uses: actions/upload-artifact@v4 + with: + name: AmneziaVPN_translations + path: client/translations + retention-days: 7 + # ------------------------------------------------------ Build-Windows: - name: Build-Windows runs-on: windows-latest env: - QT_VERSION: 6.4.1 - QIF_VERSION: 4.5 + QT_VERSION: 6.6.2 + QIF_VERSION: 4.7 BUILD_ARCH: 64 + PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }} + PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }} + DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }} + DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }} + DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }} + FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }} + PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }} steps: - name: 'Get sources' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'true' fetch-depth: 10 @@ -89,12 +117,12 @@ jobs: setup-python: 'true' tools: 'tools_ifw' set-env: 'true' - extra: '--external 7z' + extra: '--external 7z --base ${{ env.QT_MIRROR }}' - name: 'Setup mvsc' uses: ilammy/msvc-dev-cmd@v1 with: - arch: 'x64' + arch: 'x64' - name: 'Build project' shell: cmd @@ -105,13 +133,14 @@ jobs: call deploy\\build_windows.bat - name: 'Upload installer artifact' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: AmneziaVPN_Windows_installer path: AmneziaVPN_x${{ env.BUILD_ARCH }}.exe retention-days: 7 + - name: 'Upload unpacked artifact' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: AmneziaVPN_Windows_unpacked path: deploy\\build_${{ env.BUILD_ARCH }}\\client\\Release @@ -119,19 +148,26 @@ jobs: # ------------------------------------------------------ - Build-IOS: - name: 'Build-IOS' - runs-on: macos-latest + Build-iOS: + runs-on: macos-13 env: - QT_VERSION: 6.4.1 - QIF_VERSION: 4.4 + QT_VERSION: 6.6.2 + CC: cc + CXX: c++ + PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }} + PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }} + DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }} + DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }} + DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }} + FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }} + PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }} steps: - name: 'Setup xcode' uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: '13.4' + xcode-version: '15.2' - name: 'Install desktop Qt' uses: jurplel/install-qt-action@v3 @@ -139,25 +175,29 @@ jobs: version: ${{ env.QT_VERSION }} host: 'mac' target: 'desktop' + modules: 'qtremoteobjects qt5compat qtshadertools qtmultimedia' arch: 'clang_64' - modules: 'qtremoteobjects qt5compat qtshadertools' dir: ${{ runner.temp }} set-env: 'true' + extra: '--base ${{ env.QT_MIRROR }}' - - name: 'Install ios Qt' + - name: 'Install iOS Qt' uses: jurplel/install-qt-action@v3 with: version: ${{ env.QT_VERSION }} host: 'mac' target: 'ios' - modules: 'qtremoteobjects qt5compat qtshadertools' + modules: 'qtremoteobjects qt5compat qtshadertools qtmultimedia' dir: ${{ runner.temp }} setup-python: 'true' set-env: 'true' - extra: '--external 7z' + extra: '--external 7z --base ${{ env.QT_MIRROR }}' - name: 'Install go' - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 + with: + go-version: '1.24' + cache: false - name: 'Setup gomobile' run: | @@ -166,7 +206,7 @@ jobs: gomobile init - name: 'Get sources' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'true' fetch-depth: 10 @@ -174,40 +214,60 @@ jobs: - name: 'Setup ccache' uses: hendrikmuhs/ccache-action@v1.2 + - name: 'Install dependencies' + run: pip install jsonschema jinja2 + - name: 'Build project' run: | + git submodule update --init --recursive export QT_BIN_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/ios/bin" export QT_MACOS_ROOT_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/macos" - export QT_IOS_BIN=$QT_BIN_DIR export PATH=$PATH:~/go/bin - mkdir build-ios - $QT_IOS_BIN/qt-cmake . -B build-ios -GXcode -DQT_HOST_PATH=$QT_MACOS_ROOT_DIR + sh deploy/build_ios.sh | \ + sed -e '/-Xcc -DPROD_AGW_PUBLIC_KEY/,/-Xcc/ { /-Xcc/!d; }' -e '/-Xcc -DPROD_AGW_PUBLIC_KEY/d' | \ + sed -e '/-Xcc -DDEV_AGW_PUBLIC_KEY/,/-Xcc/ { /-Xcc/!d; }' -e '/-Xcc -DDEV_AGW_PUBLIC_KEY/d' | \ + sed -e '/-DPROD_AGW_PUBLIC_KEY/,/-D/ { /-D/!d; }' -e '/-DPROD_AGW_PUBLIC_KEY/d' | \ + sed -e '/-DDEV_AGW_PUBLIC_KEY/,/-D/ { /-D/!d; }' -e '/-DDEV_AGW_PUBLIC_KEY/d' + env: + IOS_TRUST_CERT_BASE64: ${{ secrets.IOS_TRUST_CERT_BASE64 }} + IOS_SIGNING_CERT_BASE64: ${{ secrets.IOS_SIGNING_CERT_BASE64 }} + IOS_SIGNING_CERT_PASSWORD: ${{ secrets.IOS_SIGNING_CERT_PASSWORD }} + APPSTORE_CONNECT_KEY_ID: ${{ secrets.APPSTORE_CONNECT_KEY_ID }} + APPSTORE_CONNECT_ISSUER_ID: ${{ secrets.APPSTORE_CONNECT_ISSUER_ID }} + APPSTORE_CONNECT_PRIVATE_KEY: ${{ secrets.APPSTORE_CONNECT_PRIVATE_KEY }} + IOS_APP_PROVISIONING_PROFILE: ${{ secrets.IOS_APP_PROVISIONING_PROFILE }} + IOS_NE_PROVISIONING_PROFILE: ${{ secrets.IOS_NE_PROVISIONING_PROFILE }} -# - name: iOS Build/Release With Multiple Targets Action -# uses: kumarsunil0007/build-ios-action@latest +# - name: 'Upload appstore .ipa and dSYMs to artifacts' +# uses: actions/upload-artifact@v4 # with: -# project-path: build-ios/AmneziaVPN.xcodeproj -# p12-base64: ~/amnezia-vpn/amnezia-ios-certificates/certs/distribution/443886Q5PL.p12 -# mobileprovision-base64: ~/amnezia-vpn/amnezia-ios-certificates/testprofilez.mobileprovision -# code-signing-identity: 'iOS Distribution' -# team-id: 'X7UJ388FXK' -# configuration: Release +# name: app-store ipa & dsyms +# path: | +# ${{ github.workspace }}/AmneziaVPN-iOS.ipa +# ${{ github.workspace }}/*.app.dSYM.zip +# retention-days: 7 # ------------------------------------------------------ - Build-MacOS: - name: 'Build-MacOS' + Build-MacOS-old: runs-on: macos-latest env: - QT_VERSION: 6.4.1 - QIF_VERSION: 4.5 + # Keep compat with MacOS 10.15 aka Catalina by Qt 6.4 + QT_VERSION: 6.4.3 + PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }} + PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }} + DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }} + DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }} + DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }} + FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }} + PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }} steps: - name: 'Setup xcode' uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: '13.4' + xcode-version: '15.4.0' - name: 'Install Qt' uses: jurplel/install-qt-action@v3 @@ -219,12 +279,12 @@ jobs: modules: 'qtremoteobjects qt5compat qtshadertools' dir: ${{ runner.temp }} setup-python: 'true' - tools: 'tools_ifw' set-env: 'true' - extra: '--external 7z' + extra: '--external 7z --base ${{ env.QT_MIRROR }}' + - name: 'Get sources' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'true' fetch-depth: 10 @@ -235,17 +295,80 @@ jobs: - name: 'Build project' run: | export QT_BIN_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/macos/bin" - export QIF_BIN_DIR="${{ runner.temp }}/Qt/Tools/QtInstallerFramework/${{ env.QIF_VERSION }}/bin" bash deploy/build_macos.sh - name: 'Upload installer artifact' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 + with: + name: AmneziaVPN_MacOS_old_installer + path: deploy/build/pkg/AmneziaVPN.pkg + retention-days: 7 + + - name: 'Upload unpacked artifact' + uses: actions/upload-artifact@v4 + with: + name: AmneziaVPN_MacOS_old_unpacked + path: deploy/build/client/AmneziaVPN.app + retention-days: 7 + +# ------------------------------------------------------ + + Build-MacOS: + runs-on: macos-latest + + env: + QT_VERSION: 6.8.0 + PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }} + PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }} + DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }} + DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }} + DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }} + FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }} + PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }} + + steps: + - name: 'Setup xcode' + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '15.4.0' + + - name: 'Install Qt' + uses: jurplel/install-qt-action@v3 + with: + version: ${{ env.QT_VERSION }} + host: 'mac' + target: 'desktop' + arch: 'clang_64' + modules: 'qtremoteobjects qt5compat qtshadertools' + dir: ${{ runner.temp }} + setup-python: 'true' + set-env: 'true' + extra: '--external 7z --base ${{ env.QT_MIRROR }}' + + + - name: 'Get sources' + uses: actions/checkout@v4 + with: + submodules: 'true' + fetch-depth: 10 + + - name: 'Setup ccache' + uses: hendrikmuhs/ccache-action@v1.2 + + - name: 'Build project' + run: | + export QT_BIN_DIR="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/macos/bin" + bash deploy/build_macos.sh + + - name: 'Upload installer artifact' + uses: actions/upload-artifact@v4 with: name: AmneziaVPN_MacOS_installer - path: AmneziaVPN.dmg + path: deploy/build/pkg/AmneziaVPN.pkg retention-days: 7 + - name: 'Upload unpacked artifact' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: AmneziaVPN_MacOS_unpacked path: deploy/build/client/AmneziaVPN.app @@ -254,73 +377,178 @@ jobs: # ------------------------------------------------------ Build-Android: - name: 'Build-Android' runs-on: ubuntu-latest - continue-on-error: true - - strategy: - matrix: - arch: ['android_x86_64', 'android_x86'] #, 'android_armv7', 'android_arm64_v8a'] env: - QT_VERSION: 6.4.1 - QIF_VERSION: 4.5 + ANDROID_BUILD_PLATFORM: android-34 + QT_VERSION: 6.7.3 + QT_MODULES: 'qtremoteobjects qt5compat qtimageformats qtshadertools' + PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }} + PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }} + DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }} + DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }} + DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }} + FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }} + PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }} steps: - name: 'Install desktop Qt' - uses: jurplel/install-qt-action@v3 + uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} host: 'linux' target: 'desktop' - arch: 'gcc_64' - modules: 'qtremoteobjects qt5compat qtimageformats qtshadertools' + arch: 'linux_gcc_64' + modules: ${{ env.QT_MODULES }} dir: ${{ runner.temp }} - setup-python: 'true' - set-env: 'true' - extra: '--external 7z' + py7zrversion: '==0.22.*' + extra: '--base ${{ env.QT_MIRROR }}' - - name: 'Install android Qt' - uses: jurplel/install-qt-action@v3 + - name: 'Install android_x86_64 Qt' + uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} host: 'linux' target: 'android' - arch: ${{ matrix.arch }} - modules: 'qtremoteobjects qt5compat qtimageformats qtshadertools' + arch: 'android_x86_64' + modules: ${{ env.QT_MODULES }} dir: ${{ runner.temp }} - setup-python: 'true' - set-env: 'true' - extra: '--external 7z' + py7zrversion: '==0.22.*' + extra: '--base ${{ env.QT_MIRROR }}' + + - name: 'Install android_x86 Qt' + uses: jurplel/install-qt-action@v4 + with: + version: ${{ env.QT_VERSION }} + host: 'linux' + target: 'android' + arch: 'android_x86' + modules: ${{ env.QT_MODULES }} + dir: ${{ runner.temp }} + py7zrversion: '==0.22.*' + extra: '--base ${{ env.QT_MIRROR }}' + + - name: 'Install android_armv7 Qt' + uses: jurplel/install-qt-action@v4 + with: + version: ${{ env.QT_VERSION }} + host: 'linux' + target: 'android' + arch: 'android_armv7' + modules: ${{ env.QT_MODULES }} + dir: ${{ runner.temp }} + py7zrversion: '==0.22.*' + extra: '--base ${{ env.QT_MIRROR }}' + + - name: 'Install android_arm64_v8a Qt' + uses: jurplel/install-qt-action@v4 + with: + version: ${{ env.QT_VERSION }} + host: 'linux' + target: 'android' + arch: 'android_arm64_v8a' + modules: ${{ env.QT_MODULES }} + dir: ${{ runner.temp }} + py7zrversion: '==0.22.*' + extra: '--base ${{ env.QT_MIRROR }}' + + - name: 'Grant execute permission for qt-cmake' + shell: bash + run: | + chmod +x ${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/android_x86_64/bin/qt-cmake - name: 'Get sources' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'true' - fetch-depth: 10 - name: 'Setup ccache' uses: hendrikmuhs/ccache-action@v1.2 - name: 'Setup Java' - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '11' + java-version: '17' + cache: 'gradle' + + - name: 'Setup Android NDK' + id: setup-ndk + uses: nttld/setup-ndk@v1 + with: + ndk-version: 'r26b' + + - name: 'Decode keystore secret to file' + env: + KEYSTORE_BASE64: ${{ secrets.ANDROID_RELEASE_KEYSTORE_BASE64 }} + shell: bash + run: | + echo $KEYSTORE_BASE64 | base64 --decode > android.keystore - name: 'Build project' - run: | - export QT_HOST_PATH="${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/gcc_64" - export NDK_VERSION=23c - export ANDROID_NDK_PLATFORM=android-23 - export ANDROID_NDK_HOME=${{ runner.temp }}/android-ndk-r${NDK_VERSION} - export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME - export ANDROID_CURRENT_ARCH=${{ matrix.arch }} + env: + ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }} + QT_HOST_PATH: ${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/gcc_64 + ANDROID_KEYSTORE_PATH: ${{ github.workspace }}/android.keystore + ANDROID_KEYSTORE_KEY_ALIAS: ${{ secrets.ANDROID_RELEASE_KEYSTORE_KEY_ALIAS }} + ANDROID_KEYSTORE_KEY_PASS: ${{ secrets.ANDROID_RELEASE_KEYSTORE_KEY_PASS }} + shell: bash + run: ./deploy/build_android.sh --aab --apk all --build-platform ${{ env.ANDROID_BUILD_PLATFORM }} - if [ ! -f $ANDROID_NDK_ROOT/ndk-build ]; then - wget https://dl.google.com/android/repository/android-ndk-r${NDK_VERSION}-linux.zip -qO ${{ runner.temp }}/ndk.zip && - unzip -q -d ${{ runner.temp }} ${{ runner.temp }}/ndk.zip ; - fi + - name: 'Upload x86_64 apk' + uses: actions/upload-artifact@v4 + with: + name: AmneziaVPN-android-x86_64 + path: deploy/build/AmneziaVPN-x86_64-release.apk + compression-level: 0 + retention-days: 7 - export QT_BIN_DIR=${{ runner.temp }}/Qt/${{ env.QT_VERSION }}/${{ matrix.arch }}/bin - bash deploy/build_android.sh + - name: 'Upload x86 apk' + uses: actions/upload-artifact@v4 + with: + name: AmneziaVPN-android-x86 + path: deploy/build/AmneziaVPN-x86-release.apk + compression-level: 0 + retention-days: 7 + + - name: 'Upload arm64-v8a apk' + uses: actions/upload-artifact@v4 + with: + name: AmneziaVPN-android-arm64-v8a + path: deploy/build/AmneziaVPN-arm64-v8a-release.apk + compression-level: 0 + retention-days: 7 + + - name: 'Upload armeabi-v7a apk' + uses: actions/upload-artifact@v4 + with: + name: AmneziaVPN-android-armeabi-v7a + path: deploy/build/AmneziaVPN-armeabi-v7a-release.apk + compression-level: 0 + retention-days: 7 + + - name: 'Upload aab' + uses: actions/upload-artifact@v4 + with: + name: AmneziaVPN-android + path: deploy/build/AmneziaVPN-release.aab + compression-level: 0 + retention-days: 7 + + Extra: + runs-on: ubuntu-latest + steps: + - name: Search a corresponding PR + uses: octokit/request-action@v2.x + id: pull_request + with: + route: GET /repos/${{ github.repository }}/pulls + head: ${{ github.repository_owner }}:${{ github.ref_name }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Add PR link to build summary + if: ${{ fromJSON(steps.pull_request.outputs.data)[0].number != '' }} + run: | + echo "Pull request:" >> $GITHUB_STEP_SUMMARY + echo "[[#${{ fromJSON(steps.pull_request.outputs.data)[0].number }}] ${{ fromJSON(steps.pull_request.outputs.data)[0].title }}](${{ fromJSON(steps.pull_request.outputs.data)[0].html_url }})" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/tag-deploy.yml b/.github/workflows/tag-deploy.yml index b88390f4..31c334bf 100644 --- a/.github/workflows/tag-deploy.yml +++ b/.github/workflows/tag-deploy.yml @@ -15,6 +15,13 @@ jobs: env: QT_VERSION: 6.4.1 QIF_VERSION: 4.5 + PROD_AGW_PUBLIC_KEY: ${{ secrets.PROD_AGW_PUBLIC_KEY }} + PROD_S3_ENDPOINT: ${{ secrets.PROD_S3_ENDPOINT }} + DEV_AGW_PUBLIC_KEY: ${{ secrets.DEV_AGW_PUBLIC_KEY }} + DEV_AGW_ENDPOINT: ${{ secrets.DEV_AGW_ENDPOINT }} + DEV_S3_ENDPOINT: ${{ secrets.DEV_S3_ENDPOINT }} + FREE_V2_ENDPOINT: ${{ secrets.FREE_V2_ENDPOINT }} + PREM_V1_ENDPOINT: ${{ secrets.PREM_V1_ENDPOINT }} steps: - name: 'Install desktop Qt' diff --git a/.github/workflows/tag-upload.yml b/.github/workflows/tag-upload.yml new file mode 100644 index 00000000..9ac2da58 --- /dev/null +++ b/.github/workflows/tag-upload.yml @@ -0,0 +1,41 @@ +name: 'Upload a new version' + +on: + workflow_dispatch: + inputs: + RELEASE_VERSION: + description: 'Release version (e.g. 1.2.3.4)' + required: true + type: string + +jobs: + Upload-S3: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.RELEASE_VERSION }} + sparse-checkout: | + CMakeLists.txt + deploy/deploy_s3.sh + sparse-checkout-cone-mode: false + + - name: Verify git tag + run: | + TAG_NAME=${{ inputs.RELEASE_VERSION }} + CMAKE_TAG=$(grep 'project.*VERSION' CMakeLists.txt | sed -E 's/.* ([0-9]+.[0-9]+.[0-9]+.[0-9]+)$/\1/') + if [[ "$TAG_NAME" == "$CMAKE_TAG" ]]; then + echo "Git tag ($TAG_NAME) matches CMakeLists.txt version ($CMAKE_TAG)." + else + echo "::error::Mismatch: Git tag ($TAG_NAME) != CMakeLists.txt version ($CMAKE_TAG). Exiting with error..." + exit 1 + fi + + - name: Setup Rclone + uses: AnimMouse/setup-rclone@v1 + with: + rclone_config: ${{ secrets.RCLONE_CONFIG }} + + - name: Send dist to S3 + run: bash deploy/deploy_s3.sh ${{ inputs.RELEASE_VERSION }} diff --git a/.gitignore b/.gitignore index 562b2ee7..503adc2d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ deploy/build/* deploy/build_32/* deploy/build_64/* winbuild*.bat +.cache/ # Qt-es @@ -129,4 +130,11 @@ captures/ client/3rd/ShadowSocks/ss_ios.xcconfig # UML generated pics -out/ \ No newline at end of file +out/ + +# CMake files +CMakeFiles/ + +ios-ne-build.sh +macos-ne-build.sh +macos-signed-build.sh diff --git a/.gitmodules b/.gitmodules index 5ef4a9b1..90edb582 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,42 +1,16 @@ -[submodule "3rd/QtSsh"] - path = 3rd/QtSsh - url = https://github.com/amnezia-vpn/QtSsh.git -[submodule "client/3rd/wireguard-tools"] - path = client/3rd/wireguard-tools - url = https://github.com/WireGuard/wireguard-tools/ -[submodule "client/3rd/wireguard-apple"] - path = client/3rd/wireguard-apple - url = https://github.com/WireGuard/wireguard-apple -[submodule "client/3rd/OpenVPNAdapter"] - path = client/3rd/OpenVPNAdapter - url = https://github.com/ss-abramchuk/OpenVPNAdapter.git -[submodule "client/3rd/ShadowPath"] - path = client/3rd/ShadowPath - url = https://github.com/qman9501/ShadowPath -[submodule "client/3rd/outline-go-tun2socks"] - path = client/3rd/outline-go-tun2socks - url = https://github.com/Jigsaw-Code/outline-go-tun2socks.git -[submodule "client/3rd/CocoaAsyncSocket"] - path = client/3rd/CocoaAsyncSocket - url = https://github.com/robbiehanson/CocoaAsyncSocket.git -[submodule "client/3rd/CocoaLumberjack"] - path = client/3rd/CocoaLumberjack - url = https://github.com/CocoaLumberjack/CocoaLumberjack.git [submodule "client/3rd/qtkeychain"] path = client/3rd/qtkeychain url = https://github.com/frankosterfeld/qtkeychain.git -[submodule "client/3rd/libssh"] - path = client/3rd/libssh - url = https://git.libssh.org/projects/libssh.git/ -[submodule "client/3rd/zlib"] - path = client/3rd/zlib - url = https://github.com/madler/zlib.git -[submodule "deploy/amnezia-ios-certificates"] - path = deploy/amnezia-ios-certificates - url = https://github.com/amnezia-vpn/amnezia-ios-certificates.git [submodule "client/3rd/SortFilterProxyModel"] path = client/3rd/SortFilterProxyModel url = https://github.com/mitchcurtis/SortFilterProxyModel.git -[submodule "client/3rd/mbedtls"] - path = client/3rd/mbedtls - url = https://github.com/Mbed-TLS/mbedtls.git +[submodule "client/3rd-prebuilt"] + path = client/3rd-prebuilt + url = https://github.com/amnezia-vpn/3rd-prebuilt + branch = feature/special-handshake +[submodule "client/3rd/amneziawg-apple"] + path = client/3rd/amneziawg-apple + url = https://github.com/amnezia-vpn/amneziawg-apple +[submodule "client/3rd/QSimpleCrypto"] + path = client/3rd/QSimpleCrypto + url = https://github.com/amnezia-vpn/QSimpleCrypto.git diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 00000000..2defeb74 --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,47 @@ +FROM gitpod/workspace-full-vnc + +USER gitpod + +RUN sudo apt-get -q update \ + && sudo apt-get install -yq \ + build-essential \ + libgl1-mesa-dev \ + libgstreamer-gl1.0-0 \ + libpulse-dev \ + libsecret-1-dev \ + libxcb-glx0 \ + libxcb-icccm4 \ + libxcb-image0 \ + libxcb-keysyms1 \ + libxcb-randr0 \ + libxcb-render-util0 \ + libxcb-render0 \ + libxcb-shape0 \ + libxcb-shm0 \ + libxcb-sync1 \ + libxcb-util1 \ + libxcb-xfixes0 \ + libxcb-xinerama0 \ + libxcb1 \ + libxkbcommon-dev \ + libxkbcommon-x11-0 \ + libxcb-xkb-dev \ + p7zip-full \ + && sudo rm -rf /var/lib/apt/lists/* + +RUN sudo pip3 install aqtinstall + +ARG QT_VERSION=6.4.1 +ARG QT_ARCH=gcc_64 + +ARG QT_DIR=/opt/qt +RUN sudo aqt install-qt --outputdir ${QT_DIR} linux desktop ${QT_VERSION} ${QT_ARCH} --modules \ + qtremoteobjects \ + qt5compat \ + qtshadertools +ENV QT_BIN_DIR=${QT_DIR}/${QT_VERSION}/${QT_ARCH}/bin + +ARG QIF_VERSION=4.5 +ARG QIF_DIR=/opt/qif +RUN sudo aqt install-tool --outputdir ${QIF_DIR} linux desktop tools_ifw +ENV QIF_BIN_DIR=${QIF_DIR}/Tools/QtInstallerFramework/${QIF_VERSION}/bin diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 00000000..20136846 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,8 @@ +tasks: +- init: >- + deploy/build_linux.sh +image: + file: .gitpod.Dockerfile +vscode: + extensions: + - llvm-vs-code-extensions.vscode-clangd diff --git a/AmneziaVPN.pro b/AmneziaVPN.pro deleted file mode 100644 index eea6d034..00000000 --- a/AmneziaVPN.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = client - -!ios:!android { - SUBDIRS += service -} diff --git a/CMakeLists.txt b/CMakeLists.txt index f1e5d37c..fec613de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,36 @@ cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR) set(PROJECT AmneziaVPN) -project(${PROJECT}) -if(ANDROID) - set(QT_ANDROID_BUILD_ALL_ABIS ON) +project(${PROJECT} VERSION 4.8.8.1 + DESCRIPTION "AmneziaVPN" + HOMEPAGE_URL "https://amnezia.org/" +) + +string(TIMESTAMP CURRENT_DATE "%Y-%m-%d") +set(RELEASE_DATE "${CURRENT_DATE}") + +set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH}) +set(APP_ANDROID_VERSION_CODE 2087) + +if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(MZ_PLATFORM_NAME "linux") +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + set(MZ_PLATFORM_NAME "windows") +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(MZ_PLATFORM_NAME "macos") +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android") + set(MZ_PLATFORM_NAME "android") +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "iOS") + set(MZ_PLATFORM_NAME "ios") +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") + set(MZ_PLATFORM_NAME "wasm") endif() +set(QT_BUILD_TOOLS_WHEN_CROSS_COMPILING ON) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + if(APPLE AND NOT IOS) set(CMAKE_OSX_ARCHITECTURES "x86_64") endif() @@ -15,4 +39,6 @@ add_subdirectory(client) if(NOT IOS AND NOT ANDROID) add_subdirectory(service) + + include(${CMAKE_SOURCE_DIR}/deploy/installer/config.cmake) endif() diff --git a/README.md b/README.md index c183de36..992c3ad0 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,61 @@ # Amnezia VPN -## _The best client for self-hosted VPN_ -[![Build Status](https://github.com/amnezia-vpn/desktop-client/actions/workflows/deploy.yml/badge.svg?branch=dev)] +### _The best client for self-hosted VPN_ -Amnezia is a VPN client with the key feature of deploying your own VPN server on you virtual server. + +[![Build Status](https://github.com/amnezia-vpn/amnezia-client/actions/workflows/deploy.yml/badge.svg?branch=dev)](https://github.com/amnezia-vpn/amnezia-client/actions/workflows/deploy.yml?query=branch:dev) +[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/amnezia-vpn/amnezia-client) + +### [English]([https://github.com/amnezia-vpn/amnezia-client/blob/dev/README_RU.md](https://github.com/amnezia-vpn/amnezia-client/tree/dev?tab=readme-ov-file#)) | [Русский](https://github.com/amnezia-vpn/amnezia-client/blob/dev/README_RU.md) + + +[Amnezia](https://amnezia.org) is an open-source VPN client, with a key feature that enables you to deploy your own VPN server on your server. + +[![Image](https://github.com/amnezia-vpn/amnezia-client/blob/dev/metadata/img-readme/uipic4.png)](https://amnezia.org) + +### [Website](https://amnezia.org) | [Alt website link](https://storage.googleapis.com/amnezia/amnezia.org) | [Documentation](https://docs.amnezia.org) | [Troubleshooting](https://docs.amnezia.org/troubleshooting) + +> [!TIP] +> If the [Amnezia website](https://amnezia.org) is blocked in your region, you can use an [Alternative website link](https://storage.googleapis.com/amnezia/amnezia.org ). + + + + +[All releases](https://github.com/amnezia-vpn/amnezia-client/releases) + +
+ + ## Features -- Very easy to use - enter your ip address, ssh login and password, and Amnezia client will automatically install VPN docker containers to your server and connect to VPN. -- OpenVPN and OpenVPN over ShadowSocks protocols support. -- Custom VPN routing mode support - add any sites to client to enable VPN only for them. -- Windows and MacOS support. -- Unsecure sharing connection profile for family use. + +- Very easy to use - enter your IP address, SSH login, password and Amnezia will automatically install VPN docker containers to your server and connect to the VPN. +- Classic VPN-protocols: OpenVPN, WireGuard and IKEv2 protocols. +- Protocols with traffic Masking (Obfuscation): OpenVPN over [Cloak](https://github.com/cbeuw/Cloak) plugin, Shadowsocks (OpenVPN over Shadowsocks), [AmneziaWG](https://docs.amnezia.org/documentation/amnezia-wg/) and XRay. +- Split tunneling support - add any sites to the client to enable VPN only for them or add Apps (only for Android and Desktop). +- Windows, MacOS, Linux, Android, iOS releases. +- Support for AmneziaWG protocol configuration on [Keenetic beta firmware](https://docs.keenetic.com/ua/air/kn-1611/en/6319-latest-development-release.html#UUID-186c4108-5afd-c10b-f38a-cdff6c17fab3_section-idm33192196168192-improved). + +## Links + +- [https://amnezia.org](https://amnezia.org) - Project website | [Alternative link (mirror)](https://storage.googleapis.com/kldscp/amnezia.org) +- [https://docs.amnezia.org](https://docs.amnezia.org) - Documentation +- [https://www.reddit.com/r/AmneziaVPN](https://www.reddit.com/r/AmneziaVPN) - Reddit +- [https://t.me/amnezia_vpn_en](https://t.me/amnezia_vpn_en) - Telegram support channel (English) +- [https://t.me/amnezia_vpn_ir](https://t.me/amnezia_vpn_ir) - Telegram support channel (Farsi) +- [https://t.me/amnezia_vpn_mm](https://t.me/amnezia_vpn_mm) - Telegram support channel (Myanmar) +- [https://t.me/amnezia_vpn](https://t.me/amnezia_vpn) - Telegram support channel (Russian) +- [https://vpnpay.io/en/amnezia-premium/](https://vpnpay.io/en/amnezia-premium/) - Amnezia Premium ## Tech -AmneziaVPN uses a number of open source projects to work: +AmneziaVPN uses several open-source projects to work: - [OpenSSL](https://www.openssl.org/) - [OpenVPN](https://openvpn.net/) -- [ShadowSocks](https://shadowsocks.org/) +- [Shadowsocks](https://shadowsocks.org/) - [Qt](https://www.qt.io/) -- [QtSsh](https://github.com/jaredtao/QtSsh) - forked form Qt Creator +- [LibSsh](https://libssh.org) - forked from Qt Creator - and more... ## Checking out the source code @@ -28,47 +63,66 @@ AmneziaVPN uses a number of open source projects to work: Make sure to pull all submodules after checking out the repo. ```bash -git submodule update --init +git submodule update --init --recursive ``` ## Development Want to contribute? Welcome! +### Help with translations + +Download the most actual translation files. + +Go to ["Actions" tab](https://github.com/amnezia-vpn/amnezia-client/actions?query=is%3Asuccess+branch%3Adev), click on the first line. +Then scroll down to the "Artifacts" section and download "AmneziaVPN_translations". + +Unzip this file. +Each *.ts file contains strings for one corresponding language. + +Translate or correct some strings in one or multiple *.ts files and commit them back to this repository into the ``client/translations`` folder. +You can do it via a web-interface or any other method you're familiar with. + ### Building sources and deployment -Easiest way to build your own executables - is to fork project and configure [Travis CI](https://travis-ci.com/) -Or you can build sources manually using Qt Creator. Qt >= 14.2 supported. -Look to the `build_macos.sh` and `build_windows.bat` scripts in `deploy` folder for details. -### How to build iOS app from source code on MacOS +Check deploy folder for build scripts. -1. First, make sure you have [XCode](https://developer.apple.com/xcode/) installed, -at least version 12 or higher. +### How to build an iOS app from source code on MacOS -2. We use `qmake` to generate the XCode project and then we "patch" it to add -extra components such as the wireguard, the browser bridge and so on. We patch -the XCode project using [xcodeproj](https://github.com/CocoaPods/Xcodeproj). To -install it: -```bash -gem install xcodeproj # probably you want to run this command with `sudo` -``` -3. You also need to install go >= v1.16. If you don't have it done already, +1. First, make sure you have [XCode](https://developer.apple.com/xcode/) installed, at least version 14 or higher. + +2. We use QT to generate the XCode project. We need QT version 6.6.2. Install QT for MacOS [here](https://doc.qt.io/qt-6/macos.html) or [QT Online Installer](https://www.qt.io/download-open-source). Required modules: + - MacOS + - iOS + - Qt 5 Compatibility Module + - Qt Shader Tools + - Additional Libraries: + - Qt Image Formats + - Qt Multimedia + - Qt Remote Objects + +3. Install CMake if required. We recommend CMake version 3.25. You can install CMake [here](https://cmake.org/download/) + +4. You also need to install go >= v1.16. If you don't have it installed already, download go from the [official website](https://golang.org/dl/) or use Homebrew. -Latest version is recommended. - -4. Navigate inside client folder and generate the XCode project using our script: +The latest version is recommended. Install gomobile ```bash -cd client -./scripts/apple_compile.sh ios +export PATH=$PATH:~/go/bin +go install golang.org/x/mobile/cmd/gomobile@latest +gomobile init ``` -If you have more than one version of Qt installed, you'll most likely get -a "`qmake` cannot be found in your `$PATH`" error. In this case run this script -using QT\IOS\_BIN env to set the path for the Qt5 macos build bin folder. -For example, the path could look like this: +5. Build the project ```bash -QT_IOS_BIN="/Users/username/Qt/6.4.1/ios/bin" ./scripts/apple_compile.sh ios +export QT_BIN_DIR="/Qt//ios/bin" +export QT_MACOS_ROOT_DIR="/Qt//macos" +export QT_IOS_BIN=$QT_BIN_DIR +export PATH=$PATH:~/go/bin +mkdir build-ios +$QT_IOS_BIN/qt-cmake . -B build-ios -GXcode -DQT_HOST_PATH=$QT_MACOS_ROOT_DIR ``` +Replace PATH-TO-QT-FOLDER and QT-VERSION to your environment + If you get `gomobile: command not found` make sure to set PATH to the location of the bin folder where gomobile was installed. Usually, it's in `GOPATH`. @@ -76,63 +130,67 @@ of the bin folder where gomobile was installed. Usually, it's in `GOPATH`. export PATH=$(PATH):/path/to/GOPATH/bin ``` -5. Xcode should automatically open. You can then run/test/archive/ship the app. +6. Open the XCode project. You can then run /test/archive/ship the app. -If build fails with the following error +If the build fails with the following error ``` make: *** [$(PROJECTDIR)/client/build/AmneziaVPN.build/Debug-iphoneos/wireguard-go-bridge/goroot/.prepared] Error 1 ``` -Add a user defined variable to both AmneziaVPN and WireGuardNetworkExtension targets' build settings with +Add a user-defined variable to both AmneziaVPN and WireGuardNetworkExtension targets' build settings with key `PATH` and value `${PATH}/path/to/bin/folder/with/go/executable`, e.g. `${PATH}:/usr/local/go/bin`. -if above error still persists on you M1 Mac, then most proably you need to install arch based cmake +if the above error persists on your M1 Mac, then most probably you need to install arch based CMake ``` arch -arm64 brew install cmake ``` -Build might fail with "source files not found" error the first time you try it, because modern XCode build system compiles -dependencies in parallel, and some dependencies end up being built after the ones that -require them. In this case simply restart the build. +Build might fail with the "source files not found" error the first time you try it, because the modern XCode build system compiles dependencies in parallel, and some dependencies end up being built after the ones that +require them. In this case, simply restart the build. ## How to build the Android app -_tested on Mac OS_ + +_Tested on Mac OS_ The Android app has the following requirements: * JDK 11 * Android platform SDK 33 -* cmake 3.25.0 +* CMake 3.25.0 -After you have installed QT, QT Creator and Android Studio installed, you need to configure QT Creator correctly. Click in the top menu bar on `QT Creator` -> `Preferences` -> `Devices` and select the tab `Android`. - * set path to jdk 11 - * set path to Android SDK ($ANDROID_HOME) +After you have installed QT, QT Creator, and Android Studio, you need to configure QT Creator correctly. -In case you get errors regarding missing SDK or 'sdkmanager not running', you cannot fix them by correcting the paths and you have some spare GBs on your disk, you can let QT Creator install all requirements by choosing an empty folder for `Android SDK location` and click on `Set Up SDK`. Be aware: This will install a second Android SDK and NDK on your machine! +- Click in the top menu bar on `QT Creator` -> `Preferences` -> `Devices` and select the tab `Android`. +- Set path to JDK 11 +- Set path to Android SDK (`$ANDROID_HOME`) -Double check that the right cmake version is configured: Click on `QT Creator` -> `Preferences` and click on the side menu on `Kits`. Under the center content view's `Kits` tab you'll find an entry `CMake Tool`. If the default selected CMake version is lower than 3.25.0, install on your system CMake >= 3.25.0 and choose `System CMake at ` from the drop down list. If this entry is missing, you either have not installed CMake yet or QT Creator hasn't found the path to it. In that case click in the preferences window on the side menu item `CMake`, then on the tab `Tools`in the center content view and finally on the Button `Add` to set the path to your installed CMake. +In case you get errors regarding missing SDK or 'SDK manager not running', you cannot fix them by correcting the paths. If you have some spare GBs on your disk, you can let QT Creator install all requirements by choosing an empty folder for `Android SDK location` and clicking on `Set Up SDK`. Be aware: This will install a second Android SDK and NDK on your machine!  +Double-check that the right CMake version is configured:  Click on `QT Creator` -> `Preferences` and click on the side menu on `Kits`. Under the center content view's `Kits` tab, you'll find an entry for `CMake Tool`. If the default selected CMake version is lower than 3.25.0, install on your system CMake >= 3.25.0 and choose `System CMake at ` from the drop-down list. If this entry is missing, you either have not installed CMake yet or QT Creator hasn't found the path to it. In that case, click in the preferences window on the side menu item `CMake`, then on the tab `Tools` in the center content view, and finally on the button `Add` to set the path to your installed CMake.  +Please make sure that you have selected Android Platform SDK 33 for your project: click in the main view's side menu on `Projects`, and on the left, you'll see a section `Build & Run` showing different Android build targets. You can select any of them, Amnezia VPN's project setup is designed in a way that all Android targets will be built. Click on the targets submenu item `Build` and scroll in the center content view to `Build Steps`. Click on `Details` at the end of the headline `Build Android APK` (the `Details` button might be hidden in case the QT Creator Window is not running in full screen!). Here we are: Choose `android-33` as `Android Build Platform SDK`. -Please make sure that you have selected Android Platform SDK 33 for your project: click in the main view's side menu on on `Projects`, on the left you'll see a section `Build & Run` showing different Android build targets. You can select any of them, Amnezia VPN's project setup is designed in a way that always all Android targets will be build. Click on the targets submenu item `Build` and scroll in the center content view to `Build Steps`. Click on `Details` at the end of the headline `Build Android APK` (The `Details` button might be hidden in case QT Creator Window is not running in full screen!). Here we are: choose `android-33` as `Android Build platfrom SDK`. - -That's it you should be ready to compile the project from QT Creator! +That's it! You should be ready to compile the project from QT Creator! ### Development flow -After you've hit the build button, QT-Creator copies the whole project to a folder in the repositories parent directory. The folder should look something like `build-amnezia-client-Android_Qt__Clang_-`. -If you want to develop Amnezia VPNs Android components written in Kotlin, such as components using system APIs, you need to import the generated project in Android Studio with `build-amnezia-client-Android_Qt__Clang_-/client/android-build` as the projects root directory. While you should be able to compile the generated project from Android Studio, you cannot work directly in the repository's Android project. So whenever you are confident with your work in the generated proejct, you'll need to copy and paste the affected files to the corresponding path in the repositories Android project so that you can add and commit your changes! -You may face compiling issues in QT Creator after you've worked in Android Studio on the generated project. Just do a `./gradlew clean` in the geneated project's root directory (`/client/android-build/.`) and you should be good to continue. +After you've hit the build button, QT-Creator copies the whole project to a folder in the repository parent directory. The folder should look something like `build-amnezia-client-Android_Qt__Clang_-`. +If you want to develop Amnezia VPNs Android components written in Kotlin, such as components using system APIs, you need to import the generated project in Android Studio with `build-amnezia-client-Android_Qt__Clang_-/client/android-build` as the projects root directory. While you should be able to compile the generated project from Android Studio, you cannot work directly in the repository's Android project. So whenever you are confident with your work in the generated project, you'll need to copy and paste the affected files to the corresponding path in the repository's Android project so that you can add and commit your changes! + +You may face compiling issues in QT Creator after you've worked in Android Studio on the generated project. Just do a `./gradlew clean` in the generated project's root directory (`/client/android-build/.`) and you should be good to go. ## License -GPL v.3 -## Contacts -[https://t.me/amnezia_vpn_en](https://t.me/amnezia_vpn_en) - Telegram support channel (English) -[https://t.me/amnezia_vpn](https://t.me/amnezia_vpn) - Telegram support channel (Russian) -[https://signal.group/...](https://signal.group/#CjQKIB2gUf8QH_IXnOJMGQWMDjYz9cNfmRQipGWLFiIgc4MwEhAKBONrSiWHvoUFbbD0xwdh) - Signal channel -[https://amnezia.org](https://amnezia.org) - project website +GPL v3.0 ## Donate -Bitcoin: bc1qn9rhsffuxwnhcuuu4qzrwp4upkrq94xnh8r26u -XMR: 48spms39jt1L2L5vyw2RQW6CXD6odUd4jFu19GZcDyKKQV9U88wsJVjSbL4CfRys37jVMdoaWVPSvezCQPhHXUW5UKLqUp3 -payeer.com: P2561305 -ko-fi.com: [https://ko-fi.com/amnezia_vpn](https://ko-fi.com/amnezia_vpn) + +Patreon: [https://www.patreon.com/amneziavpn](https://www.patreon.com/amneziavpn) + +Bitcoin: bc1qmhtgcf9637rl3kqyy22r2a8wa8laka4t9rx2mf
+USDT BEP20: 0x6abD576765a826f87D1D95183438f9408C901bE4
+USDT TRC20: TELAitazF1MZGmiNjTcnxDjEiH5oe7LC9d
+XMR: 48spms39jt1L2L5vyw2RQW6CXD6odUd4jFu19GZcDyKKQV9U88wsJVjSbL4CfRys37jVMdoaWVPSvezCQPhHXUW5UKLqUp3
+TON: UQDpU1CyKRmg7L8mNScKk9FRc2SlESuI7N-Hby4nX-CcVmns +## Acknowledgments + +This project is tested with BrowserStack. +We express our gratitude to [BrowserStack](https://www.browserstack.com) for supporting our project. diff --git a/README_RU.md b/README_RU.md new file mode 100644 index 00000000..44681875 --- /dev/null +++ b/README_RU.md @@ -0,0 +1,181 @@ +# Amnezia VPN + +### _Лучший клиент для создания VPN на собственном сервере_ + +[![Build Status](https://github.com/amnezia-vpn/amnezia-client/actions/workflows/deploy.yml/badge.svg?branch=dev)](https://github.com/amnezia-vpn/amnezia-client/actions/workflows/deploy.yml?query=branch:dev) +[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/amnezia-vpn/amnezia-client) + +### [English](https://github.com/amnezia-vpn/amnezia-client/blob/dev/README.md) | Русский +[AmneziaVPN](https://amnezia.org) — это open source VPN-клиент, ключевая особенность которого заключается в возможности развернуть собственный VPN на вашем сервере. + +[![Image](https://github.com/amnezia-vpn/amnezia-client/blob/dev/metadata/img-readme/uipic4.png)](https://amnezia.org) + +### [Сайт](https://amnezia.org) | [Зеркало сайта](https://storage.googleapis.com/amnezia/amnezia.org) | [Документация](https://docs.amnezia.org) | [Решение проблем](https://docs.amnezia.org/troubleshooting) + +> [!TIP] +> Если [сайт Amnezia](https://amnezia.org) заблокирован в вашем регионе, вы можете воспользоваться [ссылкой на зеркало](https://storage.googleapis.com/amnezia/amnezia.org). + + + + +[Все релизы](https://github.com/amnezia-vpn/amnezia-client/releases) + +
+ + + +## Особенности + +- Простой в использовании — введите IP-адрес, SSH-логин и пароль, и Amnezia автоматически установит VPN-контейнеры Docker на ваш сервер и подключится к VPN. +- Классические VPN-протоколы: OpenVPN, WireGuard и IKEv2. +- Протоколы с маскировкой трафика (обфускацией): OpenVPN с плагином [Cloak](https://github.com/cbeuw/Cloak), Shadowsocks (OpenVPN over Shadowsocks), [AmneziaWG](https://docs.amnezia.org/documentation/amnezia-wg/) and XRay. +- Поддержка Split Tunneling — добавляйте любые сайты или приложения в список, чтобы включить VPN только для них. +- Поддерживает платформы: Windows, macOS, Linux, Android, iOS. +- Поддержка конфигурации протокола AmneziaWG на [бета-прошивке Keenetic](https://docs.keenetic.com/ua/air/kn-1611/en/6319-latest-development-release.html#UUID-186c4108-5afd-c10b-f38a-cdff6c17fab3_section-idm33192196168192-improved). + +## Ссылки + +- [https://amnezia.org](https://amnezia.org) - Веб-сайт проекта | [Альтернативная ссылка (зеркало)](https://storage.googleapis.com/kldscp/amnezia.org) +- [https://docs.amnezia.org](https://docs.amnezia.org) - Документация +- [https://www.reddit.com/r/AmneziaVPN](https://www.reddit.com/r/AmneziaVPN) - Reddit +- [https://t.me/amnezia_vpn_en](https://t.me/amnezia_vpn_en) - Канал поддержки в Telegram (Английский) +- [https://t.me/amnezia_vpn_ir](https://t.me/amnezia_vpn_ir) - Канал поддержки в Telegram (Фарси) +- [https://t.me/amnezia_vpn_mm](https://t.me/amnezia_vpn_mm) - Канал поддержки в Telegram (Мьянма) +- [https://t.me/amnezia_vpn](https://t.me/amnezia_vpn) - Канал поддержки в Telegram (Русский) +- [https://vpnpay.io/en/amnezia-premium/](https://vpnpay.io/en/amnezia-premium/) - Amnezia Premium | [Зеркало](https://storage.googleapis.com/kldscp/vpnpay.io/ru/amnezia-premium\) + +## Технологии + +AmneziaVPN использует несколько проектов с открытым исходным кодом: + +- [OpenSSL](https://www.openssl.org/) +- [OpenVPN](https://openvpn.net/) +- [Shadowsocks](https://shadowsocks.org/) +- [Qt](https://www.qt.io/) +- [LibSsh](https://libssh.org) +- и другие... + +## Проверка исходного кода +После клонирования репозитория обязательно загрузите все подмодули. + +```bash +git submodule update --init --recursive +``` + + +## Разработка +Хотите внести свой вклад? Добро пожаловать! + +### Помощь с переводами + +Загрузите самые актуальные файлы перевода. + +Перейдите на [вкладку "Actions"](https://github.com/amnezia-vpn/amnezia-client/actions?query=is%3Asuccess+branch%3Adev), нажмите на первую строку. Затем прокрутите вниз до раздела "Artifacts" и скачайте "AmneziaVPN_translations". + +Распакуйте этот файл. Каждый файл с расширением *.ts содержит строки для соответствующего языка. + +Переведите или исправьте строки в одном или нескольких файлах *.ts и загрузите их обратно в этот репозиторий в папку ``client/translations``. Это можно сделать через веб-интерфейс или любым другим знакомым вам способом. + +### Сборка исходного кода и деплой +Проверьте папку deploy для скриптов сборки. + +### Как собрать iOS-приложение из исходного кода на MacOS +1. Убедитесь, что у вас установлен Xcode версии 14 или выше. +2. Для генерации проекта Xcode используется QT. Требуется версия QT 6.6.2. Установите QT для MacOS здесь или через QT Online Installer. Необходимые модули: +- MacOS +- iOS +- Модуль совместимости с Qt 5 +- Qt Shader Tools +- Дополнительные библиотеки: + - Qt Image Formats + - Qt Multimedia + - Qt Remote Objects + + +3. Установите CMake, если это необходимо. Рекомендуемая версия — 3.25. Скачать CMake можно здесь. +4. Установите Go версии >= v1.16. Если Go ещё не установлен, скачайте его с [официального сайта](https://golang.org/dl/) или используйте Homebrew. Установите gomobile: + +```bash +export PATH=$PATH:~/go/bin +go install golang.org/x/mobile/cmd/gomobile@latest +gomobile init +``` + +5. Соберите проект: +```bash +export QT_BIN_DIR="/Qt//ios/bin" +export QT_MACOS_ROOT_DIR="/Qt//macos" +export QT_IOS_BIN=$QT_BIN_DIR +export PATH=$PATH:~/go/bin +mkdir build-ios +$QT_IOS_BIN/qt-cmake . -B build-ios -GXcode -DQT_HOST_PATH=$QT_MACOS_ROOT_DIR +``` +Замените и на ваши значения. + +Если появляется ошибка gomobile: command not found, убедитесь, что PATH настроен на папку bin, где установлен gomobile: +```bash +export PATH=$(PATH):/path/to/GOPATH/bin +``` + +6. Откройте проект в Xcode. Теперь вы можете тестировать, архивировать или публиковать приложение. + +Если сборка завершится с ошибкой: +``` +make: *** +[$(PROJECTDIR)/client/build/AmneziaVPN.build/Debug-iphoneos/wireguard-go-bridge/goroot/.prepared] +Error 1 +``` +Добавьте пользовательскую переменную PATH в настройки сборки для целей AmneziaVPN и WireGuardNetworkExtension с ключом `PATH` и значением `${PATH}/path/to/bin/folder/with/go/executable`, e.g. `${PATH}:/usr/local/go/bin`. + +Если ошибка повторяется на Mac с M1, установите версию CMake для архитектуры ARM: +``` +arch -arm64 brew install cmake +``` + + При первой попытке сборка может завершиться с ошибкой source files not found. Это происходит из-за параллельной компиляции зависимостей в XCode. Просто перезапустите сборку. + + +## Как собрать Android-приложение +Сборка тестировалась на MacOS. Требования: +- JDK 11 +- Android SDK 33 +- CMake 3.25.0 + +Установите QT, QT Creator и Android Studio. +Настройте QT Creator: + +- В меню QT Creator перейдите в `QT Creator` -> `Preferences` -> `Devices` ->`Android`. +- Укажите путь к JDK 11. +- Укажите путь к Android SDK (`$ANDROID_HOME`) + +Если вы сталкиваетесь с ошибками, связанными с отсутствием SDK или сообщением «SDK manager not running», их нельзя исправить просто корректировкой путей. Если у вас есть несколько свободных гигабайт на диске, вы можете позволить Qt Creator установить все необходимые компоненты, выбрав пустую папку для расположения Android SDK и нажав кнопку **Set Up SDK**. Учтите: это установит второй Android SDK и NDK на вашем компьютере! + +Убедитесь, что настроена правильная версия CMake: перейдите в **Qt Creator -> Preferences** и в боковом меню выберите пункт **Kits**. В центральной части окна, на вкладке **Kits**, найдите запись для инструмента **CMake Tool**. Если выбранная по умолчанию версия CMake ниже 3.25.0, установите на свою систему CMake версии 3.25.0 или выше, а затем выберите опцию **System CMake at <путь>** из выпадающего списка. Если этот пункт отсутствует, это может означать, что вы еще не установили CMake, или Qt Creator не смог найти путь к нему. В таком случае в окне **Preferences** перейдите в боковое меню **CMake**, затем во вкладку **Tools** в центральной части окна и нажмите кнопку **Add**, чтобы указать путь к установленному CMake. + +Убедитесь, что для вашего проекта выбрана Android Platform SDK 33: в главном окне на боковой панели выберите пункт **Projects**, и слева вы увидите раздел **Build & Run**, показывающий различные целевые Android-платформы. Вы можете выбрать любую из них, так как настройка проекта Amnezia VPN разработана таким образом, чтобы все Android-цели могли быть собраны. Перейдите в подраздел **Build** и прокрутите центральную часть окна до раздела **Build Steps**. Нажмите **Details** в заголовке **Build Android APK** (кнопка **Details** может быть скрыта, если окно Qt Creator не запущено в полноэкранном режиме!). Вот здесь выберите **android-33** в качестве Android Build Platform SDK. + +### Разработка Android-компонентов + +После сборки QT Creator копирует проект в отдельную папку, например, `build-amnezia-client-Android_Qt__Clang_-`. Для разработки Android-компонентов откройте сгенерированный проект в Android Studio, указав папку `build-amnezia-client-Android_Qt__Clang_-/client/android-build` в качестве корневой. +Изменения в сгенерированном проекте нужно вручную перенести в репозиторий. После этого можно коммитить изменения. +Если возникают проблемы со сборкой в QT Creator после работы в Android Studio, выполните команду `./gradlew clean` в корневой папке сгенерированного проекта (`/client/android-build/.`). + + +## Лицензия + +GPL v3.0 + +## Донаты + +Patreon: [https://www.patreon.com/amneziavpn](https://www.patreon.com/amneziavpn) + +Bitcoin: bc1qmhtgcf9637rl3kqyy22r2a8wa8laka4t9rx2mf
+USDT BEP20: 0x6abD576765a826f87D1D95183438f9408C901bE4
+USDT TRC20: TELAitazF1MZGmiNjTcnxDjEiH5oe7LC9d
+XMR: 48spms39jt1L2L5vyw2RQW6CXD6odUd4jFu19GZcDyKKQV9U88wsJVjSbL4CfRys37jVMdoaWVPSvezCQPhHXUW5UKLqUp3
+TON: UQDpU1CyKRmg7L8mNScKk9FRc2SlESuI7N-Hby4nX-CcVmns + +## Благодарности + +Этот проект тестируется с помощью BrowserStack. +Мы выражаем благодарность [BrowserStack](https://www.browserstack.com) за поддержку нашего проекта. diff --git a/client/3rd-prebuilt b/client/3rd-prebuilt new file mode 160000 index 00000000..840b7b07 --- /dev/null +++ b/client/3rd-prebuilt @@ -0,0 +1 @@ +Subproject commit 840b7b070e6ac8b90dda2fac6e98859b23727c0c diff --git a/client/3rd/CocoaAsyncSocket b/client/3rd/CocoaAsyncSocket deleted file mode 160000 index 5ddba5e7..00000000 --- a/client/3rd/CocoaAsyncSocket +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5ddba5e72f38e56010dbfac08b44478ee5000c0c diff --git a/client/3rd/CocoaLumberjack b/client/3rd/CocoaLumberjack deleted file mode 160000 index 70f04b1d..00000000 --- a/client/3rd/CocoaLumberjack +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 70f04b1dc56dfc4fa954a39ca269382825f2a6e3 diff --git a/client/3rd/OpenSSL/include/openssl/__DECC_INCLUDE_EPILOGUE.H b/client/3rd/OpenSSL/include/openssl/__DECC_INCLUDE_EPILOGUE.H deleted file mode 100644 index ad0a5f56..00000000 --- a/client/3rd/OpenSSL/include/openssl/__DECC_INCLUDE_EPILOGUE.H +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * This file is only used by HP C/C++ on VMS, and is included automatically - * after each header file from this directory - */ - -/* - * The C++ compiler doesn't understand these pragmas, even though it - * understands the corresponding command line qualifier. - */ -#ifndef __cplusplus -/* restore state. Must correspond to the save in __decc_include_prologue.h */ -# pragma names restore -#endif diff --git a/client/3rd/OpenSSL/include/openssl/__DECC_INCLUDE_PROLOGUE.H b/client/3rd/OpenSSL/include/openssl/__DECC_INCLUDE_PROLOGUE.H deleted file mode 100644 index 5f5513e8..00000000 --- a/client/3rd/OpenSSL/include/openssl/__DECC_INCLUDE_PROLOGUE.H +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * This file is only used by HP C/C++ on VMS, and is included automatically - * after each header file from this directory - */ - -/* - * The C++ compiler doesn't understand these pragmas, even though it - * understands the corresponding command line qualifier. - */ -#ifndef __cplusplus -/* save state */ -# pragma names save -/* have the compiler shorten symbols larger than 31 chars to 23 chars - * followed by a 8 hex char CRC - */ -# pragma names as_is,shortened -#endif diff --git a/client/3rd/OpenSSL/include/openssl/aes.h b/client/3rd/OpenSSL/include/openssl/aes.h deleted file mode 100644 index 245c552a..00000000 --- a/client/3rd/OpenSSL/include/openssl/aes.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_AES_H -# define HEADER_AES_H - -# include - -# include -# ifdef __cplusplus -extern "C" { -# endif - -# define AES_ENCRYPT 1 -# define AES_DECRYPT 0 - -/* - * Because array size can't be a const in C, the following two are macros. - * Both sizes are in bytes. - */ -# define AES_MAXNR 14 -# define AES_BLOCK_SIZE 16 - -/* This should be a hidden type, but EVP requires that the size be known */ -struct aes_key_st { -# ifdef AES_LONG - unsigned long rd_key[4 * (AES_MAXNR + 1)]; -# else - unsigned int rd_key[4 * (AES_MAXNR + 1)]; -# endif - int rounds; -}; -typedef struct aes_key_st AES_KEY; - -const char *AES_options(void); - -int AES_set_encrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key); -int AES_set_decrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key); - -void AES_encrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); -void AES_decrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); - -void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key, const int enc); -void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, const int enc); -void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, int *num, const int enc); -void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, int *num, const int enc); -void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, int *num, const int enc); -void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, int *num); -/* NB: the IV is _two_ blocks long */ -void AES_ige_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, const int enc); -/* NB: the IV is _four_ blocks long */ -void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - const AES_KEY *key2, const unsigned char *ivec, - const int enc); - -int AES_wrap_key(AES_KEY *key, const unsigned char *iv, - unsigned char *out, - const unsigned char *in, unsigned int inlen); -int AES_unwrap_key(AES_KEY *key, const unsigned char *iv, - unsigned char *out, - const unsigned char *in, unsigned int inlen); - - -# ifdef __cplusplus -} -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/applink.c b/client/3rd/OpenSSL/include/openssl/applink.c deleted file mode 100644 index 903e6d47..00000000 --- a/client/3rd/OpenSSL/include/openssl/applink.c +++ /dev/null @@ -1,138 +0,0 @@ - /* - * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#define APPLINK_STDIN 1 -#define APPLINK_STDOUT 2 -#define APPLINK_STDERR 3 -#define APPLINK_FPRINTF 4 -#define APPLINK_FGETS 5 -#define APPLINK_FREAD 6 -#define APPLINK_FWRITE 7 -#define APPLINK_FSETMOD 8 -#define APPLINK_FEOF 9 -#define APPLINK_FCLOSE 10 /* should not be used */ - -#define APPLINK_FOPEN 11 /* solely for completeness */ -#define APPLINK_FSEEK 12 -#define APPLINK_FTELL 13 -#define APPLINK_FFLUSH 14 -#define APPLINK_FERROR 15 -#define APPLINK_CLEARERR 16 -#define APPLINK_FILENO 17 /* to be used with below */ - -#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */ -#define APPLINK_READ 19 -#define APPLINK_WRITE 20 -#define APPLINK_LSEEK 21 -#define APPLINK_CLOSE 22 -#define APPLINK_MAX 22 /* always same as last macro */ - -#ifndef APPMACROS_ONLY -# include -# include -# include - -static void *app_stdin(void) -{ - return stdin; -} - -static void *app_stdout(void) -{ - return stdout; -} - -static void *app_stderr(void) -{ - return stderr; -} - -static int app_feof(FILE *fp) -{ - return feof(fp); -} - -static int app_ferror(FILE *fp) -{ - return ferror(fp); -} - -static void app_clearerr(FILE *fp) -{ - clearerr(fp); -} - -static int app_fileno(FILE *fp) -{ - return _fileno(fp); -} - -static int app_fsetmod(FILE *fp, char mod) -{ - return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT); -} - -#ifdef __cplusplus -extern "C" { -#endif - -__declspec(dllexport) -void ** -# if defined(__BORLANDC__) -/* - * __stdcall appears to be the only way to get the name - * decoration right with Borland C. Otherwise it works - * purely incidentally, as we pass no parameters. - */ -__stdcall -# else -__cdecl -# endif -OPENSSL_Applink(void) -{ - static int once = 1; - static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] = - { (void *)APPLINK_MAX }; - - if (once) { - OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin; - OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout; - OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr; - OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf; - OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets; - OPENSSL_ApplinkTable[APPLINK_FREAD] = fread; - OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite; - OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod; - OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof; - OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose; - - OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen; - OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek; - OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell; - OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush; - OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror; - OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr; - OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno; - - OPENSSL_ApplinkTable[APPLINK_OPEN] = _open; - OPENSSL_ApplinkTable[APPLINK_READ] = _read; - OPENSSL_ApplinkTable[APPLINK_WRITE] = _write; - OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek; - OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close; - - once = 0; - } - - return OPENSSL_ApplinkTable; -} - -#ifdef __cplusplus -} -#endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/asn1.h b/client/3rd/OpenSSL/include/openssl/asn1.h deleted file mode 100644 index 9522eec1..00000000 --- a/client/3rd/OpenSSL/include/openssl/asn1.h +++ /dev/null @@ -1,886 +0,0 @@ -/* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ASN1_H -# define HEADER_ASN1_H - -# include -# include -# include -# include -# include -# include -# include - -# include -# if OPENSSL_API_COMPAT < 0x10100000L -# include -# endif - -# ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -# endif - -#ifdef __cplusplus -extern "C" { -#endif - -# define V_ASN1_UNIVERSAL 0x00 -# define V_ASN1_APPLICATION 0x40 -# define V_ASN1_CONTEXT_SPECIFIC 0x80 -# define V_ASN1_PRIVATE 0xc0 - -# define V_ASN1_CONSTRUCTED 0x20 -# define V_ASN1_PRIMITIVE_TAG 0x1f -# define V_ASN1_PRIMATIVE_TAG /*compat*/ V_ASN1_PRIMITIVE_TAG - -# define V_ASN1_APP_CHOOSE -2/* let the recipient choose */ -# define V_ASN1_OTHER -3/* used in ASN1_TYPE */ -# define V_ASN1_ANY -4/* used in ASN1 template code */ - -# define V_ASN1_UNDEF -1 -/* ASN.1 tag values */ -# define V_ASN1_EOC 0 -# define V_ASN1_BOOLEAN 1 /**/ -# define V_ASN1_INTEGER 2 -# define V_ASN1_BIT_STRING 3 -# define V_ASN1_OCTET_STRING 4 -# define V_ASN1_NULL 5 -# define V_ASN1_OBJECT 6 -# define V_ASN1_OBJECT_DESCRIPTOR 7 -# define V_ASN1_EXTERNAL 8 -# define V_ASN1_REAL 9 -# define V_ASN1_ENUMERATED 10 -# define V_ASN1_UTF8STRING 12 -# define V_ASN1_SEQUENCE 16 -# define V_ASN1_SET 17 -# define V_ASN1_NUMERICSTRING 18 /**/ -# define V_ASN1_PRINTABLESTRING 19 -# define V_ASN1_T61STRING 20 -# define V_ASN1_TELETEXSTRING 20/* alias */ -# define V_ASN1_VIDEOTEXSTRING 21 /**/ -# define V_ASN1_IA5STRING 22 -# define V_ASN1_UTCTIME 23 -# define V_ASN1_GENERALIZEDTIME 24 /**/ -# define V_ASN1_GRAPHICSTRING 25 /**/ -# define V_ASN1_ISO64STRING 26 /**/ -# define V_ASN1_VISIBLESTRING 26/* alias */ -# define V_ASN1_GENERALSTRING 27 /**/ -# define V_ASN1_UNIVERSALSTRING 28 /**/ -# define V_ASN1_BMPSTRING 30 - -/* - * NB the constants below are used internally by ASN1_INTEGER - * and ASN1_ENUMERATED to indicate the sign. They are *not* on - * the wire tag values. - */ - -# define V_ASN1_NEG 0x100 -# define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) -# define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) - -/* For use with d2i_ASN1_type_bytes() */ -# define B_ASN1_NUMERICSTRING 0x0001 -# define B_ASN1_PRINTABLESTRING 0x0002 -# define B_ASN1_T61STRING 0x0004 -# define B_ASN1_TELETEXSTRING 0x0004 -# define B_ASN1_VIDEOTEXSTRING 0x0008 -# define B_ASN1_IA5STRING 0x0010 -# define B_ASN1_GRAPHICSTRING 0x0020 -# define B_ASN1_ISO64STRING 0x0040 -# define B_ASN1_VISIBLESTRING 0x0040 -# define B_ASN1_GENERALSTRING 0x0080 -# define B_ASN1_UNIVERSALSTRING 0x0100 -# define B_ASN1_OCTET_STRING 0x0200 -# define B_ASN1_BIT_STRING 0x0400 -# define B_ASN1_BMPSTRING 0x0800 -# define B_ASN1_UNKNOWN 0x1000 -# define B_ASN1_UTF8STRING 0x2000 -# define B_ASN1_UTCTIME 0x4000 -# define B_ASN1_GENERALIZEDTIME 0x8000 -# define B_ASN1_SEQUENCE 0x10000 -/* For use with ASN1_mbstring_copy() */ -# define MBSTRING_FLAG 0x1000 -# define MBSTRING_UTF8 (MBSTRING_FLAG) -# define MBSTRING_ASC (MBSTRING_FLAG|1) -# define MBSTRING_BMP (MBSTRING_FLAG|2) -# define MBSTRING_UNIV (MBSTRING_FLAG|4) -# define SMIME_OLDMIME 0x400 -# define SMIME_CRLFEOL 0x800 -# define SMIME_STREAM 0x1000 - struct X509_algor_st; -DEFINE_STACK_OF(X509_ALGOR) - -# define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */ -/* - * This indicates that the ASN1_STRING is not a real value but just a place - * holder for the location where indefinite length constructed data should be - * inserted in the memory buffer - */ -# define ASN1_STRING_FLAG_NDEF 0x010 - -/* - * This flag is used by the CMS code to indicate that a string is not - * complete and is a place holder for content when it had all been accessed. - * The flag will be reset when content has been written to it. - */ - -# define ASN1_STRING_FLAG_CONT 0x020 -/* - * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING - * type. - */ -# define ASN1_STRING_FLAG_MSTRING 0x040 -/* String is embedded and only content should be freed */ -# define ASN1_STRING_FLAG_EMBED 0x080 -/* String should be parsed in RFC 5280's time format */ -# define ASN1_STRING_FLAG_X509_TIME 0x100 -/* This is the base type that holds just about everything :-) */ -struct asn1_string_st { - int length; - int type; - unsigned char *data; - /* - * The value of the following field depends on the type being held. It - * is mostly being used for BIT_STRING so if the input data has a - * non-zero 'unused bits' value, it will be handled correctly - */ - long flags; -}; - -/* - * ASN1_ENCODING structure: this is used to save the received encoding of an - * ASN1 type. This is useful to get round problems with invalid encodings - * which can break signatures. - */ - -typedef struct ASN1_ENCODING_st { - unsigned char *enc; /* DER encoding */ - long len; /* Length of encoding */ - int modified; /* set to 1 if 'enc' is invalid */ -} ASN1_ENCODING; - -/* Used with ASN1 LONG type: if a long is set to this it is omitted */ -# define ASN1_LONG_UNDEF 0x7fffffffL - -# define STABLE_FLAGS_MALLOC 0x01 -/* - * A zero passed to ASN1_STRING_TABLE_new_add for the flags is interpreted - * as "don't change" and STABLE_FLAGS_MALLOC is always set. By setting - * STABLE_FLAGS_MALLOC only we can clear the existing value. Use the alias - * STABLE_FLAGS_CLEAR to reflect this. - */ -# define STABLE_FLAGS_CLEAR STABLE_FLAGS_MALLOC -# define STABLE_NO_MASK 0x02 -# define DIRSTRING_TYPE \ - (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) -# define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) - -typedef struct asn1_string_table_st { - int nid; - long minsize; - long maxsize; - unsigned long mask; - unsigned long flags; -} ASN1_STRING_TABLE; - -DEFINE_STACK_OF(ASN1_STRING_TABLE) - -/* size limits: this stuff is taken straight from RFC2459 */ - -# define ub_name 32768 -# define ub_common_name 64 -# define ub_locality_name 128 -# define ub_state_name 128 -# define ub_organization_name 64 -# define ub_organization_unit_name 64 -# define ub_title 64 -# define ub_email_address 128 - -/* - * Declarations for template structures: for full definitions see asn1t.h - */ -typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; -typedef struct ASN1_TLC_st ASN1_TLC; -/* This is just an opaque pointer */ -typedef struct ASN1_VALUE_st ASN1_VALUE; - -/* Declare ASN1 functions: the implement macro in in asn1t.h */ - -# define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type) - -# define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type) - -# define DECLARE_ASN1_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) - -# define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) - -# define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ - type *d2i_##name(type **a, const unsigned char **in, long len); \ - int i2d_##name(type *a, unsigned char **out); \ - DECLARE_ASN1_ITEM(itname) - -# define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ - type *d2i_##name(type **a, const unsigned char **in, long len); \ - int i2d_##name(const type *a, unsigned char **out); \ - DECLARE_ASN1_ITEM(name) - -# define DECLARE_ASN1_NDEF_FUNCTION(name) \ - int i2d_##name##_NDEF(name *a, unsigned char **out); - -# define DECLARE_ASN1_FUNCTIONS_const(name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS(name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name) - -# define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - type *name##_new(void); \ - void name##_free(type *a); - -# define DECLARE_ASN1_PRINT_FUNCTION(stname) \ - DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname) - -# define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \ - int fname##_print_ctx(BIO *out, stname *x, int indent, \ - const ASN1_PCTX *pctx); - -# define D2I_OF(type) type *(*)(type **,const unsigned char **,long) -# define I2D_OF(type) int (*)(type *,unsigned char **) -# define I2D_OF_const(type) int (*)(const type *,unsigned char **) - -# define CHECKED_D2I_OF(type, d2i) \ - ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0))) -# define CHECKED_I2D_OF(type, i2d) \ - ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0))) -# define CHECKED_NEW_OF(type, xnew) \ - ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0))) -# define CHECKED_PTR_OF(type, p) \ - ((void*) (1 ? p : (type*)0)) -# define CHECKED_PPTR_OF(type, p) \ - ((void**) (1 ? p : (type**)0)) - -# define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long) -# define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **) -# define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type) - -TYPEDEF_D2I2D_OF(void); - -/*- - * The following macros and typedefs allow an ASN1_ITEM - * to be embedded in a structure and referenced. Since - * the ASN1_ITEM pointers need to be globally accessible - * (possibly from shared libraries) they may exist in - * different forms. On platforms that support it the - * ASN1_ITEM structure itself will be globally exported. - * Other platforms will export a function that returns - * an ASN1_ITEM pointer. - * - * To handle both cases transparently the macros below - * should be used instead of hard coding an ASN1_ITEM - * pointer in a structure. - * - * The structure will look like this: - * - * typedef struct SOMETHING_st { - * ... - * ASN1_ITEM_EXP *iptr; - * ... - * } SOMETHING; - * - * It would be initialised as e.g.: - * - * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; - * - * and the actual pointer extracted with: - * - * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); - * - * Finally an ASN1_ITEM pointer can be extracted from an - * appropriate reference with: ASN1_ITEM_rptr(X509). This - * would be used when a function takes an ASN1_ITEM * argument. - * - */ - -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - -/* ASN1_ITEM pointer exported type */ -typedef const ASN1_ITEM ASN1_ITEM_EXP; - -/* Macro to obtain ASN1_ITEM pointer from exported type */ -# define ASN1_ITEM_ptr(iptr) (iptr) - -/* Macro to include ASN1_ITEM pointer from base type */ -# define ASN1_ITEM_ref(iptr) (&(iptr##_it)) - -# define ASN1_ITEM_rptr(ref) (&(ref##_it)) - -# define DECLARE_ASN1_ITEM(name) \ - OPENSSL_EXTERN const ASN1_ITEM name##_it; - -# else - -/* - * Platforms that can't easily handle shared global variables are declared as - * functions returning ASN1_ITEM pointers. - */ - -/* ASN1_ITEM pointer exported type */ -typedef const ASN1_ITEM *ASN1_ITEM_EXP (void); - -/* Macro to obtain ASN1_ITEM pointer from exported type */ -# define ASN1_ITEM_ptr(iptr) (iptr()) - -/* Macro to include ASN1_ITEM pointer from base type */ -# define ASN1_ITEM_ref(iptr) (iptr##_it) - -# define ASN1_ITEM_rptr(ref) (ref##_it()) - -# define DECLARE_ASN1_ITEM(name) \ - const ASN1_ITEM * name##_it(void); - -# endif - -/* Parameters used by ASN1_STRING_print_ex() */ - -/* - * These determine which characters to escape: RFC2253 special characters, - * control characters and MSB set characters - */ - -# define ASN1_STRFLGS_ESC_2253 1 -# define ASN1_STRFLGS_ESC_CTRL 2 -# define ASN1_STRFLGS_ESC_MSB 4 - -/* - * This flag determines how we do escaping: normally RC2253 backslash only, - * set this to use backslash and quote. - */ - -# define ASN1_STRFLGS_ESC_QUOTE 8 - -/* These three flags are internal use only. */ - -/* Character is a valid PrintableString character */ -# define CHARTYPE_PRINTABLESTRING 0x10 -/* Character needs escaping if it is the first character */ -# define CHARTYPE_FIRST_ESC_2253 0x20 -/* Character needs escaping if it is the last character */ -# define CHARTYPE_LAST_ESC_2253 0x40 - -/* - * NB the internal flags are safely reused below by flags handled at the top - * level. - */ - -/* - * If this is set we convert all character strings to UTF8 first - */ - -# define ASN1_STRFLGS_UTF8_CONVERT 0x10 - -/* - * If this is set we don't attempt to interpret content: just assume all - * strings are 1 byte per character. This will produce some pretty odd - * looking output! - */ - -# define ASN1_STRFLGS_IGNORE_TYPE 0x20 - -/* If this is set we include the string type in the output */ -# define ASN1_STRFLGS_SHOW_TYPE 0x40 - -/* - * This determines which strings to display and which to 'dump' (hex dump of - * content octets or DER encoding). We can only dump non character strings or - * everything. If we don't dump 'unknown' they are interpreted as character - * strings with 1 octet per character and are subject to the usual escaping - * options. - */ - -# define ASN1_STRFLGS_DUMP_ALL 0x80 -# define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 - -/* - * These determine what 'dumping' does, we can dump the content octets or the - * DER encoding: both use the RFC2253 #XXXXX notation. - */ - -# define ASN1_STRFLGS_DUMP_DER 0x200 - -/* - * This flag specifies that RC2254 escaping shall be performed. - */ -#define ASN1_STRFLGS_ESC_2254 0x400 - -/* - * All the string flags consistent with RFC2253, escaping control characters - * isn't essential in RFC2253 but it is advisable anyway. - */ - -# define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ - ASN1_STRFLGS_ESC_CTRL | \ - ASN1_STRFLGS_ESC_MSB | \ - ASN1_STRFLGS_UTF8_CONVERT | \ - ASN1_STRFLGS_DUMP_UNKNOWN | \ - ASN1_STRFLGS_DUMP_DER) - -DEFINE_STACK_OF(ASN1_INTEGER) - -DEFINE_STACK_OF(ASN1_GENERALSTRING) - -DEFINE_STACK_OF(ASN1_UTF8STRING) - -typedef struct asn1_type_st { - int type; - union { - char *ptr; - ASN1_BOOLEAN boolean; - ASN1_STRING *asn1_string; - ASN1_OBJECT *object; - ASN1_INTEGER *integer; - ASN1_ENUMERATED *enumerated; - ASN1_BIT_STRING *bit_string; - ASN1_OCTET_STRING *octet_string; - ASN1_PRINTABLESTRING *printablestring; - ASN1_T61STRING *t61string; - ASN1_IA5STRING *ia5string; - ASN1_GENERALSTRING *generalstring; - ASN1_BMPSTRING *bmpstring; - ASN1_UNIVERSALSTRING *universalstring; - ASN1_UTCTIME *utctime; - ASN1_GENERALIZEDTIME *generalizedtime; - ASN1_VISIBLESTRING *visiblestring; - ASN1_UTF8STRING *utf8string; - /* - * set and sequence are left complete and still contain the set or - * sequence bytes - */ - ASN1_STRING *set; - ASN1_STRING *sequence; - ASN1_VALUE *asn1_value; - } value; -} ASN1_TYPE; - -DEFINE_STACK_OF(ASN1_TYPE) - -typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY; - -DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY) -DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY) - -/* This is used to contain a list of bit names */ -typedef struct BIT_STRING_BITNAME_st { - int bitnum; - const char *lname; - const char *sname; -} BIT_STRING_BITNAME; - -# define B_ASN1_TIME \ - B_ASN1_UTCTIME | \ - B_ASN1_GENERALIZEDTIME - -# define B_ASN1_PRINTABLE \ - B_ASN1_NUMERICSTRING| \ - B_ASN1_PRINTABLESTRING| \ - B_ASN1_T61STRING| \ - B_ASN1_IA5STRING| \ - B_ASN1_BIT_STRING| \ - B_ASN1_UNIVERSALSTRING|\ - B_ASN1_BMPSTRING|\ - B_ASN1_UTF8STRING|\ - B_ASN1_SEQUENCE|\ - B_ASN1_UNKNOWN - -# define B_ASN1_DIRECTORYSTRING \ - B_ASN1_PRINTABLESTRING| \ - B_ASN1_TELETEXSTRING|\ - B_ASN1_BMPSTRING|\ - B_ASN1_UNIVERSALSTRING|\ - B_ASN1_UTF8STRING - -# define B_ASN1_DISPLAYTEXT \ - B_ASN1_IA5STRING| \ - B_ASN1_VISIBLESTRING| \ - B_ASN1_BMPSTRING|\ - B_ASN1_UTF8STRING - -DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) - -int ASN1_TYPE_get(const ASN1_TYPE *a); -void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); -int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); -int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b); - -ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t); -void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t); - -ASN1_OBJECT *ASN1_OBJECT_new(void); -void ASN1_OBJECT_free(ASN1_OBJECT *a); -int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp); -ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, - long length); - -DECLARE_ASN1_ITEM(ASN1_OBJECT) - -DEFINE_STACK_OF(ASN1_OBJECT) - -ASN1_STRING *ASN1_STRING_new(void); -void ASN1_STRING_free(ASN1_STRING *a); -void ASN1_STRING_clear_free(ASN1_STRING *a); -int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str); -ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a); -ASN1_STRING *ASN1_STRING_type_new(int type); -int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b); - /* - * Since this is used to store all sorts of things, via macros, for now, - * make its data void * - */ -int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); -void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len); -int ASN1_STRING_length(const ASN1_STRING *x); -void ASN1_STRING_length_set(ASN1_STRING *x, int n); -int ASN1_STRING_type(const ASN1_STRING *x); -DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x)) -const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x); - -DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) -int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length); -int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); -int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n); -int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, - const unsigned char *flags, int flags_len); - -int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, - BIT_STRING_BITNAME *tbl, int indent); -int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl); -int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value, - BIT_STRING_BITNAME *tbl); - -DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) -ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, - long length); -ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x); -int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y); - -DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) - -int ASN1_UTCTIME_check(const ASN1_UTCTIME *a); -ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t); -ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, - int offset_day, long offset_sec); -int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); -int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); - -int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a); -ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, - time_t t); -ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, - time_t t, int offset_day, - long offset_sec); -int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); - -int ASN1_TIME_diff(int *pday, int *psec, - const ASN1_TIME *from, const ASN1_TIME *to); - -DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) -ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a); -int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, - const ASN1_OCTET_STRING *b); -int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, - int len); - -DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_NULL) -DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) - -int UTF8_getc(const unsigned char *str, int len, unsigned long *val); -int UTF8_putc(unsigned char *str, int len, unsigned long value); - -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) - -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) -DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) -DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) -DECLARE_ASN1_FUNCTIONS(ASN1_TIME) - -DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) - -ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t); -ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, - int offset_day, long offset_sec); -int ASN1_TIME_check(const ASN1_TIME *t); -ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t, - ASN1_GENERALIZEDTIME **out); -int ASN1_TIME_set_string(ASN1_TIME *s, const char *str); -int ASN1_TIME_set_string_X509(ASN1_TIME *s, const char *str); -int ASN1_TIME_to_tm(const ASN1_TIME *s, struct tm *tm); -int ASN1_TIME_normalize(ASN1_TIME *s); -int ASN1_TIME_cmp_time_t(const ASN1_TIME *s, time_t t); -int ASN1_TIME_compare(const ASN1_TIME *a, const ASN1_TIME *b); - -int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a); -int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size); -int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a); -int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size); -int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a); -int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size); -int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type); -int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a); - -int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num); -ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, - const char *sn, const char *ln); - -int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a); -int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r); -int ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a); -int ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r); - -int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); -long ASN1_INTEGER_get(const ASN1_INTEGER *a); -ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai); -BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn); - -int ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a); -int ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r); - - -int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); -long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a); -ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai); -BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn); - -/* General */ -/* given a string, return the correct type, max is the maximum length */ -int ASN1_PRINTABLE_type(const unsigned char *s, int max); - -unsigned long ASN1_tag2bit(int tag); - -/* SPECIALS */ -int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, - int *pclass, long omax); -int ASN1_check_infinite_end(unsigned char **p, long len); -int ASN1_const_check_infinite_end(const unsigned char **p, long len); -void ASN1_put_object(unsigned char **pp, int constructed, int length, - int tag, int xclass); -int ASN1_put_eoc(unsigned char **pp); -int ASN1_object_size(int constructed, int length, int tag); - -/* Used to implement other functions */ -void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x); - -# define ASN1_dup_of(type,i2d,d2i,x) \ - ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \ - CHECKED_D2I_OF(type, d2i), \ - CHECKED_PTR_OF(type, x))) - -# define ASN1_dup_of_const(type,i2d,d2i,x) \ - ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \ - CHECKED_D2I_OF(type, d2i), \ - CHECKED_PTR_OF(const type, x))) - -void *ASN1_item_dup(const ASN1_ITEM *it, void *x); - -/* ASN1 alloc/free macros for when a type is only used internally */ - -# define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type)) -# define M_ASN1_free_of(x, type) \ - ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type)) - -# ifndef OPENSSL_NO_STDIO -void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x); - -# define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ - ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \ - CHECKED_D2I_OF(type, d2i), \ - in, \ - CHECKED_PPTR_OF(type, x))) - -void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); -int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x); - -# define ASN1_i2d_fp_of(type,i2d,out,x) \ - (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \ - out, \ - CHECKED_PTR_OF(type, x))) - -# define ASN1_i2d_fp_of_const(type,i2d,out,x) \ - (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \ - out, \ - CHECKED_PTR_OF(const type, x))) - -int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); -int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags); -# endif - -int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in); - -void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x); - -# define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ - ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \ - CHECKED_D2I_OF(type, d2i), \ - in, \ - CHECKED_PPTR_OF(type, x))) - -void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x); -int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x); - -# define ASN1_i2d_bio_of(type,i2d,out,x) \ - (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \ - out, \ - CHECKED_PTR_OF(type, x))) - -# define ASN1_i2d_bio_of_const(type,i2d,out,x) \ - (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \ - out, \ - CHECKED_PTR_OF(const type, x))) - -int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); -int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a); -int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a); -int ASN1_TIME_print(BIO *fp, const ASN1_TIME *a); -int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v); -int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags); -int ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int off); -int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, - unsigned char *buf, int off); -int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent); -int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, - int dump); -const char *ASN1_tag2str(int tag); - -/* Used to load and write Netscape format cert */ - -int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); - -int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len); -int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len); -int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, - unsigned char *data, int len); -int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num, - unsigned char *data, int max_len); - -void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it); - -ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, - ASN1_OCTET_STRING **oct); - -void ASN1_STRING_set_default_mask(unsigned long mask); -int ASN1_STRING_set_default_mask_asc(const char *p); -unsigned long ASN1_STRING_get_default_mask(void); -int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, - int inform, unsigned long mask); -int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, - int inform, unsigned long mask, - long minsize, long maxsize); - -ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, - const unsigned char *in, int inlen, - int inform, int nid); -ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); -int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); -void ASN1_STRING_TABLE_cleanup(void); - -/* ASN1 template functions */ - -/* Old API compatible functions */ -ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); -void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); -ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, - long len, const ASN1_ITEM *it); -int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); -int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, - const ASN1_ITEM *it); - -void ASN1_add_oid_module(void); -void ASN1_add_stable_module(void); - -ASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf); -ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf); -int ASN1_str2mask(const char *str, unsigned long *pmask); - -/* ASN1 Print flags */ - -/* Indicate missing OPTIONAL fields */ -# define ASN1_PCTX_FLAGS_SHOW_ABSENT 0x001 -/* Mark start and end of SEQUENCE */ -# define ASN1_PCTX_FLAGS_SHOW_SEQUENCE 0x002 -/* Mark start and end of SEQUENCE/SET OF */ -# define ASN1_PCTX_FLAGS_SHOW_SSOF 0x004 -/* Show the ASN1 type of primitives */ -# define ASN1_PCTX_FLAGS_SHOW_TYPE 0x008 -/* Don't show ASN1 type of ANY */ -# define ASN1_PCTX_FLAGS_NO_ANY_TYPE 0x010 -/* Don't show ASN1 type of MSTRINGs */ -# define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE 0x020 -/* Don't show field names in SEQUENCE */ -# define ASN1_PCTX_FLAGS_NO_FIELD_NAME 0x040 -/* Show structure names of each SEQUENCE field */ -# define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME 0x080 -/* Don't show structure name even at top level */ -# define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100 - -int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent, - const ASN1_ITEM *it, const ASN1_PCTX *pctx); -ASN1_PCTX *ASN1_PCTX_new(void); -void ASN1_PCTX_free(ASN1_PCTX *p); -unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p); -void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p); -void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p); -void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p); -void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p); -void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags); - -ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx)); -void ASN1_SCTX_free(ASN1_SCTX *p); -const ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p); -const ASN1_TEMPLATE *ASN1_SCTX_get_template(ASN1_SCTX *p); -unsigned long ASN1_SCTX_get_flags(ASN1_SCTX *p); -void ASN1_SCTX_set_app_data(ASN1_SCTX *p, void *data); -void *ASN1_SCTX_get_app_data(ASN1_SCTX *p); - -const BIO_METHOD *BIO_f_asn1(void); - -BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it); - -int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, - const ASN1_ITEM *it); -int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, - const char *hdr, const ASN1_ITEM *it); -int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, - int ctype_nid, int econt_nid, - STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it); -ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); -int SMIME_crlf_copy(BIO *in, BIO *out, int flags); -int SMIME_text(BIO *in, BIO *out); - -const ASN1_ITEM *ASN1_ITEM_lookup(const char *name); -const ASN1_ITEM *ASN1_ITEM_get(size_t i); - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/asn1_mac.h b/client/3rd/OpenSSL/include/openssl/asn1_mac.h deleted file mode 100644 index 7ac1782a..00000000 --- a/client/3rd/OpenSSL/include/openssl/asn1_mac.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#error "This file is obsolete; please update your software." diff --git a/client/3rd/OpenSSL/include/openssl/asn1err.h b/client/3rd/OpenSSL/include/openssl/asn1err.h deleted file mode 100644 index e1ad1fef..00000000 --- a/client/3rd/OpenSSL/include/openssl/asn1err.h +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ASN1ERR_H -# define HEADER_ASN1ERR_H - -# include - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_ASN1_strings(void); - -/* - * ASN1 function codes. - */ -# define ASN1_F_A2D_ASN1_OBJECT 100 -# define ASN1_F_A2I_ASN1_INTEGER 102 -# define ASN1_F_A2I_ASN1_STRING 103 -# define ASN1_F_APPEND_EXP 176 -# define ASN1_F_ASN1_BIO_INIT 113 -# define ASN1_F_ASN1_BIT_STRING_SET_BIT 183 -# define ASN1_F_ASN1_CB 177 -# define ASN1_F_ASN1_CHECK_TLEN 104 -# define ASN1_F_ASN1_COLLECT 106 -# define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108 -# define ASN1_F_ASN1_D2I_FP 109 -# define ASN1_F_ASN1_D2I_READ_BIO 107 -# define ASN1_F_ASN1_DIGEST 184 -# define ASN1_F_ASN1_DO_ADB 110 -# define ASN1_F_ASN1_DO_LOCK 233 -# define ASN1_F_ASN1_DUP 111 -# define ASN1_F_ASN1_ENC_SAVE 115 -# define ASN1_F_ASN1_EX_C2I 204 -# define ASN1_F_ASN1_FIND_END 190 -# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ 216 -# define ASN1_F_ASN1_GENERATE_V3 178 -# define ASN1_F_ASN1_GET_INT64 224 -# define ASN1_F_ASN1_GET_OBJECT 114 -# define ASN1_F_ASN1_GET_UINT64 225 -# define ASN1_F_ASN1_I2D_BIO 116 -# define ASN1_F_ASN1_I2D_FP 117 -# define ASN1_F_ASN1_ITEM_D2I_FP 206 -# define ASN1_F_ASN1_ITEM_DUP 191 -# define ASN1_F_ASN1_ITEM_EMBED_D2I 120 -# define ASN1_F_ASN1_ITEM_EMBED_NEW 121 -# define ASN1_F_ASN1_ITEM_EX_I2D 144 -# define ASN1_F_ASN1_ITEM_FLAGS_I2D 118 -# define ASN1_F_ASN1_ITEM_I2D_BIO 192 -# define ASN1_F_ASN1_ITEM_I2D_FP 193 -# define ASN1_F_ASN1_ITEM_PACK 198 -# define ASN1_F_ASN1_ITEM_SIGN 195 -# define ASN1_F_ASN1_ITEM_SIGN_CTX 220 -# define ASN1_F_ASN1_ITEM_UNPACK 199 -# define ASN1_F_ASN1_ITEM_VERIFY 197 -# define ASN1_F_ASN1_MBSTRING_NCOPY 122 -# define ASN1_F_ASN1_OBJECT_NEW 123 -# define ASN1_F_ASN1_OUTPUT_DATA 214 -# define ASN1_F_ASN1_PCTX_NEW 205 -# define ASN1_F_ASN1_PRIMITIVE_NEW 119 -# define ASN1_F_ASN1_SCTX_NEW 221 -# define ASN1_F_ASN1_SIGN 128 -# define ASN1_F_ASN1_STR2TYPE 179 -# define ASN1_F_ASN1_STRING_GET_INT64 227 -# define ASN1_F_ASN1_STRING_GET_UINT64 230 -# define ASN1_F_ASN1_STRING_SET 186 -# define ASN1_F_ASN1_STRING_TABLE_ADD 129 -# define ASN1_F_ASN1_STRING_TO_BN 228 -# define ASN1_F_ASN1_STRING_TYPE_NEW 130 -# define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 -# define ASN1_F_ASN1_TEMPLATE_NEW 133 -# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131 -# define ASN1_F_ASN1_TIME_ADJ 217 -# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 -# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 -# define ASN1_F_ASN1_UTCTIME_ADJ 218 -# define ASN1_F_ASN1_VERIFY 137 -# define ASN1_F_B64_READ_ASN1 209 -# define ASN1_F_B64_WRITE_ASN1 210 -# define ASN1_F_BIO_NEW_NDEF 208 -# define ASN1_F_BITSTR_CB 180 -# define ASN1_F_BN_TO_ASN1_STRING 229 -# define ASN1_F_C2I_ASN1_BIT_STRING 189 -# define ASN1_F_C2I_ASN1_INTEGER 194 -# define ASN1_F_C2I_ASN1_OBJECT 196 -# define ASN1_F_C2I_IBUF 226 -# define ASN1_F_C2I_UINT64_INT 101 -# define ASN1_F_COLLECT_DATA 140 -# define ASN1_F_D2I_ASN1_OBJECT 147 -# define ASN1_F_D2I_ASN1_UINTEGER 150 -# define ASN1_F_D2I_AUTOPRIVATEKEY 207 -# define ASN1_F_D2I_PRIVATEKEY 154 -# define ASN1_F_D2I_PUBLICKEY 155 -# define ASN1_F_DO_BUF 142 -# define ASN1_F_DO_CREATE 124 -# define ASN1_F_DO_DUMP 125 -# define ASN1_F_DO_TCREATE 222 -# define ASN1_F_I2A_ASN1_OBJECT 126 -# define ASN1_F_I2D_ASN1_BIO_STREAM 211 -# define ASN1_F_I2D_ASN1_OBJECT 143 -# define ASN1_F_I2D_DSA_PUBKEY 161 -# define ASN1_F_I2D_EC_PUBKEY 181 -# define ASN1_F_I2D_PRIVATEKEY 163 -# define ASN1_F_I2D_PUBLICKEY 164 -# define ASN1_F_I2D_RSA_PUBKEY 165 -# define ASN1_F_LONG_C2I 166 -# define ASN1_F_NDEF_PREFIX 127 -# define ASN1_F_NDEF_SUFFIX 136 -# define ASN1_F_OID_MODULE_INIT 174 -# define ASN1_F_PARSE_TAGGING 182 -# define ASN1_F_PKCS5_PBE2_SET_IV 167 -# define ASN1_F_PKCS5_PBE2_SET_SCRYPT 231 -# define ASN1_F_PKCS5_PBE_SET 202 -# define ASN1_F_PKCS5_PBE_SET0_ALGOR 215 -# define ASN1_F_PKCS5_PBKDF2_SET 219 -# define ASN1_F_PKCS5_SCRYPT_SET 232 -# define ASN1_F_SMIME_READ_ASN1 212 -# define ASN1_F_SMIME_TEXT 213 -# define ASN1_F_STABLE_GET 138 -# define ASN1_F_STBL_MODULE_INIT 223 -# define ASN1_F_UINT32_C2I 105 -# define ASN1_F_UINT32_NEW 139 -# define ASN1_F_UINT64_C2I 112 -# define ASN1_F_UINT64_NEW 141 -# define ASN1_F_X509_CRL_ADD0_REVOKED 169 -# define ASN1_F_X509_INFO_NEW 170 -# define ASN1_F_X509_NAME_ENCODE 203 -# define ASN1_F_X509_NAME_EX_D2I 158 -# define ASN1_F_X509_NAME_EX_NEW 171 -# define ASN1_F_X509_PKEY_NEW 173 - -/* - * ASN1 reason codes. - */ -# define ASN1_R_ADDING_OBJECT 171 -# define ASN1_R_ASN1_PARSE_ERROR 203 -# define ASN1_R_ASN1_SIG_PARSE_ERROR 204 -# define ASN1_R_AUX_ERROR 100 -# define ASN1_R_BAD_OBJECT_HEADER 102 -# define ASN1_R_BAD_TEMPLATE 230 -# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 214 -# define ASN1_R_BN_LIB 105 -# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 -# define ASN1_R_BUFFER_TOO_SMALL 107 -# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108 -# define ASN1_R_CONTEXT_NOT_INITIALISED 217 -# define ASN1_R_DATA_IS_WRONG 109 -# define ASN1_R_DECODE_ERROR 110 -# define ASN1_R_DEPTH_EXCEEDED 174 -# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 198 -# define ASN1_R_ENCODE_ERROR 112 -# define ASN1_R_ERROR_GETTING_TIME 173 -# define ASN1_R_ERROR_LOADING_SECTION 172 -# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 -# define ASN1_R_EXPECTING_AN_INTEGER 115 -# define ASN1_R_EXPECTING_AN_OBJECT 116 -# define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119 -# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120 -# define ASN1_R_FIELD_MISSING 121 -# define ASN1_R_FIRST_NUM_TOO_LARGE 122 -# define ASN1_R_HEADER_TOO_LONG 123 -# define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175 -# define ASN1_R_ILLEGAL_BOOLEAN 176 -# define ASN1_R_ILLEGAL_CHARACTERS 124 -# define ASN1_R_ILLEGAL_FORMAT 177 -# define ASN1_R_ILLEGAL_HEX 178 -# define ASN1_R_ILLEGAL_IMPLICIT_TAG 179 -# define ASN1_R_ILLEGAL_INTEGER 180 -# define ASN1_R_ILLEGAL_NEGATIVE_VALUE 226 -# define ASN1_R_ILLEGAL_NESTED_TAGGING 181 -# define ASN1_R_ILLEGAL_NULL 125 -# define ASN1_R_ILLEGAL_NULL_VALUE 182 -# define ASN1_R_ILLEGAL_OBJECT 183 -# define ASN1_R_ILLEGAL_OPTIONAL_ANY 126 -# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170 -# define ASN1_R_ILLEGAL_PADDING 221 -# define ASN1_R_ILLEGAL_TAGGED_ANY 127 -# define ASN1_R_ILLEGAL_TIME_VALUE 184 -# define ASN1_R_ILLEGAL_ZERO_CONTENT 222 -# define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185 -# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128 -# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 220 -# define ASN1_R_INVALID_BMPSTRING_LENGTH 129 -# define ASN1_R_INVALID_DIGIT 130 -# define ASN1_R_INVALID_MIME_TYPE 205 -# define ASN1_R_INVALID_MODIFIER 186 -# define ASN1_R_INVALID_NUMBER 187 -# define ASN1_R_INVALID_OBJECT_ENCODING 216 -# define ASN1_R_INVALID_SCRYPT_PARAMETERS 227 -# define ASN1_R_INVALID_SEPARATOR 131 -# define ASN1_R_INVALID_STRING_TABLE_VALUE 218 -# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133 -# define ASN1_R_INVALID_UTF8STRING 134 -# define ASN1_R_INVALID_VALUE 219 -# define ASN1_R_LIST_ERROR 188 -# define ASN1_R_MIME_NO_CONTENT_TYPE 206 -# define ASN1_R_MIME_PARSE_ERROR 207 -# define ASN1_R_MIME_SIG_PARSE_ERROR 208 -# define ASN1_R_MISSING_EOC 137 -# define ASN1_R_MISSING_SECOND_NUMBER 138 -# define ASN1_R_MISSING_VALUE 189 -# define ASN1_R_MSTRING_NOT_UNIVERSAL 139 -# define ASN1_R_MSTRING_WRONG_TAG 140 -# define ASN1_R_NESTED_ASN1_STRING 197 -# define ASN1_R_NESTED_TOO_DEEP 201 -# define ASN1_R_NON_HEX_CHARACTERS 141 -# define ASN1_R_NOT_ASCII_FORMAT 190 -# define ASN1_R_NOT_ENOUGH_DATA 142 -# define ASN1_R_NO_CONTENT_TYPE 209 -# define ASN1_R_NO_MATCHING_CHOICE_TYPE 143 -# define ASN1_R_NO_MULTIPART_BODY_FAILURE 210 -# define ASN1_R_NO_MULTIPART_BOUNDARY 211 -# define ASN1_R_NO_SIG_CONTENT_TYPE 212 -# define ASN1_R_NULL_IS_WRONG_LENGTH 144 -# define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191 -# define ASN1_R_ODD_NUMBER_OF_CHARS 145 -# define ASN1_R_SECOND_NUMBER_TOO_LARGE 147 -# define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148 -# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149 -# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192 -# define ASN1_R_SHORT_LINE 150 -# define ASN1_R_SIG_INVALID_MIME_TYPE 213 -# define ASN1_R_STREAMING_NOT_SUPPORTED 202 -# define ASN1_R_STRING_TOO_LONG 151 -# define ASN1_R_STRING_TOO_SHORT 152 -# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154 -# define ASN1_R_TIME_NOT_ASCII_FORMAT 193 -# define ASN1_R_TOO_LARGE 223 -# define ASN1_R_TOO_LONG 155 -# define ASN1_R_TOO_SMALL 224 -# define ASN1_R_TYPE_NOT_CONSTRUCTED 156 -# define ASN1_R_TYPE_NOT_PRIMITIVE 195 -# define ASN1_R_UNEXPECTED_EOC 159 -# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 215 -# define ASN1_R_UNKNOWN_FORMAT 160 -# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161 -# define ASN1_R_UNKNOWN_OBJECT_TYPE 162 -# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163 -# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 199 -# define ASN1_R_UNKNOWN_TAG 194 -# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164 -# define ASN1_R_UNSUPPORTED_CIPHER 228 -# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167 -# define ASN1_R_UNSUPPORTED_TYPE 196 -# define ASN1_R_WRONG_INTEGER_TYPE 225 -# define ASN1_R_WRONG_PUBLIC_KEY_TYPE 200 -# define ASN1_R_WRONG_TAG 168 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/asn1t.h b/client/3rd/OpenSSL/include/openssl/asn1t.h deleted file mode 100644 index a450ba0d..00000000 --- a/client/3rd/OpenSSL/include/openssl/asn1t.h +++ /dev/null @@ -1,945 +0,0 @@ -/* - * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ASN1T_H -# define HEADER_ASN1T_H - -# include -# include -# include - -# ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -# endif - -/* ASN1 template defines, structures and functions */ - -#ifdef __cplusplus -extern "C" { -#endif - -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - -/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ -# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr)) - -/* Macros for start and end of ASN1_ITEM definition */ - -# define ASN1_ITEM_start(itname) \ - const ASN1_ITEM itname##_it = { - -# define static_ASN1_ITEM_start(itname) \ - static const ASN1_ITEM itname##_it = { - -# define ASN1_ITEM_end(itname) \ - }; - -# else - -/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ -# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)((iptr)())) - -/* Macros for start and end of ASN1_ITEM definition */ - -# define ASN1_ITEM_start(itname) \ - const ASN1_ITEM * itname##_it(void) \ - { \ - static const ASN1_ITEM local_it = { - -# define static_ASN1_ITEM_start(itname) \ - static ASN1_ITEM_start(itname) - -# define ASN1_ITEM_end(itname) \ - }; \ - return &local_it; \ - } - -# endif - -/* Macros to aid ASN1 template writing */ - -# define ASN1_ITEM_TEMPLATE(tname) \ - static const ASN1_TEMPLATE tname##_item_tt - -# define ASN1_ITEM_TEMPLATE_END(tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_PRIMITIVE,\ - -1,\ - &tname##_item_tt,\ - 0,\ - NULL,\ - 0,\ - #tname \ - ASN1_ITEM_end(tname) -# define static_ASN1_ITEM_TEMPLATE_END(tname) \ - ;\ - static_ASN1_ITEM_start(tname) \ - ASN1_ITYPE_PRIMITIVE,\ - -1,\ - &tname##_item_tt,\ - 0,\ - NULL,\ - 0,\ - #tname \ - ASN1_ITEM_end(tname) - -/* This is a ASN1 type which just embeds a template */ - -/*- - * This pair helps declare a SEQUENCE. We can do: - * - * ASN1_SEQUENCE(stname) = { - * ... SEQUENCE components ... - * } ASN1_SEQUENCE_END(stname) - * - * This will produce an ASN1_ITEM called stname_it - * for a structure called stname. - * - * If you want the same structure but a different - * name then use: - * - * ASN1_SEQUENCE(itname) = { - * ... SEQUENCE components ... - * } ASN1_SEQUENCE_END_name(stname, itname) - * - * This will create an item called itname_it using - * a structure called stname. - */ - -# define ASN1_SEQUENCE(tname) \ - static const ASN1_TEMPLATE tname##_seq_tt[] - -# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) - -# define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname) - -# define ASN1_SEQUENCE_END_name(stname, tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #tname \ - ASN1_ITEM_end(tname) - -# define static_ASN1_SEQUENCE_END_name(stname, tname) \ - ;\ - static_ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -# define ASN1_NDEF_SEQUENCE(tname) \ - ASN1_SEQUENCE(tname) - -# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \ - ASN1_SEQUENCE_cb(tname, cb) - -# define ASN1_SEQUENCE_cb(tname, cb) \ - static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ - ASN1_SEQUENCE(tname) - -# define ASN1_BROKEN_SEQUENCE(tname) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \ - ASN1_SEQUENCE(tname) - -# define ASN1_SEQUENCE_ref(tname, cb) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0}; \ - ASN1_SEQUENCE(tname) - -# define ASN1_SEQUENCE_enc(tname, enc, cb) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \ - ASN1_SEQUENCE(tname) - -# define ASN1_NDEF_SEQUENCE_END(tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_NDEF_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(tname),\ - #tname \ - ASN1_ITEM_end(tname) -# define static_ASN1_NDEF_SEQUENCE_END(tname) \ - ;\ - static_ASN1_ITEM_start(tname) \ - ASN1_ITYPE_NDEF_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(tname),\ - #tname \ - ASN1_ITEM_end(tname) - -# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname) -# define static_ASN1_BROKEN_SEQUENCE_END(stname) \ - static_ASN1_SEQUENCE_END_ref(stname, stname) - -# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) - -# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) -# define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname) - -# define ASN1_SEQUENCE_END_ref(stname, tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #tname \ - ASN1_ITEM_end(tname) -# define static_ASN1_SEQUENCE_END_ref(stname, tname) \ - ;\ - static_ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_NDEF_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -/*- - * This pair helps declare a CHOICE type. We can do: - * - * ASN1_CHOICE(chname) = { - * ... CHOICE options ... - * ASN1_CHOICE_END(chname) - * - * This will produce an ASN1_ITEM called chname_it - * for a structure called chname. The structure - * definition must look like this: - * typedef struct { - * int type; - * union { - * ASN1_SOMETHING *opt1; - * ASN1_SOMEOTHER *opt2; - * } value; - * } chname; - * - * the name of the selector must be 'type'. - * to use an alternative selector name use the - * ASN1_CHOICE_END_selector() version. - */ - -# define ASN1_CHOICE(tname) \ - static const ASN1_TEMPLATE tname##_ch_tt[] - -# define ASN1_CHOICE_cb(tname, cb) \ - static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ - ASN1_CHOICE(tname) - -# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) - -# define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname) - -# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) - -# define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type) - -# define ASN1_CHOICE_END_selector(stname, tname, selname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_CHOICE,\ - offsetof(stname,selname) ,\ - tname##_ch_tt,\ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -# define static_ASN1_CHOICE_END_selector(stname, tname, selname) \ - ;\ - static_ASN1_ITEM_start(tname) \ - ASN1_ITYPE_CHOICE,\ - offsetof(stname,selname) ,\ - tname##_ch_tt,\ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -# define ASN1_CHOICE_END_cb(stname, tname, selname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_CHOICE,\ - offsetof(stname,selname) ,\ - tname##_ch_tt,\ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -/* This helps with the template wrapper form of ASN1_ITEM */ - -# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ - (flags), (tag), 0,\ - #name, ASN1_ITEM_ref(type) } - -/* These help with SEQUENCE or CHOICE components */ - -/* used to declare other types */ - -# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ - (flags), (tag), offsetof(stname, field),\ - #field, ASN1_ITEM_ref(type) } - -/* implicit and explicit helper macros */ - -# define ASN1_IMP_EX(stname, field, type, tag, ex) \ - ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type) - -# define ASN1_EXP_EX(stname, field, type, tag, ex) \ - ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type) - -/* Any defined by macros: the field used is in the table itself */ - -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION -# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } -# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } -# else -# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb } -# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb } -# endif -/* Plain simple type */ -# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) -/* Embedded simple type */ -# define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED,0, stname, field, type) - -/* OPTIONAL simple type */ -# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) -# define ASN1_OPT_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED, 0, stname, field, type) - -/* IMPLICIT tagged simple type */ -# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) -# define ASN1_IMP_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_EMBED) - -/* IMPLICIT tagged OPTIONAL simple type */ -# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) -# define ASN1_IMP_OPT_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED) - -/* Same as above but EXPLICIT */ - -# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) -# define ASN1_EXP_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_EMBED) -# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) -# define ASN1_EXP_OPT_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED) - -/* SEQUENCE OF type */ -# define ASN1_SEQUENCE_OF(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) - -/* OPTIONAL SEQUENCE OF */ -# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) - -/* Same as above but for SET OF */ - -# define ASN1_SET_OF(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) - -# define ASN1_SET_OF_OPT(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) - -/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ - -# define ASN1_IMP_SET_OF(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) - -# define ASN1_EXP_SET_OF(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) - -# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) - -# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) - -# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) - -# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) - -# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) - -# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) - -/* EXPLICIT using indefinite length constructed form */ -# define ASN1_NDEF_EXP(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF) - -/* EXPLICIT OPTIONAL using indefinite length constructed form */ -# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) - -/* Macros for the ASN1_ADB structure */ - -# define ASN1_ADB(name) \ - static const ASN1_ADB_TABLE name##_adbtbl[] - -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - -# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ - ;\ - static const ASN1_ADB name##_adb = {\ - flags,\ - offsetof(name, field),\ - adb_cb,\ - name##_adbtbl,\ - sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ - def,\ - none\ - } - -# else - -# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ - ;\ - static const ASN1_ITEM *name##_adb(void) \ - { \ - static const ASN1_ADB internal_adb = \ - {\ - flags,\ - offsetof(name, field),\ - adb_cb,\ - name##_adbtbl,\ - sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ - def,\ - none\ - }; \ - return (const ASN1_ITEM *) &internal_adb; \ - } \ - void dummy_function(void) - -# endif - -# define ADB_ENTRY(val, template) {val, template} - -# define ASN1_ADB_TEMPLATE(name) \ - static const ASN1_TEMPLATE name##_tt - -/* - * This is the ASN1 template structure that defines a wrapper round the - * actual type. It determines the actual position of the field in the value - * structure, various flags such as OPTIONAL and the field name. - */ - -struct ASN1_TEMPLATE_st { - unsigned long flags; /* Various flags */ - long tag; /* tag, not used if no tagging */ - unsigned long offset; /* Offset of this field in structure */ - const char *field_name; /* Field name */ - ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ -}; - -/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ - -# define ASN1_TEMPLATE_item(t) (t->item_ptr) -# define ASN1_TEMPLATE_adb(t) (t->item_ptr) - -typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE; -typedef struct ASN1_ADB_st ASN1_ADB; - -struct ASN1_ADB_st { - unsigned long flags; /* Various flags */ - unsigned long offset; /* Offset of selector field */ - int (*adb_cb)(long *psel); /* Application callback */ - const ASN1_ADB_TABLE *tbl; /* Table of possible types */ - long tblcount; /* Number of entries in tbl */ - const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ - const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ -}; - -struct ASN1_ADB_TABLE_st { - long value; /* NID for an object or value for an int */ - const ASN1_TEMPLATE tt; /* item for this value */ -}; - -/* template flags */ - -/* Field is optional */ -# define ASN1_TFLG_OPTIONAL (0x1) - -/* Field is a SET OF */ -# define ASN1_TFLG_SET_OF (0x1 << 1) - -/* Field is a SEQUENCE OF */ -# define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) - -/* - * Special case: this refers to a SET OF that will be sorted into DER order - * when encoded *and* the corresponding STACK will be modified to match the - * new order. - */ -# define ASN1_TFLG_SET_ORDER (0x3 << 1) - -/* Mask for SET OF or SEQUENCE OF */ -# define ASN1_TFLG_SK_MASK (0x3 << 1) - -/* - * These flags mean the tag should be taken from the tag field. If EXPLICIT - * then the underlying type is used for the inner tag. - */ - -/* IMPLICIT tagging */ -# define ASN1_TFLG_IMPTAG (0x1 << 3) - -/* EXPLICIT tagging, inner tag from underlying type */ -# define ASN1_TFLG_EXPTAG (0x2 << 3) - -# define ASN1_TFLG_TAG_MASK (0x3 << 3) - -/* context specific IMPLICIT */ -# define ASN1_TFLG_IMPLICIT (ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT) - -/* context specific EXPLICIT */ -# define ASN1_TFLG_EXPLICIT (ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT) - -/* - * If tagging is in force these determine the type of tag to use. Otherwise - * the tag is determined by the underlying type. These values reflect the - * actual octet format. - */ - -/* Universal tag */ -# define ASN1_TFLG_UNIVERSAL (0x0<<6) -/* Application tag */ -# define ASN1_TFLG_APPLICATION (0x1<<6) -/* Context specific tag */ -# define ASN1_TFLG_CONTEXT (0x2<<6) -/* Private tag */ -# define ASN1_TFLG_PRIVATE (0x3<<6) - -# define ASN1_TFLG_TAG_CLASS (0x3<<6) - -/* - * These are for ANY DEFINED BY type. In this case the 'item' field points to - * an ASN1_ADB structure which contains a table of values to decode the - * relevant type - */ - -# define ASN1_TFLG_ADB_MASK (0x3<<8) - -# define ASN1_TFLG_ADB_OID (0x1<<8) - -# define ASN1_TFLG_ADB_INT (0x1<<9) - -/* - * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes - * indefinite length constructed encoding to be used if required. - */ - -# define ASN1_TFLG_NDEF (0x1<<11) - -/* Field is embedded and not a pointer */ -# define ASN1_TFLG_EMBED (0x1 << 12) - -/* This is the actual ASN1 item itself */ - -struct ASN1_ITEM_st { - char itype; /* The item type, primitive, SEQUENCE, CHOICE - * or extern */ - long utype; /* underlying type */ - const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains - * the contents */ - long tcount; /* Number of templates if SEQUENCE or CHOICE */ - const void *funcs; /* functions that handle this type */ - long size; /* Structure size (usually) */ - const char *sname; /* Structure name */ -}; - -/*- - * These are values for the itype field and - * determine how the type is interpreted. - * - * For PRIMITIVE types the underlying type - * determines the behaviour if items is NULL. - * - * Otherwise templates must contain a single - * template and the type is treated in the - * same way as the type specified in the template. - * - * For SEQUENCE types the templates field points - * to the members, the size field is the - * structure size. - * - * For CHOICE types the templates field points - * to each possible member (typically a union) - * and the 'size' field is the offset of the - * selector. - * - * The 'funcs' field is used for application - * specific functions. - * - * The EXTERN type uses a new style d2i/i2d. - * The new style should be used where possible - * because it avoids things like the d2i IMPLICIT - * hack. - * - * MSTRING is a multiple string type, it is used - * for a CHOICE of character strings where the - * actual strings all occupy an ASN1_STRING - * structure. In this case the 'utype' field - * has a special meaning, it is used as a mask - * of acceptable types using the B_ASN1 constants. - * - * NDEF_SEQUENCE is the same as SEQUENCE except - * that it will use indefinite length constructed - * encoding if requested. - * - */ - -# define ASN1_ITYPE_PRIMITIVE 0x0 - -# define ASN1_ITYPE_SEQUENCE 0x1 - -# define ASN1_ITYPE_CHOICE 0x2 - -# define ASN1_ITYPE_EXTERN 0x4 - -# define ASN1_ITYPE_MSTRING 0x5 - -# define ASN1_ITYPE_NDEF_SEQUENCE 0x6 - -/* - * Cache for ASN1 tag and length, so we don't keep re-reading it for things - * like CHOICE - */ - -struct ASN1_TLC_st { - char valid; /* Values below are valid */ - int ret; /* return value */ - long plen; /* length */ - int ptag; /* class value */ - int pclass; /* class value */ - int hdrlen; /* header length */ -}; - -/* Typedefs for ASN1 function pointers */ -typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, - const ASN1_ITEM *it, int tag, int aclass, char opt, - ASN1_TLC *ctx); - -typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, - const ASN1_ITEM *it, int tag, int aclass); -typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); -typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); - -typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval, - int indent, const char *fname, - const ASN1_PCTX *pctx); - -typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, - int *putype, const ASN1_ITEM *it); -typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, - int len, int utype, char *free_cont, - const ASN1_ITEM *it); -typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, - const ASN1_ITEM *it, int indent, - const ASN1_PCTX *pctx); - -typedef struct ASN1_EXTERN_FUNCS_st { - void *app_data; - ASN1_ex_new_func *asn1_ex_new; - ASN1_ex_free_func *asn1_ex_free; - ASN1_ex_free_func *asn1_ex_clear; - ASN1_ex_d2i *asn1_ex_d2i; - ASN1_ex_i2d *asn1_ex_i2d; - ASN1_ex_print_func *asn1_ex_print; -} ASN1_EXTERN_FUNCS; - -typedef struct ASN1_PRIMITIVE_FUNCS_st { - void *app_data; - unsigned long flags; - ASN1_ex_new_func *prim_new; - ASN1_ex_free_func *prim_free; - ASN1_ex_free_func *prim_clear; - ASN1_primitive_c2i *prim_c2i; - ASN1_primitive_i2c *prim_i2c; - ASN1_primitive_print *prim_print; -} ASN1_PRIMITIVE_FUNCS; - -/* - * This is the ASN1_AUX structure: it handles various miscellaneous - * requirements. For example the use of reference counts and an informational - * callback. The "informational callback" is called at various points during - * the ASN1 encoding and decoding. It can be used to provide minor - * customisation of the structures used. This is most useful where the - * supplied routines *almost* do the right thing but need some extra help at - * a few points. If the callback returns zero then it is assumed a fatal - * error has occurred and the main operation should be abandoned. If major - * changes in the default behaviour are required then an external type is - * more appropriate. - */ - -typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it, - void *exarg); - -typedef struct ASN1_AUX_st { - void *app_data; - int flags; - int ref_offset; /* Offset of reference value */ - int ref_lock; /* Lock type to use */ - ASN1_aux_cb *asn1_cb; - int enc_offset; /* Offset of ASN1_ENCODING structure */ -} ASN1_AUX; - -/* For print related callbacks exarg points to this structure */ -typedef struct ASN1_PRINT_ARG_st { - BIO *out; - int indent; - const ASN1_PCTX *pctx; -} ASN1_PRINT_ARG; - -/* For streaming related callbacks exarg points to this structure */ -typedef struct ASN1_STREAM_ARG_st { - /* BIO to stream through */ - BIO *out; - /* BIO with filters appended */ - BIO *ndef_bio; - /* Streaming I/O boundary */ - unsigned char **boundary; -} ASN1_STREAM_ARG; - -/* Flags in ASN1_AUX */ - -/* Use a reference count */ -# define ASN1_AFLG_REFCOUNT 1 -/* Save the encoding of structure (useful for signatures) */ -# define ASN1_AFLG_ENCODING 2 -/* The Sequence length is invalid */ -# define ASN1_AFLG_BROKEN 4 - -/* operation values for asn1_cb */ - -# define ASN1_OP_NEW_PRE 0 -# define ASN1_OP_NEW_POST 1 -# define ASN1_OP_FREE_PRE 2 -# define ASN1_OP_FREE_POST 3 -# define ASN1_OP_D2I_PRE 4 -# define ASN1_OP_D2I_POST 5 -# define ASN1_OP_I2D_PRE 6 -# define ASN1_OP_I2D_POST 7 -# define ASN1_OP_PRINT_PRE 8 -# define ASN1_OP_PRINT_POST 9 -# define ASN1_OP_STREAM_PRE 10 -# define ASN1_OP_STREAM_POST 11 -# define ASN1_OP_DETACHED_PRE 12 -# define ASN1_OP_DETACHED_POST 13 - -/* Macro to implement a primitive type */ -# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) -# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ - ASN1_ITEM_start(itname) \ - ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \ - ASN1_ITEM_end(itname) - -/* Macro to implement a multi string type */ -# define IMPLEMENT_ASN1_MSTRING(itname, mask) \ - ASN1_ITEM_start(itname) \ - ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ - ASN1_ITEM_end(itname) - -# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ - ASN1_ITEM_start(sname) \ - ASN1_ITYPE_EXTERN, \ - tag, \ - NULL, \ - 0, \ - &fptrs, \ - 0, \ - #sname \ - ASN1_ITEM_end(sname) - -/* Macro to implement standard functions in terms of ASN1_ITEM structures */ - -# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) - -# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) - -# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ - IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) - -# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname) - -# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) - -# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \ - pre stname *fname##_new(void) \ - { \ - return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ - } \ - pre void fname##_free(stname *a) \ - { \ - ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ - } - -# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ - stname *fname##_new(void) \ - { \ - return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ - } \ - void fname##_free(stname *a) \ - { \ - ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ - } - -# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) - -# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ - stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ - } \ - int i2d_##fname(stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ - } - -# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ - int i2d_##stname##_NDEF(stname *a, unsigned char **out) \ - { \ - return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ - } - -# define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \ - static stname *d2i_##stname(stname **a, \ - const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \ - ASN1_ITEM_rptr(stname)); \ - } \ - static int i2d_##stname(stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((ASN1_VALUE *)a, out, \ - ASN1_ITEM_rptr(stname)); \ - } - -/* - * This includes evil casts to remove const: they will go away when full ASN1 - * constification is done. - */ -# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ - stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ - } \ - int i2d_##fname(const stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ - } - -# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ - stname * stname##_dup(stname *x) \ - { \ - return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ - } - -# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \ - IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname) - -# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \ - int fname##_print_ctx(BIO *out, stname *x, int indent, \ - const ASN1_PCTX *pctx) \ - { \ - return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \ - ASN1_ITEM_rptr(itname), pctx); \ - } - -# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ - IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) - -# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) - -/* external definitions for primitive types */ - -DECLARE_ASN1_ITEM(ASN1_BOOLEAN) -DECLARE_ASN1_ITEM(ASN1_TBOOLEAN) -DECLARE_ASN1_ITEM(ASN1_FBOOLEAN) -DECLARE_ASN1_ITEM(ASN1_SEQUENCE) -DECLARE_ASN1_ITEM(CBIGNUM) -DECLARE_ASN1_ITEM(BIGNUM) -DECLARE_ASN1_ITEM(INT32) -DECLARE_ASN1_ITEM(ZINT32) -DECLARE_ASN1_ITEM(UINT32) -DECLARE_ASN1_ITEM(ZUINT32) -DECLARE_ASN1_ITEM(INT64) -DECLARE_ASN1_ITEM(ZINT64) -DECLARE_ASN1_ITEM(UINT64) -DECLARE_ASN1_ITEM(ZUINT64) - -# if OPENSSL_API_COMPAT < 0x10200000L -/* - * LONG and ZLONG are strongly discouraged for use as stored data, as the - * underlying C type (long) differs in size depending on the architecture. - * They are designed with 32-bit longs in mind. - */ -DECLARE_ASN1_ITEM(LONG) -DECLARE_ASN1_ITEM(ZLONG) -# endif - -DEFINE_STACK_OF(ASN1_VALUE) - -/* Functions used internally by the ASN1 code */ - -int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); -void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); - -int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, - const ASN1_ITEM *it, int tag, int aclass, char opt, - ASN1_TLC *ctx); - -int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, - const ASN1_ITEM *it, int tag, int aclass); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/async.h b/client/3rd/OpenSSL/include/openssl/async.h deleted file mode 100644 index 7052b890..00000000 --- a/client/3rd/OpenSSL/include/openssl/async.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include - -#ifndef HEADER_ASYNC_H -# define HEADER_ASYNC_H - -#if defined(_WIN32) -# if defined(BASETYPES) || defined(_WINDEF_H) -/* application has to include to use this */ -#define OSSL_ASYNC_FD HANDLE -#define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE -# endif -#else -#define OSSL_ASYNC_FD int -#define OSSL_BAD_ASYNC_FD -1 -#endif -# include - - -# ifdef __cplusplus -extern "C" { -# endif - -typedef struct async_job_st ASYNC_JOB; -typedef struct async_wait_ctx_st ASYNC_WAIT_CTX; - -#define ASYNC_ERR 0 -#define ASYNC_NO_JOBS 1 -#define ASYNC_PAUSE 2 -#define ASYNC_FINISH 3 - -int ASYNC_init_thread(size_t max_size, size_t init_size); -void ASYNC_cleanup_thread(void); - -#ifdef OSSL_ASYNC_FD -ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void); -void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx); -int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key, - OSSL_ASYNC_FD fd, - void *custom_data, - void (*cleanup)(ASYNC_WAIT_CTX *, const void *, - OSSL_ASYNC_FD, void *)); -int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key, - OSSL_ASYNC_FD *fd, void **custom_data); -int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd, - size_t *numfds); -int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd, - size_t *numaddfds, OSSL_ASYNC_FD *delfd, - size_t *numdelfds); -int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key); -#endif - -int ASYNC_is_capable(void); - -int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret, - int (*func)(void *), void *args, size_t size); -int ASYNC_pause_job(void); - -ASYNC_JOB *ASYNC_get_current_job(void); -ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job); -void ASYNC_block_pause(void); -void ASYNC_unblock_pause(void); - - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/asyncerr.h b/client/3rd/OpenSSL/include/openssl/asyncerr.h deleted file mode 100644 index 91afbbb2..00000000 --- a/client/3rd/OpenSSL/include/openssl/asyncerr.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ASYNCERR_H -# define HEADER_ASYNCERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_ASYNC_strings(void); - -/* - * ASYNC function codes. - */ -# define ASYNC_F_ASYNC_CTX_NEW 100 -# define ASYNC_F_ASYNC_INIT_THREAD 101 -# define ASYNC_F_ASYNC_JOB_NEW 102 -# define ASYNC_F_ASYNC_PAUSE_JOB 103 -# define ASYNC_F_ASYNC_START_FUNC 104 -# define ASYNC_F_ASYNC_START_JOB 105 -# define ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD 106 - -/* - * ASYNC reason codes. - */ -# define ASYNC_R_FAILED_TO_SET_POOL 101 -# define ASYNC_R_FAILED_TO_SWAP_CONTEXT 102 -# define ASYNC_R_INIT_FAILED 105 -# define ASYNC_R_INVALID_POOL_SIZE 103 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/bio.h b/client/3rd/OpenSSL/include/openssl/bio.h deleted file mode 100644 index ae559a51..00000000 --- a/client/3rd/OpenSSL/include/openssl/bio.h +++ /dev/null @@ -1,801 +0,0 @@ -/* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_BIO_H -# define HEADER_BIO_H - -# include - -# ifndef OPENSSL_NO_STDIO -# include -# endif -# include - -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/* There are the classes of BIOs */ -# define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ -# define BIO_TYPE_FILTER 0x0200 -# define BIO_TYPE_SOURCE_SINK 0x0400 - -/* These are the 'types' of BIOs */ -# define BIO_TYPE_NONE 0 -# define BIO_TYPE_MEM ( 1|BIO_TYPE_SOURCE_SINK) -# define BIO_TYPE_FILE ( 2|BIO_TYPE_SOURCE_SINK) - -# define BIO_TYPE_FD ( 4|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) -# define BIO_TYPE_SOCKET ( 5|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) -# define BIO_TYPE_NULL ( 6|BIO_TYPE_SOURCE_SINK) -# define BIO_TYPE_SSL ( 7|BIO_TYPE_FILTER) -# define BIO_TYPE_MD ( 8|BIO_TYPE_FILTER) -# define BIO_TYPE_BUFFER ( 9|BIO_TYPE_FILTER) -# define BIO_TYPE_CIPHER (10|BIO_TYPE_FILTER) -# define BIO_TYPE_BASE64 (11|BIO_TYPE_FILTER) -# define BIO_TYPE_CONNECT (12|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) -# define BIO_TYPE_ACCEPT (13|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) - -# define BIO_TYPE_NBIO_TEST (16|BIO_TYPE_FILTER)/* server proxy BIO */ -# define BIO_TYPE_NULL_FILTER (17|BIO_TYPE_FILTER) -# define BIO_TYPE_BIO (19|BIO_TYPE_SOURCE_SINK)/* half a BIO pair */ -# define BIO_TYPE_LINEBUFFER (20|BIO_TYPE_FILTER) -# define BIO_TYPE_DGRAM (21|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) -# define BIO_TYPE_ASN1 (22|BIO_TYPE_FILTER) -# define BIO_TYPE_COMP (23|BIO_TYPE_FILTER) -# ifndef OPENSSL_NO_SCTP -# define BIO_TYPE_DGRAM_SCTP (24|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) -# endif - -#define BIO_TYPE_START 128 - -/* - * BIO_FILENAME_READ|BIO_CLOSE to open or close on free. - * BIO_set_fp(in,stdin,BIO_NOCLOSE); - */ -# define BIO_NOCLOSE 0x00 -# define BIO_CLOSE 0x01 - -/* - * These are used in the following macros and are passed to BIO_ctrl() - */ -# define BIO_CTRL_RESET 1/* opt - rewind/zero etc */ -# define BIO_CTRL_EOF 2/* opt - are we at the eof */ -# define BIO_CTRL_INFO 3/* opt - extra tit-bits */ -# define BIO_CTRL_SET 4/* man - set the 'IO' type */ -# define BIO_CTRL_GET 5/* man - get the 'IO' type */ -# define BIO_CTRL_PUSH 6/* opt - internal, used to signify change */ -# define BIO_CTRL_POP 7/* opt - internal, used to signify change */ -# define BIO_CTRL_GET_CLOSE 8/* man - set the 'close' on free */ -# define BIO_CTRL_SET_CLOSE 9/* man - set the 'close' on free */ -# define BIO_CTRL_PENDING 10/* opt - is their more data buffered */ -# define BIO_CTRL_FLUSH 11/* opt - 'flush' buffered output */ -# define BIO_CTRL_DUP 12/* man - extra stuff for 'duped' BIO */ -# define BIO_CTRL_WPENDING 13/* opt - number of bytes still to write */ -# define BIO_CTRL_SET_CALLBACK 14/* opt - set callback function */ -# define BIO_CTRL_GET_CALLBACK 15/* opt - set callback function */ - -# define BIO_CTRL_PEEK 29/* BIO_f_buffer special */ -# define BIO_CTRL_SET_FILENAME 30/* BIO_s_file special */ - -/* dgram BIO stuff */ -# define BIO_CTRL_DGRAM_CONNECT 31/* BIO dgram special */ -# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected - * socket to be passed in */ -# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */ -# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */ -# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */ -# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */ - -# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */ -# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */ - -/* #ifdef IP_MTU_DISCOVER */ -# define BIO_CTRL_DGRAM_MTU_DISCOVER 39/* set DF bit on egress packets */ -/* #endif */ - -# define BIO_CTRL_DGRAM_QUERY_MTU 40/* as kernel for current MTU */ -# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47 -# define BIO_CTRL_DGRAM_GET_MTU 41/* get cached value for MTU */ -# define BIO_CTRL_DGRAM_SET_MTU 42/* set cached value for MTU. - * want to use this if asking - * the kernel fails */ - -# define BIO_CTRL_DGRAM_MTU_EXCEEDED 43/* check whether the MTU was - * exceed in the previous write - * operation */ - -# define BIO_CTRL_DGRAM_GET_PEER 46 -# define BIO_CTRL_DGRAM_SET_PEER 44/* Destination for the data */ - -# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45/* Next DTLS handshake timeout - * to adjust socket timeouts */ -# define BIO_CTRL_DGRAM_SET_DONT_FRAG 48 - -# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49 - -/* Deliberately outside of OPENSSL_NO_SCTP - used in bss_dgram.c */ -# define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50 -# ifndef OPENSSL_NO_SCTP -/* SCTP stuff */ -# define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51 -# define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52 -# define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53 -# define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60 -# define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61 -# define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62 -# define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63 -# define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64 -# define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65 -# define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70 -# endif - -# define BIO_CTRL_DGRAM_SET_PEEK_MODE 71 - -/* modifiers */ -# define BIO_FP_READ 0x02 -# define BIO_FP_WRITE 0x04 -# define BIO_FP_APPEND 0x08 -# define BIO_FP_TEXT 0x10 - -# define BIO_FLAGS_READ 0x01 -# define BIO_FLAGS_WRITE 0x02 -# define BIO_FLAGS_IO_SPECIAL 0x04 -# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) -# define BIO_FLAGS_SHOULD_RETRY 0x08 -# ifndef BIO_FLAGS_UPLINK -/* - * "UPLINK" flag denotes file descriptors provided by application. It - * defaults to 0, as most platforms don't require UPLINK interface. - */ -# define BIO_FLAGS_UPLINK 0 -# endif - -# define BIO_FLAGS_BASE64_NO_NL 0x100 - -/* - * This is used with memory BIOs: - * BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any way; - * BIO_FLAGS_NONCLEAR_RST means we shouldn't clear data on reset. - */ -# define BIO_FLAGS_MEM_RDONLY 0x200 -# define BIO_FLAGS_NONCLEAR_RST 0x400 -# define BIO_FLAGS_IN_EOF 0x800 - -typedef union bio_addr_st BIO_ADDR; -typedef struct bio_addrinfo_st BIO_ADDRINFO; - -int BIO_get_new_index(void); -void BIO_set_flags(BIO *b, int flags); -int BIO_test_flags(const BIO *b, int flags); -void BIO_clear_flags(BIO *b, int flags); - -# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0)) -# define BIO_set_retry_special(b) \ - BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) -# define BIO_set_retry_read(b) \ - BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) -# define BIO_set_retry_write(b) \ - BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) - -/* These are normally used internally in BIOs */ -# define BIO_clear_retry_flags(b) \ - BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) -# define BIO_get_retry_flags(b) \ - BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) - -/* These should be used by the application to tell why we should retry */ -# define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ) -# define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE) -# define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL) -# define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS) -# define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY) - -/* - * The next three are used in conjunction with the BIO_should_io_special() - * condition. After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int - * *reason); will walk the BIO stack and return the 'reason' for the special - * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return - * the code. - */ -/* - * Returned from the SSL bio when the certificate retrieval code had an error - */ -# define BIO_RR_SSL_X509_LOOKUP 0x01 -/* Returned from the connect BIO when a connect would have blocked */ -# define BIO_RR_CONNECT 0x02 -/* Returned from the accept BIO when an accept would have blocked */ -# define BIO_RR_ACCEPT 0x03 - -/* These are passed by the BIO callback */ -# define BIO_CB_FREE 0x01 -# define BIO_CB_READ 0x02 -# define BIO_CB_WRITE 0x03 -# define BIO_CB_PUTS 0x04 -# define BIO_CB_GETS 0x05 -# define BIO_CB_CTRL 0x06 - -/* - * The callback is called before and after the underling operation, The - * BIO_CB_RETURN flag indicates if it is after the call - */ -# define BIO_CB_RETURN 0x80 -# define BIO_CB_return(a) ((a)|BIO_CB_RETURN) -# define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) -# define BIO_cb_post(a) ((a)&BIO_CB_RETURN) - -typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi, - long argl, long ret); -typedef long (*BIO_callback_fn_ex)(BIO *b, int oper, const char *argp, - size_t len, int argi, - long argl, int ret, size_t *processed); -BIO_callback_fn BIO_get_callback(const BIO *b); -void BIO_set_callback(BIO *b, BIO_callback_fn callback); - -BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b); -void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex callback); - -char *BIO_get_callback_arg(const BIO *b); -void BIO_set_callback_arg(BIO *b, char *arg); - -typedef struct bio_method_st BIO_METHOD; - -const char *BIO_method_name(const BIO *b); -int BIO_method_type(const BIO *b); - -typedef int BIO_info_cb(BIO *, int, int); -typedef BIO_info_cb bio_info_cb; /* backward compatibility */ - -DEFINE_STACK_OF(BIO) - -/* Prefix and suffix callback in ASN1 BIO */ -typedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen, - void *parg); - -# ifndef OPENSSL_NO_SCTP -/* SCTP parameter structs */ -struct bio_dgram_sctp_sndinfo { - uint16_t snd_sid; - uint16_t snd_flags; - uint32_t snd_ppid; - uint32_t snd_context; -}; - -struct bio_dgram_sctp_rcvinfo { - uint16_t rcv_sid; - uint16_t rcv_ssn; - uint16_t rcv_flags; - uint32_t rcv_ppid; - uint32_t rcv_tsn; - uint32_t rcv_cumtsn; - uint32_t rcv_context; -}; - -struct bio_dgram_sctp_prinfo { - uint16_t pr_policy; - uint32_t pr_value; -}; -# endif - -/* - * #define BIO_CONN_get_param_hostname BIO_ctrl - */ - -# define BIO_C_SET_CONNECT 100 -# define BIO_C_DO_STATE_MACHINE 101 -# define BIO_C_SET_NBIO 102 -/* # define BIO_C_SET_PROXY_PARAM 103 */ -# define BIO_C_SET_FD 104 -# define BIO_C_GET_FD 105 -# define BIO_C_SET_FILE_PTR 106 -# define BIO_C_GET_FILE_PTR 107 -# define BIO_C_SET_FILENAME 108 -# define BIO_C_SET_SSL 109 -# define BIO_C_GET_SSL 110 -# define BIO_C_SET_MD 111 -# define BIO_C_GET_MD 112 -# define BIO_C_GET_CIPHER_STATUS 113 -# define BIO_C_SET_BUF_MEM 114 -# define BIO_C_GET_BUF_MEM_PTR 115 -# define BIO_C_GET_BUFF_NUM_LINES 116 -# define BIO_C_SET_BUFF_SIZE 117 -# define BIO_C_SET_ACCEPT 118 -# define BIO_C_SSL_MODE 119 -# define BIO_C_GET_MD_CTX 120 -/* # define BIO_C_GET_PROXY_PARAM 121 */ -# define BIO_C_SET_BUFF_READ_DATA 122/* data to read first */ -# define BIO_C_GET_CONNECT 123 -# define BIO_C_GET_ACCEPT 124 -# define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 -# define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 -# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 -# define BIO_C_FILE_SEEK 128 -# define BIO_C_GET_CIPHER_CTX 129 -# define BIO_C_SET_BUF_MEM_EOF_RETURN 130/* return end of input - * value */ -# define BIO_C_SET_BIND_MODE 131 -# define BIO_C_GET_BIND_MODE 132 -# define BIO_C_FILE_TELL 133 -# define BIO_C_GET_SOCKS 134 -# define BIO_C_SET_SOCKS 135 - -# define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ -# define BIO_C_GET_WRITE_BUF_SIZE 137 -# define BIO_C_MAKE_BIO_PAIR 138 -# define BIO_C_DESTROY_BIO_PAIR 139 -# define BIO_C_GET_WRITE_GUARANTEE 140 -# define BIO_C_GET_READ_REQUEST 141 -# define BIO_C_SHUTDOWN_WR 142 -# define BIO_C_NREAD0 143 -# define BIO_C_NREAD 144 -# define BIO_C_NWRITE0 145 -# define BIO_C_NWRITE 146 -# define BIO_C_RESET_READ_REQUEST 147 -# define BIO_C_SET_MD_CTX 148 - -# define BIO_C_SET_PREFIX 149 -# define BIO_C_GET_PREFIX 150 -# define BIO_C_SET_SUFFIX 151 -# define BIO_C_GET_SUFFIX 152 - -# define BIO_C_SET_EX_ARG 153 -# define BIO_C_GET_EX_ARG 154 - -# define BIO_C_SET_CONNECT_MODE 155 - -# define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) -# define BIO_get_app_data(s) BIO_get_ex_data(s,0) - -# define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) - -# ifndef OPENSSL_NO_SOCK -/* IP families we support, for BIO_s_connect() and BIO_s_accept() */ -/* Note: the underlying operating system may not support some of them */ -# define BIO_FAMILY_IPV4 4 -# define BIO_FAMILY_IPV6 6 -# define BIO_FAMILY_IPANY 256 - -/* BIO_s_connect() */ -# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0, \ - (char *)(name)) -# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1, \ - (char *)(port)) -# define BIO_set_conn_address(b,addr) BIO_ctrl(b,BIO_C_SET_CONNECT,2, \ - (char *)(addr)) -# define BIO_set_conn_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,f) -# define BIO_get_conn_hostname(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)) -# define BIO_get_conn_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)) -# define BIO_get_conn_address(b) ((const BIO_ADDR *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)) -# define BIO_get_conn_ip_family(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL) -# define BIO_set_conn_mode(b,n) BIO_ctrl(b,BIO_C_SET_CONNECT_MODE,(n),NULL) - -/* BIO_s_accept() */ -# define BIO_set_accept_name(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0, \ - (char *)(name)) -# define BIO_set_accept_port(b,port) BIO_ctrl(b,BIO_C_SET_ACCEPT,1, \ - (char *)(port)) -# define BIO_get_accept_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)) -# define BIO_get_accept_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,1)) -# define BIO_get_peer_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,2)) -# define BIO_get_peer_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,3)) -/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ -# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(n)?(void *)"a":NULL) -# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,3, \ - (char *)(bio)) -# define BIO_set_accept_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_ACCEPT,4,f) -# define BIO_get_accept_ip_family(b) BIO_ctrl(b,BIO_C_GET_ACCEPT,4,NULL) - -/* Aliases kept for backward compatibility */ -# define BIO_BIND_NORMAL 0 -# define BIO_BIND_REUSEADDR BIO_SOCK_REUSEADDR -# define BIO_BIND_REUSEADDR_IF_UNUSED BIO_SOCK_REUSEADDR -# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) -# define BIO_get_bind_mode(b) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) - -/* BIO_s_accept() and BIO_s_connect() */ -# define BIO_do_connect(b) BIO_do_handshake(b) -# define BIO_do_accept(b) BIO_do_handshake(b) -# endif /* OPENSSL_NO_SOCK */ - -# define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) - -/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */ -# define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) -# define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)(c)) - -/* BIO_s_file() */ -# define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)(fp)) -# define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)(fpp)) - -/* BIO_s_fd() and BIO_s_file() */ -# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) -# define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) - -/* - * name is cast to lose const, but might be better to route through a - * function so we can do it safely - */ -# ifdef CONST_STRICT -/* - * If you are wondering why this isn't defined, its because CONST_STRICT is - * purely a compile-time kludge to allow const to be checked. - */ -int BIO_read_filename(BIO *b, const char *name); -# else -# define BIO_read_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_READ,(char *)(name)) -# endif -# define BIO_write_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_WRITE,name) -# define BIO_append_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_APPEND,name) -# define BIO_rw_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) - -/* - * WARNING WARNING, this ups the reference count on the read bio of the SSL - * structure. This is because the ssl read BIO is now pointed to by the - * next_bio field in the bio. So when you free the BIO, make sure you are - * doing a BIO_free_all() to catch the underlying BIO. - */ -# define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)(ssl)) -# define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)(sslp)) -# define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) -# define BIO_set_ssl_renegotiate_bytes(b,num) \ - BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL) -# define BIO_get_num_renegotiates(b) \ - BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL) -# define BIO_set_ssl_renegotiate_timeout(b,seconds) \ - BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL) - -/* defined in evp.h */ -/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)(md)) */ - -# define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)(pp)) -# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)(bm)) -# define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0, \ - (char *)(pp)) -# define BIO_set_mem_eof_return(b,v) \ - BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) - -/* For the BIO_f_buffer() type */ -# define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) -# define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) -# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) -# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) -# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) - -/* Don't use the next one unless you know what you are doing :-) */ -# define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret)) - -# define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL) -# define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) -# define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL) -# define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) -# define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) -# define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) -/* ...pending macros have inappropriate return type */ -size_t BIO_ctrl_pending(BIO *b); -size_t BIO_ctrl_wpending(BIO *b); -# define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) -# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \ - cbp) -# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb) - -/* For the BIO_f_buffer() type */ -# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) -# define BIO_buffer_peek(b,s,l) BIO_ctrl(b,BIO_CTRL_PEEK,(l),(s)) - -/* For BIO_s_bio() */ -# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) -# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) -# define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) -# define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) -# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) -/* macros with inappropriate type -- but ...pending macros use int too: */ -# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) -# define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) -size_t BIO_ctrl_get_write_guarantee(BIO *b); -size_t BIO_ctrl_get_read_request(BIO *b); -int BIO_ctrl_reset_read_request(BIO *b); - -/* ctrl macros for dgram */ -# define BIO_ctrl_dgram_connect(b,peer) \ - (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)(peer)) -# define BIO_ctrl_set_connected(b,peer) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)(peer)) -# define BIO_dgram_recv_timedout(b) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) -# define BIO_dgram_send_timedout(b) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) -# define BIO_dgram_get_peer(b,peer) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)(peer)) -# define BIO_dgram_set_peer(b,peer) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)(peer)) -# define BIO_dgram_get_mtu_overhead(b) \ - (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL) - -#define BIO_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef) -int BIO_set_ex_data(BIO *bio, int idx, void *data); -void *BIO_get_ex_data(BIO *bio, int idx); -uint64_t BIO_number_read(BIO *bio); -uint64_t BIO_number_written(BIO *bio); - -/* For BIO_f_asn1() */ -int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix, - asn1_ps_func *prefix_free); -int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix, - asn1_ps_func **pprefix_free); -int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, - asn1_ps_func *suffix_free); -int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, - asn1_ps_func **psuffix_free); - -const BIO_METHOD *BIO_s_file(void); -BIO *BIO_new_file(const char *filename, const char *mode); -# ifndef OPENSSL_NO_STDIO -BIO *BIO_new_fp(FILE *stream, int close_flag); -# endif -BIO *BIO_new(const BIO_METHOD *type); -int BIO_free(BIO *a); -void BIO_set_data(BIO *a, void *ptr); -void *BIO_get_data(BIO *a); -void BIO_set_init(BIO *a, int init); -int BIO_get_init(BIO *a); -void BIO_set_shutdown(BIO *a, int shut); -int BIO_get_shutdown(BIO *a); -void BIO_vfree(BIO *a); -int BIO_up_ref(BIO *a); -int BIO_read(BIO *b, void *data, int dlen); -int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes); -int BIO_gets(BIO *bp, char *buf, int size); -int BIO_write(BIO *b, const void *data, int dlen); -int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written); -int BIO_puts(BIO *bp, const char *buf); -int BIO_indent(BIO *b, int indent, int max); -long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg); -long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp); -void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg); -long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg); -BIO *BIO_push(BIO *b, BIO *append); -BIO *BIO_pop(BIO *b); -void BIO_free_all(BIO *a); -BIO *BIO_find_type(BIO *b, int bio_type); -BIO *BIO_next(BIO *b); -void BIO_set_next(BIO *b, BIO *next); -BIO *BIO_get_retry_BIO(BIO *bio, int *reason); -int BIO_get_retry_reason(BIO *bio); -void BIO_set_retry_reason(BIO *bio, int reason); -BIO *BIO_dup_chain(BIO *in); - -int BIO_nread0(BIO *bio, char **buf); -int BIO_nread(BIO *bio, char **buf, int num); -int BIO_nwrite0(BIO *bio, char **buf); -int BIO_nwrite(BIO *bio, char **buf, int num); - -long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi, - long argl, long ret); - -const BIO_METHOD *BIO_s_mem(void); -const BIO_METHOD *BIO_s_secmem(void); -BIO *BIO_new_mem_buf(const void *buf, int len); -# ifndef OPENSSL_NO_SOCK -const BIO_METHOD *BIO_s_socket(void); -const BIO_METHOD *BIO_s_connect(void); -const BIO_METHOD *BIO_s_accept(void); -# endif -const BIO_METHOD *BIO_s_fd(void); -const BIO_METHOD *BIO_s_log(void); -const BIO_METHOD *BIO_s_bio(void); -const BIO_METHOD *BIO_s_null(void); -const BIO_METHOD *BIO_f_null(void); -const BIO_METHOD *BIO_f_buffer(void); -const BIO_METHOD *BIO_f_linebuffer(void); -const BIO_METHOD *BIO_f_nbio_test(void); -# ifndef OPENSSL_NO_DGRAM -const BIO_METHOD *BIO_s_datagram(void); -int BIO_dgram_non_fatal_error(int error); -BIO *BIO_new_dgram(int fd, int close_flag); -# ifndef OPENSSL_NO_SCTP -const BIO_METHOD *BIO_s_datagram_sctp(void); -BIO *BIO_new_dgram_sctp(int fd, int close_flag); -int BIO_dgram_is_sctp(BIO *bio); -int BIO_dgram_sctp_notification_cb(BIO *b, - void (*handle_notifications) (BIO *bio, - void *context, - void *buf), - void *context); -int BIO_dgram_sctp_wait_for_dry(BIO *b); -int BIO_dgram_sctp_msg_waiting(BIO *b); -# endif -# endif - -# ifndef OPENSSL_NO_SOCK -int BIO_sock_should_retry(int i); -int BIO_sock_non_fatal_error(int error); -# endif - -int BIO_fd_should_retry(int i); -int BIO_fd_non_fatal_error(int error); -int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u), - void *u, const char *s, int len); -int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), - void *u, const char *s, int len, int indent); -int BIO_dump(BIO *b, const char *bytes, int len); -int BIO_dump_indent(BIO *b, const char *bytes, int len, int indent); -# ifndef OPENSSL_NO_STDIO -int BIO_dump_fp(FILE *fp, const char *s, int len); -int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent); -# endif -int BIO_hex_string(BIO *out, int indent, int width, unsigned char *data, - int datalen); - -# ifndef OPENSSL_NO_SOCK -BIO_ADDR *BIO_ADDR_new(void); -int BIO_ADDR_rawmake(BIO_ADDR *ap, int family, - const void *where, size_t wherelen, unsigned short port); -void BIO_ADDR_free(BIO_ADDR *); -void BIO_ADDR_clear(BIO_ADDR *ap); -int BIO_ADDR_family(const BIO_ADDR *ap); -int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l); -unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap); -char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric); -char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric); -char *BIO_ADDR_path_string(const BIO_ADDR *ap); - -const BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai); -int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai); -int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai); -int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai); -const BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai); -void BIO_ADDRINFO_free(BIO_ADDRINFO *bai); - -enum BIO_hostserv_priorities { - BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV -}; -int BIO_parse_hostserv(const char *hostserv, char **host, char **service, - enum BIO_hostserv_priorities hostserv_prio); -enum BIO_lookup_type { - BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER -}; -int BIO_lookup(const char *host, const char *service, - enum BIO_lookup_type lookup_type, - int family, int socktype, BIO_ADDRINFO **res); -int BIO_lookup_ex(const char *host, const char *service, - int lookup_type, int family, int socktype, int protocol, - BIO_ADDRINFO **res); -int BIO_sock_error(int sock); -int BIO_socket_ioctl(int fd, long type, void *arg); -int BIO_socket_nbio(int fd, int mode); -int BIO_sock_init(void); -# if OPENSSL_API_COMPAT < 0x10100000L -# define BIO_sock_cleanup() while(0) continue -# endif -int BIO_set_tcp_ndelay(int sock, int turn_on); - -DEPRECATEDIN_1_1_0(struct hostent *BIO_gethostbyname(const char *name)) -DEPRECATEDIN_1_1_0(int BIO_get_port(const char *str, unsigned short *port_ptr)) -DEPRECATEDIN_1_1_0(int BIO_get_host_ip(const char *str, unsigned char *ip)) -DEPRECATEDIN_1_1_0(int BIO_get_accept_socket(char *host_port, int mode)) -DEPRECATEDIN_1_1_0(int BIO_accept(int sock, char **ip_port)) - -union BIO_sock_info_u { - BIO_ADDR *addr; -}; -enum BIO_sock_info_type { - BIO_SOCK_INFO_ADDRESS -}; -int BIO_sock_info(int sock, - enum BIO_sock_info_type type, union BIO_sock_info_u *info); - -# define BIO_SOCK_REUSEADDR 0x01 -# define BIO_SOCK_V6_ONLY 0x02 -# define BIO_SOCK_KEEPALIVE 0x04 -# define BIO_SOCK_NONBLOCK 0x08 -# define BIO_SOCK_NODELAY 0x10 - -int BIO_socket(int domain, int socktype, int protocol, int options); -int BIO_connect(int sock, const BIO_ADDR *addr, int options); -int BIO_bind(int sock, const BIO_ADDR *addr, int options); -int BIO_listen(int sock, const BIO_ADDR *addr, int options); -int BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options); -int BIO_closesocket(int sock); - -BIO *BIO_new_socket(int sock, int close_flag); -BIO *BIO_new_connect(const char *host_port); -BIO *BIO_new_accept(const char *host_port); -# endif /* OPENSSL_NO_SOCK*/ - -BIO *BIO_new_fd(int fd, int close_flag); - -int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, - BIO **bio2, size_t writebuf2); -/* - * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. - * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default - * value. - */ - -void BIO_copy_next_retry(BIO *b); - -/* - * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg); - */ - -# define ossl_bio__attr__(x) -# if defined(__GNUC__) && defined(__STDC_VERSION__) \ - && !defined(__APPLE__) - /* - * Because we support the 'z' modifier, which made its appearance in C99, - * we can't use __attribute__ with pre C99 dialects. - */ -# if __STDC_VERSION__ >= 199901L -# undef ossl_bio__attr__ -# define ossl_bio__attr__ __attribute__ -# if __GNUC__*10 + __GNUC_MINOR__ >= 44 -# define ossl_bio__printf__ __gnu_printf__ -# else -# define ossl_bio__printf__ __printf__ -# endif -# endif -# endif -int BIO_printf(BIO *bio, const char *format, ...) -ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 3))); -int BIO_vprintf(BIO *bio, const char *format, va_list args) -ossl_bio__attr__((__format__(ossl_bio__printf__, 2, 0))); -int BIO_snprintf(char *buf, size_t n, const char *format, ...) -ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 4))); -int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) -ossl_bio__attr__((__format__(ossl_bio__printf__, 3, 0))); -# undef ossl_bio__attr__ -# undef ossl_bio__printf__ - - -BIO_METHOD *BIO_meth_new(int type, const char *name); -void BIO_meth_free(BIO_METHOD *biom); -int (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, int); -int (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *, size_t, - size_t *); -int BIO_meth_set_write(BIO_METHOD *biom, - int (*write) (BIO *, const char *, int)); -int BIO_meth_set_write_ex(BIO_METHOD *biom, - int (*bwrite) (BIO *, const char *, size_t, size_t *)); -int (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int); -int (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *, size_t, size_t *); -int BIO_meth_set_read(BIO_METHOD *biom, - int (*read) (BIO *, char *, int)); -int BIO_meth_set_read_ex(BIO_METHOD *biom, - int (*bread) (BIO *, char *, size_t, size_t *)); -int (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *); -int BIO_meth_set_puts(BIO_METHOD *biom, - int (*puts) (BIO *, const char *)); -int (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int); -int BIO_meth_set_gets(BIO_METHOD *biom, - int (*gets) (BIO *, char *, int)); -long (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, long, void *); -int BIO_meth_set_ctrl(BIO_METHOD *biom, - long (*ctrl) (BIO *, int, long, void *)); -int (*BIO_meth_get_create(const BIO_METHOD *bion)) (BIO *); -int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *)); -int (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *); -int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *)); -long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom)) - (BIO *, int, BIO_info_cb *); -int BIO_meth_set_callback_ctrl(BIO_METHOD *biom, - long (*callback_ctrl) (BIO *, int, - BIO_info_cb *)); - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/bioerr.h b/client/3rd/OpenSSL/include/openssl/bioerr.h deleted file mode 100644 index 46e2c96e..00000000 --- a/client/3rd/OpenSSL/include/openssl/bioerr.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_BIOERR_H -# define HEADER_BIOERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_BIO_strings(void); - -/* - * BIO function codes. - */ -# define BIO_F_ACPT_STATE 100 -# define BIO_F_ADDRINFO_WRAP 148 -# define BIO_F_ADDR_STRINGS 134 -# define BIO_F_BIO_ACCEPT 101 -# define BIO_F_BIO_ACCEPT_EX 137 -# define BIO_F_BIO_ACCEPT_NEW 152 -# define BIO_F_BIO_ADDR_NEW 144 -# define BIO_F_BIO_BIND 147 -# define BIO_F_BIO_CALLBACK_CTRL 131 -# define BIO_F_BIO_CONNECT 138 -# define BIO_F_BIO_CONNECT_NEW 153 -# define BIO_F_BIO_CTRL 103 -# define BIO_F_BIO_GETS 104 -# define BIO_F_BIO_GET_HOST_IP 106 -# define BIO_F_BIO_GET_NEW_INDEX 102 -# define BIO_F_BIO_GET_PORT 107 -# define BIO_F_BIO_LISTEN 139 -# define BIO_F_BIO_LOOKUP 135 -# define BIO_F_BIO_LOOKUP_EX 143 -# define BIO_F_BIO_MAKE_PAIR 121 -# define BIO_F_BIO_METH_NEW 146 -# define BIO_F_BIO_NEW 108 -# define BIO_F_BIO_NEW_DGRAM_SCTP 145 -# define BIO_F_BIO_NEW_FILE 109 -# define BIO_F_BIO_NEW_MEM_BUF 126 -# define BIO_F_BIO_NREAD 123 -# define BIO_F_BIO_NREAD0 124 -# define BIO_F_BIO_NWRITE 125 -# define BIO_F_BIO_NWRITE0 122 -# define BIO_F_BIO_PARSE_HOSTSERV 136 -# define BIO_F_BIO_PUTS 110 -# define BIO_F_BIO_READ 111 -# define BIO_F_BIO_READ_EX 105 -# define BIO_F_BIO_READ_INTERN 120 -# define BIO_F_BIO_SOCKET 140 -# define BIO_F_BIO_SOCKET_NBIO 142 -# define BIO_F_BIO_SOCK_INFO 141 -# define BIO_F_BIO_SOCK_INIT 112 -# define BIO_F_BIO_WRITE 113 -# define BIO_F_BIO_WRITE_EX 119 -# define BIO_F_BIO_WRITE_INTERN 128 -# define BIO_F_BUFFER_CTRL 114 -# define BIO_F_CONN_CTRL 127 -# define BIO_F_CONN_STATE 115 -# define BIO_F_DGRAM_SCTP_NEW 149 -# define BIO_F_DGRAM_SCTP_READ 132 -# define BIO_F_DGRAM_SCTP_WRITE 133 -# define BIO_F_DOAPR_OUTCH 150 -# define BIO_F_FILE_CTRL 116 -# define BIO_F_FILE_READ 130 -# define BIO_F_LINEBUFFER_CTRL 129 -# define BIO_F_LINEBUFFER_NEW 151 -# define BIO_F_MEM_WRITE 117 -# define BIO_F_NBIOF_NEW 154 -# define BIO_F_SLG_WRITE 155 -# define BIO_F_SSL_NEW 118 - -/* - * BIO reason codes. - */ -# define BIO_R_ACCEPT_ERROR 100 -# define BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET 141 -# define BIO_R_AMBIGUOUS_HOST_OR_SERVICE 129 -# define BIO_R_BAD_FOPEN_MODE 101 -# define BIO_R_BROKEN_PIPE 124 -# define BIO_R_CONNECT_ERROR 103 -# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 -# define BIO_R_GETSOCKNAME_ERROR 132 -# define BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS 133 -# define BIO_R_GETTING_SOCKTYPE 134 -# define BIO_R_INVALID_ARGUMENT 125 -# define BIO_R_INVALID_SOCKET 135 -# define BIO_R_IN_USE 123 -# define BIO_R_LENGTH_TOO_LONG 102 -# define BIO_R_LISTEN_V6_ONLY 136 -# define BIO_R_LOOKUP_RETURNED_NOTHING 142 -# define BIO_R_MALFORMED_HOST_OR_SERVICE 130 -# define BIO_R_NBIO_CONNECT_ERROR 110 -# define BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED 143 -# define BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED 144 -# define BIO_R_NO_PORT_DEFINED 113 -# define BIO_R_NO_SUCH_FILE 128 -# define BIO_R_NULL_PARAMETER 115 -# define BIO_R_UNABLE_TO_BIND_SOCKET 117 -# define BIO_R_UNABLE_TO_CREATE_SOCKET 118 -# define BIO_R_UNABLE_TO_KEEPALIVE 137 -# define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 -# define BIO_R_UNABLE_TO_NODELAY 138 -# define BIO_R_UNABLE_TO_REUSEADDR 139 -# define BIO_R_UNAVAILABLE_IP_FAMILY 145 -# define BIO_R_UNINITIALIZED 120 -# define BIO_R_UNKNOWN_INFO_TYPE 140 -# define BIO_R_UNSUPPORTED_IP_FAMILY 146 -# define BIO_R_UNSUPPORTED_METHOD 121 -# define BIO_R_UNSUPPORTED_PROTOCOL_FAMILY 131 -# define BIO_R_WRITE_TO_READ_ONLY_BIO 126 -# define BIO_R_WSASTARTUP 122 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/blowfish.h b/client/3rd/OpenSSL/include/openssl/blowfish.h deleted file mode 100644 index cd3e460e..00000000 --- a/client/3rd/OpenSSL/include/openssl/blowfish.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_BLOWFISH_H -# define HEADER_BLOWFISH_H - -# include - -# ifndef OPENSSL_NO_BF -# include -# ifdef __cplusplus -extern "C" { -# endif - -# define BF_ENCRYPT 1 -# define BF_DECRYPT 0 - -/*- - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! BF_LONG has to be at least 32 bits wide. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ -# define BF_LONG unsigned int - -# define BF_ROUNDS 16 -# define BF_BLOCK 8 - -typedef struct bf_key_st { - BF_LONG P[BF_ROUNDS + 2]; - BF_LONG S[4 * 256]; -} BF_KEY; - -void BF_set_key(BF_KEY *key, int len, const unsigned char *data); - -void BF_encrypt(BF_LONG *data, const BF_KEY *key); -void BF_decrypt(BF_LONG *data, const BF_KEY *key); - -void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, - const BF_KEY *key, int enc); -void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int enc); -void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, const BF_KEY *schedule, - unsigned char *ivec, int *num, int enc); -void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, const BF_KEY *schedule, - unsigned char *ivec, int *num); -const char *BF_options(void); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/bn.h b/client/3rd/OpenSSL/include/openssl/bn.h deleted file mode 100644 index d8776604..00000000 --- a/client/3rd/OpenSSL/include/openssl/bn.h +++ /dev/null @@ -1,539 +0,0 @@ -/* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_BN_H -# define HEADER_BN_H - -# include -# ifndef OPENSSL_NO_STDIO -# include -# endif -# include -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * 64-bit processor with LP64 ABI - */ -# ifdef SIXTY_FOUR_BIT_LONG -# define BN_ULONG unsigned long -# define BN_BYTES 8 -# endif - -/* - * 64-bit processor other than LP64 ABI - */ -# ifdef SIXTY_FOUR_BIT -# define BN_ULONG unsigned long long -# define BN_BYTES 8 -# endif - -# ifdef THIRTY_TWO_BIT -# define BN_ULONG unsigned int -# define BN_BYTES 4 -# endif - -# define BN_BITS2 (BN_BYTES * 8) -# define BN_BITS (BN_BITS2 * 2) -# define BN_TBIT ((BN_ULONG)1 << (BN_BITS2 - 1)) - -# define BN_FLG_MALLOCED 0x01 -# define BN_FLG_STATIC_DATA 0x02 - -/* - * avoid leaking exponent information through timing, - * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime, - * BN_div() will call BN_div_no_branch, - * BN_mod_inverse() will call bn_mod_inverse_no_branch. - */ -# define BN_FLG_CONSTTIME 0x04 -# define BN_FLG_SECURE 0x08 - -# if OPENSSL_API_COMPAT < 0x00908000L -/* deprecated name for the flag */ -# define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME -# define BN_FLG_FREE 0x8000 /* used for debugging */ -# endif - -void BN_set_flags(BIGNUM *b, int n); -int BN_get_flags(const BIGNUM *b, int n); - -/* Values for |top| in BN_rand() */ -#define BN_RAND_TOP_ANY -1 -#define BN_RAND_TOP_ONE 0 -#define BN_RAND_TOP_TWO 1 - -/* Values for |bottom| in BN_rand() */ -#define BN_RAND_BOTTOM_ANY 0 -#define BN_RAND_BOTTOM_ODD 1 - -/* - * get a clone of a BIGNUM with changed flags, for *temporary* use only (the - * two BIGNUMs cannot be used in parallel!). Also only for *read only* use. The - * value |dest| should be a newly allocated BIGNUM obtained via BN_new() that - * has not been otherwise initialised or used. - */ -void BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags); - -/* Wrapper function to make using BN_GENCB easier */ -int BN_GENCB_call(BN_GENCB *cb, int a, int b); - -BN_GENCB *BN_GENCB_new(void); -void BN_GENCB_free(BN_GENCB *cb); - -/* Populate a BN_GENCB structure with an "old"-style callback */ -void BN_GENCB_set_old(BN_GENCB *gencb, void (*callback) (int, int, void *), - void *cb_arg); - -/* Populate a BN_GENCB structure with a "new"-style callback */ -void BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *), - void *cb_arg); - -void *BN_GENCB_get_arg(BN_GENCB *cb); - -# define BN_prime_checks 0 /* default: select number of iterations based - * on the size of the number */ - -/* - * BN_prime_checks_for_size() returns the number of Miller-Rabin iterations - * that will be done for checking that a random number is probably prime. The - * error rate for accepting a composite number as prime depends on the size of - * the prime |b|. The error rates used are for calculating an RSA key with 2 primes, - * and so the level is what you would expect for a key of double the size of the - * prime. - * - * This table is generated using the algorithm of FIPS PUB 186-4 - * Digital Signature Standard (DSS), section F.1, page 117. - * (https://dx.doi.org/10.6028/NIST.FIPS.186-4) - * - * The following magma script was used to generate the output: - * securitybits:=125; - * k:=1024; - * for t:=1 to 65 do - * for M:=3 to Floor(2*Sqrt(k-1)-1) do - * S:=0; - * // Sum over m - * for m:=3 to M do - * s:=0; - * // Sum over j - * for j:=2 to m do - * s+:=(RealField(32)!2)^-(j+(k-1)/j); - * end for; - * S+:=2^(m-(m-1)*t)*s; - * end for; - * A:=2^(k-2-M*t); - * B:=8*(Pi(RealField(32))^2-6)/3*2^(k-2)*S; - * pkt:=2.00743*Log(2)*k*2^-k*(A+B); - * seclevel:=Floor(-Log(2,pkt)); - * if seclevel ge securitybits then - * printf "k: %5o, security: %o bits (t: %o, M: %o)\n",k,seclevel,t,M; - * break; - * end if; - * end for; - * if seclevel ge securitybits then break; end if; - * end for; - * - * It can be run online at: - * http://magma.maths.usyd.edu.au/calc - * - * And will output: - * k: 1024, security: 129 bits (t: 6, M: 23) - * - * k is the number of bits of the prime, securitybits is the level we want to - * reach. - * - * prime length | RSA key size | # MR tests | security level - * -------------+--------------|------------+--------------- - * (b) >= 6394 | >= 12788 | 3 | 256 bit - * (b) >= 3747 | >= 7494 | 3 | 192 bit - * (b) >= 1345 | >= 2690 | 4 | 128 bit - * (b) >= 1080 | >= 2160 | 5 | 128 bit - * (b) >= 852 | >= 1704 | 5 | 112 bit - * (b) >= 476 | >= 952 | 5 | 80 bit - * (b) >= 400 | >= 800 | 6 | 80 bit - * (b) >= 347 | >= 694 | 7 | 80 bit - * (b) >= 308 | >= 616 | 8 | 80 bit - * (b) >= 55 | >= 110 | 27 | 64 bit - * (b) >= 6 | >= 12 | 34 | 64 bit - */ - -# define BN_prime_checks_for_size(b) ((b) >= 3747 ? 3 : \ - (b) >= 1345 ? 4 : \ - (b) >= 476 ? 5 : \ - (b) >= 400 ? 6 : \ - (b) >= 347 ? 7 : \ - (b) >= 308 ? 8 : \ - (b) >= 55 ? 27 : \ - /* b >= 6 */ 34) - -# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) - -int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w); -int BN_is_zero(const BIGNUM *a); -int BN_is_one(const BIGNUM *a); -int BN_is_word(const BIGNUM *a, const BN_ULONG w); -int BN_is_odd(const BIGNUM *a); - -# define BN_one(a) (BN_set_word((a),1)) - -void BN_zero_ex(BIGNUM *a); - -# if OPENSSL_API_COMPAT >= 0x00908000L -# define BN_zero(a) BN_zero_ex(a) -# else -# define BN_zero(a) (BN_set_word((a),0)) -# endif - -const BIGNUM *BN_value_one(void); -char *BN_options(void); -BN_CTX *BN_CTX_new(void); -BN_CTX *BN_CTX_secure_new(void); -void BN_CTX_free(BN_CTX *c); -void BN_CTX_start(BN_CTX *ctx); -BIGNUM *BN_CTX_get(BN_CTX *ctx); -void BN_CTX_end(BN_CTX *ctx); -int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); -int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom); -int BN_rand_range(BIGNUM *rnd, const BIGNUM *range); -int BN_priv_rand_range(BIGNUM *rnd, const BIGNUM *range); -int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); -int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range); -int BN_num_bits(const BIGNUM *a); -int BN_num_bits_word(BN_ULONG l); -int BN_security_bits(int L, int N); -BIGNUM *BN_new(void); -BIGNUM *BN_secure_new(void); -void BN_clear_free(BIGNUM *a); -BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); -void BN_swap(BIGNUM *a, BIGNUM *b); -BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret); -int BN_bn2bin(const BIGNUM *a, unsigned char *to); -int BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen); -BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret); -int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen); -BIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret); -int BN_bn2mpi(const BIGNUM *a, unsigned char *to); -int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); -int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx); -/** BN_set_negative sets sign of a BIGNUM - * \param b pointer to the BIGNUM object - * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise - */ -void BN_set_negative(BIGNUM *b, int n); -/** BN_is_negative returns 1 if the BIGNUM is negative - * \param b pointer to the BIGNUM object - * \return 1 if a < 0 and 0 otherwise - */ -int BN_is_negative(const BIGNUM *b); - -int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, - BN_CTX *ctx); -# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) -int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); -int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, - BN_CTX *ctx); -int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m); -int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, - BN_CTX *ctx); -int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m); -int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, - BN_CTX *ctx); -int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); -int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, - BN_CTX *ctx); -int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); - -BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); -BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); -int BN_mul_word(BIGNUM *a, BN_ULONG w); -int BN_add_word(BIGNUM *a, BN_ULONG w); -int BN_sub_word(BIGNUM *a, BN_ULONG w); -int BN_set_word(BIGNUM *a, BN_ULONG w); -BN_ULONG BN_get_word(const BIGNUM *a); - -int BN_cmp(const BIGNUM *a, const BIGNUM *b); -void BN_free(BIGNUM *a); -int BN_is_bit_set(const BIGNUM *a, int n); -int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); -int BN_lshift1(BIGNUM *r, const BIGNUM *a); -int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); - -int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); -int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *in_mont); -int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, - const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); - -int BN_mask_bits(BIGNUM *a, int n); -# ifndef OPENSSL_NO_STDIO -int BN_print_fp(FILE *fp, const BIGNUM *a); -# endif -int BN_print(BIO *bio, const BIGNUM *a); -int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); -int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); -int BN_rshift1(BIGNUM *r, const BIGNUM *a); -void BN_clear(BIGNUM *a); -BIGNUM *BN_dup(const BIGNUM *a); -int BN_ucmp(const BIGNUM *a, const BIGNUM *b); -int BN_set_bit(BIGNUM *a, int n); -int BN_clear_bit(BIGNUM *a, int n); -char *BN_bn2hex(const BIGNUM *a); -char *BN_bn2dec(const BIGNUM *a); -int BN_hex2bn(BIGNUM **a, const char *str); -int BN_dec2bn(BIGNUM **a, const char *str); -int BN_asc2bn(BIGNUM **a, const char *str); -int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); -int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns - * -2 for - * error */ -BIGNUM *BN_mod_inverse(BIGNUM *ret, - const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); -BIGNUM *BN_mod_sqrt(BIGNUM *ret, - const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); - -void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords); - -/* Deprecated versions */ -DEPRECATEDIN_0_9_8(BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, - const BIGNUM *add, - const BIGNUM *rem, - void (*callback) (int, int, - void *), - void *cb_arg)) -DEPRECATEDIN_0_9_8(int - BN_is_prime(const BIGNUM *p, int nchecks, - void (*callback) (int, int, void *), - BN_CTX *ctx, void *cb_arg)) -DEPRECATEDIN_0_9_8(int - BN_is_prime_fasttest(const BIGNUM *p, int nchecks, - void (*callback) (int, int, void *), - BN_CTX *ctx, void *cb_arg, - int do_trial_division)) - -/* Newer versions */ -int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, - const BIGNUM *rem, BN_GENCB *cb); -int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb); -int BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, - int do_trial_division, BN_GENCB *cb); - -int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx); - -int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, - const BIGNUM *Xp, const BIGNUM *Xp1, - const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx, - BN_GENCB *cb); -int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1, - BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e, - BN_CTX *ctx, BN_GENCB *cb); - -BN_MONT_CTX *BN_MONT_CTX_new(void); -int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - BN_MONT_CTX *mont, BN_CTX *ctx); -int BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, - BN_CTX *ctx); -int BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, - BN_CTX *ctx); -void BN_MONT_CTX_free(BN_MONT_CTX *mont); -int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx); -BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from); -BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_RWLOCK *lock, - const BIGNUM *mod, BN_CTX *ctx); - -/* BN_BLINDING flags */ -# define BN_BLINDING_NO_UPDATE 0x00000001 -# define BN_BLINDING_NO_RECREATE 0x00000002 - -BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod); -void BN_BLINDING_free(BN_BLINDING *b); -int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx); -int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); -int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); -int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); -int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, - BN_CTX *); - -int BN_BLINDING_is_current_thread(BN_BLINDING *b); -void BN_BLINDING_set_current_thread(BN_BLINDING *b); -int BN_BLINDING_lock(BN_BLINDING *b); -int BN_BLINDING_unlock(BN_BLINDING *b); - -unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); -void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); -BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, - const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, - int (*bn_mod_exp) (BIGNUM *r, - const BIGNUM *a, - const BIGNUM *p, - const BIGNUM *m, - BN_CTX *ctx, - BN_MONT_CTX *m_ctx), - BN_MONT_CTX *m_ctx); - -DEPRECATEDIN_0_9_8(void BN_set_params(int mul, int high, int low, int mont)) -DEPRECATEDIN_0_9_8(int BN_get_params(int which)) /* 0, mul, 1 high, 2 low, 3 - * mont */ - -BN_RECP_CTX *BN_RECP_CTX_new(void); -void BN_RECP_CTX_free(BN_RECP_CTX *recp); -int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx); -int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, - BN_RECP_CTX *recp, BN_CTX *ctx); -int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); -int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, - BN_RECP_CTX *recp, BN_CTX *ctx); - -# ifndef OPENSSL_NO_EC2M - -/* - * Functions for arithmetic over binary polynomials represented by BIGNUMs. - * The BIGNUM::neg property of BIGNUMs representing binary polynomials is - * ignored. Note that input arguments are not const so that their bit arrays - * can be expanded to the appropriate size if needed. - */ - -/* - * r = a + b - */ -int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -# define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) -/* - * r=a mod p - */ -int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); -/* r = (a * b) mod p */ -int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *p, BN_CTX *ctx); -/* r = (a * a) mod p */ -int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -/* r = (1 / b) mod p */ -int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx); -/* r = (a / b) mod p */ -int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *p, BN_CTX *ctx); -/* r = (a ^ b) mod p */ -int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *p, BN_CTX *ctx); -/* r = sqrt(a) mod p */ -int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - BN_CTX *ctx); -/* r^2 + r = a mod p */ -int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - BN_CTX *ctx); -# define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) -/*- - * Some functions allow for representation of the irreducible polynomials - * as an unsigned int[], say p. The irreducible f(t) is then of the form: - * t^p[0] + t^p[1] + ... + t^p[k] - * where m = p[0] > p[1] > ... > p[k] = 0. - */ -/* r = a mod p */ -int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]); -/* r = (a * b) mod p */ -int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const int p[], BN_CTX *ctx); -/* r = (a * a) mod p */ -int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], - BN_CTX *ctx); -/* r = (1 / b) mod p */ -int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[], - BN_CTX *ctx); -/* r = (a / b) mod p */ -int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const int p[], BN_CTX *ctx); -/* r = (a ^ b) mod p */ -int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const int p[], BN_CTX *ctx); -/* r = sqrt(a) mod p */ -int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, - const int p[], BN_CTX *ctx); -/* r^2 + r = a mod p */ -int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, - const int p[], BN_CTX *ctx); -int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max); -int BN_GF2m_arr2poly(const int p[], BIGNUM *a); - -# endif - -/* - * faster mod functions for the 'NIST primes' 0 <= a < p^2 - */ -int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); - -const BIGNUM *BN_get0_nist_prime_192(void); -const BIGNUM *BN_get0_nist_prime_224(void); -const BIGNUM *BN_get0_nist_prime_256(void); -const BIGNUM *BN_get0_nist_prime_384(void); -const BIGNUM *BN_get0_nist_prime_521(void); - -int (*BN_nist_mod_func(const BIGNUM *p)) (BIGNUM *r, const BIGNUM *a, - const BIGNUM *field, BN_CTX *ctx); - -int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, - const BIGNUM *priv, const unsigned char *message, - size_t message_len, BN_CTX *ctx); - -/* Primes from RFC 2409 */ -BIGNUM *BN_get_rfc2409_prime_768(BIGNUM *bn); -BIGNUM *BN_get_rfc2409_prime_1024(BIGNUM *bn); - -/* Primes from RFC 3526 */ -BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *bn); -BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *bn); -BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *bn); -BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn); -BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn); -BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define get_rfc2409_prime_768 BN_get_rfc2409_prime_768 -# define get_rfc2409_prime_1024 BN_get_rfc2409_prime_1024 -# define get_rfc3526_prime_1536 BN_get_rfc3526_prime_1536 -# define get_rfc3526_prime_2048 BN_get_rfc3526_prime_2048 -# define get_rfc3526_prime_3072 BN_get_rfc3526_prime_3072 -# define get_rfc3526_prime_4096 BN_get_rfc3526_prime_4096 -# define get_rfc3526_prime_6144 BN_get_rfc3526_prime_6144 -# define get_rfc3526_prime_8192 BN_get_rfc3526_prime_8192 -# endif - -int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom); - - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/bnerr.h b/client/3rd/OpenSSL/include/openssl/bnerr.h deleted file mode 100644 index 9f3c7cfa..00000000 --- a/client/3rd/OpenSSL/include/openssl/bnerr.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_BNERR_H -# define HEADER_BNERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_BN_strings(void); - -/* - * BN function codes. - */ -# define BN_F_BNRAND 127 -# define BN_F_BNRAND_RANGE 138 -# define BN_F_BN_BLINDING_CONVERT_EX 100 -# define BN_F_BN_BLINDING_CREATE_PARAM 128 -# define BN_F_BN_BLINDING_INVERT_EX 101 -# define BN_F_BN_BLINDING_NEW 102 -# define BN_F_BN_BLINDING_UPDATE 103 -# define BN_F_BN_BN2DEC 104 -# define BN_F_BN_BN2HEX 105 -# define BN_F_BN_COMPUTE_WNAF 142 -# define BN_F_BN_CTX_GET 116 -# define BN_F_BN_CTX_NEW 106 -# define BN_F_BN_CTX_START 129 -# define BN_F_BN_DIV 107 -# define BN_F_BN_DIV_RECP 130 -# define BN_F_BN_EXP 123 -# define BN_F_BN_EXPAND_INTERNAL 120 -# define BN_F_BN_GENCB_NEW 143 -# define BN_F_BN_GENERATE_DSA_NONCE 140 -# define BN_F_BN_GENERATE_PRIME_EX 141 -# define BN_F_BN_GF2M_MOD 131 -# define BN_F_BN_GF2M_MOD_EXP 132 -# define BN_F_BN_GF2M_MOD_MUL 133 -# define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134 -# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135 -# define BN_F_BN_GF2M_MOD_SQR 136 -# define BN_F_BN_GF2M_MOD_SQRT 137 -# define BN_F_BN_LSHIFT 145 -# define BN_F_BN_MOD_EXP2_MONT 118 -# define BN_F_BN_MOD_EXP_MONT 109 -# define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124 -# define BN_F_BN_MOD_EXP_MONT_WORD 117 -# define BN_F_BN_MOD_EXP_RECP 125 -# define BN_F_BN_MOD_EXP_SIMPLE 126 -# define BN_F_BN_MOD_INVERSE 110 -# define BN_F_BN_MOD_INVERSE_NO_BRANCH 139 -# define BN_F_BN_MOD_LSHIFT_QUICK 119 -# define BN_F_BN_MOD_SQRT 121 -# define BN_F_BN_MONT_CTX_NEW 149 -# define BN_F_BN_MPI2BN 112 -# define BN_F_BN_NEW 113 -# define BN_F_BN_POOL_GET 147 -# define BN_F_BN_RAND 114 -# define BN_F_BN_RAND_RANGE 122 -# define BN_F_BN_RECP_CTX_NEW 150 -# define BN_F_BN_RSHIFT 146 -# define BN_F_BN_SET_WORDS 144 -# define BN_F_BN_STACK_PUSH 148 -# define BN_F_BN_USUB 115 - -/* - * BN reason codes. - */ -# define BN_R_ARG2_LT_ARG3 100 -# define BN_R_BAD_RECIPROCAL 101 -# define BN_R_BIGNUM_TOO_LONG 114 -# define BN_R_BITS_TOO_SMALL 118 -# define BN_R_CALLED_WITH_EVEN_MODULUS 102 -# define BN_R_DIV_BY_ZERO 103 -# define BN_R_ENCODING_ERROR 104 -# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 -# define BN_R_INPUT_NOT_REDUCED 110 -# define BN_R_INVALID_LENGTH 106 -# define BN_R_INVALID_RANGE 115 -# define BN_R_INVALID_SHIFT 119 -# define BN_R_NOT_A_SQUARE 111 -# define BN_R_NOT_INITIALIZED 107 -# define BN_R_NO_INVERSE 108 -# define BN_R_NO_SOLUTION 116 -# define BN_R_PRIVATE_KEY_TOO_LARGE 117 -# define BN_R_P_IS_NOT_PRIME 112 -# define BN_R_TOO_MANY_ITERATIONS 113 -# define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/buffer.h b/client/3rd/OpenSSL/include/openssl/buffer.h deleted file mode 100644 index d2765766..00000000 --- a/client/3rd/OpenSSL/include/openssl/buffer.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_BUFFER_H -# define HEADER_BUFFER_H - -# include -# ifndef HEADER_CRYPTO_H -# include -# endif -# include - - -#ifdef __cplusplus -extern "C" { -#endif - -# include -# include - -/* - * These names are outdated as of OpenSSL 1.1; a future release - * will move them to be deprecated. - */ -# define BUF_strdup(s) OPENSSL_strdup(s) -# define BUF_strndup(s, size) OPENSSL_strndup(s, size) -# define BUF_memdup(data, size) OPENSSL_memdup(data, size) -# define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size) -# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size) -# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen) - -struct buf_mem_st { - size_t length; /* current number of bytes */ - char *data; - size_t max; /* size of buffer */ - unsigned long flags; -}; - -# define BUF_MEM_FLAG_SECURE 0x01 - -BUF_MEM *BUF_MEM_new(void); -BUF_MEM *BUF_MEM_new_ex(unsigned long flags); -void BUF_MEM_free(BUF_MEM *a); -size_t BUF_MEM_grow(BUF_MEM *str, size_t len); -size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len); -void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); - - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/buffererr.h b/client/3rd/OpenSSL/include/openssl/buffererr.h deleted file mode 100644 index 04f6ff7a..00000000 --- a/client/3rd/OpenSSL/include/openssl/buffererr.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_BUFERR_H -# define HEADER_BUFERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_BUF_strings(void); - -/* - * BUF function codes. - */ -# define BUF_F_BUF_MEM_GROW 100 -# define BUF_F_BUF_MEM_GROW_CLEAN 105 -# define BUF_F_BUF_MEM_NEW 101 - -/* - * BUF reason codes. - */ - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/camellia.h b/client/3rd/OpenSSL/include/openssl/camellia.h deleted file mode 100644 index 151f3c13..00000000 --- a/client/3rd/OpenSSL/include/openssl/camellia.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CAMELLIA_H -# define HEADER_CAMELLIA_H - -# include - -# ifndef OPENSSL_NO_CAMELLIA -# include -#ifdef __cplusplus -extern "C" { -#endif - -# define CAMELLIA_ENCRYPT 1 -# define CAMELLIA_DECRYPT 0 - -/* - * Because array size can't be a const in C, the following two are macros. - * Both sizes are in bytes. - */ - -/* This should be a hidden type, but EVP requires that the size be known */ - -# define CAMELLIA_BLOCK_SIZE 16 -# define CAMELLIA_TABLE_BYTE_LEN 272 -# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) - -typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match - * with WORD */ - -struct camellia_key_st { - union { - double d; /* ensures 64-bit align */ - KEY_TABLE_TYPE rd_key; - } u; - int grand_rounds; -}; -typedef struct camellia_key_st CAMELLIA_KEY; - -int Camellia_set_key(const unsigned char *userKey, const int bits, - CAMELLIA_KEY *key); - -void Camellia_encrypt(const unsigned char *in, unsigned char *out, - const CAMELLIA_KEY *key); -void Camellia_decrypt(const unsigned char *in, unsigned char *out, - const CAMELLIA_KEY *key); - -void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, - const CAMELLIA_KEY *key, const int enc); -void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, const int enc); -void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num, const int enc); -void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num, const int enc); -void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num, const int enc); -void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num); -void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char ivec[CAMELLIA_BLOCK_SIZE], - unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], - unsigned int *num); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/cast.h b/client/3rd/OpenSSL/include/openssl/cast.h deleted file mode 100644 index 2cc89ae0..00000000 --- a/client/3rd/OpenSSL/include/openssl/cast.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CAST_H -# define HEADER_CAST_H - -# include - -# ifndef OPENSSL_NO_CAST -# ifdef __cplusplus -extern "C" { -# endif - -# define CAST_ENCRYPT 1 -# define CAST_DECRYPT 0 - -# define CAST_LONG unsigned int - -# define CAST_BLOCK 8 -# define CAST_KEY_LENGTH 16 - -typedef struct cast_key_st { - CAST_LONG data[32]; - int short_key; /* Use reduced rounds for short key */ -} CAST_KEY; - -void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); -void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, - const CAST_KEY *key, int enc); -void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key); -void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key); -void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, - long length, const CAST_KEY *ks, unsigned char *iv, - int enc); -void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, const CAST_KEY *schedule, - unsigned char *ivec, int *num, int enc); -void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, const CAST_KEY *schedule, - unsigned char *ivec, int *num); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/cmac.h b/client/3rd/OpenSSL/include/openssl/cmac.h deleted file mode 100644 index 3535a9ab..00000000 --- a/client/3rd/OpenSSL/include/openssl/cmac.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CMAC_H -# define HEADER_CMAC_H - -# ifndef OPENSSL_NO_CMAC - -#ifdef __cplusplus -extern "C" { -#endif - -# include - -/* Opaque */ -typedef struct CMAC_CTX_st CMAC_CTX; - -CMAC_CTX *CMAC_CTX_new(void); -void CMAC_CTX_cleanup(CMAC_CTX *ctx); -void CMAC_CTX_free(CMAC_CTX *ctx); -EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx); -int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in); - -int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, - const EVP_CIPHER *cipher, ENGINE *impl); -int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); -int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); -int CMAC_resume(CMAC_CTX *ctx); - -#ifdef __cplusplus -} -#endif - -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/cms.h b/client/3rd/OpenSSL/include/openssl/cms.h deleted file mode 100644 index c7627968..00000000 --- a/client/3rd/OpenSSL/include/openssl/cms.h +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright 2008-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CMS_H -# define HEADER_CMS_H - -# include - -# ifndef OPENSSL_NO_CMS -# include -# include -# include -# ifdef __cplusplus -extern "C" { -# endif - -typedef struct CMS_ContentInfo_st CMS_ContentInfo; -typedef struct CMS_SignerInfo_st CMS_SignerInfo; -typedef struct CMS_CertificateChoices CMS_CertificateChoices; -typedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice; -typedef struct CMS_RecipientInfo_st CMS_RecipientInfo; -typedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest; -typedef struct CMS_Receipt_st CMS_Receipt; -typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey; -typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute; - -DEFINE_STACK_OF(CMS_SignerInfo) -DEFINE_STACK_OF(CMS_RecipientEncryptedKey) -DEFINE_STACK_OF(CMS_RecipientInfo) -DEFINE_STACK_OF(CMS_RevocationInfoChoice) -DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) -DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest) -DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo) - -# define CMS_SIGNERINFO_ISSUER_SERIAL 0 -# define CMS_SIGNERINFO_KEYIDENTIFIER 1 - -# define CMS_RECIPINFO_NONE -1 -# define CMS_RECIPINFO_TRANS 0 -# define CMS_RECIPINFO_AGREE 1 -# define CMS_RECIPINFO_KEK 2 -# define CMS_RECIPINFO_PASS 3 -# define CMS_RECIPINFO_OTHER 4 - -/* S/MIME related flags */ - -# define CMS_TEXT 0x1 -# define CMS_NOCERTS 0x2 -# define CMS_NO_CONTENT_VERIFY 0x4 -# define CMS_NO_ATTR_VERIFY 0x8 -# define CMS_NOSIGS \ - (CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY) -# define CMS_NOINTERN 0x10 -# define CMS_NO_SIGNER_CERT_VERIFY 0x20 -# define CMS_NOVERIFY 0x20 -# define CMS_DETACHED 0x40 -# define CMS_BINARY 0x80 -# define CMS_NOATTR 0x100 -# define CMS_NOSMIMECAP 0x200 -# define CMS_NOOLDMIMETYPE 0x400 -# define CMS_CRLFEOL 0x800 -# define CMS_STREAM 0x1000 -# define CMS_NOCRL 0x2000 -# define CMS_PARTIAL 0x4000 -# define CMS_REUSE_DIGEST 0x8000 -# define CMS_USE_KEYID 0x10000 -# define CMS_DEBUG_DECRYPT 0x20000 -# define CMS_KEY_PARAM 0x40000 -# define CMS_ASCIICRLF 0x80000 - -const ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms); - -BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont); -int CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio); - -ASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms); -int CMS_is_detached(CMS_ContentInfo *cms); -int CMS_set_detached(CMS_ContentInfo *cms, int detached); - -# ifdef HEADER_PEM_H -DECLARE_PEM_rw_const(CMS, CMS_ContentInfo) -# endif -int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms); -CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms); -int i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms); - -BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms); -int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags); -int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, - int flags); -CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont); -int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags); - -int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, - unsigned int flags); - -CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, - STACK_OF(X509) *certs, BIO *data, - unsigned int flags); - -CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si, - X509 *signcert, EVP_PKEY *pkey, - STACK_OF(X509) *certs, unsigned int flags); - -int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags); -CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags); - -int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out, - unsigned int flags); -CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md, - unsigned int flags); - -int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms, - const unsigned char *key, size_t keylen, - BIO *dcont, BIO *out, unsigned int flags); - -CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher, - const unsigned char *key, - size_t keylen, unsigned int flags); - -int CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph, - const unsigned char *key, size_t keylen); - -int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, - X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags); - -int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms, - STACK_OF(X509) *certs, - X509_STORE *store, unsigned int flags); - -STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms); - -CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in, - const EVP_CIPHER *cipher, unsigned int flags); - -int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert, - BIO *dcont, BIO *out, unsigned int flags); - -int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert); -int CMS_decrypt_set1_key(CMS_ContentInfo *cms, - unsigned char *key, size_t keylen, - const unsigned char *id, size_t idlen); -int CMS_decrypt_set1_password(CMS_ContentInfo *cms, - unsigned char *pass, ossl_ssize_t passlen); - -STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms); -int CMS_RecipientInfo_type(CMS_RecipientInfo *ri); -EVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri); -CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher); -CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms, - X509 *recip, unsigned int flags); -int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey); -int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert); -int CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri, - EVP_PKEY **pk, X509 **recip, - X509_ALGOR **palg); -int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri, - ASN1_OCTET_STRING **keyid, - X509_NAME **issuer, - ASN1_INTEGER **sno); - -CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, - unsigned char *key, size_t keylen, - unsigned char *id, size_t idlen, - ASN1_GENERALIZEDTIME *date, - ASN1_OBJECT *otherTypeId, - ASN1_TYPE *otherType); - -int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri, - X509_ALGOR **palg, - ASN1_OCTET_STRING **pid, - ASN1_GENERALIZEDTIME **pdate, - ASN1_OBJECT **potherid, - ASN1_TYPE **pothertype); - -int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri, - unsigned char *key, size_t keylen); - -int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri, - const unsigned char *id, size_t idlen); - -int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, - unsigned char *pass, - ossl_ssize_t passlen); - -CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms, - int iter, int wrap_nid, - int pbe_nid, - unsigned char *pass, - ossl_ssize_t passlen, - const EVP_CIPHER *kekciph); - -int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri); -int CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri); - -int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out, - unsigned int flags); -CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags); - -int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid); -const ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms); - -CMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms); -int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert); -int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert); -STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms); - -CMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms); -int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl); -int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl); -STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms); - -int CMS_SignedData_init(CMS_ContentInfo *cms); -CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, - X509 *signer, EVP_PKEY *pk, const EVP_MD *md, - unsigned int flags); -EVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si); -EVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si); -STACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms); - -void CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer); -int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si, - ASN1_OCTET_STRING **keyid, - X509_NAME **issuer, ASN1_INTEGER **sno); -int CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert); -int CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs, - unsigned int flags); -void CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk, - X509 **signer, X509_ALGOR **pdig, - X509_ALGOR **psig); -ASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si); -int CMS_SignerInfo_sign(CMS_SignerInfo *si); -int CMS_SignerInfo_verify(CMS_SignerInfo *si); -int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain); - -int CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs); -int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs, - int algnid, int keysize); -int CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap); - -int CMS_signed_get_attr_count(const CMS_SignerInfo *si); -int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid, - int lastpos); -int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj, - int lastpos); -X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc); -X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc); -int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr); -int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si, - const ASN1_OBJECT *obj, int type, - const void *bytes, int len); -int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si, - int nid, int type, - const void *bytes, int len); -int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si, - const char *attrname, int type, - const void *bytes, int len); -void *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *oid, - int lastpos, int type); - -int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si); -int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid, - int lastpos); -int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, - const ASN1_OBJECT *obj, int lastpos); -X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc); -X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc); -int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr); -int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si, - const ASN1_OBJECT *obj, int type, - const void *bytes, int len); -int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si, - int nid, int type, - const void *bytes, int len); -int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si, - const char *attrname, int type, - const void *bytes, int len); -void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid, - int lastpos, int type); - -int CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr); -CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen, - int allorfirst, - STACK_OF(GENERAL_NAMES) - *receiptList, STACK_OF(GENERAL_NAMES) - *receiptsTo); -int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr); -void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr, - ASN1_STRING **pcid, - int *pallorfirst, - STACK_OF(GENERAL_NAMES) **plist, - STACK_OF(GENERAL_NAMES) **prto); -int CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri, - X509_ALGOR **palg, - ASN1_OCTET_STRING **pukm); -STACK_OF(CMS_RecipientEncryptedKey) -*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri); - -int CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri, - X509_ALGOR **pubalg, - ASN1_BIT_STRING **pubkey, - ASN1_OCTET_STRING **keyid, - X509_NAME **issuer, - ASN1_INTEGER **sno); - -int CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert); - -int CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek, - ASN1_OCTET_STRING **keyid, - ASN1_GENERALIZEDTIME **tm, - CMS_OtherKeyAttribute **other, - X509_NAME **issuer, ASN1_INTEGER **sno); -int CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek, - X509 *cert); -int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk); -EVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri); -int CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms, - CMS_RecipientInfo *ri, - CMS_RecipientEncryptedKey *rek); - -int CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg, - ASN1_OCTET_STRING *ukm, int keylen); - -/* Backward compatibility for spelling errors. */ -# define CMS_R_UNKNOWN_DIGEST_ALGORITM CMS_R_UNKNOWN_DIGEST_ALGORITHM -# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE \ - CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/cmserr.h b/client/3rd/OpenSSL/include/openssl/cmserr.h deleted file mode 100644 index 7dbc13dc..00000000 --- a/client/3rd/OpenSSL/include/openssl/cmserr.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CMSERR_H -# define HEADER_CMSERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# include - -# ifndef OPENSSL_NO_CMS - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_CMS_strings(void); - -/* - * CMS function codes. - */ -# define CMS_F_CHECK_CONTENT 99 -# define CMS_F_CMS_ADD0_CERT 164 -# define CMS_F_CMS_ADD0_RECIPIENT_KEY 100 -# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD 165 -# define CMS_F_CMS_ADD1_RECEIPTREQUEST 158 -# define CMS_F_CMS_ADD1_RECIPIENT_CERT 101 -# define CMS_F_CMS_ADD1_SIGNER 102 -# define CMS_F_CMS_ADD1_SIGNINGTIME 103 -# define CMS_F_CMS_COMPRESS 104 -# define CMS_F_CMS_COMPRESSEDDATA_CREATE 105 -# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO 106 -# define CMS_F_CMS_COPY_CONTENT 107 -# define CMS_F_CMS_COPY_MESSAGEDIGEST 108 -# define CMS_F_CMS_DATA 109 -# define CMS_F_CMS_DATAFINAL 110 -# define CMS_F_CMS_DATAINIT 111 -# define CMS_F_CMS_DECRYPT 112 -# define CMS_F_CMS_DECRYPT_SET1_KEY 113 -# define CMS_F_CMS_DECRYPT_SET1_PASSWORD 166 -# define CMS_F_CMS_DECRYPT_SET1_PKEY 114 -# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX 115 -# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO 116 -# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL 117 -# define CMS_F_CMS_DIGEST_VERIFY 118 -# define CMS_F_CMS_ENCODE_RECEIPT 161 -# define CMS_F_CMS_ENCRYPT 119 -# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT 179 -# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO 120 -# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT 121 -# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT 122 -# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY 123 -# define CMS_F_CMS_ENVELOPEDDATA_CREATE 124 -# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO 125 -# define CMS_F_CMS_ENVELOPED_DATA_INIT 126 -# define CMS_F_CMS_ENV_ASN1_CTRL 171 -# define CMS_F_CMS_FINAL 127 -# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES 128 -# define CMS_F_CMS_GET0_CONTENT 129 -# define CMS_F_CMS_GET0_ECONTENT_TYPE 130 -# define CMS_F_CMS_GET0_ENVELOPED 131 -# define CMS_F_CMS_GET0_REVOCATION_CHOICES 132 -# define CMS_F_CMS_GET0_SIGNED 133 -# define CMS_F_CMS_MSGSIGDIGEST_ADD1 162 -# define CMS_F_CMS_RECEIPTREQUEST_CREATE0 159 -# define CMS_F_CMS_RECEIPT_VERIFY 160 -# define CMS_F_CMS_RECIPIENTINFO_DECRYPT 134 -# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT 169 -# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT 178 -# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG 175 -# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID 173 -# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS 172 -# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP 174 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT 135 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT 136 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID 137 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP 138 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP 139 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT 140 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT 141 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS 142 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID 143 -# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT 167 -# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY 144 -# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD 168 -# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY 145 -# define CMS_F_CMS_SD_ASN1_CTRL 170 -# define CMS_F_CMS_SET1_IAS 176 -# define CMS_F_CMS_SET1_KEYID 177 -# define CMS_F_CMS_SET1_SIGNERIDENTIFIER 146 -# define CMS_F_CMS_SET_DETACHED 147 -# define CMS_F_CMS_SIGN 148 -# define CMS_F_CMS_SIGNED_DATA_INIT 149 -# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN 150 -# define CMS_F_CMS_SIGNERINFO_SIGN 151 -# define CMS_F_CMS_SIGNERINFO_VERIFY 152 -# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT 153 -# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT 154 -# define CMS_F_CMS_SIGN_RECEIPT 163 -# define CMS_F_CMS_SI_CHECK_ATTRIBUTES 183 -# define CMS_F_CMS_STREAM 155 -# define CMS_F_CMS_UNCOMPRESS 156 -# define CMS_F_CMS_VERIFY 157 -# define CMS_F_KEK_UNWRAP_KEY 180 - -/* - * CMS reason codes. - */ -# define CMS_R_ADD_SIGNER_ERROR 99 -# define CMS_R_ATTRIBUTE_ERROR 161 -# define CMS_R_CERTIFICATE_ALREADY_PRESENT 175 -# define CMS_R_CERTIFICATE_HAS_NO_KEYID 160 -# define CMS_R_CERTIFICATE_VERIFY_ERROR 100 -# define CMS_R_CIPHER_INITIALISATION_ERROR 101 -# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR 102 -# define CMS_R_CMS_DATAFINAL_ERROR 103 -# define CMS_R_CMS_LIB 104 -# define CMS_R_CONTENTIDENTIFIER_MISMATCH 170 -# define CMS_R_CONTENT_NOT_FOUND 105 -# define CMS_R_CONTENT_TYPE_MISMATCH 171 -# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA 106 -# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA 107 -# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA 108 -# define CMS_R_CONTENT_VERIFY_ERROR 109 -# define CMS_R_CTRL_ERROR 110 -# define CMS_R_CTRL_FAILURE 111 -# define CMS_R_DECRYPT_ERROR 112 -# define CMS_R_ERROR_GETTING_PUBLIC_KEY 113 -# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE 114 -# define CMS_R_ERROR_SETTING_KEY 115 -# define CMS_R_ERROR_SETTING_RECIPIENTINFO 116 -# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH 117 -# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER 176 -# define CMS_R_INVALID_KEY_LENGTH 118 -# define CMS_R_MD_BIO_INIT_ERROR 119 -# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH 120 -# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH 121 -# define CMS_R_MSGSIGDIGEST_ERROR 172 -# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE 162 -# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH 163 -# define CMS_R_NEED_ONE_SIGNER 164 -# define CMS_R_NOT_A_SIGNED_RECEIPT 165 -# define CMS_R_NOT_ENCRYPTED_DATA 122 -# define CMS_R_NOT_KEK 123 -# define CMS_R_NOT_KEY_AGREEMENT 181 -# define CMS_R_NOT_KEY_TRANSPORT 124 -# define CMS_R_NOT_PWRI 177 -# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 125 -# define CMS_R_NO_CIPHER 126 -# define CMS_R_NO_CONTENT 127 -# define CMS_R_NO_CONTENT_TYPE 173 -# define CMS_R_NO_DEFAULT_DIGEST 128 -# define CMS_R_NO_DIGEST_SET 129 -# define CMS_R_NO_KEY 130 -# define CMS_R_NO_KEY_OR_CERT 174 -# define CMS_R_NO_MATCHING_DIGEST 131 -# define CMS_R_NO_MATCHING_RECIPIENT 132 -# define CMS_R_NO_MATCHING_SIGNATURE 166 -# define CMS_R_NO_MSGSIGDIGEST 167 -# define CMS_R_NO_PASSWORD 178 -# define CMS_R_NO_PRIVATE_KEY 133 -# define CMS_R_NO_PUBLIC_KEY 134 -# define CMS_R_NO_RECEIPT_REQUEST 168 -# define CMS_R_NO_SIGNERS 135 -# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 136 -# define CMS_R_RECEIPT_DECODE_ERROR 169 -# define CMS_R_RECIPIENT_ERROR 137 -# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND 138 -# define CMS_R_SIGNFINAL_ERROR 139 -# define CMS_R_SMIME_TEXT_ERROR 140 -# define CMS_R_STORE_INIT_ERROR 141 -# define CMS_R_TYPE_NOT_COMPRESSED_DATA 142 -# define CMS_R_TYPE_NOT_DATA 143 -# define CMS_R_TYPE_NOT_DIGESTED_DATA 144 -# define CMS_R_TYPE_NOT_ENCRYPTED_DATA 145 -# define CMS_R_TYPE_NOT_ENVELOPED_DATA 146 -# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT 147 -# define CMS_R_UNKNOWN_CIPHER 148 -# define CMS_R_UNKNOWN_DIGEST_ALGORITHM 149 -# define CMS_R_UNKNOWN_ID 150 -# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM 151 -# define CMS_R_UNSUPPORTED_CONTENT_TYPE 152 -# define CMS_R_UNSUPPORTED_KEK_ALGORITHM 153 -# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM 179 -# define CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE 155 -# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE 154 -# define CMS_R_UNSUPPORTED_TYPE 156 -# define CMS_R_UNWRAP_ERROR 157 -# define CMS_R_UNWRAP_FAILURE 180 -# define CMS_R_VERIFICATION_FAILURE 158 -# define CMS_R_WRAP_ERROR 159 - -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/comp.h b/client/3rd/OpenSSL/include/openssl/comp.h deleted file mode 100644 index d814d3cf..00000000 --- a/client/3rd/OpenSSL/include/openssl/comp.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_COMP_H -# define HEADER_COMP_H - -# include - -# ifndef OPENSSL_NO_COMP -# include -# include -# ifdef __cplusplus -extern "C" { -# endif - - - -COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); -const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx); -int COMP_CTX_get_type(const COMP_CTX* comp); -int COMP_get_type(const COMP_METHOD *meth); -const char *COMP_get_name(const COMP_METHOD *meth); -void COMP_CTX_free(COMP_CTX *ctx); - -int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, - unsigned char *in, int ilen); -int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, - unsigned char *in, int ilen); - -COMP_METHOD *COMP_zlib(void); - -#if OPENSSL_API_COMPAT < 0x10100000L -#define COMP_zlib_cleanup() while(0) continue -#endif - -# ifdef HEADER_BIO_H -# ifdef ZLIB -const BIO_METHOD *BIO_f_zlib(void); -# endif -# endif - - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/comperr.h b/client/3rd/OpenSSL/include/openssl/comperr.h deleted file mode 100644 index 90231e9a..00000000 --- a/client/3rd/OpenSSL/include/openssl/comperr.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_COMPERR_H -# define HEADER_COMPERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# include - -# ifndef OPENSSL_NO_COMP - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_COMP_strings(void); - -/* - * COMP function codes. - */ -# define COMP_F_BIO_ZLIB_FLUSH 99 -# define COMP_F_BIO_ZLIB_NEW 100 -# define COMP_F_BIO_ZLIB_READ 101 -# define COMP_F_BIO_ZLIB_WRITE 102 -# define COMP_F_COMP_CTX_NEW 103 - -/* - * COMP reason codes. - */ -# define COMP_R_ZLIB_DEFLATE_ERROR 99 -# define COMP_R_ZLIB_INFLATE_ERROR 100 -# define COMP_R_ZLIB_NOT_SUPPORTED 101 - -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/conf.h b/client/3rd/OpenSSL/include/openssl/conf.h deleted file mode 100644 index 7336cd2f..00000000 --- a/client/3rd/OpenSSL/include/openssl/conf.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CONF_H -# define HEADER_CONF_H - -# include -# include -# include -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - char *section; - char *name; - char *value; -} CONF_VALUE; - -DEFINE_STACK_OF(CONF_VALUE) -DEFINE_LHASH_OF(CONF_VALUE); - -struct conf_st; -struct conf_method_st; -typedef struct conf_method_st CONF_METHOD; - -struct conf_method_st { - const char *name; - CONF *(*create) (CONF_METHOD *meth); - int (*init) (CONF *conf); - int (*destroy) (CONF *conf); - int (*destroy_data) (CONF *conf); - int (*load_bio) (CONF *conf, BIO *bp, long *eline); - int (*dump) (const CONF *conf, BIO *bp); - int (*is_number) (const CONF *conf, char c); - int (*to_int) (const CONF *conf, char c); - int (*load) (CONF *conf, const char *name, long *eline); -}; - -/* Module definitions */ - -typedef struct conf_imodule_st CONF_IMODULE; -typedef struct conf_module_st CONF_MODULE; - -DEFINE_STACK_OF(CONF_MODULE) -DEFINE_STACK_OF(CONF_IMODULE) - -/* DSO module function typedefs */ -typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf); -typedef void conf_finish_func (CONF_IMODULE *md); - -# define CONF_MFLAGS_IGNORE_ERRORS 0x1 -# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 -# define CONF_MFLAGS_SILENT 0x4 -# define CONF_MFLAGS_NO_DSO 0x8 -# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 -# define CONF_MFLAGS_DEFAULT_SECTION 0x20 - -int CONF_set_default_method(CONF_METHOD *meth); -void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash); -LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, - long *eline); -# ifndef OPENSSL_NO_STDIO -LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, - long *eline); -# endif -LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, - long *eline); -STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, - const char *section); -char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, - const char *name); -long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, - const char *name); -void CONF_free(LHASH_OF(CONF_VALUE) *conf); -#ifndef OPENSSL_NO_STDIO -int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out); -#endif -int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out); - -DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name)) - -#if OPENSSL_API_COMPAT < 0x10100000L -# define OPENSSL_no_config() \ - OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL) -#endif - -/* - * New conf code. The semantics are different from the functions above. If - * that wasn't the case, the above functions would have been replaced - */ - -struct conf_st { - CONF_METHOD *meth; - void *meth_data; - LHASH_OF(CONF_VALUE) *data; -}; - -CONF *NCONF_new(CONF_METHOD *meth); -CONF_METHOD *NCONF_default(void); -CONF_METHOD *NCONF_WIN32(void); -void NCONF_free(CONF *conf); -void NCONF_free_data(CONF *conf); - -int NCONF_load(CONF *conf, const char *file, long *eline); -# ifndef OPENSSL_NO_STDIO -int NCONF_load_fp(CONF *conf, FILE *fp, long *eline); -# endif -int NCONF_load_bio(CONF *conf, BIO *bp, long *eline); -STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, - const char *section); -char *NCONF_get_string(const CONF *conf, const char *group, const char *name); -int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, - long *result); -#ifndef OPENSSL_NO_STDIO -int NCONF_dump_fp(const CONF *conf, FILE *out); -#endif -int NCONF_dump_bio(const CONF *conf, BIO *out); - -#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) - -/* Module functions */ - -int CONF_modules_load(const CONF *cnf, const char *appname, - unsigned long flags); -int CONF_modules_load_file(const char *filename, const char *appname, - unsigned long flags); -void CONF_modules_unload(int all); -void CONF_modules_finish(void); -#if OPENSSL_API_COMPAT < 0x10100000L -# define CONF_modules_free() while(0) continue -#endif -int CONF_module_add(const char *name, conf_init_func *ifunc, - conf_finish_func *ffunc); - -const char *CONF_imodule_get_name(const CONF_IMODULE *md); -const char *CONF_imodule_get_value(const CONF_IMODULE *md); -void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); -void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); -CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); -unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); -void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); -void *CONF_module_get_usr_data(CONF_MODULE *pmod); -void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); - -char *CONF_get1_default_config_file(void); - -int CONF_parse_list(const char *list, int sep, int nospc, - int (*list_cb) (const char *elem, int len, void *usr), - void *arg); - -void OPENSSL_load_builtin_modules(void); - - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/conf_api.h b/client/3rd/OpenSSL/include/openssl/conf_api.h deleted file mode 100644 index a0275ad7..00000000 --- a/client/3rd/OpenSSL/include/openssl/conf_api.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CONF_API_H -# define HEADER_CONF_API_H - -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Up until OpenSSL 0.9.5a, this was new_section */ -CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); -/* Up until OpenSSL 0.9.5a, this was get_section */ -CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); -/* Up until OpenSSL 0.9.5a, this was CONF_get_section */ -STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, - const char *section); - -int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); -char *_CONF_get_string(const CONF *conf, const char *section, - const char *name); -long _CONF_get_number(const CONF *conf, const char *section, - const char *name); - -int _CONF_new_data(CONF *conf); -void _CONF_free_data(CONF *conf); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/conferr.h b/client/3rd/OpenSSL/include/openssl/conferr.h deleted file mode 100644 index 32b92291..00000000 --- a/client/3rd/OpenSSL/include/openssl/conferr.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CONFERR_H -# define HEADER_CONFERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_CONF_strings(void); - -/* - * CONF function codes. - */ -# define CONF_F_CONF_DUMP_FP 104 -# define CONF_F_CONF_LOAD 100 -# define CONF_F_CONF_LOAD_FP 103 -# define CONF_F_CONF_PARSE_LIST 119 -# define CONF_F_DEF_LOAD 120 -# define CONF_F_DEF_LOAD_BIO 121 -# define CONF_F_GET_NEXT_FILE 107 -# define CONF_F_MODULE_ADD 122 -# define CONF_F_MODULE_INIT 115 -# define CONF_F_MODULE_LOAD_DSO 117 -# define CONF_F_MODULE_RUN 118 -# define CONF_F_NCONF_DUMP_BIO 105 -# define CONF_F_NCONF_DUMP_FP 106 -# define CONF_F_NCONF_GET_NUMBER_E 112 -# define CONF_F_NCONF_GET_SECTION 108 -# define CONF_F_NCONF_GET_STRING 109 -# define CONF_F_NCONF_LOAD 113 -# define CONF_F_NCONF_LOAD_BIO 110 -# define CONF_F_NCONF_LOAD_FP 114 -# define CONF_F_NCONF_NEW 111 -# define CONF_F_PROCESS_INCLUDE 116 -# define CONF_F_SSL_MODULE_INIT 123 -# define CONF_F_STR_COPY 101 - -/* - * CONF reason codes. - */ -# define CONF_R_ERROR_LOADING_DSO 110 -# define CONF_R_LIST_CANNOT_BE_NULL 115 -# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 -# define CONF_R_MISSING_EQUAL_SIGN 101 -# define CONF_R_MISSING_INIT_FUNCTION 112 -# define CONF_R_MODULE_INITIALIZATION_ERROR 109 -# define CONF_R_NO_CLOSE_BRACE 102 -# define CONF_R_NO_CONF 105 -# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 -# define CONF_R_NO_SECTION 107 -# define CONF_R_NO_SUCH_FILE 114 -# define CONF_R_NO_VALUE 108 -# define CONF_R_NUMBER_TOO_LARGE 121 -# define CONF_R_RECURSIVE_DIRECTORY_INCLUDE 111 -# define CONF_R_SSL_COMMAND_SECTION_EMPTY 117 -# define CONF_R_SSL_COMMAND_SECTION_NOT_FOUND 118 -# define CONF_R_SSL_SECTION_EMPTY 119 -# define CONF_R_SSL_SECTION_NOT_FOUND 120 -# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 -# define CONF_R_UNKNOWN_MODULE_NAME 113 -# define CONF_R_VARIABLE_EXPANSION_TOO_LONG 116 -# define CONF_R_VARIABLE_HAS_NO_VALUE 104 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/crypto.h b/client/3rd/OpenSSL/include/openssl/crypto.h deleted file mode 100644 index 7d0b5262..00000000 --- a/client/3rd/OpenSSL/include/openssl/crypto.h +++ /dev/null @@ -1,445 +0,0 @@ -/* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CRYPTO_H -# define HEADER_CRYPTO_H - -# include -# include - -# include - -# ifndef OPENSSL_NO_STDIO -# include -# endif - -# include -# include -# include -# include -# include - -# ifdef CHARSET_EBCDIC -# include -# endif - -/* - * Resolve problems on some operating systems with symbol names that clash - * one way or another - */ -# include - -# if OPENSSL_API_COMPAT < 0x10100000L -# include -# endif - -#ifdef __cplusplus -extern "C" { -#endif - -# if OPENSSL_API_COMPAT < 0x10100000L -# define SSLeay OpenSSL_version_num -# define SSLeay_version OpenSSL_version -# define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER -# define SSLEAY_VERSION OPENSSL_VERSION -# define SSLEAY_CFLAGS OPENSSL_CFLAGS -# define SSLEAY_BUILT_ON OPENSSL_BUILT_ON -# define SSLEAY_PLATFORM OPENSSL_PLATFORM -# define SSLEAY_DIR OPENSSL_DIR - -/* - * Old type for allocating dynamic locks. No longer used. Use the new thread - * API instead. - */ -typedef struct { - int dummy; -} CRYPTO_dynlock; - -# endif /* OPENSSL_API_COMPAT */ - -typedef void CRYPTO_RWLOCK; - -CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void); -int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock); -int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock); -int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock); -void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock); - -int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock); - -/* - * The following can be used to detect memory leaks in the library. If - * used, it turns on malloc checking - */ -# define CRYPTO_MEM_CHECK_OFF 0x0 /* Control only */ -# define CRYPTO_MEM_CHECK_ON 0x1 /* Control and mode bit */ -# define CRYPTO_MEM_CHECK_ENABLE 0x2 /* Control and mode bit */ -# define CRYPTO_MEM_CHECK_DISABLE 0x3 /* Control only */ - -struct crypto_ex_data_st { - STACK_OF(void) *sk; -}; -DEFINE_STACK_OF(void) - -/* - * Per class, we have a STACK of function pointers. - */ -# define CRYPTO_EX_INDEX_SSL 0 -# define CRYPTO_EX_INDEX_SSL_CTX 1 -# define CRYPTO_EX_INDEX_SSL_SESSION 2 -# define CRYPTO_EX_INDEX_X509 3 -# define CRYPTO_EX_INDEX_X509_STORE 4 -# define CRYPTO_EX_INDEX_X509_STORE_CTX 5 -# define CRYPTO_EX_INDEX_DH 6 -# define CRYPTO_EX_INDEX_DSA 7 -# define CRYPTO_EX_INDEX_EC_KEY 8 -# define CRYPTO_EX_INDEX_RSA 9 -# define CRYPTO_EX_INDEX_ENGINE 10 -# define CRYPTO_EX_INDEX_UI 11 -# define CRYPTO_EX_INDEX_BIO 12 -# define CRYPTO_EX_INDEX_APP 13 -# define CRYPTO_EX_INDEX_UI_METHOD 14 -# define CRYPTO_EX_INDEX_DRBG 15 -# define CRYPTO_EX_INDEX__COUNT 16 - -/* No longer needed, so this is a no-op */ -#define OPENSSL_malloc_init() while(0) continue - -int CRYPTO_mem_ctrl(int mode); - -# define OPENSSL_malloc(num) \ - CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_zalloc(num) \ - CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_realloc(addr, num) \ - CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_clear_realloc(addr, old_num, num) \ - CRYPTO_clear_realloc(addr, old_num, num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_clear_free(addr, num) \ - CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_free(addr) \ - CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_memdup(str, s) \ - CRYPTO_memdup((str), s, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_strdup(str) \ - CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_strndup(str, n) \ - CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_secure_malloc(num) \ - CRYPTO_secure_malloc(num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_secure_zalloc(num) \ - CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_secure_free(addr) \ - CRYPTO_secure_free(addr, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_secure_clear_free(addr, num) \ - CRYPTO_secure_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_secure_actual_size(ptr) \ - CRYPTO_secure_actual_size(ptr) - -size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz); -size_t OPENSSL_strlcat(char *dst, const char *src, size_t siz); -size_t OPENSSL_strnlen(const char *str, size_t maxlen); -char *OPENSSL_buf2hexstr(const unsigned char *buffer, long len); -unsigned char *OPENSSL_hexstr2buf(const char *str, long *len); -int OPENSSL_hexchar2int(unsigned char c); - -# define OPENSSL_MALLOC_MAX_NELEMS(type) (((1U<<(sizeof(int)*8-1))-1)/sizeof(type)) - -unsigned long OpenSSL_version_num(void); -const char *OpenSSL_version(int type); -# define OPENSSL_VERSION 0 -# define OPENSSL_CFLAGS 1 -# define OPENSSL_BUILT_ON 2 -# define OPENSSL_PLATFORM 3 -# define OPENSSL_DIR 4 -# define OPENSSL_ENGINES_DIR 5 - -int OPENSSL_issetugid(void); - -typedef void CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); -typedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); -typedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from, - void *from_d, int idx, long argl, void *argp); -__owur int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, - CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func); -/* No longer use an index. */ -int CRYPTO_free_ex_index(int class_index, int idx); - -/* - * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a - * given class (invokes whatever per-class callbacks are applicable) - */ -int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); -int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, - const CRYPTO_EX_DATA *from); - -void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); - -/* - * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular - * index (relative to the class type involved) - */ -int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); -void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx); - -# if OPENSSL_API_COMPAT < 0x10100000L -/* - * This function cleans up all "ex_data" state. It mustn't be called under - * potential race-conditions. - */ -# define CRYPTO_cleanup_all_ex_data() while(0) continue - -/* - * The old locking functions have been removed completely without compatibility - * macros. This is because the old functions either could not properly report - * errors, or the returned error values were not clearly documented. - * Replacing the locking functions with no-ops would cause race condition - * issues in the affected applications. It is far better for them to fail at - * compile time. - * On the other hand, the locking callbacks are no longer used. Consequently, - * the callback management functions can be safely replaced with no-op macros. - */ -# define CRYPTO_num_locks() (1) -# define CRYPTO_set_locking_callback(func) -# define CRYPTO_get_locking_callback() (NULL) -# define CRYPTO_set_add_lock_callback(func) -# define CRYPTO_get_add_lock_callback() (NULL) - -/* - * These defines where used in combination with the old locking callbacks, - * they are not called anymore, but old code that's not called might still - * use them. - */ -# define CRYPTO_LOCK 1 -# define CRYPTO_UNLOCK 2 -# define CRYPTO_READ 4 -# define CRYPTO_WRITE 8 - -/* This structure is no longer used */ -typedef struct crypto_threadid_st { - int dummy; -} CRYPTO_THREADID; -/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */ -# define CRYPTO_THREADID_set_numeric(id, val) -# define CRYPTO_THREADID_set_pointer(id, ptr) -# define CRYPTO_THREADID_set_callback(threadid_func) (0) -# define CRYPTO_THREADID_get_callback() (NULL) -# define CRYPTO_THREADID_current(id) -# define CRYPTO_THREADID_cmp(a, b) (-1) -# define CRYPTO_THREADID_cpy(dest, src) -# define CRYPTO_THREADID_hash(id) (0UL) - -# if OPENSSL_API_COMPAT < 0x10000000L -# define CRYPTO_set_id_callback(func) -# define CRYPTO_get_id_callback() (NULL) -# define CRYPTO_thread_id() (0UL) -# endif /* OPENSSL_API_COMPAT < 0x10000000L */ - -# define CRYPTO_set_dynlock_create_callback(dyn_create_function) -# define CRYPTO_set_dynlock_lock_callback(dyn_lock_function) -# define CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function) -# define CRYPTO_get_dynlock_create_callback() (NULL) -# define CRYPTO_get_dynlock_lock_callback() (NULL) -# define CRYPTO_get_dynlock_destroy_callback() (NULL) -# endif /* OPENSSL_API_COMPAT < 0x10100000L */ - -int CRYPTO_set_mem_functions( - void *(*m) (size_t, const char *, int), - void *(*r) (void *, size_t, const char *, int), - void (*f) (void *, const char *, int)); -int CRYPTO_set_mem_debug(int flag); -void CRYPTO_get_mem_functions( - void *(**m) (size_t, const char *, int), - void *(**r) (void *, size_t, const char *, int), - void (**f) (void *, const char *, int)); - -void *CRYPTO_malloc(size_t num, const char *file, int line); -void *CRYPTO_zalloc(size_t num, const char *file, int line); -void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line); -char *CRYPTO_strdup(const char *str, const char *file, int line); -char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line); -void CRYPTO_free(void *ptr, const char *file, int line); -void CRYPTO_clear_free(void *ptr, size_t num, const char *file, int line); -void *CRYPTO_realloc(void *addr, size_t num, const char *file, int line); -void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num, - const char *file, int line); - -int CRYPTO_secure_malloc_init(size_t sz, int minsize); -int CRYPTO_secure_malloc_done(void); -void *CRYPTO_secure_malloc(size_t num, const char *file, int line); -void *CRYPTO_secure_zalloc(size_t num, const char *file, int line); -void CRYPTO_secure_free(void *ptr, const char *file, int line); -void CRYPTO_secure_clear_free(void *ptr, size_t num, - const char *file, int line); -int CRYPTO_secure_allocated(const void *ptr); -int CRYPTO_secure_malloc_initialized(void); -size_t CRYPTO_secure_actual_size(void *ptr); -size_t CRYPTO_secure_used(void); - -void OPENSSL_cleanse(void *ptr, size_t len); - -# ifndef OPENSSL_NO_CRYPTO_MDEBUG -# define OPENSSL_mem_debug_push(info) \ - CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_mem_debug_pop() \ - CRYPTO_mem_debug_pop() -int CRYPTO_mem_debug_push(const char *info, const char *file, int line); -int CRYPTO_mem_debug_pop(void); -void CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount); - -/*- - * Debugging functions (enabled by CRYPTO_set_mem_debug(1)) - * The flag argument has the following significance: - * 0: called before the actual memory allocation has taken place - * 1: called after the actual memory allocation has taken place - */ -void CRYPTO_mem_debug_malloc(void *addr, size_t num, int flag, - const char *file, int line); -void CRYPTO_mem_debug_realloc(void *addr1, void *addr2, size_t num, int flag, - const char *file, int line); -void CRYPTO_mem_debug_free(void *addr, int flag, - const char *file, int line); - -int CRYPTO_mem_leaks_cb(int (*cb) (const char *str, size_t len, void *u), - void *u); -# ifndef OPENSSL_NO_STDIO -int CRYPTO_mem_leaks_fp(FILE *); -# endif -int CRYPTO_mem_leaks(BIO *bio); -# endif - -/* die if we have to */ -ossl_noreturn void OPENSSL_die(const char *assertion, const char *file, int line); -# if OPENSSL_API_COMPAT < 0x10100000L -# define OpenSSLDie(f,l,a) OPENSSL_die((a),(f),(l)) -# endif -# define OPENSSL_assert(e) \ - (void)((e) ? 0 : (OPENSSL_die("assertion failed: " #e, OPENSSL_FILE, OPENSSL_LINE), 1)) - -int OPENSSL_isservice(void); - -int FIPS_mode(void); -int FIPS_mode_set(int r); - -void OPENSSL_init(void); -# ifdef OPENSSL_SYS_UNIX -void OPENSSL_fork_prepare(void); -void OPENSSL_fork_parent(void); -void OPENSSL_fork_child(void); -# endif - -struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result); -int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); -int OPENSSL_gmtime_diff(int *pday, int *psec, - const struct tm *from, const struct tm *to); - -/* - * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. - * It takes an amount of time dependent on |len|, but independent of the - * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements - * into a defined order as the return value when a != b is undefined, other - * than to be non-zero. - */ -int CRYPTO_memcmp(const void * in_a, const void * in_b, size_t len); - -/* Standard initialisation options */ -# define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0x00000001L -# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L -# define OPENSSL_INIT_ADD_ALL_CIPHERS 0x00000004L -# define OPENSSL_INIT_ADD_ALL_DIGESTS 0x00000008L -# define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0x00000010L -# define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0x00000020L -# define OPENSSL_INIT_LOAD_CONFIG 0x00000040L -# define OPENSSL_INIT_NO_LOAD_CONFIG 0x00000080L -# define OPENSSL_INIT_ASYNC 0x00000100L -# define OPENSSL_INIT_ENGINE_RDRAND 0x00000200L -# define OPENSSL_INIT_ENGINE_DYNAMIC 0x00000400L -# define OPENSSL_INIT_ENGINE_OPENSSL 0x00000800L -# define OPENSSL_INIT_ENGINE_CRYPTODEV 0x00001000L -# define OPENSSL_INIT_ENGINE_CAPI 0x00002000L -# define OPENSSL_INIT_ENGINE_PADLOCK 0x00004000L -# define OPENSSL_INIT_ENGINE_AFALG 0x00008000L -/* OPENSSL_INIT_ZLIB 0x00010000L */ -# define OPENSSL_INIT_ATFORK 0x00020000L -/* OPENSSL_INIT_BASE_ONLY 0x00040000L */ -# define OPENSSL_INIT_NO_ATEXIT 0x00080000L -/* OPENSSL_INIT flag range 0xfff00000 reserved for OPENSSL_init_ssl() */ -/* Max OPENSSL_INIT flag value is 0x80000000 */ - -/* openssl and dasync not counted as builtin */ -# define OPENSSL_INIT_ENGINE_ALL_BUILTIN \ - (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \ - | OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \ - OPENSSL_INIT_ENGINE_PADLOCK) - - -/* Library initialisation functions */ -void OPENSSL_cleanup(void); -int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); -int OPENSSL_atexit(void (*handler)(void)); -void OPENSSL_thread_stop(void); - -/* Low-level control of initialization */ -OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void); -# ifndef OPENSSL_NO_STDIO -int OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings, - const char *config_filename); -void OPENSSL_INIT_set_config_file_flags(OPENSSL_INIT_SETTINGS *settings, - unsigned long flags); -int OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings, - const char *config_appname); -# endif -void OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings); - -# if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) -# if defined(_WIN32) -# if defined(BASETYPES) || defined(_WINDEF_H) -/* application has to include in order to use this */ -typedef DWORD CRYPTO_THREAD_LOCAL; -typedef DWORD CRYPTO_THREAD_ID; - -typedef LONG CRYPTO_ONCE; -# define CRYPTO_ONCE_STATIC_INIT 0 -# endif -# else -# include -typedef pthread_once_t CRYPTO_ONCE; -typedef pthread_key_t CRYPTO_THREAD_LOCAL; -typedef pthread_t CRYPTO_THREAD_ID; - -# define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT -# endif -# endif - -# if !defined(CRYPTO_ONCE_STATIC_INIT) -typedef unsigned int CRYPTO_ONCE; -typedef unsigned int CRYPTO_THREAD_LOCAL; -typedef unsigned int CRYPTO_THREAD_ID; -# define CRYPTO_ONCE_STATIC_INIT 0 -# endif - -int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void)); - -int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *)); -void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key); -int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val); -int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key); - -CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void); -int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b); - - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/cryptoerr.h b/client/3rd/OpenSSL/include/openssl/cryptoerr.h deleted file mode 100644 index 3db5a4ee..00000000 --- a/client/3rd/OpenSSL/include/openssl/cryptoerr.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CRYPTOERR_H -# define HEADER_CRYPTOERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_CRYPTO_strings(void); - -/* - * CRYPTO function codes. - */ -# define CRYPTO_F_CMAC_CTX_NEW 120 -# define CRYPTO_F_CRYPTO_DUP_EX_DATA 110 -# define CRYPTO_F_CRYPTO_FREE_EX_DATA 111 -# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 -# define CRYPTO_F_CRYPTO_MEMDUP 115 -# define CRYPTO_F_CRYPTO_NEW_EX_DATA 112 -# define CRYPTO_F_CRYPTO_OCB128_COPY_CTX 121 -# define CRYPTO_F_CRYPTO_OCB128_INIT 122 -# define CRYPTO_F_CRYPTO_SET_EX_DATA 102 -# define CRYPTO_F_FIPS_MODE_SET 109 -# define CRYPTO_F_GET_AND_LOCK 113 -# define CRYPTO_F_OPENSSL_ATEXIT 114 -# define CRYPTO_F_OPENSSL_BUF2HEXSTR 117 -# define CRYPTO_F_OPENSSL_FOPEN 119 -# define CRYPTO_F_OPENSSL_HEXSTR2BUF 118 -# define CRYPTO_F_OPENSSL_INIT_CRYPTO 116 -# define CRYPTO_F_OPENSSL_LH_NEW 126 -# define CRYPTO_F_OPENSSL_SK_DEEP_COPY 127 -# define CRYPTO_F_OPENSSL_SK_DUP 128 -# define CRYPTO_F_PKEY_HMAC_INIT 123 -# define CRYPTO_F_PKEY_POLY1305_INIT 124 -# define CRYPTO_F_PKEY_SIPHASH_INIT 125 -# define CRYPTO_F_SK_RESERVE 129 - -/* - * CRYPTO reason codes. - */ -# define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101 -# define CRYPTO_R_ILLEGAL_HEX_DIGIT 102 -# define CRYPTO_R_ODD_NUMBER_OF_DIGITS 103 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ct.h b/client/3rd/OpenSSL/include/openssl/ct.h deleted file mode 100644 index ebdba34d..00000000 --- a/client/3rd/OpenSSL/include/openssl/ct.h +++ /dev/null @@ -1,474 +0,0 @@ -/* - * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CT_H -# define HEADER_CT_H - -# include - -# ifndef OPENSSL_NO_CT -# include -# include -# include -# include -# ifdef __cplusplus -extern "C" { -# endif - - -/* Minimum RSA key size, from RFC6962 */ -# define SCT_MIN_RSA_BITS 2048 - -/* All hashes are SHA256 in v1 of Certificate Transparency */ -# define CT_V1_HASHLEN SHA256_DIGEST_LENGTH - -typedef enum { - CT_LOG_ENTRY_TYPE_NOT_SET = -1, - CT_LOG_ENTRY_TYPE_X509 = 0, - CT_LOG_ENTRY_TYPE_PRECERT = 1 -} ct_log_entry_type_t; - -typedef enum { - SCT_VERSION_NOT_SET = -1, - SCT_VERSION_V1 = 0 -} sct_version_t; - -typedef enum { - SCT_SOURCE_UNKNOWN, - SCT_SOURCE_TLS_EXTENSION, - SCT_SOURCE_X509V3_EXTENSION, - SCT_SOURCE_OCSP_STAPLED_RESPONSE -} sct_source_t; - -typedef enum { - SCT_VALIDATION_STATUS_NOT_SET, - SCT_VALIDATION_STATUS_UNKNOWN_LOG, - SCT_VALIDATION_STATUS_VALID, - SCT_VALIDATION_STATUS_INVALID, - SCT_VALIDATION_STATUS_UNVERIFIED, - SCT_VALIDATION_STATUS_UNKNOWN_VERSION -} sct_validation_status_t; - -DEFINE_STACK_OF(SCT) -DEFINE_STACK_OF(CTLOG) - -/****************************************** - * CT policy evaluation context functions * - ******************************************/ - -/* - * Creates a new, empty policy evaluation context. - * The caller is responsible for calling CT_POLICY_EVAL_CTX_free when finished - * with the CT_POLICY_EVAL_CTX. - */ -CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void); - -/* Deletes a policy evaluation context and anything it owns. */ -void CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx); - -/* Gets the peer certificate that the SCTs are for */ -X509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx); - -/* - * Sets the certificate associated with the received SCTs. - * Increments the reference count of cert. - * Returns 1 on success, 0 otherwise. - */ -int CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert); - -/* Gets the issuer of the aforementioned certificate */ -X509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx); - -/* - * Sets the issuer of the certificate associated with the received SCTs. - * Increments the reference count of issuer. - * Returns 1 on success, 0 otherwise. - */ -int CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer); - -/* Gets the CT logs that are trusted sources of SCTs */ -const CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx); - -/* Sets the log store that is in use. It must outlive the CT_POLICY_EVAL_CTX. */ -void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx, - CTLOG_STORE *log_store); - -/* - * Gets the time, in milliseconds since the Unix epoch, that will be used as the - * current time when checking whether an SCT was issued in the future. - * Such SCTs will fail validation, as required by RFC6962. - */ -uint64_t CT_POLICY_EVAL_CTX_get_time(const CT_POLICY_EVAL_CTX *ctx); - -/* - * Sets the time to evaluate SCTs against, in milliseconds since the Unix epoch. - * If an SCT's timestamp is after this time, it will be interpreted as having - * been issued in the future. RFC6962 states that "TLS clients MUST reject SCTs - * whose timestamp is in the future", so an SCT will not validate in this case. - */ -void CT_POLICY_EVAL_CTX_set_time(CT_POLICY_EVAL_CTX *ctx, uint64_t time_in_ms); - -/***************** - * SCT functions * - *****************/ - -/* - * Creates a new, blank SCT. - * The caller is responsible for calling SCT_free when finished with the SCT. - */ -SCT *SCT_new(void); - -/* - * Creates a new SCT from some base64-encoded strings. - * The caller is responsible for calling SCT_free when finished with the SCT. - */ -SCT *SCT_new_from_base64(unsigned char version, - const char *logid_base64, - ct_log_entry_type_t entry_type, - uint64_t timestamp, - const char *extensions_base64, - const char *signature_base64); - -/* - * Frees the SCT and the underlying data structures. - */ -void SCT_free(SCT *sct); - -/* - * Free a stack of SCTs, and the underlying SCTs themselves. - * Intended to be compatible with X509V3_EXT_FREE. - */ -void SCT_LIST_free(STACK_OF(SCT) *a); - -/* - * Returns the version of the SCT. - */ -sct_version_t SCT_get_version(const SCT *sct); - -/* - * Set the version of an SCT. - * Returns 1 on success, 0 if the version is unrecognized. - */ -__owur int SCT_set_version(SCT *sct, sct_version_t version); - -/* - * Returns the log entry type of the SCT. - */ -ct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct); - -/* - * Set the log entry type of an SCT. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type); - -/* - * Gets the ID of the log that an SCT came from. - * Ownership of the log ID remains with the SCT. - * Returns the length of the log ID. - */ -size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id); - -/* - * Set the log ID of an SCT to point directly to the *log_id specified. - * The SCT takes ownership of the specified pointer. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len); - -/* - * Set the log ID of an SCT. - * This makes a copy of the log_id. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id, - size_t log_id_len); - -/* - * Returns the timestamp for the SCT (epoch time in milliseconds). - */ -uint64_t SCT_get_timestamp(const SCT *sct); - -/* - * Set the timestamp of an SCT (epoch time in milliseconds). - */ -void SCT_set_timestamp(SCT *sct, uint64_t timestamp); - -/* - * Return the NID for the signature used by the SCT. - * For CT v1, this will be either NID_sha256WithRSAEncryption or - * NID_ecdsa_with_SHA256 (or NID_undef if incorrect/unset). - */ -int SCT_get_signature_nid(const SCT *sct); - -/* - * Set the signature type of an SCT - * For CT v1, this should be either NID_sha256WithRSAEncryption or - * NID_ecdsa_with_SHA256. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set_signature_nid(SCT *sct, int nid); - -/* - * Set *ext to point to the extension data for the SCT. ext must not be NULL. - * The SCT retains ownership of this pointer. - * Returns length of the data pointed to. - */ -size_t SCT_get0_extensions(const SCT *sct, unsigned char **ext); - -/* - * Set the extensions of an SCT to point directly to the *ext specified. - * The SCT takes ownership of the specified pointer. - */ -void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len); - -/* - * Set the extensions of an SCT. - * This takes a copy of the ext. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext, - size_t ext_len); - -/* - * Set *sig to point to the signature for the SCT. sig must not be NULL. - * The SCT retains ownership of this pointer. - * Returns length of the data pointed to. - */ -size_t SCT_get0_signature(const SCT *sct, unsigned char **sig); - -/* - * Set the signature of an SCT to point directly to the *sig specified. - * The SCT takes ownership of the specified pointer. - */ -void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len); - -/* - * Set the signature of an SCT to be a copy of the *sig specified. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set1_signature(SCT *sct, const unsigned char *sig, - size_t sig_len); - -/* - * The origin of this SCT, e.g. TLS extension, OCSP response, etc. - */ -sct_source_t SCT_get_source(const SCT *sct); - -/* - * Set the origin of this SCT, e.g. TLS extension, OCSP response, etc. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set_source(SCT *sct, sct_source_t source); - -/* - * Returns a text string describing the validation status of |sct|. - */ -const char *SCT_validation_status_string(const SCT *sct); - -/* - * Pretty-prints an |sct| to |out|. - * It will be indented by the number of spaces specified by |indent|. - * If |logs| is not NULL, it will be used to lookup the CT log that the SCT came - * from, so that the log name can be printed. - */ -void SCT_print(const SCT *sct, BIO *out, int indent, const CTLOG_STORE *logs); - -/* - * Pretty-prints an |sct_list| to |out|. - * It will be indented by the number of spaces specified by |indent|. - * SCTs will be delimited by |separator|. - * If |logs| is not NULL, it will be used to lookup the CT log that each SCT - * came from, so that the log names can be printed. - */ -void SCT_LIST_print(const STACK_OF(SCT) *sct_list, BIO *out, int indent, - const char *separator, const CTLOG_STORE *logs); - -/* - * Gets the last result of validating this SCT. - * If it has not been validated yet, returns SCT_VALIDATION_STATUS_NOT_SET. - */ -sct_validation_status_t SCT_get_validation_status(const SCT *sct); - -/* - * Validates the given SCT with the provided context. - * Sets the "validation_status" field of the SCT. - * Returns 1 if the SCT is valid and the signature verifies. - * Returns 0 if the SCT is invalid or could not be verified. - * Returns -1 if an error occurs. - */ -__owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx); - -/* - * Validates the given list of SCTs with the provided context. - * Sets the "validation_status" field of each SCT. - * Returns 1 if there are no invalid SCTs and all signatures verify. - * Returns 0 if at least one SCT is invalid or could not be verified. - * Returns a negative integer if an error occurs. - */ -__owur int SCT_LIST_validate(const STACK_OF(SCT) *scts, - CT_POLICY_EVAL_CTX *ctx); - - -/********************************* - * SCT parsing and serialisation * - *********************************/ - -/* - * Serialize (to TLS format) a stack of SCTs and return the length. - * "a" must not be NULL. - * If "pp" is NULL, just return the length of what would have been serialized. - * If "pp" is not NULL and "*pp" is null, function will allocate a new pointer - * for data that caller is responsible for freeing (only if function returns - * successfully). - * If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring - * that "*pp" is large enough to accept all of the serialized data. - * Returns < 0 on error, >= 0 indicating bytes written (or would have been) - * on success. - */ -__owur int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp); - -/* - * Convert TLS format SCT list to a stack of SCTs. - * If "a" or "*a" is NULL, a new stack will be created that the caller is - * responsible for freeing (by calling SCT_LIST_free). - * "**pp" and "*pp" must not be NULL. - * Upon success, "*pp" will point to after the last bytes read, and a stack - * will be returned. - * Upon failure, a NULL pointer will be returned, and the position of "*pp" is - * not defined. - */ -STACK_OF(SCT) *o2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp, - size_t len); - -/* - * Serialize (to DER format) a stack of SCTs and return the length. - * "a" must not be NULL. - * If "pp" is NULL, just returns the length of what would have been serialized. - * If "pp" is not NULL and "*pp" is null, function will allocate a new pointer - * for data that caller is responsible for freeing (only if function returns - * successfully). - * If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring - * that "*pp" is large enough to accept all of the serialized data. - * Returns < 0 on error, >= 0 indicating bytes written (or would have been) - * on success. - */ -__owur int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp); - -/* - * Parses an SCT list in DER format and returns it. - * If "a" or "*a" is NULL, a new stack will be created that the caller is - * responsible for freeing (by calling SCT_LIST_free). - * "**pp" and "*pp" must not be NULL. - * Upon success, "*pp" will point to after the last bytes read, and a stack - * will be returned. - * Upon failure, a NULL pointer will be returned, and the position of "*pp" is - * not defined. - */ -STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp, - long len); - -/* - * Serialize (to TLS format) an |sct| and write it to |out|. - * If |out| is null, no SCT will be output but the length will still be returned. - * If |out| points to a null pointer, a string will be allocated to hold the - * TLS-format SCT. It is the responsibility of the caller to free it. - * If |out| points to an allocated string, the TLS-format SCT will be written - * to it. - * The length of the SCT in TLS format will be returned. - */ -__owur int i2o_SCT(const SCT *sct, unsigned char **out); - -/* - * Parses an SCT in TLS format and returns it. - * If |psct| is not null, it will end up pointing to the parsed SCT. If it - * already points to a non-null pointer, the pointer will be free'd. - * |in| should be a pointer to a string containing the TLS-format SCT. - * |in| will be advanced to the end of the SCT if parsing succeeds. - * |len| should be the length of the SCT in |in|. - * Returns NULL if an error occurs. - * If the SCT is an unsupported version, only the SCT's 'sct' and 'sct_len' - * fields will be populated (with |in| and |len| respectively). - */ -SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len); - -/******************** - * CT log functions * - ********************/ - -/* - * Creates a new CT log instance with the given |public_key| and |name|. - * Takes ownership of |public_key| but copies |name|. - * Returns NULL if malloc fails or if |public_key| cannot be converted to DER. - * Should be deleted by the caller using CTLOG_free when no longer needed. - */ -CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name); - -/* - * Creates a new CTLOG instance with the base64-encoded SubjectPublicKeyInfo DER - * in |pkey_base64|. The |name| is a string to help users identify this log. - * Returns 1 on success, 0 on failure. - * Should be deleted by the caller using CTLOG_free when no longer needed. - */ -int CTLOG_new_from_base64(CTLOG ** ct_log, - const char *pkey_base64, const char *name); - -/* - * Deletes a CT log instance and its fields. - */ -void CTLOG_free(CTLOG *log); - -/* Gets the name of the CT log */ -const char *CTLOG_get0_name(const CTLOG *log); -/* Gets the ID of the CT log */ -void CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id, - size_t *log_id_len); -/* Gets the public key of the CT log */ -EVP_PKEY *CTLOG_get0_public_key(const CTLOG *log); - -/************************** - * CT log store functions * - **************************/ - -/* - * Creates a new CT log store. - * Should be deleted by the caller using CTLOG_STORE_free when no longer needed. - */ -CTLOG_STORE *CTLOG_STORE_new(void); - -/* - * Deletes a CT log store and all of the CT log instances held within. - */ -void CTLOG_STORE_free(CTLOG_STORE *store); - -/* - * Finds a CT log in the store based on its log ID. - * Returns the CT log, or NULL if no match is found. - */ -const CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store, - const uint8_t *log_id, - size_t log_id_len); - -/* - * Loads a CT log list into a |store| from a |file|. - * Returns 1 if loading is successful, or 0 otherwise. - */ -__owur int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file); - -/* - * Loads the default CT log list into a |store|. - * Returns 1 if loading is successful, or 0 otherwise. - */ -__owur int CTLOG_STORE_load_default_file(CTLOG_STORE *store); - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/cterr.h b/client/3rd/OpenSSL/include/openssl/cterr.h deleted file mode 100644 index feb7bc56..00000000 --- a/client/3rd/OpenSSL/include/openssl/cterr.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CTERR_H -# define HEADER_CTERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# include - -# ifndef OPENSSL_NO_CT - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_CT_strings(void); - -/* - * CT function codes. - */ -# define CT_F_CTLOG_NEW 117 -# define CT_F_CTLOG_NEW_FROM_BASE64 118 -# define CT_F_CTLOG_NEW_FROM_CONF 119 -# define CT_F_CTLOG_STORE_LOAD_CTX_NEW 122 -# define CT_F_CTLOG_STORE_LOAD_FILE 123 -# define CT_F_CTLOG_STORE_LOAD_LOG 130 -# define CT_F_CTLOG_STORE_NEW 131 -# define CT_F_CT_BASE64_DECODE 124 -# define CT_F_CT_POLICY_EVAL_CTX_NEW 133 -# define CT_F_CT_V1_LOG_ID_FROM_PKEY 125 -# define CT_F_I2O_SCT 107 -# define CT_F_I2O_SCT_LIST 108 -# define CT_F_I2O_SCT_SIGNATURE 109 -# define CT_F_O2I_SCT 110 -# define CT_F_O2I_SCT_LIST 111 -# define CT_F_O2I_SCT_SIGNATURE 112 -# define CT_F_SCT_CTX_NEW 126 -# define CT_F_SCT_CTX_VERIFY 128 -# define CT_F_SCT_NEW 100 -# define CT_F_SCT_NEW_FROM_BASE64 127 -# define CT_F_SCT_SET0_LOG_ID 101 -# define CT_F_SCT_SET1_EXTENSIONS 114 -# define CT_F_SCT_SET1_LOG_ID 115 -# define CT_F_SCT_SET1_SIGNATURE 116 -# define CT_F_SCT_SET_LOG_ENTRY_TYPE 102 -# define CT_F_SCT_SET_SIGNATURE_NID 103 -# define CT_F_SCT_SET_VERSION 104 - -/* - * CT reason codes. - */ -# define CT_R_BASE64_DECODE_ERROR 108 -# define CT_R_INVALID_LOG_ID_LENGTH 100 -# define CT_R_LOG_CONF_INVALID 109 -# define CT_R_LOG_CONF_INVALID_KEY 110 -# define CT_R_LOG_CONF_MISSING_DESCRIPTION 111 -# define CT_R_LOG_CONF_MISSING_KEY 112 -# define CT_R_LOG_KEY_INVALID 113 -# define CT_R_SCT_FUTURE_TIMESTAMP 116 -# define CT_R_SCT_INVALID 104 -# define CT_R_SCT_INVALID_SIGNATURE 107 -# define CT_R_SCT_LIST_INVALID 105 -# define CT_R_SCT_LOG_ID_MISMATCH 114 -# define CT_R_SCT_NOT_SET 106 -# define CT_R_SCT_UNSUPPORTED_VERSION 115 -# define CT_R_UNRECOGNIZED_SIGNATURE_NID 101 -# define CT_R_UNSUPPORTED_ENTRY_TYPE 102 -# define CT_R_UNSUPPORTED_VERSION 103 - -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/des.h b/client/3rd/OpenSSL/include/openssl/des.h deleted file mode 100644 index be4abbdf..00000000 --- a/client/3rd/OpenSSL/include/openssl/des.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_DES_H -# define HEADER_DES_H - -# include - -# ifndef OPENSSL_NO_DES -# ifdef __cplusplus -extern "C" { -# endif -# include - -typedef unsigned int DES_LONG; - -# ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -# endif - -typedef unsigned char DES_cblock[8]; -typedef /* const */ unsigned char const_DES_cblock[8]; -/* - * With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * and - * const_DES_cblock * are incompatible pointer types. - */ - -typedef struct DES_ks { - union { - DES_cblock cblock; - /* - * make sure things are correct size on machines with 8 byte longs - */ - DES_LONG deslong[2]; - } ks[16]; -} DES_key_schedule; - -# define DES_KEY_SZ (sizeof(DES_cblock)) -# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) - -# define DES_ENCRYPT 1 -# define DES_DECRYPT 0 - -# define DES_CBC_MODE 0 -# define DES_PCBC_MODE 1 - -# define DES_ecb2_encrypt(i,o,k1,k2,e) \ - DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) - -# define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ - DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) - -# define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ - DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) - -# define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ - DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) - -OPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */ -# define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key) - -const char *DES_options(void); -void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, - DES_key_schedule *ks1, DES_key_schedule *ks2, - DES_key_schedule *ks3, int enc); -DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output, - long length, DES_key_schedule *schedule, - const_DES_cblock *ivec); -/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ -void DES_cbc_encrypt(const unsigned char *input, unsigned char *output, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int enc); -void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int enc); -void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, const_DES_cblock *inw, - const_DES_cblock *outw, int enc); -void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int enc); -void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, - DES_key_schedule *ks, int enc); - -/* - * This is the DES encryption function that gets called by just about every - * other DES routine in the library. You should not use this function except - * to implement 'modes' of DES. I say this because the functions that call - * this routine do the conversion from 'char *' to long, and this needs to be - * done to make sure 'non-aligned' memory access do not occur. The - * characters are loaded 'little endian'. Data is a pointer to 2 unsigned - * long's and ks is the DES_key_schedule to use. enc, is non zero specifies - * encryption, zero if decryption. - */ -void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc); - -/* - * This functions is the same as DES_encrypt1() except that the DES initial - * permutation (IP) and final permutation (FP) have been left out. As for - * DES_encrypt1(), you should not use this function. It is used by the - * routines in the library that implement triple DES. IP() DES_encrypt2() - * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1() - * DES_encrypt1() DES_encrypt1() except faster :-). - */ -void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc); - -void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3); -void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3); -void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, - long length, - DES_key_schedule *ks1, DES_key_schedule *ks2, - DES_key_schedule *ks3, DES_cblock *ivec, int enc); -void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3, - DES_cblock *ivec, int *num, int enc); -void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out, - int numbits, long length, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3, - DES_cblock *ivec, int enc); -void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3, - DES_cblock *ivec, int *num); -char *DES_fcrypt(const char *buf, const char *salt, char *ret); -char *DES_crypt(const char *buf, const char *salt); -void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, - long length, DES_key_schedule *schedule, - DES_cblock *ivec); -void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int enc); -DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], - long length, int out_count, DES_cblock *seed); -int DES_random_key(DES_cblock *ret); -void DES_set_odd_parity(DES_cblock *key); -int DES_check_key_parity(const_DES_cblock *key); -int DES_is_weak_key(const_DES_cblock *key); -/* - * DES_set_key (= set_key = DES_key_sched = key_sched) calls - * DES_set_key_checked if global variable DES_check_key is set, - * DES_set_key_unchecked otherwise. - */ -int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule); -int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule); -int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule); -void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule); -void DES_string_to_key(const char *str, DES_cblock *key); -void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2); -void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int *num, int enc); -void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int *num); - -# define DES_fixup_key_parity DES_set_odd_parity - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/dh.h b/client/3rd/OpenSSL/include/openssl/dh.h deleted file mode 100644 index 3527540c..00000000 --- a/client/3rd/OpenSSL/include/openssl/dh.h +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_DH_H -# define HEADER_DH_H - -# include - -# ifndef OPENSSL_NO_DH -# include -# include -# include -# include -# if OPENSSL_API_COMPAT < 0x10100000L -# include -# endif -# include - -# ifdef __cplusplus -extern "C" { -# endif - -# ifndef OPENSSL_DH_MAX_MODULUS_BITS -# define OPENSSL_DH_MAX_MODULUS_BITS 10000 -# endif - -# define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024 - -# define DH_FLAG_CACHE_MONT_P 0x01 - -# if OPENSSL_API_COMPAT < 0x10100000L -/* - * Does nothing. Previously this switched off constant time behaviour. - */ -# define DH_FLAG_NO_EXP_CONSTTIME 0x00 -# endif - -/* - * If this flag is set the DH method is FIPS compliant and can be used in - * FIPS mode. This is set in the validated module method. If an application - * sets this flag in its own methods it is its responsibility to ensure the - * result is compliant. - */ - -# define DH_FLAG_FIPS_METHOD 0x0400 - -/* - * If this flag is set the operations normally disabled in FIPS mode are - * permitted it is then the applications responsibility to ensure that the - * usage is compliant. - */ - -# define DH_FLAG_NON_FIPS_ALLOW 0x0400 - -/* Already defined in ossl_typ.h */ -/* typedef struct dh_st DH; */ -/* typedef struct dh_method DH_METHOD; */ - -DECLARE_ASN1_ITEM(DHparams) - -# define DH_GENERATOR_2 2 -/* #define DH_GENERATOR_3 3 */ -# define DH_GENERATOR_5 5 - -/* DH_check error codes */ -# define DH_CHECK_P_NOT_PRIME 0x01 -# define DH_CHECK_P_NOT_SAFE_PRIME 0x02 -# define DH_UNABLE_TO_CHECK_GENERATOR 0x04 -# define DH_NOT_SUITABLE_GENERATOR 0x08 -# define DH_CHECK_Q_NOT_PRIME 0x10 -# define DH_CHECK_INVALID_Q_VALUE 0x20 -# define DH_CHECK_INVALID_J_VALUE 0x40 - -/* DH_check_pub_key error codes */ -# define DH_CHECK_PUBKEY_TOO_SMALL 0x01 -# define DH_CHECK_PUBKEY_TOO_LARGE 0x02 -# define DH_CHECK_PUBKEY_INVALID 0x04 - -/* - * primes p where (p-1)/2 is prime too are called "safe"; we define this for - * backward compatibility: - */ -# define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME - -# define d2i_DHparams_fp(fp,x) \ - (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ - (char *(*)())d2i_DHparams, \ - (fp), \ - (unsigned char **)(x)) -# define i2d_DHparams_fp(fp,x) \ - ASN1_i2d_fp(i2d_DHparams,(fp), (unsigned char *)(x)) -# define d2i_DHparams_bio(bp,x) \ - ASN1_d2i_bio_of(DH, DH_new, d2i_DHparams, bp, x) -# define i2d_DHparams_bio(bp,x) \ - ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x) - -# define d2i_DHxparams_fp(fp,x) \ - (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ - (char *(*)())d2i_DHxparams, \ - (fp), \ - (unsigned char **)(x)) -# define i2d_DHxparams_fp(fp,x) \ - ASN1_i2d_fp(i2d_DHxparams,(fp), (unsigned char *)(x)) -# define d2i_DHxparams_bio(bp,x) \ - ASN1_d2i_bio_of(DH, DH_new, d2i_DHxparams, bp, x) -# define i2d_DHxparams_bio(bp,x) \ - ASN1_i2d_bio_of_const(DH, i2d_DHxparams, bp, x) - -DH *DHparams_dup(DH *); - -const DH_METHOD *DH_OpenSSL(void); - -void DH_set_default_method(const DH_METHOD *meth); -const DH_METHOD *DH_get_default_method(void); -int DH_set_method(DH *dh, const DH_METHOD *meth); -DH *DH_new_method(ENGINE *engine); - -DH *DH_new(void); -void DH_free(DH *dh); -int DH_up_ref(DH *dh); -int DH_bits(const DH *dh); -int DH_size(const DH *dh); -int DH_security_bits(const DH *dh); -#define DH_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, l, p, newf, dupf, freef) -int DH_set_ex_data(DH *d, int idx, void *arg); -void *DH_get_ex_data(DH *d, int idx); - -/* Deprecated version */ -DEPRECATEDIN_0_9_8(DH *DH_generate_parameters(int prime_len, int generator, - void (*callback) (int, int, - void *), - void *cb_arg)) - -/* New version */ -int DH_generate_parameters_ex(DH *dh, int prime_len, int generator, - BN_GENCB *cb); - -int DH_check_params_ex(const DH *dh); -int DH_check_ex(const DH *dh); -int DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key); -int DH_check_params(const DH *dh, int *ret); -int DH_check(const DH *dh, int *codes); -int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes); -int DH_generate_key(DH *dh); -int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh); -int DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh); -DH *d2i_DHparams(DH **a, const unsigned char **pp, long length); -int i2d_DHparams(const DH *a, unsigned char **pp); -DH *d2i_DHxparams(DH **a, const unsigned char **pp, long length); -int i2d_DHxparams(const DH *a, unsigned char **pp); -# ifndef OPENSSL_NO_STDIO -int DHparams_print_fp(FILE *fp, const DH *x); -# endif -int DHparams_print(BIO *bp, const DH *x); - -/* RFC 5114 parameters */ -DH *DH_get_1024_160(void); -DH *DH_get_2048_224(void); -DH *DH_get_2048_256(void); - -/* Named parameters, currently RFC7919 */ -DH *DH_new_by_nid(int nid); -int DH_get_nid(const DH *dh); - -# ifndef OPENSSL_NO_CMS -/* RFC2631 KDF */ -int DH_KDF_X9_42(unsigned char *out, size_t outlen, - const unsigned char *Z, size_t Zlen, - ASN1_OBJECT *key_oid, - const unsigned char *ukm, size_t ukmlen, const EVP_MD *md); -# endif - -void DH_get0_pqg(const DH *dh, - const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); -int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); -void DH_get0_key(const DH *dh, - const BIGNUM **pub_key, const BIGNUM **priv_key); -int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); -const BIGNUM *DH_get0_p(const DH *dh); -const BIGNUM *DH_get0_q(const DH *dh); -const BIGNUM *DH_get0_g(const DH *dh); -const BIGNUM *DH_get0_priv_key(const DH *dh); -const BIGNUM *DH_get0_pub_key(const DH *dh); -void DH_clear_flags(DH *dh, int flags); -int DH_test_flags(const DH *dh, int flags); -void DH_set_flags(DH *dh, int flags); -ENGINE *DH_get0_engine(DH *d); -long DH_get_length(const DH *dh); -int DH_set_length(DH *dh, long length); - -DH_METHOD *DH_meth_new(const char *name, int flags); -void DH_meth_free(DH_METHOD *dhm); -DH_METHOD *DH_meth_dup(const DH_METHOD *dhm); -const char *DH_meth_get0_name(const DH_METHOD *dhm); -int DH_meth_set1_name(DH_METHOD *dhm, const char *name); -int DH_meth_get_flags(const DH_METHOD *dhm); -int DH_meth_set_flags(DH_METHOD *dhm, int flags); -void *DH_meth_get0_app_data(const DH_METHOD *dhm); -int DH_meth_set0_app_data(DH_METHOD *dhm, void *app_data); -int (*DH_meth_get_generate_key(const DH_METHOD *dhm)) (DH *); -int DH_meth_set_generate_key(DH_METHOD *dhm, int (*generate_key) (DH *)); -int (*DH_meth_get_compute_key(const DH_METHOD *dhm)) - (unsigned char *key, const BIGNUM *pub_key, DH *dh); -int DH_meth_set_compute_key(DH_METHOD *dhm, - int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh)); -int (*DH_meth_get_bn_mod_exp(const DH_METHOD *dhm)) - (const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, - BN_CTX *, BN_MONT_CTX *); -int DH_meth_set_bn_mod_exp(DH_METHOD *dhm, - int (*bn_mod_exp) (const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, BN_CTX *, BN_MONT_CTX *)); -int (*DH_meth_get_init(const DH_METHOD *dhm))(DH *); -int DH_meth_set_init(DH_METHOD *dhm, int (*init)(DH *)); -int (*DH_meth_get_finish(const DH_METHOD *dhm)) (DH *); -int DH_meth_set_finish(DH_METHOD *dhm, int (*finish) (DH *)); -int (*DH_meth_get_generate_params(const DH_METHOD *dhm)) - (DH *, int, int, BN_GENCB *); -int DH_meth_set_generate_params(DH_METHOD *dhm, - int (*generate_params) (DH *, int, int, BN_GENCB *)); - - -# define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL) - -# define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL) - -# define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL) - -# define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL) - -# define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_RFC5114, gen, NULL) - -# define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_RFC5114, gen, NULL) - -# define EVP_PKEY_CTX_set_dh_nid(ctx, nid) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, \ - EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_DH_NID, nid, NULL) - -# define EVP_PKEY_CTX_set_dh_pad(ctx, pad) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_PAD, pad, NULL) - -# define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL) - -# define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL) - -# define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)(oid)) - -# define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)(poid)) - -# define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)(md)) - -# define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)(pmd)) - -# define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL) - -# define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)(plen)) - -# define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)(p)) - -# define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)(p)) - -# define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN (EVP_PKEY_ALG_CTRL + 1) -# define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR (EVP_PKEY_ALG_CTRL + 2) -# define EVP_PKEY_CTRL_DH_RFC5114 (EVP_PKEY_ALG_CTRL + 3) -# define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN (EVP_PKEY_ALG_CTRL + 4) -# define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE (EVP_PKEY_ALG_CTRL + 5) -# define EVP_PKEY_CTRL_DH_KDF_TYPE (EVP_PKEY_ALG_CTRL + 6) -# define EVP_PKEY_CTRL_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 7) -# define EVP_PKEY_CTRL_GET_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 8) -# define EVP_PKEY_CTRL_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 9) -# define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 10) -# define EVP_PKEY_CTRL_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 11) -# define EVP_PKEY_CTRL_GET_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 12) -# define EVP_PKEY_CTRL_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 13) -# define EVP_PKEY_CTRL_GET_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 14) -# define EVP_PKEY_CTRL_DH_NID (EVP_PKEY_ALG_CTRL + 15) -# define EVP_PKEY_CTRL_DH_PAD (EVP_PKEY_ALG_CTRL + 16) - -/* KDF types */ -# define EVP_PKEY_DH_KDF_NONE 1 -# ifndef OPENSSL_NO_CMS -# define EVP_PKEY_DH_KDF_X9_42 2 -# endif - - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/dherr.h b/client/3rd/OpenSSL/include/openssl/dherr.h deleted file mode 100644 index 916b3bed..00000000 --- a/client/3rd/OpenSSL/include/openssl/dherr.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_DHERR_H -# define HEADER_DHERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# include - -# ifndef OPENSSL_NO_DH - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_DH_strings(void); - -/* - * DH function codes. - */ -# define DH_F_COMPUTE_KEY 102 -# define DH_F_DHPARAMS_PRINT_FP 101 -# define DH_F_DH_BUILTIN_GENPARAMS 106 -# define DH_F_DH_CHECK_EX 121 -# define DH_F_DH_CHECK_PARAMS_EX 122 -# define DH_F_DH_CHECK_PUB_KEY_EX 123 -# define DH_F_DH_CMS_DECRYPT 114 -# define DH_F_DH_CMS_SET_PEERKEY 115 -# define DH_F_DH_CMS_SET_SHARED_INFO 116 -# define DH_F_DH_METH_DUP 117 -# define DH_F_DH_METH_NEW 118 -# define DH_F_DH_METH_SET1_NAME 119 -# define DH_F_DH_NEW_BY_NID 104 -# define DH_F_DH_NEW_METHOD 105 -# define DH_F_DH_PARAM_DECODE 107 -# define DH_F_DH_PKEY_PUBLIC_CHECK 124 -# define DH_F_DH_PRIV_DECODE 110 -# define DH_F_DH_PRIV_ENCODE 111 -# define DH_F_DH_PUB_DECODE 108 -# define DH_F_DH_PUB_ENCODE 109 -# define DH_F_DO_DH_PRINT 100 -# define DH_F_GENERATE_KEY 103 -# define DH_F_PKEY_DH_CTRL_STR 120 -# define DH_F_PKEY_DH_DERIVE 112 -# define DH_F_PKEY_DH_INIT 125 -# define DH_F_PKEY_DH_KEYGEN 113 - -/* - * DH reason codes. - */ -# define DH_R_BAD_GENERATOR 101 -# define DH_R_BN_DECODE_ERROR 109 -# define DH_R_BN_ERROR 106 -# define DH_R_CHECK_INVALID_J_VALUE 115 -# define DH_R_CHECK_INVALID_Q_VALUE 116 -# define DH_R_CHECK_PUBKEY_INVALID 122 -# define DH_R_CHECK_PUBKEY_TOO_LARGE 123 -# define DH_R_CHECK_PUBKEY_TOO_SMALL 124 -# define DH_R_CHECK_P_NOT_PRIME 117 -# define DH_R_CHECK_P_NOT_SAFE_PRIME 118 -# define DH_R_CHECK_Q_NOT_PRIME 119 -# define DH_R_DECODE_ERROR 104 -# define DH_R_INVALID_PARAMETER_NAME 110 -# define DH_R_INVALID_PARAMETER_NID 114 -# define DH_R_INVALID_PUBKEY 102 -# define DH_R_KDF_PARAMETER_ERROR 112 -# define DH_R_KEYS_NOT_SET 108 -# define DH_R_MISSING_PUBKEY 125 -# define DH_R_MODULUS_TOO_LARGE 103 -# define DH_R_NOT_SUITABLE_GENERATOR 120 -# define DH_R_NO_PARAMETERS_SET 107 -# define DH_R_NO_PRIVATE_VALUE 100 -# define DH_R_PARAMETER_ENCODING_ERROR 105 -# define DH_R_PEER_KEY_ERROR 111 -# define DH_R_SHARED_INFO_ERROR 113 -# define DH_R_UNABLE_TO_CHECK_GENERATOR 121 - -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/dsa.h b/client/3rd/OpenSSL/include/openssl/dsa.h deleted file mode 100644 index 6d8a18a4..00000000 --- a/client/3rd/OpenSSL/include/openssl/dsa.h +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_DSA_H -# define HEADER_DSA_H - -# include - -# ifndef OPENSSL_NO_DSA -# ifdef __cplusplus -extern "C" { -# endif -# include -# include -# include -# include -# include -# if OPENSSL_API_COMPAT < 0x10100000L -# include -# endif -# include - -# ifndef OPENSSL_DSA_MAX_MODULUS_BITS -# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 -# endif - -# define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024 - -# define DSA_FLAG_CACHE_MONT_P 0x01 -# if OPENSSL_API_COMPAT < 0x10100000L -/* - * Does nothing. Previously this switched off constant time behaviour. - */ -# define DSA_FLAG_NO_EXP_CONSTTIME 0x00 -# endif - -/* - * If this flag is set the DSA method is FIPS compliant and can be used in - * FIPS mode. This is set in the validated module method. If an application - * sets this flag in its own methods it is its responsibility to ensure the - * result is compliant. - */ - -# define DSA_FLAG_FIPS_METHOD 0x0400 - -/* - * If this flag is set the operations normally disabled in FIPS mode are - * permitted it is then the applications responsibility to ensure that the - * usage is compliant. - */ - -# define DSA_FLAG_NON_FIPS_ALLOW 0x0400 -# define DSA_FLAG_FIPS_CHECKED 0x0800 - -/* Already defined in ossl_typ.h */ -/* typedef struct dsa_st DSA; */ -/* typedef struct dsa_method DSA_METHOD; */ - -typedef struct DSA_SIG_st DSA_SIG; - -# define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ - (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x)) -# define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \ - (unsigned char *)(x)) -# define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x) -# define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x) - -DSA *DSAparams_dup(DSA *x); -DSA_SIG *DSA_SIG_new(void); -void DSA_SIG_free(DSA_SIG *a); -int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); -DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length); -void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); -int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s); - -DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); -int DSA_do_verify(const unsigned char *dgst, int dgst_len, - DSA_SIG *sig, DSA *dsa); - -const DSA_METHOD *DSA_OpenSSL(void); - -void DSA_set_default_method(const DSA_METHOD *); -const DSA_METHOD *DSA_get_default_method(void); -int DSA_set_method(DSA *dsa, const DSA_METHOD *); -const DSA_METHOD *DSA_get_method(DSA *d); - -DSA *DSA_new(void); -DSA *DSA_new_method(ENGINE *engine); -void DSA_free(DSA *r); -/* "up" the DSA object's reference count */ -int DSA_up_ref(DSA *r); -int DSA_size(const DSA *); -int DSA_bits(const DSA *d); -int DSA_security_bits(const DSA *d); - /* next 4 return -1 on error */ -DEPRECATEDIN_1_2_0(int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)) -int DSA_sign(int type, const unsigned char *dgst, int dlen, - unsigned char *sig, unsigned int *siglen, DSA *dsa); -int DSA_verify(int type, const unsigned char *dgst, int dgst_len, - const unsigned char *sigbuf, int siglen, DSA *dsa); -#define DSA_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, l, p, newf, dupf, freef) -int DSA_set_ex_data(DSA *d, int idx, void *arg); -void *DSA_get_ex_data(DSA *d, int idx); - -DSA *d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length); -DSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length); -DSA *d2i_DSAparams(DSA **a, const unsigned char **pp, long length); - -/* Deprecated version */ -DEPRECATEDIN_0_9_8(DSA *DSA_generate_parameters(int bits, - unsigned char *seed, - int seed_len, - int *counter_ret, - unsigned long *h_ret, void - (*callback) (int, int, - void *), - void *cb_arg)) - -/* New version */ -int DSA_generate_parameters_ex(DSA *dsa, int bits, - const unsigned char *seed, int seed_len, - int *counter_ret, unsigned long *h_ret, - BN_GENCB *cb); - -int DSA_generate_key(DSA *a); -int i2d_DSAPublicKey(const DSA *a, unsigned char **pp); -int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp); -int i2d_DSAparams(const DSA *a, unsigned char **pp); - -int DSAparams_print(BIO *bp, const DSA *x); -int DSA_print(BIO *bp, const DSA *x, int off); -# ifndef OPENSSL_NO_STDIO -int DSAparams_print_fp(FILE *fp, const DSA *x); -int DSA_print_fp(FILE *bp, const DSA *x, int off); -# endif - -# define DSS_prime_checks 64 -/* - * Primality test according to FIPS PUB 186-4, Appendix C.3. Since we only - * have one value here we set the number of checks to 64 which is the 128 bit - * security level that is the highest level and valid for creating a 3072 bit - * DSA key. - */ -# define DSA_is_prime(n, callback, cb_arg) \ - BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) - -# ifndef OPENSSL_NO_DH -/* - * Convert DSA structure (key or just parameters) into DH structure (be - * careful to avoid small subgroup attacks when using this!) - */ -DH *DSA_dup_DH(const DSA *r); -# endif - -# define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL) -# define EVP_PKEY_CTX_set_dsa_paramgen_q_bits(ctx, qbits) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS, qbits, NULL) -# define EVP_PKEY_CTX_set_dsa_paramgen_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)(md)) - -# define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1) -# define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2) -# define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3) - -void DSA_get0_pqg(const DSA *d, - const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); -int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g); -void DSA_get0_key(const DSA *d, - const BIGNUM **pub_key, const BIGNUM **priv_key); -int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key); -const BIGNUM *DSA_get0_p(const DSA *d); -const BIGNUM *DSA_get0_q(const DSA *d); -const BIGNUM *DSA_get0_g(const DSA *d); -const BIGNUM *DSA_get0_pub_key(const DSA *d); -const BIGNUM *DSA_get0_priv_key(const DSA *d); -void DSA_clear_flags(DSA *d, int flags); -int DSA_test_flags(const DSA *d, int flags); -void DSA_set_flags(DSA *d, int flags); -ENGINE *DSA_get0_engine(DSA *d); - -DSA_METHOD *DSA_meth_new(const char *name, int flags); -void DSA_meth_free(DSA_METHOD *dsam); -DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam); -const char *DSA_meth_get0_name(const DSA_METHOD *dsam); -int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name); -int DSA_meth_get_flags(const DSA_METHOD *dsam); -int DSA_meth_set_flags(DSA_METHOD *dsam, int flags); -void *DSA_meth_get0_app_data(const DSA_METHOD *dsam); -int DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data); -DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam)) - (const unsigned char *, int, DSA *); -int DSA_meth_set_sign(DSA_METHOD *dsam, - DSA_SIG *(*sign) (const unsigned char *, int, DSA *)); -int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam)) - (DSA *, BN_CTX *, BIGNUM **, BIGNUM **); -int DSA_meth_set_sign_setup(DSA_METHOD *dsam, - int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **)); -int (*DSA_meth_get_verify(const DSA_METHOD *dsam)) - (const unsigned char *, int, DSA_SIG *, DSA *); -int DSA_meth_set_verify(DSA_METHOD *dsam, - int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *)); -int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam)) - (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *); -int DSA_meth_set_mod_exp(DSA_METHOD *dsam, - int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *, - BN_MONT_CTX *)); -int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam)) - (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, - BN_CTX *, BN_MONT_CTX *); -int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam, - int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, BN_CTX *, BN_MONT_CTX *)); -int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *); -int DSA_meth_set_init(DSA_METHOD *dsam, int (*init)(DSA *)); -int (*DSA_meth_get_finish(const DSA_METHOD *dsam)) (DSA *); -int DSA_meth_set_finish(DSA_METHOD *dsam, int (*finish) (DSA *)); -int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam)) - (DSA *, int, const unsigned char *, int, int *, unsigned long *, - BN_GENCB *); -int DSA_meth_set_paramgen(DSA_METHOD *dsam, - int (*paramgen) (DSA *, int, const unsigned char *, int, int *, - unsigned long *, BN_GENCB *)); -int (*DSA_meth_get_keygen(const DSA_METHOD *dsam)) (DSA *); -int DSA_meth_set_keygen(DSA_METHOD *dsam, int (*keygen) (DSA *)); - - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/dsaerr.h b/client/3rd/OpenSSL/include/openssl/dsaerr.h deleted file mode 100644 index 495a1ac8..00000000 --- a/client/3rd/OpenSSL/include/openssl/dsaerr.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_DSAERR_H -# define HEADER_DSAERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# include - -# ifndef OPENSSL_NO_DSA - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_DSA_strings(void); - -/* - * DSA function codes. - */ -# define DSA_F_DSAPARAMS_PRINT 100 -# define DSA_F_DSAPARAMS_PRINT_FP 101 -# define DSA_F_DSA_BUILTIN_PARAMGEN 125 -# define DSA_F_DSA_BUILTIN_PARAMGEN2 126 -# define DSA_F_DSA_DO_SIGN 112 -# define DSA_F_DSA_DO_VERIFY 113 -# define DSA_F_DSA_METH_DUP 127 -# define DSA_F_DSA_METH_NEW 128 -# define DSA_F_DSA_METH_SET1_NAME 129 -# define DSA_F_DSA_NEW_METHOD 103 -# define DSA_F_DSA_PARAM_DECODE 119 -# define DSA_F_DSA_PRINT_FP 105 -# define DSA_F_DSA_PRIV_DECODE 115 -# define DSA_F_DSA_PRIV_ENCODE 116 -# define DSA_F_DSA_PUB_DECODE 117 -# define DSA_F_DSA_PUB_ENCODE 118 -# define DSA_F_DSA_SIGN 106 -# define DSA_F_DSA_SIGN_SETUP 107 -# define DSA_F_DSA_SIG_NEW 102 -# define DSA_F_OLD_DSA_PRIV_DECODE 122 -# define DSA_F_PKEY_DSA_CTRL 120 -# define DSA_F_PKEY_DSA_CTRL_STR 104 -# define DSA_F_PKEY_DSA_KEYGEN 121 - -/* - * DSA reason codes. - */ -# define DSA_R_BAD_Q_VALUE 102 -# define DSA_R_BN_DECODE_ERROR 108 -# define DSA_R_BN_ERROR 109 -# define DSA_R_DECODE_ERROR 104 -# define DSA_R_INVALID_DIGEST_TYPE 106 -# define DSA_R_INVALID_PARAMETERS 112 -# define DSA_R_MISSING_PARAMETERS 101 -# define DSA_R_MISSING_PRIVATE_KEY 111 -# define DSA_R_MODULUS_TOO_LARGE 103 -# define DSA_R_NO_PARAMETERS_SET 107 -# define DSA_R_PARAMETER_ENCODING_ERROR 105 -# define DSA_R_Q_NOT_PRIME 113 -# define DSA_R_SEED_LEN_SMALL 110 - -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/dtls1.h b/client/3rd/OpenSSL/include/openssl/dtls1.h deleted file mode 100644 index d55ca9c3..00000000 --- a/client/3rd/OpenSSL/include/openssl/dtls1.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2005-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_DTLS1_H -# define HEADER_DTLS1_H - -#ifdef __cplusplus -extern "C" { -#endif - -# define DTLS1_VERSION 0xFEFF -# define DTLS1_2_VERSION 0xFEFD -# define DTLS_MIN_VERSION DTLS1_VERSION -# define DTLS_MAX_VERSION DTLS1_2_VERSION -# define DTLS1_VERSION_MAJOR 0xFE - -# define DTLS1_BAD_VER 0x0100 - -/* Special value for method supporting multiple versions */ -# define DTLS_ANY_VERSION 0x1FFFF - -/* lengths of messages */ -/* - * Actually the max cookie length in DTLS is 255. But we can't change this now - * due to compatibility concerns. - */ -# define DTLS1_COOKIE_LENGTH 256 - -# define DTLS1_RT_HEADER_LENGTH 13 - -# define DTLS1_HM_HEADER_LENGTH 12 - -# define DTLS1_HM_BAD_FRAGMENT -2 -# define DTLS1_HM_FRAGMENT_RETRY -3 - -# define DTLS1_CCS_HEADER_LENGTH 1 - -# define DTLS1_AL_HEADER_LENGTH 2 - -/* Timeout multipliers */ -# define DTLS1_TMO_READ_COUNT 2 -# define DTLS1_TMO_WRITE_COUNT 2 - -# define DTLS1_TMO_ALERT_COUNT 12 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/e_os2.h b/client/3rd/OpenSSL/include/openssl/e_os2.h deleted file mode 100644 index 5c88e519..00000000 --- a/client/3rd/OpenSSL/include/openssl/e_os2.h +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_E_OS2_H -# define HEADER_E_OS2_H - -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/****************************************************************************** - * Detect operating systems. This probably needs completing. - * The result is that at least one OPENSSL_SYS_os macro should be defined. - * However, if none is defined, Unix is assumed. - **/ - -# define OPENSSL_SYS_UNIX - -/* --------------------- Microsoft operating systems ---------------------- */ - -/* - * Note that MSDOS actually denotes 32-bit environments running on top of - * MS-DOS, such as DJGPP one. - */ -# if defined(OPENSSL_SYS_MSDOS) -# undef OPENSSL_SYS_UNIX -# endif - -/* - * For 32 bit environment, there seems to be the CygWin environment and then - * all the others that try to do the same thing Microsoft does... - */ -/* - * UEFI lives here because it might be built with a Microsoft toolchain and - * we need to avoid the false positive match on Windows. - */ -# if defined(OPENSSL_SYS_UEFI) -# undef OPENSSL_SYS_UNIX -# elif defined(OPENSSL_SYS_UWIN) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WIN32_UWIN -# else -# if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN) -# define OPENSSL_SYS_WIN32_CYGWIN -# else -# if defined(_WIN32) || defined(OPENSSL_SYS_WIN32) -# undef OPENSSL_SYS_UNIX -# if !defined(OPENSSL_SYS_WIN32) -# define OPENSSL_SYS_WIN32 -# endif -# endif -# if defined(_WIN64) || defined(OPENSSL_SYS_WIN64) -# undef OPENSSL_SYS_UNIX -# if !defined(OPENSSL_SYS_WIN64) -# define OPENSSL_SYS_WIN64 -# endif -# endif -# if defined(OPENSSL_SYS_WINNT) -# undef OPENSSL_SYS_UNIX -# endif -# if defined(OPENSSL_SYS_WINCE) -# undef OPENSSL_SYS_UNIX -# endif -# endif -# endif - -/* Anything that tries to look like Microsoft is "Windows" */ -# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WINDOWS -# ifndef OPENSSL_SYS_MSDOS -# define OPENSSL_SYS_MSDOS -# endif -# endif - -/* - * DLL settings. This part is a bit tough, because it's up to the - * application implementor how he or she will link the application, so it - * requires some macro to be used. - */ -# ifdef OPENSSL_SYS_WINDOWS -# ifndef OPENSSL_OPT_WINDLL -# if defined(_WINDLL) /* This is used when building OpenSSL to - * indicate that DLL linkage should be used */ -# define OPENSSL_OPT_WINDLL -# endif -# endif -# endif - -/* ------------------------------- OpenVMS -------------------------------- */ -# if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYS_VMS) -# if !defined(OPENSSL_SYS_VMS) -# undef OPENSSL_SYS_UNIX -# endif -# define OPENSSL_SYS_VMS -# if defined(__DECC) -# define OPENSSL_SYS_VMS_DECC -# elif defined(__DECCXX) -# define OPENSSL_SYS_VMS_DECC -# define OPENSSL_SYS_VMS_DECCXX -# else -# define OPENSSL_SYS_VMS_NODECC -# endif -# endif - -/* -------------------------------- Unix ---------------------------------- */ -# ifdef OPENSSL_SYS_UNIX -# if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX) -# define OPENSSL_SYS_LINUX -# endif -# if defined(_AIX) && !defined(OPENSSL_SYS_AIX) -# define OPENSSL_SYS_AIX -# endif -# endif - -/* -------------------------------- VOS ----------------------------------- */ -# if defined(__VOS__) && !defined(OPENSSL_SYS_VOS) -# define OPENSSL_SYS_VOS -# ifdef __HPPA__ -# define OPENSSL_SYS_VOS_HPPA -# endif -# ifdef __IA32__ -# define OPENSSL_SYS_VOS_IA32 -# endif -# endif - -/** - * That's it for OS-specific stuff - *****************************************************************************/ - -/* Specials for I/O an exit */ -# ifdef OPENSSL_SYS_MSDOS -# define OPENSSL_UNISTD_IO -# define OPENSSL_DECLARE_EXIT extern void exit(int); -# else -# define OPENSSL_UNISTD_IO OPENSSL_UNISTD -# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ -# endif - -/*- - * OPENSSL_EXTERN is normally used to declare a symbol with possible extra - * attributes to handle its presence in a shared library. - * OPENSSL_EXPORT is used to define a symbol with extra possible attributes - * to make it visible in a shared library. - * Care needs to be taken when a header file is used both to declare and - * define symbols. Basically, for any library that exports some global - * variables, the following code must be present in the header file that - * declares them, before OPENSSL_EXTERN is used: - * - * #ifdef SOME_BUILD_FLAG_MACRO - * # undef OPENSSL_EXTERN - * # define OPENSSL_EXTERN OPENSSL_EXPORT - * #endif - * - * The default is to have OPENSSL_EXPORT and OPENSSL_EXTERN - * have some generally sensible values. - */ - -# if defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) -# define OPENSSL_EXPORT extern __declspec(dllexport) -# define OPENSSL_EXTERN extern __declspec(dllimport) -# else -# define OPENSSL_EXPORT extern -# define OPENSSL_EXTERN extern -# endif - -/*- - * Macros to allow global variables to be reached through function calls when - * required (if a shared library version requires it, for example. - * The way it's done allows definitions like this: - * - * // in foobar.c - * OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0) - * // in foobar.h - * OPENSSL_DECLARE_GLOBAL(int,foobar); - * #define foobar OPENSSL_GLOBAL_REF(foobar) - */ -# ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION -# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) \ - type *_shadow_##name(void) \ - { static type _hide_##name=value; return &_hide_##name; } -# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) -# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) -# else -# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) type _shadow_##name=value; -# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name -# define OPENSSL_GLOBAL_REF(name) _shadow_##name -# endif - -# ifdef _WIN32 -# ifdef _WIN64 -# define ossl_ssize_t __int64 -# define OSSL_SSIZE_MAX _I64_MAX -# else -# define ossl_ssize_t int -# define OSSL_SSIZE_MAX INT_MAX -# endif -# endif - -# if defined(OPENSSL_SYS_UEFI) && !defined(ossl_ssize_t) -# define ossl_ssize_t INTN -# define OSSL_SSIZE_MAX MAX_INTN -# endif - -# ifndef ossl_ssize_t -# define ossl_ssize_t ssize_t -# if defined(SSIZE_MAX) -# define OSSL_SSIZE_MAX SSIZE_MAX -# elif defined(_POSIX_SSIZE_MAX) -# define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX -# else -# define OSSL_SSIZE_MAX ((ssize_t)(SIZE_MAX>>1)) -# endif -# endif - -# ifdef DEBUG_UNUSED -# define __owur __attribute__((__warn_unused_result__)) -# else -# define __owur -# endif - -/* Standard integer types */ -# if defined(OPENSSL_SYS_UEFI) -typedef INT8 int8_t; -typedef UINT8 uint8_t; -typedef INT16 int16_t; -typedef UINT16 uint16_t; -typedef INT32 int32_t; -typedef UINT32 uint32_t; -typedef INT64 int64_t; -typedef UINT64 uint64_t; -# elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ - defined(__osf__) || defined(__sgi) || defined(__hpux) || \ - defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__) -# include -# elif defined(_MSC_VER) && _MSC_VER<1600 -/* - * minimally required typdefs for systems not supporting inttypes.h or - * stdint.h: currently just older VC++ - */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; -typedef unsigned short uint16_t; -typedef int int32_t; -typedef unsigned int uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -# else -# include -# endif - -/* ossl_inline: portable inline definition usable in public headers */ -# if !defined(inline) && !defined(__cplusplus) -# if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L - /* just use inline */ -# define ossl_inline inline -# elif defined(__GNUC__) && __GNUC__>=2 -# define ossl_inline __inline__ -# elif defined(_MSC_VER) - /* - * Visual Studio: inline is available in C++ only, however - * __inline is available for C, see - * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx - */ -# define ossl_inline __inline -# else -# define ossl_inline -# endif -# else -# define ossl_inline inline -# endif - -# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && \ - !defined(__cplusplus) -# define ossl_noreturn _Noreturn -# elif defined(__GNUC__) && __GNUC__ >= 2 -# define ossl_noreturn __attribute__((noreturn)) -# else -# define ossl_noreturn -# endif - -/* ossl_unused: portable unused attribute for use in public headers */ -# if defined(__GNUC__) -# define ossl_unused __attribute__((unused)) -# else -# define ossl_unused -# endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ebcdic.h b/client/3rd/OpenSSL/include/openssl/ebcdic.h deleted file mode 100644 index aa012855..00000000 --- a/client/3rd/OpenSSL/include/openssl/ebcdic.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_EBCDIC_H -# define HEADER_EBCDIC_H - -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Avoid name clashes with other applications */ -# define os_toascii _openssl_os_toascii -# define os_toebcdic _openssl_os_toebcdic -# define ebcdic2ascii _openssl_ebcdic2ascii -# define ascii2ebcdic _openssl_ascii2ebcdic - -extern const unsigned char os_toascii[256]; -extern const unsigned char os_toebcdic[256]; -void *ebcdic2ascii(void *dest, const void *srce, size_t count); -void *ascii2ebcdic(void *dest, const void *srce, size_t count); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ec.h b/client/3rd/OpenSSL/include/openssl/ec.h deleted file mode 100644 index 44cc1399..00000000 --- a/client/3rd/OpenSSL/include/openssl/ec.h +++ /dev/null @@ -1,1481 +0,0 @@ -/* - * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_EC_H -# define HEADER_EC_H - -# include - -# ifndef OPENSSL_NO_EC -# include -# include -# if OPENSSL_API_COMPAT < 0x10100000L -# include -# endif -# include -# ifdef __cplusplus -extern "C" { -# endif - -# ifndef OPENSSL_ECC_MAX_FIELD_BITS -# define OPENSSL_ECC_MAX_FIELD_BITS 661 -# endif - -/** Enum for the point conversion form as defined in X9.62 (ECDSA) - * for the encoding of a elliptic curve point (x,y) */ -typedef enum { - /** the point is encoded as z||x, where the octet z specifies - * which solution of the quadratic equation y is */ - POINT_CONVERSION_COMPRESSED = 2, - /** the point is encoded as z||x||y, where z is the octet 0x04 */ - POINT_CONVERSION_UNCOMPRESSED = 4, - /** the point is encoded as z||x||y, where the octet z specifies - * which solution of the quadratic equation y is */ - POINT_CONVERSION_HYBRID = 6 -} point_conversion_form_t; - -typedef struct ec_method_st EC_METHOD; -typedef struct ec_group_st EC_GROUP; -typedef struct ec_point_st EC_POINT; -typedef struct ecpk_parameters_st ECPKPARAMETERS; -typedef struct ec_parameters_st ECPARAMETERS; - -/********************************************************************/ -/* EC_METHODs for curves over GF(p) */ -/********************************************************************/ - -/** Returns the basic GFp ec methods which provides the basis for the - * optimized methods. - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_simple_method(void); - -/** Returns GFp methods using montgomery multiplication. - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_mont_method(void); - -/** Returns GFp methods using optimized methods for NIST recommended curves - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_nist_method(void); - -# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 -/** Returns 64-bit optimized methods for nistp224 - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_nistp224_method(void); - -/** Returns 64-bit optimized methods for nistp256 - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_nistp256_method(void); - -/** Returns 64-bit optimized methods for nistp521 - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_nistp521_method(void); -# endif - -# ifndef OPENSSL_NO_EC2M -/********************************************************************/ -/* EC_METHOD for curves over GF(2^m) */ -/********************************************************************/ - -/** Returns the basic GF2m ec method - * \return EC_METHOD object - */ -const EC_METHOD *EC_GF2m_simple_method(void); - -# endif - -/********************************************************************/ -/* EC_GROUP functions */ -/********************************************************************/ - -/** Creates a new EC_GROUP object - * \param meth EC_METHOD to use - * \return newly created EC_GROUP object or NULL in case of an error. - */ -EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); - -/** Frees a EC_GROUP object - * \param group EC_GROUP object to be freed. - */ -void EC_GROUP_free(EC_GROUP *group); - -/** Clears and frees a EC_GROUP object - * \param group EC_GROUP object to be cleared and freed. - */ -void EC_GROUP_clear_free(EC_GROUP *group); - -/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD. - * \param dst destination EC_GROUP object - * \param src source EC_GROUP object - * \return 1 on success and 0 if an error occurred. - */ -int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); - -/** Creates a new EC_GROUP object and copies the copies the content - * form src to the newly created EC_KEY object - * \param src source EC_GROUP object - * \return newly created EC_GROUP object or NULL in case of an error. - */ -EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); - -/** Returns the EC_METHOD of the EC_GROUP object. - * \param group EC_GROUP object - * \return EC_METHOD used in this EC_GROUP object. - */ -const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); - -/** Returns the field type of the EC_METHOD. - * \param meth EC_METHOD object - * \return NID of the underlying field type OID. - */ -int EC_METHOD_get_field_type(const EC_METHOD *meth); - -/** Sets the generator and its order/cofactor of a EC_GROUP object. - * \param group EC_GROUP object - * \param generator EC_POINT object with the generator. - * \param order the order of the group generated by the generator. - * \param cofactor the index of the sub-group generated by the generator - * in the group of all points on the elliptic curve. - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, - const BIGNUM *order, const BIGNUM *cofactor); - -/** Returns the generator of a EC_GROUP object. - * \param group EC_GROUP object - * \return the currently used generator (possibly NULL). - */ -const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); - -/** Returns the montgomery data for order(Generator) - * \param group EC_GROUP object - * \return the currently used montgomery data (possibly NULL). -*/ -BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group); - -/** Gets the order of a EC_GROUP - * \param group EC_GROUP object - * \param order BIGNUM to which the order is copied - * \param ctx unused - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); - -/** Gets the order of an EC_GROUP - * \param group EC_GROUP object - * \return the group order - */ -const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group); - -/** Gets the number of bits of the order of an EC_GROUP - * \param group EC_GROUP object - * \return number of bits of group order. - */ -int EC_GROUP_order_bits(const EC_GROUP *group); - -/** Gets the cofactor of a EC_GROUP - * \param group EC_GROUP object - * \param cofactor BIGNUM to which the cofactor is copied - * \param ctx unused - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, - BN_CTX *ctx); - -/** Gets the cofactor of an EC_GROUP - * \param group EC_GROUP object - * \return the group cofactor - */ -const BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group); - -/** Sets the name of a EC_GROUP object - * \param group EC_GROUP object - * \param nid NID of the curve name OID - */ -void EC_GROUP_set_curve_name(EC_GROUP *group, int nid); - -/** Returns the curve name of a EC_GROUP object - * \param group EC_GROUP object - * \return NID of the curve name OID or 0 if not set. - */ -int EC_GROUP_get_curve_name(const EC_GROUP *group); - -void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); -int EC_GROUP_get_asn1_flag(const EC_GROUP *group); - -void EC_GROUP_set_point_conversion_form(EC_GROUP *group, - point_conversion_form_t form); -point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); - -unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); -size_t EC_GROUP_get_seed_len(const EC_GROUP *); -size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); - -/** Sets the parameters of a ec curve defined by y^2 = x^3 + a*x + b (for GFp) - * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m) - * \param group EC_GROUP object - * \param p BIGNUM with the prime number (GFp) or the polynomial - * defining the underlying field (GF2m) - * \param a BIGNUM with parameter a of the equation - * \param b BIGNUM with parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, - const BIGNUM *b, BN_CTX *ctx); - -/** Gets the parameters of the ec curve defined by y^2 = x^3 + a*x + b (for GFp) - * or y^2 + x*y = x^3 + a*x^2 + b (for GF2m) - * \param group EC_GROUP object - * \param p BIGNUM with the prime number (GFp) or the polynomial - * defining the underlying field (GF2m) - * \param a BIGNUM for parameter a of the equation - * \param b BIGNUM for parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, - BN_CTX *ctx); - -/** Sets the parameters of an ec curve. Synonym for EC_GROUP_set_curve - * \param group EC_GROUP object - * \param p BIGNUM with the prime number (GFp) or the polynomial - * defining the underlying field (GF2m) - * \param a BIGNUM with parameter a of the equation - * \param b BIGNUM with parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -DEPRECATEDIN_1_2_0(int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, - const BIGNUM *a, const BIGNUM *b, - BN_CTX *ctx)) - -/** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve - * \param group EC_GROUP object - * \param p BIGNUM with the prime number (GFp) or the polynomial - * defining the underlying field (GF2m) - * \param a BIGNUM for parameter a of the equation - * \param b BIGNUM for parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -DEPRECATEDIN_1_2_0(int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, - BIGNUM *a, BIGNUM *b, - BN_CTX *ctx)) - -# ifndef OPENSSL_NO_EC2M -/** Sets the parameter of an ec curve. Synonym for EC_GROUP_set_curve - * \param group EC_GROUP object - * \param p BIGNUM with the prime number (GFp) or the polynomial - * defining the underlying field (GF2m) - * \param a BIGNUM with parameter a of the equation - * \param b BIGNUM with parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -DEPRECATEDIN_1_2_0(int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, - const BIGNUM *a, const BIGNUM *b, - BN_CTX *ctx)) - -/** Gets the parameters of an ec curve. Synonym for EC_GROUP_get_curve - * \param group EC_GROUP object - * \param p BIGNUM with the prime number (GFp) or the polynomial - * defining the underlying field (GF2m) - * \param a BIGNUM for parameter a of the equation - * \param b BIGNUM for parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -DEPRECATEDIN_1_2_0(int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, - BIGNUM *a, BIGNUM *b, - BN_CTX *ctx)) -# endif -/** Returns the number of bits needed to represent a field element - * \param group EC_GROUP object - * \return number of bits needed to represent a field element - */ -int EC_GROUP_get_degree(const EC_GROUP *group); - -/** Checks whether the parameter in the EC_GROUP define a valid ec group - * \param group EC_GROUP object - * \param ctx BN_CTX object (optional) - * \return 1 if group is a valid ec group and 0 otherwise - */ -int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); - -/** Checks whether the discriminant of the elliptic curve is zero or not - * \param group EC_GROUP object - * \param ctx BN_CTX object (optional) - * \return 1 if the discriminant is not zero and 0 otherwise - */ -int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); - -/** Compares two EC_GROUP objects - * \param a first EC_GROUP object - * \param b second EC_GROUP object - * \param ctx BN_CTX object (optional) - * \return 0 if the groups are equal, 1 if not, or -1 on error - */ -int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); - -/* - * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after - * choosing an appropriate EC_METHOD - */ - -/** Creates a new EC_GROUP object with the specified parameters defined - * over GFp (defined by the equation y^2 = x^3 + a*x + b) - * \param p BIGNUM with the prime number - * \param a BIGNUM with the parameter a of the equation - * \param b BIGNUM with the parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return newly created EC_GROUP object with the specified parameters - */ -EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, - const BIGNUM *b, BN_CTX *ctx); -# ifndef OPENSSL_NO_EC2M -/** Creates a new EC_GROUP object with the specified parameters defined - * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) - * \param p BIGNUM with the polynomial defining the underlying field - * \param a BIGNUM with the parameter a of the equation - * \param b BIGNUM with the parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return newly created EC_GROUP object with the specified parameters - */ -EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, - const BIGNUM *b, BN_CTX *ctx); -# endif - -/** Creates a EC_GROUP object with a curve specified by a NID - * \param nid NID of the OID of the curve name - * \return newly created EC_GROUP object with specified curve or NULL - * if an error occurred - */ -EC_GROUP *EC_GROUP_new_by_curve_name(int nid); - -/** Creates a new EC_GROUP object from an ECPARAMETERS object - * \param params pointer to the ECPARAMETERS object - * \return newly created EC_GROUP object with specified curve or NULL - * if an error occurred - */ -EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params); - -/** Creates an ECPARAMETERS object for the given EC_GROUP object. - * \param group pointer to the EC_GROUP object - * \param params pointer to an existing ECPARAMETERS object or NULL - * \return pointer to the new ECPARAMETERS object or NULL - * if an error occurred. - */ -ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, - ECPARAMETERS *params); - -/** Creates a new EC_GROUP object from an ECPKPARAMETERS object - * \param params pointer to an existing ECPKPARAMETERS object, or NULL - * \return newly created EC_GROUP object with specified curve, or NULL - * if an error occurred - */ -EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params); - -/** Creates an ECPKPARAMETERS object for the given EC_GROUP object. - * \param group pointer to the EC_GROUP object - * \param params pointer to an existing ECPKPARAMETERS object or NULL - * \return pointer to the new ECPKPARAMETERS object or NULL - * if an error occurred. - */ -ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, - ECPKPARAMETERS *params); - -/********************************************************************/ -/* handling of internal curves */ -/********************************************************************/ - -typedef struct { - int nid; - const char *comment; -} EC_builtin_curve; - -/* - * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all - * available curves or zero if a error occurred. In case r is not zero, - * nitems EC_builtin_curve structures are filled with the data of the first - * nitems internal groups - */ -size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); - -const char *EC_curve_nid2nist(int nid); -int EC_curve_nist2nid(const char *name); - -/********************************************************************/ -/* EC_POINT functions */ -/********************************************************************/ - -/** Creates a new EC_POINT object for the specified EC_GROUP - * \param group EC_GROUP the underlying EC_GROUP object - * \return newly created EC_POINT object or NULL if an error occurred - */ -EC_POINT *EC_POINT_new(const EC_GROUP *group); - -/** Frees a EC_POINT object - * \param point EC_POINT object to be freed - */ -void EC_POINT_free(EC_POINT *point); - -/** Clears and frees a EC_POINT object - * \param point EC_POINT object to be cleared and freed - */ -void EC_POINT_clear_free(EC_POINT *point); - -/** Copies EC_POINT object - * \param dst destination EC_POINT object - * \param src source EC_POINT object - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); - -/** Creates a new EC_POINT object and copies the content of the supplied - * EC_POINT - * \param src source EC_POINT object - * \param group underlying the EC_GROUP object - * \return newly created EC_POINT object or NULL if an error occurred - */ -EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); - -/** Returns the EC_METHOD used in EC_POINT object - * \param point EC_POINT object - * \return the EC_METHOD used - */ -const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); - -/** Sets a point to infinity (neutral element) - * \param group underlying EC_GROUP object - * \param point EC_POINT to set to infinity - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); - -/** Sets the jacobian projective coordinates of a EC_POINT over GFp - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with the x-coordinate - * \param y BIGNUM with the y-coordinate - * \param z BIGNUM with the z-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, - EC_POINT *p, const BIGNUM *x, - const BIGNUM *y, const BIGNUM *z, - BN_CTX *ctx); - -/** Gets the jacobian projective coordinates of a EC_POINT over GFp - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM for the x-coordinate - * \param y BIGNUM for the y-coordinate - * \param z BIGNUM for the z-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, - const EC_POINT *p, BIGNUM *x, - BIGNUM *y, BIGNUM *z, - BN_CTX *ctx); - -/** Sets the affine coordinates of an EC_POINT - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with the x-coordinate - * \param y BIGNUM with the y-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p, - const BIGNUM *x, const BIGNUM *y, - BN_CTX *ctx); - -/** Gets the affine coordinates of an EC_POINT. - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM for the x-coordinate - * \param y BIGNUM for the y-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p, - BIGNUM *x, BIGNUM *y, BN_CTX *ctx); - -/** Sets the affine coordinates of an EC_POINT. A synonym of - * EC_POINT_set_affine_coordinates - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with the x-coordinate - * \param y BIGNUM with the y-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -DEPRECATEDIN_1_2_0(int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, - EC_POINT *p, - const BIGNUM *x, - const BIGNUM *y, - BN_CTX *ctx)) - -/** Gets the affine coordinates of an EC_POINT. A synonym of - * EC_POINT_get_affine_coordinates - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM for the x-coordinate - * \param y BIGNUM for the y-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -DEPRECATEDIN_1_2_0(int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, - const EC_POINT *p, - BIGNUM *x, - BIGNUM *y, - BN_CTX *ctx)) - -/** Sets the x9.62 compressed coordinates of a EC_POINT - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with x-coordinate - * \param y_bit integer with the y-Bit (either 0 or 1) - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *p, - const BIGNUM *x, int y_bit, - BN_CTX *ctx); - -/** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of - * EC_POINT_set_compressed_coordinates - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with x-coordinate - * \param y_bit integer with the y-Bit (either 0 or 1) - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -DEPRECATEDIN_1_2_0(int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, - EC_POINT *p, - const BIGNUM *x, - int y_bit, - BN_CTX *ctx)) -# ifndef OPENSSL_NO_EC2M -/** Sets the affine coordinates of an EC_POINT. A synonym of - * EC_POINT_set_affine_coordinates - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with the x-coordinate - * \param y BIGNUM with the y-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -DEPRECATEDIN_1_2_0(int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, - EC_POINT *p, - const BIGNUM *x, - const BIGNUM *y, - BN_CTX *ctx)) - -/** Gets the affine coordinates of an EC_POINT. A synonym of - * EC_POINT_get_affine_coordinates - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM for the x-coordinate - * \param y BIGNUM for the y-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -DEPRECATEDIN_1_2_0(int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, - const EC_POINT *p, - BIGNUM *x, - BIGNUM *y, - BN_CTX *ctx)) - -/** Sets the x9.62 compressed coordinates of a EC_POINT. A synonym of - * EC_POINT_set_compressed_coordinates - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with x-coordinate - * \param y_bit integer with the y-Bit (either 0 or 1) - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -DEPRECATEDIN_1_2_0(int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, - EC_POINT *p, - const BIGNUM *x, - int y_bit, - BN_CTX *ctx)) -# endif -/** Encodes a EC_POINT object to a octet string - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param form point conversion form - * \param buf memory buffer for the result. If NULL the function returns - * required buffer size. - * \param len length of the memory buffer - * \param ctx BN_CTX object (optional) - * \return the length of the encoded octet string or 0 if an error occurred - */ -size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, - point_conversion_form_t form, - unsigned char *buf, size_t len, BN_CTX *ctx); - -/** Decodes a EC_POINT from a octet string - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param buf memory buffer with the encoded ec point - * \param len length of the encoded ec point - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, - const unsigned char *buf, size_t len, BN_CTX *ctx); - -/** Encodes an EC_POINT object to an allocated octet string - * \param group underlying EC_GROUP object - * \param point EC_POINT object - * \param form point conversion form - * \param pbuf returns pointer to allocated buffer - * \param ctx BN_CTX object (optional) - * \return the length of the encoded octet string or 0 if an error occurred - */ -size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point, - point_conversion_form_t form, - unsigned char **pbuf, BN_CTX *ctx); - -/* other interfaces to point2oct/oct2point: */ -BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, - point_conversion_form_t form, BIGNUM *, BN_CTX *); -EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, - EC_POINT *, BN_CTX *); -char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, - point_conversion_form_t form, BN_CTX *); -EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, - EC_POINT *, BN_CTX *); - -/********************************************************************/ -/* functions for doing EC_POINT arithmetic */ -/********************************************************************/ - -/** Computes the sum of two EC_POINT - * \param group underlying EC_GROUP object - * \param r EC_POINT object for the result (r = a + b) - * \param a EC_POINT object with the first summand - * \param b EC_POINT object with the second summand - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, - const EC_POINT *b, BN_CTX *ctx); - -/** Computes the double of a EC_POINT - * \param group underlying EC_GROUP object - * \param r EC_POINT object for the result (r = 2 * a) - * \param a EC_POINT object - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, - BN_CTX *ctx); - -/** Computes the inverse of a EC_POINT - * \param group underlying EC_GROUP object - * \param a EC_POINT object to be inverted (it's used for the result as well) - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); - -/** Checks whether the point is the neutral element of the group - * \param group the underlying EC_GROUP object - * \param p EC_POINT object - * \return 1 if the point is the neutral element and 0 otherwise - */ -int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); - -/** Checks whether the point is on the curve - * \param group underlying EC_GROUP object - * \param point EC_POINT object to check - * \param ctx BN_CTX object (optional) - * \return 1 if the point is on the curve, 0 if not, or -1 on error - */ -int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, - BN_CTX *ctx); - -/** Compares two EC_POINTs - * \param group underlying EC_GROUP object - * \param a first EC_POINT object - * \param b second EC_POINT object - * \param ctx BN_CTX object (optional) - * \return 1 if the points are not equal, 0 if they are, or -1 on error - */ -int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, - BN_CTX *ctx); - -int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx); -int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, - EC_POINT *points[], BN_CTX *ctx); - -/** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i] - * \param group underlying EC_GROUP object - * \param r EC_POINT object for the result - * \param n BIGNUM with the multiplier for the group generator (optional) - * \param num number further summands - * \param p array of size num of EC_POINT objects - * \param m array of size num of BIGNUM objects - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, - size_t num, const EC_POINT *p[], const BIGNUM *m[], - BN_CTX *ctx); - -/** Computes r = generator * n + q * m - * \param group underlying EC_GROUP object - * \param r EC_POINT object for the result - * \param n BIGNUM with the multiplier for the group generator (optional) - * \param q EC_POINT object with the first factor of the second summand - * \param m BIGNUM with the second factor of the second summand - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, - const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); - -/** Stores multiples of generator for faster point multiplication - * \param group EC_GROUP object - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); - -/** Reports whether a precomputation has been done - * \param group EC_GROUP object - * \return 1 if a pre-computation has been done and 0 otherwise - */ -int EC_GROUP_have_precompute_mult(const EC_GROUP *group); - -/********************************************************************/ -/* ASN1 stuff */ -/********************************************************************/ - -DECLARE_ASN1_ITEM(ECPKPARAMETERS) -DECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS) -DECLARE_ASN1_ITEM(ECPARAMETERS) -DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS) - -/* - * EC_GROUP_get_basis_type() returns the NID of the basis type used to - * represent the field elements - */ -int EC_GROUP_get_basis_type(const EC_GROUP *); -# ifndef OPENSSL_NO_EC2M -int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); -int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, - unsigned int *k2, unsigned int *k3); -# endif - -# define OPENSSL_EC_EXPLICIT_CURVE 0x000 -# define OPENSSL_EC_NAMED_CURVE 0x001 - -EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); -int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); - -# define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) -# define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) -# define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \ - (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) -# define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \ - (unsigned char *)(x)) - -int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); -# ifndef OPENSSL_NO_STDIO -int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); -# endif - -/********************************************************************/ -/* EC_KEY functions */ -/********************************************************************/ - -/* some values for the encoding_flag */ -# define EC_PKEY_NO_PARAMETERS 0x001 -# define EC_PKEY_NO_PUBKEY 0x002 - -/* some values for the flags field */ -# define EC_FLAG_NON_FIPS_ALLOW 0x1 -# define EC_FLAG_FIPS_CHECKED 0x2 -# define EC_FLAG_COFACTOR_ECDH 0x1000 - -/** Creates a new EC_KEY object. - * \return EC_KEY object or NULL if an error occurred. - */ -EC_KEY *EC_KEY_new(void); - -int EC_KEY_get_flags(const EC_KEY *key); - -void EC_KEY_set_flags(EC_KEY *key, int flags); - -void EC_KEY_clear_flags(EC_KEY *key, int flags); - -int EC_KEY_decoded_from_explicit_params(const EC_KEY *key); - -/** Creates a new EC_KEY object using a named curve as underlying - * EC_GROUP object. - * \param nid NID of the named curve. - * \return EC_KEY object or NULL if an error occurred. - */ -EC_KEY *EC_KEY_new_by_curve_name(int nid); - -/** Frees a EC_KEY object. - * \param key EC_KEY object to be freed. - */ -void EC_KEY_free(EC_KEY *key); - -/** Copies a EC_KEY object. - * \param dst destination EC_KEY object - * \param src src EC_KEY object - * \return dst or NULL if an error occurred. - */ -EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); - -/** Creates a new EC_KEY object and copies the content from src to it. - * \param src the source EC_KEY object - * \return newly created EC_KEY object or NULL if an error occurred. - */ -EC_KEY *EC_KEY_dup(const EC_KEY *src); - -/** Increases the internal reference count of a EC_KEY object. - * \param key EC_KEY object - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_up_ref(EC_KEY *key); - -/** Returns the ENGINE object of a EC_KEY object - * \param eckey EC_KEY object - * \return the ENGINE object (possibly NULL). - */ -ENGINE *EC_KEY_get0_engine(const EC_KEY *eckey); - -/** Returns the EC_GROUP object of a EC_KEY object - * \param key EC_KEY object - * \return the EC_GROUP object (possibly NULL). - */ -const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); - -/** Sets the EC_GROUP of a EC_KEY object. - * \param key EC_KEY object - * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY - * object will use an own copy of the EC_GROUP). - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); - -/** Returns the private key of a EC_KEY object. - * \param key EC_KEY object - * \return a BIGNUM with the private key (possibly NULL). - */ -const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); - -/** Sets the private key of a EC_KEY object. - * \param key EC_KEY object - * \param prv BIGNUM with the private key (note: the EC_KEY object - * will use an own copy of the BIGNUM). - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); - -/** Returns the public key of a EC_KEY object. - * \param key the EC_KEY object - * \return a EC_POINT object with the public key (possibly NULL) - */ -const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); - -/** Sets the public key of a EC_KEY object. - * \param key EC_KEY object - * \param pub EC_POINT object with the public key (note: the EC_KEY object - * will use an own copy of the EC_POINT object). - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); - -unsigned EC_KEY_get_enc_flags(const EC_KEY *key); -void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); -point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); -void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform); - -#define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef) -int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg); -void *EC_KEY_get_ex_data(const EC_KEY *key, int idx); - -/* wrapper functions for the underlying EC_GROUP object */ -void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); - -/** Creates a table of pre-computed multiples of the generator to - * accelerate further EC_KEY operations. - * \param key EC_KEY object - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); - -/** Creates a new ec private (and optional a new public) key. - * \param key EC_KEY object - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_generate_key(EC_KEY *key); - -/** Verifies that a private and/or public key is valid. - * \param key the EC_KEY object - * \return 1 on success and 0 otherwise. - */ -int EC_KEY_check_key(const EC_KEY *key); - -/** Indicates if an EC_KEY can be used for signing. - * \param eckey the EC_KEY object - * \return 1 if can can sign and 0 otherwise. - */ -int EC_KEY_can_sign(const EC_KEY *eckey); - -/** Sets a public key from affine coordinates performing - * necessary NIST PKV tests. - * \param key the EC_KEY object - * \param x public key x coordinate - * \param y public key y coordinate - * \return 1 on success and 0 otherwise. - */ -int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, - BIGNUM *y); - -/** Encodes an EC_KEY public key to an allocated octet string - * \param key key to encode - * \param form point conversion form - * \param pbuf returns pointer to allocated buffer - * \param ctx BN_CTX object (optional) - * \return the length of the encoded octet string or 0 if an error occurred - */ -size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form, - unsigned char **pbuf, BN_CTX *ctx); - -/** Decodes a EC_KEY public key from a octet string - * \param key key to decode - * \param buf memory buffer with the encoded ec point - * \param len length of the encoded ec point - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ - -int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, size_t len, - BN_CTX *ctx); - -/** Decodes an EC_KEY private key from an octet string - * \param key key to decode - * \param buf memory buffer with the encoded private key - * \param len length of the encoded key - * \return 1 on success and 0 if an error occurred - */ - -int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, size_t len); - -/** Encodes a EC_KEY private key to an octet string - * \param key key to encode - * \param buf memory buffer for the result. If NULL the function returns - * required buffer size. - * \param len length of the memory buffer - * \return the length of the encoded octet string or 0 if an error occurred - */ - -size_t EC_KEY_priv2oct(const EC_KEY *key, unsigned char *buf, size_t len); - -/** Encodes an EC_KEY private key to an allocated octet string - * \param eckey key to encode - * \param pbuf returns pointer to allocated buffer - * \return the length of the encoded octet string or 0 if an error occurred - */ -size_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf); - -/********************************************************************/ -/* de- and encoding functions for SEC1 ECPrivateKey */ -/********************************************************************/ - -/** Decodes a private key from a memory buffer. - * \param key a pointer to a EC_KEY object which should be used (or NULL) - * \param in pointer to memory with the DER encoded private key - * \param len length of the DER encoded private key - * \return the decoded private key or NULL if an error occurred. - */ -EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len); - -/** Encodes a private key object and stores the result in a buffer. - * \param key the EC_KEY object to encode - * \param out the buffer for the result (if NULL the function returns number - * of bytes needed). - * \return 1 on success and 0 if an error occurred. - */ -int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out); - -/********************************************************************/ -/* de- and encoding functions for EC parameters */ -/********************************************************************/ - -/** Decodes ec parameter from a memory buffer. - * \param key a pointer to a EC_KEY object which should be used (or NULL) - * \param in pointer to memory with the DER encoded ec parameters - * \param len length of the DER encoded ec parameters - * \return a EC_KEY object with the decoded parameters or NULL if an error - * occurred. - */ -EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len); - -/** Encodes ec parameter and stores the result in a buffer. - * \param key the EC_KEY object with ec parameters to encode - * \param out the buffer for the result (if NULL the function returns number - * of bytes needed). - * \return 1 on success and 0 if an error occurred. - */ -int i2d_ECParameters(EC_KEY *key, unsigned char **out); - -/********************************************************************/ -/* de- and encoding functions for EC public key */ -/* (octet string, not DER -- hence 'o2i' and 'i2o') */ -/********************************************************************/ - -/** Decodes a ec public key from a octet string. - * \param key a pointer to a EC_KEY object which should be used - * \param in memory buffer with the encoded public key - * \param len length of the encoded public key - * \return EC_KEY object with decoded public key or NULL if an error - * occurred. - */ -EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len); - -/** Encodes a ec public key in an octet string. - * \param key the EC_KEY object with the public key - * \param out the buffer for the result (if NULL the function returns number - * of bytes needed). - * \return 1 on success and 0 if an error occurred - */ -int i2o_ECPublicKey(const EC_KEY *key, unsigned char **out); - -/** Prints out the ec parameters on human readable form. - * \param bp BIO object to which the information is printed - * \param key EC_KEY object - * \return 1 on success and 0 if an error occurred - */ -int ECParameters_print(BIO *bp, const EC_KEY *key); - -/** Prints out the contents of a EC_KEY object - * \param bp BIO object to which the information is printed - * \param key EC_KEY object - * \param off line offset - * \return 1 on success and 0 if an error occurred - */ -int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); - -# ifndef OPENSSL_NO_STDIO -/** Prints out the ec parameters on human readable form. - * \param fp file descriptor to which the information is printed - * \param key EC_KEY object - * \return 1 on success and 0 if an error occurred - */ -int ECParameters_print_fp(FILE *fp, const EC_KEY *key); - -/** Prints out the contents of a EC_KEY object - * \param fp file descriptor to which the information is printed - * \param key EC_KEY object - * \param off line offset - * \return 1 on success and 0 if an error occurred - */ -int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); - -# endif - -const EC_KEY_METHOD *EC_KEY_OpenSSL(void); -const EC_KEY_METHOD *EC_KEY_get_default_method(void); -void EC_KEY_set_default_method(const EC_KEY_METHOD *meth); -const EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key); -int EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth); -EC_KEY *EC_KEY_new_method(ENGINE *engine); - -/** The old name for ecdh_KDF_X9_63 - * The ECDH KDF specification has been mistakingly attributed to ANSI X9.62, - * it is actually specified in ANSI X9.63. - * This identifier is retained for backwards compatibility - */ -int ECDH_KDF_X9_62(unsigned char *out, size_t outlen, - const unsigned char *Z, size_t Zlen, - const unsigned char *sinfo, size_t sinfolen, - const EVP_MD *md); - -int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, - const EC_KEY *ecdh, - void *(*KDF) (const void *in, size_t inlen, - void *out, size_t *outlen)); - -typedef struct ECDSA_SIG_st ECDSA_SIG; - -/** Allocates and initialize a ECDSA_SIG structure - * \return pointer to a ECDSA_SIG structure or NULL if an error occurred - */ -ECDSA_SIG *ECDSA_SIG_new(void); - -/** frees a ECDSA_SIG structure - * \param sig pointer to the ECDSA_SIG structure - */ -void ECDSA_SIG_free(ECDSA_SIG *sig); - -/** DER encode content of ECDSA_SIG object (note: this function modifies *pp - * (*pp += length of the DER encoded signature)). - * \param sig pointer to the ECDSA_SIG object - * \param pp pointer to a unsigned char pointer for the output or NULL - * \return the length of the DER encoded ECDSA_SIG object or a negative value - * on error - */ -int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp); - -/** Decodes a DER encoded ECDSA signature (note: this function changes *pp - * (*pp += len)). - * \param sig pointer to ECDSA_SIG pointer (may be NULL) - * \param pp memory buffer with the DER encoded signature - * \param len length of the buffer - * \return pointer to the decoded ECDSA_SIG structure (or NULL) - */ -ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len); - -/** Accessor for r and s fields of ECDSA_SIG - * \param sig pointer to ECDSA_SIG structure - * \param pr pointer to BIGNUM pointer for r (may be NULL) - * \param ps pointer to BIGNUM pointer for s (may be NULL) - */ -void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); - -/** Accessor for r field of ECDSA_SIG - * \param sig pointer to ECDSA_SIG structure - */ -const BIGNUM *ECDSA_SIG_get0_r(const ECDSA_SIG *sig); - -/** Accessor for s field of ECDSA_SIG - * \param sig pointer to ECDSA_SIG structure - */ -const BIGNUM *ECDSA_SIG_get0_s(const ECDSA_SIG *sig); - -/** Setter for r and s fields of ECDSA_SIG - * \param sig pointer to ECDSA_SIG structure - * \param r pointer to BIGNUM for r (may be NULL) - * \param s pointer to BIGNUM for s (may be NULL) - */ -int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); - -/** Computes the ECDSA signature of the given hash value using - * the supplied private key and returns the created signature. - * \param dgst pointer to the hash value - * \param dgst_len length of the hash value - * \param eckey EC_KEY object containing a private EC key - * \return pointer to a ECDSA_SIG structure or NULL if an error occurred - */ -ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len, - EC_KEY *eckey); - -/** Computes ECDSA signature of a given hash value using the supplied - * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). - * \param dgst pointer to the hash value to sign - * \param dgstlen length of the hash value - * \param kinv BIGNUM with a pre-computed inverse k (optional) - * \param rp BIGNUM with a pre-computed rp value (optional), - * see ECDSA_sign_setup - * \param eckey EC_KEY object containing a private EC key - * \return pointer to a ECDSA_SIG structure or NULL if an error occurred - */ -ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, - const BIGNUM *kinv, const BIGNUM *rp, - EC_KEY *eckey); - -/** Verifies that the supplied signature is a valid ECDSA - * signature of the supplied hash value using the supplied public key. - * \param dgst pointer to the hash value - * \param dgst_len length of the hash value - * \param sig ECDSA_SIG structure - * \param eckey EC_KEY object containing a public EC key - * \return 1 if the signature is valid, 0 if the signature is invalid - * and -1 on error - */ -int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, - const ECDSA_SIG *sig, EC_KEY *eckey); - -/** Precompute parts of the signing operation - * \param eckey EC_KEY object containing a private EC key - * \param ctx BN_CTX object (optional) - * \param kinv BIGNUM pointer for the inverse of k - * \param rp BIGNUM pointer for x coordinate of k * generator - * \return 1 on success and 0 otherwise - */ -int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp); - -/** Computes ECDSA signature of a given hash value using the supplied - * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). - * \param type this parameter is ignored - * \param dgst pointer to the hash value to sign - * \param dgstlen length of the hash value - * \param sig memory for the DER encoded created signature - * \param siglen pointer to the length of the returned signature - * \param eckey EC_KEY object containing a private EC key - * \return 1 on success and 0 otherwise - */ -int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, - unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); - -/** Computes ECDSA signature of a given hash value using the supplied - * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). - * \param type this parameter is ignored - * \param dgst pointer to the hash value to sign - * \param dgstlen length of the hash value - * \param sig buffer to hold the DER encoded signature - * \param siglen pointer to the length of the returned signature - * \param kinv BIGNUM with a pre-computed inverse k (optional) - * \param rp BIGNUM with a pre-computed rp value (optional), - * see ECDSA_sign_setup - * \param eckey EC_KEY object containing a private EC key - * \return 1 on success and 0 otherwise - */ -int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, - unsigned char *sig, unsigned int *siglen, - const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); - -/** Verifies that the given signature is valid ECDSA signature - * of the supplied hash value using the specified public key. - * \param type this parameter is ignored - * \param dgst pointer to the hash value - * \param dgstlen length of the hash value - * \param sig pointer to the DER encoded signature - * \param siglen length of the DER encoded signature - * \param eckey EC_KEY object containing a public EC key - * \return 1 if the signature is valid, 0 if the signature is invalid - * and -1 on error - */ -int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, - const unsigned char *sig, int siglen, EC_KEY *eckey); - -/** Returns the maximum length of the DER encoded signature - * \param eckey EC_KEY object - * \return numbers of bytes required for the DER encoded signature - */ -int ECDSA_size(const EC_KEY *eckey); - -/********************************************************************/ -/* EC_KEY_METHOD constructors, destructors, writers and accessors */ -/********************************************************************/ - -EC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth); -void EC_KEY_METHOD_free(EC_KEY_METHOD *meth); -void EC_KEY_METHOD_set_init(EC_KEY_METHOD *meth, - int (*init)(EC_KEY *key), - void (*finish)(EC_KEY *key), - int (*copy)(EC_KEY *dest, const EC_KEY *src), - int (*set_group)(EC_KEY *key, const EC_GROUP *grp), - int (*set_private)(EC_KEY *key, - const BIGNUM *priv_key), - int (*set_public)(EC_KEY *key, - const EC_POINT *pub_key)); - -void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD *meth, - int (*keygen)(EC_KEY *key)); - -void EC_KEY_METHOD_set_compute_key(EC_KEY_METHOD *meth, - int (*ckey)(unsigned char **psec, - size_t *pseclen, - const EC_POINT *pub_key, - const EC_KEY *ecdh)); - -void EC_KEY_METHOD_set_sign(EC_KEY_METHOD *meth, - int (*sign)(int type, const unsigned char *dgst, - int dlen, unsigned char *sig, - unsigned int *siglen, - const BIGNUM *kinv, const BIGNUM *r, - EC_KEY *eckey), - int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, - BIGNUM **kinvp, BIGNUM **rp), - ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, - int dgst_len, - const BIGNUM *in_kinv, - const BIGNUM *in_r, - EC_KEY *eckey)); - -void EC_KEY_METHOD_set_verify(EC_KEY_METHOD *meth, - int (*verify)(int type, const unsigned - char *dgst, int dgst_len, - const unsigned char *sigbuf, - int sig_len, EC_KEY *eckey), - int (*verify_sig)(const unsigned char *dgst, - int dgst_len, - const ECDSA_SIG *sig, - EC_KEY *eckey)); - -void EC_KEY_METHOD_get_init(const EC_KEY_METHOD *meth, - int (**pinit)(EC_KEY *key), - void (**pfinish)(EC_KEY *key), - int (**pcopy)(EC_KEY *dest, const EC_KEY *src), - int (**pset_group)(EC_KEY *key, - const EC_GROUP *grp), - int (**pset_private)(EC_KEY *key, - const BIGNUM *priv_key), - int (**pset_public)(EC_KEY *key, - const EC_POINT *pub_key)); - -void EC_KEY_METHOD_get_keygen(const EC_KEY_METHOD *meth, - int (**pkeygen)(EC_KEY *key)); - -void EC_KEY_METHOD_get_compute_key(const EC_KEY_METHOD *meth, - int (**pck)(unsigned char **psec, - size_t *pseclen, - const EC_POINT *pub_key, - const EC_KEY *ecdh)); - -void EC_KEY_METHOD_get_sign(const EC_KEY_METHOD *meth, - int (**psign)(int type, const unsigned char *dgst, - int dlen, unsigned char *sig, - unsigned int *siglen, - const BIGNUM *kinv, const BIGNUM *r, - EC_KEY *eckey), - int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, - BIGNUM **kinvp, BIGNUM **rp), - ECDSA_SIG *(**psign_sig)(const unsigned char *dgst, - int dgst_len, - const BIGNUM *in_kinv, - const BIGNUM *in_r, - EC_KEY *eckey)); - -void EC_KEY_METHOD_get_verify(const EC_KEY_METHOD *meth, - int (**pverify)(int type, const unsigned - char *dgst, int dgst_len, - const unsigned char *sigbuf, - int sig_len, EC_KEY *eckey), - int (**pverify_sig)(const unsigned char *dgst, - int dgst_len, - const ECDSA_SIG *sig, - EC_KEY *eckey)); - -# define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) - -# ifndef __cplusplus -# if defined(__SUNPRO_C) -# if __SUNPRO_C >= 0x520 -# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) -# endif -# endif -# endif - -# define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) - -# define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL) - -# define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL) - -# define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL) - -# define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL) - -# define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL) - -# define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)(md)) - -# define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)(pmd)) - -# define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL) - -# define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, \ - (void *)(plen)) - -# define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)(p)) - -# define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)(p)) - -/* SM2 will skip the operation check so no need to pass operation here */ -# define EVP_PKEY_CTX_set1_id(ctx, id, id_len) \ - EVP_PKEY_CTX_ctrl(ctx, -1, -1, \ - EVP_PKEY_CTRL_SET1_ID, (int)id_len, (void*)(id)) - -# define EVP_PKEY_CTX_get1_id(ctx, id) \ - EVP_PKEY_CTX_ctrl(ctx, -1, -1, \ - EVP_PKEY_CTRL_GET1_ID, 0, (void*)(id)) - -# define EVP_PKEY_CTX_get1_id_len(ctx, id_len) \ - EVP_PKEY_CTX_ctrl(ctx, -1, -1, \ - EVP_PKEY_CTRL_GET1_ID_LEN, 0, (void*)(id_len)) - -# define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1) -# define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2) -# define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3) -# define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4) -# define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5) -# define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6) -# define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7) -# define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8) -# define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9) -# define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10) -# define EVP_PKEY_CTRL_SET1_ID (EVP_PKEY_ALG_CTRL + 11) -# define EVP_PKEY_CTRL_GET1_ID (EVP_PKEY_ALG_CTRL + 12) -# define EVP_PKEY_CTRL_GET1_ID_LEN (EVP_PKEY_ALG_CTRL + 13) -/* KDF types */ -# define EVP_PKEY_ECDH_KDF_NONE 1 -# define EVP_PKEY_ECDH_KDF_X9_63 2 -/** The old name for EVP_PKEY_ECDH_KDF_X9_63 - * The ECDH KDF specification has been mistakingly attributed to ANSI X9.62, - * it is actually specified in ANSI X9.63. - * This identifier is retained for backwards compatibility - */ -# define EVP_PKEY_ECDH_KDF_X9_62 EVP_PKEY_ECDH_KDF_X9_63 - - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ecdh.h b/client/3rd/OpenSSL/include/openssl/ecdh.h deleted file mode 100644 index 681f3d5e..00000000 --- a/client/3rd/OpenSSL/include/openssl/ecdh.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include diff --git a/client/3rd/OpenSSL/include/openssl/ecdsa.h b/client/3rd/OpenSSL/include/openssl/ecdsa.h deleted file mode 100644 index 681f3d5e..00000000 --- a/client/3rd/OpenSSL/include/openssl/ecdsa.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include diff --git a/client/3rd/OpenSSL/include/openssl/ecerr.h b/client/3rd/OpenSSL/include/openssl/ecerr.h deleted file mode 100644 index 51738113..00000000 --- a/client/3rd/OpenSSL/include/openssl/ecerr.h +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ECERR_H -# define HEADER_ECERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# include - -# ifndef OPENSSL_NO_EC - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_EC_strings(void); - -/* - * EC function codes. - */ -# define EC_F_BN_TO_FELEM 224 -# define EC_F_D2I_ECPARAMETERS 144 -# define EC_F_D2I_ECPKPARAMETERS 145 -# define EC_F_D2I_ECPRIVATEKEY 146 -# define EC_F_DO_EC_KEY_PRINT 221 -# define EC_F_ECDH_CMS_DECRYPT 238 -# define EC_F_ECDH_CMS_SET_SHARED_INFO 239 -# define EC_F_ECDH_COMPUTE_KEY 246 -# define EC_F_ECDH_SIMPLE_COMPUTE_KEY 257 -# define EC_F_ECDSA_DO_SIGN_EX 251 -# define EC_F_ECDSA_DO_VERIFY 252 -# define EC_F_ECDSA_SIGN_EX 254 -# define EC_F_ECDSA_SIGN_SETUP 248 -# define EC_F_ECDSA_SIG_NEW 265 -# define EC_F_ECDSA_VERIFY 253 -# define EC_F_ECD_ITEM_VERIFY 270 -# define EC_F_ECKEY_PARAM2TYPE 223 -# define EC_F_ECKEY_PARAM_DECODE 212 -# define EC_F_ECKEY_PRIV_DECODE 213 -# define EC_F_ECKEY_PRIV_ENCODE 214 -# define EC_F_ECKEY_PUB_DECODE 215 -# define EC_F_ECKEY_PUB_ENCODE 216 -# define EC_F_ECKEY_TYPE2PARAM 220 -# define EC_F_ECPARAMETERS_PRINT 147 -# define EC_F_ECPARAMETERS_PRINT_FP 148 -# define EC_F_ECPKPARAMETERS_PRINT 149 -# define EC_F_ECPKPARAMETERS_PRINT_FP 150 -# define EC_F_ECP_NISTZ256_GET_AFFINE 240 -# define EC_F_ECP_NISTZ256_INV_MOD_ORD 275 -# define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 243 -# define EC_F_ECP_NISTZ256_POINTS_MUL 241 -# define EC_F_ECP_NISTZ256_PRE_COMP_NEW 244 -# define EC_F_ECP_NISTZ256_WINDOWED_MUL 242 -# define EC_F_ECX_KEY_OP 266 -# define EC_F_ECX_PRIV_ENCODE 267 -# define EC_F_ECX_PUB_ENCODE 268 -# define EC_F_EC_ASN1_GROUP2CURVE 153 -# define EC_F_EC_ASN1_GROUP2FIELDID 154 -# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208 -# define EC_F_EC_GF2M_SIMPLE_FIELD_INV 296 -# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 -# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195 -# define EC_F_EC_GF2M_SIMPLE_LADDER_POST 285 -# define EC_F_EC_GF2M_SIMPLE_LADDER_PRE 288 -# define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 -# define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 -# define EC_F_EC_GF2M_SIMPLE_POINTS_MUL 289 -# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 -# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 -# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 -# define EC_F_EC_GFP_MONT_FIELD_DECODE 133 -# define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 -# define EC_F_EC_GFP_MONT_FIELD_INV 297 -# define EC_F_EC_GFP_MONT_FIELD_MUL 131 -# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209 -# define EC_F_EC_GFP_MONT_FIELD_SQR 132 -# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 -# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 225 -# define EC_F_EC_GFP_NISTP224_POINTS_MUL 228 -# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226 -# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 230 -# define EC_F_EC_GFP_NISTP256_POINTS_MUL 231 -# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232 -# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 233 -# define EC_F_EC_GFP_NISTP521_POINTS_MUL 234 -# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235 -# define EC_F_EC_GFP_NIST_FIELD_MUL 200 -# define EC_F_EC_GFP_NIST_FIELD_SQR 201 -# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 -# define EC_F_EC_GFP_SIMPLE_BLIND_COORDINATES 287 -# define EC_F_EC_GFP_SIMPLE_FIELD_INV 298 -# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 -# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 -# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 -# define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 -# define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 -# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 -# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 -# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 -# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 -# define EC_F_EC_GROUP_CHECK 170 -# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 -# define EC_F_EC_GROUP_COPY 106 -# define EC_F_EC_GROUP_GET_CURVE 291 -# define EC_F_EC_GROUP_GET_CURVE_GF2M 172 -# define EC_F_EC_GROUP_GET_CURVE_GFP 130 -# define EC_F_EC_GROUP_GET_DEGREE 173 -# define EC_F_EC_GROUP_GET_ECPARAMETERS 261 -# define EC_F_EC_GROUP_GET_ECPKPARAMETERS 262 -# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193 -# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194 -# define EC_F_EC_GROUP_NEW 108 -# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174 -# define EC_F_EC_GROUP_NEW_FROM_DATA 175 -# define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 263 -# define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 264 -# define EC_F_EC_GROUP_SET_CURVE 292 -# define EC_F_EC_GROUP_SET_CURVE_GF2M 176 -# define EC_F_EC_GROUP_SET_CURVE_GFP 109 -# define EC_F_EC_GROUP_SET_GENERATOR 111 -# define EC_F_EC_GROUP_SET_SEED 286 -# define EC_F_EC_KEY_CHECK_KEY 177 -# define EC_F_EC_KEY_COPY 178 -# define EC_F_EC_KEY_GENERATE_KEY 179 -# define EC_F_EC_KEY_NEW 182 -# define EC_F_EC_KEY_NEW_METHOD 245 -# define EC_F_EC_KEY_OCT2PRIV 255 -# define EC_F_EC_KEY_PRINT 180 -# define EC_F_EC_KEY_PRINT_FP 181 -# define EC_F_EC_KEY_PRIV2BUF 279 -# define EC_F_EC_KEY_PRIV2OCT 256 -# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229 -# define EC_F_EC_KEY_SIMPLE_CHECK_KEY 258 -# define EC_F_EC_KEY_SIMPLE_OCT2PRIV 259 -# define EC_F_EC_KEY_SIMPLE_PRIV2OCT 260 -# define EC_F_EC_PKEY_CHECK 273 -# define EC_F_EC_PKEY_PARAM_CHECK 274 -# define EC_F_EC_POINTS_MAKE_AFFINE 136 -# define EC_F_EC_POINTS_MUL 290 -# define EC_F_EC_POINT_ADD 112 -# define EC_F_EC_POINT_BN2POINT 280 -# define EC_F_EC_POINT_CMP 113 -# define EC_F_EC_POINT_COPY 114 -# define EC_F_EC_POINT_DBL 115 -# define EC_F_EC_POINT_GET_AFFINE_COORDINATES 293 -# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 -# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 -# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 -# define EC_F_EC_POINT_INVERT 210 -# define EC_F_EC_POINT_IS_AT_INFINITY 118 -# define EC_F_EC_POINT_IS_ON_CURVE 119 -# define EC_F_EC_POINT_MAKE_AFFINE 120 -# define EC_F_EC_POINT_NEW 121 -# define EC_F_EC_POINT_OCT2POINT 122 -# define EC_F_EC_POINT_POINT2BUF 281 -# define EC_F_EC_POINT_POINT2OCT 123 -# define EC_F_EC_POINT_SET_AFFINE_COORDINATES 294 -# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 -# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 -# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES 295 -# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 -# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 -# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 -# define EC_F_EC_POINT_SET_TO_INFINITY 127 -# define EC_F_EC_PRE_COMP_NEW 196 -# define EC_F_EC_SCALAR_MUL_LADDER 284 -# define EC_F_EC_WNAF_MUL 187 -# define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 -# define EC_F_I2D_ECPARAMETERS 190 -# define EC_F_I2D_ECPKPARAMETERS 191 -# define EC_F_I2D_ECPRIVATEKEY 192 -# define EC_F_I2O_ECPUBLICKEY 151 -# define EC_F_NISTP224_PRE_COMP_NEW 227 -# define EC_F_NISTP256_PRE_COMP_NEW 236 -# define EC_F_NISTP521_PRE_COMP_NEW 237 -# define EC_F_O2I_ECPUBLICKEY 152 -# define EC_F_OLD_EC_PRIV_DECODE 222 -# define EC_F_OSSL_ECDH_COMPUTE_KEY 247 -# define EC_F_OSSL_ECDSA_SIGN_SIG 249 -# define EC_F_OSSL_ECDSA_VERIFY_SIG 250 -# define EC_F_PKEY_ECD_CTRL 271 -# define EC_F_PKEY_ECD_DIGESTSIGN 272 -# define EC_F_PKEY_ECD_DIGESTSIGN25519 276 -# define EC_F_PKEY_ECD_DIGESTSIGN448 277 -# define EC_F_PKEY_ECX_DERIVE 269 -# define EC_F_PKEY_EC_CTRL 197 -# define EC_F_PKEY_EC_CTRL_STR 198 -# define EC_F_PKEY_EC_DERIVE 217 -# define EC_F_PKEY_EC_INIT 282 -# define EC_F_PKEY_EC_KDF_DERIVE 283 -# define EC_F_PKEY_EC_KEYGEN 199 -# define EC_F_PKEY_EC_PARAMGEN 219 -# define EC_F_PKEY_EC_SIGN 218 -# define EC_F_VALIDATE_ECX_DERIVE 278 - -/* - * EC reason codes. - */ -# define EC_R_ASN1_ERROR 115 -# define EC_R_BAD_SIGNATURE 156 -# define EC_R_BIGNUM_OUT_OF_RANGE 144 -# define EC_R_BUFFER_TOO_SMALL 100 -# define EC_R_CANNOT_INVERT 165 -# define EC_R_COORDINATES_OUT_OF_RANGE 146 -# define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH 160 -# define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING 159 -# define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 -# define EC_R_DECODE_ERROR 142 -# define EC_R_DISCRIMINANT_IS_ZERO 118 -# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 -# define EC_R_FIELD_TOO_LARGE 143 -# define EC_R_GF2M_NOT_SUPPORTED 147 -# define EC_R_GROUP2PKPARAMETERS_FAILURE 120 -# define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 -# define EC_R_INCOMPATIBLE_OBJECTS 101 -# define EC_R_INVALID_ARGUMENT 112 -# define EC_R_INVALID_COMPRESSED_POINT 110 -# define EC_R_INVALID_COMPRESSION_BIT 109 -# define EC_R_INVALID_CURVE 141 -# define EC_R_INVALID_DIGEST 151 -# define EC_R_INVALID_DIGEST_TYPE 138 -# define EC_R_INVALID_ENCODING 102 -# define EC_R_INVALID_FIELD 103 -# define EC_R_INVALID_FORM 104 -# define EC_R_INVALID_GROUP_ORDER 122 -# define EC_R_INVALID_KEY 116 -# define EC_R_INVALID_OUTPUT_LENGTH 161 -# define EC_R_INVALID_PEER_KEY 133 -# define EC_R_INVALID_PENTANOMIAL_BASIS 132 -# define EC_R_INVALID_PRIVATE_KEY 123 -# define EC_R_INVALID_TRINOMIAL_BASIS 137 -# define EC_R_KDF_PARAMETER_ERROR 148 -# define EC_R_KEYS_NOT_SET 140 -# define EC_R_LADDER_POST_FAILURE 136 -# define EC_R_LADDER_PRE_FAILURE 153 -# define EC_R_LADDER_STEP_FAILURE 162 -# define EC_R_MISSING_OID 167 -# define EC_R_MISSING_PARAMETERS 124 -# define EC_R_MISSING_PRIVATE_KEY 125 -# define EC_R_NEED_NEW_SETUP_VALUES 157 -# define EC_R_NOT_A_NIST_PRIME 135 -# define EC_R_NOT_IMPLEMENTED 126 -# define EC_R_NOT_INITIALIZED 111 -# define EC_R_NO_PARAMETERS_SET 139 -# define EC_R_NO_PRIVATE_VALUE 154 -# define EC_R_OPERATION_NOT_SUPPORTED 152 -# define EC_R_PASSED_NULL_PARAMETER 134 -# define EC_R_PEER_KEY_ERROR 149 -# define EC_R_PKPARAMETERS2GROUP_FAILURE 127 -# define EC_R_POINT_ARITHMETIC_FAILURE 155 -# define EC_R_POINT_AT_INFINITY 106 -# define EC_R_POINT_COORDINATES_BLIND_FAILURE 163 -# define EC_R_POINT_IS_NOT_ON_CURVE 107 -# define EC_R_RANDOM_NUMBER_GENERATION_FAILED 158 -# define EC_R_SHARED_INFO_ERROR 150 -# define EC_R_SLOT_FULL 108 -# define EC_R_UNDEFINED_GENERATOR 113 -# define EC_R_UNDEFINED_ORDER 128 -# define EC_R_UNKNOWN_COFACTOR 164 -# define EC_R_UNKNOWN_GROUP 129 -# define EC_R_UNKNOWN_ORDER 114 -# define EC_R_UNSUPPORTED_FIELD 131 -# define EC_R_WRONG_CURVE_PARAMETERS 145 -# define EC_R_WRONG_ORDER 130 - -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/engine.h b/client/3rd/OpenSSL/include/openssl/engine.h deleted file mode 100644 index 0780f0fb..00000000 --- a/client/3rd/OpenSSL/include/openssl/engine.h +++ /dev/null @@ -1,751 +0,0 @@ -/* - * Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ENGINE_H -# define HEADER_ENGINE_H - -# include - -# ifndef OPENSSL_NO_ENGINE -# if OPENSSL_API_COMPAT < 0x10100000L -# include -# include -# include -# include -# include -# include -# include -# include -# endif -# include -# include -# include -# include -# ifdef __cplusplus -extern "C" { -# endif - -/* - * These flags are used to control combinations of algorithm (methods) by - * bitwise "OR"ing. - */ -# define ENGINE_METHOD_RSA (unsigned int)0x0001 -# define ENGINE_METHOD_DSA (unsigned int)0x0002 -# define ENGINE_METHOD_DH (unsigned int)0x0004 -# define ENGINE_METHOD_RAND (unsigned int)0x0008 -# define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 -# define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 -# define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200 -# define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400 -# define ENGINE_METHOD_EC (unsigned int)0x0800 -/* Obvious all-or-nothing cases. */ -# define ENGINE_METHOD_ALL (unsigned int)0xFFFF -# define ENGINE_METHOD_NONE (unsigned int)0x0000 - -/* - * This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used - * internally to control registration of ENGINE implementations, and can be - * set by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to - * initialise registered ENGINEs if they are not already initialised. - */ -# define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001 - -/* ENGINE flags that can be set by ENGINE_set_flags(). */ -/* Not used */ -/* #define ENGINE_FLAGS_MALLOCED 0x0001 */ - -/* - * This flag is for ENGINEs that wish to handle the various 'CMD'-related - * control commands on their own. Without this flag, ENGINE_ctrl() handles - * these control commands on behalf of the ENGINE using their "cmd_defns" - * data. - */ -# define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002 - -/* - * This flag is for ENGINEs who return new duplicate structures when found - * via "ENGINE_by_id()". When an ENGINE must store state (eg. if - * ENGINE_ctrl() commands are called in sequence as part of some stateful - * process like key-generation setup and execution), it can set this flag - - * then each attempt to obtain the ENGINE will result in it being copied into - * a new structure. Normally, ENGINEs don't declare this flag so - * ENGINE_by_id() just increments the existing ENGINE's structural reference - * count. - */ -# define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 - -/* - * This flag if for an ENGINE that does not want its methods registered as - * part of ENGINE_register_all_complete() for example if the methods are not - * usable as default methods. - */ - -# define ENGINE_FLAGS_NO_REGISTER_ALL (int)0x0008 - -/* - * ENGINEs can support their own command types, and these flags are used in - * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input - * each command expects. Currently only numeric and string input is - * supported. If a control command supports none of the _NUMERIC, _STRING, or - * _NO_INPUT options, then it is regarded as an "internal" control command - - * and not for use in config setting situations. As such, they're not - * available to the ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() - * access. Changes to this list of 'command types' should be reflected - * carefully in ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string(). - */ - -/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */ -# define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 -/* - * accepts string input (cast from 'void*' to 'const char *', 4th parameter - * to ENGINE_ctrl) - */ -# define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 -/* - * Indicates that the control command takes *no* input. Ie. the control - * command is unparameterised. - */ -# define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 -/* - * Indicates that the control command is internal. This control command won't - * be shown in any output, and is only usable through the ENGINE_ctrl_cmd() - * function. - */ -# define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 - -/* - * NB: These 3 control commands are deprecated and should not be used. - * ENGINEs relying on these commands should compile conditional support for - * compatibility (eg. if these symbols are defined) but should also migrate - * the same functionality to their own ENGINE-specific control functions that - * can be "discovered" by calling applications. The fact these control - * commands wouldn't be "executable" (ie. usable by text-based config) - * doesn't change the fact that application code can find and use them - * without requiring per-ENGINE hacking. - */ - -/* - * These flags are used to tell the ctrl function what should be done. All - * command numbers are shared between all engines, even if some don't make - * sense to some engines. In such a case, they do nothing but return the - * error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. - */ -# define ENGINE_CTRL_SET_LOGSTREAM 1 -# define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2 -# define ENGINE_CTRL_HUP 3/* Close and reinitialise - * any handles/connections - * etc. */ -# define ENGINE_CTRL_SET_USER_INTERFACE 4/* Alternative to callback */ -# define ENGINE_CTRL_SET_CALLBACK_DATA 5/* User-specific data, used - * when calling the password - * callback and the user - * interface */ -# define ENGINE_CTRL_LOAD_CONFIGURATION 6/* Load a configuration, - * given a string that - * represents a file name - * or so */ -# define ENGINE_CTRL_LOAD_SECTION 7/* Load data from a given - * section in the already - * loaded configuration */ - -/* - * These control commands allow an application to deal with an arbitrary - * engine in a dynamic way. Warn: Negative return values indicate errors FOR - * THESE COMMANDS because zero is used to indicate 'end-of-list'. Other - * commands, including ENGINE-specific command types, return zero for an - * error. An ENGINE can choose to implement these ctrl functions, and can - * internally manage things however it chooses - it does so by setting the - * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise - * the ENGINE_ctrl() code handles this on the ENGINE's behalf using the - * cmd_defns data (set using ENGINE_set_cmd_defns()). This means an ENGINE's - * ctrl() handler need only implement its own commands - the above "meta" - * commands will be taken care of. - */ - -/* - * Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", - * then all the remaining control commands will return failure, so it is - * worth checking this first if the caller is trying to "discover" the - * engine's capabilities and doesn't want errors generated unnecessarily. - */ -# define ENGINE_CTRL_HAS_CTRL_FUNCTION 10 -/* - * Returns a positive command number for the first command supported by the - * engine. Returns zero if no ctrl commands are supported. - */ -# define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 -/* - * The 'long' argument specifies a command implemented by the engine, and the - * return value is the next command supported, or zero if there are no more. - */ -# define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 -/* - * The 'void*' argument is a command name (cast from 'const char *'), and the - * return value is the command that corresponds to it. - */ -# define ENGINE_CTRL_GET_CMD_FROM_NAME 13 -/* - * The next two allow a command to be converted into its corresponding string - * form. In each case, the 'long' argument supplies the command. In the - * NAME_LEN case, the return value is the length of the command name (not - * counting a trailing EOL). In the NAME case, the 'void*' argument must be a - * string buffer large enough, and it will be populated with the name of the - * command (WITH a trailing EOL). - */ -# define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 -# define ENGINE_CTRL_GET_NAME_FROM_CMD 15 -/* The next two are similar but give a "short description" of a command. */ -# define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 -# define ENGINE_CTRL_GET_DESC_FROM_CMD 17 -/* - * With this command, the return value is the OR'd combination of - * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given - * engine-specific ctrl command expects. - */ -# define ENGINE_CTRL_GET_CMD_FLAGS 18 - -/* - * ENGINE implementations should start the numbering of their own control - * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). - */ -# define ENGINE_CMD_BASE 200 - -/* - * NB: These 2 nCipher "chil" control commands are deprecated, and their - * functionality is now available through ENGINE-specific control commands - * (exposed through the above-mentioned 'CMD'-handling). Code using these 2 - * commands should be migrated to the more general command handling before - * these are removed. - */ - -/* Flags specific to the nCipher "chil" engine */ -# define ENGINE_CTRL_CHIL_SET_FORKCHECK 100 - /* - * Depending on the value of the (long)i argument, this sets or - * unsets the SimpleForkCheck flag in the CHIL API to enable or - * disable checking and workarounds for applications that fork(). - */ -# define ENGINE_CTRL_CHIL_NO_LOCKING 101 - /* - * This prevents the initialisation function from providing mutex - * callbacks to the nCipher library. - */ - -/* - * If an ENGINE supports its own specific control commands and wishes the - * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on - * its behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN - * entries to ENGINE_set_cmd_defns(). It should also implement a ctrl() - * handler that supports the stated commands (ie. the "cmd_num" entries as - * described by the array). NB: The array must be ordered in increasing order - * of cmd_num. "null-terminated" means that the last ENGINE_CMD_DEFN element - * has cmd_num set to zero and/or cmd_name set to NULL. - */ -typedef struct ENGINE_CMD_DEFN_st { - unsigned int cmd_num; /* The command number */ - const char *cmd_name; /* The command name itself */ - const char *cmd_desc; /* A short description of the command */ - unsigned int cmd_flags; /* The input the command expects */ -} ENGINE_CMD_DEFN; - -/* Generic function pointer */ -typedef int (*ENGINE_GEN_FUNC_PTR) (void); -/* Generic function pointer taking no arguments */ -typedef int (*ENGINE_GEN_INT_FUNC_PTR) (ENGINE *); -/* Specific control function pointer */ -typedef int (*ENGINE_CTRL_FUNC_PTR) (ENGINE *, int, long, void *, - void (*f) (void)); -/* Generic load_key function pointer */ -typedef EVP_PKEY *(*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, - UI_METHOD *ui_method, - void *callback_data); -typedef int (*ENGINE_SSL_CLIENT_CERT_PTR) (ENGINE *, SSL *ssl, - STACK_OF(X509_NAME) *ca_dn, - X509 **pcert, EVP_PKEY **pkey, - STACK_OF(X509) **pother, - UI_METHOD *ui_method, - void *callback_data); -/*- - * These callback types are for an ENGINE's handler for cipher and digest logic. - * These handlers have these prototypes; - * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); - * int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid); - * Looking at how to implement these handlers in the case of cipher support, if - * the framework wants the EVP_CIPHER for 'nid', it will call; - * foo(e, &p_evp_cipher, NULL, nid); (return zero for failure) - * If the framework wants a list of supported 'nid's, it will call; - * foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error) - */ -/* - * Returns to a pointer to the array of supported cipher 'nid's. If the - * second parameter is non-NULL it is set to the size of the returned array. - */ -typedef int (*ENGINE_CIPHERS_PTR) (ENGINE *, const EVP_CIPHER **, - const int **, int); -typedef int (*ENGINE_DIGESTS_PTR) (ENGINE *, const EVP_MD **, const int **, - int); -typedef int (*ENGINE_PKEY_METHS_PTR) (ENGINE *, EVP_PKEY_METHOD **, - const int **, int); -typedef int (*ENGINE_PKEY_ASN1_METHS_PTR) (ENGINE *, EVP_PKEY_ASN1_METHOD **, - const int **, int); -/* - * STRUCTURE functions ... all of these functions deal with pointers to - * ENGINE structures where the pointers have a "structural reference". This - * means that their reference is to allowed access to the structure but it - * does not imply that the structure is functional. To simply increment or - * decrement the structural reference count, use ENGINE_by_id and - * ENGINE_free. NB: This is not required when iterating using ENGINE_get_next - * as it will automatically decrement the structural reference count of the - * "current" ENGINE and increment the structural reference count of the - * ENGINE it returns (unless it is NULL). - */ - -/* Get the first/last "ENGINE" type available. */ -ENGINE *ENGINE_get_first(void); -ENGINE *ENGINE_get_last(void); -/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ -ENGINE *ENGINE_get_next(ENGINE *e); -ENGINE *ENGINE_get_prev(ENGINE *e); -/* Add another "ENGINE" type into the array. */ -int ENGINE_add(ENGINE *e); -/* Remove an existing "ENGINE" type from the array. */ -int ENGINE_remove(ENGINE *e); -/* Retrieve an engine from the list by its unique "id" value. */ -ENGINE *ENGINE_by_id(const char *id); - -#if OPENSSL_API_COMPAT < 0x10100000L -# define ENGINE_load_openssl() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_OPENSSL, NULL) -# define ENGINE_load_dynamic() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DYNAMIC, NULL) -# ifndef OPENSSL_NO_STATIC_ENGINE -# define ENGINE_load_padlock() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_PADLOCK, NULL) -# define ENGINE_load_capi() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CAPI, NULL) -# define ENGINE_load_afalg() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL) -# endif -# define ENGINE_load_cryptodev() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CRYPTODEV, NULL) -# define ENGINE_load_rdrand() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_RDRAND, NULL) -#endif -void ENGINE_load_builtin_engines(void); - -/* - * Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation - * "registry" handling. - */ -unsigned int ENGINE_get_table_flags(void); -void ENGINE_set_table_flags(unsigned int flags); - -/*- Manage registration of ENGINEs per "table". For each type, there are 3 - * functions; - * ENGINE_register_***(e) - registers the implementation from 'e' (if it has one) - * ENGINE_unregister_***(e) - unregister the implementation from 'e' - * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list - * Cleanup is automatically registered from each table when required. - */ - -int ENGINE_register_RSA(ENGINE *e); -void ENGINE_unregister_RSA(ENGINE *e); -void ENGINE_register_all_RSA(void); - -int ENGINE_register_DSA(ENGINE *e); -void ENGINE_unregister_DSA(ENGINE *e); -void ENGINE_register_all_DSA(void); - -int ENGINE_register_EC(ENGINE *e); -void ENGINE_unregister_EC(ENGINE *e); -void ENGINE_register_all_EC(void); - -int ENGINE_register_DH(ENGINE *e); -void ENGINE_unregister_DH(ENGINE *e); -void ENGINE_register_all_DH(void); - -int ENGINE_register_RAND(ENGINE *e); -void ENGINE_unregister_RAND(ENGINE *e); -void ENGINE_register_all_RAND(void); - -int ENGINE_register_ciphers(ENGINE *e); -void ENGINE_unregister_ciphers(ENGINE *e); -void ENGINE_register_all_ciphers(void); - -int ENGINE_register_digests(ENGINE *e); -void ENGINE_unregister_digests(ENGINE *e); -void ENGINE_register_all_digests(void); - -int ENGINE_register_pkey_meths(ENGINE *e); -void ENGINE_unregister_pkey_meths(ENGINE *e); -void ENGINE_register_all_pkey_meths(void); - -int ENGINE_register_pkey_asn1_meths(ENGINE *e); -void ENGINE_unregister_pkey_asn1_meths(ENGINE *e); -void ENGINE_register_all_pkey_asn1_meths(void); - -/* - * These functions register all support from the above categories. Note, use - * of these functions can result in static linkage of code your application - * may not need. If you only need a subset of functionality, consider using - * more selective initialisation. - */ -int ENGINE_register_complete(ENGINE *e); -int ENGINE_register_all_complete(void); - -/* - * Send parameterised control commands to the engine. The possibilities to - * send down an integer, a pointer to data or a function pointer are - * provided. Any of the parameters may or may not be NULL, depending on the - * command number. In actuality, this function only requires a structural - * (rather than functional) reference to an engine, but many control commands - * may require the engine be functional. The caller should be aware of trying - * commands that require an operational ENGINE, and only use functional - * references in such situations. - */ -int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)); - -/* - * This function tests if an ENGINE-specific command is usable as a - * "setting". Eg. in an application's config file that gets processed through - * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to - * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). - */ -int ENGINE_cmd_is_executable(ENGINE *e, int cmd); - -/* - * This function works like ENGINE_ctrl() with the exception of taking a - * command name instead of a command number, and can handle optional - * commands. See the comment on ENGINE_ctrl_cmd_string() for an explanation - * on how to use the cmd_name and cmd_optional. - */ -int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, - long i, void *p, void (*f) (void), int cmd_optional); - -/* - * This function passes a command-name and argument to an ENGINE. The - * cmd_name is converted to a command number and the control command is - * called using 'arg' as an argument (unless the ENGINE doesn't support such - * a command, in which case no control command is called). The command is - * checked for input flags, and if necessary the argument will be converted - * to a numeric value. If cmd_optional is non-zero, then if the ENGINE - * doesn't support the given cmd_name the return value will be success - * anyway. This function is intended for applications to use so that users - * (or config files) can supply engine-specific config data to the ENGINE at - * run-time to control behaviour of specific engines. As such, it shouldn't - * be used for calling ENGINE_ctrl() functions that return data, deal with - * binary data, or that are otherwise supposed to be used directly through - * ENGINE_ctrl() in application code. Any "return" data from an ENGINE_ctrl() - * operation in this function will be lost - the return value is interpreted - * as failure if the return value is zero, success otherwise, and this - * function returns a boolean value as a result. In other words, vendors of - * 'ENGINE'-enabled devices should write ENGINE implementations with - * parameterisations that work in this scheme, so that compliant ENGINE-based - * applications can work consistently with the same configuration for the - * same ENGINE-enabled devices, across applications. - */ -int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, - int cmd_optional); - -/* - * These functions are useful for manufacturing new ENGINE structures. They - * don't address reference counting at all - one uses them to populate an - * ENGINE structure with personalised implementations of things prior to - * using it directly or adding it to the builtin ENGINE list in OpenSSL. - * These are also here so that the ENGINE structure doesn't have to be - * exposed and break binary compatibility! - */ -ENGINE *ENGINE_new(void); -int ENGINE_free(ENGINE *e); -int ENGINE_up_ref(ENGINE *e); -int ENGINE_set_id(ENGINE *e, const char *id); -int ENGINE_set_name(ENGINE *e, const char *name); -int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); -int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); -int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth); -int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); -int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); -int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); -int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); -int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); -int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); -int ENGINE_set_load_privkey_function(ENGINE *e, - ENGINE_LOAD_KEY_PTR loadpriv_f); -int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); -int ENGINE_set_load_ssl_client_cert_function(ENGINE *e, - ENGINE_SSL_CLIENT_CERT_PTR - loadssl_f); -int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); -int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); -int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f); -int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f); -int ENGINE_set_flags(ENGINE *e, int flags); -int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); -/* These functions allow control over any per-structure ENGINE data. */ -#define ENGINE_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, l, p, newf, dupf, freef) -int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); -void *ENGINE_get_ex_data(const ENGINE *e, int idx); - -#if OPENSSL_API_COMPAT < 0x10100000L -/* - * This function previously cleaned up anything that needs it. Auto-deinit will - * now take care of it so it is no longer required to call this function. - */ -# define ENGINE_cleanup() while(0) continue -#endif - -/* - * These return values from within the ENGINE structure. These can be useful - * with functional references as well as structural references - it depends - * which you obtained. Using the result for functional purposes if you only - * obtained a structural reference may be problematic! - */ -const char *ENGINE_get_id(const ENGINE *e); -const char *ENGINE_get_name(const ENGINE *e); -const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); -const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); -const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e); -const DH_METHOD *ENGINE_get_DH(const ENGINE *e); -const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); -ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); -ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); -ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); -ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e); -ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e); -ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e); -ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE - *e); -ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e); -ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e); -ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e); -ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e); -const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); -const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); -const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid); -const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid); -const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, - const char *str, - int len); -const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe, - const char *str, - int len); -const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); -int ENGINE_get_flags(const ENGINE *e); - -/* - * FUNCTIONAL functions. These functions deal with ENGINE structures that - * have (or will) be initialised for use. Broadly speaking, the structural - * functions are useful for iterating the list of available engine types, - * creating new engine types, and other "list" operations. These functions - * actually deal with ENGINEs that are to be used. As such these functions - * can fail (if applicable) when particular engines are unavailable - eg. if - * a hardware accelerator is not attached or not functioning correctly. Each - * ENGINE has 2 reference counts; structural and functional. Every time a - * functional reference is obtained or released, a corresponding structural - * reference is automatically obtained or released too. - */ - -/* - * Initialise a engine type for use (or up its reference count if it's - * already in use). This will fail if the engine is not currently operational - * and cannot initialise. - */ -int ENGINE_init(ENGINE *e); -/* - * Free a functional reference to a engine type. This does not require a - * corresponding call to ENGINE_free as it also releases a structural - * reference. - */ -int ENGINE_finish(ENGINE *e); - -/* - * The following functions handle keys that are stored in some secondary - * location, handled by the engine. The storage may be on a card or - * whatever. - */ -EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, void *callback_data); -EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, void *callback_data); -int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, - STACK_OF(X509_NAME) *ca_dn, X509 **pcert, - EVP_PKEY **ppkey, STACK_OF(X509) **pother, - UI_METHOD *ui_method, void *callback_data); - -/* - * This returns a pointer for the current ENGINE structure that is (by - * default) performing any RSA operations. The value returned is an - * incremented reference, so it should be free'd (ENGINE_finish) before it is - * discarded. - */ -ENGINE *ENGINE_get_default_RSA(void); -/* Same for the other "methods" */ -ENGINE *ENGINE_get_default_DSA(void); -ENGINE *ENGINE_get_default_EC(void); -ENGINE *ENGINE_get_default_DH(void); -ENGINE *ENGINE_get_default_RAND(void); -/* - * These functions can be used to get a functional reference to perform - * ciphering or digesting corresponding to "nid". - */ -ENGINE *ENGINE_get_cipher_engine(int nid); -ENGINE *ENGINE_get_digest_engine(int nid); -ENGINE *ENGINE_get_pkey_meth_engine(int nid); -ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid); - -/* - * This sets a new default ENGINE structure for performing RSA operations. If - * the result is non-zero (success) then the ENGINE structure will have had - * its reference count up'd so the caller should still free their own - * reference 'e'. - */ -int ENGINE_set_default_RSA(ENGINE *e); -int ENGINE_set_default_string(ENGINE *e, const char *def_list); -/* Same for the other "methods" */ -int ENGINE_set_default_DSA(ENGINE *e); -int ENGINE_set_default_EC(ENGINE *e); -int ENGINE_set_default_DH(ENGINE *e); -int ENGINE_set_default_RAND(ENGINE *e); -int ENGINE_set_default_ciphers(ENGINE *e); -int ENGINE_set_default_digests(ENGINE *e); -int ENGINE_set_default_pkey_meths(ENGINE *e); -int ENGINE_set_default_pkey_asn1_meths(ENGINE *e); - -/* - * The combination "set" - the flags are bitwise "OR"d from the - * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()" - * function, this function can result in unnecessary static linkage. If your - * application requires only specific functionality, consider using more - * selective functions. - */ -int ENGINE_set_default(ENGINE *e, unsigned int flags); - -void ENGINE_add_conf_module(void); - -/* Deprecated functions ... */ -/* int ENGINE_clear_defaults(void); */ - -/**************************/ -/* DYNAMIC ENGINE SUPPORT */ -/**************************/ - -/* Binary/behaviour compatibility levels */ -# define OSSL_DYNAMIC_VERSION (unsigned long)0x00030000 -/* - * Binary versions older than this are too old for us (whether we're a loader - * or a loadee) - */ -# define OSSL_DYNAMIC_OLDEST (unsigned long)0x00030000 - -/* - * When compiling an ENGINE entirely as an external shared library, loadable - * by the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' - * structure type provides the calling application's (or library's) error - * functionality and memory management function pointers to the loaded - * library. These should be used/set in the loaded library code so that the - * loading application's 'state' will be used/changed in all operations. The - * 'static_state' pointer allows the loaded library to know if it shares the - * same static data as the calling application (or library), and thus whether - * these callbacks need to be set or not. - */ -typedef void *(*dyn_MEM_malloc_fn) (size_t, const char *, int); -typedef void *(*dyn_MEM_realloc_fn) (void *, size_t, const char *, int); -typedef void (*dyn_MEM_free_fn) (void *, const char *, int); -typedef struct st_dynamic_MEM_fns { - dyn_MEM_malloc_fn malloc_fn; - dyn_MEM_realloc_fn realloc_fn; - dyn_MEM_free_fn free_fn; -} dynamic_MEM_fns; -/* - * FIXME: Perhaps the memory and locking code (crypto.h) should declare and - * use these types so we (and any other dependent code) can simplify a bit?? - */ -/* The top-level structure */ -typedef struct st_dynamic_fns { - void *static_state; - dynamic_MEM_fns mem_fns; -} dynamic_fns; - -/* - * The version checking function should be of this prototype. NB: The - * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading - * code. If this function returns zero, it indicates a (potential) version - * incompatibility and the loaded library doesn't believe it can proceed. - * Otherwise, the returned value is the (latest) version supported by the - * loading library. The loader may still decide that the loaded code's - * version is unsatisfactory and could veto the load. The function is - * expected to be implemented with the symbol name "v_check", and a default - * implementation can be fully instantiated with - * IMPLEMENT_DYNAMIC_CHECK_FN(). - */ -typedef unsigned long (*dynamic_v_check_fn) (unsigned long ossl_version); -# define IMPLEMENT_DYNAMIC_CHECK_FN() \ - OPENSSL_EXPORT unsigned long v_check(unsigned long v); \ - OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \ - if (v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \ - return 0; } - -/* - * This function is passed the ENGINE structure to initialise with its own - * function and command settings. It should not adjust the structural or - * functional reference counts. If this function returns zero, (a) the load - * will be aborted, (b) the previous ENGINE state will be memcpy'd back onto - * the structure, and (c) the shared library will be unloaded. So - * implementations should do their own internal cleanup in failure - * circumstances otherwise they could leak. The 'id' parameter, if non-NULL, - * represents the ENGINE id that the loader is looking for. If this is NULL, - * the shared library can choose to return failure or to initialise a - * 'default' ENGINE. If non-NULL, the shared library must initialise only an - * ENGINE matching the passed 'id'. The function is expected to be - * implemented with the symbol name "bind_engine". A standard implementation - * can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where the parameter - * 'fn' is a callback function that populates the ENGINE structure and - * returns an int value (zero for failure). 'fn' should have prototype; - * [static] int fn(ENGINE *e, const char *id); - */ -typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id, - const dynamic_fns *fns); -# define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ - OPENSSL_EXPORT \ - int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \ - OPENSSL_EXPORT \ - int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \ - if (ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \ - CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \ - fns->mem_fns.realloc_fn, \ - fns->mem_fns.free_fn); \ - skip_cbs: \ - if (!fn(e, id)) return 0; \ - return 1; } - -/* - * If the loading application (or library) and the loaded ENGINE library - * share the same static data (eg. they're both dynamically linked to the - * same libcrypto.so) we need a way to avoid trying to set system callbacks - - * this would fail, and for the same reason that it's unnecessary to try. If - * the loaded ENGINE has (or gets from through the loader) its own copy of - * the libcrypto static data, we will need to set the callbacks. The easiest - * way to detect this is to have a function that returns a pointer to some - * static data and let the loading application and loaded ENGINE compare - * their respective values. - */ -void *ENGINE_get_static_state(void); - -# if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) -DEPRECATEDIN_1_1_0(void ENGINE_setup_bsd_cryptodev(void)) -# endif - - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/engineerr.h b/client/3rd/OpenSSL/include/openssl/engineerr.h deleted file mode 100644 index 05e84bd2..00000000 --- a/client/3rd/OpenSSL/include/openssl/engineerr.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ENGINEERR_H -# define HEADER_ENGINEERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# include - -# ifndef OPENSSL_NO_ENGINE - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_ENGINE_strings(void); - -/* - * ENGINE function codes. - */ -# define ENGINE_F_DIGEST_UPDATE 198 -# define ENGINE_F_DYNAMIC_CTRL 180 -# define ENGINE_F_DYNAMIC_GET_DATA_CTX 181 -# define ENGINE_F_DYNAMIC_LOAD 182 -# define ENGINE_F_DYNAMIC_SET_DATA_CTX 183 -# define ENGINE_F_ENGINE_ADD 105 -# define ENGINE_F_ENGINE_BY_ID 106 -# define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170 -# define ENGINE_F_ENGINE_CTRL 142 -# define ENGINE_F_ENGINE_CTRL_CMD 178 -# define ENGINE_F_ENGINE_CTRL_CMD_STRING 171 -# define ENGINE_F_ENGINE_FINISH 107 -# define ENGINE_F_ENGINE_GET_CIPHER 185 -# define ENGINE_F_ENGINE_GET_DIGEST 186 -# define ENGINE_F_ENGINE_GET_FIRST 195 -# define ENGINE_F_ENGINE_GET_LAST 196 -# define ENGINE_F_ENGINE_GET_NEXT 115 -# define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH 193 -# define ENGINE_F_ENGINE_GET_PKEY_METH 192 -# define ENGINE_F_ENGINE_GET_PREV 116 -# define ENGINE_F_ENGINE_INIT 119 -# define ENGINE_F_ENGINE_LIST_ADD 120 -# define ENGINE_F_ENGINE_LIST_REMOVE 121 -# define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150 -# define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151 -# define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT 194 -# define ENGINE_F_ENGINE_NEW 122 -# define ENGINE_F_ENGINE_PKEY_ASN1_FIND_STR 197 -# define ENGINE_F_ENGINE_REMOVE 123 -# define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189 -# define ENGINE_F_ENGINE_SET_ID 129 -# define ENGINE_F_ENGINE_SET_NAME 130 -# define ENGINE_F_ENGINE_TABLE_REGISTER 184 -# define ENGINE_F_ENGINE_UNLOCKED_FINISH 191 -# define ENGINE_F_ENGINE_UP_REF 190 -# define ENGINE_F_INT_CLEANUP_ITEM 199 -# define ENGINE_F_INT_CTRL_HELPER 172 -# define ENGINE_F_INT_ENGINE_CONFIGURE 188 -# define ENGINE_F_INT_ENGINE_MODULE_INIT 187 -# define ENGINE_F_OSSL_HMAC_INIT 200 - -/* - * ENGINE reason codes. - */ -# define ENGINE_R_ALREADY_LOADED 100 -# define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133 -# define ENGINE_R_CMD_NOT_EXECUTABLE 134 -# define ENGINE_R_COMMAND_TAKES_INPUT 135 -# define ENGINE_R_COMMAND_TAKES_NO_INPUT 136 -# define ENGINE_R_CONFLICTING_ENGINE_ID 103 -# define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119 -# define ENGINE_R_DSO_FAILURE 104 -# define ENGINE_R_DSO_NOT_FOUND 132 -# define ENGINE_R_ENGINES_SECTION_ERROR 148 -# define ENGINE_R_ENGINE_CONFIGURATION_ERROR 102 -# define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 -# define ENGINE_R_ENGINE_SECTION_ERROR 149 -# define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 -# define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129 -# define ENGINE_R_FINISH_FAILED 106 -# define ENGINE_R_ID_OR_NAME_MISSING 108 -# define ENGINE_R_INIT_FAILED 109 -# define ENGINE_R_INTERNAL_LIST_ERROR 110 -# define ENGINE_R_INVALID_ARGUMENT 143 -# define ENGINE_R_INVALID_CMD_NAME 137 -# define ENGINE_R_INVALID_CMD_NUMBER 138 -# define ENGINE_R_INVALID_INIT_VALUE 151 -# define ENGINE_R_INVALID_STRING 150 -# define ENGINE_R_NOT_INITIALISED 117 -# define ENGINE_R_NOT_LOADED 112 -# define ENGINE_R_NO_CONTROL_FUNCTION 120 -# define ENGINE_R_NO_INDEX 144 -# define ENGINE_R_NO_LOAD_FUNCTION 125 -# define ENGINE_R_NO_REFERENCE 130 -# define ENGINE_R_NO_SUCH_ENGINE 116 -# define ENGINE_R_UNIMPLEMENTED_CIPHER 146 -# define ENGINE_R_UNIMPLEMENTED_DIGEST 147 -# define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD 101 -# define ENGINE_R_VERSION_INCOMPATIBILITY 145 - -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/err.h b/client/3rd/OpenSSL/include/openssl/err.h deleted file mode 100644 index b49f8812..00000000 --- a/client/3rd/OpenSSL/include/openssl/err.h +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ERR_H -# define HEADER_ERR_H - -# include - -# ifndef OPENSSL_NO_STDIO -# include -# include -# endif - -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -# ifndef OPENSSL_NO_ERR -# define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e) -# else -# define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0) -# endif - -# include - -# define ERR_TXT_MALLOCED 0x01 -# define ERR_TXT_STRING 0x02 - -# define ERR_FLAG_MARK 0x01 -# define ERR_FLAG_CLEAR 0x02 - -# define ERR_NUM_ERRORS 16 -typedef struct err_state_st { - int err_flags[ERR_NUM_ERRORS]; - unsigned long err_buffer[ERR_NUM_ERRORS]; - char *err_data[ERR_NUM_ERRORS]; - int err_data_flags[ERR_NUM_ERRORS]; - const char *err_file[ERR_NUM_ERRORS]; - int err_line[ERR_NUM_ERRORS]; - int top, bottom; -} ERR_STATE; - -/* library */ -# define ERR_LIB_NONE 1 -# define ERR_LIB_SYS 2 -# define ERR_LIB_BN 3 -# define ERR_LIB_RSA 4 -# define ERR_LIB_DH 5 -# define ERR_LIB_EVP 6 -# define ERR_LIB_BUF 7 -# define ERR_LIB_OBJ 8 -# define ERR_LIB_PEM 9 -# define ERR_LIB_DSA 10 -# define ERR_LIB_X509 11 -/* #define ERR_LIB_METH 12 */ -# define ERR_LIB_ASN1 13 -# define ERR_LIB_CONF 14 -# define ERR_LIB_CRYPTO 15 -# define ERR_LIB_EC 16 -# define ERR_LIB_SSL 20 -/* #define ERR_LIB_SSL23 21 */ -/* #define ERR_LIB_SSL2 22 */ -/* #define ERR_LIB_SSL3 23 */ -/* #define ERR_LIB_RSAREF 30 */ -/* #define ERR_LIB_PROXY 31 */ -# define ERR_LIB_BIO 32 -# define ERR_LIB_PKCS7 33 -# define ERR_LIB_X509V3 34 -# define ERR_LIB_PKCS12 35 -# define ERR_LIB_RAND 36 -# define ERR_LIB_DSO 37 -# define ERR_LIB_ENGINE 38 -# define ERR_LIB_OCSP 39 -# define ERR_LIB_UI 40 -# define ERR_LIB_COMP 41 -# define ERR_LIB_ECDSA 42 -# define ERR_LIB_ECDH 43 -# define ERR_LIB_OSSL_STORE 44 -# define ERR_LIB_FIPS 45 -# define ERR_LIB_CMS 46 -# define ERR_LIB_TS 47 -# define ERR_LIB_HMAC 48 -/* # define ERR_LIB_JPAKE 49 */ -# define ERR_LIB_CT 50 -# define ERR_LIB_ASYNC 51 -# define ERR_LIB_KDF 52 -# define ERR_LIB_SM2 53 - -# define ERR_LIB_USER 128 - -# define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define OSSL_STOREerr(f,r) ERR_PUT_error(ERR_LIB_OSSL_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define CTerr(f,r) ERR_PUT_error(ERR_LIB_CT,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ASYNCerr(f,r) ERR_PUT_error(ERR_LIB_ASYNC,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define KDFerr(f,r) ERR_PUT_error(ERR_LIB_KDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define SM2err(f,r) ERR_PUT_error(ERR_LIB_SM2,(f),(r),OPENSSL_FILE,OPENSSL_LINE) - -# define ERR_PACK(l,f,r) ( \ - (((unsigned int)(l) & 0x0FF) << 24L) | \ - (((unsigned int)(f) & 0xFFF) << 12L) | \ - (((unsigned int)(r) & 0xFFF) ) ) -# define ERR_GET_LIB(l) (int)(((l) >> 24L) & 0x0FFL) -# define ERR_GET_FUNC(l) (int)(((l) >> 12L) & 0xFFFL) -# define ERR_GET_REASON(l) (int)( (l) & 0xFFFL) -# define ERR_FATAL_ERROR(l) (int)( (l) & ERR_R_FATAL) - -/* OS functions */ -# define SYS_F_FOPEN 1 -# define SYS_F_CONNECT 2 -# define SYS_F_GETSERVBYNAME 3 -# define SYS_F_SOCKET 4 -# define SYS_F_IOCTLSOCKET 5 -# define SYS_F_BIND 6 -# define SYS_F_LISTEN 7 -# define SYS_F_ACCEPT 8 -# define SYS_F_WSASTARTUP 9/* Winsock stuff */ -# define SYS_F_OPENDIR 10 -# define SYS_F_FREAD 11 -# define SYS_F_GETADDRINFO 12 -# define SYS_F_GETNAMEINFO 13 -# define SYS_F_SETSOCKOPT 14 -# define SYS_F_GETSOCKOPT 15 -# define SYS_F_GETSOCKNAME 16 -# define SYS_F_GETHOSTBYNAME 17 -# define SYS_F_FFLUSH 18 -# define SYS_F_OPEN 19 -# define SYS_F_CLOSE 20 -# define SYS_F_IOCTL 21 -# define SYS_F_STAT 22 -# define SYS_F_FCNTL 23 -# define SYS_F_FSTAT 24 - -/* reasons */ -# define ERR_R_SYS_LIB ERR_LIB_SYS/* 2 */ -# define ERR_R_BN_LIB ERR_LIB_BN/* 3 */ -# define ERR_R_RSA_LIB ERR_LIB_RSA/* 4 */ -# define ERR_R_DH_LIB ERR_LIB_DH/* 5 */ -# define ERR_R_EVP_LIB ERR_LIB_EVP/* 6 */ -# define ERR_R_BUF_LIB ERR_LIB_BUF/* 7 */ -# define ERR_R_OBJ_LIB ERR_LIB_OBJ/* 8 */ -# define ERR_R_PEM_LIB ERR_LIB_PEM/* 9 */ -# define ERR_R_DSA_LIB ERR_LIB_DSA/* 10 */ -# define ERR_R_X509_LIB ERR_LIB_X509/* 11 */ -# define ERR_R_ASN1_LIB ERR_LIB_ASN1/* 13 */ -# define ERR_R_EC_LIB ERR_LIB_EC/* 16 */ -# define ERR_R_BIO_LIB ERR_LIB_BIO/* 32 */ -# define ERR_R_PKCS7_LIB ERR_LIB_PKCS7/* 33 */ -# define ERR_R_X509V3_LIB ERR_LIB_X509V3/* 34 */ -# define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */ -# define ERR_R_UI_LIB ERR_LIB_UI/* 40 */ -# define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */ -# define ERR_R_OSSL_STORE_LIB ERR_LIB_OSSL_STORE/* 44 */ - -# define ERR_R_NESTED_ASN1_ERROR 58 -# define ERR_R_MISSING_ASN1_EOS 63 - -/* fatal error */ -# define ERR_R_FATAL 64 -# define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) -# define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL) -# define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL) -# define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL) -# define ERR_R_DISABLED (5|ERR_R_FATAL) -# define ERR_R_INIT_FAIL (6|ERR_R_FATAL) -# define ERR_R_PASSED_INVALID_ARGUMENT (7) -# define ERR_R_OPERATION_FAIL (8|ERR_R_FATAL) - -/* - * 99 is the maximum possible ERR_R_... code, higher values are reserved for - * the individual libraries - */ - -typedef struct ERR_string_data_st { - unsigned long error; - const char *string; -} ERR_STRING_DATA; - -DEFINE_LHASH_OF(ERR_STRING_DATA); - -void ERR_put_error(int lib, int func, int reason, const char *file, int line); -void ERR_set_error_data(char *data, int flags); - -unsigned long ERR_get_error(void); -unsigned long ERR_get_error_line(const char **file, int *line); -unsigned long ERR_get_error_line_data(const char **file, int *line, - const char **data, int *flags); -unsigned long ERR_peek_error(void); -unsigned long ERR_peek_error_line(const char **file, int *line); -unsigned long ERR_peek_error_line_data(const char **file, int *line, - const char **data, int *flags); -unsigned long ERR_peek_last_error(void); -unsigned long ERR_peek_last_error_line(const char **file, int *line); -unsigned long ERR_peek_last_error_line_data(const char **file, int *line, - const char **data, int *flags); -void ERR_clear_error(void); -char *ERR_error_string(unsigned long e, char *buf); -void ERR_error_string_n(unsigned long e, char *buf, size_t len); -const char *ERR_lib_error_string(unsigned long e); -const char *ERR_func_error_string(unsigned long e); -const char *ERR_reason_error_string(unsigned long e); -void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u), - void *u); -# ifndef OPENSSL_NO_STDIO -void ERR_print_errors_fp(FILE *fp); -# endif -void ERR_print_errors(BIO *bp); -void ERR_add_error_data(int num, ...); -void ERR_add_error_vdata(int num, va_list args); -int ERR_load_strings(int lib, ERR_STRING_DATA *str); -int ERR_load_strings_const(const ERR_STRING_DATA *str); -int ERR_unload_strings(int lib, ERR_STRING_DATA *str); -int ERR_load_ERR_strings(void); - -#if OPENSSL_API_COMPAT < 0x10100000L -# define ERR_load_crypto_strings() \ - OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) -# define ERR_free_strings() while(0) continue -#endif - -DEPRECATEDIN_1_1_0(void ERR_remove_thread_state(void *)) -DEPRECATEDIN_1_0_0(void ERR_remove_state(unsigned long pid)) -ERR_STATE *ERR_get_state(void); - -int ERR_get_next_error_library(void); - -int ERR_set_mark(void); -int ERR_pop_to_mark(void); -int ERR_clear_last_mark(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/evp.h b/client/3rd/OpenSSL/include/openssl/evp.h deleted file mode 100644 index a411f3f2..00000000 --- a/client/3rd/OpenSSL/include/openssl/evp.h +++ /dev/null @@ -1,1666 +0,0 @@ -/* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ENVELOPE_H -# define HEADER_ENVELOPE_H - -# include -# include -# include -# include -# include - -# define EVP_MAX_MD_SIZE 64/* longest known is SHA512 */ -# define EVP_MAX_KEY_LENGTH 64 -# define EVP_MAX_IV_LENGTH 16 -# define EVP_MAX_BLOCK_LENGTH 32 - -# define PKCS5_SALT_LEN 8 -/* Default PKCS#5 iteration count */ -# define PKCS5_DEFAULT_ITER 2048 - -# include - -# define EVP_PK_RSA 0x0001 -# define EVP_PK_DSA 0x0002 -# define EVP_PK_DH 0x0004 -# define EVP_PK_EC 0x0008 -# define EVP_PKT_SIGN 0x0010 -# define EVP_PKT_ENC 0x0020 -# define EVP_PKT_EXCH 0x0040 -# define EVP_PKS_RSA 0x0100 -# define EVP_PKS_DSA 0x0200 -# define EVP_PKS_EC 0x0400 - -# define EVP_PKEY_NONE NID_undef -# define EVP_PKEY_RSA NID_rsaEncryption -# define EVP_PKEY_RSA2 NID_rsa -# define EVP_PKEY_RSA_PSS NID_rsassaPss -# define EVP_PKEY_DSA NID_dsa -# define EVP_PKEY_DSA1 NID_dsa_2 -# define EVP_PKEY_DSA2 NID_dsaWithSHA -# define EVP_PKEY_DSA3 NID_dsaWithSHA1 -# define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 -# define EVP_PKEY_DH NID_dhKeyAgreement -# define EVP_PKEY_DHX NID_dhpublicnumber -# define EVP_PKEY_EC NID_X9_62_id_ecPublicKey -# define EVP_PKEY_SM2 NID_sm2 -# define EVP_PKEY_HMAC NID_hmac -# define EVP_PKEY_CMAC NID_cmac -# define EVP_PKEY_SCRYPT NID_id_scrypt -# define EVP_PKEY_TLS1_PRF NID_tls1_prf -# define EVP_PKEY_HKDF NID_hkdf -# define EVP_PKEY_POLY1305 NID_poly1305 -# define EVP_PKEY_SIPHASH NID_siphash -# define EVP_PKEY_X25519 NID_X25519 -# define EVP_PKEY_ED25519 NID_ED25519 -# define EVP_PKEY_X448 NID_X448 -# define EVP_PKEY_ED448 NID_ED448 - -#ifdef __cplusplus -extern "C" { -#endif - -# define EVP_PKEY_MO_SIGN 0x0001 -# define EVP_PKEY_MO_VERIFY 0x0002 -# define EVP_PKEY_MO_ENCRYPT 0x0004 -# define EVP_PKEY_MO_DECRYPT 0x0008 - -# ifndef EVP_MD -EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type); -EVP_MD *EVP_MD_meth_dup(const EVP_MD *md); -void EVP_MD_meth_free(EVP_MD *md); - -int EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize); -int EVP_MD_meth_set_result_size(EVP_MD *md, int resultsize); -int EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize); -int EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags); -int EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx)); -int EVP_MD_meth_set_update(EVP_MD *md, int (*update)(EVP_MD_CTX *ctx, - const void *data, - size_t count)); -int EVP_MD_meth_set_final(EVP_MD *md, int (*final)(EVP_MD_CTX *ctx, - unsigned char *md)); -int EVP_MD_meth_set_copy(EVP_MD *md, int (*copy)(EVP_MD_CTX *to, - const EVP_MD_CTX *from)); -int EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx)); -int EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd, - int p1, void *p2)); - -int EVP_MD_meth_get_input_blocksize(const EVP_MD *md); -int EVP_MD_meth_get_result_size(const EVP_MD *md); -int EVP_MD_meth_get_app_datasize(const EVP_MD *md); -unsigned long EVP_MD_meth_get_flags(const EVP_MD *md); -int (*EVP_MD_meth_get_init(const EVP_MD *md))(EVP_MD_CTX *ctx); -int (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx, - const void *data, - size_t count); -int (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx, - unsigned char *md); -int (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to, - const EVP_MD_CTX *from); -int (*EVP_MD_meth_get_cleanup(const EVP_MD *md))(EVP_MD_CTX *ctx); -int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd, - int p1, void *p2); - -/* digest can only handle a single block */ -# define EVP_MD_FLAG_ONESHOT 0x0001 - -/* digest is extensible-output function, XOF */ -# define EVP_MD_FLAG_XOF 0x0002 - -/* DigestAlgorithmIdentifier flags... */ - -# define EVP_MD_FLAG_DIGALGID_MASK 0x0018 - -/* NULL or absent parameter accepted. Use NULL */ - -# define EVP_MD_FLAG_DIGALGID_NULL 0x0000 - -/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */ - -# define EVP_MD_FLAG_DIGALGID_ABSENT 0x0008 - -/* Custom handling via ctrl */ - -# define EVP_MD_FLAG_DIGALGID_CUSTOM 0x0018 - -/* Note if suitable for use in FIPS mode */ -# define EVP_MD_FLAG_FIPS 0x0400 - -/* Digest ctrls */ - -# define EVP_MD_CTRL_DIGALGID 0x1 -# define EVP_MD_CTRL_MICALG 0x2 -# define EVP_MD_CTRL_XOF_LEN 0x3 - -/* Minimum Algorithm specific ctrl value */ - -# define EVP_MD_CTRL_ALG_CTRL 0x1000 - -# endif /* !EVP_MD */ - -/* values for EVP_MD_CTX flags */ - -# define EVP_MD_CTX_FLAG_ONESHOT 0x0001/* digest update will be - * called once only */ -# define EVP_MD_CTX_FLAG_CLEANED 0x0002/* context has already been - * cleaned */ -# define EVP_MD_CTX_FLAG_REUSE 0x0004/* Don't free up ctx->md_data - * in EVP_MD_CTX_reset */ -/* - * FIPS and pad options are ignored in 1.0.0, definitions are here so we - * don't accidentally reuse the values for other purposes. - */ - -# define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008/* Allow use of non FIPS - * digest in FIPS mode */ - -/* - * The following PAD options are also currently ignored in 1.0.0, digest - * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*() - * instead. - */ -# define EVP_MD_CTX_FLAG_PAD_MASK 0xF0/* RSA mode to use */ -# define EVP_MD_CTX_FLAG_PAD_PKCS1 0x00/* PKCS#1 v1.5 mode */ -# define EVP_MD_CTX_FLAG_PAD_X931 0x10/* X9.31 mode */ -# define EVP_MD_CTX_FLAG_PAD_PSS 0x20/* PSS mode */ - -# define EVP_MD_CTX_FLAG_NO_INIT 0x0100/* Don't initialize md_data */ -/* - * Some functions such as EVP_DigestSign only finalise copies of internal - * contexts so additional data can be included after the finalisation call. - * This is inefficient if this functionality is not required: it is disabled - * if the following flag is set. - */ -# define EVP_MD_CTX_FLAG_FINALISE 0x0200 -/* NOTE: 0x0400 is reserved for internal usage */ - -EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len); -EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher); -void EVP_CIPHER_meth_free(EVP_CIPHER *cipher); - -int EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len); -int EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags); -int EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size); -int EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher, - int (*init) (EVP_CIPHER_CTX *ctx, - const unsigned char *key, - const unsigned char *iv, - int enc)); -int EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher, - int (*do_cipher) (EVP_CIPHER_CTX *ctx, - unsigned char *out, - const unsigned char *in, - size_t inl)); -int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher, - int (*cleanup) (EVP_CIPHER_CTX *)); -int EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher, - int (*set_asn1_parameters) (EVP_CIPHER_CTX *, - ASN1_TYPE *)); -int EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher, - int (*get_asn1_parameters) (EVP_CIPHER_CTX *, - ASN1_TYPE *)); -int EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher, - int (*ctrl) (EVP_CIPHER_CTX *, int type, - int arg, void *ptr)); - -int (*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx, - const unsigned char *key, - const unsigned char *iv, - int enc); -int (*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx, - unsigned char *out, - const unsigned char *in, - size_t inl); -int (*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *); -int (*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, - ASN1_TYPE *); -int (*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, - ASN1_TYPE *); -int (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, - int type, int arg, - void *ptr); - -/* Values for cipher flags */ - -/* Modes for ciphers */ - -# define EVP_CIPH_STREAM_CIPHER 0x0 -# define EVP_CIPH_ECB_MODE 0x1 -# define EVP_CIPH_CBC_MODE 0x2 -# define EVP_CIPH_CFB_MODE 0x3 -# define EVP_CIPH_OFB_MODE 0x4 -# define EVP_CIPH_CTR_MODE 0x5 -# define EVP_CIPH_GCM_MODE 0x6 -# define EVP_CIPH_CCM_MODE 0x7 -# define EVP_CIPH_XTS_MODE 0x10001 -# define EVP_CIPH_WRAP_MODE 0x10002 -# define EVP_CIPH_OCB_MODE 0x10003 -# define EVP_CIPH_MODE 0xF0007 -/* Set if variable length cipher */ -# define EVP_CIPH_VARIABLE_LENGTH 0x8 -/* Set if the iv handling should be done by the cipher itself */ -# define EVP_CIPH_CUSTOM_IV 0x10 -/* Set if the cipher's init() function should be called if key is NULL */ -# define EVP_CIPH_ALWAYS_CALL_INIT 0x20 -/* Call ctrl() to init cipher parameters */ -# define EVP_CIPH_CTRL_INIT 0x40 -/* Don't use standard key length function */ -# define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80 -/* Don't use standard block padding */ -# define EVP_CIPH_NO_PADDING 0x100 -/* cipher handles random key generation */ -# define EVP_CIPH_RAND_KEY 0x200 -/* cipher has its own additional copying logic */ -# define EVP_CIPH_CUSTOM_COPY 0x400 -/* Don't use standard iv length function */ -# define EVP_CIPH_CUSTOM_IV_LENGTH 0x800 -/* Allow use default ASN1 get/set iv */ -# define EVP_CIPH_FLAG_DEFAULT_ASN1 0x1000 -/* Buffer length in bits not bytes: CFB1 mode only */ -# define EVP_CIPH_FLAG_LENGTH_BITS 0x2000 -/* Note if suitable for use in FIPS mode */ -# define EVP_CIPH_FLAG_FIPS 0x4000 -/* Allow non FIPS cipher in FIPS mode */ -# define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0x8000 -/* - * Cipher handles any and all padding logic as well as finalisation. - */ -# define EVP_CIPH_FLAG_CUSTOM_CIPHER 0x100000 -# define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000 -# define EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000 -/* Cipher can handle pipeline operations */ -# define EVP_CIPH_FLAG_PIPELINE 0X800000 - -/* - * Cipher context flag to indicate we can handle wrap mode: if allowed in - * older applications it could overflow buffers. - */ - -# define EVP_CIPHER_CTX_FLAG_WRAP_ALLOW 0x1 - -/* ctrl() values */ - -# define EVP_CTRL_INIT 0x0 -# define EVP_CTRL_SET_KEY_LENGTH 0x1 -# define EVP_CTRL_GET_RC2_KEY_BITS 0x2 -# define EVP_CTRL_SET_RC2_KEY_BITS 0x3 -# define EVP_CTRL_GET_RC5_ROUNDS 0x4 -# define EVP_CTRL_SET_RC5_ROUNDS 0x5 -# define EVP_CTRL_RAND_KEY 0x6 -# define EVP_CTRL_PBE_PRF_NID 0x7 -# define EVP_CTRL_COPY 0x8 -# define EVP_CTRL_AEAD_SET_IVLEN 0x9 -# define EVP_CTRL_AEAD_GET_TAG 0x10 -# define EVP_CTRL_AEAD_SET_TAG 0x11 -# define EVP_CTRL_AEAD_SET_IV_FIXED 0x12 -# define EVP_CTRL_GCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN -# define EVP_CTRL_GCM_GET_TAG EVP_CTRL_AEAD_GET_TAG -# define EVP_CTRL_GCM_SET_TAG EVP_CTRL_AEAD_SET_TAG -# define EVP_CTRL_GCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED -# define EVP_CTRL_GCM_IV_GEN 0x13 -# define EVP_CTRL_CCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN -# define EVP_CTRL_CCM_GET_TAG EVP_CTRL_AEAD_GET_TAG -# define EVP_CTRL_CCM_SET_TAG EVP_CTRL_AEAD_SET_TAG -# define EVP_CTRL_CCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED -# define EVP_CTRL_CCM_SET_L 0x14 -# define EVP_CTRL_CCM_SET_MSGLEN 0x15 -/* - * AEAD cipher deduces payload length and returns number of bytes required to - * store MAC and eventual padding. Subsequent call to EVP_Cipher even - * appends/verifies MAC. - */ -# define EVP_CTRL_AEAD_TLS1_AAD 0x16 -/* Used by composite AEAD ciphers, no-op in GCM, CCM... */ -# define EVP_CTRL_AEAD_SET_MAC_KEY 0x17 -/* Set the GCM invocation field, decrypt only */ -# define EVP_CTRL_GCM_SET_IV_INV 0x18 - -# define EVP_CTRL_TLS1_1_MULTIBLOCK_AAD 0x19 -# define EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT 0x1a -# define EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT 0x1b -# define EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE 0x1c - -# define EVP_CTRL_SSL3_MASTER_SECRET 0x1d - -/* EVP_CTRL_SET_SBOX takes the char * specifying S-boxes */ -# define EVP_CTRL_SET_SBOX 0x1e -/* - * EVP_CTRL_SBOX_USED takes a 'size_t' and 'char *', pointing at a - * pre-allocated buffer with specified size - */ -# define EVP_CTRL_SBOX_USED 0x1f -/* EVP_CTRL_KEY_MESH takes 'size_t' number of bytes to mesh the key after, - * 0 switches meshing off - */ -# define EVP_CTRL_KEY_MESH 0x20 -/* EVP_CTRL_BLOCK_PADDING_MODE takes the padding mode */ -# define EVP_CTRL_BLOCK_PADDING_MODE 0x21 - -/* Set the output buffers to use for a pipelined operation */ -# define EVP_CTRL_SET_PIPELINE_OUTPUT_BUFS 0x22 -/* Set the input buffers to use for a pipelined operation */ -# define EVP_CTRL_SET_PIPELINE_INPUT_BUFS 0x23 -/* Set the input buffer lengths to use for a pipelined operation */ -# define EVP_CTRL_SET_PIPELINE_INPUT_LENS 0x24 - -# define EVP_CTRL_GET_IVLEN 0x25 - -/* Padding modes */ -#define EVP_PADDING_PKCS7 1 -#define EVP_PADDING_ISO7816_4 2 -#define EVP_PADDING_ANSI923 3 -#define EVP_PADDING_ISO10126 4 -#define EVP_PADDING_ZERO 5 - -/* RFC 5246 defines additional data to be 13 bytes in length */ -# define EVP_AEAD_TLS1_AAD_LEN 13 - -typedef struct { - unsigned char *out; - const unsigned char *inp; - size_t len; - unsigned int interleave; -} EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM; - -/* GCM TLS constants */ -/* Length of fixed part of IV derived from PRF */ -# define EVP_GCM_TLS_FIXED_IV_LEN 4 -/* Length of explicit part of IV part of TLS records */ -# define EVP_GCM_TLS_EXPLICIT_IV_LEN 8 -/* Length of tag for TLS */ -# define EVP_GCM_TLS_TAG_LEN 16 - -/* CCM TLS constants */ -/* Length of fixed part of IV derived from PRF */ -# define EVP_CCM_TLS_FIXED_IV_LEN 4 -/* Length of explicit part of IV part of TLS records */ -# define EVP_CCM_TLS_EXPLICIT_IV_LEN 8 -/* Total length of CCM IV length for TLS */ -# define EVP_CCM_TLS_IV_LEN 12 -/* Length of tag for TLS */ -# define EVP_CCM_TLS_TAG_LEN 16 -/* Length of CCM8 tag for TLS */ -# define EVP_CCM8_TLS_TAG_LEN 8 - -/* Length of tag for TLS */ -# define EVP_CHACHAPOLY_TLS_TAG_LEN 16 - -typedef struct evp_cipher_info_st { - const EVP_CIPHER *cipher; - unsigned char iv[EVP_MAX_IV_LENGTH]; -} EVP_CIPHER_INFO; - - -/* Password based encryption function */ -typedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass, - int passlen, ASN1_TYPE *param, - const EVP_CIPHER *cipher, const EVP_MD *md, - int en_de); - -# ifndef OPENSSL_NO_RSA -# define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ - (char *)(rsa)) -# endif - -# ifndef OPENSSL_NO_DSA -# define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ - (char *)(dsa)) -# endif - -# ifndef OPENSSL_NO_DH -# define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\ - (char *)(dh)) -# endif - -# ifndef OPENSSL_NO_EC -# define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\ - (char *)(eckey)) -# endif -# ifndef OPENSSL_NO_SIPHASH -# define EVP_PKEY_assign_SIPHASH(pkey,shkey) EVP_PKEY_assign((pkey),EVP_PKEY_SIPHASH,\ - (char *)(shkey)) -# endif - -# ifndef OPENSSL_NO_POLY1305 -# define EVP_PKEY_assign_POLY1305(pkey,polykey) EVP_PKEY_assign((pkey),EVP_PKEY_POLY1305,\ - (char *)(polykey)) -# endif - -/* Add some extra combinations */ -# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) -# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) -# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) -# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) - -int EVP_MD_type(const EVP_MD *md); -# define EVP_MD_nid(e) EVP_MD_type(e) -# define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e)) -int EVP_MD_pkey_type(const EVP_MD *md); -int EVP_MD_size(const EVP_MD *md); -int EVP_MD_block_size(const EVP_MD *md); -unsigned long EVP_MD_flags(const EVP_MD *md); - -const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx); -int (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx, - const void *data, size_t count); -void EVP_MD_CTX_set_update_fn(EVP_MD_CTX *ctx, - int (*update) (EVP_MD_CTX *ctx, - const void *data, size_t count)); -# define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e)) -# define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e)) -# define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e)) -EVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx); -void EVP_MD_CTX_set_pkey_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pctx); -void *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx); - -int EVP_CIPHER_nid(const EVP_CIPHER *cipher); -# define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e)) -int EVP_CIPHER_block_size(const EVP_CIPHER *cipher); -int EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *cipher); -int EVP_CIPHER_key_length(const EVP_CIPHER *cipher); -int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher); -unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher); -# define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE) - -const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx); -const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx); -const unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx); -unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx); -unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_num(const EVP_CIPHER_CTX *ctx); -void EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num); -int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in); -void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx); -void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data); -void *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx); -void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data); -# define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) -# if OPENSSL_API_COMPAT < 0x10100000L -# define EVP_CIPHER_CTX_flags(c) EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(c)) -# endif -# define EVP_CIPHER_CTX_mode(c) EVP_CIPHER_mode(EVP_CIPHER_CTX_cipher(c)) - -# define EVP_ENCODE_LENGTH(l) ((((l)+2)/3*4)+((l)/48+1)*2+80) -# define EVP_DECODE_LENGTH(l) (((l)+3)/4*3+80) - -# define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) -# define EVP_SignInit(a,b) EVP_DigestInit(a,b) -# define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) -# define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) -# define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) -# define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) -# define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) -# define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) -# define EVP_DigestSignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) -# define EVP_DigestVerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) - -# ifdef CONST_STRICT -void BIO_set_md(BIO *, const EVP_MD *md); -# else -# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)(md)) -# endif -# define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)(mdp)) -# define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0, \ - (char *)(mdcp)) -# define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0, \ - (char *)(mdcp)) -# define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) -# define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0, \ - (char *)(c_pp)) - -/*__owur*/ int EVP_Cipher(EVP_CIPHER_CTX *c, - unsigned char *out, - const unsigned char *in, unsigned int inl); - -# define EVP_add_cipher_alias(n,alias) \ - OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n)) -# define EVP_add_digest_alias(n,alias) \ - OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n)) -# define EVP_delete_cipher_alias(alias) \ - OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS); -# define EVP_delete_digest_alias(alias) \ - OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); - -int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2); -EVP_MD_CTX *EVP_MD_CTX_new(void); -int EVP_MD_CTX_reset(EVP_MD_CTX *ctx); -void EVP_MD_CTX_free(EVP_MD_CTX *ctx); -# define EVP_MD_CTX_create() EVP_MD_CTX_new() -# define EVP_MD_CTX_init(ctx) EVP_MD_CTX_reset((ctx)) -# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx)) -__owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in); -void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags); -void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags); -int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags); -__owur int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, - ENGINE *impl); -__owur int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, - size_t cnt); -__owur int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, - unsigned int *s); -__owur int EVP_Digest(const void *data, size_t count, - unsigned char *md, unsigned int *size, - const EVP_MD *type, ENGINE *impl); - -__owur int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in); -__owur int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); -__owur int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, - unsigned int *s); -__owur int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md, - size_t len); - -int EVP_read_pw_string(char *buf, int length, const char *prompt, int verify); -int EVP_read_pw_string_min(char *buf, int minlen, int maxlen, - const char *prompt, int verify); -void EVP_set_pw_prompt(const char *prompt); -char *EVP_get_pw_prompt(void); - -__owur int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, - const unsigned char *salt, - const unsigned char *data, int datal, int count, - unsigned char *key, unsigned char *iv); - -void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags); -void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags); -int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags); - -__owur int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv); -/*__owur*/ int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key, - const unsigned char *iv); -/*__owur*/ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl, const unsigned char *in, int inl); -/*__owur*/ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl); -/*__owur*/ int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl); - -__owur int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv); -/*__owur*/ int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key, - const unsigned char *iv); -/*__owur*/ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl, const unsigned char *in, int inl); -__owur int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, - int *outl); -/*__owur*/ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, - int *outl); - -__owur int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv, - int enc); -/*__owur*/ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key, - const unsigned char *iv, int enc); -__owur int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl, const unsigned char *in, int inl); -__owur int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, - int *outl); -__owur int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, - int *outl); - -__owur int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s, - EVP_PKEY *pkey); - -__owur int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret, - size_t *siglen, const unsigned char *tbs, - size_t tbslen); - -__owur int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, - unsigned int siglen, EVP_PKEY *pkey); - -__owur int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret, - size_t siglen, const unsigned char *tbs, - size_t tbslen); - -/*__owur*/ int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, - const EVP_MD *type, ENGINE *e, - EVP_PKEY *pkey); -__owur int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, - size_t *siglen); - -__owur int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, - const EVP_MD *type, ENGINE *e, - EVP_PKEY *pkey); -__owur int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig, - size_t siglen); - -# ifndef OPENSSL_NO_RSA -__owur int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, - const unsigned char *ek, int ekl, - const unsigned char *iv, EVP_PKEY *priv); -__owur int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); - -__owur int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, - unsigned char **ek, int *ekl, unsigned char *iv, - EVP_PKEY **pubk, int npubk); -__owur int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); -# endif - -EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void); -void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx); -int EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, EVP_ENCODE_CTX *sctx); -int EVP_ENCODE_CTX_num(EVP_ENCODE_CTX *ctx); -void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); -int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, - const unsigned char *in, int inl); -void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl); -int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); - -void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); -int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, - const unsigned char *in, int inl); -int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned - char *out, int *outl); -int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define EVP_CIPHER_CTX_init(c) EVP_CIPHER_CTX_reset(c) -# define EVP_CIPHER_CTX_cleanup(c) EVP_CIPHER_CTX_reset(c) -# endif -EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void); -int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c); -void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *c); -int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); -int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad); -int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); -int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key); - -const BIO_METHOD *BIO_f_md(void); -const BIO_METHOD *BIO_f_base64(void); -const BIO_METHOD *BIO_f_cipher(void); -const BIO_METHOD *BIO_f_reliable(void); -__owur int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, - const unsigned char *i, int enc); - -const EVP_MD *EVP_md_null(void); -# ifndef OPENSSL_NO_MD2 -const EVP_MD *EVP_md2(void); -# endif -# ifndef OPENSSL_NO_MD4 -const EVP_MD *EVP_md4(void); -# endif -# ifndef OPENSSL_NO_MD5 -const EVP_MD *EVP_md5(void); -const EVP_MD *EVP_md5_sha1(void); -# endif -# ifndef OPENSSL_NO_BLAKE2 -const EVP_MD *EVP_blake2b512(void); -const EVP_MD *EVP_blake2s256(void); -# endif -const EVP_MD *EVP_sha1(void); -const EVP_MD *EVP_sha224(void); -const EVP_MD *EVP_sha256(void); -const EVP_MD *EVP_sha384(void); -const EVP_MD *EVP_sha512(void); -const EVP_MD *EVP_sha512_224(void); -const EVP_MD *EVP_sha512_256(void); -const EVP_MD *EVP_sha3_224(void); -const EVP_MD *EVP_sha3_256(void); -const EVP_MD *EVP_sha3_384(void); -const EVP_MD *EVP_sha3_512(void); -const EVP_MD *EVP_shake128(void); -const EVP_MD *EVP_shake256(void); -# ifndef OPENSSL_NO_MDC2 -const EVP_MD *EVP_mdc2(void); -# endif -# ifndef OPENSSL_NO_RMD160 -const EVP_MD *EVP_ripemd160(void); -# endif -# ifndef OPENSSL_NO_WHIRLPOOL -const EVP_MD *EVP_whirlpool(void); -# endif -# ifndef OPENSSL_NO_SM3 -const EVP_MD *EVP_sm3(void); -# endif -const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ -# ifndef OPENSSL_NO_DES -const EVP_CIPHER *EVP_des_ecb(void); -const EVP_CIPHER *EVP_des_ede(void); -const EVP_CIPHER *EVP_des_ede3(void); -const EVP_CIPHER *EVP_des_ede_ecb(void); -const EVP_CIPHER *EVP_des_ede3_ecb(void); -const EVP_CIPHER *EVP_des_cfb64(void); -# define EVP_des_cfb EVP_des_cfb64 -const EVP_CIPHER *EVP_des_cfb1(void); -const EVP_CIPHER *EVP_des_cfb8(void); -const EVP_CIPHER *EVP_des_ede_cfb64(void); -# define EVP_des_ede_cfb EVP_des_ede_cfb64 -const EVP_CIPHER *EVP_des_ede3_cfb64(void); -# define EVP_des_ede3_cfb EVP_des_ede3_cfb64 -const EVP_CIPHER *EVP_des_ede3_cfb1(void); -const EVP_CIPHER *EVP_des_ede3_cfb8(void); -const EVP_CIPHER *EVP_des_ofb(void); -const EVP_CIPHER *EVP_des_ede_ofb(void); -const EVP_CIPHER *EVP_des_ede3_ofb(void); -const EVP_CIPHER *EVP_des_cbc(void); -const EVP_CIPHER *EVP_des_ede_cbc(void); -const EVP_CIPHER *EVP_des_ede3_cbc(void); -const EVP_CIPHER *EVP_desx_cbc(void); -const EVP_CIPHER *EVP_des_ede3_wrap(void); -/* - * This should now be supported through the dev_crypto ENGINE. But also, why - * are rc4 and md5 declarations made here inside a "NO_DES" precompiler - * branch? - */ -# endif -# ifndef OPENSSL_NO_RC4 -const EVP_CIPHER *EVP_rc4(void); -const EVP_CIPHER *EVP_rc4_40(void); -# ifndef OPENSSL_NO_MD5 -const EVP_CIPHER *EVP_rc4_hmac_md5(void); -# endif -# endif -# ifndef OPENSSL_NO_IDEA -const EVP_CIPHER *EVP_idea_ecb(void); -const EVP_CIPHER *EVP_idea_cfb64(void); -# define EVP_idea_cfb EVP_idea_cfb64 -const EVP_CIPHER *EVP_idea_ofb(void); -const EVP_CIPHER *EVP_idea_cbc(void); -# endif -# ifndef OPENSSL_NO_RC2 -const EVP_CIPHER *EVP_rc2_ecb(void); -const EVP_CIPHER *EVP_rc2_cbc(void); -const EVP_CIPHER *EVP_rc2_40_cbc(void); -const EVP_CIPHER *EVP_rc2_64_cbc(void); -const EVP_CIPHER *EVP_rc2_cfb64(void); -# define EVP_rc2_cfb EVP_rc2_cfb64 -const EVP_CIPHER *EVP_rc2_ofb(void); -# endif -# ifndef OPENSSL_NO_BF -const EVP_CIPHER *EVP_bf_ecb(void); -const EVP_CIPHER *EVP_bf_cbc(void); -const EVP_CIPHER *EVP_bf_cfb64(void); -# define EVP_bf_cfb EVP_bf_cfb64 -const EVP_CIPHER *EVP_bf_ofb(void); -# endif -# ifndef OPENSSL_NO_CAST -const EVP_CIPHER *EVP_cast5_ecb(void); -const EVP_CIPHER *EVP_cast5_cbc(void); -const EVP_CIPHER *EVP_cast5_cfb64(void); -# define EVP_cast5_cfb EVP_cast5_cfb64 -const EVP_CIPHER *EVP_cast5_ofb(void); -# endif -# ifndef OPENSSL_NO_RC5 -const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); -const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); -const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void); -# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 -const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); -# endif -const EVP_CIPHER *EVP_aes_128_ecb(void); -const EVP_CIPHER *EVP_aes_128_cbc(void); -const EVP_CIPHER *EVP_aes_128_cfb1(void); -const EVP_CIPHER *EVP_aes_128_cfb8(void); -const EVP_CIPHER *EVP_aes_128_cfb128(void); -# define EVP_aes_128_cfb EVP_aes_128_cfb128 -const EVP_CIPHER *EVP_aes_128_ofb(void); -const EVP_CIPHER *EVP_aes_128_ctr(void); -const EVP_CIPHER *EVP_aes_128_ccm(void); -const EVP_CIPHER *EVP_aes_128_gcm(void); -const EVP_CIPHER *EVP_aes_128_xts(void); -const EVP_CIPHER *EVP_aes_128_wrap(void); -const EVP_CIPHER *EVP_aes_128_wrap_pad(void); -# ifndef OPENSSL_NO_OCB -const EVP_CIPHER *EVP_aes_128_ocb(void); -# endif -const EVP_CIPHER *EVP_aes_192_ecb(void); -const EVP_CIPHER *EVP_aes_192_cbc(void); -const EVP_CIPHER *EVP_aes_192_cfb1(void); -const EVP_CIPHER *EVP_aes_192_cfb8(void); -const EVP_CIPHER *EVP_aes_192_cfb128(void); -# define EVP_aes_192_cfb EVP_aes_192_cfb128 -const EVP_CIPHER *EVP_aes_192_ofb(void); -const EVP_CIPHER *EVP_aes_192_ctr(void); -const EVP_CIPHER *EVP_aes_192_ccm(void); -const EVP_CIPHER *EVP_aes_192_gcm(void); -const EVP_CIPHER *EVP_aes_192_wrap(void); -const EVP_CIPHER *EVP_aes_192_wrap_pad(void); -# ifndef OPENSSL_NO_OCB -const EVP_CIPHER *EVP_aes_192_ocb(void); -# endif -const EVP_CIPHER *EVP_aes_256_ecb(void); -const EVP_CIPHER *EVP_aes_256_cbc(void); -const EVP_CIPHER *EVP_aes_256_cfb1(void); -const EVP_CIPHER *EVP_aes_256_cfb8(void); -const EVP_CIPHER *EVP_aes_256_cfb128(void); -# define EVP_aes_256_cfb EVP_aes_256_cfb128 -const EVP_CIPHER *EVP_aes_256_ofb(void); -const EVP_CIPHER *EVP_aes_256_ctr(void); -const EVP_CIPHER *EVP_aes_256_ccm(void); -const EVP_CIPHER *EVP_aes_256_gcm(void); -const EVP_CIPHER *EVP_aes_256_xts(void); -const EVP_CIPHER *EVP_aes_256_wrap(void); -const EVP_CIPHER *EVP_aes_256_wrap_pad(void); -# ifndef OPENSSL_NO_OCB -const EVP_CIPHER *EVP_aes_256_ocb(void); -# endif -const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void); -const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void); -const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void); -const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void); -# ifndef OPENSSL_NO_ARIA -const EVP_CIPHER *EVP_aria_128_ecb(void); -const EVP_CIPHER *EVP_aria_128_cbc(void); -const EVP_CIPHER *EVP_aria_128_cfb1(void); -const EVP_CIPHER *EVP_aria_128_cfb8(void); -const EVP_CIPHER *EVP_aria_128_cfb128(void); -# define EVP_aria_128_cfb EVP_aria_128_cfb128 -const EVP_CIPHER *EVP_aria_128_ctr(void); -const EVP_CIPHER *EVP_aria_128_ofb(void); -const EVP_CIPHER *EVP_aria_128_gcm(void); -const EVP_CIPHER *EVP_aria_128_ccm(void); -const EVP_CIPHER *EVP_aria_192_ecb(void); -const EVP_CIPHER *EVP_aria_192_cbc(void); -const EVP_CIPHER *EVP_aria_192_cfb1(void); -const EVP_CIPHER *EVP_aria_192_cfb8(void); -const EVP_CIPHER *EVP_aria_192_cfb128(void); -# define EVP_aria_192_cfb EVP_aria_192_cfb128 -const EVP_CIPHER *EVP_aria_192_ctr(void); -const EVP_CIPHER *EVP_aria_192_ofb(void); -const EVP_CIPHER *EVP_aria_192_gcm(void); -const EVP_CIPHER *EVP_aria_192_ccm(void); -const EVP_CIPHER *EVP_aria_256_ecb(void); -const EVP_CIPHER *EVP_aria_256_cbc(void); -const EVP_CIPHER *EVP_aria_256_cfb1(void); -const EVP_CIPHER *EVP_aria_256_cfb8(void); -const EVP_CIPHER *EVP_aria_256_cfb128(void); -# define EVP_aria_256_cfb EVP_aria_256_cfb128 -const EVP_CIPHER *EVP_aria_256_ctr(void); -const EVP_CIPHER *EVP_aria_256_ofb(void); -const EVP_CIPHER *EVP_aria_256_gcm(void); -const EVP_CIPHER *EVP_aria_256_ccm(void); -# endif -# ifndef OPENSSL_NO_CAMELLIA -const EVP_CIPHER *EVP_camellia_128_ecb(void); -const EVP_CIPHER *EVP_camellia_128_cbc(void); -const EVP_CIPHER *EVP_camellia_128_cfb1(void); -const EVP_CIPHER *EVP_camellia_128_cfb8(void); -const EVP_CIPHER *EVP_camellia_128_cfb128(void); -# define EVP_camellia_128_cfb EVP_camellia_128_cfb128 -const EVP_CIPHER *EVP_camellia_128_ofb(void); -const EVP_CIPHER *EVP_camellia_128_ctr(void); -const EVP_CIPHER *EVP_camellia_192_ecb(void); -const EVP_CIPHER *EVP_camellia_192_cbc(void); -const EVP_CIPHER *EVP_camellia_192_cfb1(void); -const EVP_CIPHER *EVP_camellia_192_cfb8(void); -const EVP_CIPHER *EVP_camellia_192_cfb128(void); -# define EVP_camellia_192_cfb EVP_camellia_192_cfb128 -const EVP_CIPHER *EVP_camellia_192_ofb(void); -const EVP_CIPHER *EVP_camellia_192_ctr(void); -const EVP_CIPHER *EVP_camellia_256_ecb(void); -const EVP_CIPHER *EVP_camellia_256_cbc(void); -const EVP_CIPHER *EVP_camellia_256_cfb1(void); -const EVP_CIPHER *EVP_camellia_256_cfb8(void); -const EVP_CIPHER *EVP_camellia_256_cfb128(void); -# define EVP_camellia_256_cfb EVP_camellia_256_cfb128 -const EVP_CIPHER *EVP_camellia_256_ofb(void); -const EVP_CIPHER *EVP_camellia_256_ctr(void); -# endif -# ifndef OPENSSL_NO_CHACHA -const EVP_CIPHER *EVP_chacha20(void); -# ifndef OPENSSL_NO_POLY1305 -const EVP_CIPHER *EVP_chacha20_poly1305(void); -# endif -# endif - -# ifndef OPENSSL_NO_SEED -const EVP_CIPHER *EVP_seed_ecb(void); -const EVP_CIPHER *EVP_seed_cbc(void); -const EVP_CIPHER *EVP_seed_cfb128(void); -# define EVP_seed_cfb EVP_seed_cfb128 -const EVP_CIPHER *EVP_seed_ofb(void); -# endif - -# ifndef OPENSSL_NO_SM4 -const EVP_CIPHER *EVP_sm4_ecb(void); -const EVP_CIPHER *EVP_sm4_cbc(void); -const EVP_CIPHER *EVP_sm4_cfb128(void); -# define EVP_sm4_cfb EVP_sm4_cfb128 -const EVP_CIPHER *EVP_sm4_ofb(void); -const EVP_CIPHER *EVP_sm4_ctr(void); -# endif - -# if OPENSSL_API_COMPAT < 0x10100000L -# define OPENSSL_add_all_algorithms_conf() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \ - | OPENSSL_INIT_ADD_ALL_DIGESTS \ - | OPENSSL_INIT_LOAD_CONFIG, NULL) -# define OPENSSL_add_all_algorithms_noconf() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \ - | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL) - -# ifdef OPENSSL_LOAD_CONF -# define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_conf() -# else -# define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_noconf() -# endif - -# define OpenSSL_add_all_ciphers() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL) -# define OpenSSL_add_all_digests() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL) - -# define EVP_cleanup() while(0) continue -# endif - -int EVP_add_cipher(const EVP_CIPHER *cipher); -int EVP_add_digest(const EVP_MD *digest); - -const EVP_CIPHER *EVP_get_cipherbyname(const char *name); -const EVP_MD *EVP_get_digestbyname(const char *name); - -void EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph, - const char *from, const char *to, void *x), - void *arg); -void EVP_CIPHER_do_all_sorted(void (*fn) - (const EVP_CIPHER *ciph, const char *from, - const char *to, void *x), void *arg); - -void EVP_MD_do_all(void (*fn) (const EVP_MD *ciph, - const char *from, const char *to, void *x), - void *arg); -void EVP_MD_do_all_sorted(void (*fn) - (const EVP_MD *ciph, const char *from, - const char *to, void *x), void *arg); - -int EVP_PKEY_decrypt_old(unsigned char *dec_key, - const unsigned char *enc_key, int enc_key_len, - EVP_PKEY *private_key); -int EVP_PKEY_encrypt_old(unsigned char *enc_key, - const unsigned char *key, int key_len, - EVP_PKEY *pub_key); -int EVP_PKEY_type(int type); -int EVP_PKEY_id(const EVP_PKEY *pkey); -int EVP_PKEY_base_id(const EVP_PKEY *pkey); -int EVP_PKEY_bits(const EVP_PKEY *pkey); -int EVP_PKEY_security_bits(const EVP_PKEY *pkey); -int EVP_PKEY_size(const EVP_PKEY *pkey); -int EVP_PKEY_set_type(EVP_PKEY *pkey, int type); -int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len); -int EVP_PKEY_set_alias_type(EVP_PKEY *pkey, int type); -# ifndef OPENSSL_NO_ENGINE -int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e); -ENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey); -# endif -int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key); -void *EVP_PKEY_get0(const EVP_PKEY *pkey); -const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len); -# ifndef OPENSSL_NO_POLY1305 -const unsigned char *EVP_PKEY_get0_poly1305(const EVP_PKEY *pkey, size_t *len); -# endif -# ifndef OPENSSL_NO_SIPHASH -const unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len); -# endif - -# ifndef OPENSSL_NO_RSA -struct rsa_st; -int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key); -struct rsa_st *EVP_PKEY_get0_RSA(EVP_PKEY *pkey); -struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); -# endif -# ifndef OPENSSL_NO_DSA -struct dsa_st; -int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key); -struct dsa_st *EVP_PKEY_get0_DSA(EVP_PKEY *pkey); -struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); -# endif -# ifndef OPENSSL_NO_DH -struct dh_st; -int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key); -struct dh_st *EVP_PKEY_get0_DH(EVP_PKEY *pkey); -struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); -# endif -# ifndef OPENSSL_NO_EC -struct ec_key_st; -int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key); -struct ec_key_st *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey); -struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); -# endif - -EVP_PKEY *EVP_PKEY_new(void); -int EVP_PKEY_up_ref(EVP_PKEY *pkey); -void EVP_PKEY_free(EVP_PKEY *pkey); - -EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, - long length); -int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp); - -EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, - long length); -EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, - long length); -int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); - -int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from); -int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey); -int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode); -int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b); - -int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); - -int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, - int indent, ASN1_PCTX *pctx); -int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, - int indent, ASN1_PCTX *pctx); -int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, - int indent, ASN1_PCTX *pctx); - -int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid); - -int EVP_PKEY_set1_tls_encodedpoint(EVP_PKEY *pkey, - const unsigned char *pt, size_t ptlen); -size_t EVP_PKEY_get1_tls_encodedpoint(EVP_PKEY *pkey, unsigned char **ppt); - -int EVP_CIPHER_type(const EVP_CIPHER *ctx); - -/* calls methods */ -int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); -int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); - -/* These are used by EVP_CIPHER methods */ -int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); -int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); - -/* PKCS5 password based encryption */ -int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, - ASN1_TYPE *param, const EVP_CIPHER *cipher, - const EVP_MD *md, int en_de); -int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, - const unsigned char *salt, int saltlen, int iter, - int keylen, unsigned char *out); -int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, - const unsigned char *salt, int saltlen, int iter, - const EVP_MD *digest, int keylen, unsigned char *out); -int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, - ASN1_TYPE *param, const EVP_CIPHER *cipher, - const EVP_MD *md, int en_de); - -#ifndef OPENSSL_NO_SCRYPT -int EVP_PBE_scrypt(const char *pass, size_t passlen, - const unsigned char *salt, size_t saltlen, - uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem, - unsigned char *key, size_t keylen); - -int PKCS5_v2_scrypt_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, - int passlen, ASN1_TYPE *param, - const EVP_CIPHER *c, const EVP_MD *md, int en_de); -#endif - -void PKCS5_PBE_add(void); - -int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, - ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); - -/* PBE type */ - -/* Can appear as the outermost AlgorithmIdentifier */ -# define EVP_PBE_TYPE_OUTER 0x0 -/* Is an PRF type OID */ -# define EVP_PBE_TYPE_PRF 0x1 -/* Is a PKCS#5 v2.0 KDF */ -# define EVP_PBE_TYPE_KDF 0x2 - -int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, - int md_nid, EVP_PBE_KEYGEN *keygen); -int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, - EVP_PBE_KEYGEN *keygen); -int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid, - EVP_PBE_KEYGEN **pkeygen); -void EVP_PBE_cleanup(void); -int EVP_PBE_get(int *ptype, int *ppbe_nid, size_t num); - -# define ASN1_PKEY_ALIAS 0x1 -# define ASN1_PKEY_DYNAMIC 0x2 -# define ASN1_PKEY_SIGPARAM_NULL 0x4 - -# define ASN1_PKEY_CTRL_PKCS7_SIGN 0x1 -# define ASN1_PKEY_CTRL_PKCS7_ENCRYPT 0x2 -# define ASN1_PKEY_CTRL_DEFAULT_MD_NID 0x3 -# define ASN1_PKEY_CTRL_CMS_SIGN 0x5 -# define ASN1_PKEY_CTRL_CMS_ENVELOPE 0x7 -# define ASN1_PKEY_CTRL_CMS_RI_TYPE 0x8 - -# define ASN1_PKEY_CTRL_SET1_TLS_ENCPT 0x9 -# define ASN1_PKEY_CTRL_GET1_TLS_ENCPT 0xa - -int EVP_PKEY_asn1_get_count(void); -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx); -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type); -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe, - const char *str, int len); -int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth); -int EVP_PKEY_asn1_add_alias(int to, int from); -int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id, - int *ppkey_flags, const char **pinfo, - const char **ppem_str, - const EVP_PKEY_ASN1_METHOD *ameth); - -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(const EVP_PKEY *pkey); -EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags, - const char *pem_str, - const char *info); -void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, - const EVP_PKEY_ASN1_METHOD *src); -void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth); -void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth, - int (*pub_decode) (EVP_PKEY *pk, - X509_PUBKEY *pub), - int (*pub_encode) (X509_PUBKEY *pub, - const EVP_PKEY *pk), - int (*pub_cmp) (const EVP_PKEY *a, - const EVP_PKEY *b), - int (*pub_print) (BIO *out, - const EVP_PKEY *pkey, - int indent, ASN1_PCTX *pctx), - int (*pkey_size) (const EVP_PKEY *pk), - int (*pkey_bits) (const EVP_PKEY *pk)); -void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth, - int (*priv_decode) (EVP_PKEY *pk, - const PKCS8_PRIV_KEY_INFO - *p8inf), - int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, - const EVP_PKEY *pk), - int (*priv_print) (BIO *out, - const EVP_PKEY *pkey, - int indent, - ASN1_PCTX *pctx)); -void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth, - int (*param_decode) (EVP_PKEY *pkey, - const unsigned char **pder, - int derlen), - int (*param_encode) (const EVP_PKEY *pkey, - unsigned char **pder), - int (*param_missing) (const EVP_PKEY *pk), - int (*param_copy) (EVP_PKEY *to, - const EVP_PKEY *from), - int (*param_cmp) (const EVP_PKEY *a, - const EVP_PKEY *b), - int (*param_print) (BIO *out, - const EVP_PKEY *pkey, - int indent, - ASN1_PCTX *pctx)); - -void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth, - void (*pkey_free) (EVP_PKEY *pkey)); -void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth, - int (*pkey_ctrl) (EVP_PKEY *pkey, int op, - long arg1, void *arg2)); -void EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth, - int (*item_verify) (EVP_MD_CTX *ctx, - const ASN1_ITEM *it, - void *asn, - X509_ALGOR *a, - ASN1_BIT_STRING *sig, - EVP_PKEY *pkey), - int (*item_sign) (EVP_MD_CTX *ctx, - const ASN1_ITEM *it, - void *asn, - X509_ALGOR *alg1, - X509_ALGOR *alg2, - ASN1_BIT_STRING *sig)); - -void EVP_PKEY_asn1_set_siginf(EVP_PKEY_ASN1_METHOD *ameth, - int (*siginf_set) (X509_SIG_INFO *siginf, - const X509_ALGOR *alg, - const ASN1_STRING *sig)); - -void EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth, - int (*pkey_check) (const EVP_PKEY *pk)); - -void EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth, - int (*pkey_pub_check) (const EVP_PKEY *pk)); - -void EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth, - int (*pkey_param_check) (const EVP_PKEY *pk)); - -void EVP_PKEY_asn1_set_set_priv_key(EVP_PKEY_ASN1_METHOD *ameth, - int (*set_priv_key) (EVP_PKEY *pk, - const unsigned char - *priv, - size_t len)); -void EVP_PKEY_asn1_set_set_pub_key(EVP_PKEY_ASN1_METHOD *ameth, - int (*set_pub_key) (EVP_PKEY *pk, - const unsigned char *pub, - size_t len)); -void EVP_PKEY_asn1_set_get_priv_key(EVP_PKEY_ASN1_METHOD *ameth, - int (*get_priv_key) (const EVP_PKEY *pk, - unsigned char *priv, - size_t *len)); -void EVP_PKEY_asn1_set_get_pub_key(EVP_PKEY_ASN1_METHOD *ameth, - int (*get_pub_key) (const EVP_PKEY *pk, - unsigned char *pub, - size_t *len)); - -void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth, - int (*pkey_security_bits) (const EVP_PKEY - *pk)); - -# define EVP_PKEY_OP_UNDEFINED 0 -# define EVP_PKEY_OP_PARAMGEN (1<<1) -# define EVP_PKEY_OP_KEYGEN (1<<2) -# define EVP_PKEY_OP_SIGN (1<<3) -# define EVP_PKEY_OP_VERIFY (1<<4) -# define EVP_PKEY_OP_VERIFYRECOVER (1<<5) -# define EVP_PKEY_OP_SIGNCTX (1<<6) -# define EVP_PKEY_OP_VERIFYCTX (1<<7) -# define EVP_PKEY_OP_ENCRYPT (1<<8) -# define EVP_PKEY_OP_DECRYPT (1<<9) -# define EVP_PKEY_OP_DERIVE (1<<10) - -# define EVP_PKEY_OP_TYPE_SIG \ - (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \ - | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX) - -# define EVP_PKEY_OP_TYPE_CRYPT \ - (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT) - -# define EVP_PKEY_OP_TYPE_NOGEN \ - (EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT | EVP_PKEY_OP_DERIVE) - -# define EVP_PKEY_OP_TYPE_GEN \ - (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN) - -# define EVP_PKEY_CTX_set_signature_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \ - EVP_PKEY_CTRL_MD, 0, (void *)(md)) - -# define EVP_PKEY_CTX_get_signature_md(ctx, pmd) \ - EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \ - EVP_PKEY_CTRL_GET_MD, 0, (void *)(pmd)) - -# define EVP_PKEY_CTX_set_mac_key(ctx, key, len) \ - EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_SET_MAC_KEY, len, (void *)(key)) - -# define EVP_PKEY_CTRL_MD 1 -# define EVP_PKEY_CTRL_PEER_KEY 2 - -# define EVP_PKEY_CTRL_PKCS7_ENCRYPT 3 -# define EVP_PKEY_CTRL_PKCS7_DECRYPT 4 - -# define EVP_PKEY_CTRL_PKCS7_SIGN 5 - -# define EVP_PKEY_CTRL_SET_MAC_KEY 6 - -# define EVP_PKEY_CTRL_DIGESTINIT 7 - -/* Used by GOST key encryption in TLS */ -# define EVP_PKEY_CTRL_SET_IV 8 - -# define EVP_PKEY_CTRL_CMS_ENCRYPT 9 -# define EVP_PKEY_CTRL_CMS_DECRYPT 10 -# define EVP_PKEY_CTRL_CMS_SIGN 11 - -# define EVP_PKEY_CTRL_CIPHER 12 - -# define EVP_PKEY_CTRL_GET_MD 13 - -# define EVP_PKEY_CTRL_SET_DIGEST_SIZE 14 - -# define EVP_PKEY_ALG_CTRL 0x1000 - -# define EVP_PKEY_FLAG_AUTOARGLEN 2 -/* - * Method handles all operations: don't assume any digest related defaults. - */ -# define EVP_PKEY_FLAG_SIGCTX_CUSTOM 4 - -const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type); -EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags); -void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags, - const EVP_PKEY_METHOD *meth); -void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src); -void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth); -int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth); -int EVP_PKEY_meth_remove(const EVP_PKEY_METHOD *pmeth); -size_t EVP_PKEY_meth_get_count(void); -const EVP_PKEY_METHOD *EVP_PKEY_meth_get0(size_t idx); - -EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e); -EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e); -EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx); -void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx); - -int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, - int cmd, int p1, void *p2); -int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, - const char *value); -int EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX *ctx, int keytype, int optype, - int cmd, uint64_t value); - -int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str); -int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex); - -int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md); - -int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx); -void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen); - -EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e, - const unsigned char *key, int keylen); -EVP_PKEY *EVP_PKEY_new_raw_private_key(int type, ENGINE *e, - const unsigned char *priv, - size_t len); -EVP_PKEY *EVP_PKEY_new_raw_public_key(int type, ENGINE *e, - const unsigned char *pub, - size_t len); -int EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey, unsigned char *priv, - size_t *len); -int EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, unsigned char *pub, - size_t *len); - -EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv, - size_t len, const EVP_CIPHER *cipher); - -void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data); -void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx); -EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx); - -EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx); - -void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data); -void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx); - -int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_sign(EVP_PKEY_CTX *ctx, - unsigned char *sig, size_t *siglen, - const unsigned char *tbs, size_t tbslen); -int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_verify(EVP_PKEY_CTX *ctx, - const unsigned char *sig, size_t siglen, - const unsigned char *tbs, size_t tbslen); -int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx, - unsigned char *rout, size_t *routlen, - const unsigned char *sig, size_t siglen); -int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx, - unsigned char *out, size_t *outlen, - const unsigned char *in, size_t inlen); -int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx, - unsigned char *out, size_t *outlen, - const unsigned char *in, size_t inlen); - -int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer); -int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); - -typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx); - -int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); -int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); -int EVP_PKEY_check(EVP_PKEY_CTX *ctx); -int EVP_PKEY_public_check(EVP_PKEY_CTX *ctx); -int EVP_PKEY_param_check(EVP_PKEY_CTX *ctx); - -void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb); -EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx); - -int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx); - -void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth, - int (*init) (EVP_PKEY_CTX *ctx)); - -void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth, - int (*copy) (EVP_PKEY_CTX *dst, - EVP_PKEY_CTX *src)); - -void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth, - void (*cleanup) (EVP_PKEY_CTX *ctx)); - -void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth, - int (*paramgen_init) (EVP_PKEY_CTX *ctx), - int (*paramgen) (EVP_PKEY_CTX *ctx, - EVP_PKEY *pkey)); - -void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth, - int (*keygen_init) (EVP_PKEY_CTX *ctx), - int (*keygen) (EVP_PKEY_CTX *ctx, - EVP_PKEY *pkey)); - -void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth, - int (*sign_init) (EVP_PKEY_CTX *ctx), - int (*sign) (EVP_PKEY_CTX *ctx, - unsigned char *sig, size_t *siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth, - int (*verify_init) (EVP_PKEY_CTX *ctx), - int (*verify) (EVP_PKEY_CTX *ctx, - const unsigned char *sig, - size_t siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth, - int (*verify_recover_init) (EVP_PKEY_CTX - *ctx), - int (*verify_recover) (EVP_PKEY_CTX - *ctx, - unsigned char - *sig, - size_t *siglen, - const unsigned - char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth, - int (*signctx_init) (EVP_PKEY_CTX *ctx, - EVP_MD_CTX *mctx), - int (*signctx) (EVP_PKEY_CTX *ctx, - unsigned char *sig, - size_t *siglen, - EVP_MD_CTX *mctx)); - -void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth, - int (*verifyctx_init) (EVP_PKEY_CTX *ctx, - EVP_MD_CTX *mctx), - int (*verifyctx) (EVP_PKEY_CTX *ctx, - const unsigned char *sig, - int siglen, - EVP_MD_CTX *mctx)); - -void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth, - int (*encrypt_init) (EVP_PKEY_CTX *ctx), - int (*encryptfn) (EVP_PKEY_CTX *ctx, - unsigned char *out, - size_t *outlen, - const unsigned char *in, - size_t inlen)); - -void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth, - int (*decrypt_init) (EVP_PKEY_CTX *ctx), - int (*decrypt) (EVP_PKEY_CTX *ctx, - unsigned char *out, - size_t *outlen, - const unsigned char *in, - size_t inlen)); - -void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth, - int (*derive_init) (EVP_PKEY_CTX *ctx), - int (*derive) (EVP_PKEY_CTX *ctx, - unsigned char *key, - size_t *keylen)); - -void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, - int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, - void *p2), - int (*ctrl_str) (EVP_PKEY_CTX *ctx, - const char *type, - const char *value)); - -void EVP_PKEY_meth_set_digestsign(EVP_PKEY_METHOD *pmeth, - int (*digestsign) (EVP_MD_CTX *ctx, - unsigned char *sig, - size_t *siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_set_digestverify(EVP_PKEY_METHOD *pmeth, - int (*digestverify) (EVP_MD_CTX *ctx, - const unsigned char *sig, - size_t siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth, - int (*check) (EVP_PKEY *pkey)); - -void EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth, - int (*check) (EVP_PKEY *pkey)); - -void EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth, - int (*check) (EVP_PKEY *pkey)); - -void EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD *pmeth, - int (*digest_custom) (EVP_PKEY_CTX *ctx, - EVP_MD_CTX *mctx)); - -void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth, - int (**pinit) (EVP_PKEY_CTX *ctx)); - -void EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD *pmeth, - int (**pcopy) (EVP_PKEY_CTX *dst, - EVP_PKEY_CTX *src)); - -void EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD *pmeth, - void (**pcleanup) (EVP_PKEY_CTX *ctx)); - -void EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD *pmeth, - int (**pparamgen_init) (EVP_PKEY_CTX *ctx), - int (**pparamgen) (EVP_PKEY_CTX *ctx, - EVP_PKEY *pkey)); - -void EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD *pmeth, - int (**pkeygen_init) (EVP_PKEY_CTX *ctx), - int (**pkeygen) (EVP_PKEY_CTX *ctx, - EVP_PKEY *pkey)); - -void EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD *pmeth, - int (**psign_init) (EVP_PKEY_CTX *ctx), - int (**psign) (EVP_PKEY_CTX *ctx, - unsigned char *sig, size_t *siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD *pmeth, - int (**pverify_init) (EVP_PKEY_CTX *ctx), - int (**pverify) (EVP_PKEY_CTX *ctx, - const unsigned char *sig, - size_t siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_get_verify_recover(const EVP_PKEY_METHOD *pmeth, - int (**pverify_recover_init) (EVP_PKEY_CTX - *ctx), - int (**pverify_recover) (EVP_PKEY_CTX - *ctx, - unsigned char - *sig, - size_t *siglen, - const unsigned - char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_get_signctx(const EVP_PKEY_METHOD *pmeth, - int (**psignctx_init) (EVP_PKEY_CTX *ctx, - EVP_MD_CTX *mctx), - int (**psignctx) (EVP_PKEY_CTX *ctx, - unsigned char *sig, - size_t *siglen, - EVP_MD_CTX *mctx)); - -void EVP_PKEY_meth_get_verifyctx(const EVP_PKEY_METHOD *pmeth, - int (**pverifyctx_init) (EVP_PKEY_CTX *ctx, - EVP_MD_CTX *mctx), - int (**pverifyctx) (EVP_PKEY_CTX *ctx, - const unsigned char *sig, - int siglen, - EVP_MD_CTX *mctx)); - -void EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD *pmeth, - int (**pencrypt_init) (EVP_PKEY_CTX *ctx), - int (**pencryptfn) (EVP_PKEY_CTX *ctx, - unsigned char *out, - size_t *outlen, - const unsigned char *in, - size_t inlen)); - -void EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD *pmeth, - int (**pdecrypt_init) (EVP_PKEY_CTX *ctx), - int (**pdecrypt) (EVP_PKEY_CTX *ctx, - unsigned char *out, - size_t *outlen, - const unsigned char *in, - size_t inlen)); - -void EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD *pmeth, - int (**pderive_init) (EVP_PKEY_CTX *ctx), - int (**pderive) (EVP_PKEY_CTX *ctx, - unsigned char *key, - size_t *keylen)); - -void EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth, - int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1, - void *p2), - int (**pctrl_str) (EVP_PKEY_CTX *ctx, - const char *type, - const char *value)); - -void EVP_PKEY_meth_get_digestsign(EVP_PKEY_METHOD *pmeth, - int (**digestsign) (EVP_MD_CTX *ctx, - unsigned char *sig, - size_t *siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_get_digestverify(EVP_PKEY_METHOD *pmeth, - int (**digestverify) (EVP_MD_CTX *ctx, - const unsigned char *sig, - size_t siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth, - int (**pcheck) (EVP_PKEY *pkey)); - -void EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD *pmeth, - int (**pcheck) (EVP_PKEY *pkey)); - -void EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD *pmeth, - int (**pcheck) (EVP_PKEY *pkey)); - -void EVP_PKEY_meth_get_digest_custom(EVP_PKEY_METHOD *pmeth, - int (**pdigest_custom) (EVP_PKEY_CTX *ctx, - EVP_MD_CTX *mctx)); -void EVP_add_alg_module(void); - - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/evperr.h b/client/3rd/OpenSSL/include/openssl/evperr.h deleted file mode 100644 index b4ea90ae..00000000 --- a/client/3rd/OpenSSL/include/openssl/evperr.h +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_EVPERR_H -# define HEADER_EVPERR_H - -# include - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_EVP_strings(void); - -/* - * EVP function codes. - */ -# define EVP_F_AESNI_INIT_KEY 165 -# define EVP_F_AESNI_XTS_INIT_KEY 207 -# define EVP_F_AES_GCM_CTRL 196 -# define EVP_F_AES_INIT_KEY 133 -# define EVP_F_AES_OCB_CIPHER 169 -# define EVP_F_AES_T4_INIT_KEY 178 -# define EVP_F_AES_T4_XTS_INIT_KEY 208 -# define EVP_F_AES_WRAP_CIPHER 170 -# define EVP_F_AES_XTS_INIT_KEY 209 -# define EVP_F_ALG_MODULE_INIT 177 -# define EVP_F_ARIA_CCM_INIT_KEY 175 -# define EVP_F_ARIA_GCM_CTRL 197 -# define EVP_F_ARIA_GCM_INIT_KEY 176 -# define EVP_F_ARIA_INIT_KEY 185 -# define EVP_F_B64_NEW 198 -# define EVP_F_CAMELLIA_INIT_KEY 159 -# define EVP_F_CHACHA20_POLY1305_CTRL 182 -# define EVP_F_CMLL_T4_INIT_KEY 179 -# define EVP_F_DES_EDE3_WRAP_CIPHER 171 -# define EVP_F_DO_SIGVER_INIT 161 -# define EVP_F_ENC_NEW 199 -# define EVP_F_EVP_CIPHERINIT_EX 123 -# define EVP_F_EVP_CIPHER_ASN1_TO_PARAM 204 -# define EVP_F_EVP_CIPHER_CTX_COPY 163 -# define EVP_F_EVP_CIPHER_CTX_CTRL 124 -# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 -# define EVP_F_EVP_CIPHER_PARAM_TO_ASN1 205 -# define EVP_F_EVP_DECRYPTFINAL_EX 101 -# define EVP_F_EVP_DECRYPTUPDATE 166 -# define EVP_F_EVP_DIGESTFINALXOF 174 -# define EVP_F_EVP_DIGESTINIT_EX 128 -# define EVP_F_EVP_ENCRYPTDECRYPTUPDATE 219 -# define EVP_F_EVP_ENCRYPTFINAL_EX 127 -# define EVP_F_EVP_ENCRYPTUPDATE 167 -# define EVP_F_EVP_MD_CTX_COPY_EX 110 -# define EVP_F_EVP_MD_SIZE 162 -# define EVP_F_EVP_OPENINIT 102 -# define EVP_F_EVP_PBE_ALG_ADD 115 -# define EVP_F_EVP_PBE_ALG_ADD_TYPE 160 -# define EVP_F_EVP_PBE_CIPHERINIT 116 -# define EVP_F_EVP_PBE_SCRYPT 181 -# define EVP_F_EVP_PKCS82PKEY 111 -# define EVP_F_EVP_PKEY2PKCS8 113 -# define EVP_F_EVP_PKEY_ASN1_ADD0 188 -# define EVP_F_EVP_PKEY_CHECK 186 -# define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 -# define EVP_F_EVP_PKEY_CTX_CTRL 137 -# define EVP_F_EVP_PKEY_CTX_CTRL_STR 150 -# define EVP_F_EVP_PKEY_CTX_DUP 156 -# define EVP_F_EVP_PKEY_CTX_MD 168 -# define EVP_F_EVP_PKEY_DECRYPT 104 -# define EVP_F_EVP_PKEY_DECRYPT_INIT 138 -# define EVP_F_EVP_PKEY_DECRYPT_OLD 151 -# define EVP_F_EVP_PKEY_DERIVE 153 -# define EVP_F_EVP_PKEY_DERIVE_INIT 154 -# define EVP_F_EVP_PKEY_DERIVE_SET_PEER 155 -# define EVP_F_EVP_PKEY_ENCRYPT 105 -# define EVP_F_EVP_PKEY_ENCRYPT_INIT 139 -# define EVP_F_EVP_PKEY_ENCRYPT_OLD 152 -# define EVP_F_EVP_PKEY_GET0_DH 119 -# define EVP_F_EVP_PKEY_GET0_DSA 120 -# define EVP_F_EVP_PKEY_GET0_EC_KEY 131 -# define EVP_F_EVP_PKEY_GET0_HMAC 183 -# define EVP_F_EVP_PKEY_GET0_POLY1305 184 -# define EVP_F_EVP_PKEY_GET0_RSA 121 -# define EVP_F_EVP_PKEY_GET0_SIPHASH 172 -# define EVP_F_EVP_PKEY_GET_RAW_PRIVATE_KEY 202 -# define EVP_F_EVP_PKEY_GET_RAW_PUBLIC_KEY 203 -# define EVP_F_EVP_PKEY_KEYGEN 146 -# define EVP_F_EVP_PKEY_KEYGEN_INIT 147 -# define EVP_F_EVP_PKEY_METH_ADD0 194 -# define EVP_F_EVP_PKEY_METH_NEW 195 -# define EVP_F_EVP_PKEY_NEW 106 -# define EVP_F_EVP_PKEY_NEW_CMAC_KEY 193 -# define EVP_F_EVP_PKEY_NEW_RAW_PRIVATE_KEY 191 -# define EVP_F_EVP_PKEY_NEW_RAW_PUBLIC_KEY 192 -# define EVP_F_EVP_PKEY_PARAMGEN 148 -# define EVP_F_EVP_PKEY_PARAMGEN_INIT 149 -# define EVP_F_EVP_PKEY_PARAM_CHECK 189 -# define EVP_F_EVP_PKEY_PUBLIC_CHECK 190 -# define EVP_F_EVP_PKEY_SET1_ENGINE 187 -# define EVP_F_EVP_PKEY_SET_ALIAS_TYPE 206 -# define EVP_F_EVP_PKEY_SIGN 140 -# define EVP_F_EVP_PKEY_SIGN_INIT 141 -# define EVP_F_EVP_PKEY_VERIFY 142 -# define EVP_F_EVP_PKEY_VERIFY_INIT 143 -# define EVP_F_EVP_PKEY_VERIFY_RECOVER 144 -# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT 145 -# define EVP_F_EVP_SIGNFINAL 107 -# define EVP_F_EVP_VERIFYFINAL 108 -# define EVP_F_INT_CTX_NEW 157 -# define EVP_F_OK_NEW 200 -# define EVP_F_PKCS5_PBE_KEYIVGEN 117 -# define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 -# define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN 164 -# define EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN 180 -# define EVP_F_PKEY_SET_TYPE 158 -# define EVP_F_RC2_MAGIC_TO_METH 109 -# define EVP_F_RC5_CTRL 125 -# define EVP_F_R_32_12_16_INIT_KEY 242 -# define EVP_F_S390X_AES_GCM_CTRL 201 -# define EVP_F_UPDATE 173 - -/* - * EVP reason codes. - */ -# define EVP_R_AES_KEY_SETUP_FAILED 143 -# define EVP_R_ARIA_KEY_SETUP_FAILED 176 -# define EVP_R_BAD_DECRYPT 100 -# define EVP_R_BAD_KEY_LENGTH 195 -# define EVP_R_BUFFER_TOO_SMALL 155 -# define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157 -# define EVP_R_CIPHER_PARAMETER_ERROR 122 -# define EVP_R_COMMAND_NOT_SUPPORTED 147 -# define EVP_R_COPY_ERROR 173 -# define EVP_R_CTRL_NOT_IMPLEMENTED 132 -# define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 -# define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 -# define EVP_R_DECODE_ERROR 114 -# define EVP_R_DIFFERENT_KEY_TYPES 101 -# define EVP_R_DIFFERENT_PARAMETERS 153 -# define EVP_R_ERROR_LOADING_SECTION 165 -# define EVP_R_ERROR_SETTING_FIPS_MODE 166 -# define EVP_R_EXPECTING_AN_HMAC_KEY 174 -# define EVP_R_EXPECTING_AN_RSA_KEY 127 -# define EVP_R_EXPECTING_A_DH_KEY 128 -# define EVP_R_EXPECTING_A_DSA_KEY 129 -# define EVP_R_EXPECTING_A_EC_KEY 142 -# define EVP_R_EXPECTING_A_POLY1305_KEY 164 -# define EVP_R_EXPECTING_A_SIPHASH_KEY 175 -# define EVP_R_FIPS_MODE_NOT_SUPPORTED 167 -# define EVP_R_GET_RAW_KEY_FAILED 182 -# define EVP_R_ILLEGAL_SCRYPT_PARAMETERS 171 -# define EVP_R_INITIALIZATION_ERROR 134 -# define EVP_R_INPUT_NOT_INITIALIZED 111 -# define EVP_R_INVALID_DIGEST 152 -# define EVP_R_INVALID_FIPS_MODE 168 -# define EVP_R_INVALID_IV_LENGTH 194 -# define EVP_R_INVALID_KEY 163 -# define EVP_R_INVALID_KEY_LENGTH 130 -# define EVP_R_INVALID_OPERATION 148 -# define EVP_R_KEYGEN_FAILURE 120 -# define EVP_R_KEY_SETUP_FAILED 180 -# define EVP_R_MEMORY_LIMIT_EXCEEDED 172 -# define EVP_R_MESSAGE_DIGEST_IS_NULL 159 -# define EVP_R_METHOD_NOT_SUPPORTED 144 -# define EVP_R_MISSING_PARAMETERS 103 -# define EVP_R_NOT_XOF_OR_INVALID_LENGTH 178 -# define EVP_R_NO_CIPHER_SET 131 -# define EVP_R_NO_DEFAULT_DIGEST 158 -# define EVP_R_NO_DIGEST_SET 139 -# define EVP_R_NO_KEY_SET 154 -# define EVP_R_NO_OPERATION_SET 149 -# define EVP_R_ONLY_ONESHOT_SUPPORTED 177 -# define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 150 -# define EVP_R_OPERATON_NOT_INITIALIZED 151 -# define EVP_R_OUTPUT_WOULD_OVERFLOW 184 -# define EVP_R_PARTIALLY_OVERLAPPING 162 -# define EVP_R_PBKDF2_ERROR 181 -# define EVP_R_PKEY_APPLICATION_ASN1_METHOD_ALREADY_REGISTERED 179 -# define EVP_R_PRIVATE_KEY_DECODE_ERROR 145 -# define EVP_R_PRIVATE_KEY_ENCODE_ERROR 146 -# define EVP_R_PUBLIC_KEY_NOT_RSA 106 -# define EVP_R_UNKNOWN_CIPHER 160 -# define EVP_R_UNKNOWN_DIGEST 161 -# define EVP_R_UNKNOWN_OPTION 169 -# define EVP_R_UNKNOWN_PBE_ALGORITHM 121 -# define EVP_R_UNSUPPORTED_ALGORITHM 156 -# define EVP_R_UNSUPPORTED_CIPHER 107 -# define EVP_R_UNSUPPORTED_KEYLENGTH 123 -# define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 -# define EVP_R_UNSUPPORTED_KEY_SIZE 108 -# define EVP_R_UNSUPPORTED_NUMBER_OF_ROUNDS 135 -# define EVP_R_UNSUPPORTED_PRF 125 -# define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 -# define EVP_R_UNSUPPORTED_SALT_TYPE 126 -# define EVP_R_WRAP_MODE_NOT_ALLOWED 170 -# define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 -# define EVP_R_XTS_DUPLICATED_KEYS 183 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/hmac.h b/client/3rd/OpenSSL/include/openssl/hmac.h deleted file mode 100644 index 458efc1d..00000000 --- a/client/3rd/OpenSSL/include/openssl/hmac.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_HMAC_H -# define HEADER_HMAC_H - -# include - -# include - -# if OPENSSL_API_COMPAT < 0x10200000L -# define HMAC_MAX_MD_CBLOCK 128 /* Deprecated */ -# endif - -#ifdef __cplusplus -extern "C" { -#endif - -size_t HMAC_size(const HMAC_CTX *e); -HMAC_CTX *HMAC_CTX_new(void); -int HMAC_CTX_reset(HMAC_CTX *ctx); -void HMAC_CTX_free(HMAC_CTX *ctx); - -DEPRECATEDIN_1_1_0(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, - const EVP_MD *md)) - -/*__owur*/ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, - const EVP_MD *md, ENGINE *impl); -/*__owur*/ int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, - size_t len); -/*__owur*/ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, - unsigned int *len); -unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, - const unsigned char *d, size_t n, unsigned char *md, - unsigned int *md_len); -__owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx); - -void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); -const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/idea.h b/client/3rd/OpenSSL/include/openssl/idea.h deleted file mode 100644 index 4334f3ea..00000000 --- a/client/3rd/OpenSSL/include/openssl/idea.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_IDEA_H -# define HEADER_IDEA_H - -# include - -# ifndef OPENSSL_NO_IDEA -# ifdef __cplusplus -extern "C" { -# endif - -typedef unsigned int IDEA_INT; - -# define IDEA_ENCRYPT 1 -# define IDEA_DECRYPT 0 - -# define IDEA_BLOCK 8 -# define IDEA_KEY_LENGTH 16 - -typedef struct idea_key_st { - IDEA_INT data[9][6]; -} IDEA_KEY_SCHEDULE; - -const char *IDEA_options(void); -void IDEA_ecb_encrypt(const unsigned char *in, unsigned char *out, - IDEA_KEY_SCHEDULE *ks); -void IDEA_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); -void IDEA_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); -void IDEA_cbc_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, - int enc); -void IDEA_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, - int *num, int enc); -void IDEA_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, - int *num); -void IDEA_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define idea_options IDEA_options -# define idea_ecb_encrypt IDEA_ecb_encrypt -# define idea_set_encrypt_key IDEA_set_encrypt_key -# define idea_set_decrypt_key IDEA_set_decrypt_key -# define idea_cbc_encrypt IDEA_cbc_encrypt -# define idea_cfb64_encrypt IDEA_cfb64_encrypt -# define idea_ofb64_encrypt IDEA_ofb64_encrypt -# define idea_encrypt IDEA_encrypt -# endif - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/kdf.h b/client/3rd/OpenSSL/include/openssl/kdf.h deleted file mode 100644 index 5abd4c37..00000000 --- a/client/3rd/OpenSSL/include/openssl/kdf.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_KDF_H -# define HEADER_KDF_H - -# include -#ifdef __cplusplus -extern "C" { -#endif - -# define EVP_PKEY_CTRL_TLS_MD (EVP_PKEY_ALG_CTRL) -# define EVP_PKEY_CTRL_TLS_SECRET (EVP_PKEY_ALG_CTRL + 1) -# define EVP_PKEY_CTRL_TLS_SEED (EVP_PKEY_ALG_CTRL + 2) -# define EVP_PKEY_CTRL_HKDF_MD (EVP_PKEY_ALG_CTRL + 3) -# define EVP_PKEY_CTRL_HKDF_SALT (EVP_PKEY_ALG_CTRL + 4) -# define EVP_PKEY_CTRL_HKDF_KEY (EVP_PKEY_ALG_CTRL + 5) -# define EVP_PKEY_CTRL_HKDF_INFO (EVP_PKEY_ALG_CTRL + 6) -# define EVP_PKEY_CTRL_HKDF_MODE (EVP_PKEY_ALG_CTRL + 7) -# define EVP_PKEY_CTRL_PASS (EVP_PKEY_ALG_CTRL + 8) -# define EVP_PKEY_CTRL_SCRYPT_SALT (EVP_PKEY_ALG_CTRL + 9) -# define EVP_PKEY_CTRL_SCRYPT_N (EVP_PKEY_ALG_CTRL + 10) -# define EVP_PKEY_CTRL_SCRYPT_R (EVP_PKEY_ALG_CTRL + 11) -# define EVP_PKEY_CTRL_SCRYPT_P (EVP_PKEY_ALG_CTRL + 12) -# define EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES (EVP_PKEY_ALG_CTRL + 13) - -# define EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND 0 -# define EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY 1 -# define EVP_PKEY_HKDEF_MODE_EXPAND_ONLY 2 - -# define EVP_PKEY_CTX_set_tls1_prf_md(pctx, md) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_TLS_MD, 0, (void *)(md)) - -# define EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, sec, seclen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_TLS_SECRET, seclen, (void *)(sec)) - -# define EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed, seedlen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_TLS_SEED, seedlen, (void *)(seed)) - -# define EVP_PKEY_CTX_set_hkdf_md(pctx, md) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_HKDF_MD, 0, (void *)(md)) - -# define EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, saltlen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_HKDF_SALT, saltlen, (void *)(salt)) - -# define EVP_PKEY_CTX_set1_hkdf_key(pctx, key, keylen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_HKDF_KEY, keylen, (void *)(key)) - -# define EVP_PKEY_CTX_add1_hkdf_info(pctx, info, infolen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_HKDF_INFO, infolen, (void *)(info)) - -# define EVP_PKEY_CTX_hkdf_mode(pctx, mode) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_HKDF_MODE, mode, NULL) - -# define EVP_PKEY_CTX_set1_pbe_pass(pctx, pass, passlen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_PASS, passlen, (void *)(pass)) - -# define EVP_PKEY_CTX_set1_scrypt_salt(pctx, salt, saltlen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_SCRYPT_SALT, saltlen, (void *)(salt)) - -# define EVP_PKEY_CTX_set_scrypt_N(pctx, n) \ - EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_SCRYPT_N, n) - -# define EVP_PKEY_CTX_set_scrypt_r(pctx, r) \ - EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_SCRYPT_R, r) - -# define EVP_PKEY_CTX_set_scrypt_p(pctx, p) \ - EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_SCRYPT_P, p) - -# define EVP_PKEY_CTX_set_scrypt_maxmem_bytes(pctx, maxmem_bytes) \ - EVP_PKEY_CTX_ctrl_uint64(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_SCRYPT_MAXMEM_BYTES, maxmem_bytes) - - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/kdferr.h b/client/3rd/OpenSSL/include/openssl/kdferr.h deleted file mode 100644 index 3f51bd02..00000000 --- a/client/3rd/OpenSSL/include/openssl/kdferr.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_KDFERR_H -# define HEADER_KDFERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_KDF_strings(void); - -/* - * KDF function codes. - */ -# define KDF_F_PKEY_HKDF_CTRL_STR 103 -# define KDF_F_PKEY_HKDF_DERIVE 102 -# define KDF_F_PKEY_HKDF_INIT 108 -# define KDF_F_PKEY_SCRYPT_CTRL_STR 104 -# define KDF_F_PKEY_SCRYPT_CTRL_UINT64 105 -# define KDF_F_PKEY_SCRYPT_DERIVE 109 -# define KDF_F_PKEY_SCRYPT_INIT 106 -# define KDF_F_PKEY_SCRYPT_SET_MEMBUF 107 -# define KDF_F_PKEY_TLS1_PRF_CTRL_STR 100 -# define KDF_F_PKEY_TLS1_PRF_DERIVE 101 -# define KDF_F_PKEY_TLS1_PRF_INIT 110 -# define KDF_F_TLS1_PRF_ALG 111 - -/* - * KDF reason codes. - */ -# define KDF_R_INVALID_DIGEST 100 -# define KDF_R_MISSING_ITERATION_COUNT 109 -# define KDF_R_MISSING_KEY 104 -# define KDF_R_MISSING_MESSAGE_DIGEST 105 -# define KDF_R_MISSING_PARAMETER 101 -# define KDF_R_MISSING_PASS 110 -# define KDF_R_MISSING_SALT 111 -# define KDF_R_MISSING_SECRET 107 -# define KDF_R_MISSING_SEED 106 -# define KDF_R_UNKNOWN_PARAMETER_TYPE 103 -# define KDF_R_VALUE_ERROR 108 -# define KDF_R_VALUE_MISSING 102 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/lhash.h b/client/3rd/OpenSSL/include/openssl/lhash.h deleted file mode 100644 index 2e42d727..00000000 --- a/client/3rd/OpenSSL/include/openssl/lhash.h +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * Header for dynamic hash table routines Author - Eric Young - */ - -#ifndef HEADER_LHASH_H -# define HEADER_LHASH_H - -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct lhash_node_st OPENSSL_LH_NODE; -typedef int (*OPENSSL_LH_COMPFUNC) (const void *, const void *); -typedef unsigned long (*OPENSSL_LH_HASHFUNC) (const void *); -typedef void (*OPENSSL_LH_DOALL_FUNC) (void *); -typedef void (*OPENSSL_LH_DOALL_FUNCARG) (void *, void *); -typedef struct lhash_st OPENSSL_LHASH; - -/* - * Macros for declaring and implementing type-safe wrappers for LHASH - * callbacks. This way, callbacks can be provided to LHASH structures without - * function pointer casting and the macro-defined callbacks provide - * per-variable casting before deferring to the underlying type-specific - * callbacks. NB: It is possible to place a "static" in front of both the - * DECLARE and IMPLEMENT macros if the functions are strictly internal. - */ - -/* First: "hash" functions */ -# define DECLARE_LHASH_HASH_FN(name, o_type) \ - unsigned long name##_LHASH_HASH(const void *); -# define IMPLEMENT_LHASH_HASH_FN(name, o_type) \ - unsigned long name##_LHASH_HASH(const void *arg) { \ - const o_type *a = arg; \ - return name##_hash(a); } -# define LHASH_HASH_FN(name) name##_LHASH_HASH - -/* Second: "compare" functions */ -# define DECLARE_LHASH_COMP_FN(name, o_type) \ - int name##_LHASH_COMP(const void *, const void *); -# define IMPLEMENT_LHASH_COMP_FN(name, o_type) \ - int name##_LHASH_COMP(const void *arg1, const void *arg2) { \ - const o_type *a = arg1; \ - const o_type *b = arg2; \ - return name##_cmp(a,b); } -# define LHASH_COMP_FN(name) name##_LHASH_COMP - -/* Fourth: "doall_arg" functions */ -# define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ - void name##_LHASH_DOALL_ARG(void *, void *); -# define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ - void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \ - o_type *a = arg1; \ - a_type *b = arg2; \ - name##_doall_arg(a, b); } -# define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG - - -# define LH_LOAD_MULT 256 - -int OPENSSL_LH_error(OPENSSL_LHASH *lh); -OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c); -void OPENSSL_LH_free(OPENSSL_LHASH *lh); -void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data); -void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data); -void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data); -void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func); -void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg); -unsigned long OPENSSL_LH_strhash(const char *c); -unsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh); -unsigned long OPENSSL_LH_get_down_load(const OPENSSL_LHASH *lh); -void OPENSSL_LH_set_down_load(OPENSSL_LHASH *lh, unsigned long down_load); - -# ifndef OPENSSL_NO_STDIO -void OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp); -void OPENSSL_LH_node_stats(const OPENSSL_LHASH *lh, FILE *fp); -void OPENSSL_LH_node_usage_stats(const OPENSSL_LHASH *lh, FILE *fp); -# endif -void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out); -void OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, BIO *out); -void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define _LHASH OPENSSL_LHASH -# define LHASH_NODE OPENSSL_LH_NODE -# define lh_error OPENSSL_LH_error -# define lh_new OPENSSL_LH_new -# define lh_free OPENSSL_LH_free -# define lh_insert OPENSSL_LH_insert -# define lh_delete OPENSSL_LH_delete -# define lh_retrieve OPENSSL_LH_retrieve -# define lh_doall OPENSSL_LH_doall -# define lh_doall_arg OPENSSL_LH_doall_arg -# define lh_strhash OPENSSL_LH_strhash -# define lh_num_items OPENSSL_LH_num_items -# ifndef OPENSSL_NO_STDIO -# define lh_stats OPENSSL_LH_stats -# define lh_node_stats OPENSSL_LH_node_stats -# define lh_node_usage_stats OPENSSL_LH_node_usage_stats -# endif -# define lh_stats_bio OPENSSL_LH_stats_bio -# define lh_node_stats_bio OPENSSL_LH_node_stats_bio -# define lh_node_usage_stats_bio OPENSSL_LH_node_usage_stats_bio -# endif - -/* Type checking... */ - -# define LHASH_OF(type) struct lhash_st_##type - -# define DEFINE_LHASH_OF(type) \ - LHASH_OF(type) { union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; }; \ - static ossl_unused ossl_inline LHASH_OF(type) *lh_##type##_new(unsigned long (*hfn)(const type *), \ - int (*cfn)(const type *, const type *)) \ - { \ - return (LHASH_OF(type) *) \ - OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, (OPENSSL_LH_COMPFUNC)cfn); \ - } \ - static ossl_unused ossl_inline void lh_##type##_free(LHASH_OF(type) *lh) \ - { \ - OPENSSL_LH_free((OPENSSL_LHASH *)lh); \ - } \ - static ossl_unused ossl_inline type *lh_##type##_insert(LHASH_OF(type) *lh, type *d) \ - { \ - return (type *)OPENSSL_LH_insert((OPENSSL_LHASH *)lh, d); \ - } \ - static ossl_unused ossl_inline type *lh_##type##_delete(LHASH_OF(type) *lh, const type *d) \ - { \ - return (type *)OPENSSL_LH_delete((OPENSSL_LHASH *)lh, d); \ - } \ - static ossl_unused ossl_inline type *lh_##type##_retrieve(LHASH_OF(type) *lh, const type *d) \ - { \ - return (type *)OPENSSL_LH_retrieve((OPENSSL_LHASH *)lh, d); \ - } \ - static ossl_unused ossl_inline int lh_##type##_error(LHASH_OF(type) *lh) \ - { \ - return OPENSSL_LH_error((OPENSSL_LHASH *)lh); \ - } \ - static ossl_unused ossl_inline unsigned long lh_##type##_num_items(LHASH_OF(type) *lh) \ - { \ - return OPENSSL_LH_num_items((OPENSSL_LHASH *)lh); \ - } \ - static ossl_unused ossl_inline void lh_##type##_node_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ - { \ - OPENSSL_LH_node_stats_bio((const OPENSSL_LHASH *)lh, out); \ - } \ - static ossl_unused ossl_inline void lh_##type##_node_usage_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ - { \ - OPENSSL_LH_node_usage_stats_bio((const OPENSSL_LHASH *)lh, out); \ - } \ - static ossl_unused ossl_inline void lh_##type##_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ - { \ - OPENSSL_LH_stats_bio((const OPENSSL_LHASH *)lh, out); \ - } \ - static ossl_unused ossl_inline unsigned long lh_##type##_get_down_load(LHASH_OF(type) *lh) \ - { \ - return OPENSSL_LH_get_down_load((OPENSSL_LHASH *)lh); \ - } \ - static ossl_unused ossl_inline void lh_##type##_set_down_load(LHASH_OF(type) *lh, unsigned long dl) \ - { \ - OPENSSL_LH_set_down_load((OPENSSL_LHASH *)lh, dl); \ - } \ - static ossl_unused ossl_inline void lh_##type##_doall(LHASH_OF(type) *lh, \ - void (*doall)(type *)) \ - { \ - OPENSSL_LH_doall((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNC)doall); \ - } \ - LHASH_OF(type) - -#define IMPLEMENT_LHASH_DOALL_ARG_CONST(type, argtype) \ - int_implement_lhash_doall(type, argtype, const type) - -#define IMPLEMENT_LHASH_DOALL_ARG(type, argtype) \ - int_implement_lhash_doall(type, argtype, type) - -#define int_implement_lhash_doall(type, argtype, cbargtype) \ - static ossl_unused ossl_inline void \ - lh_##type##_doall_##argtype(LHASH_OF(type) *lh, \ - void (*fn)(cbargtype *, argtype *), \ - argtype *arg) \ - { \ - OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNCARG)fn, (void *)arg); \ - } \ - LHASH_OF(type) - -DEFINE_LHASH_OF(OPENSSL_STRING); -# ifdef _MSC_VER -/* - * push and pop this warning: - * warning C4090: 'function': different 'const' qualifiers - */ -# pragma warning (push) -# pragma warning (disable: 4090) -# endif - -DEFINE_LHASH_OF(OPENSSL_CSTRING); - -# ifdef _MSC_VER -# pragma warning (pop) -# endif - -/* - * If called without higher optimization (min. -xO3) the Oracle Developer - * Studio compiler generates code for the defined (static inline) functions - * above. - * This would later lead to the linker complaining about missing symbols when - * this header file is included but the resulting object is not linked against - * the Crypto library (openssl#6912). - */ -# ifdef __SUNPRO_C -# pragma weak OPENSSL_LH_new -# pragma weak OPENSSL_LH_free -# pragma weak OPENSSL_LH_insert -# pragma weak OPENSSL_LH_delete -# pragma weak OPENSSL_LH_retrieve -# pragma weak OPENSSL_LH_error -# pragma weak OPENSSL_LH_num_items -# pragma weak OPENSSL_LH_node_stats_bio -# pragma weak OPENSSL_LH_node_usage_stats_bio -# pragma weak OPENSSL_LH_stats_bio -# pragma weak OPENSSL_LH_get_down_load -# pragma weak OPENSSL_LH_set_down_load -# pragma weak OPENSSL_LH_doall -# pragma weak OPENSSL_LH_doall_arg -# endif /* __SUNPRO_C */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/md2.h b/client/3rd/OpenSSL/include/openssl/md2.h deleted file mode 100644 index 7faf8e3d..00000000 --- a/client/3rd/OpenSSL/include/openssl/md2.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_MD2_H -# define HEADER_MD2_H - -# include - -# ifndef OPENSSL_NO_MD2 -# include -# ifdef __cplusplus -extern "C" { -# endif - -typedef unsigned char MD2_INT; - -# define MD2_DIGEST_LENGTH 16 -# define MD2_BLOCK 16 - -typedef struct MD2state_st { - unsigned int num; - unsigned char data[MD2_BLOCK]; - MD2_INT cksm[MD2_BLOCK]; - MD2_INT state[MD2_BLOCK]; -} MD2_CTX; - -const char *MD2_options(void); -int MD2_Init(MD2_CTX *c); -int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); -int MD2_Final(unsigned char *md, MD2_CTX *c); -unsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/md4.h b/client/3rd/OpenSSL/include/openssl/md4.h deleted file mode 100644 index 940e29db..00000000 --- a/client/3rd/OpenSSL/include/openssl/md4.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_MD4_H -# define HEADER_MD4_H - -# include - -# ifndef OPENSSL_NO_MD4 -# include -# include -# ifdef __cplusplus -extern "C" { -# endif - -/*- - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! MD4_LONG has to be at least 32 bits wide. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ -# define MD4_LONG unsigned int - -# define MD4_CBLOCK 64 -# define MD4_LBLOCK (MD4_CBLOCK/4) -# define MD4_DIGEST_LENGTH 16 - -typedef struct MD4state_st { - MD4_LONG A, B, C, D; - MD4_LONG Nl, Nh; - MD4_LONG data[MD4_LBLOCK]; - unsigned int num; -} MD4_CTX; - -int MD4_Init(MD4_CTX *c); -int MD4_Update(MD4_CTX *c, const void *data, size_t len); -int MD4_Final(unsigned char *md, MD4_CTX *c); -unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); -void MD4_Transform(MD4_CTX *c, const unsigned char *b); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/md5.h b/client/3rd/OpenSSL/include/openssl/md5.h deleted file mode 100644 index 2deb7721..00000000 --- a/client/3rd/OpenSSL/include/openssl/md5.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_MD5_H -# define HEADER_MD5_H - -# include - -# ifndef OPENSSL_NO_MD5 -# include -# include -# ifdef __cplusplus -extern "C" { -# endif - -/* - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! MD5_LONG has to be at least 32 bits wide. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ -# define MD5_LONG unsigned int - -# define MD5_CBLOCK 64 -# define MD5_LBLOCK (MD5_CBLOCK/4) -# define MD5_DIGEST_LENGTH 16 - -typedef struct MD5state_st { - MD5_LONG A, B, C, D; - MD5_LONG Nl, Nh; - MD5_LONG data[MD5_LBLOCK]; - unsigned int num; -} MD5_CTX; - -int MD5_Init(MD5_CTX *c); -int MD5_Update(MD5_CTX *c, const void *data, size_t len); -int MD5_Final(unsigned char *md, MD5_CTX *c); -unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); -void MD5_Transform(MD5_CTX *c, const unsigned char *b); -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/mdc2.h b/client/3rd/OpenSSL/include/openssl/mdc2.h deleted file mode 100644 index aabd2bfa..00000000 --- a/client/3rd/OpenSSL/include/openssl/mdc2.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_MDC2_H -# define HEADER_MDC2_H - -# include - -#ifndef OPENSSL_NO_MDC2 -# include -# include -# ifdef __cplusplus -extern "C" { -# endif - -# define MDC2_BLOCK 8 -# define MDC2_DIGEST_LENGTH 16 - -typedef struct mdc2_ctx_st { - unsigned int num; - unsigned char data[MDC2_BLOCK]; - DES_cblock h, hh; - int pad_type; /* either 1 or 2, default 1 */ -} MDC2_CTX; - -int MDC2_Init(MDC2_CTX *c); -int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len); -int MDC2_Final(unsigned char *md, MDC2_CTX *c); -unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/modes.h b/client/3rd/OpenSSL/include/openssl/modes.h deleted file mode 100644 index d544f98d..00000000 --- a/client/3rd/OpenSSL/include/openssl/modes.h +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_MODES_H -# define HEADER_MODES_H - -# include - -# ifdef __cplusplus -extern "C" { -# endif -typedef void (*block128_f) (const unsigned char in[16], - unsigned char out[16], const void *key); - -typedef void (*cbc128_f) (const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], int enc); - -typedef void (*ctr128_f) (const unsigned char *in, unsigned char *out, - size_t blocks, const void *key, - const unsigned char ivec[16]); - -typedef void (*ccm128_f) (const unsigned char *in, unsigned char *out, - size_t blocks, const void *key, - const unsigned char ivec[16], - unsigned char cmac[16]); - -void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], block128_f block); -void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], block128_f block); - -void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], - unsigned char ecount_buf[16], unsigned int *num, - block128_f block); - -void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], - unsigned char ecount_buf[16], - unsigned int *num, ctr128_f ctr); - -void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], int *num, - block128_f block); - -void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], int *num, - int enc, block128_f block); -void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const void *key, - unsigned char ivec[16], int *num, - int enc, block128_f block); -void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out, - size_t bits, const void *key, - unsigned char ivec[16], int *num, - int enc, block128_f block); - -size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, - unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], - block128_f block); -size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], cbc128_f cbc); -size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, - unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], - block128_f block); -size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], cbc128_f cbc); - -size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in, - unsigned char *out, size_t len, - const void *key, - unsigned char ivec[16], - block128_f block); -size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], cbc128_f cbc); -size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, - unsigned char *out, size_t len, - const void *key, - unsigned char ivec[16], - block128_f block); -size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], cbc128_f cbc); - -typedef struct gcm128_context GCM128_CONTEXT; - -GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block); -void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block); -void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv, - size_t len); -int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad, - size_t len); -int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, - const unsigned char *in, unsigned char *out, - size_t len); -int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, - const unsigned char *in, unsigned char *out, - size_t len); -int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, - const unsigned char *in, unsigned char *out, - size_t len, ctr128_f stream); -int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, - const unsigned char *in, unsigned char *out, - size_t len, ctr128_f stream); -int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag, - size_t len); -void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len); -void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx); - -typedef struct ccm128_context CCM128_CONTEXT; - -void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx, - unsigned int M, unsigned int L, void *key, - block128_f block); -int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce, - size_t nlen, size_t mlen); -void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad, - size_t alen); -int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, - unsigned char *out, size_t len); -int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, - unsigned char *out, size_t len); -int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, - unsigned char *out, size_t len, - ccm128_f stream); -int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, - unsigned char *out, size_t len, - ccm128_f stream); -size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len); - -typedef struct xts128_context XTS128_CONTEXT; - -int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, - const unsigned char iv[16], - const unsigned char *inp, unsigned char *out, - size_t len, int enc); - -size_t CRYPTO_128_wrap(void *key, const unsigned char *iv, - unsigned char *out, - const unsigned char *in, size_t inlen, - block128_f block); - -size_t CRYPTO_128_unwrap(void *key, const unsigned char *iv, - unsigned char *out, - const unsigned char *in, size_t inlen, - block128_f block); -size_t CRYPTO_128_wrap_pad(void *key, const unsigned char *icv, - unsigned char *out, const unsigned char *in, - size_t inlen, block128_f block); -size_t CRYPTO_128_unwrap_pad(void *key, const unsigned char *icv, - unsigned char *out, const unsigned char *in, - size_t inlen, block128_f block); - -# ifndef OPENSSL_NO_OCB -typedef struct ocb128_context OCB128_CONTEXT; - -typedef void (*ocb128_f) (const unsigned char *in, unsigned char *out, - size_t blocks, const void *key, - size_t start_block_num, - unsigned char offset_i[16], - const unsigned char L_[][16], - unsigned char checksum[16]); - -OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec, - block128_f encrypt, block128_f decrypt, - ocb128_f stream); -int CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec, - block128_f encrypt, block128_f decrypt, - ocb128_f stream); -int CRYPTO_ocb128_copy_ctx(OCB128_CONTEXT *dest, OCB128_CONTEXT *src, - void *keyenc, void *keydec); -int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv, - size_t len, size_t taglen); -int CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad, - size_t len); -int CRYPTO_ocb128_encrypt(OCB128_CONTEXT *ctx, const unsigned char *in, - unsigned char *out, size_t len); -int CRYPTO_ocb128_decrypt(OCB128_CONTEXT *ctx, const unsigned char *in, - unsigned char *out, size_t len); -int CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag, - size_t len); -int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len); -void CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx); -# endif /* OPENSSL_NO_OCB */ - -# ifdef __cplusplus -} -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/obj_mac.h b/client/3rd/OpenSSL/include/openssl/obj_mac.h deleted file mode 100644 index eb812ed1..00000000 --- a/client/3rd/OpenSSL/include/openssl/obj_mac.h +++ /dev/null @@ -1,5198 +0,0 @@ -/* - * WARNING: do not edit! - * Generated by crypto/objects/objects.pl - * - * Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#define SN_undef "UNDEF" -#define LN_undef "undefined" -#define NID_undef 0 -#define OBJ_undef 0L - -#define SN_itu_t "ITU-T" -#define LN_itu_t "itu-t" -#define NID_itu_t 645 -#define OBJ_itu_t 0L - -#define NID_ccitt 404 -#define OBJ_ccitt OBJ_itu_t - -#define SN_iso "ISO" -#define LN_iso "iso" -#define NID_iso 181 -#define OBJ_iso 1L - -#define SN_joint_iso_itu_t "JOINT-ISO-ITU-T" -#define LN_joint_iso_itu_t "joint-iso-itu-t" -#define NID_joint_iso_itu_t 646 -#define OBJ_joint_iso_itu_t 2L - -#define NID_joint_iso_ccitt 393 -#define OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t - -#define SN_member_body "member-body" -#define LN_member_body "ISO Member Body" -#define NID_member_body 182 -#define OBJ_member_body OBJ_iso,2L - -#define SN_identified_organization "identified-organization" -#define NID_identified_organization 676 -#define OBJ_identified_organization OBJ_iso,3L - -#define SN_hmac_md5 "HMAC-MD5" -#define LN_hmac_md5 "hmac-md5" -#define NID_hmac_md5 780 -#define OBJ_hmac_md5 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L - -#define SN_hmac_sha1 "HMAC-SHA1" -#define LN_hmac_sha1 "hmac-sha1" -#define NID_hmac_sha1 781 -#define OBJ_hmac_sha1 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L - -#define SN_x509ExtAdmission "x509ExtAdmission" -#define LN_x509ExtAdmission "Professional Information or basis for Admission" -#define NID_x509ExtAdmission 1093 -#define OBJ_x509ExtAdmission OBJ_identified_organization,36L,8L,3L,3L - -#define SN_certicom_arc "certicom-arc" -#define NID_certicom_arc 677 -#define OBJ_certicom_arc OBJ_identified_organization,132L - -#define SN_ieee "ieee" -#define NID_ieee 1170 -#define OBJ_ieee OBJ_identified_organization,111L - -#define SN_ieee_siswg "ieee-siswg" -#define LN_ieee_siswg "IEEE Security in Storage Working Group" -#define NID_ieee_siswg 1171 -#define OBJ_ieee_siswg OBJ_ieee,2L,1619L - -#define SN_international_organizations "international-organizations" -#define LN_international_organizations "International Organizations" -#define NID_international_organizations 647 -#define OBJ_international_organizations OBJ_joint_iso_itu_t,23L - -#define SN_wap "wap" -#define NID_wap 678 -#define OBJ_wap OBJ_international_organizations,43L - -#define SN_wap_wsg "wap-wsg" -#define NID_wap_wsg 679 -#define OBJ_wap_wsg OBJ_wap,1L - -#define SN_selected_attribute_types "selected-attribute-types" -#define LN_selected_attribute_types "Selected Attribute Types" -#define NID_selected_attribute_types 394 -#define OBJ_selected_attribute_types OBJ_joint_iso_itu_t,5L,1L,5L - -#define SN_clearance "clearance" -#define NID_clearance 395 -#define OBJ_clearance OBJ_selected_attribute_types,55L - -#define SN_ISO_US "ISO-US" -#define LN_ISO_US "ISO US Member Body" -#define NID_ISO_US 183 -#define OBJ_ISO_US OBJ_member_body,840L - -#define SN_X9_57 "X9-57" -#define LN_X9_57 "X9.57" -#define NID_X9_57 184 -#define OBJ_X9_57 OBJ_ISO_US,10040L - -#define SN_X9cm "X9cm" -#define LN_X9cm "X9.57 CM ?" -#define NID_X9cm 185 -#define OBJ_X9cm OBJ_X9_57,4L - -#define SN_ISO_CN "ISO-CN" -#define LN_ISO_CN "ISO CN Member Body" -#define NID_ISO_CN 1140 -#define OBJ_ISO_CN OBJ_member_body,156L - -#define SN_oscca "oscca" -#define NID_oscca 1141 -#define OBJ_oscca OBJ_ISO_CN,10197L - -#define SN_sm_scheme "sm-scheme" -#define NID_sm_scheme 1142 -#define OBJ_sm_scheme OBJ_oscca,1L - -#define SN_dsa "DSA" -#define LN_dsa "dsaEncryption" -#define NID_dsa 116 -#define OBJ_dsa OBJ_X9cm,1L - -#define SN_dsaWithSHA1 "DSA-SHA1" -#define LN_dsaWithSHA1 "dsaWithSHA1" -#define NID_dsaWithSHA1 113 -#define OBJ_dsaWithSHA1 OBJ_X9cm,3L - -#define SN_ansi_X9_62 "ansi-X9-62" -#define LN_ansi_X9_62 "ANSI X9.62" -#define NID_ansi_X9_62 405 -#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L - -#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L - -#define SN_X9_62_prime_field "prime-field" -#define NID_X9_62_prime_field 406 -#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L - -#define SN_X9_62_characteristic_two_field "characteristic-two-field" -#define NID_X9_62_characteristic_two_field 407 -#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L - -#define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis" -#define NID_X9_62_id_characteristic_two_basis 680 -#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field,3L - -#define SN_X9_62_onBasis "onBasis" -#define NID_X9_62_onBasis 681 -#define OBJ_X9_62_onBasis OBJ_X9_62_id_characteristic_two_basis,1L - -#define SN_X9_62_tpBasis "tpBasis" -#define NID_X9_62_tpBasis 682 -#define OBJ_X9_62_tpBasis OBJ_X9_62_id_characteristic_two_basis,2L - -#define SN_X9_62_ppBasis "ppBasis" -#define NID_X9_62_ppBasis 683 -#define OBJ_X9_62_ppBasis OBJ_X9_62_id_characteristic_two_basis,3L - -#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L - -#define SN_X9_62_id_ecPublicKey "id-ecPublicKey" -#define NID_X9_62_id_ecPublicKey 408 -#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L - -#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L - -#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L - -#define SN_X9_62_c2pnb163v1 "c2pnb163v1" -#define NID_X9_62_c2pnb163v1 684 -#define OBJ_X9_62_c2pnb163v1 OBJ_X9_62_c_TwoCurve,1L - -#define SN_X9_62_c2pnb163v2 "c2pnb163v2" -#define NID_X9_62_c2pnb163v2 685 -#define OBJ_X9_62_c2pnb163v2 OBJ_X9_62_c_TwoCurve,2L - -#define SN_X9_62_c2pnb163v3 "c2pnb163v3" -#define NID_X9_62_c2pnb163v3 686 -#define OBJ_X9_62_c2pnb163v3 OBJ_X9_62_c_TwoCurve,3L - -#define SN_X9_62_c2pnb176v1 "c2pnb176v1" -#define NID_X9_62_c2pnb176v1 687 -#define OBJ_X9_62_c2pnb176v1 OBJ_X9_62_c_TwoCurve,4L - -#define SN_X9_62_c2tnb191v1 "c2tnb191v1" -#define NID_X9_62_c2tnb191v1 688 -#define OBJ_X9_62_c2tnb191v1 OBJ_X9_62_c_TwoCurve,5L - -#define SN_X9_62_c2tnb191v2 "c2tnb191v2" -#define NID_X9_62_c2tnb191v2 689 -#define OBJ_X9_62_c2tnb191v2 OBJ_X9_62_c_TwoCurve,6L - -#define SN_X9_62_c2tnb191v3 "c2tnb191v3" -#define NID_X9_62_c2tnb191v3 690 -#define OBJ_X9_62_c2tnb191v3 OBJ_X9_62_c_TwoCurve,7L - -#define SN_X9_62_c2onb191v4 "c2onb191v4" -#define NID_X9_62_c2onb191v4 691 -#define OBJ_X9_62_c2onb191v4 OBJ_X9_62_c_TwoCurve,8L - -#define SN_X9_62_c2onb191v5 "c2onb191v5" -#define NID_X9_62_c2onb191v5 692 -#define OBJ_X9_62_c2onb191v5 OBJ_X9_62_c_TwoCurve,9L - -#define SN_X9_62_c2pnb208w1 "c2pnb208w1" -#define NID_X9_62_c2pnb208w1 693 -#define OBJ_X9_62_c2pnb208w1 OBJ_X9_62_c_TwoCurve,10L - -#define SN_X9_62_c2tnb239v1 "c2tnb239v1" -#define NID_X9_62_c2tnb239v1 694 -#define OBJ_X9_62_c2tnb239v1 OBJ_X9_62_c_TwoCurve,11L - -#define SN_X9_62_c2tnb239v2 "c2tnb239v2" -#define NID_X9_62_c2tnb239v2 695 -#define OBJ_X9_62_c2tnb239v2 OBJ_X9_62_c_TwoCurve,12L - -#define SN_X9_62_c2tnb239v3 "c2tnb239v3" -#define NID_X9_62_c2tnb239v3 696 -#define OBJ_X9_62_c2tnb239v3 OBJ_X9_62_c_TwoCurve,13L - -#define SN_X9_62_c2onb239v4 "c2onb239v4" -#define NID_X9_62_c2onb239v4 697 -#define OBJ_X9_62_c2onb239v4 OBJ_X9_62_c_TwoCurve,14L - -#define SN_X9_62_c2onb239v5 "c2onb239v5" -#define NID_X9_62_c2onb239v5 698 -#define OBJ_X9_62_c2onb239v5 OBJ_X9_62_c_TwoCurve,15L - -#define SN_X9_62_c2pnb272w1 "c2pnb272w1" -#define NID_X9_62_c2pnb272w1 699 -#define OBJ_X9_62_c2pnb272w1 OBJ_X9_62_c_TwoCurve,16L - -#define SN_X9_62_c2pnb304w1 "c2pnb304w1" -#define NID_X9_62_c2pnb304w1 700 -#define OBJ_X9_62_c2pnb304w1 OBJ_X9_62_c_TwoCurve,17L - -#define SN_X9_62_c2tnb359v1 "c2tnb359v1" -#define NID_X9_62_c2tnb359v1 701 -#define OBJ_X9_62_c2tnb359v1 OBJ_X9_62_c_TwoCurve,18L - -#define SN_X9_62_c2pnb368w1 "c2pnb368w1" -#define NID_X9_62_c2pnb368w1 702 -#define OBJ_X9_62_c2pnb368w1 OBJ_X9_62_c_TwoCurve,19L - -#define SN_X9_62_c2tnb431r1 "c2tnb431r1" -#define NID_X9_62_c2tnb431r1 703 -#define OBJ_X9_62_c2tnb431r1 OBJ_X9_62_c_TwoCurve,20L - -#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L - -#define SN_X9_62_prime192v1 "prime192v1" -#define NID_X9_62_prime192v1 409 -#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L - -#define SN_X9_62_prime192v2 "prime192v2" -#define NID_X9_62_prime192v2 410 -#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L - -#define SN_X9_62_prime192v3 "prime192v3" -#define NID_X9_62_prime192v3 411 -#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L - -#define SN_X9_62_prime239v1 "prime239v1" -#define NID_X9_62_prime239v1 412 -#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L - -#define SN_X9_62_prime239v2 "prime239v2" -#define NID_X9_62_prime239v2 413 -#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L - -#define SN_X9_62_prime239v3 "prime239v3" -#define NID_X9_62_prime239v3 414 -#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L - -#define SN_X9_62_prime256v1 "prime256v1" -#define NID_X9_62_prime256v1 415 -#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L - -#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L - -#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1" -#define NID_ecdsa_with_SHA1 416 -#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L - -#define SN_ecdsa_with_Recommended "ecdsa-with-Recommended" -#define NID_ecdsa_with_Recommended 791 -#define OBJ_ecdsa_with_Recommended OBJ_X9_62_id_ecSigType,2L - -#define SN_ecdsa_with_Specified "ecdsa-with-Specified" -#define NID_ecdsa_with_Specified 792 -#define OBJ_ecdsa_with_Specified OBJ_X9_62_id_ecSigType,3L - -#define SN_ecdsa_with_SHA224 "ecdsa-with-SHA224" -#define NID_ecdsa_with_SHA224 793 -#define OBJ_ecdsa_with_SHA224 OBJ_ecdsa_with_Specified,1L - -#define SN_ecdsa_with_SHA256 "ecdsa-with-SHA256" -#define NID_ecdsa_with_SHA256 794 -#define OBJ_ecdsa_with_SHA256 OBJ_ecdsa_with_Specified,2L - -#define SN_ecdsa_with_SHA384 "ecdsa-with-SHA384" -#define NID_ecdsa_with_SHA384 795 -#define OBJ_ecdsa_with_SHA384 OBJ_ecdsa_with_Specified,3L - -#define SN_ecdsa_with_SHA512 "ecdsa-with-SHA512" -#define NID_ecdsa_with_SHA512 796 -#define OBJ_ecdsa_with_SHA512 OBJ_ecdsa_with_Specified,4L - -#define OBJ_secg_ellipticCurve OBJ_certicom_arc,0L - -#define SN_secp112r1 "secp112r1" -#define NID_secp112r1 704 -#define OBJ_secp112r1 OBJ_secg_ellipticCurve,6L - -#define SN_secp112r2 "secp112r2" -#define NID_secp112r2 705 -#define OBJ_secp112r2 OBJ_secg_ellipticCurve,7L - -#define SN_secp128r1 "secp128r1" -#define NID_secp128r1 706 -#define OBJ_secp128r1 OBJ_secg_ellipticCurve,28L - -#define SN_secp128r2 "secp128r2" -#define NID_secp128r2 707 -#define OBJ_secp128r2 OBJ_secg_ellipticCurve,29L - -#define SN_secp160k1 "secp160k1" -#define NID_secp160k1 708 -#define OBJ_secp160k1 OBJ_secg_ellipticCurve,9L - -#define SN_secp160r1 "secp160r1" -#define NID_secp160r1 709 -#define OBJ_secp160r1 OBJ_secg_ellipticCurve,8L - -#define SN_secp160r2 "secp160r2" -#define NID_secp160r2 710 -#define OBJ_secp160r2 OBJ_secg_ellipticCurve,30L - -#define SN_secp192k1 "secp192k1" -#define NID_secp192k1 711 -#define OBJ_secp192k1 OBJ_secg_ellipticCurve,31L - -#define SN_secp224k1 "secp224k1" -#define NID_secp224k1 712 -#define OBJ_secp224k1 OBJ_secg_ellipticCurve,32L - -#define SN_secp224r1 "secp224r1" -#define NID_secp224r1 713 -#define OBJ_secp224r1 OBJ_secg_ellipticCurve,33L - -#define SN_secp256k1 "secp256k1" -#define NID_secp256k1 714 -#define OBJ_secp256k1 OBJ_secg_ellipticCurve,10L - -#define SN_secp384r1 "secp384r1" -#define NID_secp384r1 715 -#define OBJ_secp384r1 OBJ_secg_ellipticCurve,34L - -#define SN_secp521r1 "secp521r1" -#define NID_secp521r1 716 -#define OBJ_secp521r1 OBJ_secg_ellipticCurve,35L - -#define SN_sect113r1 "sect113r1" -#define NID_sect113r1 717 -#define OBJ_sect113r1 OBJ_secg_ellipticCurve,4L - -#define SN_sect113r2 "sect113r2" -#define NID_sect113r2 718 -#define OBJ_sect113r2 OBJ_secg_ellipticCurve,5L - -#define SN_sect131r1 "sect131r1" -#define NID_sect131r1 719 -#define OBJ_sect131r1 OBJ_secg_ellipticCurve,22L - -#define SN_sect131r2 "sect131r2" -#define NID_sect131r2 720 -#define OBJ_sect131r2 OBJ_secg_ellipticCurve,23L - -#define SN_sect163k1 "sect163k1" -#define NID_sect163k1 721 -#define OBJ_sect163k1 OBJ_secg_ellipticCurve,1L - -#define SN_sect163r1 "sect163r1" -#define NID_sect163r1 722 -#define OBJ_sect163r1 OBJ_secg_ellipticCurve,2L - -#define SN_sect163r2 "sect163r2" -#define NID_sect163r2 723 -#define OBJ_sect163r2 OBJ_secg_ellipticCurve,15L - -#define SN_sect193r1 "sect193r1" -#define NID_sect193r1 724 -#define OBJ_sect193r1 OBJ_secg_ellipticCurve,24L - -#define SN_sect193r2 "sect193r2" -#define NID_sect193r2 725 -#define OBJ_sect193r2 OBJ_secg_ellipticCurve,25L - -#define SN_sect233k1 "sect233k1" -#define NID_sect233k1 726 -#define OBJ_sect233k1 OBJ_secg_ellipticCurve,26L - -#define SN_sect233r1 "sect233r1" -#define NID_sect233r1 727 -#define OBJ_sect233r1 OBJ_secg_ellipticCurve,27L - -#define SN_sect239k1 "sect239k1" -#define NID_sect239k1 728 -#define OBJ_sect239k1 OBJ_secg_ellipticCurve,3L - -#define SN_sect283k1 "sect283k1" -#define NID_sect283k1 729 -#define OBJ_sect283k1 OBJ_secg_ellipticCurve,16L - -#define SN_sect283r1 "sect283r1" -#define NID_sect283r1 730 -#define OBJ_sect283r1 OBJ_secg_ellipticCurve,17L - -#define SN_sect409k1 "sect409k1" -#define NID_sect409k1 731 -#define OBJ_sect409k1 OBJ_secg_ellipticCurve,36L - -#define SN_sect409r1 "sect409r1" -#define NID_sect409r1 732 -#define OBJ_sect409r1 OBJ_secg_ellipticCurve,37L - -#define SN_sect571k1 "sect571k1" -#define NID_sect571k1 733 -#define OBJ_sect571k1 OBJ_secg_ellipticCurve,38L - -#define SN_sect571r1 "sect571r1" -#define NID_sect571r1 734 -#define OBJ_sect571r1 OBJ_secg_ellipticCurve,39L - -#define OBJ_wap_wsg_idm_ecid OBJ_wap_wsg,4L - -#define SN_wap_wsg_idm_ecid_wtls1 "wap-wsg-idm-ecid-wtls1" -#define NID_wap_wsg_idm_ecid_wtls1 735 -#define OBJ_wap_wsg_idm_ecid_wtls1 OBJ_wap_wsg_idm_ecid,1L - -#define SN_wap_wsg_idm_ecid_wtls3 "wap-wsg-idm-ecid-wtls3" -#define NID_wap_wsg_idm_ecid_wtls3 736 -#define OBJ_wap_wsg_idm_ecid_wtls3 OBJ_wap_wsg_idm_ecid,3L - -#define SN_wap_wsg_idm_ecid_wtls4 "wap-wsg-idm-ecid-wtls4" -#define NID_wap_wsg_idm_ecid_wtls4 737 -#define OBJ_wap_wsg_idm_ecid_wtls4 OBJ_wap_wsg_idm_ecid,4L - -#define SN_wap_wsg_idm_ecid_wtls5 "wap-wsg-idm-ecid-wtls5" -#define NID_wap_wsg_idm_ecid_wtls5 738 -#define OBJ_wap_wsg_idm_ecid_wtls5 OBJ_wap_wsg_idm_ecid,5L - -#define SN_wap_wsg_idm_ecid_wtls6 "wap-wsg-idm-ecid-wtls6" -#define NID_wap_wsg_idm_ecid_wtls6 739 -#define OBJ_wap_wsg_idm_ecid_wtls6 OBJ_wap_wsg_idm_ecid,6L - -#define SN_wap_wsg_idm_ecid_wtls7 "wap-wsg-idm-ecid-wtls7" -#define NID_wap_wsg_idm_ecid_wtls7 740 -#define OBJ_wap_wsg_idm_ecid_wtls7 OBJ_wap_wsg_idm_ecid,7L - -#define SN_wap_wsg_idm_ecid_wtls8 "wap-wsg-idm-ecid-wtls8" -#define NID_wap_wsg_idm_ecid_wtls8 741 -#define OBJ_wap_wsg_idm_ecid_wtls8 OBJ_wap_wsg_idm_ecid,8L - -#define SN_wap_wsg_idm_ecid_wtls9 "wap-wsg-idm-ecid-wtls9" -#define NID_wap_wsg_idm_ecid_wtls9 742 -#define OBJ_wap_wsg_idm_ecid_wtls9 OBJ_wap_wsg_idm_ecid,9L - -#define SN_wap_wsg_idm_ecid_wtls10 "wap-wsg-idm-ecid-wtls10" -#define NID_wap_wsg_idm_ecid_wtls10 743 -#define OBJ_wap_wsg_idm_ecid_wtls10 OBJ_wap_wsg_idm_ecid,10L - -#define SN_wap_wsg_idm_ecid_wtls11 "wap-wsg-idm-ecid-wtls11" -#define NID_wap_wsg_idm_ecid_wtls11 744 -#define OBJ_wap_wsg_idm_ecid_wtls11 OBJ_wap_wsg_idm_ecid,11L - -#define SN_wap_wsg_idm_ecid_wtls12 "wap-wsg-idm-ecid-wtls12" -#define NID_wap_wsg_idm_ecid_wtls12 745 -#define OBJ_wap_wsg_idm_ecid_wtls12 OBJ_wap_wsg_idm_ecid,12L - -#define SN_cast5_cbc "CAST5-CBC" -#define LN_cast5_cbc "cast5-cbc" -#define NID_cast5_cbc 108 -#define OBJ_cast5_cbc OBJ_ISO_US,113533L,7L,66L,10L - -#define SN_cast5_ecb "CAST5-ECB" -#define LN_cast5_ecb "cast5-ecb" -#define NID_cast5_ecb 109 - -#define SN_cast5_cfb64 "CAST5-CFB" -#define LN_cast5_cfb64 "cast5-cfb" -#define NID_cast5_cfb64 110 - -#define SN_cast5_ofb64 "CAST5-OFB" -#define LN_cast5_ofb64 "cast5-ofb" -#define NID_cast5_ofb64 111 - -#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" -#define NID_pbeWithMD5AndCast5_CBC 112 -#define OBJ_pbeWithMD5AndCast5_CBC OBJ_ISO_US,113533L,7L,66L,12L - -#define SN_id_PasswordBasedMAC "id-PasswordBasedMAC" -#define LN_id_PasswordBasedMAC "password based MAC" -#define NID_id_PasswordBasedMAC 782 -#define OBJ_id_PasswordBasedMAC OBJ_ISO_US,113533L,7L,66L,13L - -#define SN_id_DHBasedMac "id-DHBasedMac" -#define LN_id_DHBasedMac "Diffie-Hellman based MAC" -#define NID_id_DHBasedMac 783 -#define OBJ_id_DHBasedMac OBJ_ISO_US,113533L,7L,66L,30L - -#define SN_rsadsi "rsadsi" -#define LN_rsadsi "RSA Data Security, Inc." -#define NID_rsadsi 1 -#define OBJ_rsadsi OBJ_ISO_US,113549L - -#define SN_pkcs "pkcs" -#define LN_pkcs "RSA Data Security, Inc. PKCS" -#define NID_pkcs 2 -#define OBJ_pkcs OBJ_rsadsi,1L - -#define SN_pkcs1 "pkcs1" -#define NID_pkcs1 186 -#define OBJ_pkcs1 OBJ_pkcs,1L - -#define LN_rsaEncryption "rsaEncryption" -#define NID_rsaEncryption 6 -#define OBJ_rsaEncryption OBJ_pkcs1,1L - -#define SN_md2WithRSAEncryption "RSA-MD2" -#define LN_md2WithRSAEncryption "md2WithRSAEncryption" -#define NID_md2WithRSAEncryption 7 -#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L - -#define SN_md4WithRSAEncryption "RSA-MD4" -#define LN_md4WithRSAEncryption "md4WithRSAEncryption" -#define NID_md4WithRSAEncryption 396 -#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L - -#define SN_md5WithRSAEncryption "RSA-MD5" -#define LN_md5WithRSAEncryption "md5WithRSAEncryption" -#define NID_md5WithRSAEncryption 8 -#define OBJ_md5WithRSAEncryption OBJ_pkcs1,4L - -#define SN_sha1WithRSAEncryption "RSA-SHA1" -#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" -#define NID_sha1WithRSAEncryption 65 -#define OBJ_sha1WithRSAEncryption OBJ_pkcs1,5L - -#define SN_rsaesOaep "RSAES-OAEP" -#define LN_rsaesOaep "rsaesOaep" -#define NID_rsaesOaep 919 -#define OBJ_rsaesOaep OBJ_pkcs1,7L - -#define SN_mgf1 "MGF1" -#define LN_mgf1 "mgf1" -#define NID_mgf1 911 -#define OBJ_mgf1 OBJ_pkcs1,8L - -#define SN_pSpecified "PSPECIFIED" -#define LN_pSpecified "pSpecified" -#define NID_pSpecified 935 -#define OBJ_pSpecified OBJ_pkcs1,9L - -#define SN_rsassaPss "RSASSA-PSS" -#define LN_rsassaPss "rsassaPss" -#define NID_rsassaPss 912 -#define OBJ_rsassaPss OBJ_pkcs1,10L - -#define SN_sha256WithRSAEncryption "RSA-SHA256" -#define LN_sha256WithRSAEncryption "sha256WithRSAEncryption" -#define NID_sha256WithRSAEncryption 668 -#define OBJ_sha256WithRSAEncryption OBJ_pkcs1,11L - -#define SN_sha384WithRSAEncryption "RSA-SHA384" -#define LN_sha384WithRSAEncryption "sha384WithRSAEncryption" -#define NID_sha384WithRSAEncryption 669 -#define OBJ_sha384WithRSAEncryption OBJ_pkcs1,12L - -#define SN_sha512WithRSAEncryption "RSA-SHA512" -#define LN_sha512WithRSAEncryption "sha512WithRSAEncryption" -#define NID_sha512WithRSAEncryption 670 -#define OBJ_sha512WithRSAEncryption OBJ_pkcs1,13L - -#define SN_sha224WithRSAEncryption "RSA-SHA224" -#define LN_sha224WithRSAEncryption "sha224WithRSAEncryption" -#define NID_sha224WithRSAEncryption 671 -#define OBJ_sha224WithRSAEncryption OBJ_pkcs1,14L - -#define SN_sha512_224WithRSAEncryption "RSA-SHA512/224" -#define LN_sha512_224WithRSAEncryption "sha512-224WithRSAEncryption" -#define NID_sha512_224WithRSAEncryption 1145 -#define OBJ_sha512_224WithRSAEncryption OBJ_pkcs1,15L - -#define SN_sha512_256WithRSAEncryption "RSA-SHA512/256" -#define LN_sha512_256WithRSAEncryption "sha512-256WithRSAEncryption" -#define NID_sha512_256WithRSAEncryption 1146 -#define OBJ_sha512_256WithRSAEncryption OBJ_pkcs1,16L - -#define SN_pkcs3 "pkcs3" -#define NID_pkcs3 27 -#define OBJ_pkcs3 OBJ_pkcs,3L - -#define LN_dhKeyAgreement "dhKeyAgreement" -#define NID_dhKeyAgreement 28 -#define OBJ_dhKeyAgreement OBJ_pkcs3,1L - -#define SN_pkcs5 "pkcs5" -#define NID_pkcs5 187 -#define OBJ_pkcs5 OBJ_pkcs,5L - -#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" -#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" -#define NID_pbeWithMD2AndDES_CBC 9 -#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs5,1L - -#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" -#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" -#define NID_pbeWithMD5AndDES_CBC 10 -#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs5,3L - -#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" -#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" -#define NID_pbeWithMD2AndRC2_CBC 168 -#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs5,4L - -#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" -#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" -#define NID_pbeWithMD5AndRC2_CBC 169 -#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs5,6L - -#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" -#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" -#define NID_pbeWithSHA1AndDES_CBC 170 -#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs5,10L - -#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" -#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" -#define NID_pbeWithSHA1AndRC2_CBC 68 -#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs5,11L - -#define LN_id_pbkdf2 "PBKDF2" -#define NID_id_pbkdf2 69 -#define OBJ_id_pbkdf2 OBJ_pkcs5,12L - -#define LN_pbes2 "PBES2" -#define NID_pbes2 161 -#define OBJ_pbes2 OBJ_pkcs5,13L - -#define LN_pbmac1 "PBMAC1" -#define NID_pbmac1 162 -#define OBJ_pbmac1 OBJ_pkcs5,14L - -#define SN_pkcs7 "pkcs7" -#define NID_pkcs7 20 -#define OBJ_pkcs7 OBJ_pkcs,7L - -#define LN_pkcs7_data "pkcs7-data" -#define NID_pkcs7_data 21 -#define OBJ_pkcs7_data OBJ_pkcs7,1L - -#define LN_pkcs7_signed "pkcs7-signedData" -#define NID_pkcs7_signed 22 -#define OBJ_pkcs7_signed OBJ_pkcs7,2L - -#define LN_pkcs7_enveloped "pkcs7-envelopedData" -#define NID_pkcs7_enveloped 23 -#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L - -#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" -#define NID_pkcs7_signedAndEnveloped 24 -#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L - -#define LN_pkcs7_digest "pkcs7-digestData" -#define NID_pkcs7_digest 25 -#define OBJ_pkcs7_digest OBJ_pkcs7,5L - -#define LN_pkcs7_encrypted "pkcs7-encryptedData" -#define NID_pkcs7_encrypted 26 -#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L - -#define SN_pkcs9 "pkcs9" -#define NID_pkcs9 47 -#define OBJ_pkcs9 OBJ_pkcs,9L - -#define LN_pkcs9_emailAddress "emailAddress" -#define NID_pkcs9_emailAddress 48 -#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L - -#define LN_pkcs9_unstructuredName "unstructuredName" -#define NID_pkcs9_unstructuredName 49 -#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L - -#define LN_pkcs9_contentType "contentType" -#define NID_pkcs9_contentType 50 -#define OBJ_pkcs9_contentType OBJ_pkcs9,3L - -#define LN_pkcs9_messageDigest "messageDigest" -#define NID_pkcs9_messageDigest 51 -#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L - -#define LN_pkcs9_signingTime "signingTime" -#define NID_pkcs9_signingTime 52 -#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L - -#define LN_pkcs9_countersignature "countersignature" -#define NID_pkcs9_countersignature 53 -#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L - -#define LN_pkcs9_challengePassword "challengePassword" -#define NID_pkcs9_challengePassword 54 -#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L - -#define LN_pkcs9_unstructuredAddress "unstructuredAddress" -#define NID_pkcs9_unstructuredAddress 55 -#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L - -#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" -#define NID_pkcs9_extCertAttributes 56 -#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L - -#define SN_ext_req "extReq" -#define LN_ext_req "Extension Request" -#define NID_ext_req 172 -#define OBJ_ext_req OBJ_pkcs9,14L - -#define SN_SMIMECapabilities "SMIME-CAPS" -#define LN_SMIMECapabilities "S/MIME Capabilities" -#define NID_SMIMECapabilities 167 -#define OBJ_SMIMECapabilities OBJ_pkcs9,15L - -#define SN_SMIME "SMIME" -#define LN_SMIME "S/MIME" -#define NID_SMIME 188 -#define OBJ_SMIME OBJ_pkcs9,16L - -#define SN_id_smime_mod "id-smime-mod" -#define NID_id_smime_mod 189 -#define OBJ_id_smime_mod OBJ_SMIME,0L - -#define SN_id_smime_ct "id-smime-ct" -#define NID_id_smime_ct 190 -#define OBJ_id_smime_ct OBJ_SMIME,1L - -#define SN_id_smime_aa "id-smime-aa" -#define NID_id_smime_aa 191 -#define OBJ_id_smime_aa OBJ_SMIME,2L - -#define SN_id_smime_alg "id-smime-alg" -#define NID_id_smime_alg 192 -#define OBJ_id_smime_alg OBJ_SMIME,3L - -#define SN_id_smime_cd "id-smime-cd" -#define NID_id_smime_cd 193 -#define OBJ_id_smime_cd OBJ_SMIME,4L - -#define SN_id_smime_spq "id-smime-spq" -#define NID_id_smime_spq 194 -#define OBJ_id_smime_spq OBJ_SMIME,5L - -#define SN_id_smime_cti "id-smime-cti" -#define NID_id_smime_cti 195 -#define OBJ_id_smime_cti OBJ_SMIME,6L - -#define SN_id_smime_mod_cms "id-smime-mod-cms" -#define NID_id_smime_mod_cms 196 -#define OBJ_id_smime_mod_cms OBJ_id_smime_mod,1L - -#define SN_id_smime_mod_ess "id-smime-mod-ess" -#define NID_id_smime_mod_ess 197 -#define OBJ_id_smime_mod_ess OBJ_id_smime_mod,2L - -#define SN_id_smime_mod_oid "id-smime-mod-oid" -#define NID_id_smime_mod_oid 198 -#define OBJ_id_smime_mod_oid OBJ_id_smime_mod,3L - -#define SN_id_smime_mod_msg_v3 "id-smime-mod-msg-v3" -#define NID_id_smime_mod_msg_v3 199 -#define OBJ_id_smime_mod_msg_v3 OBJ_id_smime_mod,4L - -#define SN_id_smime_mod_ets_eSignature_88 "id-smime-mod-ets-eSignature-88" -#define NID_id_smime_mod_ets_eSignature_88 200 -#define OBJ_id_smime_mod_ets_eSignature_88 OBJ_id_smime_mod,5L - -#define SN_id_smime_mod_ets_eSignature_97 "id-smime-mod-ets-eSignature-97" -#define NID_id_smime_mod_ets_eSignature_97 201 -#define OBJ_id_smime_mod_ets_eSignature_97 OBJ_id_smime_mod,6L - -#define SN_id_smime_mod_ets_eSigPolicy_88 "id-smime-mod-ets-eSigPolicy-88" -#define NID_id_smime_mod_ets_eSigPolicy_88 202 -#define OBJ_id_smime_mod_ets_eSigPolicy_88 OBJ_id_smime_mod,7L - -#define SN_id_smime_mod_ets_eSigPolicy_97 "id-smime-mod-ets-eSigPolicy-97" -#define NID_id_smime_mod_ets_eSigPolicy_97 203 -#define OBJ_id_smime_mod_ets_eSigPolicy_97 OBJ_id_smime_mod,8L - -#define SN_id_smime_ct_receipt "id-smime-ct-receipt" -#define NID_id_smime_ct_receipt 204 -#define OBJ_id_smime_ct_receipt OBJ_id_smime_ct,1L - -#define SN_id_smime_ct_authData "id-smime-ct-authData" -#define NID_id_smime_ct_authData 205 -#define OBJ_id_smime_ct_authData OBJ_id_smime_ct,2L - -#define SN_id_smime_ct_publishCert "id-smime-ct-publishCert" -#define NID_id_smime_ct_publishCert 206 -#define OBJ_id_smime_ct_publishCert OBJ_id_smime_ct,3L - -#define SN_id_smime_ct_TSTInfo "id-smime-ct-TSTInfo" -#define NID_id_smime_ct_TSTInfo 207 -#define OBJ_id_smime_ct_TSTInfo OBJ_id_smime_ct,4L - -#define SN_id_smime_ct_TDTInfo "id-smime-ct-TDTInfo" -#define NID_id_smime_ct_TDTInfo 208 -#define OBJ_id_smime_ct_TDTInfo OBJ_id_smime_ct,5L - -#define SN_id_smime_ct_contentInfo "id-smime-ct-contentInfo" -#define NID_id_smime_ct_contentInfo 209 -#define OBJ_id_smime_ct_contentInfo OBJ_id_smime_ct,6L - -#define SN_id_smime_ct_DVCSRequestData "id-smime-ct-DVCSRequestData" -#define NID_id_smime_ct_DVCSRequestData 210 -#define OBJ_id_smime_ct_DVCSRequestData OBJ_id_smime_ct,7L - -#define SN_id_smime_ct_DVCSResponseData "id-smime-ct-DVCSResponseData" -#define NID_id_smime_ct_DVCSResponseData 211 -#define OBJ_id_smime_ct_DVCSResponseData OBJ_id_smime_ct,8L - -#define SN_id_smime_ct_compressedData "id-smime-ct-compressedData" -#define NID_id_smime_ct_compressedData 786 -#define OBJ_id_smime_ct_compressedData OBJ_id_smime_ct,9L - -#define SN_id_smime_ct_contentCollection "id-smime-ct-contentCollection" -#define NID_id_smime_ct_contentCollection 1058 -#define OBJ_id_smime_ct_contentCollection OBJ_id_smime_ct,19L - -#define SN_id_smime_ct_authEnvelopedData "id-smime-ct-authEnvelopedData" -#define NID_id_smime_ct_authEnvelopedData 1059 -#define OBJ_id_smime_ct_authEnvelopedData OBJ_id_smime_ct,23L - -#define SN_id_ct_asciiTextWithCRLF "id-ct-asciiTextWithCRLF" -#define NID_id_ct_asciiTextWithCRLF 787 -#define OBJ_id_ct_asciiTextWithCRLF OBJ_id_smime_ct,27L - -#define SN_id_ct_xml "id-ct-xml" -#define NID_id_ct_xml 1060 -#define OBJ_id_ct_xml OBJ_id_smime_ct,28L - -#define SN_id_smime_aa_receiptRequest "id-smime-aa-receiptRequest" -#define NID_id_smime_aa_receiptRequest 212 -#define OBJ_id_smime_aa_receiptRequest OBJ_id_smime_aa,1L - -#define SN_id_smime_aa_securityLabel "id-smime-aa-securityLabel" -#define NID_id_smime_aa_securityLabel 213 -#define OBJ_id_smime_aa_securityLabel OBJ_id_smime_aa,2L - -#define SN_id_smime_aa_mlExpandHistory "id-smime-aa-mlExpandHistory" -#define NID_id_smime_aa_mlExpandHistory 214 -#define OBJ_id_smime_aa_mlExpandHistory OBJ_id_smime_aa,3L - -#define SN_id_smime_aa_contentHint "id-smime-aa-contentHint" -#define NID_id_smime_aa_contentHint 215 -#define OBJ_id_smime_aa_contentHint OBJ_id_smime_aa,4L - -#define SN_id_smime_aa_msgSigDigest "id-smime-aa-msgSigDigest" -#define NID_id_smime_aa_msgSigDigest 216 -#define OBJ_id_smime_aa_msgSigDigest OBJ_id_smime_aa,5L - -#define SN_id_smime_aa_encapContentType "id-smime-aa-encapContentType" -#define NID_id_smime_aa_encapContentType 217 -#define OBJ_id_smime_aa_encapContentType OBJ_id_smime_aa,6L - -#define SN_id_smime_aa_contentIdentifier "id-smime-aa-contentIdentifier" -#define NID_id_smime_aa_contentIdentifier 218 -#define OBJ_id_smime_aa_contentIdentifier OBJ_id_smime_aa,7L - -#define SN_id_smime_aa_macValue "id-smime-aa-macValue" -#define NID_id_smime_aa_macValue 219 -#define OBJ_id_smime_aa_macValue OBJ_id_smime_aa,8L - -#define SN_id_smime_aa_equivalentLabels "id-smime-aa-equivalentLabels" -#define NID_id_smime_aa_equivalentLabels 220 -#define OBJ_id_smime_aa_equivalentLabels OBJ_id_smime_aa,9L - -#define SN_id_smime_aa_contentReference "id-smime-aa-contentReference" -#define NID_id_smime_aa_contentReference 221 -#define OBJ_id_smime_aa_contentReference OBJ_id_smime_aa,10L - -#define SN_id_smime_aa_encrypKeyPref "id-smime-aa-encrypKeyPref" -#define NID_id_smime_aa_encrypKeyPref 222 -#define OBJ_id_smime_aa_encrypKeyPref OBJ_id_smime_aa,11L - -#define SN_id_smime_aa_signingCertificate "id-smime-aa-signingCertificate" -#define NID_id_smime_aa_signingCertificate 223 -#define OBJ_id_smime_aa_signingCertificate OBJ_id_smime_aa,12L - -#define SN_id_smime_aa_smimeEncryptCerts "id-smime-aa-smimeEncryptCerts" -#define NID_id_smime_aa_smimeEncryptCerts 224 -#define OBJ_id_smime_aa_smimeEncryptCerts OBJ_id_smime_aa,13L - -#define SN_id_smime_aa_timeStampToken "id-smime-aa-timeStampToken" -#define NID_id_smime_aa_timeStampToken 225 -#define OBJ_id_smime_aa_timeStampToken OBJ_id_smime_aa,14L - -#define SN_id_smime_aa_ets_sigPolicyId "id-smime-aa-ets-sigPolicyId" -#define NID_id_smime_aa_ets_sigPolicyId 226 -#define OBJ_id_smime_aa_ets_sigPolicyId OBJ_id_smime_aa,15L - -#define SN_id_smime_aa_ets_commitmentType "id-smime-aa-ets-commitmentType" -#define NID_id_smime_aa_ets_commitmentType 227 -#define OBJ_id_smime_aa_ets_commitmentType OBJ_id_smime_aa,16L - -#define SN_id_smime_aa_ets_signerLocation "id-smime-aa-ets-signerLocation" -#define NID_id_smime_aa_ets_signerLocation 228 -#define OBJ_id_smime_aa_ets_signerLocation OBJ_id_smime_aa,17L - -#define SN_id_smime_aa_ets_signerAttr "id-smime-aa-ets-signerAttr" -#define NID_id_smime_aa_ets_signerAttr 229 -#define OBJ_id_smime_aa_ets_signerAttr OBJ_id_smime_aa,18L - -#define SN_id_smime_aa_ets_otherSigCert "id-smime-aa-ets-otherSigCert" -#define NID_id_smime_aa_ets_otherSigCert 230 -#define OBJ_id_smime_aa_ets_otherSigCert OBJ_id_smime_aa,19L - -#define SN_id_smime_aa_ets_contentTimestamp "id-smime-aa-ets-contentTimestamp" -#define NID_id_smime_aa_ets_contentTimestamp 231 -#define OBJ_id_smime_aa_ets_contentTimestamp OBJ_id_smime_aa,20L - -#define SN_id_smime_aa_ets_CertificateRefs "id-smime-aa-ets-CertificateRefs" -#define NID_id_smime_aa_ets_CertificateRefs 232 -#define OBJ_id_smime_aa_ets_CertificateRefs OBJ_id_smime_aa,21L - -#define SN_id_smime_aa_ets_RevocationRefs "id-smime-aa-ets-RevocationRefs" -#define NID_id_smime_aa_ets_RevocationRefs 233 -#define OBJ_id_smime_aa_ets_RevocationRefs OBJ_id_smime_aa,22L - -#define SN_id_smime_aa_ets_certValues "id-smime-aa-ets-certValues" -#define NID_id_smime_aa_ets_certValues 234 -#define OBJ_id_smime_aa_ets_certValues OBJ_id_smime_aa,23L - -#define SN_id_smime_aa_ets_revocationValues "id-smime-aa-ets-revocationValues" -#define NID_id_smime_aa_ets_revocationValues 235 -#define OBJ_id_smime_aa_ets_revocationValues OBJ_id_smime_aa,24L - -#define SN_id_smime_aa_ets_escTimeStamp "id-smime-aa-ets-escTimeStamp" -#define NID_id_smime_aa_ets_escTimeStamp 236 -#define OBJ_id_smime_aa_ets_escTimeStamp OBJ_id_smime_aa,25L - -#define SN_id_smime_aa_ets_certCRLTimestamp "id-smime-aa-ets-certCRLTimestamp" -#define NID_id_smime_aa_ets_certCRLTimestamp 237 -#define OBJ_id_smime_aa_ets_certCRLTimestamp OBJ_id_smime_aa,26L - -#define SN_id_smime_aa_ets_archiveTimeStamp "id-smime-aa-ets-archiveTimeStamp" -#define NID_id_smime_aa_ets_archiveTimeStamp 238 -#define OBJ_id_smime_aa_ets_archiveTimeStamp OBJ_id_smime_aa,27L - -#define SN_id_smime_aa_signatureType "id-smime-aa-signatureType" -#define NID_id_smime_aa_signatureType 239 -#define OBJ_id_smime_aa_signatureType OBJ_id_smime_aa,28L - -#define SN_id_smime_aa_dvcs_dvc "id-smime-aa-dvcs-dvc" -#define NID_id_smime_aa_dvcs_dvc 240 -#define OBJ_id_smime_aa_dvcs_dvc OBJ_id_smime_aa,29L - -#define SN_id_smime_aa_signingCertificateV2 "id-smime-aa-signingCertificateV2" -#define NID_id_smime_aa_signingCertificateV2 1086 -#define OBJ_id_smime_aa_signingCertificateV2 OBJ_id_smime_aa,47L - -#define SN_id_smime_alg_ESDHwith3DES "id-smime-alg-ESDHwith3DES" -#define NID_id_smime_alg_ESDHwith3DES 241 -#define OBJ_id_smime_alg_ESDHwith3DES OBJ_id_smime_alg,1L - -#define SN_id_smime_alg_ESDHwithRC2 "id-smime-alg-ESDHwithRC2" -#define NID_id_smime_alg_ESDHwithRC2 242 -#define OBJ_id_smime_alg_ESDHwithRC2 OBJ_id_smime_alg,2L - -#define SN_id_smime_alg_3DESwrap "id-smime-alg-3DESwrap" -#define NID_id_smime_alg_3DESwrap 243 -#define OBJ_id_smime_alg_3DESwrap OBJ_id_smime_alg,3L - -#define SN_id_smime_alg_RC2wrap "id-smime-alg-RC2wrap" -#define NID_id_smime_alg_RC2wrap 244 -#define OBJ_id_smime_alg_RC2wrap OBJ_id_smime_alg,4L - -#define SN_id_smime_alg_ESDH "id-smime-alg-ESDH" -#define NID_id_smime_alg_ESDH 245 -#define OBJ_id_smime_alg_ESDH OBJ_id_smime_alg,5L - -#define SN_id_smime_alg_CMS3DESwrap "id-smime-alg-CMS3DESwrap" -#define NID_id_smime_alg_CMS3DESwrap 246 -#define OBJ_id_smime_alg_CMS3DESwrap OBJ_id_smime_alg,6L - -#define SN_id_smime_alg_CMSRC2wrap "id-smime-alg-CMSRC2wrap" -#define NID_id_smime_alg_CMSRC2wrap 247 -#define OBJ_id_smime_alg_CMSRC2wrap OBJ_id_smime_alg,7L - -#define SN_id_alg_PWRI_KEK "id-alg-PWRI-KEK" -#define NID_id_alg_PWRI_KEK 893 -#define OBJ_id_alg_PWRI_KEK OBJ_id_smime_alg,9L - -#define SN_id_smime_cd_ldap "id-smime-cd-ldap" -#define NID_id_smime_cd_ldap 248 -#define OBJ_id_smime_cd_ldap OBJ_id_smime_cd,1L - -#define SN_id_smime_spq_ets_sqt_uri "id-smime-spq-ets-sqt-uri" -#define NID_id_smime_spq_ets_sqt_uri 249 -#define OBJ_id_smime_spq_ets_sqt_uri OBJ_id_smime_spq,1L - -#define SN_id_smime_spq_ets_sqt_unotice "id-smime-spq-ets-sqt-unotice" -#define NID_id_smime_spq_ets_sqt_unotice 250 -#define OBJ_id_smime_spq_ets_sqt_unotice OBJ_id_smime_spq,2L - -#define SN_id_smime_cti_ets_proofOfOrigin "id-smime-cti-ets-proofOfOrigin" -#define NID_id_smime_cti_ets_proofOfOrigin 251 -#define OBJ_id_smime_cti_ets_proofOfOrigin OBJ_id_smime_cti,1L - -#define SN_id_smime_cti_ets_proofOfReceipt "id-smime-cti-ets-proofOfReceipt" -#define NID_id_smime_cti_ets_proofOfReceipt 252 -#define OBJ_id_smime_cti_ets_proofOfReceipt OBJ_id_smime_cti,2L - -#define SN_id_smime_cti_ets_proofOfDelivery "id-smime-cti-ets-proofOfDelivery" -#define NID_id_smime_cti_ets_proofOfDelivery 253 -#define OBJ_id_smime_cti_ets_proofOfDelivery OBJ_id_smime_cti,3L - -#define SN_id_smime_cti_ets_proofOfSender "id-smime-cti-ets-proofOfSender" -#define NID_id_smime_cti_ets_proofOfSender 254 -#define OBJ_id_smime_cti_ets_proofOfSender OBJ_id_smime_cti,4L - -#define SN_id_smime_cti_ets_proofOfApproval "id-smime-cti-ets-proofOfApproval" -#define NID_id_smime_cti_ets_proofOfApproval 255 -#define OBJ_id_smime_cti_ets_proofOfApproval OBJ_id_smime_cti,5L - -#define SN_id_smime_cti_ets_proofOfCreation "id-smime-cti-ets-proofOfCreation" -#define NID_id_smime_cti_ets_proofOfCreation 256 -#define OBJ_id_smime_cti_ets_proofOfCreation OBJ_id_smime_cti,6L - -#define LN_friendlyName "friendlyName" -#define NID_friendlyName 156 -#define OBJ_friendlyName OBJ_pkcs9,20L - -#define LN_localKeyID "localKeyID" -#define NID_localKeyID 157 -#define OBJ_localKeyID OBJ_pkcs9,21L - -#define SN_ms_csp_name "CSPName" -#define LN_ms_csp_name "Microsoft CSP Name" -#define NID_ms_csp_name 417 -#define OBJ_ms_csp_name 1L,3L,6L,1L,4L,1L,311L,17L,1L - -#define SN_LocalKeySet "LocalKeySet" -#define LN_LocalKeySet "Microsoft Local Key set" -#define NID_LocalKeySet 856 -#define OBJ_LocalKeySet 1L,3L,6L,1L,4L,1L,311L,17L,2L - -#define OBJ_certTypes OBJ_pkcs9,22L - -#define LN_x509Certificate "x509Certificate" -#define NID_x509Certificate 158 -#define OBJ_x509Certificate OBJ_certTypes,1L - -#define LN_sdsiCertificate "sdsiCertificate" -#define NID_sdsiCertificate 159 -#define OBJ_sdsiCertificate OBJ_certTypes,2L - -#define OBJ_crlTypes OBJ_pkcs9,23L - -#define LN_x509Crl "x509Crl" -#define NID_x509Crl 160 -#define OBJ_x509Crl OBJ_crlTypes,1L - -#define OBJ_pkcs12 OBJ_pkcs,12L - -#define OBJ_pkcs12_pbeids OBJ_pkcs12,1L - -#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" -#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" -#define NID_pbe_WithSHA1And128BitRC4 144 -#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids,1L - -#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" -#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" -#define NID_pbe_WithSHA1And40BitRC4 145 -#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids,2L - -#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" -#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 -#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids,3L - -#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" -#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 -#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids,4L - -#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" -#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" -#define NID_pbe_WithSHA1And128BitRC2_CBC 148 -#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids,5L - -#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" -#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" -#define NID_pbe_WithSHA1And40BitRC2_CBC 149 -#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L - -#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L - -#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L - -#define LN_keyBag "keyBag" -#define NID_keyBag 150 -#define OBJ_keyBag OBJ_pkcs12_BagIds,1L - -#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" -#define NID_pkcs8ShroudedKeyBag 151 -#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds,2L - -#define LN_certBag "certBag" -#define NID_certBag 152 -#define OBJ_certBag OBJ_pkcs12_BagIds,3L - -#define LN_crlBag "crlBag" -#define NID_crlBag 153 -#define OBJ_crlBag OBJ_pkcs12_BagIds,4L - -#define LN_secretBag "secretBag" -#define NID_secretBag 154 -#define OBJ_secretBag OBJ_pkcs12_BagIds,5L - -#define LN_safeContentsBag "safeContentsBag" -#define NID_safeContentsBag 155 -#define OBJ_safeContentsBag OBJ_pkcs12_BagIds,6L - -#define SN_md2 "MD2" -#define LN_md2 "md2" -#define NID_md2 3 -#define OBJ_md2 OBJ_rsadsi,2L,2L - -#define SN_md4 "MD4" -#define LN_md4 "md4" -#define NID_md4 257 -#define OBJ_md4 OBJ_rsadsi,2L,4L - -#define SN_md5 "MD5" -#define LN_md5 "md5" -#define NID_md5 4 -#define OBJ_md5 OBJ_rsadsi,2L,5L - -#define SN_md5_sha1 "MD5-SHA1" -#define LN_md5_sha1 "md5-sha1" -#define NID_md5_sha1 114 - -#define LN_hmacWithMD5 "hmacWithMD5" -#define NID_hmacWithMD5 797 -#define OBJ_hmacWithMD5 OBJ_rsadsi,2L,6L - -#define LN_hmacWithSHA1 "hmacWithSHA1" -#define NID_hmacWithSHA1 163 -#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L - -#define SN_sm2 "SM2" -#define LN_sm2 "sm2" -#define NID_sm2 1172 -#define OBJ_sm2 OBJ_sm_scheme,301L - -#define SN_sm3 "SM3" -#define LN_sm3 "sm3" -#define NID_sm3 1143 -#define OBJ_sm3 OBJ_sm_scheme,401L - -#define SN_sm3WithRSAEncryption "RSA-SM3" -#define LN_sm3WithRSAEncryption "sm3WithRSAEncryption" -#define NID_sm3WithRSAEncryption 1144 -#define OBJ_sm3WithRSAEncryption OBJ_sm_scheme,504L - -#define LN_hmacWithSHA224 "hmacWithSHA224" -#define NID_hmacWithSHA224 798 -#define OBJ_hmacWithSHA224 OBJ_rsadsi,2L,8L - -#define LN_hmacWithSHA256 "hmacWithSHA256" -#define NID_hmacWithSHA256 799 -#define OBJ_hmacWithSHA256 OBJ_rsadsi,2L,9L - -#define LN_hmacWithSHA384 "hmacWithSHA384" -#define NID_hmacWithSHA384 800 -#define OBJ_hmacWithSHA384 OBJ_rsadsi,2L,10L - -#define LN_hmacWithSHA512 "hmacWithSHA512" -#define NID_hmacWithSHA512 801 -#define OBJ_hmacWithSHA512 OBJ_rsadsi,2L,11L - -#define LN_hmacWithSHA512_224 "hmacWithSHA512-224" -#define NID_hmacWithSHA512_224 1193 -#define OBJ_hmacWithSHA512_224 OBJ_rsadsi,2L,12L - -#define LN_hmacWithSHA512_256 "hmacWithSHA512-256" -#define NID_hmacWithSHA512_256 1194 -#define OBJ_hmacWithSHA512_256 OBJ_rsadsi,2L,13L - -#define SN_rc2_cbc "RC2-CBC" -#define LN_rc2_cbc "rc2-cbc" -#define NID_rc2_cbc 37 -#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L - -#define SN_rc2_ecb "RC2-ECB" -#define LN_rc2_ecb "rc2-ecb" -#define NID_rc2_ecb 38 - -#define SN_rc2_cfb64 "RC2-CFB" -#define LN_rc2_cfb64 "rc2-cfb" -#define NID_rc2_cfb64 39 - -#define SN_rc2_ofb64 "RC2-OFB" -#define LN_rc2_ofb64 "rc2-ofb" -#define NID_rc2_ofb64 40 - -#define SN_rc2_40_cbc "RC2-40-CBC" -#define LN_rc2_40_cbc "rc2-40-cbc" -#define NID_rc2_40_cbc 98 - -#define SN_rc2_64_cbc "RC2-64-CBC" -#define LN_rc2_64_cbc "rc2-64-cbc" -#define NID_rc2_64_cbc 166 - -#define SN_rc4 "RC4" -#define LN_rc4 "rc4" -#define NID_rc4 5 -#define OBJ_rc4 OBJ_rsadsi,3L,4L - -#define SN_rc4_40 "RC4-40" -#define LN_rc4_40 "rc4-40" -#define NID_rc4_40 97 - -#define SN_des_ede3_cbc "DES-EDE3-CBC" -#define LN_des_ede3_cbc "des-ede3-cbc" -#define NID_des_ede3_cbc 44 -#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L - -#define SN_rc5_cbc "RC5-CBC" -#define LN_rc5_cbc "rc5-cbc" -#define NID_rc5_cbc 120 -#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L - -#define SN_rc5_ecb "RC5-ECB" -#define LN_rc5_ecb "rc5-ecb" -#define NID_rc5_ecb 121 - -#define SN_rc5_cfb64 "RC5-CFB" -#define LN_rc5_cfb64 "rc5-cfb" -#define NID_rc5_cfb64 122 - -#define SN_rc5_ofb64 "RC5-OFB" -#define LN_rc5_ofb64 "rc5-ofb" -#define NID_rc5_ofb64 123 - -#define SN_ms_ext_req "msExtReq" -#define LN_ms_ext_req "Microsoft Extension Request" -#define NID_ms_ext_req 171 -#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L - -#define SN_ms_code_ind "msCodeInd" -#define LN_ms_code_ind "Microsoft Individual Code Signing" -#define NID_ms_code_ind 134 -#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L - -#define SN_ms_code_com "msCodeCom" -#define LN_ms_code_com "Microsoft Commercial Code Signing" -#define NID_ms_code_com 135 -#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L - -#define SN_ms_ctl_sign "msCTLSign" -#define LN_ms_ctl_sign "Microsoft Trust List Signing" -#define NID_ms_ctl_sign 136 -#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L - -#define SN_ms_sgc "msSGC" -#define LN_ms_sgc "Microsoft Server Gated Crypto" -#define NID_ms_sgc 137 -#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L - -#define SN_ms_efs "msEFS" -#define LN_ms_efs "Microsoft Encrypted File System" -#define NID_ms_efs 138 -#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L - -#define SN_ms_smartcard_login "msSmartcardLogin" -#define LN_ms_smartcard_login "Microsoft Smartcard Login" -#define NID_ms_smartcard_login 648 -#define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L - -#define SN_ms_upn "msUPN" -#define LN_ms_upn "Microsoft User Principal Name" -#define NID_ms_upn 649 -#define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L - -#define SN_idea_cbc "IDEA-CBC" -#define LN_idea_cbc "idea-cbc" -#define NID_idea_cbc 34 -#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L - -#define SN_idea_ecb "IDEA-ECB" -#define LN_idea_ecb "idea-ecb" -#define NID_idea_ecb 36 - -#define SN_idea_cfb64 "IDEA-CFB" -#define LN_idea_cfb64 "idea-cfb" -#define NID_idea_cfb64 35 - -#define SN_idea_ofb64 "IDEA-OFB" -#define LN_idea_ofb64 "idea-ofb" -#define NID_idea_ofb64 46 - -#define SN_bf_cbc "BF-CBC" -#define LN_bf_cbc "bf-cbc" -#define NID_bf_cbc 91 -#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L - -#define SN_bf_ecb "BF-ECB" -#define LN_bf_ecb "bf-ecb" -#define NID_bf_ecb 92 - -#define SN_bf_cfb64 "BF-CFB" -#define LN_bf_cfb64 "bf-cfb" -#define NID_bf_cfb64 93 - -#define SN_bf_ofb64 "BF-OFB" -#define LN_bf_ofb64 "bf-ofb" -#define NID_bf_ofb64 94 - -#define SN_id_pkix "PKIX" -#define NID_id_pkix 127 -#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L - -#define SN_id_pkix_mod "id-pkix-mod" -#define NID_id_pkix_mod 258 -#define OBJ_id_pkix_mod OBJ_id_pkix,0L - -#define SN_id_pe "id-pe" -#define NID_id_pe 175 -#define OBJ_id_pe OBJ_id_pkix,1L - -#define SN_id_qt "id-qt" -#define NID_id_qt 259 -#define OBJ_id_qt OBJ_id_pkix,2L - -#define SN_id_kp "id-kp" -#define NID_id_kp 128 -#define OBJ_id_kp OBJ_id_pkix,3L - -#define SN_id_it "id-it" -#define NID_id_it 260 -#define OBJ_id_it OBJ_id_pkix,4L - -#define SN_id_pkip "id-pkip" -#define NID_id_pkip 261 -#define OBJ_id_pkip OBJ_id_pkix,5L - -#define SN_id_alg "id-alg" -#define NID_id_alg 262 -#define OBJ_id_alg OBJ_id_pkix,6L - -#define SN_id_cmc "id-cmc" -#define NID_id_cmc 263 -#define OBJ_id_cmc OBJ_id_pkix,7L - -#define SN_id_on "id-on" -#define NID_id_on 264 -#define OBJ_id_on OBJ_id_pkix,8L - -#define SN_id_pda "id-pda" -#define NID_id_pda 265 -#define OBJ_id_pda OBJ_id_pkix,9L - -#define SN_id_aca "id-aca" -#define NID_id_aca 266 -#define OBJ_id_aca OBJ_id_pkix,10L - -#define SN_id_qcs "id-qcs" -#define NID_id_qcs 267 -#define OBJ_id_qcs OBJ_id_pkix,11L - -#define SN_id_cct "id-cct" -#define NID_id_cct 268 -#define OBJ_id_cct OBJ_id_pkix,12L - -#define SN_id_ppl "id-ppl" -#define NID_id_ppl 662 -#define OBJ_id_ppl OBJ_id_pkix,21L - -#define SN_id_ad "id-ad" -#define NID_id_ad 176 -#define OBJ_id_ad OBJ_id_pkix,48L - -#define SN_id_pkix1_explicit_88 "id-pkix1-explicit-88" -#define NID_id_pkix1_explicit_88 269 -#define OBJ_id_pkix1_explicit_88 OBJ_id_pkix_mod,1L - -#define SN_id_pkix1_implicit_88 "id-pkix1-implicit-88" -#define NID_id_pkix1_implicit_88 270 -#define OBJ_id_pkix1_implicit_88 OBJ_id_pkix_mod,2L - -#define SN_id_pkix1_explicit_93 "id-pkix1-explicit-93" -#define NID_id_pkix1_explicit_93 271 -#define OBJ_id_pkix1_explicit_93 OBJ_id_pkix_mod,3L - -#define SN_id_pkix1_implicit_93 "id-pkix1-implicit-93" -#define NID_id_pkix1_implicit_93 272 -#define OBJ_id_pkix1_implicit_93 OBJ_id_pkix_mod,4L - -#define SN_id_mod_crmf "id-mod-crmf" -#define NID_id_mod_crmf 273 -#define OBJ_id_mod_crmf OBJ_id_pkix_mod,5L - -#define SN_id_mod_cmc "id-mod-cmc" -#define NID_id_mod_cmc 274 -#define OBJ_id_mod_cmc OBJ_id_pkix_mod,6L - -#define SN_id_mod_kea_profile_88 "id-mod-kea-profile-88" -#define NID_id_mod_kea_profile_88 275 -#define OBJ_id_mod_kea_profile_88 OBJ_id_pkix_mod,7L - -#define SN_id_mod_kea_profile_93 "id-mod-kea-profile-93" -#define NID_id_mod_kea_profile_93 276 -#define OBJ_id_mod_kea_profile_93 OBJ_id_pkix_mod,8L - -#define SN_id_mod_cmp "id-mod-cmp" -#define NID_id_mod_cmp 277 -#define OBJ_id_mod_cmp OBJ_id_pkix_mod,9L - -#define SN_id_mod_qualified_cert_88 "id-mod-qualified-cert-88" -#define NID_id_mod_qualified_cert_88 278 -#define OBJ_id_mod_qualified_cert_88 OBJ_id_pkix_mod,10L - -#define SN_id_mod_qualified_cert_93 "id-mod-qualified-cert-93" -#define NID_id_mod_qualified_cert_93 279 -#define OBJ_id_mod_qualified_cert_93 OBJ_id_pkix_mod,11L - -#define SN_id_mod_attribute_cert "id-mod-attribute-cert" -#define NID_id_mod_attribute_cert 280 -#define OBJ_id_mod_attribute_cert OBJ_id_pkix_mod,12L - -#define SN_id_mod_timestamp_protocol "id-mod-timestamp-protocol" -#define NID_id_mod_timestamp_protocol 281 -#define OBJ_id_mod_timestamp_protocol OBJ_id_pkix_mod,13L - -#define SN_id_mod_ocsp "id-mod-ocsp" -#define NID_id_mod_ocsp 282 -#define OBJ_id_mod_ocsp OBJ_id_pkix_mod,14L - -#define SN_id_mod_dvcs "id-mod-dvcs" -#define NID_id_mod_dvcs 283 -#define OBJ_id_mod_dvcs OBJ_id_pkix_mod,15L - -#define SN_id_mod_cmp2000 "id-mod-cmp2000" -#define NID_id_mod_cmp2000 284 -#define OBJ_id_mod_cmp2000 OBJ_id_pkix_mod,16L - -#define SN_info_access "authorityInfoAccess" -#define LN_info_access "Authority Information Access" -#define NID_info_access 177 -#define OBJ_info_access OBJ_id_pe,1L - -#define SN_biometricInfo "biometricInfo" -#define LN_biometricInfo "Biometric Info" -#define NID_biometricInfo 285 -#define OBJ_biometricInfo OBJ_id_pe,2L - -#define SN_qcStatements "qcStatements" -#define NID_qcStatements 286 -#define OBJ_qcStatements OBJ_id_pe,3L - -#define SN_ac_auditEntity "ac-auditEntity" -#define NID_ac_auditEntity 287 -#define OBJ_ac_auditEntity OBJ_id_pe,4L - -#define SN_ac_targeting "ac-targeting" -#define NID_ac_targeting 288 -#define OBJ_ac_targeting OBJ_id_pe,5L - -#define SN_aaControls "aaControls" -#define NID_aaControls 289 -#define OBJ_aaControls OBJ_id_pe,6L - -#define SN_sbgp_ipAddrBlock "sbgp-ipAddrBlock" -#define NID_sbgp_ipAddrBlock 290 -#define OBJ_sbgp_ipAddrBlock OBJ_id_pe,7L - -#define SN_sbgp_autonomousSysNum "sbgp-autonomousSysNum" -#define NID_sbgp_autonomousSysNum 291 -#define OBJ_sbgp_autonomousSysNum OBJ_id_pe,8L - -#define SN_sbgp_routerIdentifier "sbgp-routerIdentifier" -#define NID_sbgp_routerIdentifier 292 -#define OBJ_sbgp_routerIdentifier OBJ_id_pe,9L - -#define SN_ac_proxying "ac-proxying" -#define NID_ac_proxying 397 -#define OBJ_ac_proxying OBJ_id_pe,10L - -#define SN_sinfo_access "subjectInfoAccess" -#define LN_sinfo_access "Subject Information Access" -#define NID_sinfo_access 398 -#define OBJ_sinfo_access OBJ_id_pe,11L - -#define SN_proxyCertInfo "proxyCertInfo" -#define LN_proxyCertInfo "Proxy Certificate Information" -#define NID_proxyCertInfo 663 -#define OBJ_proxyCertInfo OBJ_id_pe,14L - -#define SN_tlsfeature "tlsfeature" -#define LN_tlsfeature "TLS Feature" -#define NID_tlsfeature 1020 -#define OBJ_tlsfeature OBJ_id_pe,24L - -#define SN_id_qt_cps "id-qt-cps" -#define LN_id_qt_cps "Policy Qualifier CPS" -#define NID_id_qt_cps 164 -#define OBJ_id_qt_cps OBJ_id_qt,1L - -#define SN_id_qt_unotice "id-qt-unotice" -#define LN_id_qt_unotice "Policy Qualifier User Notice" -#define NID_id_qt_unotice 165 -#define OBJ_id_qt_unotice OBJ_id_qt,2L - -#define SN_textNotice "textNotice" -#define NID_textNotice 293 -#define OBJ_textNotice OBJ_id_qt,3L - -#define SN_server_auth "serverAuth" -#define LN_server_auth "TLS Web Server Authentication" -#define NID_server_auth 129 -#define OBJ_server_auth OBJ_id_kp,1L - -#define SN_client_auth "clientAuth" -#define LN_client_auth "TLS Web Client Authentication" -#define NID_client_auth 130 -#define OBJ_client_auth OBJ_id_kp,2L - -#define SN_code_sign "codeSigning" -#define LN_code_sign "Code Signing" -#define NID_code_sign 131 -#define OBJ_code_sign OBJ_id_kp,3L - -#define SN_email_protect "emailProtection" -#define LN_email_protect "E-mail Protection" -#define NID_email_protect 132 -#define OBJ_email_protect OBJ_id_kp,4L - -#define SN_ipsecEndSystem "ipsecEndSystem" -#define LN_ipsecEndSystem "IPSec End System" -#define NID_ipsecEndSystem 294 -#define OBJ_ipsecEndSystem OBJ_id_kp,5L - -#define SN_ipsecTunnel "ipsecTunnel" -#define LN_ipsecTunnel "IPSec Tunnel" -#define NID_ipsecTunnel 295 -#define OBJ_ipsecTunnel OBJ_id_kp,6L - -#define SN_ipsecUser "ipsecUser" -#define LN_ipsecUser "IPSec User" -#define NID_ipsecUser 296 -#define OBJ_ipsecUser OBJ_id_kp,7L - -#define SN_time_stamp "timeStamping" -#define LN_time_stamp "Time Stamping" -#define NID_time_stamp 133 -#define OBJ_time_stamp OBJ_id_kp,8L - -#define SN_OCSP_sign "OCSPSigning" -#define LN_OCSP_sign "OCSP Signing" -#define NID_OCSP_sign 180 -#define OBJ_OCSP_sign OBJ_id_kp,9L - -#define SN_dvcs "DVCS" -#define LN_dvcs "dvcs" -#define NID_dvcs 297 -#define OBJ_dvcs OBJ_id_kp,10L - -#define SN_ipsec_IKE "ipsecIKE" -#define LN_ipsec_IKE "ipsec Internet Key Exchange" -#define NID_ipsec_IKE 1022 -#define OBJ_ipsec_IKE OBJ_id_kp,17L - -#define SN_capwapAC "capwapAC" -#define LN_capwapAC "Ctrl/provision WAP Access" -#define NID_capwapAC 1023 -#define OBJ_capwapAC OBJ_id_kp,18L - -#define SN_capwapWTP "capwapWTP" -#define LN_capwapWTP "Ctrl/Provision WAP Termination" -#define NID_capwapWTP 1024 -#define OBJ_capwapWTP OBJ_id_kp,19L - -#define SN_sshClient "secureShellClient" -#define LN_sshClient "SSH Client" -#define NID_sshClient 1025 -#define OBJ_sshClient OBJ_id_kp,21L - -#define SN_sshServer "secureShellServer" -#define LN_sshServer "SSH Server" -#define NID_sshServer 1026 -#define OBJ_sshServer OBJ_id_kp,22L - -#define SN_sendRouter "sendRouter" -#define LN_sendRouter "Send Router" -#define NID_sendRouter 1027 -#define OBJ_sendRouter OBJ_id_kp,23L - -#define SN_sendProxiedRouter "sendProxiedRouter" -#define LN_sendProxiedRouter "Send Proxied Router" -#define NID_sendProxiedRouter 1028 -#define OBJ_sendProxiedRouter OBJ_id_kp,24L - -#define SN_sendOwner "sendOwner" -#define LN_sendOwner "Send Owner" -#define NID_sendOwner 1029 -#define OBJ_sendOwner OBJ_id_kp,25L - -#define SN_sendProxiedOwner "sendProxiedOwner" -#define LN_sendProxiedOwner "Send Proxied Owner" -#define NID_sendProxiedOwner 1030 -#define OBJ_sendProxiedOwner OBJ_id_kp,26L - -#define SN_cmcCA "cmcCA" -#define LN_cmcCA "CMC Certificate Authority" -#define NID_cmcCA 1131 -#define OBJ_cmcCA OBJ_id_kp,27L - -#define SN_cmcRA "cmcRA" -#define LN_cmcRA "CMC Registration Authority" -#define NID_cmcRA 1132 -#define OBJ_cmcRA OBJ_id_kp,28L - -#define SN_id_it_caProtEncCert "id-it-caProtEncCert" -#define NID_id_it_caProtEncCert 298 -#define OBJ_id_it_caProtEncCert OBJ_id_it,1L - -#define SN_id_it_signKeyPairTypes "id-it-signKeyPairTypes" -#define NID_id_it_signKeyPairTypes 299 -#define OBJ_id_it_signKeyPairTypes OBJ_id_it,2L - -#define SN_id_it_encKeyPairTypes "id-it-encKeyPairTypes" -#define NID_id_it_encKeyPairTypes 300 -#define OBJ_id_it_encKeyPairTypes OBJ_id_it,3L - -#define SN_id_it_preferredSymmAlg "id-it-preferredSymmAlg" -#define NID_id_it_preferredSymmAlg 301 -#define OBJ_id_it_preferredSymmAlg OBJ_id_it,4L - -#define SN_id_it_caKeyUpdateInfo "id-it-caKeyUpdateInfo" -#define NID_id_it_caKeyUpdateInfo 302 -#define OBJ_id_it_caKeyUpdateInfo OBJ_id_it,5L - -#define SN_id_it_currentCRL "id-it-currentCRL" -#define NID_id_it_currentCRL 303 -#define OBJ_id_it_currentCRL OBJ_id_it,6L - -#define SN_id_it_unsupportedOIDs "id-it-unsupportedOIDs" -#define NID_id_it_unsupportedOIDs 304 -#define OBJ_id_it_unsupportedOIDs OBJ_id_it,7L - -#define SN_id_it_subscriptionRequest "id-it-subscriptionRequest" -#define NID_id_it_subscriptionRequest 305 -#define OBJ_id_it_subscriptionRequest OBJ_id_it,8L - -#define SN_id_it_subscriptionResponse "id-it-subscriptionResponse" -#define NID_id_it_subscriptionResponse 306 -#define OBJ_id_it_subscriptionResponse OBJ_id_it,9L - -#define SN_id_it_keyPairParamReq "id-it-keyPairParamReq" -#define NID_id_it_keyPairParamReq 307 -#define OBJ_id_it_keyPairParamReq OBJ_id_it,10L - -#define SN_id_it_keyPairParamRep "id-it-keyPairParamRep" -#define NID_id_it_keyPairParamRep 308 -#define OBJ_id_it_keyPairParamRep OBJ_id_it,11L - -#define SN_id_it_revPassphrase "id-it-revPassphrase" -#define NID_id_it_revPassphrase 309 -#define OBJ_id_it_revPassphrase OBJ_id_it,12L - -#define SN_id_it_implicitConfirm "id-it-implicitConfirm" -#define NID_id_it_implicitConfirm 310 -#define OBJ_id_it_implicitConfirm OBJ_id_it,13L - -#define SN_id_it_confirmWaitTime "id-it-confirmWaitTime" -#define NID_id_it_confirmWaitTime 311 -#define OBJ_id_it_confirmWaitTime OBJ_id_it,14L - -#define SN_id_it_origPKIMessage "id-it-origPKIMessage" -#define NID_id_it_origPKIMessage 312 -#define OBJ_id_it_origPKIMessage OBJ_id_it,15L - -#define SN_id_it_suppLangTags "id-it-suppLangTags" -#define NID_id_it_suppLangTags 784 -#define OBJ_id_it_suppLangTags OBJ_id_it,16L - -#define SN_id_regCtrl "id-regCtrl" -#define NID_id_regCtrl 313 -#define OBJ_id_regCtrl OBJ_id_pkip,1L - -#define SN_id_regInfo "id-regInfo" -#define NID_id_regInfo 314 -#define OBJ_id_regInfo OBJ_id_pkip,2L - -#define SN_id_regCtrl_regToken "id-regCtrl-regToken" -#define NID_id_regCtrl_regToken 315 -#define OBJ_id_regCtrl_regToken OBJ_id_regCtrl,1L - -#define SN_id_regCtrl_authenticator "id-regCtrl-authenticator" -#define NID_id_regCtrl_authenticator 316 -#define OBJ_id_regCtrl_authenticator OBJ_id_regCtrl,2L - -#define SN_id_regCtrl_pkiPublicationInfo "id-regCtrl-pkiPublicationInfo" -#define NID_id_regCtrl_pkiPublicationInfo 317 -#define OBJ_id_regCtrl_pkiPublicationInfo OBJ_id_regCtrl,3L - -#define SN_id_regCtrl_pkiArchiveOptions "id-regCtrl-pkiArchiveOptions" -#define NID_id_regCtrl_pkiArchiveOptions 318 -#define OBJ_id_regCtrl_pkiArchiveOptions OBJ_id_regCtrl,4L - -#define SN_id_regCtrl_oldCertID "id-regCtrl-oldCertID" -#define NID_id_regCtrl_oldCertID 319 -#define OBJ_id_regCtrl_oldCertID OBJ_id_regCtrl,5L - -#define SN_id_regCtrl_protocolEncrKey "id-regCtrl-protocolEncrKey" -#define NID_id_regCtrl_protocolEncrKey 320 -#define OBJ_id_regCtrl_protocolEncrKey OBJ_id_regCtrl,6L - -#define SN_id_regInfo_utf8Pairs "id-regInfo-utf8Pairs" -#define NID_id_regInfo_utf8Pairs 321 -#define OBJ_id_regInfo_utf8Pairs OBJ_id_regInfo,1L - -#define SN_id_regInfo_certReq "id-regInfo-certReq" -#define NID_id_regInfo_certReq 322 -#define OBJ_id_regInfo_certReq OBJ_id_regInfo,2L - -#define SN_id_alg_des40 "id-alg-des40" -#define NID_id_alg_des40 323 -#define OBJ_id_alg_des40 OBJ_id_alg,1L - -#define SN_id_alg_noSignature "id-alg-noSignature" -#define NID_id_alg_noSignature 324 -#define OBJ_id_alg_noSignature OBJ_id_alg,2L - -#define SN_id_alg_dh_sig_hmac_sha1 "id-alg-dh-sig-hmac-sha1" -#define NID_id_alg_dh_sig_hmac_sha1 325 -#define OBJ_id_alg_dh_sig_hmac_sha1 OBJ_id_alg,3L - -#define SN_id_alg_dh_pop "id-alg-dh-pop" -#define NID_id_alg_dh_pop 326 -#define OBJ_id_alg_dh_pop OBJ_id_alg,4L - -#define SN_id_cmc_statusInfo "id-cmc-statusInfo" -#define NID_id_cmc_statusInfo 327 -#define OBJ_id_cmc_statusInfo OBJ_id_cmc,1L - -#define SN_id_cmc_identification "id-cmc-identification" -#define NID_id_cmc_identification 328 -#define OBJ_id_cmc_identification OBJ_id_cmc,2L - -#define SN_id_cmc_identityProof "id-cmc-identityProof" -#define NID_id_cmc_identityProof 329 -#define OBJ_id_cmc_identityProof OBJ_id_cmc,3L - -#define SN_id_cmc_dataReturn "id-cmc-dataReturn" -#define NID_id_cmc_dataReturn 330 -#define OBJ_id_cmc_dataReturn OBJ_id_cmc,4L - -#define SN_id_cmc_transactionId "id-cmc-transactionId" -#define NID_id_cmc_transactionId 331 -#define OBJ_id_cmc_transactionId OBJ_id_cmc,5L - -#define SN_id_cmc_senderNonce "id-cmc-senderNonce" -#define NID_id_cmc_senderNonce 332 -#define OBJ_id_cmc_senderNonce OBJ_id_cmc,6L - -#define SN_id_cmc_recipientNonce "id-cmc-recipientNonce" -#define NID_id_cmc_recipientNonce 333 -#define OBJ_id_cmc_recipientNonce OBJ_id_cmc,7L - -#define SN_id_cmc_addExtensions "id-cmc-addExtensions" -#define NID_id_cmc_addExtensions 334 -#define OBJ_id_cmc_addExtensions OBJ_id_cmc,8L - -#define SN_id_cmc_encryptedPOP "id-cmc-encryptedPOP" -#define NID_id_cmc_encryptedPOP 335 -#define OBJ_id_cmc_encryptedPOP OBJ_id_cmc,9L - -#define SN_id_cmc_decryptedPOP "id-cmc-decryptedPOP" -#define NID_id_cmc_decryptedPOP 336 -#define OBJ_id_cmc_decryptedPOP OBJ_id_cmc,10L - -#define SN_id_cmc_lraPOPWitness "id-cmc-lraPOPWitness" -#define NID_id_cmc_lraPOPWitness 337 -#define OBJ_id_cmc_lraPOPWitness OBJ_id_cmc,11L - -#define SN_id_cmc_getCert "id-cmc-getCert" -#define NID_id_cmc_getCert 338 -#define OBJ_id_cmc_getCert OBJ_id_cmc,15L - -#define SN_id_cmc_getCRL "id-cmc-getCRL" -#define NID_id_cmc_getCRL 339 -#define OBJ_id_cmc_getCRL OBJ_id_cmc,16L - -#define SN_id_cmc_revokeRequest "id-cmc-revokeRequest" -#define NID_id_cmc_revokeRequest 340 -#define OBJ_id_cmc_revokeRequest OBJ_id_cmc,17L - -#define SN_id_cmc_regInfo "id-cmc-regInfo" -#define NID_id_cmc_regInfo 341 -#define OBJ_id_cmc_regInfo OBJ_id_cmc,18L - -#define SN_id_cmc_responseInfo "id-cmc-responseInfo" -#define NID_id_cmc_responseInfo 342 -#define OBJ_id_cmc_responseInfo OBJ_id_cmc,19L - -#define SN_id_cmc_queryPending "id-cmc-queryPending" -#define NID_id_cmc_queryPending 343 -#define OBJ_id_cmc_queryPending OBJ_id_cmc,21L - -#define SN_id_cmc_popLinkRandom "id-cmc-popLinkRandom" -#define NID_id_cmc_popLinkRandom 344 -#define OBJ_id_cmc_popLinkRandom OBJ_id_cmc,22L - -#define SN_id_cmc_popLinkWitness "id-cmc-popLinkWitness" -#define NID_id_cmc_popLinkWitness 345 -#define OBJ_id_cmc_popLinkWitness OBJ_id_cmc,23L - -#define SN_id_cmc_confirmCertAcceptance "id-cmc-confirmCertAcceptance" -#define NID_id_cmc_confirmCertAcceptance 346 -#define OBJ_id_cmc_confirmCertAcceptance OBJ_id_cmc,24L - -#define SN_id_on_personalData "id-on-personalData" -#define NID_id_on_personalData 347 -#define OBJ_id_on_personalData OBJ_id_on,1L - -#define SN_id_on_permanentIdentifier "id-on-permanentIdentifier" -#define LN_id_on_permanentIdentifier "Permanent Identifier" -#define NID_id_on_permanentIdentifier 858 -#define OBJ_id_on_permanentIdentifier OBJ_id_on,3L - -#define SN_id_pda_dateOfBirth "id-pda-dateOfBirth" -#define NID_id_pda_dateOfBirth 348 -#define OBJ_id_pda_dateOfBirth OBJ_id_pda,1L - -#define SN_id_pda_placeOfBirth "id-pda-placeOfBirth" -#define NID_id_pda_placeOfBirth 349 -#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L - -#define SN_id_pda_gender "id-pda-gender" -#define NID_id_pda_gender 351 -#define OBJ_id_pda_gender OBJ_id_pda,3L - -#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship" -#define NID_id_pda_countryOfCitizenship 352 -#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L - -#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence" -#define NID_id_pda_countryOfResidence 353 -#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L - -#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo" -#define NID_id_aca_authenticationInfo 354 -#define OBJ_id_aca_authenticationInfo OBJ_id_aca,1L - -#define SN_id_aca_accessIdentity "id-aca-accessIdentity" -#define NID_id_aca_accessIdentity 355 -#define OBJ_id_aca_accessIdentity OBJ_id_aca,2L - -#define SN_id_aca_chargingIdentity "id-aca-chargingIdentity" -#define NID_id_aca_chargingIdentity 356 -#define OBJ_id_aca_chargingIdentity OBJ_id_aca,3L - -#define SN_id_aca_group "id-aca-group" -#define NID_id_aca_group 357 -#define OBJ_id_aca_group OBJ_id_aca,4L - -#define SN_id_aca_role "id-aca-role" -#define NID_id_aca_role 358 -#define OBJ_id_aca_role OBJ_id_aca,5L - -#define SN_id_aca_encAttrs "id-aca-encAttrs" -#define NID_id_aca_encAttrs 399 -#define OBJ_id_aca_encAttrs OBJ_id_aca,6L - -#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1" -#define NID_id_qcs_pkixQCSyntax_v1 359 -#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L - -#define SN_id_cct_crs "id-cct-crs" -#define NID_id_cct_crs 360 -#define OBJ_id_cct_crs OBJ_id_cct,1L - -#define SN_id_cct_PKIData "id-cct-PKIData" -#define NID_id_cct_PKIData 361 -#define OBJ_id_cct_PKIData OBJ_id_cct,2L - -#define SN_id_cct_PKIResponse "id-cct-PKIResponse" -#define NID_id_cct_PKIResponse 362 -#define OBJ_id_cct_PKIResponse OBJ_id_cct,3L - -#define SN_id_ppl_anyLanguage "id-ppl-anyLanguage" -#define LN_id_ppl_anyLanguage "Any language" -#define NID_id_ppl_anyLanguage 664 -#define OBJ_id_ppl_anyLanguage OBJ_id_ppl,0L - -#define SN_id_ppl_inheritAll "id-ppl-inheritAll" -#define LN_id_ppl_inheritAll "Inherit all" -#define NID_id_ppl_inheritAll 665 -#define OBJ_id_ppl_inheritAll OBJ_id_ppl,1L - -#define SN_Independent "id-ppl-independent" -#define LN_Independent "Independent" -#define NID_Independent 667 -#define OBJ_Independent OBJ_id_ppl,2L - -#define SN_ad_OCSP "OCSP" -#define LN_ad_OCSP "OCSP" -#define NID_ad_OCSP 178 -#define OBJ_ad_OCSP OBJ_id_ad,1L - -#define SN_ad_ca_issuers "caIssuers" -#define LN_ad_ca_issuers "CA Issuers" -#define NID_ad_ca_issuers 179 -#define OBJ_ad_ca_issuers OBJ_id_ad,2L - -#define SN_ad_timeStamping "ad_timestamping" -#define LN_ad_timeStamping "AD Time Stamping" -#define NID_ad_timeStamping 363 -#define OBJ_ad_timeStamping OBJ_id_ad,3L - -#define SN_ad_dvcs "AD_DVCS" -#define LN_ad_dvcs "ad dvcs" -#define NID_ad_dvcs 364 -#define OBJ_ad_dvcs OBJ_id_ad,4L - -#define SN_caRepository "caRepository" -#define LN_caRepository "CA Repository" -#define NID_caRepository 785 -#define OBJ_caRepository OBJ_id_ad,5L - -#define OBJ_id_pkix_OCSP OBJ_ad_OCSP - -#define SN_id_pkix_OCSP_basic "basicOCSPResponse" -#define LN_id_pkix_OCSP_basic "Basic OCSP Response" -#define NID_id_pkix_OCSP_basic 365 -#define OBJ_id_pkix_OCSP_basic OBJ_id_pkix_OCSP,1L - -#define SN_id_pkix_OCSP_Nonce "Nonce" -#define LN_id_pkix_OCSP_Nonce "OCSP Nonce" -#define NID_id_pkix_OCSP_Nonce 366 -#define OBJ_id_pkix_OCSP_Nonce OBJ_id_pkix_OCSP,2L - -#define SN_id_pkix_OCSP_CrlID "CrlID" -#define LN_id_pkix_OCSP_CrlID "OCSP CRL ID" -#define NID_id_pkix_OCSP_CrlID 367 -#define OBJ_id_pkix_OCSP_CrlID OBJ_id_pkix_OCSP,3L - -#define SN_id_pkix_OCSP_acceptableResponses "acceptableResponses" -#define LN_id_pkix_OCSP_acceptableResponses "Acceptable OCSP Responses" -#define NID_id_pkix_OCSP_acceptableResponses 368 -#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L - -#define SN_id_pkix_OCSP_noCheck "noCheck" -#define LN_id_pkix_OCSP_noCheck "OCSP No Check" -#define NID_id_pkix_OCSP_noCheck 369 -#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L - -#define SN_id_pkix_OCSP_archiveCutoff "archiveCutoff" -#define LN_id_pkix_OCSP_archiveCutoff "OCSP Archive Cutoff" -#define NID_id_pkix_OCSP_archiveCutoff 370 -#define OBJ_id_pkix_OCSP_archiveCutoff OBJ_id_pkix_OCSP,6L - -#define SN_id_pkix_OCSP_serviceLocator "serviceLocator" -#define LN_id_pkix_OCSP_serviceLocator "OCSP Service Locator" -#define NID_id_pkix_OCSP_serviceLocator 371 -#define OBJ_id_pkix_OCSP_serviceLocator OBJ_id_pkix_OCSP,7L - -#define SN_id_pkix_OCSP_extendedStatus "extendedStatus" -#define LN_id_pkix_OCSP_extendedStatus "Extended OCSP Status" -#define NID_id_pkix_OCSP_extendedStatus 372 -#define OBJ_id_pkix_OCSP_extendedStatus OBJ_id_pkix_OCSP,8L - -#define SN_id_pkix_OCSP_valid "valid" -#define NID_id_pkix_OCSP_valid 373 -#define OBJ_id_pkix_OCSP_valid OBJ_id_pkix_OCSP,9L - -#define SN_id_pkix_OCSP_path "path" -#define NID_id_pkix_OCSP_path 374 -#define OBJ_id_pkix_OCSP_path OBJ_id_pkix_OCSP,10L - -#define SN_id_pkix_OCSP_trustRoot "trustRoot" -#define LN_id_pkix_OCSP_trustRoot "Trust Root" -#define NID_id_pkix_OCSP_trustRoot 375 -#define OBJ_id_pkix_OCSP_trustRoot OBJ_id_pkix_OCSP,11L - -#define SN_algorithm "algorithm" -#define LN_algorithm "algorithm" -#define NID_algorithm 376 -#define OBJ_algorithm 1L,3L,14L,3L,2L - -#define SN_md5WithRSA "RSA-NP-MD5" -#define LN_md5WithRSA "md5WithRSA" -#define NID_md5WithRSA 104 -#define OBJ_md5WithRSA OBJ_algorithm,3L - -#define SN_des_ecb "DES-ECB" -#define LN_des_ecb "des-ecb" -#define NID_des_ecb 29 -#define OBJ_des_ecb OBJ_algorithm,6L - -#define SN_des_cbc "DES-CBC" -#define LN_des_cbc "des-cbc" -#define NID_des_cbc 31 -#define OBJ_des_cbc OBJ_algorithm,7L - -#define SN_des_ofb64 "DES-OFB" -#define LN_des_ofb64 "des-ofb" -#define NID_des_ofb64 45 -#define OBJ_des_ofb64 OBJ_algorithm,8L - -#define SN_des_cfb64 "DES-CFB" -#define LN_des_cfb64 "des-cfb" -#define NID_des_cfb64 30 -#define OBJ_des_cfb64 OBJ_algorithm,9L - -#define SN_rsaSignature "rsaSignature" -#define NID_rsaSignature 377 -#define OBJ_rsaSignature OBJ_algorithm,11L - -#define SN_dsa_2 "DSA-old" -#define LN_dsa_2 "dsaEncryption-old" -#define NID_dsa_2 67 -#define OBJ_dsa_2 OBJ_algorithm,12L - -#define SN_dsaWithSHA "DSA-SHA" -#define LN_dsaWithSHA "dsaWithSHA" -#define NID_dsaWithSHA 66 -#define OBJ_dsaWithSHA OBJ_algorithm,13L - -#define SN_shaWithRSAEncryption "RSA-SHA" -#define LN_shaWithRSAEncryption "shaWithRSAEncryption" -#define NID_shaWithRSAEncryption 42 -#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L - -#define SN_des_ede_ecb "DES-EDE" -#define LN_des_ede_ecb "des-ede" -#define NID_des_ede_ecb 32 -#define OBJ_des_ede_ecb OBJ_algorithm,17L - -#define SN_des_ede3_ecb "DES-EDE3" -#define LN_des_ede3_ecb "des-ede3" -#define NID_des_ede3_ecb 33 - -#define SN_des_ede_cbc "DES-EDE-CBC" -#define LN_des_ede_cbc "des-ede-cbc" -#define NID_des_ede_cbc 43 - -#define SN_des_ede_cfb64 "DES-EDE-CFB" -#define LN_des_ede_cfb64 "des-ede-cfb" -#define NID_des_ede_cfb64 60 - -#define SN_des_ede3_cfb64 "DES-EDE3-CFB" -#define LN_des_ede3_cfb64 "des-ede3-cfb" -#define NID_des_ede3_cfb64 61 - -#define SN_des_ede_ofb64 "DES-EDE-OFB" -#define LN_des_ede_ofb64 "des-ede-ofb" -#define NID_des_ede_ofb64 62 - -#define SN_des_ede3_ofb64 "DES-EDE3-OFB" -#define LN_des_ede3_ofb64 "des-ede3-ofb" -#define NID_des_ede3_ofb64 63 - -#define SN_desx_cbc "DESX-CBC" -#define LN_desx_cbc "desx-cbc" -#define NID_desx_cbc 80 - -#define SN_sha "SHA" -#define LN_sha "sha" -#define NID_sha 41 -#define OBJ_sha OBJ_algorithm,18L - -#define SN_sha1 "SHA1" -#define LN_sha1 "sha1" -#define NID_sha1 64 -#define OBJ_sha1 OBJ_algorithm,26L - -#define SN_dsaWithSHA1_2 "DSA-SHA1-old" -#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" -#define NID_dsaWithSHA1_2 70 -#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L - -#define SN_sha1WithRSA "RSA-SHA1-2" -#define LN_sha1WithRSA "sha1WithRSA" -#define NID_sha1WithRSA 115 -#define OBJ_sha1WithRSA OBJ_algorithm,29L - -#define SN_ripemd160 "RIPEMD160" -#define LN_ripemd160 "ripemd160" -#define NID_ripemd160 117 -#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L - -#define SN_ripemd160WithRSA "RSA-RIPEMD160" -#define LN_ripemd160WithRSA "ripemd160WithRSA" -#define NID_ripemd160WithRSA 119 -#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L - -#define SN_blake2b512 "BLAKE2b512" -#define LN_blake2b512 "blake2b512" -#define NID_blake2b512 1056 -#define OBJ_blake2b512 1L,3L,6L,1L,4L,1L,1722L,12L,2L,1L,16L - -#define SN_blake2s256 "BLAKE2s256" -#define LN_blake2s256 "blake2s256" -#define NID_blake2s256 1057 -#define OBJ_blake2s256 1L,3L,6L,1L,4L,1L,1722L,12L,2L,2L,8L - -#define SN_sxnet "SXNetID" -#define LN_sxnet "Strong Extranet ID" -#define NID_sxnet 143 -#define OBJ_sxnet 1L,3L,101L,1L,4L,1L - -#define SN_X500 "X500" -#define LN_X500 "directory services (X.500)" -#define NID_X500 11 -#define OBJ_X500 2L,5L - -#define SN_X509 "X509" -#define NID_X509 12 -#define OBJ_X509 OBJ_X500,4L - -#define SN_commonName "CN" -#define LN_commonName "commonName" -#define NID_commonName 13 -#define OBJ_commonName OBJ_X509,3L - -#define SN_surname "SN" -#define LN_surname "surname" -#define NID_surname 100 -#define OBJ_surname OBJ_X509,4L - -#define LN_serialNumber "serialNumber" -#define NID_serialNumber 105 -#define OBJ_serialNumber OBJ_X509,5L - -#define SN_countryName "C" -#define LN_countryName "countryName" -#define NID_countryName 14 -#define OBJ_countryName OBJ_X509,6L - -#define SN_localityName "L" -#define LN_localityName "localityName" -#define NID_localityName 15 -#define OBJ_localityName OBJ_X509,7L - -#define SN_stateOrProvinceName "ST" -#define LN_stateOrProvinceName "stateOrProvinceName" -#define NID_stateOrProvinceName 16 -#define OBJ_stateOrProvinceName OBJ_X509,8L - -#define SN_streetAddress "street" -#define LN_streetAddress "streetAddress" -#define NID_streetAddress 660 -#define OBJ_streetAddress OBJ_X509,9L - -#define SN_organizationName "O" -#define LN_organizationName "organizationName" -#define NID_organizationName 17 -#define OBJ_organizationName OBJ_X509,10L - -#define SN_organizationalUnitName "OU" -#define LN_organizationalUnitName "organizationalUnitName" -#define NID_organizationalUnitName 18 -#define OBJ_organizationalUnitName OBJ_X509,11L - -#define SN_title "title" -#define LN_title "title" -#define NID_title 106 -#define OBJ_title OBJ_X509,12L - -#define LN_description "description" -#define NID_description 107 -#define OBJ_description OBJ_X509,13L - -#define LN_searchGuide "searchGuide" -#define NID_searchGuide 859 -#define OBJ_searchGuide OBJ_X509,14L - -#define LN_businessCategory "businessCategory" -#define NID_businessCategory 860 -#define OBJ_businessCategory OBJ_X509,15L - -#define LN_postalAddress "postalAddress" -#define NID_postalAddress 861 -#define OBJ_postalAddress OBJ_X509,16L - -#define LN_postalCode "postalCode" -#define NID_postalCode 661 -#define OBJ_postalCode OBJ_X509,17L - -#define LN_postOfficeBox "postOfficeBox" -#define NID_postOfficeBox 862 -#define OBJ_postOfficeBox OBJ_X509,18L - -#define LN_physicalDeliveryOfficeName "physicalDeliveryOfficeName" -#define NID_physicalDeliveryOfficeName 863 -#define OBJ_physicalDeliveryOfficeName OBJ_X509,19L - -#define LN_telephoneNumber "telephoneNumber" -#define NID_telephoneNumber 864 -#define OBJ_telephoneNumber OBJ_X509,20L - -#define LN_telexNumber "telexNumber" -#define NID_telexNumber 865 -#define OBJ_telexNumber OBJ_X509,21L - -#define LN_teletexTerminalIdentifier "teletexTerminalIdentifier" -#define NID_teletexTerminalIdentifier 866 -#define OBJ_teletexTerminalIdentifier OBJ_X509,22L - -#define LN_facsimileTelephoneNumber "facsimileTelephoneNumber" -#define NID_facsimileTelephoneNumber 867 -#define OBJ_facsimileTelephoneNumber OBJ_X509,23L - -#define LN_x121Address "x121Address" -#define NID_x121Address 868 -#define OBJ_x121Address OBJ_X509,24L - -#define LN_internationaliSDNNumber "internationaliSDNNumber" -#define NID_internationaliSDNNumber 869 -#define OBJ_internationaliSDNNumber OBJ_X509,25L - -#define LN_registeredAddress "registeredAddress" -#define NID_registeredAddress 870 -#define OBJ_registeredAddress OBJ_X509,26L - -#define LN_destinationIndicator "destinationIndicator" -#define NID_destinationIndicator 871 -#define OBJ_destinationIndicator OBJ_X509,27L - -#define LN_preferredDeliveryMethod "preferredDeliveryMethod" -#define NID_preferredDeliveryMethod 872 -#define OBJ_preferredDeliveryMethod OBJ_X509,28L - -#define LN_presentationAddress "presentationAddress" -#define NID_presentationAddress 873 -#define OBJ_presentationAddress OBJ_X509,29L - -#define LN_supportedApplicationContext "supportedApplicationContext" -#define NID_supportedApplicationContext 874 -#define OBJ_supportedApplicationContext OBJ_X509,30L - -#define SN_member "member" -#define NID_member 875 -#define OBJ_member OBJ_X509,31L - -#define SN_owner "owner" -#define NID_owner 876 -#define OBJ_owner OBJ_X509,32L - -#define LN_roleOccupant "roleOccupant" -#define NID_roleOccupant 877 -#define OBJ_roleOccupant OBJ_X509,33L - -#define SN_seeAlso "seeAlso" -#define NID_seeAlso 878 -#define OBJ_seeAlso OBJ_X509,34L - -#define LN_userPassword "userPassword" -#define NID_userPassword 879 -#define OBJ_userPassword OBJ_X509,35L - -#define LN_userCertificate "userCertificate" -#define NID_userCertificate 880 -#define OBJ_userCertificate OBJ_X509,36L - -#define LN_cACertificate "cACertificate" -#define NID_cACertificate 881 -#define OBJ_cACertificate OBJ_X509,37L - -#define LN_authorityRevocationList "authorityRevocationList" -#define NID_authorityRevocationList 882 -#define OBJ_authorityRevocationList OBJ_X509,38L - -#define LN_certificateRevocationList "certificateRevocationList" -#define NID_certificateRevocationList 883 -#define OBJ_certificateRevocationList OBJ_X509,39L - -#define LN_crossCertificatePair "crossCertificatePair" -#define NID_crossCertificatePair 884 -#define OBJ_crossCertificatePair OBJ_X509,40L - -#define SN_name "name" -#define LN_name "name" -#define NID_name 173 -#define OBJ_name OBJ_X509,41L - -#define SN_givenName "GN" -#define LN_givenName "givenName" -#define NID_givenName 99 -#define OBJ_givenName OBJ_X509,42L - -#define SN_initials "initials" -#define LN_initials "initials" -#define NID_initials 101 -#define OBJ_initials OBJ_X509,43L - -#define LN_generationQualifier "generationQualifier" -#define NID_generationQualifier 509 -#define OBJ_generationQualifier OBJ_X509,44L - -#define LN_x500UniqueIdentifier "x500UniqueIdentifier" -#define NID_x500UniqueIdentifier 503 -#define OBJ_x500UniqueIdentifier OBJ_X509,45L - -#define SN_dnQualifier "dnQualifier" -#define LN_dnQualifier "dnQualifier" -#define NID_dnQualifier 174 -#define OBJ_dnQualifier OBJ_X509,46L - -#define LN_enhancedSearchGuide "enhancedSearchGuide" -#define NID_enhancedSearchGuide 885 -#define OBJ_enhancedSearchGuide OBJ_X509,47L - -#define LN_protocolInformation "protocolInformation" -#define NID_protocolInformation 886 -#define OBJ_protocolInformation OBJ_X509,48L - -#define LN_distinguishedName "distinguishedName" -#define NID_distinguishedName 887 -#define OBJ_distinguishedName OBJ_X509,49L - -#define LN_uniqueMember "uniqueMember" -#define NID_uniqueMember 888 -#define OBJ_uniqueMember OBJ_X509,50L - -#define LN_houseIdentifier "houseIdentifier" -#define NID_houseIdentifier 889 -#define OBJ_houseIdentifier OBJ_X509,51L - -#define LN_supportedAlgorithms "supportedAlgorithms" -#define NID_supportedAlgorithms 890 -#define OBJ_supportedAlgorithms OBJ_X509,52L - -#define LN_deltaRevocationList "deltaRevocationList" -#define NID_deltaRevocationList 891 -#define OBJ_deltaRevocationList OBJ_X509,53L - -#define SN_dmdName "dmdName" -#define NID_dmdName 892 -#define OBJ_dmdName OBJ_X509,54L - -#define LN_pseudonym "pseudonym" -#define NID_pseudonym 510 -#define OBJ_pseudonym OBJ_X509,65L - -#define SN_role "role" -#define LN_role "role" -#define NID_role 400 -#define OBJ_role OBJ_X509,72L - -#define LN_organizationIdentifier "organizationIdentifier" -#define NID_organizationIdentifier 1089 -#define OBJ_organizationIdentifier OBJ_X509,97L - -#define SN_countryCode3c "c3" -#define LN_countryCode3c "countryCode3c" -#define NID_countryCode3c 1090 -#define OBJ_countryCode3c OBJ_X509,98L - -#define SN_countryCode3n "n3" -#define LN_countryCode3n "countryCode3n" -#define NID_countryCode3n 1091 -#define OBJ_countryCode3n OBJ_X509,99L - -#define LN_dnsName "dnsName" -#define NID_dnsName 1092 -#define OBJ_dnsName OBJ_X509,100L - -#define SN_X500algorithms "X500algorithms" -#define LN_X500algorithms "directory services - algorithms" -#define NID_X500algorithms 378 -#define OBJ_X500algorithms OBJ_X500,8L - -#define SN_rsa "RSA" -#define LN_rsa "rsa" -#define NID_rsa 19 -#define OBJ_rsa OBJ_X500algorithms,1L,1L - -#define SN_mdc2WithRSA "RSA-MDC2" -#define LN_mdc2WithRSA "mdc2WithRSA" -#define NID_mdc2WithRSA 96 -#define OBJ_mdc2WithRSA OBJ_X500algorithms,3L,100L - -#define SN_mdc2 "MDC2" -#define LN_mdc2 "mdc2" -#define NID_mdc2 95 -#define OBJ_mdc2 OBJ_X500algorithms,3L,101L - -#define SN_id_ce "id-ce" -#define NID_id_ce 81 -#define OBJ_id_ce OBJ_X500,29L - -#define SN_subject_directory_attributes "subjectDirectoryAttributes" -#define LN_subject_directory_attributes "X509v3 Subject Directory Attributes" -#define NID_subject_directory_attributes 769 -#define OBJ_subject_directory_attributes OBJ_id_ce,9L - -#define SN_subject_key_identifier "subjectKeyIdentifier" -#define LN_subject_key_identifier "X509v3 Subject Key Identifier" -#define NID_subject_key_identifier 82 -#define OBJ_subject_key_identifier OBJ_id_ce,14L - -#define SN_key_usage "keyUsage" -#define LN_key_usage "X509v3 Key Usage" -#define NID_key_usage 83 -#define OBJ_key_usage OBJ_id_ce,15L - -#define SN_private_key_usage_period "privateKeyUsagePeriod" -#define LN_private_key_usage_period "X509v3 Private Key Usage Period" -#define NID_private_key_usage_period 84 -#define OBJ_private_key_usage_period OBJ_id_ce,16L - -#define SN_subject_alt_name "subjectAltName" -#define LN_subject_alt_name "X509v3 Subject Alternative Name" -#define NID_subject_alt_name 85 -#define OBJ_subject_alt_name OBJ_id_ce,17L - -#define SN_issuer_alt_name "issuerAltName" -#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" -#define NID_issuer_alt_name 86 -#define OBJ_issuer_alt_name OBJ_id_ce,18L - -#define SN_basic_constraints "basicConstraints" -#define LN_basic_constraints "X509v3 Basic Constraints" -#define NID_basic_constraints 87 -#define OBJ_basic_constraints OBJ_id_ce,19L - -#define SN_crl_number "crlNumber" -#define LN_crl_number "X509v3 CRL Number" -#define NID_crl_number 88 -#define OBJ_crl_number OBJ_id_ce,20L - -#define SN_crl_reason "CRLReason" -#define LN_crl_reason "X509v3 CRL Reason Code" -#define NID_crl_reason 141 -#define OBJ_crl_reason OBJ_id_ce,21L - -#define SN_invalidity_date "invalidityDate" -#define LN_invalidity_date "Invalidity Date" -#define NID_invalidity_date 142 -#define OBJ_invalidity_date OBJ_id_ce,24L - -#define SN_delta_crl "deltaCRL" -#define LN_delta_crl "X509v3 Delta CRL Indicator" -#define NID_delta_crl 140 -#define OBJ_delta_crl OBJ_id_ce,27L - -#define SN_issuing_distribution_point "issuingDistributionPoint" -#define LN_issuing_distribution_point "X509v3 Issuing Distribution Point" -#define NID_issuing_distribution_point 770 -#define OBJ_issuing_distribution_point OBJ_id_ce,28L - -#define SN_certificate_issuer "certificateIssuer" -#define LN_certificate_issuer "X509v3 Certificate Issuer" -#define NID_certificate_issuer 771 -#define OBJ_certificate_issuer OBJ_id_ce,29L - -#define SN_name_constraints "nameConstraints" -#define LN_name_constraints "X509v3 Name Constraints" -#define NID_name_constraints 666 -#define OBJ_name_constraints OBJ_id_ce,30L - -#define SN_crl_distribution_points "crlDistributionPoints" -#define LN_crl_distribution_points "X509v3 CRL Distribution Points" -#define NID_crl_distribution_points 103 -#define OBJ_crl_distribution_points OBJ_id_ce,31L - -#define SN_certificate_policies "certificatePolicies" -#define LN_certificate_policies "X509v3 Certificate Policies" -#define NID_certificate_policies 89 -#define OBJ_certificate_policies OBJ_id_ce,32L - -#define SN_any_policy "anyPolicy" -#define LN_any_policy "X509v3 Any Policy" -#define NID_any_policy 746 -#define OBJ_any_policy OBJ_certificate_policies,0L - -#define SN_policy_mappings "policyMappings" -#define LN_policy_mappings "X509v3 Policy Mappings" -#define NID_policy_mappings 747 -#define OBJ_policy_mappings OBJ_id_ce,33L - -#define SN_authority_key_identifier "authorityKeyIdentifier" -#define LN_authority_key_identifier "X509v3 Authority Key Identifier" -#define NID_authority_key_identifier 90 -#define OBJ_authority_key_identifier OBJ_id_ce,35L - -#define SN_policy_constraints "policyConstraints" -#define LN_policy_constraints "X509v3 Policy Constraints" -#define NID_policy_constraints 401 -#define OBJ_policy_constraints OBJ_id_ce,36L - -#define SN_ext_key_usage "extendedKeyUsage" -#define LN_ext_key_usage "X509v3 Extended Key Usage" -#define NID_ext_key_usage 126 -#define OBJ_ext_key_usage OBJ_id_ce,37L - -#define SN_freshest_crl "freshestCRL" -#define LN_freshest_crl "X509v3 Freshest CRL" -#define NID_freshest_crl 857 -#define OBJ_freshest_crl OBJ_id_ce,46L - -#define SN_inhibit_any_policy "inhibitAnyPolicy" -#define LN_inhibit_any_policy "X509v3 Inhibit Any Policy" -#define NID_inhibit_any_policy 748 -#define OBJ_inhibit_any_policy OBJ_id_ce,54L - -#define SN_target_information "targetInformation" -#define LN_target_information "X509v3 AC Targeting" -#define NID_target_information 402 -#define OBJ_target_information OBJ_id_ce,55L - -#define SN_no_rev_avail "noRevAvail" -#define LN_no_rev_avail "X509v3 No Revocation Available" -#define NID_no_rev_avail 403 -#define OBJ_no_rev_avail OBJ_id_ce,56L - -#define SN_anyExtendedKeyUsage "anyExtendedKeyUsage" -#define LN_anyExtendedKeyUsage "Any Extended Key Usage" -#define NID_anyExtendedKeyUsage 910 -#define OBJ_anyExtendedKeyUsage OBJ_ext_key_usage,0L - -#define SN_netscape "Netscape" -#define LN_netscape "Netscape Communications Corp." -#define NID_netscape 57 -#define OBJ_netscape 2L,16L,840L,1L,113730L - -#define SN_netscape_cert_extension "nsCertExt" -#define LN_netscape_cert_extension "Netscape Certificate Extension" -#define NID_netscape_cert_extension 58 -#define OBJ_netscape_cert_extension OBJ_netscape,1L - -#define SN_netscape_data_type "nsDataType" -#define LN_netscape_data_type "Netscape Data Type" -#define NID_netscape_data_type 59 -#define OBJ_netscape_data_type OBJ_netscape,2L - -#define SN_netscape_cert_type "nsCertType" -#define LN_netscape_cert_type "Netscape Cert Type" -#define NID_netscape_cert_type 71 -#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L - -#define SN_netscape_base_url "nsBaseUrl" -#define LN_netscape_base_url "Netscape Base Url" -#define NID_netscape_base_url 72 -#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L - -#define SN_netscape_revocation_url "nsRevocationUrl" -#define LN_netscape_revocation_url "Netscape Revocation Url" -#define NID_netscape_revocation_url 73 -#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L - -#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" -#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" -#define NID_netscape_ca_revocation_url 74 -#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L - -#define SN_netscape_renewal_url "nsRenewalUrl" -#define LN_netscape_renewal_url "Netscape Renewal Url" -#define NID_netscape_renewal_url 75 -#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L - -#define SN_netscape_ca_policy_url "nsCaPolicyUrl" -#define LN_netscape_ca_policy_url "Netscape CA Policy Url" -#define NID_netscape_ca_policy_url 76 -#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L - -#define SN_netscape_ssl_server_name "nsSslServerName" -#define LN_netscape_ssl_server_name "Netscape SSL Server Name" -#define NID_netscape_ssl_server_name 77 -#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L - -#define SN_netscape_comment "nsComment" -#define LN_netscape_comment "Netscape Comment" -#define NID_netscape_comment 78 -#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L - -#define SN_netscape_cert_sequence "nsCertSequence" -#define LN_netscape_cert_sequence "Netscape Certificate Sequence" -#define NID_netscape_cert_sequence 79 -#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L - -#define SN_ns_sgc "nsSGC" -#define LN_ns_sgc "Netscape Server Gated Crypto" -#define NID_ns_sgc 139 -#define OBJ_ns_sgc OBJ_netscape,4L,1L - -#define SN_org "ORG" -#define LN_org "org" -#define NID_org 379 -#define OBJ_org OBJ_iso,3L - -#define SN_dod "DOD" -#define LN_dod "dod" -#define NID_dod 380 -#define OBJ_dod OBJ_org,6L - -#define SN_iana "IANA" -#define LN_iana "iana" -#define NID_iana 381 -#define OBJ_iana OBJ_dod,1L - -#define OBJ_internet OBJ_iana - -#define SN_Directory "directory" -#define LN_Directory "Directory" -#define NID_Directory 382 -#define OBJ_Directory OBJ_internet,1L - -#define SN_Management "mgmt" -#define LN_Management "Management" -#define NID_Management 383 -#define OBJ_Management OBJ_internet,2L - -#define SN_Experimental "experimental" -#define LN_Experimental "Experimental" -#define NID_Experimental 384 -#define OBJ_Experimental OBJ_internet,3L - -#define SN_Private "private" -#define LN_Private "Private" -#define NID_Private 385 -#define OBJ_Private OBJ_internet,4L - -#define SN_Security "security" -#define LN_Security "Security" -#define NID_Security 386 -#define OBJ_Security OBJ_internet,5L - -#define SN_SNMPv2 "snmpv2" -#define LN_SNMPv2 "SNMPv2" -#define NID_SNMPv2 387 -#define OBJ_SNMPv2 OBJ_internet,6L - -#define LN_Mail "Mail" -#define NID_Mail 388 -#define OBJ_Mail OBJ_internet,7L - -#define SN_Enterprises "enterprises" -#define LN_Enterprises "Enterprises" -#define NID_Enterprises 389 -#define OBJ_Enterprises OBJ_Private,1L - -#define SN_dcObject "dcobject" -#define LN_dcObject "dcObject" -#define NID_dcObject 390 -#define OBJ_dcObject OBJ_Enterprises,1466L,344L - -#define SN_mime_mhs "mime-mhs" -#define LN_mime_mhs "MIME MHS" -#define NID_mime_mhs 504 -#define OBJ_mime_mhs OBJ_Mail,1L - -#define SN_mime_mhs_headings "mime-mhs-headings" -#define LN_mime_mhs_headings "mime-mhs-headings" -#define NID_mime_mhs_headings 505 -#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L - -#define SN_mime_mhs_bodies "mime-mhs-bodies" -#define LN_mime_mhs_bodies "mime-mhs-bodies" -#define NID_mime_mhs_bodies 506 -#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L - -#define SN_id_hex_partial_message "id-hex-partial-message" -#define LN_id_hex_partial_message "id-hex-partial-message" -#define NID_id_hex_partial_message 507 -#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L - -#define SN_id_hex_multipart_message "id-hex-multipart-message" -#define LN_id_hex_multipart_message "id-hex-multipart-message" -#define NID_id_hex_multipart_message 508 -#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L - -#define SN_zlib_compression "ZLIB" -#define LN_zlib_compression "zlib compression" -#define NID_zlib_compression 125 -#define OBJ_zlib_compression OBJ_id_smime_alg,8L - -#define OBJ_csor 2L,16L,840L,1L,101L,3L - -#define OBJ_nistAlgorithms OBJ_csor,4L - -#define OBJ_aes OBJ_nistAlgorithms,1L - -#define SN_aes_128_ecb "AES-128-ECB" -#define LN_aes_128_ecb "aes-128-ecb" -#define NID_aes_128_ecb 418 -#define OBJ_aes_128_ecb OBJ_aes,1L - -#define SN_aes_128_cbc "AES-128-CBC" -#define LN_aes_128_cbc "aes-128-cbc" -#define NID_aes_128_cbc 419 -#define OBJ_aes_128_cbc OBJ_aes,2L - -#define SN_aes_128_ofb128 "AES-128-OFB" -#define LN_aes_128_ofb128 "aes-128-ofb" -#define NID_aes_128_ofb128 420 -#define OBJ_aes_128_ofb128 OBJ_aes,3L - -#define SN_aes_128_cfb128 "AES-128-CFB" -#define LN_aes_128_cfb128 "aes-128-cfb" -#define NID_aes_128_cfb128 421 -#define OBJ_aes_128_cfb128 OBJ_aes,4L - -#define SN_id_aes128_wrap "id-aes128-wrap" -#define NID_id_aes128_wrap 788 -#define OBJ_id_aes128_wrap OBJ_aes,5L - -#define SN_aes_128_gcm "id-aes128-GCM" -#define LN_aes_128_gcm "aes-128-gcm" -#define NID_aes_128_gcm 895 -#define OBJ_aes_128_gcm OBJ_aes,6L - -#define SN_aes_128_ccm "id-aes128-CCM" -#define LN_aes_128_ccm "aes-128-ccm" -#define NID_aes_128_ccm 896 -#define OBJ_aes_128_ccm OBJ_aes,7L - -#define SN_id_aes128_wrap_pad "id-aes128-wrap-pad" -#define NID_id_aes128_wrap_pad 897 -#define OBJ_id_aes128_wrap_pad OBJ_aes,8L - -#define SN_aes_192_ecb "AES-192-ECB" -#define LN_aes_192_ecb "aes-192-ecb" -#define NID_aes_192_ecb 422 -#define OBJ_aes_192_ecb OBJ_aes,21L - -#define SN_aes_192_cbc "AES-192-CBC" -#define LN_aes_192_cbc "aes-192-cbc" -#define NID_aes_192_cbc 423 -#define OBJ_aes_192_cbc OBJ_aes,22L - -#define SN_aes_192_ofb128 "AES-192-OFB" -#define LN_aes_192_ofb128 "aes-192-ofb" -#define NID_aes_192_ofb128 424 -#define OBJ_aes_192_ofb128 OBJ_aes,23L - -#define SN_aes_192_cfb128 "AES-192-CFB" -#define LN_aes_192_cfb128 "aes-192-cfb" -#define NID_aes_192_cfb128 425 -#define OBJ_aes_192_cfb128 OBJ_aes,24L - -#define SN_id_aes192_wrap "id-aes192-wrap" -#define NID_id_aes192_wrap 789 -#define OBJ_id_aes192_wrap OBJ_aes,25L - -#define SN_aes_192_gcm "id-aes192-GCM" -#define LN_aes_192_gcm "aes-192-gcm" -#define NID_aes_192_gcm 898 -#define OBJ_aes_192_gcm OBJ_aes,26L - -#define SN_aes_192_ccm "id-aes192-CCM" -#define LN_aes_192_ccm "aes-192-ccm" -#define NID_aes_192_ccm 899 -#define OBJ_aes_192_ccm OBJ_aes,27L - -#define SN_id_aes192_wrap_pad "id-aes192-wrap-pad" -#define NID_id_aes192_wrap_pad 900 -#define OBJ_id_aes192_wrap_pad OBJ_aes,28L - -#define SN_aes_256_ecb "AES-256-ECB" -#define LN_aes_256_ecb "aes-256-ecb" -#define NID_aes_256_ecb 426 -#define OBJ_aes_256_ecb OBJ_aes,41L - -#define SN_aes_256_cbc "AES-256-CBC" -#define LN_aes_256_cbc "aes-256-cbc" -#define NID_aes_256_cbc 427 -#define OBJ_aes_256_cbc OBJ_aes,42L - -#define SN_aes_256_ofb128 "AES-256-OFB" -#define LN_aes_256_ofb128 "aes-256-ofb" -#define NID_aes_256_ofb128 428 -#define OBJ_aes_256_ofb128 OBJ_aes,43L - -#define SN_aes_256_cfb128 "AES-256-CFB" -#define LN_aes_256_cfb128 "aes-256-cfb" -#define NID_aes_256_cfb128 429 -#define OBJ_aes_256_cfb128 OBJ_aes,44L - -#define SN_id_aes256_wrap "id-aes256-wrap" -#define NID_id_aes256_wrap 790 -#define OBJ_id_aes256_wrap OBJ_aes,45L - -#define SN_aes_256_gcm "id-aes256-GCM" -#define LN_aes_256_gcm "aes-256-gcm" -#define NID_aes_256_gcm 901 -#define OBJ_aes_256_gcm OBJ_aes,46L - -#define SN_aes_256_ccm "id-aes256-CCM" -#define LN_aes_256_ccm "aes-256-ccm" -#define NID_aes_256_ccm 902 -#define OBJ_aes_256_ccm OBJ_aes,47L - -#define SN_id_aes256_wrap_pad "id-aes256-wrap-pad" -#define NID_id_aes256_wrap_pad 903 -#define OBJ_id_aes256_wrap_pad OBJ_aes,48L - -#define SN_aes_128_xts "AES-128-XTS" -#define LN_aes_128_xts "aes-128-xts" -#define NID_aes_128_xts 913 -#define OBJ_aes_128_xts OBJ_ieee_siswg,0L,1L,1L - -#define SN_aes_256_xts "AES-256-XTS" -#define LN_aes_256_xts "aes-256-xts" -#define NID_aes_256_xts 914 -#define OBJ_aes_256_xts OBJ_ieee_siswg,0L,1L,2L - -#define SN_aes_128_cfb1 "AES-128-CFB1" -#define LN_aes_128_cfb1 "aes-128-cfb1" -#define NID_aes_128_cfb1 650 - -#define SN_aes_192_cfb1 "AES-192-CFB1" -#define LN_aes_192_cfb1 "aes-192-cfb1" -#define NID_aes_192_cfb1 651 - -#define SN_aes_256_cfb1 "AES-256-CFB1" -#define LN_aes_256_cfb1 "aes-256-cfb1" -#define NID_aes_256_cfb1 652 - -#define SN_aes_128_cfb8 "AES-128-CFB8" -#define LN_aes_128_cfb8 "aes-128-cfb8" -#define NID_aes_128_cfb8 653 - -#define SN_aes_192_cfb8 "AES-192-CFB8" -#define LN_aes_192_cfb8 "aes-192-cfb8" -#define NID_aes_192_cfb8 654 - -#define SN_aes_256_cfb8 "AES-256-CFB8" -#define LN_aes_256_cfb8 "aes-256-cfb8" -#define NID_aes_256_cfb8 655 - -#define SN_aes_128_ctr "AES-128-CTR" -#define LN_aes_128_ctr "aes-128-ctr" -#define NID_aes_128_ctr 904 - -#define SN_aes_192_ctr "AES-192-CTR" -#define LN_aes_192_ctr "aes-192-ctr" -#define NID_aes_192_ctr 905 - -#define SN_aes_256_ctr "AES-256-CTR" -#define LN_aes_256_ctr "aes-256-ctr" -#define NID_aes_256_ctr 906 - -#define SN_aes_128_ocb "AES-128-OCB" -#define LN_aes_128_ocb "aes-128-ocb" -#define NID_aes_128_ocb 958 - -#define SN_aes_192_ocb "AES-192-OCB" -#define LN_aes_192_ocb "aes-192-ocb" -#define NID_aes_192_ocb 959 - -#define SN_aes_256_ocb "AES-256-OCB" -#define LN_aes_256_ocb "aes-256-ocb" -#define NID_aes_256_ocb 960 - -#define SN_des_cfb1 "DES-CFB1" -#define LN_des_cfb1 "des-cfb1" -#define NID_des_cfb1 656 - -#define SN_des_cfb8 "DES-CFB8" -#define LN_des_cfb8 "des-cfb8" -#define NID_des_cfb8 657 - -#define SN_des_ede3_cfb1 "DES-EDE3-CFB1" -#define LN_des_ede3_cfb1 "des-ede3-cfb1" -#define NID_des_ede3_cfb1 658 - -#define SN_des_ede3_cfb8 "DES-EDE3-CFB8" -#define LN_des_ede3_cfb8 "des-ede3-cfb8" -#define NID_des_ede3_cfb8 659 - -#define OBJ_nist_hashalgs OBJ_nistAlgorithms,2L - -#define SN_sha256 "SHA256" -#define LN_sha256 "sha256" -#define NID_sha256 672 -#define OBJ_sha256 OBJ_nist_hashalgs,1L - -#define SN_sha384 "SHA384" -#define LN_sha384 "sha384" -#define NID_sha384 673 -#define OBJ_sha384 OBJ_nist_hashalgs,2L - -#define SN_sha512 "SHA512" -#define LN_sha512 "sha512" -#define NID_sha512 674 -#define OBJ_sha512 OBJ_nist_hashalgs,3L - -#define SN_sha224 "SHA224" -#define LN_sha224 "sha224" -#define NID_sha224 675 -#define OBJ_sha224 OBJ_nist_hashalgs,4L - -#define SN_sha512_224 "SHA512-224" -#define LN_sha512_224 "sha512-224" -#define NID_sha512_224 1094 -#define OBJ_sha512_224 OBJ_nist_hashalgs,5L - -#define SN_sha512_256 "SHA512-256" -#define LN_sha512_256 "sha512-256" -#define NID_sha512_256 1095 -#define OBJ_sha512_256 OBJ_nist_hashalgs,6L - -#define SN_sha3_224 "SHA3-224" -#define LN_sha3_224 "sha3-224" -#define NID_sha3_224 1096 -#define OBJ_sha3_224 OBJ_nist_hashalgs,7L - -#define SN_sha3_256 "SHA3-256" -#define LN_sha3_256 "sha3-256" -#define NID_sha3_256 1097 -#define OBJ_sha3_256 OBJ_nist_hashalgs,8L - -#define SN_sha3_384 "SHA3-384" -#define LN_sha3_384 "sha3-384" -#define NID_sha3_384 1098 -#define OBJ_sha3_384 OBJ_nist_hashalgs,9L - -#define SN_sha3_512 "SHA3-512" -#define LN_sha3_512 "sha3-512" -#define NID_sha3_512 1099 -#define OBJ_sha3_512 OBJ_nist_hashalgs,10L - -#define SN_shake128 "SHAKE128" -#define LN_shake128 "shake128" -#define NID_shake128 1100 -#define OBJ_shake128 OBJ_nist_hashalgs,11L - -#define SN_shake256 "SHAKE256" -#define LN_shake256 "shake256" -#define NID_shake256 1101 -#define OBJ_shake256 OBJ_nist_hashalgs,12L - -#define SN_hmac_sha3_224 "id-hmacWithSHA3-224" -#define LN_hmac_sha3_224 "hmac-sha3-224" -#define NID_hmac_sha3_224 1102 -#define OBJ_hmac_sha3_224 OBJ_nist_hashalgs,13L - -#define SN_hmac_sha3_256 "id-hmacWithSHA3-256" -#define LN_hmac_sha3_256 "hmac-sha3-256" -#define NID_hmac_sha3_256 1103 -#define OBJ_hmac_sha3_256 OBJ_nist_hashalgs,14L - -#define SN_hmac_sha3_384 "id-hmacWithSHA3-384" -#define LN_hmac_sha3_384 "hmac-sha3-384" -#define NID_hmac_sha3_384 1104 -#define OBJ_hmac_sha3_384 OBJ_nist_hashalgs,15L - -#define SN_hmac_sha3_512 "id-hmacWithSHA3-512" -#define LN_hmac_sha3_512 "hmac-sha3-512" -#define NID_hmac_sha3_512 1105 -#define OBJ_hmac_sha3_512 OBJ_nist_hashalgs,16L - -#define OBJ_dsa_with_sha2 OBJ_nistAlgorithms,3L - -#define SN_dsa_with_SHA224 "dsa_with_SHA224" -#define NID_dsa_with_SHA224 802 -#define OBJ_dsa_with_SHA224 OBJ_dsa_with_sha2,1L - -#define SN_dsa_with_SHA256 "dsa_with_SHA256" -#define NID_dsa_with_SHA256 803 -#define OBJ_dsa_with_SHA256 OBJ_dsa_with_sha2,2L - -#define OBJ_sigAlgs OBJ_nistAlgorithms,3L - -#define SN_dsa_with_SHA384 "id-dsa-with-sha384" -#define LN_dsa_with_SHA384 "dsa_with_SHA384" -#define NID_dsa_with_SHA384 1106 -#define OBJ_dsa_with_SHA384 OBJ_sigAlgs,3L - -#define SN_dsa_with_SHA512 "id-dsa-with-sha512" -#define LN_dsa_with_SHA512 "dsa_with_SHA512" -#define NID_dsa_with_SHA512 1107 -#define OBJ_dsa_with_SHA512 OBJ_sigAlgs,4L - -#define SN_dsa_with_SHA3_224 "id-dsa-with-sha3-224" -#define LN_dsa_with_SHA3_224 "dsa_with_SHA3-224" -#define NID_dsa_with_SHA3_224 1108 -#define OBJ_dsa_with_SHA3_224 OBJ_sigAlgs,5L - -#define SN_dsa_with_SHA3_256 "id-dsa-with-sha3-256" -#define LN_dsa_with_SHA3_256 "dsa_with_SHA3-256" -#define NID_dsa_with_SHA3_256 1109 -#define OBJ_dsa_with_SHA3_256 OBJ_sigAlgs,6L - -#define SN_dsa_with_SHA3_384 "id-dsa-with-sha3-384" -#define LN_dsa_with_SHA3_384 "dsa_with_SHA3-384" -#define NID_dsa_with_SHA3_384 1110 -#define OBJ_dsa_with_SHA3_384 OBJ_sigAlgs,7L - -#define SN_dsa_with_SHA3_512 "id-dsa-with-sha3-512" -#define LN_dsa_with_SHA3_512 "dsa_with_SHA3-512" -#define NID_dsa_with_SHA3_512 1111 -#define OBJ_dsa_with_SHA3_512 OBJ_sigAlgs,8L - -#define SN_ecdsa_with_SHA3_224 "id-ecdsa-with-sha3-224" -#define LN_ecdsa_with_SHA3_224 "ecdsa_with_SHA3-224" -#define NID_ecdsa_with_SHA3_224 1112 -#define OBJ_ecdsa_with_SHA3_224 OBJ_sigAlgs,9L - -#define SN_ecdsa_with_SHA3_256 "id-ecdsa-with-sha3-256" -#define LN_ecdsa_with_SHA3_256 "ecdsa_with_SHA3-256" -#define NID_ecdsa_with_SHA3_256 1113 -#define OBJ_ecdsa_with_SHA3_256 OBJ_sigAlgs,10L - -#define SN_ecdsa_with_SHA3_384 "id-ecdsa-with-sha3-384" -#define LN_ecdsa_with_SHA3_384 "ecdsa_with_SHA3-384" -#define NID_ecdsa_with_SHA3_384 1114 -#define OBJ_ecdsa_with_SHA3_384 OBJ_sigAlgs,11L - -#define SN_ecdsa_with_SHA3_512 "id-ecdsa-with-sha3-512" -#define LN_ecdsa_with_SHA3_512 "ecdsa_with_SHA3-512" -#define NID_ecdsa_with_SHA3_512 1115 -#define OBJ_ecdsa_with_SHA3_512 OBJ_sigAlgs,12L - -#define SN_RSA_SHA3_224 "id-rsassa-pkcs1-v1_5-with-sha3-224" -#define LN_RSA_SHA3_224 "RSA-SHA3-224" -#define NID_RSA_SHA3_224 1116 -#define OBJ_RSA_SHA3_224 OBJ_sigAlgs,13L - -#define SN_RSA_SHA3_256 "id-rsassa-pkcs1-v1_5-with-sha3-256" -#define LN_RSA_SHA3_256 "RSA-SHA3-256" -#define NID_RSA_SHA3_256 1117 -#define OBJ_RSA_SHA3_256 OBJ_sigAlgs,14L - -#define SN_RSA_SHA3_384 "id-rsassa-pkcs1-v1_5-with-sha3-384" -#define LN_RSA_SHA3_384 "RSA-SHA3-384" -#define NID_RSA_SHA3_384 1118 -#define OBJ_RSA_SHA3_384 OBJ_sigAlgs,15L - -#define SN_RSA_SHA3_512 "id-rsassa-pkcs1-v1_5-with-sha3-512" -#define LN_RSA_SHA3_512 "RSA-SHA3-512" -#define NID_RSA_SHA3_512 1119 -#define OBJ_RSA_SHA3_512 OBJ_sigAlgs,16L - -#define SN_hold_instruction_code "holdInstructionCode" -#define LN_hold_instruction_code "Hold Instruction Code" -#define NID_hold_instruction_code 430 -#define OBJ_hold_instruction_code OBJ_id_ce,23L - -#define OBJ_holdInstruction OBJ_X9_57,2L - -#define SN_hold_instruction_none "holdInstructionNone" -#define LN_hold_instruction_none "Hold Instruction None" -#define NID_hold_instruction_none 431 -#define OBJ_hold_instruction_none OBJ_holdInstruction,1L - -#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer" -#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer" -#define NID_hold_instruction_call_issuer 432 -#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L - -#define SN_hold_instruction_reject "holdInstructionReject" -#define LN_hold_instruction_reject "Hold Instruction Reject" -#define NID_hold_instruction_reject 433 -#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L - -#define SN_data "data" -#define NID_data 434 -#define OBJ_data OBJ_itu_t,9L - -#define SN_pss "pss" -#define NID_pss 435 -#define OBJ_pss OBJ_data,2342L - -#define SN_ucl "ucl" -#define NID_ucl 436 -#define OBJ_ucl OBJ_pss,19200300L - -#define SN_pilot "pilot" -#define NID_pilot 437 -#define OBJ_pilot OBJ_ucl,100L - -#define LN_pilotAttributeType "pilotAttributeType" -#define NID_pilotAttributeType 438 -#define OBJ_pilotAttributeType OBJ_pilot,1L - -#define LN_pilotAttributeSyntax "pilotAttributeSyntax" -#define NID_pilotAttributeSyntax 439 -#define OBJ_pilotAttributeSyntax OBJ_pilot,3L - -#define LN_pilotObjectClass "pilotObjectClass" -#define NID_pilotObjectClass 440 -#define OBJ_pilotObjectClass OBJ_pilot,4L - -#define LN_pilotGroups "pilotGroups" -#define NID_pilotGroups 441 -#define OBJ_pilotGroups OBJ_pilot,10L - -#define LN_iA5StringSyntax "iA5StringSyntax" -#define NID_iA5StringSyntax 442 -#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L - -#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax" -#define NID_caseIgnoreIA5StringSyntax 443 -#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L - -#define LN_pilotObject "pilotObject" -#define NID_pilotObject 444 -#define OBJ_pilotObject OBJ_pilotObjectClass,3L - -#define LN_pilotPerson "pilotPerson" -#define NID_pilotPerson 445 -#define OBJ_pilotPerson OBJ_pilotObjectClass,4L - -#define SN_account "account" -#define NID_account 446 -#define OBJ_account OBJ_pilotObjectClass,5L - -#define SN_document "document" -#define NID_document 447 -#define OBJ_document OBJ_pilotObjectClass,6L - -#define SN_room "room" -#define NID_room 448 -#define OBJ_room OBJ_pilotObjectClass,7L - -#define LN_documentSeries "documentSeries" -#define NID_documentSeries 449 -#define OBJ_documentSeries OBJ_pilotObjectClass,9L - -#define SN_Domain "domain" -#define LN_Domain "Domain" -#define NID_Domain 392 -#define OBJ_Domain OBJ_pilotObjectClass,13L - -#define LN_rFC822localPart "rFC822localPart" -#define NID_rFC822localPart 450 -#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L - -#define LN_dNSDomain "dNSDomain" -#define NID_dNSDomain 451 -#define OBJ_dNSDomain OBJ_pilotObjectClass,15L - -#define LN_domainRelatedObject "domainRelatedObject" -#define NID_domainRelatedObject 452 -#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L - -#define LN_friendlyCountry "friendlyCountry" -#define NID_friendlyCountry 453 -#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L - -#define LN_simpleSecurityObject "simpleSecurityObject" -#define NID_simpleSecurityObject 454 -#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L - -#define LN_pilotOrganization "pilotOrganization" -#define NID_pilotOrganization 455 -#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L - -#define LN_pilotDSA "pilotDSA" -#define NID_pilotDSA 456 -#define OBJ_pilotDSA OBJ_pilotObjectClass,21L - -#define LN_qualityLabelledData "qualityLabelledData" -#define NID_qualityLabelledData 457 -#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L - -#define SN_userId "UID" -#define LN_userId "userId" -#define NID_userId 458 -#define OBJ_userId OBJ_pilotAttributeType,1L - -#define LN_textEncodedORAddress "textEncodedORAddress" -#define NID_textEncodedORAddress 459 -#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L - -#define SN_rfc822Mailbox "mail" -#define LN_rfc822Mailbox "rfc822Mailbox" -#define NID_rfc822Mailbox 460 -#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L - -#define SN_info "info" -#define NID_info 461 -#define OBJ_info OBJ_pilotAttributeType,4L - -#define LN_favouriteDrink "favouriteDrink" -#define NID_favouriteDrink 462 -#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L - -#define LN_roomNumber "roomNumber" -#define NID_roomNumber 463 -#define OBJ_roomNumber OBJ_pilotAttributeType,6L - -#define SN_photo "photo" -#define NID_photo 464 -#define OBJ_photo OBJ_pilotAttributeType,7L - -#define LN_userClass "userClass" -#define NID_userClass 465 -#define OBJ_userClass OBJ_pilotAttributeType,8L - -#define SN_host "host" -#define NID_host 466 -#define OBJ_host OBJ_pilotAttributeType,9L - -#define SN_manager "manager" -#define NID_manager 467 -#define OBJ_manager OBJ_pilotAttributeType,10L - -#define LN_documentIdentifier "documentIdentifier" -#define NID_documentIdentifier 468 -#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L - -#define LN_documentTitle "documentTitle" -#define NID_documentTitle 469 -#define OBJ_documentTitle OBJ_pilotAttributeType,12L - -#define LN_documentVersion "documentVersion" -#define NID_documentVersion 470 -#define OBJ_documentVersion OBJ_pilotAttributeType,13L - -#define LN_documentAuthor "documentAuthor" -#define NID_documentAuthor 471 -#define OBJ_documentAuthor OBJ_pilotAttributeType,14L - -#define LN_documentLocation "documentLocation" -#define NID_documentLocation 472 -#define OBJ_documentLocation OBJ_pilotAttributeType,15L - -#define LN_homeTelephoneNumber "homeTelephoneNumber" -#define NID_homeTelephoneNumber 473 -#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L - -#define SN_secretary "secretary" -#define NID_secretary 474 -#define OBJ_secretary OBJ_pilotAttributeType,21L - -#define LN_otherMailbox "otherMailbox" -#define NID_otherMailbox 475 -#define OBJ_otherMailbox OBJ_pilotAttributeType,22L - -#define LN_lastModifiedTime "lastModifiedTime" -#define NID_lastModifiedTime 476 -#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L - -#define LN_lastModifiedBy "lastModifiedBy" -#define NID_lastModifiedBy 477 -#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L - -#define SN_domainComponent "DC" -#define LN_domainComponent "domainComponent" -#define NID_domainComponent 391 -#define OBJ_domainComponent OBJ_pilotAttributeType,25L - -#define LN_aRecord "aRecord" -#define NID_aRecord 478 -#define OBJ_aRecord OBJ_pilotAttributeType,26L - -#define LN_pilotAttributeType27 "pilotAttributeType27" -#define NID_pilotAttributeType27 479 -#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L - -#define LN_mXRecord "mXRecord" -#define NID_mXRecord 480 -#define OBJ_mXRecord OBJ_pilotAttributeType,28L - -#define LN_nSRecord "nSRecord" -#define NID_nSRecord 481 -#define OBJ_nSRecord OBJ_pilotAttributeType,29L - -#define LN_sOARecord "sOARecord" -#define NID_sOARecord 482 -#define OBJ_sOARecord OBJ_pilotAttributeType,30L - -#define LN_cNAMERecord "cNAMERecord" -#define NID_cNAMERecord 483 -#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L - -#define LN_associatedDomain "associatedDomain" -#define NID_associatedDomain 484 -#define OBJ_associatedDomain OBJ_pilotAttributeType,37L - -#define LN_associatedName "associatedName" -#define NID_associatedName 485 -#define OBJ_associatedName OBJ_pilotAttributeType,38L - -#define LN_homePostalAddress "homePostalAddress" -#define NID_homePostalAddress 486 -#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L - -#define LN_personalTitle "personalTitle" -#define NID_personalTitle 487 -#define OBJ_personalTitle OBJ_pilotAttributeType,40L - -#define LN_mobileTelephoneNumber "mobileTelephoneNumber" -#define NID_mobileTelephoneNumber 488 -#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L - -#define LN_pagerTelephoneNumber "pagerTelephoneNumber" -#define NID_pagerTelephoneNumber 489 -#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L - -#define LN_friendlyCountryName "friendlyCountryName" -#define NID_friendlyCountryName 490 -#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L - -#define SN_uniqueIdentifier "uid" -#define LN_uniqueIdentifier "uniqueIdentifier" -#define NID_uniqueIdentifier 102 -#define OBJ_uniqueIdentifier OBJ_pilotAttributeType,44L - -#define LN_organizationalStatus "organizationalStatus" -#define NID_organizationalStatus 491 -#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L - -#define LN_janetMailbox "janetMailbox" -#define NID_janetMailbox 492 -#define OBJ_janetMailbox OBJ_pilotAttributeType,46L - -#define LN_mailPreferenceOption "mailPreferenceOption" -#define NID_mailPreferenceOption 493 -#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L - -#define LN_buildingName "buildingName" -#define NID_buildingName 494 -#define OBJ_buildingName OBJ_pilotAttributeType,48L - -#define LN_dSAQuality "dSAQuality" -#define NID_dSAQuality 495 -#define OBJ_dSAQuality OBJ_pilotAttributeType,49L - -#define LN_singleLevelQuality "singleLevelQuality" -#define NID_singleLevelQuality 496 -#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L - -#define LN_subtreeMinimumQuality "subtreeMinimumQuality" -#define NID_subtreeMinimumQuality 497 -#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L - -#define LN_subtreeMaximumQuality "subtreeMaximumQuality" -#define NID_subtreeMaximumQuality 498 -#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L - -#define LN_personalSignature "personalSignature" -#define NID_personalSignature 499 -#define OBJ_personalSignature OBJ_pilotAttributeType,53L - -#define LN_dITRedirect "dITRedirect" -#define NID_dITRedirect 500 -#define OBJ_dITRedirect OBJ_pilotAttributeType,54L - -#define SN_audio "audio" -#define NID_audio 501 -#define OBJ_audio OBJ_pilotAttributeType,55L - -#define LN_documentPublisher "documentPublisher" -#define NID_documentPublisher 502 -#define OBJ_documentPublisher OBJ_pilotAttributeType,56L - -#define SN_id_set "id-set" -#define LN_id_set "Secure Electronic Transactions" -#define NID_id_set 512 -#define OBJ_id_set OBJ_international_organizations,42L - -#define SN_set_ctype "set-ctype" -#define LN_set_ctype "content types" -#define NID_set_ctype 513 -#define OBJ_set_ctype OBJ_id_set,0L - -#define SN_set_msgExt "set-msgExt" -#define LN_set_msgExt "message extensions" -#define NID_set_msgExt 514 -#define OBJ_set_msgExt OBJ_id_set,1L - -#define SN_set_attr "set-attr" -#define NID_set_attr 515 -#define OBJ_set_attr OBJ_id_set,3L - -#define SN_set_policy "set-policy" -#define NID_set_policy 516 -#define OBJ_set_policy OBJ_id_set,5L - -#define SN_set_certExt "set-certExt" -#define LN_set_certExt "certificate extensions" -#define NID_set_certExt 517 -#define OBJ_set_certExt OBJ_id_set,7L - -#define SN_set_brand "set-brand" -#define NID_set_brand 518 -#define OBJ_set_brand OBJ_id_set,8L - -#define SN_setct_PANData "setct-PANData" -#define NID_setct_PANData 519 -#define OBJ_setct_PANData OBJ_set_ctype,0L - -#define SN_setct_PANToken "setct-PANToken" -#define NID_setct_PANToken 520 -#define OBJ_setct_PANToken OBJ_set_ctype,1L - -#define SN_setct_PANOnly "setct-PANOnly" -#define NID_setct_PANOnly 521 -#define OBJ_setct_PANOnly OBJ_set_ctype,2L - -#define SN_setct_OIData "setct-OIData" -#define NID_setct_OIData 522 -#define OBJ_setct_OIData OBJ_set_ctype,3L - -#define SN_setct_PI "setct-PI" -#define NID_setct_PI 523 -#define OBJ_setct_PI OBJ_set_ctype,4L - -#define SN_setct_PIData "setct-PIData" -#define NID_setct_PIData 524 -#define OBJ_setct_PIData OBJ_set_ctype,5L - -#define SN_setct_PIDataUnsigned "setct-PIDataUnsigned" -#define NID_setct_PIDataUnsigned 525 -#define OBJ_setct_PIDataUnsigned OBJ_set_ctype,6L - -#define SN_setct_HODInput "setct-HODInput" -#define NID_setct_HODInput 526 -#define OBJ_setct_HODInput OBJ_set_ctype,7L - -#define SN_setct_AuthResBaggage "setct-AuthResBaggage" -#define NID_setct_AuthResBaggage 527 -#define OBJ_setct_AuthResBaggage OBJ_set_ctype,8L - -#define SN_setct_AuthRevReqBaggage "setct-AuthRevReqBaggage" -#define NID_setct_AuthRevReqBaggage 528 -#define OBJ_setct_AuthRevReqBaggage OBJ_set_ctype,9L - -#define SN_setct_AuthRevResBaggage "setct-AuthRevResBaggage" -#define NID_setct_AuthRevResBaggage 529 -#define OBJ_setct_AuthRevResBaggage OBJ_set_ctype,10L - -#define SN_setct_CapTokenSeq "setct-CapTokenSeq" -#define NID_setct_CapTokenSeq 530 -#define OBJ_setct_CapTokenSeq OBJ_set_ctype,11L - -#define SN_setct_PInitResData "setct-PInitResData" -#define NID_setct_PInitResData 531 -#define OBJ_setct_PInitResData OBJ_set_ctype,12L - -#define SN_setct_PI_TBS "setct-PI-TBS" -#define NID_setct_PI_TBS 532 -#define OBJ_setct_PI_TBS OBJ_set_ctype,13L - -#define SN_setct_PResData "setct-PResData" -#define NID_setct_PResData 533 -#define OBJ_setct_PResData OBJ_set_ctype,14L - -#define SN_setct_AuthReqTBS "setct-AuthReqTBS" -#define NID_setct_AuthReqTBS 534 -#define OBJ_setct_AuthReqTBS OBJ_set_ctype,16L - -#define SN_setct_AuthResTBS "setct-AuthResTBS" -#define NID_setct_AuthResTBS 535 -#define OBJ_setct_AuthResTBS OBJ_set_ctype,17L - -#define SN_setct_AuthResTBSX "setct-AuthResTBSX" -#define NID_setct_AuthResTBSX 536 -#define OBJ_setct_AuthResTBSX OBJ_set_ctype,18L - -#define SN_setct_AuthTokenTBS "setct-AuthTokenTBS" -#define NID_setct_AuthTokenTBS 537 -#define OBJ_setct_AuthTokenTBS OBJ_set_ctype,19L - -#define SN_setct_CapTokenData "setct-CapTokenData" -#define NID_setct_CapTokenData 538 -#define OBJ_setct_CapTokenData OBJ_set_ctype,20L - -#define SN_setct_CapTokenTBS "setct-CapTokenTBS" -#define NID_setct_CapTokenTBS 539 -#define OBJ_setct_CapTokenTBS OBJ_set_ctype,21L - -#define SN_setct_AcqCardCodeMsg "setct-AcqCardCodeMsg" -#define NID_setct_AcqCardCodeMsg 540 -#define OBJ_setct_AcqCardCodeMsg OBJ_set_ctype,22L - -#define SN_setct_AuthRevReqTBS "setct-AuthRevReqTBS" -#define NID_setct_AuthRevReqTBS 541 -#define OBJ_setct_AuthRevReqTBS OBJ_set_ctype,23L - -#define SN_setct_AuthRevResData "setct-AuthRevResData" -#define NID_setct_AuthRevResData 542 -#define OBJ_setct_AuthRevResData OBJ_set_ctype,24L - -#define SN_setct_AuthRevResTBS "setct-AuthRevResTBS" -#define NID_setct_AuthRevResTBS 543 -#define OBJ_setct_AuthRevResTBS OBJ_set_ctype,25L - -#define SN_setct_CapReqTBS "setct-CapReqTBS" -#define NID_setct_CapReqTBS 544 -#define OBJ_setct_CapReqTBS OBJ_set_ctype,26L - -#define SN_setct_CapReqTBSX "setct-CapReqTBSX" -#define NID_setct_CapReqTBSX 545 -#define OBJ_setct_CapReqTBSX OBJ_set_ctype,27L - -#define SN_setct_CapResData "setct-CapResData" -#define NID_setct_CapResData 546 -#define OBJ_setct_CapResData OBJ_set_ctype,28L - -#define SN_setct_CapRevReqTBS "setct-CapRevReqTBS" -#define NID_setct_CapRevReqTBS 547 -#define OBJ_setct_CapRevReqTBS OBJ_set_ctype,29L - -#define SN_setct_CapRevReqTBSX "setct-CapRevReqTBSX" -#define NID_setct_CapRevReqTBSX 548 -#define OBJ_setct_CapRevReqTBSX OBJ_set_ctype,30L - -#define SN_setct_CapRevResData "setct-CapRevResData" -#define NID_setct_CapRevResData 549 -#define OBJ_setct_CapRevResData OBJ_set_ctype,31L - -#define SN_setct_CredReqTBS "setct-CredReqTBS" -#define NID_setct_CredReqTBS 550 -#define OBJ_setct_CredReqTBS OBJ_set_ctype,32L - -#define SN_setct_CredReqTBSX "setct-CredReqTBSX" -#define NID_setct_CredReqTBSX 551 -#define OBJ_setct_CredReqTBSX OBJ_set_ctype,33L - -#define SN_setct_CredResData "setct-CredResData" -#define NID_setct_CredResData 552 -#define OBJ_setct_CredResData OBJ_set_ctype,34L - -#define SN_setct_CredRevReqTBS "setct-CredRevReqTBS" -#define NID_setct_CredRevReqTBS 553 -#define OBJ_setct_CredRevReqTBS OBJ_set_ctype,35L - -#define SN_setct_CredRevReqTBSX "setct-CredRevReqTBSX" -#define NID_setct_CredRevReqTBSX 554 -#define OBJ_setct_CredRevReqTBSX OBJ_set_ctype,36L - -#define SN_setct_CredRevResData "setct-CredRevResData" -#define NID_setct_CredRevResData 555 -#define OBJ_setct_CredRevResData OBJ_set_ctype,37L - -#define SN_setct_PCertReqData "setct-PCertReqData" -#define NID_setct_PCertReqData 556 -#define OBJ_setct_PCertReqData OBJ_set_ctype,38L - -#define SN_setct_PCertResTBS "setct-PCertResTBS" -#define NID_setct_PCertResTBS 557 -#define OBJ_setct_PCertResTBS OBJ_set_ctype,39L - -#define SN_setct_BatchAdminReqData "setct-BatchAdminReqData" -#define NID_setct_BatchAdminReqData 558 -#define OBJ_setct_BatchAdminReqData OBJ_set_ctype,40L - -#define SN_setct_BatchAdminResData "setct-BatchAdminResData" -#define NID_setct_BatchAdminResData 559 -#define OBJ_setct_BatchAdminResData OBJ_set_ctype,41L - -#define SN_setct_CardCInitResTBS "setct-CardCInitResTBS" -#define NID_setct_CardCInitResTBS 560 -#define OBJ_setct_CardCInitResTBS OBJ_set_ctype,42L - -#define SN_setct_MeAqCInitResTBS "setct-MeAqCInitResTBS" -#define NID_setct_MeAqCInitResTBS 561 -#define OBJ_setct_MeAqCInitResTBS OBJ_set_ctype,43L - -#define SN_setct_RegFormResTBS "setct-RegFormResTBS" -#define NID_setct_RegFormResTBS 562 -#define OBJ_setct_RegFormResTBS OBJ_set_ctype,44L - -#define SN_setct_CertReqData "setct-CertReqData" -#define NID_setct_CertReqData 563 -#define OBJ_setct_CertReqData OBJ_set_ctype,45L - -#define SN_setct_CertReqTBS "setct-CertReqTBS" -#define NID_setct_CertReqTBS 564 -#define OBJ_setct_CertReqTBS OBJ_set_ctype,46L - -#define SN_setct_CertResData "setct-CertResData" -#define NID_setct_CertResData 565 -#define OBJ_setct_CertResData OBJ_set_ctype,47L - -#define SN_setct_CertInqReqTBS "setct-CertInqReqTBS" -#define NID_setct_CertInqReqTBS 566 -#define OBJ_setct_CertInqReqTBS OBJ_set_ctype,48L - -#define SN_setct_ErrorTBS "setct-ErrorTBS" -#define NID_setct_ErrorTBS 567 -#define OBJ_setct_ErrorTBS OBJ_set_ctype,49L - -#define SN_setct_PIDualSignedTBE "setct-PIDualSignedTBE" -#define NID_setct_PIDualSignedTBE 568 -#define OBJ_setct_PIDualSignedTBE OBJ_set_ctype,50L - -#define SN_setct_PIUnsignedTBE "setct-PIUnsignedTBE" -#define NID_setct_PIUnsignedTBE 569 -#define OBJ_setct_PIUnsignedTBE OBJ_set_ctype,51L - -#define SN_setct_AuthReqTBE "setct-AuthReqTBE" -#define NID_setct_AuthReqTBE 570 -#define OBJ_setct_AuthReqTBE OBJ_set_ctype,52L - -#define SN_setct_AuthResTBE "setct-AuthResTBE" -#define NID_setct_AuthResTBE 571 -#define OBJ_setct_AuthResTBE OBJ_set_ctype,53L - -#define SN_setct_AuthResTBEX "setct-AuthResTBEX" -#define NID_setct_AuthResTBEX 572 -#define OBJ_setct_AuthResTBEX OBJ_set_ctype,54L - -#define SN_setct_AuthTokenTBE "setct-AuthTokenTBE" -#define NID_setct_AuthTokenTBE 573 -#define OBJ_setct_AuthTokenTBE OBJ_set_ctype,55L - -#define SN_setct_CapTokenTBE "setct-CapTokenTBE" -#define NID_setct_CapTokenTBE 574 -#define OBJ_setct_CapTokenTBE OBJ_set_ctype,56L - -#define SN_setct_CapTokenTBEX "setct-CapTokenTBEX" -#define NID_setct_CapTokenTBEX 575 -#define OBJ_setct_CapTokenTBEX OBJ_set_ctype,57L - -#define SN_setct_AcqCardCodeMsgTBE "setct-AcqCardCodeMsgTBE" -#define NID_setct_AcqCardCodeMsgTBE 576 -#define OBJ_setct_AcqCardCodeMsgTBE OBJ_set_ctype,58L - -#define SN_setct_AuthRevReqTBE "setct-AuthRevReqTBE" -#define NID_setct_AuthRevReqTBE 577 -#define OBJ_setct_AuthRevReqTBE OBJ_set_ctype,59L - -#define SN_setct_AuthRevResTBE "setct-AuthRevResTBE" -#define NID_setct_AuthRevResTBE 578 -#define OBJ_setct_AuthRevResTBE OBJ_set_ctype,60L - -#define SN_setct_AuthRevResTBEB "setct-AuthRevResTBEB" -#define NID_setct_AuthRevResTBEB 579 -#define OBJ_setct_AuthRevResTBEB OBJ_set_ctype,61L - -#define SN_setct_CapReqTBE "setct-CapReqTBE" -#define NID_setct_CapReqTBE 580 -#define OBJ_setct_CapReqTBE OBJ_set_ctype,62L - -#define SN_setct_CapReqTBEX "setct-CapReqTBEX" -#define NID_setct_CapReqTBEX 581 -#define OBJ_setct_CapReqTBEX OBJ_set_ctype,63L - -#define SN_setct_CapResTBE "setct-CapResTBE" -#define NID_setct_CapResTBE 582 -#define OBJ_setct_CapResTBE OBJ_set_ctype,64L - -#define SN_setct_CapRevReqTBE "setct-CapRevReqTBE" -#define NID_setct_CapRevReqTBE 583 -#define OBJ_setct_CapRevReqTBE OBJ_set_ctype,65L - -#define SN_setct_CapRevReqTBEX "setct-CapRevReqTBEX" -#define NID_setct_CapRevReqTBEX 584 -#define OBJ_setct_CapRevReqTBEX OBJ_set_ctype,66L - -#define SN_setct_CapRevResTBE "setct-CapRevResTBE" -#define NID_setct_CapRevResTBE 585 -#define OBJ_setct_CapRevResTBE OBJ_set_ctype,67L - -#define SN_setct_CredReqTBE "setct-CredReqTBE" -#define NID_setct_CredReqTBE 586 -#define OBJ_setct_CredReqTBE OBJ_set_ctype,68L - -#define SN_setct_CredReqTBEX "setct-CredReqTBEX" -#define NID_setct_CredReqTBEX 587 -#define OBJ_setct_CredReqTBEX OBJ_set_ctype,69L - -#define SN_setct_CredResTBE "setct-CredResTBE" -#define NID_setct_CredResTBE 588 -#define OBJ_setct_CredResTBE OBJ_set_ctype,70L - -#define SN_setct_CredRevReqTBE "setct-CredRevReqTBE" -#define NID_setct_CredRevReqTBE 589 -#define OBJ_setct_CredRevReqTBE OBJ_set_ctype,71L - -#define SN_setct_CredRevReqTBEX "setct-CredRevReqTBEX" -#define NID_setct_CredRevReqTBEX 590 -#define OBJ_setct_CredRevReqTBEX OBJ_set_ctype,72L - -#define SN_setct_CredRevResTBE "setct-CredRevResTBE" -#define NID_setct_CredRevResTBE 591 -#define OBJ_setct_CredRevResTBE OBJ_set_ctype,73L - -#define SN_setct_BatchAdminReqTBE "setct-BatchAdminReqTBE" -#define NID_setct_BatchAdminReqTBE 592 -#define OBJ_setct_BatchAdminReqTBE OBJ_set_ctype,74L - -#define SN_setct_BatchAdminResTBE "setct-BatchAdminResTBE" -#define NID_setct_BatchAdminResTBE 593 -#define OBJ_setct_BatchAdminResTBE OBJ_set_ctype,75L - -#define SN_setct_RegFormReqTBE "setct-RegFormReqTBE" -#define NID_setct_RegFormReqTBE 594 -#define OBJ_setct_RegFormReqTBE OBJ_set_ctype,76L - -#define SN_setct_CertReqTBE "setct-CertReqTBE" -#define NID_setct_CertReqTBE 595 -#define OBJ_setct_CertReqTBE OBJ_set_ctype,77L - -#define SN_setct_CertReqTBEX "setct-CertReqTBEX" -#define NID_setct_CertReqTBEX 596 -#define OBJ_setct_CertReqTBEX OBJ_set_ctype,78L - -#define SN_setct_CertResTBE "setct-CertResTBE" -#define NID_setct_CertResTBE 597 -#define OBJ_setct_CertResTBE OBJ_set_ctype,79L - -#define SN_setct_CRLNotificationTBS "setct-CRLNotificationTBS" -#define NID_setct_CRLNotificationTBS 598 -#define OBJ_setct_CRLNotificationTBS OBJ_set_ctype,80L - -#define SN_setct_CRLNotificationResTBS "setct-CRLNotificationResTBS" -#define NID_setct_CRLNotificationResTBS 599 -#define OBJ_setct_CRLNotificationResTBS OBJ_set_ctype,81L - -#define SN_setct_BCIDistributionTBS "setct-BCIDistributionTBS" -#define NID_setct_BCIDistributionTBS 600 -#define OBJ_setct_BCIDistributionTBS OBJ_set_ctype,82L - -#define SN_setext_genCrypt "setext-genCrypt" -#define LN_setext_genCrypt "generic cryptogram" -#define NID_setext_genCrypt 601 -#define OBJ_setext_genCrypt OBJ_set_msgExt,1L - -#define SN_setext_miAuth "setext-miAuth" -#define LN_setext_miAuth "merchant initiated auth" -#define NID_setext_miAuth 602 -#define OBJ_setext_miAuth OBJ_set_msgExt,3L - -#define SN_setext_pinSecure "setext-pinSecure" -#define NID_setext_pinSecure 603 -#define OBJ_setext_pinSecure OBJ_set_msgExt,4L - -#define SN_setext_pinAny "setext-pinAny" -#define NID_setext_pinAny 604 -#define OBJ_setext_pinAny OBJ_set_msgExt,5L - -#define SN_setext_track2 "setext-track2" -#define NID_setext_track2 605 -#define OBJ_setext_track2 OBJ_set_msgExt,7L - -#define SN_setext_cv "setext-cv" -#define LN_setext_cv "additional verification" -#define NID_setext_cv 606 -#define OBJ_setext_cv OBJ_set_msgExt,8L - -#define SN_set_policy_root "set-policy-root" -#define NID_set_policy_root 607 -#define OBJ_set_policy_root OBJ_set_policy,0L - -#define SN_setCext_hashedRoot "setCext-hashedRoot" -#define NID_setCext_hashedRoot 608 -#define OBJ_setCext_hashedRoot OBJ_set_certExt,0L - -#define SN_setCext_certType "setCext-certType" -#define NID_setCext_certType 609 -#define OBJ_setCext_certType OBJ_set_certExt,1L - -#define SN_setCext_merchData "setCext-merchData" -#define NID_setCext_merchData 610 -#define OBJ_setCext_merchData OBJ_set_certExt,2L - -#define SN_setCext_cCertRequired "setCext-cCertRequired" -#define NID_setCext_cCertRequired 611 -#define OBJ_setCext_cCertRequired OBJ_set_certExt,3L - -#define SN_setCext_tunneling "setCext-tunneling" -#define NID_setCext_tunneling 612 -#define OBJ_setCext_tunneling OBJ_set_certExt,4L - -#define SN_setCext_setExt "setCext-setExt" -#define NID_setCext_setExt 613 -#define OBJ_setCext_setExt OBJ_set_certExt,5L - -#define SN_setCext_setQualf "setCext-setQualf" -#define NID_setCext_setQualf 614 -#define OBJ_setCext_setQualf OBJ_set_certExt,6L - -#define SN_setCext_PGWYcapabilities "setCext-PGWYcapabilities" -#define NID_setCext_PGWYcapabilities 615 -#define OBJ_setCext_PGWYcapabilities OBJ_set_certExt,7L - -#define SN_setCext_TokenIdentifier "setCext-TokenIdentifier" -#define NID_setCext_TokenIdentifier 616 -#define OBJ_setCext_TokenIdentifier OBJ_set_certExt,8L - -#define SN_setCext_Track2Data "setCext-Track2Data" -#define NID_setCext_Track2Data 617 -#define OBJ_setCext_Track2Data OBJ_set_certExt,9L - -#define SN_setCext_TokenType "setCext-TokenType" -#define NID_setCext_TokenType 618 -#define OBJ_setCext_TokenType OBJ_set_certExt,10L - -#define SN_setCext_IssuerCapabilities "setCext-IssuerCapabilities" -#define NID_setCext_IssuerCapabilities 619 -#define OBJ_setCext_IssuerCapabilities OBJ_set_certExt,11L - -#define SN_setAttr_Cert "setAttr-Cert" -#define NID_setAttr_Cert 620 -#define OBJ_setAttr_Cert OBJ_set_attr,0L - -#define SN_setAttr_PGWYcap "setAttr-PGWYcap" -#define LN_setAttr_PGWYcap "payment gateway capabilities" -#define NID_setAttr_PGWYcap 621 -#define OBJ_setAttr_PGWYcap OBJ_set_attr,1L - -#define SN_setAttr_TokenType "setAttr-TokenType" -#define NID_setAttr_TokenType 622 -#define OBJ_setAttr_TokenType OBJ_set_attr,2L - -#define SN_setAttr_IssCap "setAttr-IssCap" -#define LN_setAttr_IssCap "issuer capabilities" -#define NID_setAttr_IssCap 623 -#define OBJ_setAttr_IssCap OBJ_set_attr,3L - -#define SN_set_rootKeyThumb "set-rootKeyThumb" -#define NID_set_rootKeyThumb 624 -#define OBJ_set_rootKeyThumb OBJ_setAttr_Cert,0L - -#define SN_set_addPolicy "set-addPolicy" -#define NID_set_addPolicy 625 -#define OBJ_set_addPolicy OBJ_setAttr_Cert,1L - -#define SN_setAttr_Token_EMV "setAttr-Token-EMV" -#define NID_setAttr_Token_EMV 626 -#define OBJ_setAttr_Token_EMV OBJ_setAttr_TokenType,1L - -#define SN_setAttr_Token_B0Prime "setAttr-Token-B0Prime" -#define NID_setAttr_Token_B0Prime 627 -#define OBJ_setAttr_Token_B0Prime OBJ_setAttr_TokenType,2L - -#define SN_setAttr_IssCap_CVM "setAttr-IssCap-CVM" -#define NID_setAttr_IssCap_CVM 628 -#define OBJ_setAttr_IssCap_CVM OBJ_setAttr_IssCap,3L - -#define SN_setAttr_IssCap_T2 "setAttr-IssCap-T2" -#define NID_setAttr_IssCap_T2 629 -#define OBJ_setAttr_IssCap_T2 OBJ_setAttr_IssCap,4L - -#define SN_setAttr_IssCap_Sig "setAttr-IssCap-Sig" -#define NID_setAttr_IssCap_Sig 630 -#define OBJ_setAttr_IssCap_Sig OBJ_setAttr_IssCap,5L - -#define SN_setAttr_GenCryptgrm "setAttr-GenCryptgrm" -#define LN_setAttr_GenCryptgrm "generate cryptogram" -#define NID_setAttr_GenCryptgrm 631 -#define OBJ_setAttr_GenCryptgrm OBJ_setAttr_IssCap_CVM,1L - -#define SN_setAttr_T2Enc "setAttr-T2Enc" -#define LN_setAttr_T2Enc "encrypted track 2" -#define NID_setAttr_T2Enc 632 -#define OBJ_setAttr_T2Enc OBJ_setAttr_IssCap_T2,1L - -#define SN_setAttr_T2cleartxt "setAttr-T2cleartxt" -#define LN_setAttr_T2cleartxt "cleartext track 2" -#define NID_setAttr_T2cleartxt 633 -#define OBJ_setAttr_T2cleartxt OBJ_setAttr_IssCap_T2,2L - -#define SN_setAttr_TokICCsig "setAttr-TokICCsig" -#define LN_setAttr_TokICCsig "ICC or token signature" -#define NID_setAttr_TokICCsig 634 -#define OBJ_setAttr_TokICCsig OBJ_setAttr_IssCap_Sig,1L - -#define SN_setAttr_SecDevSig "setAttr-SecDevSig" -#define LN_setAttr_SecDevSig "secure device signature" -#define NID_setAttr_SecDevSig 635 -#define OBJ_setAttr_SecDevSig OBJ_setAttr_IssCap_Sig,2L - -#define SN_set_brand_IATA_ATA "set-brand-IATA-ATA" -#define NID_set_brand_IATA_ATA 636 -#define OBJ_set_brand_IATA_ATA OBJ_set_brand,1L - -#define SN_set_brand_Diners "set-brand-Diners" -#define NID_set_brand_Diners 637 -#define OBJ_set_brand_Diners OBJ_set_brand,30L - -#define SN_set_brand_AmericanExpress "set-brand-AmericanExpress" -#define NID_set_brand_AmericanExpress 638 -#define OBJ_set_brand_AmericanExpress OBJ_set_brand,34L - -#define SN_set_brand_JCB "set-brand-JCB" -#define NID_set_brand_JCB 639 -#define OBJ_set_brand_JCB OBJ_set_brand,35L - -#define SN_set_brand_Visa "set-brand-Visa" -#define NID_set_brand_Visa 640 -#define OBJ_set_brand_Visa OBJ_set_brand,4L - -#define SN_set_brand_MasterCard "set-brand-MasterCard" -#define NID_set_brand_MasterCard 641 -#define OBJ_set_brand_MasterCard OBJ_set_brand,5L - -#define SN_set_brand_Novus "set-brand-Novus" -#define NID_set_brand_Novus 642 -#define OBJ_set_brand_Novus OBJ_set_brand,6011L - -#define SN_des_cdmf "DES-CDMF" -#define LN_des_cdmf "des-cdmf" -#define NID_des_cdmf 643 -#define OBJ_des_cdmf OBJ_rsadsi,3L,10L - -#define SN_rsaOAEPEncryptionSET "rsaOAEPEncryptionSET" -#define NID_rsaOAEPEncryptionSET 644 -#define OBJ_rsaOAEPEncryptionSET OBJ_rsadsi,1L,1L,6L - -#define SN_ipsec3 "Oakley-EC2N-3" -#define LN_ipsec3 "ipsec3" -#define NID_ipsec3 749 - -#define SN_ipsec4 "Oakley-EC2N-4" -#define LN_ipsec4 "ipsec4" -#define NID_ipsec4 750 - -#define SN_whirlpool "whirlpool" -#define NID_whirlpool 804 -#define OBJ_whirlpool OBJ_iso,0L,10118L,3L,0L,55L - -#define SN_cryptopro "cryptopro" -#define NID_cryptopro 805 -#define OBJ_cryptopro OBJ_member_body,643L,2L,2L - -#define SN_cryptocom "cryptocom" -#define NID_cryptocom 806 -#define OBJ_cryptocom OBJ_member_body,643L,2L,9L - -#define SN_id_tc26 "id-tc26" -#define NID_id_tc26 974 -#define OBJ_id_tc26 OBJ_member_body,643L,7L,1L - -#define SN_id_GostR3411_94_with_GostR3410_2001 "id-GostR3411-94-with-GostR3410-2001" -#define LN_id_GostR3411_94_with_GostR3410_2001 "GOST R 34.11-94 with GOST R 34.10-2001" -#define NID_id_GostR3411_94_with_GostR3410_2001 807 -#define OBJ_id_GostR3411_94_with_GostR3410_2001 OBJ_cryptopro,3L - -#define SN_id_GostR3411_94_with_GostR3410_94 "id-GostR3411-94-with-GostR3410-94" -#define LN_id_GostR3411_94_with_GostR3410_94 "GOST R 34.11-94 with GOST R 34.10-94" -#define NID_id_GostR3411_94_with_GostR3410_94 808 -#define OBJ_id_GostR3411_94_with_GostR3410_94 OBJ_cryptopro,4L - -#define SN_id_GostR3411_94 "md_gost94" -#define LN_id_GostR3411_94 "GOST R 34.11-94" -#define NID_id_GostR3411_94 809 -#define OBJ_id_GostR3411_94 OBJ_cryptopro,9L - -#define SN_id_HMACGostR3411_94 "id-HMACGostR3411-94" -#define LN_id_HMACGostR3411_94 "HMAC GOST 34.11-94" -#define NID_id_HMACGostR3411_94 810 -#define OBJ_id_HMACGostR3411_94 OBJ_cryptopro,10L - -#define SN_id_GostR3410_2001 "gost2001" -#define LN_id_GostR3410_2001 "GOST R 34.10-2001" -#define NID_id_GostR3410_2001 811 -#define OBJ_id_GostR3410_2001 OBJ_cryptopro,19L - -#define SN_id_GostR3410_94 "gost94" -#define LN_id_GostR3410_94 "GOST R 34.10-94" -#define NID_id_GostR3410_94 812 -#define OBJ_id_GostR3410_94 OBJ_cryptopro,20L - -#define SN_id_Gost28147_89 "gost89" -#define LN_id_Gost28147_89 "GOST 28147-89" -#define NID_id_Gost28147_89 813 -#define OBJ_id_Gost28147_89 OBJ_cryptopro,21L - -#define SN_gost89_cnt "gost89-cnt" -#define NID_gost89_cnt 814 - -#define SN_gost89_cnt_12 "gost89-cnt-12" -#define NID_gost89_cnt_12 975 - -#define SN_gost89_cbc "gost89-cbc" -#define NID_gost89_cbc 1009 - -#define SN_gost89_ecb "gost89-ecb" -#define NID_gost89_ecb 1010 - -#define SN_gost89_ctr "gost89-ctr" -#define NID_gost89_ctr 1011 - -#define SN_id_Gost28147_89_MAC "gost-mac" -#define LN_id_Gost28147_89_MAC "GOST 28147-89 MAC" -#define NID_id_Gost28147_89_MAC 815 -#define OBJ_id_Gost28147_89_MAC OBJ_cryptopro,22L - -#define SN_gost_mac_12 "gost-mac-12" -#define NID_gost_mac_12 976 - -#define SN_id_GostR3411_94_prf "prf-gostr3411-94" -#define LN_id_GostR3411_94_prf "GOST R 34.11-94 PRF" -#define NID_id_GostR3411_94_prf 816 -#define OBJ_id_GostR3411_94_prf OBJ_cryptopro,23L - -#define SN_id_GostR3410_2001DH "id-GostR3410-2001DH" -#define LN_id_GostR3410_2001DH "GOST R 34.10-2001 DH" -#define NID_id_GostR3410_2001DH 817 -#define OBJ_id_GostR3410_2001DH OBJ_cryptopro,98L - -#define SN_id_GostR3410_94DH "id-GostR3410-94DH" -#define LN_id_GostR3410_94DH "GOST R 34.10-94 DH" -#define NID_id_GostR3410_94DH 818 -#define OBJ_id_GostR3410_94DH OBJ_cryptopro,99L - -#define SN_id_Gost28147_89_CryptoPro_KeyMeshing "id-Gost28147-89-CryptoPro-KeyMeshing" -#define NID_id_Gost28147_89_CryptoPro_KeyMeshing 819 -#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing OBJ_cryptopro,14L,1L - -#define SN_id_Gost28147_89_None_KeyMeshing "id-Gost28147-89-None-KeyMeshing" -#define NID_id_Gost28147_89_None_KeyMeshing 820 -#define OBJ_id_Gost28147_89_None_KeyMeshing OBJ_cryptopro,14L,0L - -#define SN_id_GostR3411_94_TestParamSet "id-GostR3411-94-TestParamSet" -#define NID_id_GostR3411_94_TestParamSet 821 -#define OBJ_id_GostR3411_94_TestParamSet OBJ_cryptopro,30L,0L - -#define SN_id_GostR3411_94_CryptoProParamSet "id-GostR3411-94-CryptoProParamSet" -#define NID_id_GostR3411_94_CryptoProParamSet 822 -#define OBJ_id_GostR3411_94_CryptoProParamSet OBJ_cryptopro,30L,1L - -#define SN_id_Gost28147_89_TestParamSet "id-Gost28147-89-TestParamSet" -#define NID_id_Gost28147_89_TestParamSet 823 -#define OBJ_id_Gost28147_89_TestParamSet OBJ_cryptopro,31L,0L - -#define SN_id_Gost28147_89_CryptoPro_A_ParamSet "id-Gost28147-89-CryptoPro-A-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_A_ParamSet 824 -#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet OBJ_cryptopro,31L,1L - -#define SN_id_Gost28147_89_CryptoPro_B_ParamSet "id-Gost28147-89-CryptoPro-B-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_B_ParamSet 825 -#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet OBJ_cryptopro,31L,2L - -#define SN_id_Gost28147_89_CryptoPro_C_ParamSet "id-Gost28147-89-CryptoPro-C-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_C_ParamSet 826 -#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet OBJ_cryptopro,31L,3L - -#define SN_id_Gost28147_89_CryptoPro_D_ParamSet "id-Gost28147-89-CryptoPro-D-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_D_ParamSet 827 -#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet OBJ_cryptopro,31L,4L - -#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet 828 -#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet OBJ_cryptopro,31L,5L - -#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet 829 -#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet OBJ_cryptopro,31L,6L - -#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet "id-Gost28147-89-CryptoPro-RIC-1-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet 830 -#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet OBJ_cryptopro,31L,7L - -#define SN_id_GostR3410_94_TestParamSet "id-GostR3410-94-TestParamSet" -#define NID_id_GostR3410_94_TestParamSet 831 -#define OBJ_id_GostR3410_94_TestParamSet OBJ_cryptopro,32L,0L - -#define SN_id_GostR3410_94_CryptoPro_A_ParamSet "id-GostR3410-94-CryptoPro-A-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_A_ParamSet 832 -#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet OBJ_cryptopro,32L,2L - -#define SN_id_GostR3410_94_CryptoPro_B_ParamSet "id-GostR3410-94-CryptoPro-B-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_B_ParamSet 833 -#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet OBJ_cryptopro,32L,3L - -#define SN_id_GostR3410_94_CryptoPro_C_ParamSet "id-GostR3410-94-CryptoPro-C-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_C_ParamSet 834 -#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet OBJ_cryptopro,32L,4L - -#define SN_id_GostR3410_94_CryptoPro_D_ParamSet "id-GostR3410-94-CryptoPro-D-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_D_ParamSet 835 -#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet OBJ_cryptopro,32L,5L - -#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet "id-GostR3410-94-CryptoPro-XchA-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet 836 -#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet OBJ_cryptopro,33L,1L - -#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet "id-GostR3410-94-CryptoPro-XchB-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet 837 -#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet OBJ_cryptopro,33L,2L - -#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet "id-GostR3410-94-CryptoPro-XchC-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet 838 -#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet OBJ_cryptopro,33L,3L - -#define SN_id_GostR3410_2001_TestParamSet "id-GostR3410-2001-TestParamSet" -#define NID_id_GostR3410_2001_TestParamSet 839 -#define OBJ_id_GostR3410_2001_TestParamSet OBJ_cryptopro,35L,0L - -#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet "id-GostR3410-2001-CryptoPro-A-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet 840 -#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet OBJ_cryptopro,35L,1L - -#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet "id-GostR3410-2001-CryptoPro-B-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet 841 -#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet OBJ_cryptopro,35L,2L - -#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet "id-GostR3410-2001-CryptoPro-C-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet 842 -#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet OBJ_cryptopro,35L,3L - -#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet "id-GostR3410-2001-CryptoPro-XchA-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet 843 -#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet OBJ_cryptopro,36L,0L - -#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet "id-GostR3410-2001-CryptoPro-XchB-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet 844 -#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet OBJ_cryptopro,36L,1L - -#define SN_id_GostR3410_94_a "id-GostR3410-94-a" -#define NID_id_GostR3410_94_a 845 -#define OBJ_id_GostR3410_94_a OBJ_id_GostR3410_94,1L - -#define SN_id_GostR3410_94_aBis "id-GostR3410-94-aBis" -#define NID_id_GostR3410_94_aBis 846 -#define OBJ_id_GostR3410_94_aBis OBJ_id_GostR3410_94,2L - -#define SN_id_GostR3410_94_b "id-GostR3410-94-b" -#define NID_id_GostR3410_94_b 847 -#define OBJ_id_GostR3410_94_b OBJ_id_GostR3410_94,3L - -#define SN_id_GostR3410_94_bBis "id-GostR3410-94-bBis" -#define NID_id_GostR3410_94_bBis 848 -#define OBJ_id_GostR3410_94_bBis OBJ_id_GostR3410_94,4L - -#define SN_id_Gost28147_89_cc "id-Gost28147-89-cc" -#define LN_id_Gost28147_89_cc "GOST 28147-89 Cryptocom ParamSet" -#define NID_id_Gost28147_89_cc 849 -#define OBJ_id_Gost28147_89_cc OBJ_cryptocom,1L,6L,1L - -#define SN_id_GostR3410_94_cc "gost94cc" -#define LN_id_GostR3410_94_cc "GOST 34.10-94 Cryptocom" -#define NID_id_GostR3410_94_cc 850 -#define OBJ_id_GostR3410_94_cc OBJ_cryptocom,1L,5L,3L - -#define SN_id_GostR3410_2001_cc "gost2001cc" -#define LN_id_GostR3410_2001_cc "GOST 34.10-2001 Cryptocom" -#define NID_id_GostR3410_2001_cc 851 -#define OBJ_id_GostR3410_2001_cc OBJ_cryptocom,1L,5L,4L - -#define SN_id_GostR3411_94_with_GostR3410_94_cc "id-GostR3411-94-with-GostR3410-94-cc" -#define LN_id_GostR3411_94_with_GostR3410_94_cc "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom" -#define NID_id_GostR3411_94_with_GostR3410_94_cc 852 -#define OBJ_id_GostR3411_94_with_GostR3410_94_cc OBJ_cryptocom,1L,3L,3L - -#define SN_id_GostR3411_94_with_GostR3410_2001_cc "id-GostR3411-94-with-GostR3410-2001-cc" -#define LN_id_GostR3411_94_with_GostR3410_2001_cc "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom" -#define NID_id_GostR3411_94_with_GostR3410_2001_cc 853 -#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc OBJ_cryptocom,1L,3L,4L - -#define SN_id_GostR3410_2001_ParamSet_cc "id-GostR3410-2001-ParamSet-cc" -#define LN_id_GostR3410_2001_ParamSet_cc "GOST R 3410-2001 Parameter Set Cryptocom" -#define NID_id_GostR3410_2001_ParamSet_cc 854 -#define OBJ_id_GostR3410_2001_ParamSet_cc OBJ_cryptocom,1L,8L,1L - -#define SN_id_tc26_algorithms "id-tc26-algorithms" -#define NID_id_tc26_algorithms 977 -#define OBJ_id_tc26_algorithms OBJ_id_tc26,1L - -#define SN_id_tc26_sign "id-tc26-sign" -#define NID_id_tc26_sign 978 -#define OBJ_id_tc26_sign OBJ_id_tc26_algorithms,1L - -#define SN_id_GostR3410_2012_256 "gost2012_256" -#define LN_id_GostR3410_2012_256 "GOST R 34.10-2012 with 256 bit modulus" -#define NID_id_GostR3410_2012_256 979 -#define OBJ_id_GostR3410_2012_256 OBJ_id_tc26_sign,1L - -#define SN_id_GostR3410_2012_512 "gost2012_512" -#define LN_id_GostR3410_2012_512 "GOST R 34.10-2012 with 512 bit modulus" -#define NID_id_GostR3410_2012_512 980 -#define OBJ_id_GostR3410_2012_512 OBJ_id_tc26_sign,2L - -#define SN_id_tc26_digest "id-tc26-digest" -#define NID_id_tc26_digest 981 -#define OBJ_id_tc26_digest OBJ_id_tc26_algorithms,2L - -#define SN_id_GostR3411_2012_256 "md_gost12_256" -#define LN_id_GostR3411_2012_256 "GOST R 34.11-2012 with 256 bit hash" -#define NID_id_GostR3411_2012_256 982 -#define OBJ_id_GostR3411_2012_256 OBJ_id_tc26_digest,2L - -#define SN_id_GostR3411_2012_512 "md_gost12_512" -#define LN_id_GostR3411_2012_512 "GOST R 34.11-2012 with 512 bit hash" -#define NID_id_GostR3411_2012_512 983 -#define OBJ_id_GostR3411_2012_512 OBJ_id_tc26_digest,3L - -#define SN_id_tc26_signwithdigest "id-tc26-signwithdigest" -#define NID_id_tc26_signwithdigest 984 -#define OBJ_id_tc26_signwithdigest OBJ_id_tc26_algorithms,3L - -#define SN_id_tc26_signwithdigest_gost3410_2012_256 "id-tc26-signwithdigest-gost3410-2012-256" -#define LN_id_tc26_signwithdigest_gost3410_2012_256 "GOST R 34.10-2012 with GOST R 34.11-2012 (256 bit)" -#define NID_id_tc26_signwithdigest_gost3410_2012_256 985 -#define OBJ_id_tc26_signwithdigest_gost3410_2012_256 OBJ_id_tc26_signwithdigest,2L - -#define SN_id_tc26_signwithdigest_gost3410_2012_512 "id-tc26-signwithdigest-gost3410-2012-512" -#define LN_id_tc26_signwithdigest_gost3410_2012_512 "GOST R 34.10-2012 with GOST R 34.11-2012 (512 bit)" -#define NID_id_tc26_signwithdigest_gost3410_2012_512 986 -#define OBJ_id_tc26_signwithdigest_gost3410_2012_512 OBJ_id_tc26_signwithdigest,3L - -#define SN_id_tc26_mac "id-tc26-mac" -#define NID_id_tc26_mac 987 -#define OBJ_id_tc26_mac OBJ_id_tc26_algorithms,4L - -#define SN_id_tc26_hmac_gost_3411_2012_256 "id-tc26-hmac-gost-3411-2012-256" -#define LN_id_tc26_hmac_gost_3411_2012_256 "HMAC GOST 34.11-2012 256 bit" -#define NID_id_tc26_hmac_gost_3411_2012_256 988 -#define OBJ_id_tc26_hmac_gost_3411_2012_256 OBJ_id_tc26_mac,1L - -#define SN_id_tc26_hmac_gost_3411_2012_512 "id-tc26-hmac-gost-3411-2012-512" -#define LN_id_tc26_hmac_gost_3411_2012_512 "HMAC GOST 34.11-2012 512 bit" -#define NID_id_tc26_hmac_gost_3411_2012_512 989 -#define OBJ_id_tc26_hmac_gost_3411_2012_512 OBJ_id_tc26_mac,2L - -#define SN_id_tc26_cipher "id-tc26-cipher" -#define NID_id_tc26_cipher 990 -#define OBJ_id_tc26_cipher OBJ_id_tc26_algorithms,5L - -#define SN_id_tc26_cipher_gostr3412_2015_magma "id-tc26-cipher-gostr3412-2015-magma" -#define NID_id_tc26_cipher_gostr3412_2015_magma 1173 -#define OBJ_id_tc26_cipher_gostr3412_2015_magma OBJ_id_tc26_cipher,1L - -#define SN_id_tc26_cipher_gostr3412_2015_magma_ctracpkm "id-tc26-cipher-gostr3412-2015-magma-ctracpkm" -#define NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm 1174 -#define OBJ_id_tc26_cipher_gostr3412_2015_magma_ctracpkm OBJ_id_tc26_cipher_gostr3412_2015_magma,1L - -#define SN_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac "id-tc26-cipher-gostr3412-2015-magma-ctracpkm-omac" -#define NID_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac 1175 -#define OBJ_id_tc26_cipher_gostr3412_2015_magma_ctracpkm_omac OBJ_id_tc26_cipher_gostr3412_2015_magma,2L - -#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik "id-tc26-cipher-gostr3412-2015-kuznyechik" -#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik 1176 -#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik OBJ_id_tc26_cipher,2L - -#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm "id-tc26-cipher-gostr3412-2015-kuznyechik-ctracpkm" -#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm 1177 -#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik,1L - -#define SN_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac "id-tc26-cipher-gostr3412-2015-kuznyechik-ctracpkm-omac" -#define NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac 1178 -#define OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac OBJ_id_tc26_cipher_gostr3412_2015_kuznyechik,2L - -#define SN_id_tc26_agreement "id-tc26-agreement" -#define NID_id_tc26_agreement 991 -#define OBJ_id_tc26_agreement OBJ_id_tc26_algorithms,6L - -#define SN_id_tc26_agreement_gost_3410_2012_256 "id-tc26-agreement-gost-3410-2012-256" -#define NID_id_tc26_agreement_gost_3410_2012_256 992 -#define OBJ_id_tc26_agreement_gost_3410_2012_256 OBJ_id_tc26_agreement,1L - -#define SN_id_tc26_agreement_gost_3410_2012_512 "id-tc26-agreement-gost-3410-2012-512" -#define NID_id_tc26_agreement_gost_3410_2012_512 993 -#define OBJ_id_tc26_agreement_gost_3410_2012_512 OBJ_id_tc26_agreement,2L - -#define SN_id_tc26_wrap "id-tc26-wrap" -#define NID_id_tc26_wrap 1179 -#define OBJ_id_tc26_wrap OBJ_id_tc26_algorithms,7L - -#define SN_id_tc26_wrap_gostr3412_2015_magma "id-tc26-wrap-gostr3412-2015-magma" -#define NID_id_tc26_wrap_gostr3412_2015_magma 1180 -#define OBJ_id_tc26_wrap_gostr3412_2015_magma OBJ_id_tc26_wrap,1L - -#define SN_id_tc26_wrap_gostr3412_2015_magma_kexp15 "id-tc26-wrap-gostr3412-2015-magma-kexp15" -#define NID_id_tc26_wrap_gostr3412_2015_magma_kexp15 1181 -#define OBJ_id_tc26_wrap_gostr3412_2015_magma_kexp15 OBJ_id_tc26_wrap_gostr3412_2015_magma,1L - -#define SN_id_tc26_wrap_gostr3412_2015_kuznyechik "id-tc26-wrap-gostr3412-2015-kuznyechik" -#define NID_id_tc26_wrap_gostr3412_2015_kuznyechik 1182 -#define OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik OBJ_id_tc26_wrap,2L - -#define SN_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15 "id-tc26-wrap-gostr3412-2015-kuznyechik-kexp15" -#define NID_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15 1183 -#define OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik_kexp15 OBJ_id_tc26_wrap_gostr3412_2015_kuznyechik,1L - -#define SN_id_tc26_constants "id-tc26-constants" -#define NID_id_tc26_constants 994 -#define OBJ_id_tc26_constants OBJ_id_tc26,2L - -#define SN_id_tc26_sign_constants "id-tc26-sign-constants" -#define NID_id_tc26_sign_constants 995 -#define OBJ_id_tc26_sign_constants OBJ_id_tc26_constants,1L - -#define SN_id_tc26_gost_3410_2012_256_constants "id-tc26-gost-3410-2012-256-constants" -#define NID_id_tc26_gost_3410_2012_256_constants 1147 -#define OBJ_id_tc26_gost_3410_2012_256_constants OBJ_id_tc26_sign_constants,1L - -#define SN_id_tc26_gost_3410_2012_256_paramSetA "id-tc26-gost-3410-2012-256-paramSetA" -#define LN_id_tc26_gost_3410_2012_256_paramSetA "GOST R 34.10-2012 (256 bit) ParamSet A" -#define NID_id_tc26_gost_3410_2012_256_paramSetA 1148 -#define OBJ_id_tc26_gost_3410_2012_256_paramSetA OBJ_id_tc26_gost_3410_2012_256_constants,1L - -#define SN_id_tc26_gost_3410_2012_256_paramSetB "id-tc26-gost-3410-2012-256-paramSetB" -#define LN_id_tc26_gost_3410_2012_256_paramSetB "GOST R 34.10-2012 (256 bit) ParamSet B" -#define NID_id_tc26_gost_3410_2012_256_paramSetB 1184 -#define OBJ_id_tc26_gost_3410_2012_256_paramSetB OBJ_id_tc26_gost_3410_2012_256_constants,2L - -#define SN_id_tc26_gost_3410_2012_256_paramSetC "id-tc26-gost-3410-2012-256-paramSetC" -#define LN_id_tc26_gost_3410_2012_256_paramSetC "GOST R 34.10-2012 (256 bit) ParamSet C" -#define NID_id_tc26_gost_3410_2012_256_paramSetC 1185 -#define OBJ_id_tc26_gost_3410_2012_256_paramSetC OBJ_id_tc26_gost_3410_2012_256_constants,3L - -#define SN_id_tc26_gost_3410_2012_256_paramSetD "id-tc26-gost-3410-2012-256-paramSetD" -#define LN_id_tc26_gost_3410_2012_256_paramSetD "GOST R 34.10-2012 (256 bit) ParamSet D" -#define NID_id_tc26_gost_3410_2012_256_paramSetD 1186 -#define OBJ_id_tc26_gost_3410_2012_256_paramSetD OBJ_id_tc26_gost_3410_2012_256_constants,4L - -#define SN_id_tc26_gost_3410_2012_512_constants "id-tc26-gost-3410-2012-512-constants" -#define NID_id_tc26_gost_3410_2012_512_constants 996 -#define OBJ_id_tc26_gost_3410_2012_512_constants OBJ_id_tc26_sign_constants,2L - -#define SN_id_tc26_gost_3410_2012_512_paramSetTest "id-tc26-gost-3410-2012-512-paramSetTest" -#define LN_id_tc26_gost_3410_2012_512_paramSetTest "GOST R 34.10-2012 (512 bit) testing parameter set" -#define NID_id_tc26_gost_3410_2012_512_paramSetTest 997 -#define OBJ_id_tc26_gost_3410_2012_512_paramSetTest OBJ_id_tc26_gost_3410_2012_512_constants,0L - -#define SN_id_tc26_gost_3410_2012_512_paramSetA "id-tc26-gost-3410-2012-512-paramSetA" -#define LN_id_tc26_gost_3410_2012_512_paramSetA "GOST R 34.10-2012 (512 bit) ParamSet A" -#define NID_id_tc26_gost_3410_2012_512_paramSetA 998 -#define OBJ_id_tc26_gost_3410_2012_512_paramSetA OBJ_id_tc26_gost_3410_2012_512_constants,1L - -#define SN_id_tc26_gost_3410_2012_512_paramSetB "id-tc26-gost-3410-2012-512-paramSetB" -#define LN_id_tc26_gost_3410_2012_512_paramSetB "GOST R 34.10-2012 (512 bit) ParamSet B" -#define NID_id_tc26_gost_3410_2012_512_paramSetB 999 -#define OBJ_id_tc26_gost_3410_2012_512_paramSetB OBJ_id_tc26_gost_3410_2012_512_constants,2L - -#define SN_id_tc26_gost_3410_2012_512_paramSetC "id-tc26-gost-3410-2012-512-paramSetC" -#define LN_id_tc26_gost_3410_2012_512_paramSetC "GOST R 34.10-2012 (512 bit) ParamSet C" -#define NID_id_tc26_gost_3410_2012_512_paramSetC 1149 -#define OBJ_id_tc26_gost_3410_2012_512_paramSetC OBJ_id_tc26_gost_3410_2012_512_constants,3L - -#define SN_id_tc26_digest_constants "id-tc26-digest-constants" -#define NID_id_tc26_digest_constants 1000 -#define OBJ_id_tc26_digest_constants OBJ_id_tc26_constants,2L - -#define SN_id_tc26_cipher_constants "id-tc26-cipher-constants" -#define NID_id_tc26_cipher_constants 1001 -#define OBJ_id_tc26_cipher_constants OBJ_id_tc26_constants,5L - -#define SN_id_tc26_gost_28147_constants "id-tc26-gost-28147-constants" -#define NID_id_tc26_gost_28147_constants 1002 -#define OBJ_id_tc26_gost_28147_constants OBJ_id_tc26_cipher_constants,1L - -#define SN_id_tc26_gost_28147_param_Z "id-tc26-gost-28147-param-Z" -#define LN_id_tc26_gost_28147_param_Z "GOST 28147-89 TC26 parameter set" -#define NID_id_tc26_gost_28147_param_Z 1003 -#define OBJ_id_tc26_gost_28147_param_Z OBJ_id_tc26_gost_28147_constants,1L - -#define SN_INN "INN" -#define LN_INN "INN" -#define NID_INN 1004 -#define OBJ_INN OBJ_member_body,643L,3L,131L,1L,1L - -#define SN_OGRN "OGRN" -#define LN_OGRN "OGRN" -#define NID_OGRN 1005 -#define OBJ_OGRN OBJ_member_body,643L,100L,1L - -#define SN_SNILS "SNILS" -#define LN_SNILS "SNILS" -#define NID_SNILS 1006 -#define OBJ_SNILS OBJ_member_body,643L,100L,3L - -#define SN_subjectSignTool "subjectSignTool" -#define LN_subjectSignTool "Signing Tool of Subject" -#define NID_subjectSignTool 1007 -#define OBJ_subjectSignTool OBJ_member_body,643L,100L,111L - -#define SN_issuerSignTool "issuerSignTool" -#define LN_issuerSignTool "Signing Tool of Issuer" -#define NID_issuerSignTool 1008 -#define OBJ_issuerSignTool OBJ_member_body,643L,100L,112L - -#define SN_grasshopper_ecb "grasshopper-ecb" -#define NID_grasshopper_ecb 1012 - -#define SN_grasshopper_ctr "grasshopper-ctr" -#define NID_grasshopper_ctr 1013 - -#define SN_grasshopper_ofb "grasshopper-ofb" -#define NID_grasshopper_ofb 1014 - -#define SN_grasshopper_cbc "grasshopper-cbc" -#define NID_grasshopper_cbc 1015 - -#define SN_grasshopper_cfb "grasshopper-cfb" -#define NID_grasshopper_cfb 1016 - -#define SN_grasshopper_mac "grasshopper-mac" -#define NID_grasshopper_mac 1017 - -#define SN_magma_ecb "magma-ecb" -#define NID_magma_ecb 1187 - -#define SN_magma_ctr "magma-ctr" -#define NID_magma_ctr 1188 - -#define SN_magma_ofb "magma-ofb" -#define NID_magma_ofb 1189 - -#define SN_magma_cbc "magma-cbc" -#define NID_magma_cbc 1190 - -#define SN_magma_cfb "magma-cfb" -#define NID_magma_cfb 1191 - -#define SN_magma_mac "magma-mac" -#define NID_magma_mac 1192 - -#define SN_camellia_128_cbc "CAMELLIA-128-CBC" -#define LN_camellia_128_cbc "camellia-128-cbc" -#define NID_camellia_128_cbc 751 -#define OBJ_camellia_128_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,2L - -#define SN_camellia_192_cbc "CAMELLIA-192-CBC" -#define LN_camellia_192_cbc "camellia-192-cbc" -#define NID_camellia_192_cbc 752 -#define OBJ_camellia_192_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,3L - -#define SN_camellia_256_cbc "CAMELLIA-256-CBC" -#define LN_camellia_256_cbc "camellia-256-cbc" -#define NID_camellia_256_cbc 753 -#define OBJ_camellia_256_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,4L - -#define SN_id_camellia128_wrap "id-camellia128-wrap" -#define NID_id_camellia128_wrap 907 -#define OBJ_id_camellia128_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,2L - -#define SN_id_camellia192_wrap "id-camellia192-wrap" -#define NID_id_camellia192_wrap 908 -#define OBJ_id_camellia192_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,3L - -#define SN_id_camellia256_wrap "id-camellia256-wrap" -#define NID_id_camellia256_wrap 909 -#define OBJ_id_camellia256_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,4L - -#define OBJ_ntt_ds 0L,3L,4401L,5L - -#define OBJ_camellia OBJ_ntt_ds,3L,1L,9L - -#define SN_camellia_128_ecb "CAMELLIA-128-ECB" -#define LN_camellia_128_ecb "camellia-128-ecb" -#define NID_camellia_128_ecb 754 -#define OBJ_camellia_128_ecb OBJ_camellia,1L - -#define SN_camellia_128_ofb128 "CAMELLIA-128-OFB" -#define LN_camellia_128_ofb128 "camellia-128-ofb" -#define NID_camellia_128_ofb128 766 -#define OBJ_camellia_128_ofb128 OBJ_camellia,3L - -#define SN_camellia_128_cfb128 "CAMELLIA-128-CFB" -#define LN_camellia_128_cfb128 "camellia-128-cfb" -#define NID_camellia_128_cfb128 757 -#define OBJ_camellia_128_cfb128 OBJ_camellia,4L - -#define SN_camellia_128_gcm "CAMELLIA-128-GCM" -#define LN_camellia_128_gcm "camellia-128-gcm" -#define NID_camellia_128_gcm 961 -#define OBJ_camellia_128_gcm OBJ_camellia,6L - -#define SN_camellia_128_ccm "CAMELLIA-128-CCM" -#define LN_camellia_128_ccm "camellia-128-ccm" -#define NID_camellia_128_ccm 962 -#define OBJ_camellia_128_ccm OBJ_camellia,7L - -#define SN_camellia_128_ctr "CAMELLIA-128-CTR" -#define LN_camellia_128_ctr "camellia-128-ctr" -#define NID_camellia_128_ctr 963 -#define OBJ_camellia_128_ctr OBJ_camellia,9L - -#define SN_camellia_128_cmac "CAMELLIA-128-CMAC" -#define LN_camellia_128_cmac "camellia-128-cmac" -#define NID_camellia_128_cmac 964 -#define OBJ_camellia_128_cmac OBJ_camellia,10L - -#define SN_camellia_192_ecb "CAMELLIA-192-ECB" -#define LN_camellia_192_ecb "camellia-192-ecb" -#define NID_camellia_192_ecb 755 -#define OBJ_camellia_192_ecb OBJ_camellia,21L - -#define SN_camellia_192_ofb128 "CAMELLIA-192-OFB" -#define LN_camellia_192_ofb128 "camellia-192-ofb" -#define NID_camellia_192_ofb128 767 -#define OBJ_camellia_192_ofb128 OBJ_camellia,23L - -#define SN_camellia_192_cfb128 "CAMELLIA-192-CFB" -#define LN_camellia_192_cfb128 "camellia-192-cfb" -#define NID_camellia_192_cfb128 758 -#define OBJ_camellia_192_cfb128 OBJ_camellia,24L - -#define SN_camellia_192_gcm "CAMELLIA-192-GCM" -#define LN_camellia_192_gcm "camellia-192-gcm" -#define NID_camellia_192_gcm 965 -#define OBJ_camellia_192_gcm OBJ_camellia,26L - -#define SN_camellia_192_ccm "CAMELLIA-192-CCM" -#define LN_camellia_192_ccm "camellia-192-ccm" -#define NID_camellia_192_ccm 966 -#define OBJ_camellia_192_ccm OBJ_camellia,27L - -#define SN_camellia_192_ctr "CAMELLIA-192-CTR" -#define LN_camellia_192_ctr "camellia-192-ctr" -#define NID_camellia_192_ctr 967 -#define OBJ_camellia_192_ctr OBJ_camellia,29L - -#define SN_camellia_192_cmac "CAMELLIA-192-CMAC" -#define LN_camellia_192_cmac "camellia-192-cmac" -#define NID_camellia_192_cmac 968 -#define OBJ_camellia_192_cmac OBJ_camellia,30L - -#define SN_camellia_256_ecb "CAMELLIA-256-ECB" -#define LN_camellia_256_ecb "camellia-256-ecb" -#define NID_camellia_256_ecb 756 -#define OBJ_camellia_256_ecb OBJ_camellia,41L - -#define SN_camellia_256_ofb128 "CAMELLIA-256-OFB" -#define LN_camellia_256_ofb128 "camellia-256-ofb" -#define NID_camellia_256_ofb128 768 -#define OBJ_camellia_256_ofb128 OBJ_camellia,43L - -#define SN_camellia_256_cfb128 "CAMELLIA-256-CFB" -#define LN_camellia_256_cfb128 "camellia-256-cfb" -#define NID_camellia_256_cfb128 759 -#define OBJ_camellia_256_cfb128 OBJ_camellia,44L - -#define SN_camellia_256_gcm "CAMELLIA-256-GCM" -#define LN_camellia_256_gcm "camellia-256-gcm" -#define NID_camellia_256_gcm 969 -#define OBJ_camellia_256_gcm OBJ_camellia,46L - -#define SN_camellia_256_ccm "CAMELLIA-256-CCM" -#define LN_camellia_256_ccm "camellia-256-ccm" -#define NID_camellia_256_ccm 970 -#define OBJ_camellia_256_ccm OBJ_camellia,47L - -#define SN_camellia_256_ctr "CAMELLIA-256-CTR" -#define LN_camellia_256_ctr "camellia-256-ctr" -#define NID_camellia_256_ctr 971 -#define OBJ_camellia_256_ctr OBJ_camellia,49L - -#define SN_camellia_256_cmac "CAMELLIA-256-CMAC" -#define LN_camellia_256_cmac "camellia-256-cmac" -#define NID_camellia_256_cmac 972 -#define OBJ_camellia_256_cmac OBJ_camellia,50L - -#define SN_camellia_128_cfb1 "CAMELLIA-128-CFB1" -#define LN_camellia_128_cfb1 "camellia-128-cfb1" -#define NID_camellia_128_cfb1 760 - -#define SN_camellia_192_cfb1 "CAMELLIA-192-CFB1" -#define LN_camellia_192_cfb1 "camellia-192-cfb1" -#define NID_camellia_192_cfb1 761 - -#define SN_camellia_256_cfb1 "CAMELLIA-256-CFB1" -#define LN_camellia_256_cfb1 "camellia-256-cfb1" -#define NID_camellia_256_cfb1 762 - -#define SN_camellia_128_cfb8 "CAMELLIA-128-CFB8" -#define LN_camellia_128_cfb8 "camellia-128-cfb8" -#define NID_camellia_128_cfb8 763 - -#define SN_camellia_192_cfb8 "CAMELLIA-192-CFB8" -#define LN_camellia_192_cfb8 "camellia-192-cfb8" -#define NID_camellia_192_cfb8 764 - -#define SN_camellia_256_cfb8 "CAMELLIA-256-CFB8" -#define LN_camellia_256_cfb8 "camellia-256-cfb8" -#define NID_camellia_256_cfb8 765 - -#define OBJ_aria 1L,2L,410L,200046L,1L,1L - -#define SN_aria_128_ecb "ARIA-128-ECB" -#define LN_aria_128_ecb "aria-128-ecb" -#define NID_aria_128_ecb 1065 -#define OBJ_aria_128_ecb OBJ_aria,1L - -#define SN_aria_128_cbc "ARIA-128-CBC" -#define LN_aria_128_cbc "aria-128-cbc" -#define NID_aria_128_cbc 1066 -#define OBJ_aria_128_cbc OBJ_aria,2L - -#define SN_aria_128_cfb128 "ARIA-128-CFB" -#define LN_aria_128_cfb128 "aria-128-cfb" -#define NID_aria_128_cfb128 1067 -#define OBJ_aria_128_cfb128 OBJ_aria,3L - -#define SN_aria_128_ofb128 "ARIA-128-OFB" -#define LN_aria_128_ofb128 "aria-128-ofb" -#define NID_aria_128_ofb128 1068 -#define OBJ_aria_128_ofb128 OBJ_aria,4L - -#define SN_aria_128_ctr "ARIA-128-CTR" -#define LN_aria_128_ctr "aria-128-ctr" -#define NID_aria_128_ctr 1069 -#define OBJ_aria_128_ctr OBJ_aria,5L - -#define SN_aria_192_ecb "ARIA-192-ECB" -#define LN_aria_192_ecb "aria-192-ecb" -#define NID_aria_192_ecb 1070 -#define OBJ_aria_192_ecb OBJ_aria,6L - -#define SN_aria_192_cbc "ARIA-192-CBC" -#define LN_aria_192_cbc "aria-192-cbc" -#define NID_aria_192_cbc 1071 -#define OBJ_aria_192_cbc OBJ_aria,7L - -#define SN_aria_192_cfb128 "ARIA-192-CFB" -#define LN_aria_192_cfb128 "aria-192-cfb" -#define NID_aria_192_cfb128 1072 -#define OBJ_aria_192_cfb128 OBJ_aria,8L - -#define SN_aria_192_ofb128 "ARIA-192-OFB" -#define LN_aria_192_ofb128 "aria-192-ofb" -#define NID_aria_192_ofb128 1073 -#define OBJ_aria_192_ofb128 OBJ_aria,9L - -#define SN_aria_192_ctr "ARIA-192-CTR" -#define LN_aria_192_ctr "aria-192-ctr" -#define NID_aria_192_ctr 1074 -#define OBJ_aria_192_ctr OBJ_aria,10L - -#define SN_aria_256_ecb "ARIA-256-ECB" -#define LN_aria_256_ecb "aria-256-ecb" -#define NID_aria_256_ecb 1075 -#define OBJ_aria_256_ecb OBJ_aria,11L - -#define SN_aria_256_cbc "ARIA-256-CBC" -#define LN_aria_256_cbc "aria-256-cbc" -#define NID_aria_256_cbc 1076 -#define OBJ_aria_256_cbc OBJ_aria,12L - -#define SN_aria_256_cfb128 "ARIA-256-CFB" -#define LN_aria_256_cfb128 "aria-256-cfb" -#define NID_aria_256_cfb128 1077 -#define OBJ_aria_256_cfb128 OBJ_aria,13L - -#define SN_aria_256_ofb128 "ARIA-256-OFB" -#define LN_aria_256_ofb128 "aria-256-ofb" -#define NID_aria_256_ofb128 1078 -#define OBJ_aria_256_ofb128 OBJ_aria,14L - -#define SN_aria_256_ctr "ARIA-256-CTR" -#define LN_aria_256_ctr "aria-256-ctr" -#define NID_aria_256_ctr 1079 -#define OBJ_aria_256_ctr OBJ_aria,15L - -#define SN_aria_128_cfb1 "ARIA-128-CFB1" -#define LN_aria_128_cfb1 "aria-128-cfb1" -#define NID_aria_128_cfb1 1080 - -#define SN_aria_192_cfb1 "ARIA-192-CFB1" -#define LN_aria_192_cfb1 "aria-192-cfb1" -#define NID_aria_192_cfb1 1081 - -#define SN_aria_256_cfb1 "ARIA-256-CFB1" -#define LN_aria_256_cfb1 "aria-256-cfb1" -#define NID_aria_256_cfb1 1082 - -#define SN_aria_128_cfb8 "ARIA-128-CFB8" -#define LN_aria_128_cfb8 "aria-128-cfb8" -#define NID_aria_128_cfb8 1083 - -#define SN_aria_192_cfb8 "ARIA-192-CFB8" -#define LN_aria_192_cfb8 "aria-192-cfb8" -#define NID_aria_192_cfb8 1084 - -#define SN_aria_256_cfb8 "ARIA-256-CFB8" -#define LN_aria_256_cfb8 "aria-256-cfb8" -#define NID_aria_256_cfb8 1085 - -#define SN_aria_128_ccm "ARIA-128-CCM" -#define LN_aria_128_ccm "aria-128-ccm" -#define NID_aria_128_ccm 1120 -#define OBJ_aria_128_ccm OBJ_aria,37L - -#define SN_aria_192_ccm "ARIA-192-CCM" -#define LN_aria_192_ccm "aria-192-ccm" -#define NID_aria_192_ccm 1121 -#define OBJ_aria_192_ccm OBJ_aria,38L - -#define SN_aria_256_ccm "ARIA-256-CCM" -#define LN_aria_256_ccm "aria-256-ccm" -#define NID_aria_256_ccm 1122 -#define OBJ_aria_256_ccm OBJ_aria,39L - -#define SN_aria_128_gcm "ARIA-128-GCM" -#define LN_aria_128_gcm "aria-128-gcm" -#define NID_aria_128_gcm 1123 -#define OBJ_aria_128_gcm OBJ_aria,34L - -#define SN_aria_192_gcm "ARIA-192-GCM" -#define LN_aria_192_gcm "aria-192-gcm" -#define NID_aria_192_gcm 1124 -#define OBJ_aria_192_gcm OBJ_aria,35L - -#define SN_aria_256_gcm "ARIA-256-GCM" -#define LN_aria_256_gcm "aria-256-gcm" -#define NID_aria_256_gcm 1125 -#define OBJ_aria_256_gcm OBJ_aria,36L - -#define SN_kisa "KISA" -#define LN_kisa "kisa" -#define NID_kisa 773 -#define OBJ_kisa OBJ_member_body,410L,200004L - -#define SN_seed_ecb "SEED-ECB" -#define LN_seed_ecb "seed-ecb" -#define NID_seed_ecb 776 -#define OBJ_seed_ecb OBJ_kisa,1L,3L - -#define SN_seed_cbc "SEED-CBC" -#define LN_seed_cbc "seed-cbc" -#define NID_seed_cbc 777 -#define OBJ_seed_cbc OBJ_kisa,1L,4L - -#define SN_seed_cfb128 "SEED-CFB" -#define LN_seed_cfb128 "seed-cfb" -#define NID_seed_cfb128 779 -#define OBJ_seed_cfb128 OBJ_kisa,1L,5L - -#define SN_seed_ofb128 "SEED-OFB" -#define LN_seed_ofb128 "seed-ofb" -#define NID_seed_ofb128 778 -#define OBJ_seed_ofb128 OBJ_kisa,1L,6L - -#define SN_sm4_ecb "SM4-ECB" -#define LN_sm4_ecb "sm4-ecb" -#define NID_sm4_ecb 1133 -#define OBJ_sm4_ecb OBJ_sm_scheme,104L,1L - -#define SN_sm4_cbc "SM4-CBC" -#define LN_sm4_cbc "sm4-cbc" -#define NID_sm4_cbc 1134 -#define OBJ_sm4_cbc OBJ_sm_scheme,104L,2L - -#define SN_sm4_ofb128 "SM4-OFB" -#define LN_sm4_ofb128 "sm4-ofb" -#define NID_sm4_ofb128 1135 -#define OBJ_sm4_ofb128 OBJ_sm_scheme,104L,3L - -#define SN_sm4_cfb128 "SM4-CFB" -#define LN_sm4_cfb128 "sm4-cfb" -#define NID_sm4_cfb128 1137 -#define OBJ_sm4_cfb128 OBJ_sm_scheme,104L,4L - -#define SN_sm4_cfb1 "SM4-CFB1" -#define LN_sm4_cfb1 "sm4-cfb1" -#define NID_sm4_cfb1 1136 -#define OBJ_sm4_cfb1 OBJ_sm_scheme,104L,5L - -#define SN_sm4_cfb8 "SM4-CFB8" -#define LN_sm4_cfb8 "sm4-cfb8" -#define NID_sm4_cfb8 1138 -#define OBJ_sm4_cfb8 OBJ_sm_scheme,104L,6L - -#define SN_sm4_ctr "SM4-CTR" -#define LN_sm4_ctr "sm4-ctr" -#define NID_sm4_ctr 1139 -#define OBJ_sm4_ctr OBJ_sm_scheme,104L,7L - -#define SN_hmac "HMAC" -#define LN_hmac "hmac" -#define NID_hmac 855 - -#define SN_cmac "CMAC" -#define LN_cmac "cmac" -#define NID_cmac 894 - -#define SN_rc4_hmac_md5 "RC4-HMAC-MD5" -#define LN_rc4_hmac_md5 "rc4-hmac-md5" -#define NID_rc4_hmac_md5 915 - -#define SN_aes_128_cbc_hmac_sha1 "AES-128-CBC-HMAC-SHA1" -#define LN_aes_128_cbc_hmac_sha1 "aes-128-cbc-hmac-sha1" -#define NID_aes_128_cbc_hmac_sha1 916 - -#define SN_aes_192_cbc_hmac_sha1 "AES-192-CBC-HMAC-SHA1" -#define LN_aes_192_cbc_hmac_sha1 "aes-192-cbc-hmac-sha1" -#define NID_aes_192_cbc_hmac_sha1 917 - -#define SN_aes_256_cbc_hmac_sha1 "AES-256-CBC-HMAC-SHA1" -#define LN_aes_256_cbc_hmac_sha1 "aes-256-cbc-hmac-sha1" -#define NID_aes_256_cbc_hmac_sha1 918 - -#define SN_aes_128_cbc_hmac_sha256 "AES-128-CBC-HMAC-SHA256" -#define LN_aes_128_cbc_hmac_sha256 "aes-128-cbc-hmac-sha256" -#define NID_aes_128_cbc_hmac_sha256 948 - -#define SN_aes_192_cbc_hmac_sha256 "AES-192-CBC-HMAC-SHA256" -#define LN_aes_192_cbc_hmac_sha256 "aes-192-cbc-hmac-sha256" -#define NID_aes_192_cbc_hmac_sha256 949 - -#define SN_aes_256_cbc_hmac_sha256 "AES-256-CBC-HMAC-SHA256" -#define LN_aes_256_cbc_hmac_sha256 "aes-256-cbc-hmac-sha256" -#define NID_aes_256_cbc_hmac_sha256 950 - -#define SN_chacha20_poly1305 "ChaCha20-Poly1305" -#define LN_chacha20_poly1305 "chacha20-poly1305" -#define NID_chacha20_poly1305 1018 - -#define SN_chacha20 "ChaCha20" -#define LN_chacha20 "chacha20" -#define NID_chacha20 1019 - -#define SN_dhpublicnumber "dhpublicnumber" -#define LN_dhpublicnumber "X9.42 DH" -#define NID_dhpublicnumber 920 -#define OBJ_dhpublicnumber OBJ_ISO_US,10046L,2L,1L - -#define SN_brainpoolP160r1 "brainpoolP160r1" -#define NID_brainpoolP160r1 921 -#define OBJ_brainpoolP160r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,1L - -#define SN_brainpoolP160t1 "brainpoolP160t1" -#define NID_brainpoolP160t1 922 -#define OBJ_brainpoolP160t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,2L - -#define SN_brainpoolP192r1 "brainpoolP192r1" -#define NID_brainpoolP192r1 923 -#define OBJ_brainpoolP192r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,3L - -#define SN_brainpoolP192t1 "brainpoolP192t1" -#define NID_brainpoolP192t1 924 -#define OBJ_brainpoolP192t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,4L - -#define SN_brainpoolP224r1 "brainpoolP224r1" -#define NID_brainpoolP224r1 925 -#define OBJ_brainpoolP224r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,5L - -#define SN_brainpoolP224t1 "brainpoolP224t1" -#define NID_brainpoolP224t1 926 -#define OBJ_brainpoolP224t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,6L - -#define SN_brainpoolP256r1 "brainpoolP256r1" -#define NID_brainpoolP256r1 927 -#define OBJ_brainpoolP256r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,7L - -#define SN_brainpoolP256t1 "brainpoolP256t1" -#define NID_brainpoolP256t1 928 -#define OBJ_brainpoolP256t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,8L - -#define SN_brainpoolP320r1 "brainpoolP320r1" -#define NID_brainpoolP320r1 929 -#define OBJ_brainpoolP320r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,9L - -#define SN_brainpoolP320t1 "brainpoolP320t1" -#define NID_brainpoolP320t1 930 -#define OBJ_brainpoolP320t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,10L - -#define SN_brainpoolP384r1 "brainpoolP384r1" -#define NID_brainpoolP384r1 931 -#define OBJ_brainpoolP384r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,11L - -#define SN_brainpoolP384t1 "brainpoolP384t1" -#define NID_brainpoolP384t1 932 -#define OBJ_brainpoolP384t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,12L - -#define SN_brainpoolP512r1 "brainpoolP512r1" -#define NID_brainpoolP512r1 933 -#define OBJ_brainpoolP512r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,13L - -#define SN_brainpoolP512t1 "brainpoolP512t1" -#define NID_brainpoolP512t1 934 -#define OBJ_brainpoolP512t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,14L - -#define OBJ_x9_63_scheme 1L,3L,133L,16L,840L,63L,0L - -#define OBJ_secg_scheme OBJ_certicom_arc,1L - -#define SN_dhSinglePass_stdDH_sha1kdf_scheme "dhSinglePass-stdDH-sha1kdf-scheme" -#define NID_dhSinglePass_stdDH_sha1kdf_scheme 936 -#define OBJ_dhSinglePass_stdDH_sha1kdf_scheme OBJ_x9_63_scheme,2L - -#define SN_dhSinglePass_stdDH_sha224kdf_scheme "dhSinglePass-stdDH-sha224kdf-scheme" -#define NID_dhSinglePass_stdDH_sha224kdf_scheme 937 -#define OBJ_dhSinglePass_stdDH_sha224kdf_scheme OBJ_secg_scheme,11L,0L - -#define SN_dhSinglePass_stdDH_sha256kdf_scheme "dhSinglePass-stdDH-sha256kdf-scheme" -#define NID_dhSinglePass_stdDH_sha256kdf_scheme 938 -#define OBJ_dhSinglePass_stdDH_sha256kdf_scheme OBJ_secg_scheme,11L,1L - -#define SN_dhSinglePass_stdDH_sha384kdf_scheme "dhSinglePass-stdDH-sha384kdf-scheme" -#define NID_dhSinglePass_stdDH_sha384kdf_scheme 939 -#define OBJ_dhSinglePass_stdDH_sha384kdf_scheme OBJ_secg_scheme,11L,2L - -#define SN_dhSinglePass_stdDH_sha512kdf_scheme "dhSinglePass-stdDH-sha512kdf-scheme" -#define NID_dhSinglePass_stdDH_sha512kdf_scheme 940 -#define OBJ_dhSinglePass_stdDH_sha512kdf_scheme OBJ_secg_scheme,11L,3L - -#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme "dhSinglePass-cofactorDH-sha1kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha1kdf_scheme 941 -#define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme OBJ_x9_63_scheme,3L - -#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme "dhSinglePass-cofactorDH-sha224kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha224kdf_scheme 942 -#define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme OBJ_secg_scheme,14L,0L - -#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme "dhSinglePass-cofactorDH-sha256kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha256kdf_scheme 943 -#define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme OBJ_secg_scheme,14L,1L - -#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme "dhSinglePass-cofactorDH-sha384kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha384kdf_scheme 944 -#define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme OBJ_secg_scheme,14L,2L - -#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme "dhSinglePass-cofactorDH-sha512kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha512kdf_scheme 945 -#define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme OBJ_secg_scheme,14L,3L - -#define SN_dh_std_kdf "dh-std-kdf" -#define NID_dh_std_kdf 946 - -#define SN_dh_cofactor_kdf "dh-cofactor-kdf" -#define NID_dh_cofactor_kdf 947 - -#define SN_ct_precert_scts "ct_precert_scts" -#define LN_ct_precert_scts "CT Precertificate SCTs" -#define NID_ct_precert_scts 951 -#define OBJ_ct_precert_scts 1L,3L,6L,1L,4L,1L,11129L,2L,4L,2L - -#define SN_ct_precert_poison "ct_precert_poison" -#define LN_ct_precert_poison "CT Precertificate Poison" -#define NID_ct_precert_poison 952 -#define OBJ_ct_precert_poison 1L,3L,6L,1L,4L,1L,11129L,2L,4L,3L - -#define SN_ct_precert_signer "ct_precert_signer" -#define LN_ct_precert_signer "CT Precertificate Signer" -#define NID_ct_precert_signer 953 -#define OBJ_ct_precert_signer 1L,3L,6L,1L,4L,1L,11129L,2L,4L,4L - -#define SN_ct_cert_scts "ct_cert_scts" -#define LN_ct_cert_scts "CT Certificate SCTs" -#define NID_ct_cert_scts 954 -#define OBJ_ct_cert_scts 1L,3L,6L,1L,4L,1L,11129L,2L,4L,5L - -#define SN_jurisdictionLocalityName "jurisdictionL" -#define LN_jurisdictionLocalityName "jurisdictionLocalityName" -#define NID_jurisdictionLocalityName 955 -#define OBJ_jurisdictionLocalityName 1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,1L - -#define SN_jurisdictionStateOrProvinceName "jurisdictionST" -#define LN_jurisdictionStateOrProvinceName "jurisdictionStateOrProvinceName" -#define NID_jurisdictionStateOrProvinceName 956 -#define OBJ_jurisdictionStateOrProvinceName 1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,2L - -#define SN_jurisdictionCountryName "jurisdictionC" -#define LN_jurisdictionCountryName "jurisdictionCountryName" -#define NID_jurisdictionCountryName 957 -#define OBJ_jurisdictionCountryName 1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,3L - -#define SN_id_scrypt "id-scrypt" -#define LN_id_scrypt "scrypt" -#define NID_id_scrypt 973 -#define OBJ_id_scrypt 1L,3L,6L,1L,4L,1L,11591L,4L,11L - -#define SN_tls1_prf "TLS1-PRF" -#define LN_tls1_prf "tls1-prf" -#define NID_tls1_prf 1021 - -#define SN_hkdf "HKDF" -#define LN_hkdf "hkdf" -#define NID_hkdf 1036 - -#define SN_id_pkinit "id-pkinit" -#define NID_id_pkinit 1031 -#define OBJ_id_pkinit 1L,3L,6L,1L,5L,2L,3L - -#define SN_pkInitClientAuth "pkInitClientAuth" -#define LN_pkInitClientAuth "PKINIT Client Auth" -#define NID_pkInitClientAuth 1032 -#define OBJ_pkInitClientAuth OBJ_id_pkinit,4L - -#define SN_pkInitKDC "pkInitKDC" -#define LN_pkInitKDC "Signing KDC Response" -#define NID_pkInitKDC 1033 -#define OBJ_pkInitKDC OBJ_id_pkinit,5L - -#define SN_X25519 "X25519" -#define NID_X25519 1034 -#define OBJ_X25519 1L,3L,101L,110L - -#define SN_X448 "X448" -#define NID_X448 1035 -#define OBJ_X448 1L,3L,101L,111L - -#define SN_ED25519 "ED25519" -#define NID_ED25519 1087 -#define OBJ_ED25519 1L,3L,101L,112L - -#define SN_ED448 "ED448" -#define NID_ED448 1088 -#define OBJ_ED448 1L,3L,101L,113L - -#define SN_kx_rsa "KxRSA" -#define LN_kx_rsa "kx-rsa" -#define NID_kx_rsa 1037 - -#define SN_kx_ecdhe "KxECDHE" -#define LN_kx_ecdhe "kx-ecdhe" -#define NID_kx_ecdhe 1038 - -#define SN_kx_dhe "KxDHE" -#define LN_kx_dhe "kx-dhe" -#define NID_kx_dhe 1039 - -#define SN_kx_ecdhe_psk "KxECDHE-PSK" -#define LN_kx_ecdhe_psk "kx-ecdhe-psk" -#define NID_kx_ecdhe_psk 1040 - -#define SN_kx_dhe_psk "KxDHE-PSK" -#define LN_kx_dhe_psk "kx-dhe-psk" -#define NID_kx_dhe_psk 1041 - -#define SN_kx_rsa_psk "KxRSA_PSK" -#define LN_kx_rsa_psk "kx-rsa-psk" -#define NID_kx_rsa_psk 1042 - -#define SN_kx_psk "KxPSK" -#define LN_kx_psk "kx-psk" -#define NID_kx_psk 1043 - -#define SN_kx_srp "KxSRP" -#define LN_kx_srp "kx-srp" -#define NID_kx_srp 1044 - -#define SN_kx_gost "KxGOST" -#define LN_kx_gost "kx-gost" -#define NID_kx_gost 1045 - -#define SN_kx_any "KxANY" -#define LN_kx_any "kx-any" -#define NID_kx_any 1063 - -#define SN_auth_rsa "AuthRSA" -#define LN_auth_rsa "auth-rsa" -#define NID_auth_rsa 1046 - -#define SN_auth_ecdsa "AuthECDSA" -#define LN_auth_ecdsa "auth-ecdsa" -#define NID_auth_ecdsa 1047 - -#define SN_auth_psk "AuthPSK" -#define LN_auth_psk "auth-psk" -#define NID_auth_psk 1048 - -#define SN_auth_dss "AuthDSS" -#define LN_auth_dss "auth-dss" -#define NID_auth_dss 1049 - -#define SN_auth_gost01 "AuthGOST01" -#define LN_auth_gost01 "auth-gost01" -#define NID_auth_gost01 1050 - -#define SN_auth_gost12 "AuthGOST12" -#define LN_auth_gost12 "auth-gost12" -#define NID_auth_gost12 1051 - -#define SN_auth_srp "AuthSRP" -#define LN_auth_srp "auth-srp" -#define NID_auth_srp 1052 - -#define SN_auth_null "AuthNULL" -#define LN_auth_null "auth-null" -#define NID_auth_null 1053 - -#define SN_auth_any "AuthANY" -#define LN_auth_any "auth-any" -#define NID_auth_any 1064 - -#define SN_poly1305 "Poly1305" -#define LN_poly1305 "poly1305" -#define NID_poly1305 1061 - -#define SN_siphash "SipHash" -#define LN_siphash "siphash" -#define NID_siphash 1062 - -#define SN_ffdhe2048 "ffdhe2048" -#define NID_ffdhe2048 1126 - -#define SN_ffdhe3072 "ffdhe3072" -#define NID_ffdhe3072 1127 - -#define SN_ffdhe4096 "ffdhe4096" -#define NID_ffdhe4096 1128 - -#define SN_ffdhe6144 "ffdhe6144" -#define NID_ffdhe6144 1129 - -#define SN_ffdhe8192 "ffdhe8192" -#define NID_ffdhe8192 1130 - -#define SN_ISO_UA "ISO-UA" -#define NID_ISO_UA 1150 -#define OBJ_ISO_UA OBJ_member_body,804L - -#define SN_ua_pki "ua-pki" -#define NID_ua_pki 1151 -#define OBJ_ua_pki OBJ_ISO_UA,2L,1L,1L,1L - -#define SN_dstu28147 "dstu28147" -#define LN_dstu28147 "DSTU Gost 28147-2009" -#define NID_dstu28147 1152 -#define OBJ_dstu28147 OBJ_ua_pki,1L,1L,1L - -#define SN_dstu28147_ofb "dstu28147-ofb" -#define LN_dstu28147_ofb "DSTU Gost 28147-2009 OFB mode" -#define NID_dstu28147_ofb 1153 -#define OBJ_dstu28147_ofb OBJ_dstu28147,2L - -#define SN_dstu28147_cfb "dstu28147-cfb" -#define LN_dstu28147_cfb "DSTU Gost 28147-2009 CFB mode" -#define NID_dstu28147_cfb 1154 -#define OBJ_dstu28147_cfb OBJ_dstu28147,3L - -#define SN_dstu28147_wrap "dstu28147-wrap" -#define LN_dstu28147_wrap "DSTU Gost 28147-2009 key wrap" -#define NID_dstu28147_wrap 1155 -#define OBJ_dstu28147_wrap OBJ_dstu28147,5L - -#define SN_hmacWithDstu34311 "hmacWithDstu34311" -#define LN_hmacWithDstu34311 "HMAC DSTU Gost 34311-95" -#define NID_hmacWithDstu34311 1156 -#define OBJ_hmacWithDstu34311 OBJ_ua_pki,1L,1L,2L - -#define SN_dstu34311 "dstu34311" -#define LN_dstu34311 "DSTU Gost 34311-95" -#define NID_dstu34311 1157 -#define OBJ_dstu34311 OBJ_ua_pki,1L,2L,1L - -#define SN_dstu4145le "dstu4145le" -#define LN_dstu4145le "DSTU 4145-2002 little endian" -#define NID_dstu4145le 1158 -#define OBJ_dstu4145le OBJ_ua_pki,1L,3L,1L,1L - -#define SN_dstu4145be "dstu4145be" -#define LN_dstu4145be "DSTU 4145-2002 big endian" -#define NID_dstu4145be 1159 -#define OBJ_dstu4145be OBJ_dstu4145le,1L,1L - -#define SN_uacurve0 "uacurve0" -#define LN_uacurve0 "DSTU curve 0" -#define NID_uacurve0 1160 -#define OBJ_uacurve0 OBJ_dstu4145le,2L,0L - -#define SN_uacurve1 "uacurve1" -#define LN_uacurve1 "DSTU curve 1" -#define NID_uacurve1 1161 -#define OBJ_uacurve1 OBJ_dstu4145le,2L,1L - -#define SN_uacurve2 "uacurve2" -#define LN_uacurve2 "DSTU curve 2" -#define NID_uacurve2 1162 -#define OBJ_uacurve2 OBJ_dstu4145le,2L,2L - -#define SN_uacurve3 "uacurve3" -#define LN_uacurve3 "DSTU curve 3" -#define NID_uacurve3 1163 -#define OBJ_uacurve3 OBJ_dstu4145le,2L,3L - -#define SN_uacurve4 "uacurve4" -#define LN_uacurve4 "DSTU curve 4" -#define NID_uacurve4 1164 -#define OBJ_uacurve4 OBJ_dstu4145le,2L,4L - -#define SN_uacurve5 "uacurve5" -#define LN_uacurve5 "DSTU curve 5" -#define NID_uacurve5 1165 -#define OBJ_uacurve5 OBJ_dstu4145le,2L,5L - -#define SN_uacurve6 "uacurve6" -#define LN_uacurve6 "DSTU curve 6" -#define NID_uacurve6 1166 -#define OBJ_uacurve6 OBJ_dstu4145le,2L,6L - -#define SN_uacurve7 "uacurve7" -#define LN_uacurve7 "DSTU curve 7" -#define NID_uacurve7 1167 -#define OBJ_uacurve7 OBJ_dstu4145le,2L,7L - -#define SN_uacurve8 "uacurve8" -#define LN_uacurve8 "DSTU curve 8" -#define NID_uacurve8 1168 -#define OBJ_uacurve8 OBJ_dstu4145le,2L,8L - -#define SN_uacurve9 "uacurve9" -#define LN_uacurve9 "DSTU curve 9" -#define NID_uacurve9 1169 -#define OBJ_uacurve9 OBJ_dstu4145le,2L,9L diff --git a/client/3rd/OpenSSL/include/openssl/objects.h b/client/3rd/OpenSSL/include/openssl/objects.h deleted file mode 100644 index 5e8b5762..00000000 --- a/client/3rd/OpenSSL/include/openssl/objects.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OBJECTS_H -# define HEADER_OBJECTS_H - -# include -# include -# include -# include - -# define OBJ_NAME_TYPE_UNDEF 0x00 -# define OBJ_NAME_TYPE_MD_METH 0x01 -# define OBJ_NAME_TYPE_CIPHER_METH 0x02 -# define OBJ_NAME_TYPE_PKEY_METH 0x03 -# define OBJ_NAME_TYPE_COMP_METH 0x04 -# define OBJ_NAME_TYPE_NUM 0x05 - -# define OBJ_NAME_ALIAS 0x8000 - -# define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01 -# define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct obj_name_st { - int type; - int alias; - const char *name; - const char *data; -} OBJ_NAME; - -# define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c) - -int OBJ_NAME_init(void); -int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *), - int (*cmp_func) (const char *, const char *), - void (*free_func) (const char *, int, const char *)); -const char *OBJ_NAME_get(const char *name, int type); -int OBJ_NAME_add(const char *name, int type, const char *data); -int OBJ_NAME_remove(const char *name, int type); -void OBJ_NAME_cleanup(int type); /* -1 for everything */ -void OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg), - void *arg); -void OBJ_NAME_do_all_sorted(int type, - void (*fn) (const OBJ_NAME *, void *arg), - void *arg); - -ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o); -ASN1_OBJECT *OBJ_nid2obj(int n); -const char *OBJ_nid2ln(int n); -const char *OBJ_nid2sn(int n); -int OBJ_obj2nid(const ASN1_OBJECT *o); -ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name); -int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name); -int OBJ_txt2nid(const char *s); -int OBJ_ln2nid(const char *s); -int OBJ_sn2nid(const char *s); -int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b); -const void *OBJ_bsearch_(const void *key, const void *base, int num, int size, - int (*cmp) (const void *, const void *)); -const void *OBJ_bsearch_ex_(const void *key, const void *base, int num, - int size, - int (*cmp) (const void *, const void *), - int flags); - -# define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \ - static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \ - static int nm##_cmp(type1 const *, type2 const *); \ - scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) - -# define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp) \ - _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp) -# define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ - type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) - -/*- - * Unsolved problem: if a type is actually a pointer type, like - * nid_triple is, then its impossible to get a const where you need - * it. Consider: - * - * typedef int nid_triple[3]; - * const void *a_; - * const nid_triple const *a = a_; - * - * The assignment discards a const because what you really want is: - * - * const int const * const *a = a_; - * - * But if you do that, you lose the fact that a is an array of 3 ints, - * which breaks comparison functions. - * - * Thus we end up having to cast, sadly, or unpack the - * declarations. Or, as I finally did in this case, declare nid_triple - * to be a struct, which it should have been in the first place. - * - * Ben, August 2008. - * - * Also, strictly speaking not all types need be const, but handling - * the non-constness means a lot of complication, and in practice - * comparison routines do always not touch their arguments. - */ - -# define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm) \ - static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ - { \ - type1 const *a = a_; \ - type2 const *b = b_; \ - return nm##_cmp(a,b); \ - } \ - static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ - { \ - return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ - nm##_cmp_BSEARCH_CMP_FN); \ - } \ - extern void dummy_prototype(void) - -# define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ - static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ - { \ - type1 const *a = a_; \ - type2 const *b = b_; \ - return nm##_cmp(a,b); \ - } \ - type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ - { \ - return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ - nm##_cmp_BSEARCH_CMP_FN); \ - } \ - extern void dummy_prototype(void) - -# define OBJ_bsearch(type1,key,type2,base,num,cmp) \ - ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \ - num,sizeof(type2), \ - ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \ - (void)CHECKED_PTR_OF(type2,cmp##_type_2), \ - cmp##_BSEARCH_CMP_FN))) - -# define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags) \ - ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \ - num,sizeof(type2), \ - ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \ - (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \ - cmp##_BSEARCH_CMP_FN)),flags) - -int OBJ_new_nid(int num); -int OBJ_add_object(const ASN1_OBJECT *obj); -int OBJ_create(const char *oid, const char *sn, const char *ln); -#if OPENSSL_API_COMPAT < 0x10100000L -# define OBJ_cleanup() while(0) continue -#endif -int OBJ_create_objects(BIO *in); - -size_t OBJ_length(const ASN1_OBJECT *obj); -const unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj); - -int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid); -int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid); -int OBJ_add_sigid(int signid, int dig_id, int pkey_id); -void OBJ_sigid_free(void); - - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/objectserr.h b/client/3rd/OpenSSL/include/openssl/objectserr.h deleted file mode 100644 index 02e166f1..00000000 --- a/client/3rd/OpenSSL/include/openssl/objectserr.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OBJERR_H -# define HEADER_OBJERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_OBJ_strings(void); - -/* - * OBJ function codes. - */ -# define OBJ_F_OBJ_ADD_OBJECT 105 -# define OBJ_F_OBJ_ADD_SIGID 107 -# define OBJ_F_OBJ_CREATE 100 -# define OBJ_F_OBJ_DUP 101 -# define OBJ_F_OBJ_NAME_NEW_INDEX 106 -# define OBJ_F_OBJ_NID2LN 102 -# define OBJ_F_OBJ_NID2OBJ 103 -# define OBJ_F_OBJ_NID2SN 104 -# define OBJ_F_OBJ_TXT2OBJ 108 - -/* - * OBJ reason codes. - */ -# define OBJ_R_OID_EXISTS 102 -# define OBJ_R_UNKNOWN_NID 101 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ocsp.h b/client/3rd/OpenSSL/include/openssl/ocsp.h deleted file mode 100644 index 4d759a49..00000000 --- a/client/3rd/OpenSSL/include/openssl/ocsp.h +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OCSP_H -# define HEADER_OCSP_H - -#include - -/* - * These definitions are outside the OPENSSL_NO_OCSP guard because although for - * historical reasons they have OCSP_* names, they can actually be used - * independently of OCSP. E.g. see RFC5280 - */ -/*- - * CRLReason ::= ENUMERATED { - * unspecified (0), - * keyCompromise (1), - * cACompromise (2), - * affiliationChanged (3), - * superseded (4), - * cessationOfOperation (5), - * certificateHold (6), - * removeFromCRL (8) } - */ -# define OCSP_REVOKED_STATUS_NOSTATUS -1 -# define OCSP_REVOKED_STATUS_UNSPECIFIED 0 -# define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1 -# define OCSP_REVOKED_STATUS_CACOMPROMISE 2 -# define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED 3 -# define OCSP_REVOKED_STATUS_SUPERSEDED 4 -# define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION 5 -# define OCSP_REVOKED_STATUS_CERTIFICATEHOLD 6 -# define OCSP_REVOKED_STATUS_REMOVEFROMCRL 8 - - -# ifndef OPENSSL_NO_OCSP - -# include -# include -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Various flags and values */ - -# define OCSP_DEFAULT_NONCE_LENGTH 16 - -# define OCSP_NOCERTS 0x1 -# define OCSP_NOINTERN 0x2 -# define OCSP_NOSIGS 0x4 -# define OCSP_NOCHAIN 0x8 -# define OCSP_NOVERIFY 0x10 -# define OCSP_NOEXPLICIT 0x20 -# define OCSP_NOCASIGN 0x40 -# define OCSP_NODELEGATED 0x80 -# define OCSP_NOCHECKS 0x100 -# define OCSP_TRUSTOTHER 0x200 -# define OCSP_RESPID_KEY 0x400 -# define OCSP_NOTIME 0x800 - -typedef struct ocsp_cert_id_st OCSP_CERTID; - -DEFINE_STACK_OF(OCSP_CERTID) - -typedef struct ocsp_one_request_st OCSP_ONEREQ; - -DEFINE_STACK_OF(OCSP_ONEREQ) - -typedef struct ocsp_req_info_st OCSP_REQINFO; -typedef struct ocsp_signature_st OCSP_SIGNATURE; -typedef struct ocsp_request_st OCSP_REQUEST; - -# define OCSP_RESPONSE_STATUS_SUCCESSFUL 0 -# define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1 -# define OCSP_RESPONSE_STATUS_INTERNALERROR 2 -# define OCSP_RESPONSE_STATUS_TRYLATER 3 -# define OCSP_RESPONSE_STATUS_SIGREQUIRED 5 -# define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6 - -typedef struct ocsp_resp_bytes_st OCSP_RESPBYTES; - -# define V_OCSP_RESPID_NAME 0 -# define V_OCSP_RESPID_KEY 1 - -DEFINE_STACK_OF(OCSP_RESPID) - -typedef struct ocsp_revoked_info_st OCSP_REVOKEDINFO; - -# define V_OCSP_CERTSTATUS_GOOD 0 -# define V_OCSP_CERTSTATUS_REVOKED 1 -# define V_OCSP_CERTSTATUS_UNKNOWN 2 - -typedef struct ocsp_cert_status_st OCSP_CERTSTATUS; -typedef struct ocsp_single_response_st OCSP_SINGLERESP; - -DEFINE_STACK_OF(OCSP_SINGLERESP) - -typedef struct ocsp_response_data_st OCSP_RESPDATA; - -typedef struct ocsp_basic_response_st OCSP_BASICRESP; - -typedef struct ocsp_crl_id_st OCSP_CRLID; -typedef struct ocsp_service_locator_st OCSP_SERVICELOC; - -# define PEM_STRING_OCSP_REQUEST "OCSP REQUEST" -# define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE" - -# define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p) - -# define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p) - -# define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST, \ - bp,(char **)(x),cb,NULL) - -# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb) (OCSP_RESPONSE *)PEM_ASN1_read_bio(\ - (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE, \ - bp,(char **)(x),cb,NULL) - -# define PEM_write_bio_OCSP_REQUEST(bp,o) \ - PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\ - bp,(char *)(o), NULL,NULL,0,NULL,NULL) - -# define PEM_write_bio_OCSP_RESPONSE(bp,o) \ - PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\ - bp,(char *)(o), NULL,NULL,0,NULL,NULL) - -# define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o) - -# define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o) - -# define ASN1_BIT_STRING_digest(data,type,md,len) \ - ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len) - -# define OCSP_CERTSTATUS_dup(cs)\ - (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\ - (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs)) - -OCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id); - -OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req); -OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req, - int maxline); -int OCSP_REQ_CTX_nbio(OCSP_REQ_CTX *rctx); -int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx); -OCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline); -void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx); -void OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len); -int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it, - ASN1_VALUE *val); -int OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval, - const ASN1_ITEM *it); -BIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx); -int OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path); -int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req); -int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx, - const char *name, const char *value); - -OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject, - const X509 *issuer); - -OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, - const X509_NAME *issuerName, - const ASN1_BIT_STRING *issuerKey, - const ASN1_INTEGER *serialNumber); - -OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid); - -int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len); -int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len); -int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs); -int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req); - -int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm); -int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert); - -int OCSP_request_sign(OCSP_REQUEST *req, - X509 *signer, - EVP_PKEY *key, - const EVP_MD *dgst, - STACK_OF(X509) *certs, unsigned long flags); - -int OCSP_response_status(OCSP_RESPONSE *resp); -OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp); - -const ASN1_OCTET_STRING *OCSP_resp_get0_signature(const OCSP_BASICRESP *bs); -const X509_ALGOR *OCSP_resp_get0_tbs_sigalg(const OCSP_BASICRESP *bs); -const OCSP_RESPDATA *OCSP_resp_get0_respdata(const OCSP_BASICRESP *bs); -int OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer, - STACK_OF(X509) *extra_certs); - -int OCSP_resp_count(OCSP_BASICRESP *bs); -OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx); -const ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(const OCSP_BASICRESP* bs); -const STACK_OF(X509) *OCSP_resp_get0_certs(const OCSP_BASICRESP *bs); -int OCSP_resp_get0_id(const OCSP_BASICRESP *bs, - const ASN1_OCTET_STRING **pid, - const X509_NAME **pname); -int OCSP_resp_get1_id(const OCSP_BASICRESP *bs, - ASN1_OCTET_STRING **pid, - X509_NAME **pname); - -int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last); -int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, - ASN1_GENERALIZEDTIME **revtime, - ASN1_GENERALIZEDTIME **thisupd, - ASN1_GENERALIZEDTIME **nextupd); -int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status, - int *reason, - ASN1_GENERALIZEDTIME **revtime, - ASN1_GENERALIZEDTIME **thisupd, - ASN1_GENERALIZEDTIME **nextupd); -int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, - ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec); - -int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, - X509_STORE *store, unsigned long flags); - -int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath, - int *pssl); - -int OCSP_id_issuer_cmp(const OCSP_CERTID *a, const OCSP_CERTID *b); -int OCSP_id_cmp(const OCSP_CERTID *a, const OCSP_CERTID *b); - -int OCSP_request_onereq_count(OCSP_REQUEST *req); -OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i); -OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one); -int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, - ASN1_OCTET_STRING **pikeyHash, - ASN1_INTEGER **pserial, OCSP_CERTID *cid); -int OCSP_request_is_signed(OCSP_REQUEST *req); -OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs); -OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, - OCSP_CERTID *cid, - int status, int reason, - ASN1_TIME *revtime, - ASN1_TIME *thisupd, - ASN1_TIME *nextupd); -int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert); -int OCSP_basic_sign(OCSP_BASICRESP *brsp, - X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, - STACK_OF(X509) *certs, unsigned long flags); -int OCSP_basic_sign_ctx(OCSP_BASICRESP *brsp, - X509 *signer, EVP_MD_CTX *ctx, - STACK_OF(X509) *certs, unsigned long flags); -int OCSP_RESPID_set_by_name(OCSP_RESPID *respid, X509 *cert); -int OCSP_RESPID_set_by_key(OCSP_RESPID *respid, X509 *cert); -int OCSP_RESPID_match(OCSP_RESPID *respid, X509 *cert); - -X509_EXTENSION *OCSP_crlID_new(const char *url, long *n, char *tim); - -X509_EXTENSION *OCSP_accept_responses_new(char **oids); - -X509_EXTENSION *OCSP_archive_cutoff_new(char *tim); - -X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, const char **urls); - -int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x); -int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos); -int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, const ASN1_OBJECT *obj, - int lastpos); -int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos); -X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc); -X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc); -void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, - int *idx); -int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, - unsigned long flags); -int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc); - -int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x); -int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos); -int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, const ASN1_OBJECT *obj, int lastpos); -int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos); -X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc); -X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc); -void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx); -int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit, - unsigned long flags); -int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc); - -int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x); -int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos); -int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, const ASN1_OBJECT *obj, - int lastpos); -int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, - int lastpos); -X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc); -X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc); -void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, - int *idx); -int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, - int crit, unsigned long flags); -int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc); - -int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x); -int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos); -int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, const ASN1_OBJECT *obj, - int lastpos); -int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, - int lastpos); -X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc); -X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc); -void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, - int *idx); -int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, - int crit, unsigned long flags); -int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc); -const OCSP_CERTID *OCSP_SINGLERESP_get0_id(const OCSP_SINGLERESP *x); - -DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP) -DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS) -DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO) -DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPID) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES) -DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ) -DECLARE_ASN1_FUNCTIONS(OCSP_CERTID) -DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST) -DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE) -DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO) -DECLARE_ASN1_FUNCTIONS(OCSP_CRLID) -DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC) - -const char *OCSP_response_status_str(long s); -const char *OCSP_cert_status_str(long s); -const char *OCSP_crl_reason_str(long s); - -int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags); -int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags); - -int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs, - X509_STORE *st, unsigned long flags); - - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ocsperr.h b/client/3rd/OpenSSL/include/openssl/ocsperr.h deleted file mode 100644 index 8dd9e01a..00000000 --- a/client/3rd/OpenSSL/include/openssl/ocsperr.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OCSPERR_H -# define HEADER_OCSPERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# include - -# ifndef OPENSSL_NO_OCSP - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_OCSP_strings(void); - -/* - * OCSP function codes. - */ -# define OCSP_F_D2I_OCSP_NONCE 102 -# define OCSP_F_OCSP_BASIC_ADD1_STATUS 103 -# define OCSP_F_OCSP_BASIC_SIGN 104 -# define OCSP_F_OCSP_BASIC_SIGN_CTX 119 -# define OCSP_F_OCSP_BASIC_VERIFY 105 -# define OCSP_F_OCSP_CERT_ID_NEW 101 -# define OCSP_F_OCSP_CHECK_DELEGATED 106 -# define OCSP_F_OCSP_CHECK_IDS 107 -# define OCSP_F_OCSP_CHECK_ISSUER 108 -# define OCSP_F_OCSP_CHECK_VALIDITY 115 -# define OCSP_F_OCSP_MATCH_ISSUERID 109 -# define OCSP_F_OCSP_PARSE_URL 114 -# define OCSP_F_OCSP_REQUEST_SIGN 110 -# define OCSP_F_OCSP_REQUEST_VERIFY 116 -# define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111 -# define OCSP_F_PARSE_HTTP_LINE1 118 - -/* - * OCSP reason codes. - */ -# define OCSP_R_CERTIFICATE_VERIFY_ERROR 101 -# define OCSP_R_DIGEST_ERR 102 -# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122 -# define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123 -# define OCSP_R_ERROR_PARSING_URL 121 -# define OCSP_R_MISSING_OCSPSIGNING_USAGE 103 -# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124 -# define OCSP_R_NOT_BASIC_RESPONSE 104 -# define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105 -# define OCSP_R_NO_RESPONSE_DATA 108 -# define OCSP_R_NO_REVOKED_TIME 109 -# define OCSP_R_NO_SIGNER_KEY 130 -# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110 -# define OCSP_R_REQUEST_NOT_SIGNED 128 -# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111 -# define OCSP_R_ROOT_CA_NOT_TRUSTED 112 -# define OCSP_R_SERVER_RESPONSE_ERROR 114 -# define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115 -# define OCSP_R_SIGNATURE_FAILURE 117 -# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118 -# define OCSP_R_STATUS_EXPIRED 125 -# define OCSP_R_STATUS_NOT_YET_VALID 126 -# define OCSP_R_STATUS_TOO_OLD 127 -# define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119 -# define OCSP_R_UNKNOWN_NID 120 -# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129 - -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/opensslconf.h b/client/3rd/OpenSSL/include/openssl/opensslconf.h deleted file mode 100644 index b358f59f..00000000 --- a/client/3rd/OpenSSL/include/openssl/opensslconf.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * WARNING: do not edit! - * Generated by makefile from include\openssl\opensslconf.h.in - * - * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef OPENSSL_ALGORITHM_DEFINES -# error OPENSSL_ALGORITHM_DEFINES no longer supported -#endif - -/* - * OpenSSL was configured with the following options: - */ - -#ifndef OPENSSL_SYS_WIN64A -# define OPENSSL_SYS_WIN64A 1 -#endif -#ifndef OPENSSL_NO_MD2 -# define OPENSSL_NO_MD2 -#endif -#ifndef OPENSSL_NO_RC5 -# define OPENSSL_NO_RC5 -#endif -#ifndef OPENSSL_THREADS -# define OPENSSL_THREADS -#endif -#ifndef OPENSSL_RAND_SEED_OS -# define OPENSSL_RAND_SEED_OS -#endif -#ifndef OPENSSL_NO_AFALGENG -# define OPENSSL_NO_AFALGENG -#endif -#ifndef OPENSSL_NO_ASAN -# define OPENSSL_NO_ASAN -#endif -#ifndef OPENSSL_NO_CRYPTO_MDEBUG -# define OPENSSL_NO_CRYPTO_MDEBUG -#endif -#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE -# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE -#endif -#ifndef OPENSSL_NO_DEVCRYPTOENG -# define OPENSSL_NO_DEVCRYPTOENG -#endif -#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 -# define OPENSSL_NO_EC_NISTP_64_GCC_128 -#endif -#ifndef OPENSSL_NO_EGD -# define OPENSSL_NO_EGD -#endif -#ifndef OPENSSL_NO_EXTERNAL_TESTS -# define OPENSSL_NO_EXTERNAL_TESTS -#endif -#ifndef OPENSSL_NO_FUZZ_AFL -# define OPENSSL_NO_FUZZ_AFL -#endif -#ifndef OPENSSL_NO_FUZZ_LIBFUZZER -# define OPENSSL_NO_FUZZ_LIBFUZZER -#endif -#ifndef OPENSSL_NO_HEARTBEATS -# define OPENSSL_NO_HEARTBEATS -#endif -#ifndef OPENSSL_NO_MSAN -# define OPENSSL_NO_MSAN -#endif -#ifndef OPENSSL_NO_SCTP -# define OPENSSL_NO_SCTP -#endif -#ifndef OPENSSL_NO_SSL_TRACE -# define OPENSSL_NO_SSL_TRACE -#endif -#ifndef OPENSSL_NO_SSL3 -# define OPENSSL_NO_SSL3 -#endif -#ifndef OPENSSL_NO_SSL3_METHOD -# define OPENSSL_NO_SSL3_METHOD -#endif -#ifndef OPENSSL_NO_UBSAN -# define OPENSSL_NO_UBSAN -#endif -#ifndef OPENSSL_NO_UNIT_TEST -# define OPENSSL_NO_UNIT_TEST -#endif -#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS -# define OPENSSL_NO_WEAK_SSL_CIPHERS -#endif -#ifndef OPENSSL_NO_STATIC_ENGINE -# define OPENSSL_NO_STATIC_ENGINE -#endif - - -/* - * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers - * don't like that. This will hopefully silence them. - */ -#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy; - -/* - * Applications should use -DOPENSSL_API_COMPAT= to suppress the - * declarations of functions deprecated in or before . Otherwise, they - * still won't see them if the library has been built to disable deprecated - * functions. - */ -#ifndef DECLARE_DEPRECATED -# define DECLARE_DEPRECATED(f) f; -# ifdef __GNUC__ -# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0) -# undef DECLARE_DEPRECATED -# define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated)); -# endif -# elif defined(__SUNPRO_C) -# if (__SUNPRO_C >= 0x5130) -# undef DECLARE_DEPRECATED -# define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated)); -# endif -# endif -#endif - -#ifndef OPENSSL_FILE -# ifdef OPENSSL_NO_FILENAMES -# define OPENSSL_FILE "" -# define OPENSSL_LINE 0 -# else -# define OPENSSL_FILE __FILE__ -# define OPENSSL_LINE __LINE__ -# endif -#endif - -#ifndef OPENSSL_MIN_API -# define OPENSSL_MIN_API 0 -#endif - -#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API -# undef OPENSSL_API_COMPAT -# define OPENSSL_API_COMPAT OPENSSL_MIN_API -#endif - -/* - * Do not deprecate things to be deprecated in version 1.2.0 before the - * OpenSSL version number matches. - */ -#if OPENSSL_VERSION_NUMBER < 0x10200000L -# define DEPRECATEDIN_1_2_0(f) f; -#elif OPENSSL_API_COMPAT < 0x10200000L -# define DEPRECATEDIN_1_2_0(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_1_2_0(f) -#endif - -#if OPENSSL_API_COMPAT < 0x10100000L -# define DEPRECATEDIN_1_1_0(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_1_1_0(f) -#endif - -#if OPENSSL_API_COMPAT < 0x10000000L -# define DEPRECATEDIN_1_0_0(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_1_0_0(f) -#endif - -#if OPENSSL_API_COMPAT < 0x00908000L -# define DEPRECATEDIN_0_9_8(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_0_9_8(f) -#endif - -/* Generate 80386 code? */ -#undef I386_ONLY - -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - -#define OPENSSL_EXPORT_VAR_AS_FUNCTION - -/* - * The following are cipher-specific, but are part of the public API. - */ -#if !defined(OPENSSL_SYS_UEFI) -# undef BN_LLONG -/* Only one for the following should be defined */ -# undef SIXTY_FOUR_BIT_LONG -# define SIXTY_FOUR_BIT -# undef THIRTY_TWO_BIT -#endif - -#define RC4_INT unsigned int - -#ifdef __cplusplus -} -#endif diff --git a/client/3rd/OpenSSL/include/openssl/opensslv.h b/client/3rd/OpenSSL/include/openssl/opensslv.h deleted file mode 100644 index cbbfab12..00000000 --- a/client/3rd/OpenSSL/include/openssl/opensslv.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OPENSSLV_H -# define HEADER_OPENSSLV_H - -#ifdef __cplusplus -extern "C" { -#endif - -/*- - * Numeric release version identifier: - * MNNFFPPS: major minor fix patch status - * The status nibble has one of the values 0 for development, 1 to e for betas - * 1 to 14, and f for release. The patch level is exactly that. - * For example: - * 0.9.3-dev 0x00903000 - * 0.9.3-beta1 0x00903001 - * 0.9.3-beta2-dev 0x00903002 - * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) - * 0.9.3 0x0090300f - * 0.9.3a 0x0090301f - * 0.9.4 0x0090400f - * 1.2.3z 0x102031af - * - * For continuity reasons (because 0.9.5 is already out, and is coded - * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level - * part is slightly different, by setting the highest bit. This means - * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start - * with 0x0090600S... - * - * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) - * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for - * major minor fix final patch/beta) - */ -# define OPENSSL_VERSION_NUMBER 0x101010cfL -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1l 24 Aug 2021" - -/*- - * The macros below are to be used for shared library (.so, .dll, ...) - * versioning. That kind of versioning works a bit differently between - * operating systems. The most usual scheme is to set a major and a minor - * number, and have the runtime loader check that the major number is equal - * to what it was at application link time, while the minor number has to - * be greater or equal to what it was at application link time. With this - * scheme, the version number is usually part of the file name, like this: - * - * libcrypto.so.0.9 - * - * Some unixen also make a softlink with the major version number only: - * - * libcrypto.so.0 - * - * On Tru64 and IRIX 6.x it works a little bit differently. There, the - * shared library version is stored in the file, and is actually a series - * of versions, separated by colons. The rightmost version present in the - * library when linking an application is stored in the application to be - * matched at run time. When the application is run, a check is done to - * see if the library version stored in the application matches any of the - * versions in the version string of the library itself. - * This version string can be constructed in any way, depending on what - * kind of matching is desired. However, to implement the same scheme as - * the one used in the other unixen, all compatible versions, from lowest - * to highest, should be part of the string. Consecutive builds would - * give the following versions strings: - * - * 3.0 - * 3.0:3.1 - * 3.0:3.1:3.2 - * 4.0 - * 4.0:4.1 - * - * Notice how version 4 is completely incompatible with version, and - * therefore give the breach you can see. - * - * There may be other schemes as well that I haven't yet discovered. - * - * So, here's the way it works here: first of all, the library version - * number doesn't need at all to match the overall OpenSSL version. - * However, it's nice and more understandable if it actually does. - * The current library version is stored in the macro SHLIB_VERSION_NUMBER, - * which is just a piece of text in the format "M.m.e" (Major, minor, edit). - * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, - * we need to keep a history of version numbers, which is done in the - * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and - * should only keep the versions that are binary compatible with the current. - */ -# define SHLIB_VERSION_HISTORY "" -# define SHLIB_VERSION_NUMBER "1.1" - - -#ifdef __cplusplus -} -#endif -#endif /* HEADER_OPENSSLV_H */ diff --git a/client/3rd/OpenSSL/include/openssl/ossl_typ.h b/client/3rd/OpenSSL/include/openssl/ossl_typ.h deleted file mode 100644 index e0edfaaf..00000000 --- a/client/3rd/OpenSSL/include/openssl/ossl_typ.h +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OPENSSL_TYPES_H -# define HEADER_OPENSSL_TYPES_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -# include - -# ifdef NO_ASN1_TYPEDEFS -# define ASN1_INTEGER ASN1_STRING -# define ASN1_ENUMERATED ASN1_STRING -# define ASN1_BIT_STRING ASN1_STRING -# define ASN1_OCTET_STRING ASN1_STRING -# define ASN1_PRINTABLESTRING ASN1_STRING -# define ASN1_T61STRING ASN1_STRING -# define ASN1_IA5STRING ASN1_STRING -# define ASN1_UTCTIME ASN1_STRING -# define ASN1_GENERALIZEDTIME ASN1_STRING -# define ASN1_TIME ASN1_STRING -# define ASN1_GENERALSTRING ASN1_STRING -# define ASN1_UNIVERSALSTRING ASN1_STRING -# define ASN1_BMPSTRING ASN1_STRING -# define ASN1_VISIBLESTRING ASN1_STRING -# define ASN1_UTF8STRING ASN1_STRING -# define ASN1_BOOLEAN int -# define ASN1_NULL int -# else -typedef struct asn1_string_st ASN1_INTEGER; -typedef struct asn1_string_st ASN1_ENUMERATED; -typedef struct asn1_string_st ASN1_BIT_STRING; -typedef struct asn1_string_st ASN1_OCTET_STRING; -typedef struct asn1_string_st ASN1_PRINTABLESTRING; -typedef struct asn1_string_st ASN1_T61STRING; -typedef struct asn1_string_st ASN1_IA5STRING; -typedef struct asn1_string_st ASN1_GENERALSTRING; -typedef struct asn1_string_st ASN1_UNIVERSALSTRING; -typedef struct asn1_string_st ASN1_BMPSTRING; -typedef struct asn1_string_st ASN1_UTCTIME; -typedef struct asn1_string_st ASN1_TIME; -typedef struct asn1_string_st ASN1_GENERALIZEDTIME; -typedef struct asn1_string_st ASN1_VISIBLESTRING; -typedef struct asn1_string_st ASN1_UTF8STRING; -typedef struct asn1_string_st ASN1_STRING; -typedef int ASN1_BOOLEAN; -typedef int ASN1_NULL; -# endif - -typedef struct asn1_object_st ASN1_OBJECT; - -typedef struct ASN1_ITEM_st ASN1_ITEM; -typedef struct asn1_pctx_st ASN1_PCTX; -typedef struct asn1_sctx_st ASN1_SCTX; - -# ifdef _WIN32 -# undef X509_NAME -# undef X509_EXTENSIONS -# undef PKCS7_ISSUER_AND_SERIAL -# undef PKCS7_SIGNER_INFO -# undef OCSP_REQUEST -# undef OCSP_RESPONSE -# endif - -# ifdef BIGNUM -# undef BIGNUM -# endif -struct dane_st; -typedef struct bio_st BIO; -typedef struct bignum_st BIGNUM; -typedef struct bignum_ctx BN_CTX; -typedef struct bn_blinding_st BN_BLINDING; -typedef struct bn_mont_ctx_st BN_MONT_CTX; -typedef struct bn_recp_ctx_st BN_RECP_CTX; -typedef struct bn_gencb_st BN_GENCB; - -typedef struct buf_mem_st BUF_MEM; - -typedef struct evp_cipher_st EVP_CIPHER; -typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; -typedef struct evp_md_st EVP_MD; -typedef struct evp_md_ctx_st EVP_MD_CTX; -typedef struct evp_pkey_st EVP_PKEY; - -typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD; - -typedef struct evp_pkey_method_st EVP_PKEY_METHOD; -typedef struct evp_pkey_ctx_st EVP_PKEY_CTX; - -typedef struct evp_Encode_Ctx_st EVP_ENCODE_CTX; - -typedef struct hmac_ctx_st HMAC_CTX; - -typedef struct dh_st DH; -typedef struct dh_method DH_METHOD; - -typedef struct dsa_st DSA; -typedef struct dsa_method DSA_METHOD; - -typedef struct rsa_st RSA; -typedef struct rsa_meth_st RSA_METHOD; -typedef struct rsa_pss_params_st RSA_PSS_PARAMS; - -typedef struct ec_key_st EC_KEY; -typedef struct ec_key_method_st EC_KEY_METHOD; - -typedef struct rand_meth_st RAND_METHOD; -typedef struct rand_drbg_st RAND_DRBG; - -typedef struct ssl_dane_st SSL_DANE; -typedef struct x509_st X509; -typedef struct X509_algor_st X509_ALGOR; -typedef struct X509_crl_st X509_CRL; -typedef struct x509_crl_method_st X509_CRL_METHOD; -typedef struct x509_revoked_st X509_REVOKED; -typedef struct X509_name_st X509_NAME; -typedef struct X509_pubkey_st X509_PUBKEY; -typedef struct x509_store_st X509_STORE; -typedef struct x509_store_ctx_st X509_STORE_CTX; - -typedef struct x509_object_st X509_OBJECT; -typedef struct x509_lookup_st X509_LOOKUP; -typedef struct x509_lookup_method_st X509_LOOKUP_METHOD; -typedef struct X509_VERIFY_PARAM_st X509_VERIFY_PARAM; - -typedef struct x509_sig_info_st X509_SIG_INFO; - -typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO; - -typedef struct v3_ext_ctx X509V3_CTX; -typedef struct conf_st CONF; -typedef struct ossl_init_settings_st OPENSSL_INIT_SETTINGS; - -typedef struct ui_st UI; -typedef struct ui_method_st UI_METHOD; - -typedef struct engine_st ENGINE; -typedef struct ssl_st SSL; -typedef struct ssl_ctx_st SSL_CTX; - -typedef struct comp_ctx_st COMP_CTX; -typedef struct comp_method_st COMP_METHOD; - -typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; -typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; -typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; -typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; - -typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID; -typedef struct DIST_POINT_st DIST_POINT; -typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT; -typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS; - -typedef struct crypto_ex_data_st CRYPTO_EX_DATA; - -typedef struct ocsp_req_ctx_st OCSP_REQ_CTX; -typedef struct ocsp_response_st OCSP_RESPONSE; -typedef struct ocsp_responder_id_st OCSP_RESPID; - -typedef struct sct_st SCT; -typedef struct sct_ctx_st SCT_CTX; -typedef struct ctlog_st CTLOG; -typedef struct ctlog_store_st CTLOG_STORE; -typedef struct ct_policy_eval_ctx_st CT_POLICY_EVAL_CTX; - -typedef struct ossl_store_info_st OSSL_STORE_INFO; -typedef struct ossl_store_search_st OSSL_STORE_SEARCH; - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \ - defined(INTMAX_MAX) && defined(UINTMAX_MAX) -typedef intmax_t ossl_intmax_t; -typedef uintmax_t ossl_uintmax_t; -#else -/* - * Not long long, because the C-library can only be expected to provide - * strtoll(), strtoull() at the same time as intmax_t and strtoimax(), - * strtoumax(). Since we use these for parsing arguments, we need the - * conversion functions, not just the sizes. - */ -typedef long ossl_intmax_t; -typedef unsigned long ossl_uintmax_t; -#endif - -#ifdef __cplusplus -} -#endif -#endif /* def HEADER_OPENSSL_TYPES_H */ diff --git a/client/3rd/OpenSSL/include/openssl/pem.h b/client/3rd/OpenSSL/include/openssl/pem.h deleted file mode 100644 index 2ef5b5d0..00000000 --- a/client/3rd/OpenSSL/include/openssl/pem.h +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_PEM_H -# define HEADER_PEM_H - -# include -# include -# include -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -# define PEM_BUFSIZE 1024 - -# define PEM_STRING_X509_OLD "X509 CERTIFICATE" -# define PEM_STRING_X509 "CERTIFICATE" -# define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE" -# define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" -# define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" -# define PEM_STRING_X509_CRL "X509 CRL" -# define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" -# define PEM_STRING_PUBLIC "PUBLIC KEY" -# define PEM_STRING_RSA "RSA PRIVATE KEY" -# define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" -# define PEM_STRING_DSA "DSA PRIVATE KEY" -# define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" -# define PEM_STRING_PKCS7 "PKCS7" -# define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA" -# define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" -# define PEM_STRING_PKCS8INF "PRIVATE KEY" -# define PEM_STRING_DHPARAMS "DH PARAMETERS" -# define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS" -# define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" -# define PEM_STRING_DSAPARAMS "DSA PARAMETERS" -# define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" -# define PEM_STRING_ECPARAMETERS "EC PARAMETERS" -# define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" -# define PEM_STRING_PARAMETERS "PARAMETERS" -# define PEM_STRING_CMS "CMS" - -# define PEM_TYPE_ENCRYPTED 10 -# define PEM_TYPE_MIC_ONLY 20 -# define PEM_TYPE_MIC_CLEAR 30 -# define PEM_TYPE_CLEAR 40 - -/* - * These macros make the PEM_read/PEM_write functions easier to maintain and - * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or - * IMPLEMENT_PEM_rw_cb(...) - */ - -# ifdef OPENSSL_NO_STDIO - -# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ -# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ -# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/ -# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ -# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/ -# else - -# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ -type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ -{ \ -return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \ -} - -# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, type *x) \ -{ \ -return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \ -} - -# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, const type *x) \ -{ \ -return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \ -} - -# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, \ - void *u) \ - { \ - return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ - } - -# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, \ - void *u) \ - { \ - return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ - } - -# endif - -# define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ -type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ -{ \ -return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \ -} - -# define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, type *x) \ -{ \ -return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \ -} - -# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, const type *x) \ -{ \ -return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \ -} - -# define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ - { \ - return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \ - } - -# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ - { \ - return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \ - } - -# define IMPLEMENT_PEM_write(name, type, str, asn1) \ - IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_write_fp(name, type, str, asn1) - -# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) - -# define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) - -# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) - -# define IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_read_fp(name, type, str, asn1) - -# define IMPLEMENT_PEM_rw(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write(name, type, str, asn1) - -# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write_const(name, type, str, asn1) - -# define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb(name, type, str, asn1) - -/* These are the same except they are for the declarations */ - -# if defined(OPENSSL_NO_STDIO) - -# define DECLARE_PEM_read_fp(name, type) /**/ -# define DECLARE_PEM_write_fp(name, type) /**/ -# define DECLARE_PEM_write_fp_const(name, type) /**/ -# define DECLARE_PEM_write_cb_fp(name, type) /**/ -# else - -# define DECLARE_PEM_read_fp(name, type) \ - type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u); - -# define DECLARE_PEM_write_fp(name, type) \ - int PEM_write_##name(FILE *fp, type *x); - -# define DECLARE_PEM_write_fp_const(name, type) \ - int PEM_write_##name(FILE *fp, const type *x); - -# define DECLARE_PEM_write_cb_fp(name, type) \ - int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u); - -# endif - -# define DECLARE_PEM_read_bio(name, type) \ - type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); - -# define DECLARE_PEM_write_bio(name, type) \ - int PEM_write_bio_##name(BIO *bp, type *x); - -# define DECLARE_PEM_write_bio_const(name, type) \ - int PEM_write_bio_##name(BIO *bp, const type *x); - -# define DECLARE_PEM_write_cb_bio(name, type) \ - int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u); - -# define DECLARE_PEM_write(name, type) \ - DECLARE_PEM_write_bio(name, type) \ - DECLARE_PEM_write_fp(name, type) -# define DECLARE_PEM_write_const(name, type) \ - DECLARE_PEM_write_bio_const(name, type) \ - DECLARE_PEM_write_fp_const(name, type) -# define DECLARE_PEM_write_cb(name, type) \ - DECLARE_PEM_write_cb_bio(name, type) \ - DECLARE_PEM_write_cb_fp(name, type) -# define DECLARE_PEM_read(name, type) \ - DECLARE_PEM_read_bio(name, type) \ - DECLARE_PEM_read_fp(name, type) -# define DECLARE_PEM_rw(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write(name, type) -# define DECLARE_PEM_rw_const(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write_const(name, type) -# define DECLARE_PEM_rw_cb(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write_cb(name, type) -typedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata); - -int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); -int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len, - pem_password_cb *callback, void *u); - -int PEM_read_bio(BIO *bp, char **name, char **header, - unsigned char **data, long *len); -# define PEM_FLAG_SECURE 0x1 -# define PEM_FLAG_EAY_COMPATIBLE 0x2 -# define PEM_FLAG_ONLY_B64 0x4 -int PEM_read_bio_ex(BIO *bp, char **name, char **header, - unsigned char **data, long *len, unsigned int flags); -int PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm, - const char *name, BIO *bp, pem_password_cb *cb, - void *u); -int PEM_write_bio(BIO *bp, const char *name, const char *hdr, - const unsigned char *data, long len); -int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, - const char *name, BIO *bp, pem_password_cb *cb, - void *u); -void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, - pem_password_cb *cb, void *u); -int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x, - const EVP_CIPHER *enc, unsigned char *kstr, int klen, - pem_password_cb *cb, void *u); - -STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, - pem_password_cb *cb, void *u); -int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, - unsigned char *kstr, int klen, - pem_password_cb *cd, void *u); - -#ifndef OPENSSL_NO_STDIO -int PEM_read(FILE *fp, char **name, char **header, - unsigned char **data, long *len); -int PEM_write(FILE *fp, const char *name, const char *hdr, - const unsigned char *data, long len); -void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, - pem_password_cb *cb, void *u); -int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, - void *x, const EVP_CIPHER *enc, unsigned char *kstr, - int klen, pem_password_cb *callback, void *u); -STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, - pem_password_cb *cb, void *u); -#endif - -int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); -int PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt); -int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, - unsigned int *siglen, EVP_PKEY *pkey); - -/* The default pem_password_cb that's used internally */ -int PEM_def_callback(char *buf, int num, int rwflag, void *userdata); -void PEM_proc_type(char *buf, int type); -void PEM_dek_info(char *buf, const char *type, int len, char *str); - -# include - -DECLARE_PEM_rw(X509, X509) -DECLARE_PEM_rw(X509_AUX, X509) -DECLARE_PEM_rw(X509_REQ, X509_REQ) -DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) -DECLARE_PEM_rw(X509_CRL, X509_CRL) -DECLARE_PEM_rw(PKCS7, PKCS7) -DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) -DECLARE_PEM_rw(PKCS8, X509_SIG) -DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) -# ifndef OPENSSL_NO_RSA -DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) -DECLARE_PEM_rw_const(RSAPublicKey, RSA) -DECLARE_PEM_rw(RSA_PUBKEY, RSA) -# endif -# ifndef OPENSSL_NO_DSA -DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) -DECLARE_PEM_rw(DSA_PUBKEY, DSA) -DECLARE_PEM_rw_const(DSAparams, DSA) -# endif -# ifndef OPENSSL_NO_EC -DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP) -DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) -DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) -# endif -# ifndef OPENSSL_NO_DH -DECLARE_PEM_rw_const(DHparams, DH) -DECLARE_PEM_write_const(DHxparams, DH) -# endif -DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) -DECLARE_PEM_rw(PUBKEY, EVP_PKEY) - -int PEM_write_bio_PrivateKey_traditional(BIO *bp, EVP_PKEY *x, - const EVP_CIPHER *enc, - unsigned char *kstr, int klen, - pem_password_cb *cb, void *u); - -int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, - char *, int, pem_password_cb *, void *); -int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); -EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, - void *u); - -# ifndef OPENSSL_NO_STDIO -int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); - -EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, - void *u); - -int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, - char *kstr, int klen, pem_password_cb *cd, - void *u); -# endif -EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x); -int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x); - -# ifndef OPENSSL_NO_DSA -EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length); -EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length); -EVP_PKEY *b2i_PrivateKey_bio(BIO *in); -EVP_PKEY *b2i_PublicKey_bio(BIO *in); -int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk); -int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk); -# ifndef OPENSSL_NO_RC4 -EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u); -int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel, - pem_password_cb *cb, void *u); -# endif -# endif - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/pem2.h b/client/3rd/OpenSSL/include/openssl/pem2.h deleted file mode 100644 index 038fe790..00000000 --- a/client/3rd/OpenSSL/include/openssl/pem2.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_PEM2_H -# define HEADER_PEM2_H -# include -#endif diff --git a/client/3rd/OpenSSL/include/openssl/pemerr.h b/client/3rd/OpenSSL/include/openssl/pemerr.h deleted file mode 100644 index 4f7e3574..00000000 --- a/client/3rd/OpenSSL/include/openssl/pemerr.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_PEMERR_H -# define HEADER_PEMERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_PEM_strings(void); - -/* - * PEM function codes. - */ -# define PEM_F_B2I_DSS 127 -# define PEM_F_B2I_PVK_BIO 128 -# define PEM_F_B2I_RSA 129 -# define PEM_F_CHECK_BITLEN_DSA 130 -# define PEM_F_CHECK_BITLEN_RSA 131 -# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 -# define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 -# define PEM_F_DO_B2I 132 -# define PEM_F_DO_B2I_BIO 133 -# define PEM_F_DO_BLOB_HEADER 134 -# define PEM_F_DO_I2B 146 -# define PEM_F_DO_PK8PKEY 126 -# define PEM_F_DO_PK8PKEY_FP 125 -# define PEM_F_DO_PVK_BODY 135 -# define PEM_F_DO_PVK_HEADER 136 -# define PEM_F_GET_HEADER_AND_DATA 143 -# define PEM_F_GET_NAME 144 -# define PEM_F_I2B_PVK 137 -# define PEM_F_I2B_PVK_BIO 138 -# define PEM_F_LOAD_IV 101 -# define PEM_F_PEM_ASN1_READ 102 -# define PEM_F_PEM_ASN1_READ_BIO 103 -# define PEM_F_PEM_ASN1_WRITE 104 -# define PEM_F_PEM_ASN1_WRITE_BIO 105 -# define PEM_F_PEM_DEF_CALLBACK 100 -# define PEM_F_PEM_DO_HEADER 106 -# define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 -# define PEM_F_PEM_READ 108 -# define PEM_F_PEM_READ_BIO 109 -# define PEM_F_PEM_READ_BIO_DHPARAMS 141 -# define PEM_F_PEM_READ_BIO_EX 145 -# define PEM_F_PEM_READ_BIO_PARAMETERS 140 -# define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 -# define PEM_F_PEM_READ_DHPARAMS 142 -# define PEM_F_PEM_READ_PRIVATEKEY 124 -# define PEM_F_PEM_SIGNFINAL 112 -# define PEM_F_PEM_WRITE 113 -# define PEM_F_PEM_WRITE_BIO 114 -# define PEM_F_PEM_WRITE_BIO_PRIVATEKEY_TRADITIONAL 147 -# define PEM_F_PEM_WRITE_PRIVATEKEY 139 -# define PEM_F_PEM_X509_INFO_READ 115 -# define PEM_F_PEM_X509_INFO_READ_BIO 116 -# define PEM_F_PEM_X509_INFO_WRITE_BIO 117 - -/* - * PEM reason codes. - */ -# define PEM_R_BAD_BASE64_DECODE 100 -# define PEM_R_BAD_DECRYPT 101 -# define PEM_R_BAD_END_LINE 102 -# define PEM_R_BAD_IV_CHARS 103 -# define PEM_R_BAD_MAGIC_NUMBER 116 -# define PEM_R_BAD_PASSWORD_READ 104 -# define PEM_R_BAD_VERSION_NUMBER 117 -# define PEM_R_BIO_WRITE_FAILURE 118 -# define PEM_R_CIPHER_IS_NULL 127 -# define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 -# define PEM_R_EXPECTING_PRIVATE_KEY_BLOB 119 -# define PEM_R_EXPECTING_PUBLIC_KEY_BLOB 120 -# define PEM_R_HEADER_TOO_LONG 128 -# define PEM_R_INCONSISTENT_HEADER 121 -# define PEM_R_KEYBLOB_HEADER_PARSE_ERROR 122 -# define PEM_R_KEYBLOB_TOO_SHORT 123 -# define PEM_R_MISSING_DEK_IV 129 -# define PEM_R_NOT_DEK_INFO 105 -# define PEM_R_NOT_ENCRYPTED 106 -# define PEM_R_NOT_PROC_TYPE 107 -# define PEM_R_NO_START_LINE 108 -# define PEM_R_PROBLEMS_GETTING_PASSWORD 109 -# define PEM_R_PVK_DATA_TOO_SHORT 124 -# define PEM_R_PVK_TOO_SHORT 125 -# define PEM_R_READ_KEY 111 -# define PEM_R_SHORT_HEADER 112 -# define PEM_R_UNEXPECTED_DEK_IV 130 -# define PEM_R_UNSUPPORTED_CIPHER 113 -# define PEM_R_UNSUPPORTED_ENCRYPTION 114 -# define PEM_R_UNSUPPORTED_KEY_COMPONENTS 126 -# define PEM_R_UNSUPPORTED_PUBLIC_KEY_TYPE 110 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/pkcs12.h b/client/3rd/OpenSSL/include/openssl/pkcs12.h deleted file mode 100644 index 3f43dad6..00000000 --- a/client/3rd/OpenSSL/include/openssl/pkcs12.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_PKCS12_H -# define HEADER_PKCS12_H - -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -# define PKCS12_KEY_ID 1 -# define PKCS12_IV_ID 2 -# define PKCS12_MAC_ID 3 - -/* Default iteration count */ -# ifndef PKCS12_DEFAULT_ITER -# define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER -# endif - -# define PKCS12_MAC_KEY_LENGTH 20 - -# define PKCS12_SALT_LEN 8 - -/* It's not clear if these are actually needed... */ -# define PKCS12_key_gen PKCS12_key_gen_utf8 -# define PKCS12_add_friendlyname PKCS12_add_friendlyname_utf8 - -/* MS key usage constants */ - -# define KEY_EX 0x10 -# define KEY_SIG 0x80 - -typedef struct PKCS12_MAC_DATA_st PKCS12_MAC_DATA; - -typedef struct PKCS12_st PKCS12; - -typedef struct PKCS12_SAFEBAG_st PKCS12_SAFEBAG; - -DEFINE_STACK_OF(PKCS12_SAFEBAG) - -typedef struct pkcs12_bag_st PKCS12_BAGS; - -# define PKCS12_ERROR 0 -# define PKCS12_OK 1 - -/* Compatibility macros */ - -#if OPENSSL_API_COMPAT < 0x10100000L - -# define M_PKCS12_bag_type PKCS12_bag_type -# define M_PKCS12_cert_bag_type PKCS12_cert_bag_type -# define M_PKCS12_crl_bag_type PKCS12_cert_bag_type - -# define PKCS12_certbag2x509 PKCS12_SAFEBAG_get1_cert -# define PKCS12_certbag2scrl PKCS12_SAFEBAG_get1_crl -# define PKCS12_bag_type PKCS12_SAFEBAG_get_nid -# define PKCS12_cert_bag_type PKCS12_SAFEBAG_get_bag_nid -# define PKCS12_x5092certbag PKCS12_SAFEBAG_create_cert -# define PKCS12_x509crl2certbag PKCS12_SAFEBAG_create_crl -# define PKCS12_MAKE_KEYBAG PKCS12_SAFEBAG_create0_p8inf -# define PKCS12_MAKE_SHKEYBAG PKCS12_SAFEBAG_create_pkcs8_encrypt - -#endif - -DEPRECATEDIN_1_1_0(ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, int attr_nid)) - -ASN1_TYPE *PKCS8_get_attr(PKCS8_PRIV_KEY_INFO *p8, int attr_nid); -int PKCS12_mac_present(const PKCS12 *p12); -void PKCS12_get0_mac(const ASN1_OCTET_STRING **pmac, - const X509_ALGOR **pmacalg, - const ASN1_OCTET_STRING **psalt, - const ASN1_INTEGER **piter, - const PKCS12 *p12); - -const ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(const PKCS12_SAFEBAG *bag, - int attr_nid); -const ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(const PKCS12_SAFEBAG *bag); -int PKCS12_SAFEBAG_get_nid(const PKCS12_SAFEBAG *bag); -int PKCS12_SAFEBAG_get_bag_nid(const PKCS12_SAFEBAG *bag); - -X509 *PKCS12_SAFEBAG_get1_cert(const PKCS12_SAFEBAG *bag); -X509_CRL *PKCS12_SAFEBAG_get1_crl(const PKCS12_SAFEBAG *bag); -const STACK_OF(PKCS12_SAFEBAG) * -PKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag); -const PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag); -const X509_SIG *PKCS12_SAFEBAG_get0_pkcs8(const PKCS12_SAFEBAG *bag); - -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_cert(X509 *x509); -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_crl(X509_CRL *crl); -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_p8inf(PKCS8_PRIV_KEY_INFO *p8); -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_pkcs8(X509_SIG *p8); -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid, - const char *pass, - int passlen, - unsigned char *salt, - int saltlen, int iter, - PKCS8_PRIV_KEY_INFO *p8inf); - -PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, - int nid1, int nid2); -PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass, - int passlen); -PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag, - const char *pass, int passlen); -X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, - const char *pass, int passlen, unsigned char *salt, - int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8); -X509_SIG *PKCS8_set0_pbe(const char *pass, int passlen, - PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe); -PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk); -STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7); -PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, - unsigned char *salt, int saltlen, int iter, - STACK_OF(PKCS12_SAFEBAG) *bags); -STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, - int passlen); - -int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes); -STACK_OF(PKCS7) *PKCS12_unpack_authsafes(const PKCS12 *p12); - -int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, - int namelen); -int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, - int namelen); -int PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name, - int namelen); -int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, - int namelen); -int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, - const unsigned char *name, int namelen); -int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); -ASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs, - int attr_nid); -char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag); -const STACK_OF(X509_ATTRIBUTE) * -PKCS12_SAFEBAG_get0_attrs(const PKCS12_SAFEBAG *bag); -unsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor, - const char *pass, int passlen, - const unsigned char *in, int inlen, - unsigned char **data, int *datalen, - int en_de); -void *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it, - const char *pass, int passlen, - const ASN1_OCTET_STRING *oct, int zbuf); -ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, - const ASN1_ITEM *it, - const char *pass, int passlen, - void *obj, int zbuf); -PKCS12 *PKCS12_init(int mode); -int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, - int saltlen, int id, int iter, int n, - unsigned char *out, const EVP_MD *md_type); -int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, - int saltlen, int id, int iter, int n, - unsigned char *out, const EVP_MD *md_type); -int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt, - int saltlen, int id, int iter, int n, - unsigned char *out, const EVP_MD *md_type); -int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, - ASN1_TYPE *param, const EVP_CIPHER *cipher, - const EVP_MD *md_type, int en_de); -int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, - unsigned char *mac, unsigned int *maclen); -int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen); -int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, - unsigned char *salt, int saltlen, int iter, - const EVP_MD *md_type); -int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, - int saltlen, const EVP_MD *md_type); -unsigned char *OPENSSL_asc2uni(const char *asc, int asclen, - unsigned char **uni, int *unilen); -char *OPENSSL_uni2asc(const unsigned char *uni, int unilen); -unsigned char *OPENSSL_utf82uni(const char *asc, int asclen, - unsigned char **uni, int *unilen); -char *OPENSSL_uni2utf8(const unsigned char *uni, int unilen); - -DECLARE_ASN1_FUNCTIONS(PKCS12) -DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA) -DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG) -DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS) - -DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS) -DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES) - -void PKCS12_PBE_add(void); -int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, - STACK_OF(X509) **ca); -PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, - X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, - int iter, int mac_iter, int keytype); - -PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert); -PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, - EVP_PKEY *key, int key_usage, int iter, - int key_nid, const char *pass); -int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, - int safe_nid, int iter, const char *pass); -PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid); - -int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12); -# ifndef OPENSSL_NO_STDIO -int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12); -# endif -PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); -# ifndef OPENSSL_NO_STDIO -PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); -# endif -int PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass); - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/pkcs12err.h b/client/3rd/OpenSSL/include/openssl/pkcs12err.h deleted file mode 100644 index eff5eb26..00000000 --- a/client/3rd/OpenSSL/include/openssl/pkcs12err.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_PKCS12ERR_H -# define HEADER_PKCS12ERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_PKCS12_strings(void); - -/* - * PKCS12 function codes. - */ -# define PKCS12_F_OPENSSL_ASC2UNI 121 -# define PKCS12_F_OPENSSL_UNI2ASC 124 -# define PKCS12_F_OPENSSL_UNI2UTF8 127 -# define PKCS12_F_OPENSSL_UTF82UNI 129 -# define PKCS12_F_PKCS12_CREATE 105 -# define PKCS12_F_PKCS12_GEN_MAC 107 -# define PKCS12_F_PKCS12_INIT 109 -# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 106 -# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 108 -# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 117 -# define PKCS12_F_PKCS12_KEY_GEN_ASC 110 -# define PKCS12_F_PKCS12_KEY_GEN_UNI 111 -# define PKCS12_F_PKCS12_KEY_GEN_UTF8 116 -# define PKCS12_F_PKCS12_NEWPASS 128 -# define PKCS12_F_PKCS12_PACK_P7DATA 114 -# define PKCS12_F_PKCS12_PACK_P7ENCDATA 115 -# define PKCS12_F_PKCS12_PARSE 118 -# define PKCS12_F_PKCS12_PBE_CRYPT 119 -# define PKCS12_F_PKCS12_PBE_KEYIVGEN 120 -# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_P8INF 112 -# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_PKCS8 113 -# define PKCS12_F_PKCS12_SAFEBAG_CREATE_PKCS8_ENCRYPT 133 -# define PKCS12_F_PKCS12_SETUP_MAC 122 -# define PKCS12_F_PKCS12_SET_MAC 123 -# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 130 -# define PKCS12_F_PKCS12_UNPACK_P7DATA 131 -# define PKCS12_F_PKCS12_VERIFY_MAC 126 -# define PKCS12_F_PKCS8_ENCRYPT 125 -# define PKCS12_F_PKCS8_SET0_PBE 132 - -/* - * PKCS12 reason codes. - */ -# define PKCS12_R_CANT_PACK_STRUCTURE 100 -# define PKCS12_R_CONTENT_TYPE_NOT_DATA 121 -# define PKCS12_R_DECODE_ERROR 101 -# define PKCS12_R_ENCODE_ERROR 102 -# define PKCS12_R_ENCRYPT_ERROR 103 -# define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120 -# define PKCS12_R_INVALID_NULL_ARGUMENT 104 -# define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 -# define PKCS12_R_IV_GEN_ERROR 106 -# define PKCS12_R_KEY_GEN_ERROR 107 -# define PKCS12_R_MAC_ABSENT 108 -# define PKCS12_R_MAC_GENERATION_ERROR 109 -# define PKCS12_R_MAC_SETUP_ERROR 110 -# define PKCS12_R_MAC_STRING_SET_ERROR 111 -# define PKCS12_R_MAC_VERIFY_FAILURE 113 -# define PKCS12_R_PARSE_ERROR 114 -# define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115 -# define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116 -# define PKCS12_R_PKCS12_PBE_CRYPT_ERROR 117 -# define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118 -# define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/pkcs7.h b/client/3rd/OpenSSL/include/openssl/pkcs7.h deleted file mode 100644 index 9b66e002..00000000 --- a/client/3rd/OpenSSL/include/openssl/pkcs7.h +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_PKCS7_H -# define HEADER_PKCS7_H - -# include -# include -# include - -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/*- -Encryption_ID DES-CBC -Digest_ID MD5 -Digest_Encryption_ID rsaEncryption -Key_Encryption_ID rsaEncryption -*/ - -typedef struct pkcs7_issuer_and_serial_st { - X509_NAME *issuer; - ASN1_INTEGER *serial; -} PKCS7_ISSUER_AND_SERIAL; - -typedef struct pkcs7_signer_info_st { - ASN1_INTEGER *version; /* version 1 */ - PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; - X509_ALGOR *digest_alg; - STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */ - X509_ALGOR *digest_enc_alg; - ASN1_OCTET_STRING *enc_digest; - STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */ - /* The private key to sign with */ - EVP_PKEY *pkey; -} PKCS7_SIGNER_INFO; - -DEFINE_STACK_OF(PKCS7_SIGNER_INFO) - -typedef struct pkcs7_recip_info_st { - ASN1_INTEGER *version; /* version 0 */ - PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; - X509_ALGOR *key_enc_algor; - ASN1_OCTET_STRING *enc_key; - X509 *cert; /* get the pub-key from this */ -} PKCS7_RECIP_INFO; - -DEFINE_STACK_OF(PKCS7_RECIP_INFO) - -typedef struct pkcs7_signed_st { - ASN1_INTEGER *version; /* version 1 */ - STACK_OF(X509_ALGOR) *md_algs; /* md used */ - STACK_OF(X509) *cert; /* [ 0 ] */ - STACK_OF(X509_CRL) *crl; /* [ 1 ] */ - STACK_OF(PKCS7_SIGNER_INFO) *signer_info; - struct pkcs7_st *contents; -} PKCS7_SIGNED; -/* - * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about - * merging the two - */ - -typedef struct pkcs7_enc_content_st { - ASN1_OBJECT *content_type; - X509_ALGOR *algorithm; - ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ - const EVP_CIPHER *cipher; -} PKCS7_ENC_CONTENT; - -typedef struct pkcs7_enveloped_st { - ASN1_INTEGER *version; /* version 0 */ - STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; - PKCS7_ENC_CONTENT *enc_data; -} PKCS7_ENVELOPE; - -typedef struct pkcs7_signedandenveloped_st { - ASN1_INTEGER *version; /* version 1 */ - STACK_OF(X509_ALGOR) *md_algs; /* md used */ - STACK_OF(X509) *cert; /* [ 0 ] */ - STACK_OF(X509_CRL) *crl; /* [ 1 ] */ - STACK_OF(PKCS7_SIGNER_INFO) *signer_info; - PKCS7_ENC_CONTENT *enc_data; - STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; -} PKCS7_SIGN_ENVELOPE; - -typedef struct pkcs7_digest_st { - ASN1_INTEGER *version; /* version 0 */ - X509_ALGOR *md; /* md used */ - struct pkcs7_st *contents; - ASN1_OCTET_STRING *digest; -} PKCS7_DIGEST; - -typedef struct pkcs7_encrypted_st { - ASN1_INTEGER *version; /* version 0 */ - PKCS7_ENC_CONTENT *enc_data; -} PKCS7_ENCRYPT; - -typedef struct pkcs7_st { - /* - * The following is non NULL if it contains ASN1 encoding of this - * structure - */ - unsigned char *asn1; - long length; -# define PKCS7_S_HEADER 0 -# define PKCS7_S_BODY 1 -# define PKCS7_S_TAIL 2 - int state; /* used during processing */ - int detached; - ASN1_OBJECT *type; - /* content as defined by the type */ - /* - * all encryption/message digests are applied to the 'contents', leaving - * out the 'type' field. - */ - union { - char *ptr; - /* NID_pkcs7_data */ - ASN1_OCTET_STRING *data; - /* NID_pkcs7_signed */ - PKCS7_SIGNED *sign; - /* NID_pkcs7_enveloped */ - PKCS7_ENVELOPE *enveloped; - /* NID_pkcs7_signedAndEnveloped */ - PKCS7_SIGN_ENVELOPE *signed_and_enveloped; - /* NID_pkcs7_digest */ - PKCS7_DIGEST *digest; - /* NID_pkcs7_encrypted */ - PKCS7_ENCRYPT *encrypted; - /* Anything else */ - ASN1_TYPE *other; - } d; -} PKCS7; - -DEFINE_STACK_OF(PKCS7) - -# define PKCS7_OP_SET_DETACHED_SIGNATURE 1 -# define PKCS7_OP_GET_DETACHED_SIGNATURE 2 - -# define PKCS7_get_signed_attributes(si) ((si)->auth_attr) -# define PKCS7_get_attributes(si) ((si)->unauth_attr) - -# define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) -# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) -# define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) -# define PKCS7_type_is_signedAndEnveloped(a) \ - (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) -# define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) -# define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) - -# define PKCS7_set_detached(p,v) \ - PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL) -# define PKCS7_get_detached(p) \ - PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL) - -# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) - -/* S/MIME related flags */ - -# define PKCS7_TEXT 0x1 -# define PKCS7_NOCERTS 0x2 -# define PKCS7_NOSIGS 0x4 -# define PKCS7_NOCHAIN 0x8 -# define PKCS7_NOINTERN 0x10 -# define PKCS7_NOVERIFY 0x20 -# define PKCS7_DETACHED 0x40 -# define PKCS7_BINARY 0x80 -# define PKCS7_NOATTR 0x100 -# define PKCS7_NOSMIMECAP 0x200 -# define PKCS7_NOOLDMIMETYPE 0x400 -# define PKCS7_CRLFEOL 0x800 -# define PKCS7_STREAM 0x1000 -# define PKCS7_NOCRL 0x2000 -# define PKCS7_PARTIAL 0x4000 -# define PKCS7_REUSE_DIGEST 0x8000 -# define PKCS7_NO_DUAL_CONTENT 0x10000 - -/* Flags: for compatibility with older code */ - -# define SMIME_TEXT PKCS7_TEXT -# define SMIME_NOCERTS PKCS7_NOCERTS -# define SMIME_NOSIGS PKCS7_NOSIGS -# define SMIME_NOCHAIN PKCS7_NOCHAIN -# define SMIME_NOINTERN PKCS7_NOINTERN -# define SMIME_NOVERIFY PKCS7_NOVERIFY -# define SMIME_DETACHED PKCS7_DETACHED -# define SMIME_BINARY PKCS7_BINARY -# define SMIME_NOATTR PKCS7_NOATTR - -/* CRLF ASCII canonicalisation */ -# define SMIME_ASCIICRLF 0x80000 - -DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) - -int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, - const EVP_MD *type, unsigned char *md, - unsigned int *len); -# ifndef OPENSSL_NO_STDIO -PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7); -int i2d_PKCS7_fp(FILE *fp, PKCS7 *p7); -# endif -PKCS7 *PKCS7_dup(PKCS7 *p7); -PKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7); -int i2d_PKCS7_bio(BIO *bp, PKCS7 *p7); -int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags); -int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags); - -DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) -DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) -DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED) -DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) -DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE) -DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE) -DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST) -DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT) -DECLARE_ASN1_FUNCTIONS(PKCS7) - -DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN) -DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY) - -DECLARE_ASN1_NDEF_FUNCTION(PKCS7) -DECLARE_ASN1_PRINT_FUNCTION(PKCS7) - -long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg); - -int PKCS7_set_type(PKCS7 *p7, int type); -int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other); -int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); -int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, - const EVP_MD *dgst); -int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si); -int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); -int PKCS7_add_certificate(PKCS7 *p7, X509 *x509); -int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509); -int PKCS7_content_new(PKCS7 *p7, int nid); -int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, - BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si); -int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, - X509 *x509); - -BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio); -int PKCS7_dataFinal(PKCS7 *p7, BIO *bio); -BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert); - -PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, - EVP_PKEY *pkey, const EVP_MD *dgst); -X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si); -int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md); -STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7); - -PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509); -void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk, - X509_ALGOR **pdig, X509_ALGOR **psig); -void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc); -int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri); -int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509); -int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher); -int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7); - -PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx); -ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk); -int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type, - void *data); -int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, - void *value); -ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid); -ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid); -int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, - STACK_OF(X509_ATTRIBUTE) *sk); -int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si, - STACK_OF(X509_ATTRIBUTE) *sk); - -PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, - BIO *data, int flags); - -PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, - X509 *signcert, EVP_PKEY *pkey, - const EVP_MD *md, int flags); - -int PKCS7_final(PKCS7 *p7, BIO *data, int flags); -int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, - BIO *indata, BIO *out, int flags); -STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, - int flags); -PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, - int flags); -int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, - int flags); - -int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, - STACK_OF(X509_ALGOR) *cap); -STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); -int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg); - -int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid); -int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t); -int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si, - const unsigned char *md, int mdlen); - -int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); -PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); - -BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7); - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/pkcs7err.h b/client/3rd/OpenSSL/include/openssl/pkcs7err.h deleted file mode 100644 index 02e0299a..00000000 --- a/client/3rd/OpenSSL/include/openssl/pkcs7err.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_PKCS7ERR_H -# define HEADER_PKCS7ERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_PKCS7_strings(void); - -/* - * PKCS7 function codes. - */ -# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB 136 -# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME 135 -# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118 -# define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 -# define PKCS7_F_PKCS7_ADD_CRL 101 -# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 -# define PKCS7_F_PKCS7_ADD_SIGNATURE 131 -# define PKCS7_F_PKCS7_ADD_SIGNER 103 -# define PKCS7_F_PKCS7_BIO_ADD_DIGEST 125 -# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST 138 -# define PKCS7_F_PKCS7_CTRL 104 -# define PKCS7_F_PKCS7_DATADECODE 112 -# define PKCS7_F_PKCS7_DATAFINAL 128 -# define PKCS7_F_PKCS7_DATAINIT 105 -# define PKCS7_F_PKCS7_DATAVERIFY 107 -# define PKCS7_F_PKCS7_DECRYPT 114 -# define PKCS7_F_PKCS7_DECRYPT_RINFO 133 -# define PKCS7_F_PKCS7_ENCODE_RINFO 132 -# define PKCS7_F_PKCS7_ENCRYPT 115 -# define PKCS7_F_PKCS7_FINAL 134 -# define PKCS7_F_PKCS7_FIND_DIGEST 127 -# define PKCS7_F_PKCS7_GET0_SIGNERS 124 -# define PKCS7_F_PKCS7_RECIP_INFO_SET 130 -# define PKCS7_F_PKCS7_SET_CIPHER 108 -# define PKCS7_F_PKCS7_SET_CONTENT 109 -# define PKCS7_F_PKCS7_SET_DIGEST 126 -# define PKCS7_F_PKCS7_SET_TYPE 110 -# define PKCS7_F_PKCS7_SIGN 116 -# define PKCS7_F_PKCS7_SIGNATUREVERIFY 113 -# define PKCS7_F_PKCS7_SIGNER_INFO_SET 129 -# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN 139 -# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER 137 -# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119 -# define PKCS7_F_PKCS7_VERIFY 117 - -/* - * PKCS7 reason codes. - */ -# define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117 -# define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144 -# define PKCS7_R_CIPHER_NOT_INITIALIZED 116 -# define PKCS7_R_CONTENT_AND_DATA_PRESENT 118 -# define PKCS7_R_CTRL_ERROR 152 -# define PKCS7_R_DECRYPT_ERROR 119 -# define PKCS7_R_DIGEST_FAILURE 101 -# define PKCS7_R_ENCRYPTION_CTRL_FAILURE 149 -# define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150 -# define PKCS7_R_ERROR_ADDING_RECIPIENT 120 -# define PKCS7_R_ERROR_SETTING_CIPHER 121 -# define PKCS7_R_INVALID_NULL_POINTER 143 -# define PKCS7_R_INVALID_SIGNED_DATA_TYPE 155 -# define PKCS7_R_NO_CONTENT 122 -# define PKCS7_R_NO_DEFAULT_DIGEST 151 -# define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND 154 -# define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115 -# define PKCS7_R_NO_SIGNATURES_ON_DATA 123 -# define PKCS7_R_NO_SIGNERS 142 -# define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104 -# define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124 -# define PKCS7_R_PKCS7_ADD_SIGNER_ERROR 153 -# define PKCS7_R_PKCS7_DATASIGN 145 -# define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127 -# define PKCS7_R_SIGNATURE_FAILURE 105 -# define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128 -# define PKCS7_R_SIGNING_CTRL_FAILURE 147 -# define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 148 -# define PKCS7_R_SMIME_TEXT_ERROR 129 -# define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106 -# define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107 -# define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108 -# define PKCS7_R_UNKNOWN_DIGEST_TYPE 109 -# define PKCS7_R_UNKNOWN_OPERATION 110 -# define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 111 -# define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 112 -# define PKCS7_R_WRONG_CONTENT_TYPE 113 -# define PKCS7_R_WRONG_PKCS7_TYPE 114 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/rand.h b/client/3rd/OpenSSL/include/openssl/rand.h deleted file mode 100644 index 38a2a271..00000000 --- a/client/3rd/OpenSSL/include/openssl/rand.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RAND_H -# define HEADER_RAND_H - -# include -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -struct rand_meth_st { - int (*seed) (const void *buf, int num); - int (*bytes) (unsigned char *buf, int num); - void (*cleanup) (void); - int (*add) (const void *buf, int num, double randomness); - int (*pseudorand) (unsigned char *buf, int num); - int (*status) (void); -}; - -int RAND_set_rand_method(const RAND_METHOD *meth); -const RAND_METHOD *RAND_get_rand_method(void); -# ifndef OPENSSL_NO_ENGINE -int RAND_set_rand_engine(ENGINE *engine); -# endif - -RAND_METHOD *RAND_OpenSSL(void); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define RAND_cleanup() while(0) continue -# endif -int RAND_bytes(unsigned char *buf, int num); -int RAND_priv_bytes(unsigned char *buf, int num); -DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num)) - -void RAND_seed(const void *buf, int num); -void RAND_keep_random_devices_open(int keep); - -# if defined(__ANDROID__) && defined(__NDK_FPABI__) -__NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */ -# endif -void RAND_add(const void *buf, int num, double randomness); -int RAND_load_file(const char *file, long max_bytes); -int RAND_write_file(const char *file); -const char *RAND_file_name(char *file, size_t num); -int RAND_status(void); - -# ifndef OPENSSL_NO_EGD -int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes); -int RAND_egd(const char *path); -int RAND_egd_bytes(const char *path, int bytes); -# endif - -int RAND_poll(void); - -# if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H)) -/* application has to include in order to use these */ -DEPRECATEDIN_1_1_0(void RAND_screen(void)) -DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM)) -# endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/rand_drbg.h b/client/3rd/OpenSSL/include/openssl/rand_drbg.h deleted file mode 100644 index 45b731b7..00000000 --- a/client/3rd/OpenSSL/include/openssl/rand_drbg.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_DRBG_RAND_H -# define HEADER_DRBG_RAND_H - -# include -# include -# include - -/* - * RAND_DRBG flags - * - * Note: if new flags are added, the constant `rand_drbg_used_flags` - * in drbg_lib.c needs to be updated accordingly. - */ - -/* In CTR mode, disable derivation function ctr_df */ -# define RAND_DRBG_FLAG_CTR_NO_DF 0x1 - - -# if OPENSSL_API_COMPAT < 0x10200000L -/* This #define was replaced by an internal constant and should not be used. */ -# define RAND_DRBG_USED_FLAGS (RAND_DRBG_FLAG_CTR_NO_DF) -# endif - -/* - * Default security strength (in the sense of [NIST SP 800-90Ar1]) - * - * NIST SP 800-90Ar1 supports the strength of the DRBG being smaller than that - * of the cipher by collecting less entropy. The current DRBG implementation - * does not take RAND_DRBG_STRENGTH into account and sets the strength of the - * DRBG to that of the cipher. - * - * RAND_DRBG_STRENGTH is currently only used for the legacy RAND - * implementation. - * - * Currently supported ciphers are: NID_aes_128_ctr, NID_aes_192_ctr and - * NID_aes_256_ctr - */ -# define RAND_DRBG_STRENGTH 256 -/* Default drbg type */ -# define RAND_DRBG_TYPE NID_aes_256_ctr -/* Default drbg flags */ -# define RAND_DRBG_FLAGS 0 - - -# ifdef __cplusplus -extern "C" { -# endif - -/* - * Object lifetime functions. - */ -RAND_DRBG *RAND_DRBG_new(int type, unsigned int flags, RAND_DRBG *parent); -RAND_DRBG *RAND_DRBG_secure_new(int type, unsigned int flags, RAND_DRBG *parent); -int RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags); -int RAND_DRBG_set_defaults(int type, unsigned int flags); -int RAND_DRBG_instantiate(RAND_DRBG *drbg, - const unsigned char *pers, size_t perslen); -int RAND_DRBG_uninstantiate(RAND_DRBG *drbg); -void RAND_DRBG_free(RAND_DRBG *drbg); - -/* - * Object "use" functions. - */ -int RAND_DRBG_reseed(RAND_DRBG *drbg, - const unsigned char *adin, size_t adinlen, - int prediction_resistance); -int RAND_DRBG_generate(RAND_DRBG *drbg, unsigned char *out, size_t outlen, - int prediction_resistance, - const unsigned char *adin, size_t adinlen); -int RAND_DRBG_bytes(RAND_DRBG *drbg, unsigned char *out, size_t outlen); - -int RAND_DRBG_set_reseed_interval(RAND_DRBG *drbg, unsigned int interval); -int RAND_DRBG_set_reseed_time_interval(RAND_DRBG *drbg, time_t interval); - -int RAND_DRBG_set_reseed_defaults( - unsigned int master_reseed_interval, - unsigned int slave_reseed_interval, - time_t master_reseed_time_interval, - time_t slave_reseed_time_interval - ); - -RAND_DRBG *RAND_DRBG_get0_master(void); -RAND_DRBG *RAND_DRBG_get0_public(void); -RAND_DRBG *RAND_DRBG_get0_private(void); - -/* - * EXDATA - */ -# define RAND_DRBG_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DRBG, l, p, newf, dupf, freef) -int RAND_DRBG_set_ex_data(RAND_DRBG *drbg, int idx, void *arg); -void *RAND_DRBG_get_ex_data(const RAND_DRBG *drbg, int idx); - -/* - * Callback function typedefs - */ -typedef size_t (*RAND_DRBG_get_entropy_fn)(RAND_DRBG *drbg, - unsigned char **pout, - int entropy, size_t min_len, - size_t max_len, - int prediction_resistance); -typedef void (*RAND_DRBG_cleanup_entropy_fn)(RAND_DRBG *ctx, - unsigned char *out, size_t outlen); -typedef size_t (*RAND_DRBG_get_nonce_fn)(RAND_DRBG *drbg, unsigned char **pout, - int entropy, size_t min_len, - size_t max_len); -typedef void (*RAND_DRBG_cleanup_nonce_fn)(RAND_DRBG *drbg, - unsigned char *out, size_t outlen); - -int RAND_DRBG_set_callbacks(RAND_DRBG *drbg, - RAND_DRBG_get_entropy_fn get_entropy, - RAND_DRBG_cleanup_entropy_fn cleanup_entropy, - RAND_DRBG_get_nonce_fn get_nonce, - RAND_DRBG_cleanup_nonce_fn cleanup_nonce); - - -# ifdef __cplusplus -} -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/randerr.h b/client/3rd/OpenSSL/include/openssl/randerr.h deleted file mode 100644 index 79d57905..00000000 --- a/client/3rd/OpenSSL/include/openssl/randerr.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RANDERR_H -# define HEADER_RANDERR_H - -# include - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_RAND_strings(void); - -/* - * RAND function codes. - */ -# define RAND_F_DATA_COLLECT_METHOD 127 -# define RAND_F_DRBG_BYTES 101 -# define RAND_F_DRBG_GET_ENTROPY 105 -# define RAND_F_DRBG_SETUP 117 -# define RAND_F_GET_ENTROPY 106 -# define RAND_F_RAND_BYTES 100 -# define RAND_F_RAND_DRBG_ENABLE_LOCKING 119 -# define RAND_F_RAND_DRBG_GENERATE 107 -# define RAND_F_RAND_DRBG_GET_ENTROPY 120 -# define RAND_F_RAND_DRBG_GET_NONCE 123 -# define RAND_F_RAND_DRBG_INSTANTIATE 108 -# define RAND_F_RAND_DRBG_NEW 109 -# define RAND_F_RAND_DRBG_RESEED 110 -# define RAND_F_RAND_DRBG_RESTART 102 -# define RAND_F_RAND_DRBG_SET 104 -# define RAND_F_RAND_DRBG_SET_DEFAULTS 121 -# define RAND_F_RAND_DRBG_UNINSTANTIATE 118 -# define RAND_F_RAND_LOAD_FILE 111 -# define RAND_F_RAND_POOL_ACQUIRE_ENTROPY 122 -# define RAND_F_RAND_POOL_ADD 103 -# define RAND_F_RAND_POOL_ADD_BEGIN 113 -# define RAND_F_RAND_POOL_ADD_END 114 -# define RAND_F_RAND_POOL_ATTACH 124 -# define RAND_F_RAND_POOL_BYTES_NEEDED 115 -# define RAND_F_RAND_POOL_GROW 125 -# define RAND_F_RAND_POOL_NEW 116 -# define RAND_F_RAND_PSEUDO_BYTES 126 -# define RAND_F_RAND_WRITE_FILE 112 - -/* - * RAND reason codes. - */ -# define RAND_R_ADDITIONAL_INPUT_TOO_LONG 102 -# define RAND_R_ALREADY_INSTANTIATED 103 -# define RAND_R_ARGUMENT_OUT_OF_RANGE 105 -# define RAND_R_CANNOT_OPEN_FILE 121 -# define RAND_R_DRBG_ALREADY_INITIALIZED 129 -# define RAND_R_DRBG_NOT_INITIALISED 104 -# define RAND_R_ENTROPY_INPUT_TOO_LONG 106 -# define RAND_R_ENTROPY_OUT_OF_RANGE 124 -# define RAND_R_ERROR_ENTROPY_POOL_WAS_IGNORED 127 -# define RAND_R_ERROR_INITIALISING_DRBG 107 -# define RAND_R_ERROR_INSTANTIATING_DRBG 108 -# define RAND_R_ERROR_RETRIEVING_ADDITIONAL_INPUT 109 -# define RAND_R_ERROR_RETRIEVING_ENTROPY 110 -# define RAND_R_ERROR_RETRIEVING_NONCE 111 -# define RAND_R_FAILED_TO_CREATE_LOCK 126 -# define RAND_R_FUNC_NOT_IMPLEMENTED 101 -# define RAND_R_FWRITE_ERROR 123 -# define RAND_R_GENERATE_ERROR 112 -# define RAND_R_INTERNAL_ERROR 113 -# define RAND_R_IN_ERROR_STATE 114 -# define RAND_R_NOT_A_REGULAR_FILE 122 -# define RAND_R_NOT_INSTANTIATED 115 -# define RAND_R_NO_DRBG_IMPLEMENTATION_SELECTED 128 -# define RAND_R_PARENT_LOCKING_NOT_ENABLED 130 -# define RAND_R_PARENT_STRENGTH_TOO_WEAK 131 -# define RAND_R_PERSONALISATION_STRING_TOO_LONG 116 -# define RAND_R_PREDICTION_RESISTANCE_NOT_SUPPORTED 133 -# define RAND_R_PRNG_NOT_SEEDED 100 -# define RAND_R_RANDOM_POOL_OVERFLOW 125 -# define RAND_R_RANDOM_POOL_UNDERFLOW 134 -# define RAND_R_REQUEST_TOO_LARGE_FOR_DRBG 117 -# define RAND_R_RESEED_ERROR 118 -# define RAND_R_SELFTEST_FAILURE 119 -# define RAND_R_TOO_LITTLE_NONCE_REQUESTED 135 -# define RAND_R_TOO_MUCH_NONCE_REQUESTED 136 -# define RAND_R_UNSUPPORTED_DRBG_FLAGS 132 -# define RAND_R_UNSUPPORTED_DRBG_TYPE 120 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/rc2.h b/client/3rd/OpenSSL/include/openssl/rc2.h deleted file mode 100644 index 585f9e4c..00000000 --- a/client/3rd/OpenSSL/include/openssl/rc2.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RC2_H -# define HEADER_RC2_H - -# include - -# ifndef OPENSSL_NO_RC2 -# ifdef __cplusplus -extern "C" { -# endif - -typedef unsigned int RC2_INT; - -# define RC2_ENCRYPT 1 -# define RC2_DECRYPT 0 - -# define RC2_BLOCK 8 -# define RC2_KEY_LENGTH 16 - -typedef struct rc2_key_st { - RC2_INT data[64]; -} RC2_KEY; - -void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits); -void RC2_ecb_encrypt(const unsigned char *in, unsigned char *out, - RC2_KEY *key, int enc); -void RC2_encrypt(unsigned long *data, RC2_KEY *key); -void RC2_decrypt(unsigned long *data, RC2_KEY *key); -void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - RC2_KEY *ks, unsigned char *iv, int enc); -void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC2_KEY *schedule, unsigned char *ivec, - int *num, int enc); -void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC2_KEY *schedule, unsigned char *ivec, - int *num); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/rc4.h b/client/3rd/OpenSSL/include/openssl/rc4.h deleted file mode 100644 index 86803b37..00000000 --- a/client/3rd/OpenSSL/include/openssl/rc4.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RC4_H -# define HEADER_RC4_H - -# include - -# ifndef OPENSSL_NO_RC4 -# include -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rc4_key_st { - RC4_INT x, y; - RC4_INT data[256]; -} RC4_KEY; - -const char *RC4_options(void); -void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); -void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, - unsigned char *outdata); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/rc5.h b/client/3rd/OpenSSL/include/openssl/rc5.h deleted file mode 100644 index 793f88e4..00000000 --- a/client/3rd/OpenSSL/include/openssl/rc5.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RC5_H -# define HEADER_RC5_H - -# include - -# ifndef OPENSSL_NO_RC5 -# ifdef __cplusplus -extern "C" { -# endif - -# define RC5_ENCRYPT 1 -# define RC5_DECRYPT 0 - -# define RC5_32_INT unsigned int - -# define RC5_32_BLOCK 8 -# define RC5_32_KEY_LENGTH 16/* This is a default, max is 255 */ - -/* - * This are the only values supported. Tweak the code if you want more The - * most supported modes will be RC5-32/12/16 RC5-32/16/8 - */ -# define RC5_8_ROUNDS 8 -# define RC5_12_ROUNDS 12 -# define RC5_16_ROUNDS 16 - -typedef struct rc5_key_st { - /* Number of rounds */ - int rounds; - RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)]; -} RC5_32_KEY; - -void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, - int rounds); -void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out, - RC5_32_KEY *key, int enc); -void RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key); -void RC5_32_decrypt(unsigned long *data, RC5_32_KEY *key); -void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *ks, unsigned char *iv, - int enc); -void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *schedule, - unsigned char *ivec, int *num, int enc); -void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *schedule, - unsigned char *ivec, int *num); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ripemd.h b/client/3rd/OpenSSL/include/openssl/ripemd.h deleted file mode 100644 index c42026aa..00000000 --- a/client/3rd/OpenSSL/include/openssl/ripemd.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RIPEMD_H -# define HEADER_RIPEMD_H - -# include - -#ifndef OPENSSL_NO_RMD160 -# include -# include -# ifdef __cplusplus -extern "C" { -# endif - -# define RIPEMD160_LONG unsigned int - -# define RIPEMD160_CBLOCK 64 -# define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) -# define RIPEMD160_DIGEST_LENGTH 20 - -typedef struct RIPEMD160state_st { - RIPEMD160_LONG A, B, C, D, E; - RIPEMD160_LONG Nl, Nh; - RIPEMD160_LONG data[RIPEMD160_LBLOCK]; - unsigned int num; -} RIPEMD160_CTX; - -int RIPEMD160_Init(RIPEMD160_CTX *c); -int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); -int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); -unsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md); -void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); - -# ifdef __cplusplus -} -# endif -# endif - - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/rsa.h b/client/3rd/OpenSSL/include/openssl/rsa.h deleted file mode 100644 index 5e76365c..00000000 --- a/client/3rd/OpenSSL/include/openssl/rsa.h +++ /dev/null @@ -1,513 +0,0 @@ -/* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RSA_H -# define HEADER_RSA_H - -# include - -# ifndef OPENSSL_NO_RSA -# include -# include -# include -# include -# if OPENSSL_API_COMPAT < 0x10100000L -# include -# endif -# include -# ifdef __cplusplus -extern "C" { -# endif - -/* The types RSA and RSA_METHOD are defined in ossl_typ.h */ - -# ifndef OPENSSL_RSA_MAX_MODULUS_BITS -# define OPENSSL_RSA_MAX_MODULUS_BITS 16384 -# endif - -# define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 1024 - -# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS -# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072 -# endif -# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS - -/* exponent limit enforced for "large" modulus only */ -# define OPENSSL_RSA_MAX_PUBEXP_BITS 64 -# endif - -# define RSA_3 0x3L -# define RSA_F4 0x10001L - -/* based on RFC 8017 appendix A.1.2 */ -# define RSA_ASN1_VERSION_DEFAULT 0 -# define RSA_ASN1_VERSION_MULTI 1 - -# define RSA_DEFAULT_PRIME_NUM 2 - -# define RSA_METHOD_FLAG_NO_CHECK 0x0001/* don't check pub/private - * match */ - -# define RSA_FLAG_CACHE_PUBLIC 0x0002 -# define RSA_FLAG_CACHE_PRIVATE 0x0004 -# define RSA_FLAG_BLINDING 0x0008 -# define RSA_FLAG_THREAD_SAFE 0x0010 -/* - * This flag means the private key operations will be handled by rsa_mod_exp - * and that they do not depend on the private key components being present: - * for example a key stored in external hardware. Without this flag - * bn_mod_exp gets called when private key components are absent. - */ -# define RSA_FLAG_EXT_PKEY 0x0020 - -/* - * new with 0.9.6j and 0.9.7b; the built-in - * RSA implementation now uses blinding by - * default (ignoring RSA_FLAG_BLINDING), - * but other engines might not need it - */ -# define RSA_FLAG_NO_BLINDING 0x0080 -# if OPENSSL_API_COMPAT < 0x10100000L -/* - * Does nothing. Previously this switched off constant time behaviour. - */ -# define RSA_FLAG_NO_CONSTTIME 0x0000 -# endif -# if OPENSSL_API_COMPAT < 0x00908000L -/* deprecated name for the flag*/ -/* - * new with 0.9.7h; the built-in RSA - * implementation now uses constant time - * modular exponentiation for secret exponents - * by default. This flag causes the - * faster variable sliding window method to - * be used for all exponents. - */ -# define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME -# endif - -# define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \ - RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_RSA_PADDING, pad, NULL) - -# define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \ - RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad) - -# define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \ - RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \ - EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL) -/* Salt length matches digest */ -# define RSA_PSS_SALTLEN_DIGEST -1 -/* Verify only: auto detect salt length */ -# define RSA_PSS_SALTLEN_AUTO -2 -/* Set salt length to maximum possible */ -# define RSA_PSS_SALTLEN_MAX -3 -/* Old compatible max salt length for sign only */ -# define RSA_PSS_SALTLEN_MAX_SIGN -2 - -# define EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(ctx, len) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL) - -# define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \ - RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \ - EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, 0, plen) - -# define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \ - RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL) - -# define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \ - RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp) - -# define EVP_PKEY_CTX_set_rsa_keygen_primes(ctx, primes) \ - RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_RSA_KEYGEN_PRIMES, primes, NULL) - -# define EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md) \ - RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md)) - -# define EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md)) - -# define EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)(md)) - -# define EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \ - RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)(pmd)) - -# define EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)(pmd)) - -# define EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, l, llen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_RSA_OAEP_LABEL, llen, (void *)(l)) - -# define EVP_PKEY_CTX_get0_rsa_oaep_label(ctx, l) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)(l)) - -# define EVP_PKEY_CTX_set_rsa_pss_keygen_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, \ - EVP_PKEY_OP_KEYGEN, EVP_PKEY_CTRL_MD, \ - 0, (void *)(md)) - -# define EVP_PKEY_CTRL_RSA_PADDING (EVP_PKEY_ALG_CTRL + 1) -# define EVP_PKEY_CTRL_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 2) - -# define EVP_PKEY_CTRL_RSA_KEYGEN_BITS (EVP_PKEY_ALG_CTRL + 3) -# define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4) -# define EVP_PKEY_CTRL_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 5) - -# define EVP_PKEY_CTRL_GET_RSA_PADDING (EVP_PKEY_ALG_CTRL + 6) -# define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 7) -# define EVP_PKEY_CTRL_GET_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 8) - -# define EVP_PKEY_CTRL_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 9) -# define EVP_PKEY_CTRL_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 10) - -# define EVP_PKEY_CTRL_GET_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 11) -# define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12) - -# define EVP_PKEY_CTRL_RSA_KEYGEN_PRIMES (EVP_PKEY_ALG_CTRL + 13) - -# define RSA_PKCS1_PADDING 1 -# define RSA_SSLV23_PADDING 2 -# define RSA_NO_PADDING 3 -# define RSA_PKCS1_OAEP_PADDING 4 -# define RSA_X931_PADDING 5 -/* EVP_PKEY_ only */ -# define RSA_PKCS1_PSS_PADDING 6 - -# define RSA_PKCS1_PADDING_SIZE 11 - -# define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg) -# define RSA_get_app_data(s) RSA_get_ex_data(s,0) - -RSA *RSA_new(void); -RSA *RSA_new_method(ENGINE *engine); -int RSA_bits(const RSA *rsa); -int RSA_size(const RSA *rsa); -int RSA_security_bits(const RSA *rsa); - -int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); -int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); -int RSA_set0_crt_params(RSA *r,BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp); -int RSA_set0_multi_prime_params(RSA *r, BIGNUM *primes[], BIGNUM *exps[], - BIGNUM *coeffs[], int pnum); -void RSA_get0_key(const RSA *r, - const BIGNUM **n, const BIGNUM **e, const BIGNUM **d); -void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); -int RSA_get_multi_prime_extra_count(const RSA *r); -int RSA_get0_multi_prime_factors(const RSA *r, const BIGNUM *primes[]); -void RSA_get0_crt_params(const RSA *r, - const BIGNUM **dmp1, const BIGNUM **dmq1, - const BIGNUM **iqmp); -int RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[], - const BIGNUM *coeffs[]); -const BIGNUM *RSA_get0_n(const RSA *d); -const BIGNUM *RSA_get0_e(const RSA *d); -const BIGNUM *RSA_get0_d(const RSA *d); -const BIGNUM *RSA_get0_p(const RSA *d); -const BIGNUM *RSA_get0_q(const RSA *d); -const BIGNUM *RSA_get0_dmp1(const RSA *r); -const BIGNUM *RSA_get0_dmq1(const RSA *r); -const BIGNUM *RSA_get0_iqmp(const RSA *r); -const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r); -void RSA_clear_flags(RSA *r, int flags); -int RSA_test_flags(const RSA *r, int flags); -void RSA_set_flags(RSA *r, int flags); -int RSA_get_version(RSA *r); -ENGINE *RSA_get0_engine(const RSA *r); - -/* Deprecated version */ -DEPRECATEDIN_0_9_8(RSA *RSA_generate_key(int bits, unsigned long e, void - (*callback) (int, int, void *), - void *cb_arg)) - -/* New version */ -int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); -/* Multi-prime version */ -int RSA_generate_multi_prime_key(RSA *rsa, int bits, int primes, - BIGNUM *e, BN_GENCB *cb); - -int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1, - BIGNUM *q2, const BIGNUM *Xp1, const BIGNUM *Xp2, - const BIGNUM *Xp, const BIGNUM *Xq1, const BIGNUM *Xq2, - const BIGNUM *Xq, const BIGNUM *e, BN_GENCB *cb); -int RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e, - BN_GENCB *cb); - -int RSA_check_key(const RSA *); -int RSA_check_key_ex(const RSA *, BN_GENCB *cb); - /* next 4 return -1 on error */ -int RSA_public_encrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_private_encrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_public_decrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_private_decrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -void RSA_free(RSA *r); -/* "up" the RSA object's reference count */ -int RSA_up_ref(RSA *r); - -int RSA_flags(const RSA *r); - -void RSA_set_default_method(const RSA_METHOD *meth); -const RSA_METHOD *RSA_get_default_method(void); -const RSA_METHOD *RSA_null_method(void); -const RSA_METHOD *RSA_get_method(const RSA *rsa); -int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); - -/* these are the actual RSA functions */ -const RSA_METHOD *RSA_PKCS1_OpenSSL(void); - -int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2); - -DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey) -DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey) - -struct rsa_pss_params_st { - X509_ALGOR *hashAlgorithm; - X509_ALGOR *maskGenAlgorithm; - ASN1_INTEGER *saltLength; - ASN1_INTEGER *trailerField; - /* Decoded hash algorithm from maskGenAlgorithm */ - X509_ALGOR *maskHash; -}; - -DECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS) - -typedef struct rsa_oaep_params_st { - X509_ALGOR *hashFunc; - X509_ALGOR *maskGenFunc; - X509_ALGOR *pSourceFunc; - /* Decoded hash algorithm from maskGenFunc */ - X509_ALGOR *maskHash; -} RSA_OAEP_PARAMS; - -DECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS) - -# ifndef OPENSSL_NO_STDIO -int RSA_print_fp(FILE *fp, const RSA *r, int offset); -# endif - -int RSA_print(BIO *bp, const RSA *r, int offset); - -/* - * The following 2 functions sign and verify a X509_SIG ASN1 object inside - * PKCS#1 padded RSA encryption - */ -int RSA_sign(int type, const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, RSA *rsa); -int RSA_verify(int type, const unsigned char *m, unsigned int m_length, - const unsigned char *sigbuf, unsigned int siglen, RSA *rsa); - -/* - * The following 2 function sign and verify a ASN1_OCTET_STRING object inside - * PKCS#1 padded RSA encryption - */ -int RSA_sign_ASN1_OCTET_STRING(int type, - const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, - RSA *rsa); -int RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m, - unsigned int m_length, unsigned char *sigbuf, - unsigned int siglen, RSA *rsa); - -int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); -void RSA_blinding_off(RSA *rsa); -BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx); - -int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, - const unsigned char *f, int fl); -int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, - const unsigned char *f, int fl, - int rsa_len); -int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, - const unsigned char *f, int fl); -int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, - const unsigned char *f, int fl, - int rsa_len); -int PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed, - long seedlen, const EVP_MD *dgst); -int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, - const unsigned char *f, int fl, - const unsigned char *p, int pl); -int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, - const unsigned char *f, int fl, int rsa_len, - const unsigned char *p, int pl); -int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, - const unsigned char *from, int flen, - const unsigned char *param, int plen, - const EVP_MD *md, const EVP_MD *mgf1md); -int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, - const unsigned char *from, int flen, - int num, const unsigned char *param, - int plen, const EVP_MD *md, - const EVP_MD *mgf1md); -int RSA_padding_add_SSLv23(unsigned char *to, int tlen, - const unsigned char *f, int fl); -int RSA_padding_check_SSLv23(unsigned char *to, int tlen, - const unsigned char *f, int fl, int rsa_len); -int RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *f, - int fl); -int RSA_padding_check_none(unsigned char *to, int tlen, - const unsigned char *f, int fl, int rsa_len); -int RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *f, - int fl); -int RSA_padding_check_X931(unsigned char *to, int tlen, - const unsigned char *f, int fl, int rsa_len); -int RSA_X931_hash_id(int nid); - -int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, - const EVP_MD *Hash, const unsigned char *EM, - int sLen); -int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, - const unsigned char *mHash, const EVP_MD *Hash, - int sLen); - -int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash, - const EVP_MD *Hash, const EVP_MD *mgf1Hash, - const unsigned char *EM, int sLen); - -int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, - const unsigned char *mHash, - const EVP_MD *Hash, const EVP_MD *mgf1Hash, - int sLen); - -#define RSA_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, l, p, newf, dupf, freef) -int RSA_set_ex_data(RSA *r, int idx, void *arg); -void *RSA_get_ex_data(const RSA *r, int idx); - -RSA *RSAPublicKey_dup(RSA *rsa); -RSA *RSAPrivateKey_dup(RSA *rsa); - -/* - * If this flag is set the RSA method is FIPS compliant and can be used in - * FIPS mode. This is set in the validated module method. If an application - * sets this flag in its own methods it is its responsibility to ensure the - * result is compliant. - */ - -# define RSA_FLAG_FIPS_METHOD 0x0400 - -/* - * If this flag is set the operations normally disabled in FIPS mode are - * permitted it is then the applications responsibility to ensure that the - * usage is compliant. - */ - -# define RSA_FLAG_NON_FIPS_ALLOW 0x0400 -/* - * Application has decided PRNG is good enough to generate a key: don't - * check. - */ -# define RSA_FLAG_CHECKED 0x0800 - -RSA_METHOD *RSA_meth_new(const char *name, int flags); -void RSA_meth_free(RSA_METHOD *meth); -RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth); -const char *RSA_meth_get0_name(const RSA_METHOD *meth); -int RSA_meth_set1_name(RSA_METHOD *meth, const char *name); -int RSA_meth_get_flags(const RSA_METHOD *meth); -int RSA_meth_set_flags(RSA_METHOD *meth, int flags); -void *RSA_meth_get0_app_data(const RSA_METHOD *meth); -int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data); -int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth)) - (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_meth_set_pub_enc(RSA_METHOD *rsa, - int (*pub_enc) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)); -int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth)) - (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_meth_set_pub_dec(RSA_METHOD *rsa, - int (*pub_dec) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)); -int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth)) - (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_meth_set_priv_enc(RSA_METHOD *rsa, - int (*priv_enc) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)); -int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth)) - (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_meth_set_priv_dec(RSA_METHOD *rsa, - int (*priv_dec) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)); -int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth)) - (BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx); -int RSA_meth_set_mod_exp(RSA_METHOD *rsa, - int (*mod_exp) (BIGNUM *r0, const BIGNUM *i, RSA *rsa, - BN_CTX *ctx)); -int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth)) - (BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa, - int (*bn_mod_exp) (BIGNUM *r, - const BIGNUM *a, - const BIGNUM *p, - const BIGNUM *m, - BN_CTX *ctx, - BN_MONT_CTX *m_ctx)); -int (*RSA_meth_get_init(const RSA_METHOD *meth)) (RSA *rsa); -int RSA_meth_set_init(RSA_METHOD *rsa, int (*init) (RSA *rsa)); -int (*RSA_meth_get_finish(const RSA_METHOD *meth)) (RSA *rsa); -int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish) (RSA *rsa)); -int (*RSA_meth_get_sign(const RSA_METHOD *meth)) - (int type, - const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, - const RSA *rsa); -int RSA_meth_set_sign(RSA_METHOD *rsa, - int (*sign) (int type, const unsigned char *m, - unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, - const RSA *rsa)); -int (*RSA_meth_get_verify(const RSA_METHOD *meth)) - (int dtype, const unsigned char *m, - unsigned int m_length, const unsigned char *sigbuf, - unsigned int siglen, const RSA *rsa); -int RSA_meth_set_verify(RSA_METHOD *rsa, - int (*verify) (int dtype, const unsigned char *m, - unsigned int m_length, - const unsigned char *sigbuf, - unsigned int siglen, const RSA *rsa)); -int (*RSA_meth_get_keygen(const RSA_METHOD *meth)) - (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); -int RSA_meth_set_keygen(RSA_METHOD *rsa, - int (*keygen) (RSA *rsa, int bits, BIGNUM *e, - BN_GENCB *cb)); -int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth)) - (RSA *rsa, int bits, int primes, BIGNUM *e, BN_GENCB *cb); -int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth, - int (*keygen) (RSA *rsa, int bits, - int primes, BIGNUM *e, - BN_GENCB *cb)); - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/rsaerr.h b/client/3rd/OpenSSL/include/openssl/rsaerr.h deleted file mode 100644 index 59b15e13..00000000 --- a/client/3rd/OpenSSL/include/openssl/rsaerr.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RSAERR_H -# define HEADER_RSAERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_RSA_strings(void); - -/* - * RSA function codes. - */ -# define RSA_F_CHECK_PADDING_MD 140 -# define RSA_F_ENCODE_PKCS1 146 -# define RSA_F_INT_RSA_VERIFY 145 -# define RSA_F_OLD_RSA_PRIV_DECODE 147 -# define RSA_F_PKEY_PSS_INIT 165 -# define RSA_F_PKEY_RSA_CTRL 143 -# define RSA_F_PKEY_RSA_CTRL_STR 144 -# define RSA_F_PKEY_RSA_SIGN 142 -# define RSA_F_PKEY_RSA_VERIFY 149 -# define RSA_F_PKEY_RSA_VERIFYRECOVER 141 -# define RSA_F_RSA_ALGOR_TO_MD 156 -# define RSA_F_RSA_BUILTIN_KEYGEN 129 -# define RSA_F_RSA_CHECK_KEY 123 -# define RSA_F_RSA_CHECK_KEY_EX 160 -# define RSA_F_RSA_CMS_DECRYPT 159 -# define RSA_F_RSA_CMS_VERIFY 158 -# define RSA_F_RSA_ITEM_VERIFY 148 -# define RSA_F_RSA_METH_DUP 161 -# define RSA_F_RSA_METH_NEW 162 -# define RSA_F_RSA_METH_SET1_NAME 163 -# define RSA_F_RSA_MGF1_TO_MD 157 -# define RSA_F_RSA_MULTIP_INFO_NEW 166 -# define RSA_F_RSA_NEW_METHOD 106 -# define RSA_F_RSA_NULL 124 -# define RSA_F_RSA_NULL_PRIVATE_DECRYPT 132 -# define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 133 -# define RSA_F_RSA_NULL_PUBLIC_DECRYPT 134 -# define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 135 -# define RSA_F_RSA_OSSL_PRIVATE_DECRYPT 101 -# define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT 102 -# define RSA_F_RSA_OSSL_PUBLIC_DECRYPT 103 -# define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT 104 -# define RSA_F_RSA_PADDING_ADD_NONE 107 -# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121 -# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1 154 -# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 125 -# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1 152 -# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108 -# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 109 -# define RSA_F_RSA_PADDING_ADD_SSLV23 110 -# define RSA_F_RSA_PADDING_ADD_X931 127 -# define RSA_F_RSA_PADDING_CHECK_NONE 111 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 122 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1 153 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 112 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113 -# define RSA_F_RSA_PADDING_CHECK_SSLV23 114 -# define RSA_F_RSA_PADDING_CHECK_X931 128 -# define RSA_F_RSA_PARAM_DECODE 164 -# define RSA_F_RSA_PRINT 115 -# define RSA_F_RSA_PRINT_FP 116 -# define RSA_F_RSA_PRIV_DECODE 150 -# define RSA_F_RSA_PRIV_ENCODE 138 -# define RSA_F_RSA_PSS_GET_PARAM 151 -# define RSA_F_RSA_PSS_TO_CTX 155 -# define RSA_F_RSA_PUB_DECODE 139 -# define RSA_F_RSA_SETUP_BLINDING 136 -# define RSA_F_RSA_SIGN 117 -# define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118 -# define RSA_F_RSA_VERIFY 119 -# define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 120 -# define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1 126 -# define RSA_F_SETUP_TBUF 167 - -/* - * RSA reason codes. - */ -# define RSA_R_ALGORITHM_MISMATCH 100 -# define RSA_R_BAD_E_VALUE 101 -# define RSA_R_BAD_FIXED_HEADER_DECRYPT 102 -# define RSA_R_BAD_PAD_BYTE_COUNT 103 -# define RSA_R_BAD_SIGNATURE 104 -# define RSA_R_BLOCK_TYPE_IS_NOT_01 106 -# define RSA_R_BLOCK_TYPE_IS_NOT_02 107 -# define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 -# define RSA_R_DATA_TOO_LARGE 109 -# define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 -# define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132 -# define RSA_R_DATA_TOO_SMALL 111 -# define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 -# define RSA_R_DIGEST_DOES_NOT_MATCH 158 -# define RSA_R_DIGEST_NOT_ALLOWED 145 -# define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 -# define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124 -# define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 -# define RSA_R_D_E_NOT_CONGRUENT_TO_1 123 -# define RSA_R_FIRST_OCTET_INVALID 133 -# define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 144 -# define RSA_R_INVALID_DIGEST 157 -# define RSA_R_INVALID_DIGEST_LENGTH 143 -# define RSA_R_INVALID_HEADER 137 -# define RSA_R_INVALID_LABEL 160 -# define RSA_R_INVALID_MESSAGE_LENGTH 131 -# define RSA_R_INVALID_MGF1_MD 156 -# define RSA_R_INVALID_MULTI_PRIME_KEY 167 -# define RSA_R_INVALID_OAEP_PARAMETERS 161 -# define RSA_R_INVALID_PADDING 138 -# define RSA_R_INVALID_PADDING_MODE 141 -# define RSA_R_INVALID_PSS_PARAMETERS 149 -# define RSA_R_INVALID_PSS_SALTLEN 146 -# define RSA_R_INVALID_SALT_LENGTH 150 -# define RSA_R_INVALID_TRAILER 139 -# define RSA_R_INVALID_X931_DIGEST 142 -# define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 -# define RSA_R_KEY_PRIME_NUM_INVALID 165 -# define RSA_R_KEY_SIZE_TOO_SMALL 120 -# define RSA_R_LAST_OCTET_INVALID 134 -# define RSA_R_MISSING_PRIVATE_KEY 179 -# define RSA_R_MGF1_DIGEST_NOT_ALLOWED 152 -# define RSA_R_MODULUS_TOO_LARGE 105 -# define RSA_R_MP_COEFFICIENT_NOT_INVERSE_OF_R 168 -# define RSA_R_MP_EXPONENT_NOT_CONGRUENT_TO_D 169 -# define RSA_R_MP_R_NOT_PRIME 170 -# define RSA_R_NO_PUBLIC_EXPONENT 140 -# define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 -# define RSA_R_N_DOES_NOT_EQUAL_PRODUCT_OF_PRIMES 172 -# define RSA_R_N_DOES_NOT_EQUAL_P_Q 127 -# define RSA_R_OAEP_DECODING_ERROR 121 -# define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 148 -# define RSA_R_PADDING_CHECK_FAILED 114 -# define RSA_R_PKCS_DECODING_ERROR 159 -# define RSA_R_PSS_SALTLEN_TOO_SMALL 164 -# define RSA_R_P_NOT_PRIME 128 -# define RSA_R_Q_NOT_PRIME 129 -# define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130 -# define RSA_R_SLEN_CHECK_FAILED 136 -# define RSA_R_SLEN_RECOVERY_FAILED 135 -# define RSA_R_SSLV3_ROLLBACK_ATTACK 115 -# define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 -# define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 -# define RSA_R_UNKNOWN_DIGEST 166 -# define RSA_R_UNKNOWN_MASK_DIGEST 151 -# define RSA_R_UNKNOWN_PADDING_TYPE 118 -# define RSA_R_UNSUPPORTED_ENCRYPTION_TYPE 162 -# define RSA_R_UNSUPPORTED_LABEL_SOURCE 163 -# define RSA_R_UNSUPPORTED_MASK_ALGORITHM 153 -# define RSA_R_UNSUPPORTED_MASK_PARAMETER 154 -# define RSA_R_UNSUPPORTED_SIGNATURE_TYPE 155 -# define RSA_R_VALUE_MISSING 147 -# define RSA_R_WRONG_SIGNATURE_LENGTH 119 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/safestack.h b/client/3rd/OpenSSL/include/openssl/safestack.h deleted file mode 100644 index 38b55789..00000000 --- a/client/3rd/OpenSSL/include/openssl/safestack.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SAFESTACK_H -# define HEADER_SAFESTACK_H - -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -# define STACK_OF(type) struct stack_st_##type - -# define SKM_DEFINE_STACK_OF(t1, t2, t3) \ - STACK_OF(t1); \ - typedef int (*sk_##t1##_compfunc)(const t3 * const *a, const t3 *const *b); \ - typedef void (*sk_##t1##_freefunc)(t3 *a); \ - typedef t3 * (*sk_##t1##_copyfunc)(const t3 *a); \ - static ossl_unused ossl_inline int sk_##t1##_num(const STACK_OF(t1) *sk) \ - { \ - return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_value(const STACK_OF(t1) *sk, int idx) \ - { \ - return (t2 *)OPENSSL_sk_value((const OPENSSL_STACK *)sk, idx); \ - } \ - static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new(sk_##t1##_compfunc compare) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_new((OPENSSL_sk_compfunc)compare); \ - } \ - static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new_null(void) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_new_null(); \ - } \ - static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_new_reserve(sk_##t1##_compfunc compare, int n) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_new_reserve((OPENSSL_sk_compfunc)compare, n); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_reserve(STACK_OF(t1) *sk, int n) \ - { \ - return OPENSSL_sk_reserve((OPENSSL_STACK *)sk, n); \ - } \ - static ossl_unused ossl_inline void sk_##t1##_free(STACK_OF(t1) *sk) \ - { \ - OPENSSL_sk_free((OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline void sk_##t1##_zero(STACK_OF(t1) *sk) \ - { \ - OPENSSL_sk_zero((OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_delete(STACK_OF(t1) *sk, int i) \ - { \ - return (t2 *)OPENSSL_sk_delete((OPENSSL_STACK *)sk, i); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_delete_ptr(STACK_OF(t1) *sk, t2 *ptr) \ - { \ - return (t2 *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, \ - (const void *)ptr); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_push(STACK_OF(t1) *sk, t2 *ptr) \ - { \ - return OPENSSL_sk_push((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_unshift(STACK_OF(t1) *sk, t2 *ptr) \ - { \ - return OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_pop(STACK_OF(t1) *sk) \ - { \ - return (t2 *)OPENSSL_sk_pop((OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_shift(STACK_OF(t1) *sk) \ - { \ - return (t2 *)OPENSSL_sk_shift((OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline void sk_##t1##_pop_free(STACK_OF(t1) *sk, sk_##t1##_freefunc freefunc) \ - { \ - OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_insert(STACK_OF(t1) *sk, t2 *ptr, int idx) \ - { \ - return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (const void *)ptr, idx); \ - } \ - static ossl_unused ossl_inline t2 *sk_##t1##_set(STACK_OF(t1) *sk, int idx, t2 *ptr) \ - { \ - return (t2 *)OPENSSL_sk_set((OPENSSL_STACK *)sk, idx, (const void *)ptr); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_find(STACK_OF(t1) *sk, t2 *ptr) \ - { \ - return OPENSSL_sk_find((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_find_ex(STACK_OF(t1) *sk, t2 *ptr) \ - { \ - return OPENSSL_sk_find_ex((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_unused ossl_inline void sk_##t1##_sort(STACK_OF(t1) *sk) \ - { \ - OPENSSL_sk_sort((OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline int sk_##t1##_is_sorted(const STACK_OF(t1) *sk) \ - { \ - return OPENSSL_sk_is_sorted((const OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline STACK_OF(t1) * sk_##t1##_dup(const STACK_OF(t1) *sk) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_dup((const OPENSSL_STACK *)sk); \ - } \ - static ossl_unused ossl_inline STACK_OF(t1) *sk_##t1##_deep_copy(const STACK_OF(t1) *sk, \ - sk_##t1##_copyfunc copyfunc, \ - sk_##t1##_freefunc freefunc) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_deep_copy((const OPENSSL_STACK *)sk, \ - (OPENSSL_sk_copyfunc)copyfunc, \ - (OPENSSL_sk_freefunc)freefunc); \ - } \ - static ossl_unused ossl_inline sk_##t1##_compfunc sk_##t1##_set_cmp_func(STACK_OF(t1) *sk, sk_##t1##_compfunc compare) \ - { \ - return (sk_##t1##_compfunc)OPENSSL_sk_set_cmp_func((OPENSSL_STACK *)sk, (OPENSSL_sk_compfunc)compare); \ - } - -# define DEFINE_SPECIAL_STACK_OF(t1, t2) SKM_DEFINE_STACK_OF(t1, t2, t2) -# define DEFINE_STACK_OF(t) SKM_DEFINE_STACK_OF(t, t, t) -# define DEFINE_SPECIAL_STACK_OF_CONST(t1, t2) \ - SKM_DEFINE_STACK_OF(t1, const t2, t2) -# define DEFINE_STACK_OF_CONST(t) SKM_DEFINE_STACK_OF(t, const t, t) - -/*- - * Strings are special: normally an lhash entry will point to a single - * (somewhat) mutable object. In the case of strings: - * - * a) Instead of a single char, there is an array of chars, NUL-terminated. - * b) The string may have be immutable. - * - * So, they need their own declarations. Especially important for - * type-checking tools, such as Deputy. - * - * In practice, however, it appears to be hard to have a const - * string. For now, I'm settling for dealing with the fact it is a - * string at all. - */ -typedef char *OPENSSL_STRING; -typedef const char *OPENSSL_CSTRING; - -/*- - * Confusingly, LHASH_OF(STRING) deals with char ** throughout, but - * STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned - * above, instead of a single char each entry is a NUL-terminated array of - * chars. So, we have to implement STRING specially for STACK_OF. This is - * dealt with in the autogenerated macros below. - */ -DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char) -DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char) - -/* - * Similarly, we sometimes use a block of characters, NOT nul-terminated. - * These should also be distinguished from "normal" stacks. - */ -typedef void *OPENSSL_BLOCK; -DEFINE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void) - -/* - * If called without higher optimization (min. -xO3) the Oracle Developer - * Studio compiler generates code for the defined (static inline) functions - * above. - * This would later lead to the linker complaining about missing symbols when - * this header file is included but the resulting object is not linked against - * the Crypto library (openssl#6912). - */ -# ifdef __SUNPRO_C -# pragma weak OPENSSL_sk_num -# pragma weak OPENSSL_sk_value -# pragma weak OPENSSL_sk_new -# pragma weak OPENSSL_sk_new_null -# pragma weak OPENSSL_sk_new_reserve -# pragma weak OPENSSL_sk_reserve -# pragma weak OPENSSL_sk_free -# pragma weak OPENSSL_sk_zero -# pragma weak OPENSSL_sk_delete -# pragma weak OPENSSL_sk_delete_ptr -# pragma weak OPENSSL_sk_push -# pragma weak OPENSSL_sk_unshift -# pragma weak OPENSSL_sk_pop -# pragma weak OPENSSL_sk_shift -# pragma weak OPENSSL_sk_pop_free -# pragma weak OPENSSL_sk_insert -# pragma weak OPENSSL_sk_set -# pragma weak OPENSSL_sk_find -# pragma weak OPENSSL_sk_find_ex -# pragma weak OPENSSL_sk_sort -# pragma weak OPENSSL_sk_is_sorted -# pragma weak OPENSSL_sk_dup -# pragma weak OPENSSL_sk_deep_copy -# pragma weak OPENSSL_sk_set_cmp_func -# endif /* __SUNPRO_C */ - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/seed.h b/client/3rd/OpenSSL/include/openssl/seed.h deleted file mode 100644 index de10b085..00000000 --- a/client/3rd/OpenSSL/include/openssl/seed.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Neither the name of author nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef HEADER_SEED_H -# define HEADER_SEED_H - -# include - -# ifndef OPENSSL_NO_SEED -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/* look whether we need 'long' to get 32 bits */ -# ifdef AES_LONG -# ifndef SEED_LONG -# define SEED_LONG 1 -# endif -# endif - -# include - -# define SEED_BLOCK_SIZE 16 -# define SEED_KEY_LENGTH 16 - -typedef struct seed_key_st { -# ifdef SEED_LONG - unsigned long data[32]; -# else - unsigned int data[32]; -# endif -} SEED_KEY_SCHEDULE; - -void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], - SEED_KEY_SCHEDULE *ks); - -void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], - unsigned char d[SEED_BLOCK_SIZE], - const SEED_KEY_SCHEDULE *ks); -void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE], - unsigned char d[SEED_BLOCK_SIZE], - const SEED_KEY_SCHEDULE *ks); - -void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out, - const SEED_KEY_SCHEDULE *ks, int enc); -void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const SEED_KEY_SCHEDULE *ks, - unsigned char ivec[SEED_BLOCK_SIZE], int enc); -void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const SEED_KEY_SCHEDULE *ks, - unsigned char ivec[SEED_BLOCK_SIZE], int *num, - int enc); -void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const SEED_KEY_SCHEDULE *ks, - unsigned char ivec[SEED_BLOCK_SIZE], int *num); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/sha.h b/client/3rd/OpenSSL/include/openssl/sha.h deleted file mode 100644 index 6a1eb0de..00000000 --- a/client/3rd/OpenSSL/include/openssl/sha.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SHA_H -# define HEADER_SHA_H - -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/*- - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! SHA_LONG has to be at least 32 bits wide. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ -# define SHA_LONG unsigned int - -# define SHA_LBLOCK 16 -# define SHA_CBLOCK (SHA_LBLOCK*4)/* SHA treats input data as a - * contiguous array of 32 bit wide - * big-endian values. */ -# define SHA_LAST_BLOCK (SHA_CBLOCK-8) -# define SHA_DIGEST_LENGTH 20 - -typedef struct SHAstate_st { - SHA_LONG h0, h1, h2, h3, h4; - SHA_LONG Nl, Nh; - SHA_LONG data[SHA_LBLOCK]; - unsigned int num; -} SHA_CTX; - -int SHA1_Init(SHA_CTX *c); -int SHA1_Update(SHA_CTX *c, const void *data, size_t len); -int SHA1_Final(unsigned char *md, SHA_CTX *c); -unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); -void SHA1_Transform(SHA_CTX *c, const unsigned char *data); - -# define SHA256_CBLOCK (SHA_LBLOCK*4)/* SHA-256 treats input data as a - * contiguous array of 32 bit wide - * big-endian values. */ - -typedef struct SHA256state_st { - SHA_LONG h[8]; - SHA_LONG Nl, Nh; - SHA_LONG data[SHA_LBLOCK]; - unsigned int num, md_len; -} SHA256_CTX; - -int SHA224_Init(SHA256_CTX *c); -int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); -int SHA224_Final(unsigned char *md, SHA256_CTX *c); -unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md); -int SHA256_Init(SHA256_CTX *c); -int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); -int SHA256_Final(unsigned char *md, SHA256_CTX *c); -unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md); -void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); - -# define SHA224_DIGEST_LENGTH 28 -# define SHA256_DIGEST_LENGTH 32 -# define SHA384_DIGEST_LENGTH 48 -# define SHA512_DIGEST_LENGTH 64 - -/* - * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64 - * being exactly 64-bit wide. See Implementation Notes in sha512.c - * for further details. - */ -/* - * SHA-512 treats input data as a - * contiguous array of 64 bit - * wide big-endian values. - */ -# define SHA512_CBLOCK (SHA_LBLOCK*8) -# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) -# define SHA_LONG64 unsigned __int64 -# define U64(C) C##UI64 -# elif defined(__arch64__) -# define SHA_LONG64 unsigned long -# define U64(C) C##UL -# else -# define SHA_LONG64 unsigned long long -# define U64(C) C##ULL -# endif - -typedef struct SHA512state_st { - SHA_LONG64 h[8]; - SHA_LONG64 Nl, Nh; - union { - SHA_LONG64 d[SHA_LBLOCK]; - unsigned char p[SHA512_CBLOCK]; - } u; - unsigned int num, md_len; -} SHA512_CTX; - -int SHA384_Init(SHA512_CTX *c); -int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); -int SHA384_Final(unsigned char *md, SHA512_CTX *c); -unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md); -int SHA512_Init(SHA512_CTX *c); -int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); -int SHA512_Final(unsigned char *md, SHA512_CTX *c); -unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md); -void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/srp.h b/client/3rd/OpenSSL/include/openssl/srp.h deleted file mode 100644 index aaf13558..00000000 --- a/client/3rd/OpenSSL/include/openssl/srp.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2004, EdelKey Project. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - * - * Originally written by Christophe Renou and Peter Sylvester, - * for the EdelKey project. - */ - -#ifndef HEADER_SRP_H -# define HEADER_SRP_H - -#include - -#ifndef OPENSSL_NO_SRP -# include -# include -# include -# include -# include - -# ifdef __cplusplus -extern "C" { -# endif - -typedef struct SRP_gN_cache_st { - char *b64_bn; - BIGNUM *bn; -} SRP_gN_cache; - - -DEFINE_STACK_OF(SRP_gN_cache) - -typedef struct SRP_user_pwd_st { - /* Owned by us. */ - char *id; - BIGNUM *s; - BIGNUM *v; - /* Not owned by us. */ - const BIGNUM *g; - const BIGNUM *N; - /* Owned by us. */ - char *info; -} SRP_user_pwd; - -void SRP_user_pwd_free(SRP_user_pwd *user_pwd); - -DEFINE_STACK_OF(SRP_user_pwd) - -typedef struct SRP_VBASE_st { - STACK_OF(SRP_user_pwd) *users_pwd; - STACK_OF(SRP_gN_cache) *gN_cache; -/* to simulate a user */ - char *seed_key; - const BIGNUM *default_g; - const BIGNUM *default_N; -} SRP_VBASE; - -/* - * Internal structure storing N and g pair - */ -typedef struct SRP_gN_st { - char *id; - const BIGNUM *g; - const BIGNUM *N; -} SRP_gN; - -DEFINE_STACK_OF(SRP_gN) - -SRP_VBASE *SRP_VBASE_new(char *seed_key); -void SRP_VBASE_free(SRP_VBASE *vb); -int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file); - -/* This method ignores the configured seed and fails for an unknown user. */ -DEPRECATEDIN_1_1_0(SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)) -/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/ -SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username); - -char *SRP_create_verifier(const char *user, const char *pass, char **salt, - char **verifier, const char *N, const char *g); -int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt, - BIGNUM **verifier, const BIGNUM *N, - const BIGNUM *g); - -# define SRP_NO_ERROR 0 -# define SRP_ERR_VBASE_INCOMPLETE_FILE 1 -# define SRP_ERR_VBASE_BN_LIB 2 -# define SRP_ERR_OPEN_FILE 3 -# define SRP_ERR_MEMORY 4 - -# define DB_srptype 0 -# define DB_srpverifier 1 -# define DB_srpsalt 2 -# define DB_srpid 3 -# define DB_srpgN 4 -# define DB_srpinfo 5 -# undef DB_NUMBER -# define DB_NUMBER 6 - -# define DB_SRP_INDEX 'I' -# define DB_SRP_VALID 'V' -# define DB_SRP_REVOKED 'R' -# define DB_SRP_MODIF 'v' - -/* see srp.c */ -char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N); -SRP_gN *SRP_get_default_gN(const char *id); - -/* server side .... */ -BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u, - const BIGNUM *b, const BIGNUM *N); -BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g, - const BIGNUM *v); -int SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N); -BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N); - -/* client side .... */ -BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass); -BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g); -BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g, - const BIGNUM *x, const BIGNUM *a, const BIGNUM *u); -int SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N); - -# define SRP_MINIMAL_N 1024 - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/srtp.h b/client/3rd/OpenSSL/include/openssl/srtp.h deleted file mode 100644 index 0b57c235..00000000 --- a/client/3rd/OpenSSL/include/openssl/srtp.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * DTLS code by Eric Rescorla - * - * Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc. - */ - -#ifndef HEADER_D1_SRTP_H -# define HEADER_D1_SRTP_H - -# include - -#ifdef __cplusplus -extern "C" { -#endif - -# define SRTP_AES128_CM_SHA1_80 0x0001 -# define SRTP_AES128_CM_SHA1_32 0x0002 -# define SRTP_AES128_F8_SHA1_80 0x0003 -# define SRTP_AES128_F8_SHA1_32 0x0004 -# define SRTP_NULL_SHA1_80 0x0005 -# define SRTP_NULL_SHA1_32 0x0006 - -/* AEAD SRTP protection profiles from RFC 7714 */ -# define SRTP_AEAD_AES_128_GCM 0x0007 -# define SRTP_AEAD_AES_256_GCM 0x0008 - -# ifndef OPENSSL_NO_SRTP - -__owur int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles); -__owur int SSL_set_tlsext_use_srtp(SSL *ssl, const char *profiles); - -__owur STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl); -__owur SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s); - -# endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ssl.h b/client/3rd/OpenSSL/include/openssl/ssl.h deleted file mode 100644 index fd0c5a99..00000000 --- a/client/3rd/OpenSSL/include/openssl/ssl.h +++ /dev/null @@ -1,2438 +0,0 @@ -/* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved - * Copyright 2005 Nokia. All rights reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SSL_H -# define HEADER_SSL_H - -# include -# include -# include -# include -# if OPENSSL_API_COMPAT < 0x10100000L -# include -# include -# include -# endif -# include -# include -# include -# include - -# include -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/* OpenSSL version number for ASN.1 encoding of the session information */ -/*- - * Version 0 - initial version - * Version 1 - added the optional peer certificate - */ -# define SSL_SESSION_ASN1_VERSION 0x0001 - -# define SSL_MAX_SSL_SESSION_ID_LENGTH 32 -# define SSL_MAX_SID_CTX_LENGTH 32 - -# define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8) -# define SSL_MAX_KEY_ARG_LENGTH 8 -# define SSL_MAX_MASTER_KEY_LENGTH 48 - -/* The maximum number of encrypt/decrypt pipelines we can support */ -# define SSL_MAX_PIPELINES 32 - -/* text strings for the ciphers */ - -/* These are used to specify which ciphers to use and not to use */ - -# define SSL_TXT_LOW "LOW" -# define SSL_TXT_MEDIUM "MEDIUM" -# define SSL_TXT_HIGH "HIGH" -# define SSL_TXT_FIPS "FIPS" - -# define SSL_TXT_aNULL "aNULL" -# define SSL_TXT_eNULL "eNULL" -# define SSL_TXT_NULL "NULL" - -# define SSL_TXT_kRSA "kRSA" -# define SSL_TXT_kDHr "kDHr"/* this cipher class has been removed */ -# define SSL_TXT_kDHd "kDHd"/* this cipher class has been removed */ -# define SSL_TXT_kDH "kDH"/* this cipher class has been removed */ -# define SSL_TXT_kEDH "kEDH"/* alias for kDHE */ -# define SSL_TXT_kDHE "kDHE" -# define SSL_TXT_kECDHr "kECDHr"/* this cipher class has been removed */ -# define SSL_TXT_kECDHe "kECDHe"/* this cipher class has been removed */ -# define SSL_TXT_kECDH "kECDH"/* this cipher class has been removed */ -# define SSL_TXT_kEECDH "kEECDH"/* alias for kECDHE */ -# define SSL_TXT_kECDHE "kECDHE" -# define SSL_TXT_kPSK "kPSK" -# define SSL_TXT_kRSAPSK "kRSAPSK" -# define SSL_TXT_kECDHEPSK "kECDHEPSK" -# define SSL_TXT_kDHEPSK "kDHEPSK" -# define SSL_TXT_kGOST "kGOST" -# define SSL_TXT_kSRP "kSRP" - -# define SSL_TXT_aRSA "aRSA" -# define SSL_TXT_aDSS "aDSS" -# define SSL_TXT_aDH "aDH"/* this cipher class has been removed */ -# define SSL_TXT_aECDH "aECDH"/* this cipher class has been removed */ -# define SSL_TXT_aECDSA "aECDSA" -# define SSL_TXT_aPSK "aPSK" -# define SSL_TXT_aGOST94 "aGOST94" -# define SSL_TXT_aGOST01 "aGOST01" -# define SSL_TXT_aGOST12 "aGOST12" -# define SSL_TXT_aGOST "aGOST" -# define SSL_TXT_aSRP "aSRP" - -# define SSL_TXT_DSS "DSS" -# define SSL_TXT_DH "DH" -# define SSL_TXT_DHE "DHE"/* same as "kDHE:-ADH" */ -# define SSL_TXT_EDH "EDH"/* alias for DHE */ -# define SSL_TXT_ADH "ADH" -# define SSL_TXT_RSA "RSA" -# define SSL_TXT_ECDH "ECDH" -# define SSL_TXT_EECDH "EECDH"/* alias for ECDHE" */ -# define SSL_TXT_ECDHE "ECDHE"/* same as "kECDHE:-AECDH" */ -# define SSL_TXT_AECDH "AECDH" -# define SSL_TXT_ECDSA "ECDSA" -# define SSL_TXT_PSK "PSK" -# define SSL_TXT_SRP "SRP" - -# define SSL_TXT_DES "DES" -# define SSL_TXT_3DES "3DES" -# define SSL_TXT_RC4 "RC4" -# define SSL_TXT_RC2 "RC2" -# define SSL_TXT_IDEA "IDEA" -# define SSL_TXT_SEED "SEED" -# define SSL_TXT_AES128 "AES128" -# define SSL_TXT_AES256 "AES256" -# define SSL_TXT_AES "AES" -# define SSL_TXT_AES_GCM "AESGCM" -# define SSL_TXT_AES_CCM "AESCCM" -# define SSL_TXT_AES_CCM_8 "AESCCM8" -# define SSL_TXT_CAMELLIA128 "CAMELLIA128" -# define SSL_TXT_CAMELLIA256 "CAMELLIA256" -# define SSL_TXT_CAMELLIA "CAMELLIA" -# define SSL_TXT_CHACHA20 "CHACHA20" -# define SSL_TXT_GOST "GOST89" -# define SSL_TXT_ARIA "ARIA" -# define SSL_TXT_ARIA_GCM "ARIAGCM" -# define SSL_TXT_ARIA128 "ARIA128" -# define SSL_TXT_ARIA256 "ARIA256" - -# define SSL_TXT_MD5 "MD5" -# define SSL_TXT_SHA1 "SHA1" -# define SSL_TXT_SHA "SHA"/* same as "SHA1" */ -# define SSL_TXT_GOST94 "GOST94" -# define SSL_TXT_GOST89MAC "GOST89MAC" -# define SSL_TXT_GOST12 "GOST12" -# define SSL_TXT_GOST89MAC12 "GOST89MAC12" -# define SSL_TXT_SHA256 "SHA256" -# define SSL_TXT_SHA384 "SHA384" - -# define SSL_TXT_SSLV3 "SSLv3" -# define SSL_TXT_TLSV1 "TLSv1" -# define SSL_TXT_TLSV1_1 "TLSv1.1" -# define SSL_TXT_TLSV1_2 "TLSv1.2" - -# define SSL_TXT_ALL "ALL" - -/*- - * COMPLEMENTOF* definitions. These identifiers are used to (de-select) - * ciphers normally not being used. - * Example: "RC4" will activate all ciphers using RC4 including ciphers - * without authentication, which would normally disabled by DEFAULT (due - * the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT" - * will make sure that it is also disabled in the specific selection. - * COMPLEMENTOF* identifiers are portable between version, as adjustments - * to the default cipher setup will also be included here. - * - * COMPLEMENTOFDEFAULT does not experience the same special treatment that - * DEFAULT gets, as only selection is being done and no sorting as needed - * for DEFAULT. - */ -# define SSL_TXT_CMPALL "COMPLEMENTOFALL" -# define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT" - -/* - * The following cipher list is used by default. It also is substituted when - * an application-defined cipher list string starts with 'DEFAULT'. - * This applies to ciphersuites for TLSv1.2 and below. - */ -# define SSL_DEFAULT_CIPHER_LIST "ALL:!COMPLEMENTOFDEFAULT:!eNULL" -/* This is the default set of TLSv1.3 ciphersuites */ -# if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305) -# define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ - "TLS_CHACHA20_POLY1305_SHA256:" \ - "TLS_AES_128_GCM_SHA256" -# else -# define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \ - "TLS_AES_128_GCM_SHA256" -#endif -/* - * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always - * starts with a reasonable order, and all we have to do for DEFAULT is - * throwing out anonymous and unencrypted ciphersuites! (The latter are not - * actually enabled by ALL, but "ALL:RSA" would enable some of them.) - */ - -/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ -# define SSL_SENT_SHUTDOWN 1 -# define SSL_RECEIVED_SHUTDOWN 2 - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -# define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 -# define SSL_FILETYPE_PEM X509_FILETYPE_PEM - -/* - * This is needed to stop compilers complaining about the 'struct ssl_st *' - * function parameters used to prototype callbacks in SSL_CTX. - */ -typedef struct ssl_st *ssl_crock_st; -typedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT; -typedef struct ssl_method_st SSL_METHOD; -typedef struct ssl_cipher_st SSL_CIPHER; -typedef struct ssl_session_st SSL_SESSION; -typedef struct tls_sigalgs_st TLS_SIGALGS; -typedef struct ssl_conf_ctx_st SSL_CONF_CTX; -typedef struct ssl_comp_st SSL_COMP; - -STACK_OF(SSL_CIPHER); -STACK_OF(SSL_COMP); - -/* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/ -typedef struct srtp_protection_profile_st { - const char *name; - unsigned long id; -} SRTP_PROTECTION_PROFILE; - -DEFINE_STACK_OF(SRTP_PROTECTION_PROFILE) - -typedef int (*tls_session_ticket_ext_cb_fn)(SSL *s, const unsigned char *data, - int len, void *arg); -typedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len, - STACK_OF(SSL_CIPHER) *peer_ciphers, - const SSL_CIPHER **cipher, void *arg); - -/* Extension context codes */ -/* This extension is only allowed in TLS */ -#define SSL_EXT_TLS_ONLY 0x0001 -/* This extension is only allowed in DTLS */ -#define SSL_EXT_DTLS_ONLY 0x0002 -/* Some extensions may be allowed in DTLS but we don't implement them for it */ -#define SSL_EXT_TLS_IMPLEMENTATION_ONLY 0x0004 -/* Most extensions are not defined for SSLv3 but EXT_TYPE_renegotiate is */ -#define SSL_EXT_SSL3_ALLOWED 0x0008 -/* Extension is only defined for TLS1.2 and below */ -#define SSL_EXT_TLS1_2_AND_BELOW_ONLY 0x0010 -/* Extension is only defined for TLS1.3 and above */ -#define SSL_EXT_TLS1_3_ONLY 0x0020 -/* Ignore this extension during parsing if we are resuming */ -#define SSL_EXT_IGNORE_ON_RESUMPTION 0x0040 -#define SSL_EXT_CLIENT_HELLO 0x0080 -/* Really means TLS1.2 or below */ -#define SSL_EXT_TLS1_2_SERVER_HELLO 0x0100 -#define SSL_EXT_TLS1_3_SERVER_HELLO 0x0200 -#define SSL_EXT_TLS1_3_ENCRYPTED_EXTENSIONS 0x0400 -#define SSL_EXT_TLS1_3_HELLO_RETRY_REQUEST 0x0800 -#define SSL_EXT_TLS1_3_CERTIFICATE 0x1000 -#define SSL_EXT_TLS1_3_NEW_SESSION_TICKET 0x2000 -#define SSL_EXT_TLS1_3_CERTIFICATE_REQUEST 0x4000 - -/* Typedefs for handling custom extensions */ - -typedef int (*custom_ext_add_cb)(SSL *s, unsigned int ext_type, - const unsigned char **out, size_t *outlen, - int *al, void *add_arg); - -typedef void (*custom_ext_free_cb)(SSL *s, unsigned int ext_type, - const unsigned char *out, void *add_arg); - -typedef int (*custom_ext_parse_cb)(SSL *s, unsigned int ext_type, - const unsigned char *in, size_t inlen, - int *al, void *parse_arg); - - -typedef int (*SSL_custom_ext_add_cb_ex)(SSL *s, unsigned int ext_type, - unsigned int context, - const unsigned char **out, - size_t *outlen, X509 *x, - size_t chainidx, - int *al, void *add_arg); - -typedef void (*SSL_custom_ext_free_cb_ex)(SSL *s, unsigned int ext_type, - unsigned int context, - const unsigned char *out, - void *add_arg); - -typedef int (*SSL_custom_ext_parse_cb_ex)(SSL *s, unsigned int ext_type, - unsigned int context, - const unsigned char *in, - size_t inlen, X509 *x, - size_t chainidx, - int *al, void *parse_arg); - -/* Typedef for verification callback */ -typedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx); - -/* - * Some values are reserved until OpenSSL 1.2.0 because they were previously - * included in SSL_OP_ALL in a 1.1.x release. - * - * Reserved value (until OpenSSL 1.2.0) 0x00000001U - * Reserved value (until OpenSSL 1.2.0) 0x00000002U - */ -/* Allow initial connection to servers that don't support RI */ -# define SSL_OP_LEGACY_SERVER_CONNECT 0x00000004U - -/* Reserved value (until OpenSSL 1.2.0) 0x00000008U */ -# define SSL_OP_TLSEXT_PADDING 0x00000010U -/* Reserved value (until OpenSSL 1.2.0) 0x00000020U */ -# define SSL_OP_SAFARI_ECDHE_ECDSA_BUG 0x00000040U -/* - * Reserved value (until OpenSSL 1.2.0) 0x00000080U - * Reserved value (until OpenSSL 1.2.0) 0x00000100U - * Reserved value (until OpenSSL 1.2.0) 0x00000200U - */ - -/* In TLSv1.3 allow a non-(ec)dhe based kex_mode */ -# define SSL_OP_ALLOW_NO_DHE_KEX 0x00000400U - -/* - * Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added in - * OpenSSL 0.9.6d. Usually (depending on the application protocol) the - * workaround is not needed. Unfortunately some broken SSL/TLS - * implementations cannot handle it at all, which is why we include it in - * SSL_OP_ALL. Added in 0.9.6e - */ -# define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x00000800U - -/* DTLS options */ -# define SSL_OP_NO_QUERY_MTU 0x00001000U -/* Turn on Cookie Exchange (on relevant for servers) */ -# define SSL_OP_COOKIE_EXCHANGE 0x00002000U -/* Don't use RFC4507 ticket extension */ -# define SSL_OP_NO_TICKET 0x00004000U -# ifndef OPENSSL_NO_DTLS1_METHOD -/* Use Cisco's "speshul" version of DTLS_BAD_VER - * (only with deprecated DTLSv1_client_method()) */ -# define SSL_OP_CISCO_ANYCONNECT 0x00008000U -# endif - -/* As server, disallow session resumption on renegotiation */ -# define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x00010000U -/* Don't use compression even if supported */ -# define SSL_OP_NO_COMPRESSION 0x00020000U -/* Permit unsafe legacy renegotiation */ -# define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION 0x00040000U -/* Disable encrypt-then-mac */ -# define SSL_OP_NO_ENCRYPT_THEN_MAC 0x00080000U - -/* - * Enable TLSv1.3 Compatibility mode. This is on by default. A future version - * of OpenSSL may have this disabled by default. - */ -# define SSL_OP_ENABLE_MIDDLEBOX_COMPAT 0x00100000U - -/* Prioritize Chacha20Poly1305 when client does. - * Modifies SSL_OP_CIPHER_SERVER_PREFERENCE */ -# define SSL_OP_PRIORITIZE_CHACHA 0x00200000U - -/* - * Set on servers to choose the cipher according to the server's preferences - */ -# define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000U -/* - * If set, a server will allow a client to issue a SSLv3.0 version number as - * latest version supported in the premaster secret, even when TLSv1.0 - * (version 3.1) was announced in the client hello. Normally this is - * forbidden to prevent version rollback attacks. - */ -# define SSL_OP_TLS_ROLLBACK_BUG 0x00800000U - -/* - * Switches off automatic TLSv1.3 anti-replay protection for early data. This - * is a server-side option only (no effect on the client). - */ -# define SSL_OP_NO_ANTI_REPLAY 0x01000000U - -# define SSL_OP_NO_SSLv3 0x02000000U -# define SSL_OP_NO_TLSv1 0x04000000U -# define SSL_OP_NO_TLSv1_2 0x08000000U -# define SSL_OP_NO_TLSv1_1 0x10000000U -# define SSL_OP_NO_TLSv1_3 0x20000000U - -# define SSL_OP_NO_DTLSv1 0x04000000U -# define SSL_OP_NO_DTLSv1_2 0x08000000U - -# define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv3|\ - SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2|SSL_OP_NO_TLSv1_3) -# define SSL_OP_NO_DTLS_MASK (SSL_OP_NO_DTLSv1|SSL_OP_NO_DTLSv1_2) - -/* Disallow all renegotiation */ -# define SSL_OP_NO_RENEGOTIATION 0x40000000U - -/* - * Make server add server-hello extension from early version of cryptopro - * draft, when GOST ciphersuite is negotiated. Required for interoperability - * with CryptoPro CSP 3.x - */ -# define SSL_OP_CRYPTOPRO_TLSEXT_BUG 0x80000000U - -/* - * SSL_OP_ALL: various bug workarounds that should be rather harmless. - * This used to be 0x000FFFFFL before 0.9.7. - * This used to be 0x80000BFFU before 1.1.1. - */ -# define SSL_OP_ALL (SSL_OP_CRYPTOPRO_TLSEXT_BUG|\ - SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS|\ - SSL_OP_LEGACY_SERVER_CONNECT|\ - SSL_OP_TLSEXT_PADDING|\ - SSL_OP_SAFARI_ECDHE_ECDSA_BUG) - -/* OBSOLETE OPTIONS: retained for compatibility */ - -/* Removed from OpenSSL 1.1.0. Was 0x00000001L */ -/* Related to removed SSLv2. */ -# define SSL_OP_MICROSOFT_SESS_ID_BUG 0x0 -/* Removed from OpenSSL 1.1.0. Was 0x00000002L */ -/* Related to removed SSLv2. */ -# define SSL_OP_NETSCAPE_CHALLENGE_BUG 0x0 -/* Removed from OpenSSL 0.9.8q and 1.0.0c. Was 0x00000008L */ -/* Dead forever, see CVE-2010-4180 */ -# define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x0 -/* Removed from OpenSSL 1.0.1h and 1.0.2. Was 0x00000010L */ -/* Refers to ancient SSLREF and SSLv2. */ -# define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x0 -/* Removed from OpenSSL 1.1.0. Was 0x00000020 */ -# define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x0 -/* Removed from OpenSSL 0.9.7h and 0.9.8b. Was 0x00000040L */ -# define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x0 -/* Removed from OpenSSL 1.1.0. Was 0x00000080 */ -/* Ancient SSLeay version. */ -# define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x0 -/* Removed from OpenSSL 1.1.0. Was 0x00000100L */ -# define SSL_OP_TLS_D5_BUG 0x0 -/* Removed from OpenSSL 1.1.0. Was 0x00000200L */ -# define SSL_OP_TLS_BLOCK_PADDING_BUG 0x0 -/* Removed from OpenSSL 1.1.0. Was 0x00080000L */ -# define SSL_OP_SINGLE_ECDH_USE 0x0 -/* Removed from OpenSSL 1.1.0. Was 0x00100000L */ -# define SSL_OP_SINGLE_DH_USE 0x0 -/* Removed from OpenSSL 1.0.1k and 1.0.2. Was 0x00200000L */ -# define SSL_OP_EPHEMERAL_RSA 0x0 -/* Removed from OpenSSL 1.1.0. Was 0x01000000L */ -# define SSL_OP_NO_SSLv2 0x0 -/* Removed from OpenSSL 1.0.1. Was 0x08000000L */ -# define SSL_OP_PKCS1_CHECK_1 0x0 -/* Removed from OpenSSL 1.0.1. Was 0x10000000L */ -# define SSL_OP_PKCS1_CHECK_2 0x0 -/* Removed from OpenSSL 1.1.0. Was 0x20000000L */ -# define SSL_OP_NETSCAPE_CA_DN_BUG 0x0 -/* Removed from OpenSSL 1.1.0. Was 0x40000000L */ -# define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x0 - -/* - * Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success - * when just a single record has been written): - */ -# define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001U -/* - * Make it possible to retry SSL_write() with changed buffer location (buffer - * contents must stay the same!); this is not the default to avoid the - * misconception that non-blocking SSL_write() behaves like non-blocking - * write(): - */ -# define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002U -/* - * Never bother the application with retries if the transport is blocking: - */ -# define SSL_MODE_AUTO_RETRY 0x00000004U -/* Don't attempt to automatically build certificate chain */ -# define SSL_MODE_NO_AUTO_CHAIN 0x00000008U -/* - * Save RAM by releasing read and write buffers when they're empty. (SSL3 and - * TLS only.) Released buffers are freed. - */ -# define SSL_MODE_RELEASE_BUFFERS 0x00000010U -/* - * Send the current time in the Random fields of the ClientHello and - * ServerHello records for compatibility with hypothetical implementations - * that require it. - */ -# define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020U -# define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040U -/* - * Send TLS_FALLBACK_SCSV in the ClientHello. To be set only by applications - * that reconnect with a downgraded protocol version; see - * draft-ietf-tls-downgrade-scsv-00 for details. DO NOT ENABLE THIS if your - * application attempts a normal handshake. Only use this in explicit - * fallback retries, following the guidance in - * draft-ietf-tls-downgrade-scsv-00. - */ -# define SSL_MODE_SEND_FALLBACK_SCSV 0x00000080U -/* - * Support Asynchronous operation - */ -# define SSL_MODE_ASYNC 0x00000100U - -/* - * When using DTLS/SCTP, include the terminating zero in the label - * used for computing the endpoint-pair shared secret. Required for - * interoperability with implementations having this bug like these - * older version of OpenSSL: - * - OpenSSL 1.0.0 series - * - OpenSSL 1.0.1 series - * - OpenSSL 1.0.2 series - * - OpenSSL 1.1.0 series - * - OpenSSL 1.1.1 and 1.1.1a - */ -# define SSL_MODE_DTLS_SCTP_LABEL_LENGTH_BUG 0x00000400U - -/* Cert related flags */ -/* - * Many implementations ignore some aspects of the TLS standards such as - * enforcing certificate chain algorithms. When this is set we enforce them. - */ -# define SSL_CERT_FLAG_TLS_STRICT 0x00000001U - -/* Suite B modes, takes same values as certificate verify flags */ -# define SSL_CERT_FLAG_SUITEB_128_LOS_ONLY 0x10000 -/* Suite B 192 bit only mode */ -# define SSL_CERT_FLAG_SUITEB_192_LOS 0x20000 -/* Suite B 128 bit mode allowing 192 bit algorithms */ -# define SSL_CERT_FLAG_SUITEB_128_LOS 0x30000 - -/* Perform all sorts of protocol violations for testing purposes */ -# define SSL_CERT_FLAG_BROKEN_PROTOCOL 0x10000000 - -/* Flags for building certificate chains */ -/* Treat any existing certificates as untrusted CAs */ -# define SSL_BUILD_CHAIN_FLAG_UNTRUSTED 0x1 -/* Don't include root CA in chain */ -# define SSL_BUILD_CHAIN_FLAG_NO_ROOT 0x2 -/* Just check certificates already there */ -# define SSL_BUILD_CHAIN_FLAG_CHECK 0x4 -/* Ignore verification errors */ -# define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR 0x8 -/* Clear verification errors from queue */ -# define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR 0x10 - -/* Flags returned by SSL_check_chain */ -/* Certificate can be used with this session */ -# define CERT_PKEY_VALID 0x1 -/* Certificate can also be used for signing */ -# define CERT_PKEY_SIGN 0x2 -/* EE certificate signing algorithm OK */ -# define CERT_PKEY_EE_SIGNATURE 0x10 -/* CA signature algorithms OK */ -# define CERT_PKEY_CA_SIGNATURE 0x20 -/* EE certificate parameters OK */ -# define CERT_PKEY_EE_PARAM 0x40 -/* CA certificate parameters OK */ -# define CERT_PKEY_CA_PARAM 0x80 -/* Signing explicitly allowed as opposed to SHA1 fallback */ -# define CERT_PKEY_EXPLICIT_SIGN 0x100 -/* Client CA issuer names match (always set for server cert) */ -# define CERT_PKEY_ISSUER_NAME 0x200 -/* Cert type matches client types (always set for server cert) */ -# define CERT_PKEY_CERT_TYPE 0x400 -/* Cert chain suitable to Suite B */ -# define CERT_PKEY_SUITEB 0x800 - -# define SSL_CONF_FLAG_CMDLINE 0x1 -# define SSL_CONF_FLAG_FILE 0x2 -# define SSL_CONF_FLAG_CLIENT 0x4 -# define SSL_CONF_FLAG_SERVER 0x8 -# define SSL_CONF_FLAG_SHOW_ERRORS 0x10 -# define SSL_CONF_FLAG_CERTIFICATE 0x20 -# define SSL_CONF_FLAG_REQUIRE_PRIVATE 0x40 -/* Configuration value types */ -# define SSL_CONF_TYPE_UNKNOWN 0x0 -# define SSL_CONF_TYPE_STRING 0x1 -# define SSL_CONF_TYPE_FILE 0x2 -# define SSL_CONF_TYPE_DIR 0x3 -# define SSL_CONF_TYPE_NONE 0x4 - -/* Maximum length of the application-controlled segment of a a TLSv1.3 cookie */ -# define SSL_COOKIE_LENGTH 4096 - -/* - * Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, they - * cannot be used to clear bits. - */ - -unsigned long SSL_CTX_get_options(const SSL_CTX *ctx); -unsigned long SSL_get_options(const SSL *s); -unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op); -unsigned long SSL_clear_options(SSL *s, unsigned long op); -unsigned long SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op); -unsigned long SSL_set_options(SSL *s, unsigned long op); - -# define SSL_CTX_set_mode(ctx,op) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL) -# define SSL_CTX_clear_mode(ctx,op) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_MODE,(op),NULL) -# define SSL_CTX_get_mode(ctx) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL) -# define SSL_clear_mode(ssl,op) \ - SSL_ctrl((ssl),SSL_CTRL_CLEAR_MODE,(op),NULL) -# define SSL_set_mode(ssl,op) \ - SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL) -# define SSL_get_mode(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL) -# define SSL_set_mtu(ssl, mtu) \ - SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL) -# define DTLS_set_link_mtu(ssl, mtu) \ - SSL_ctrl((ssl),DTLS_CTRL_SET_LINK_MTU,(mtu),NULL) -# define DTLS_get_link_min_mtu(ssl) \ - SSL_ctrl((ssl),DTLS_CTRL_GET_LINK_MIN_MTU,0,NULL) - -# define SSL_get_secure_renegotiation_support(ssl) \ - SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL) - -# ifndef OPENSSL_NO_HEARTBEATS -# define SSL_heartbeat(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT,0,NULL) -# endif - -# define SSL_CTX_set_cert_flags(ctx,op) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_CERT_FLAGS,(op),NULL) -# define SSL_set_cert_flags(s,op) \ - SSL_ctrl((s),SSL_CTRL_CERT_FLAGS,(op),NULL) -# define SSL_CTX_clear_cert_flags(ctx,op) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL) -# define SSL_clear_cert_flags(s,op) \ - SSL_ctrl((s),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL) - -void SSL_CTX_set_msg_callback(SSL_CTX *ctx, - void (*cb) (int write_p, int version, - int content_type, const void *buf, - size_t len, SSL *ssl, void *arg)); -void SSL_set_msg_callback(SSL *ssl, - void (*cb) (int write_p, int version, - int content_type, const void *buf, - size_t len, SSL *ssl, void *arg)); -# define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) -# define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) - -# define SSL_get_extms_support(s) \ - SSL_ctrl((s),SSL_CTRL_GET_EXTMS_SUPPORT,0,NULL) - -# ifndef OPENSSL_NO_SRP - -/* see tls_srp.c */ -__owur int SSL_SRP_CTX_init(SSL *s); -__owur int SSL_CTX_SRP_CTX_init(SSL_CTX *ctx); -int SSL_SRP_CTX_free(SSL *ctx); -int SSL_CTX_SRP_CTX_free(SSL_CTX *ctx); -__owur int SSL_srp_server_param_with_username(SSL *s, int *ad); -__owur int SRP_Calc_A_param(SSL *s); - -# endif - -/* 100k max cert list */ -# define SSL_MAX_CERT_LIST_DEFAULT 1024*100 - -# define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) - -/* - * This callback type is used inside SSL_CTX, SSL, and in the functions that - * set them. It is used to override the generation of SSL/TLS session IDs in - * a server. Return value should be zero on an error, non-zero to proceed. - * Also, callbacks should themselves check if the id they generate is unique - * otherwise the SSL handshake will fail with an error - callbacks can do - * this using the 'ssl' value they're passed by; - * SSL_has_matching_session_id(ssl, id, *id_len) The length value passed in - * is set at the maximum size the session ID can be. In SSLv3/TLSv1 it is 32 - * bytes. The callback can alter this length to be less if desired. It is - * also an error for the callback to set the size to zero. - */ -typedef int (*GEN_SESSION_CB) (SSL *ssl, unsigned char *id, - unsigned int *id_len); - -# define SSL_SESS_CACHE_OFF 0x0000 -# define SSL_SESS_CACHE_CLIENT 0x0001 -# define SSL_SESS_CACHE_SERVER 0x0002 -# define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER) -# define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 -/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */ -# define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 -# define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 -# define SSL_SESS_CACHE_NO_INTERNAL \ - (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE) - -LHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx); -# define SSL_CTX_sess_number(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL) -# define SSL_CTX_sess_connect(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL) -# define SSL_CTX_sess_connect_good(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL) -# define SSL_CTX_sess_connect_renegotiate(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL) -# define SSL_CTX_sess_accept(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL) -# define SSL_CTX_sess_accept_renegotiate(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL) -# define SSL_CTX_sess_accept_good(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL) -# define SSL_CTX_sess_hits(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL) -# define SSL_CTX_sess_cb_hits(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL) -# define SSL_CTX_sess_misses(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL) -# define SSL_CTX_sess_timeouts(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL) -# define SSL_CTX_sess_cache_full(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL) - -void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, - int (*new_session_cb) (struct ssl_st *ssl, - SSL_SESSION *sess)); -int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)) (struct ssl_st *ssl, - SSL_SESSION *sess); -void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, - void (*remove_session_cb) (struct ssl_ctx_st - *ctx, - SSL_SESSION *sess)); -void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx)) (struct ssl_ctx_st *ctx, - SSL_SESSION *sess); -void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, - SSL_SESSION *(*get_session_cb) (struct ssl_st - *ssl, - const unsigned char - *data, int len, - int *copy)); -SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx)) (struct ssl_st *ssl, - const unsigned char *data, - int len, int *copy); -void SSL_CTX_set_info_callback(SSL_CTX *ctx, - void (*cb) (const SSL *ssl, int type, int val)); -void (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type, - int val); -void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, - int (*client_cert_cb) (SSL *ssl, X509 **x509, - EVP_PKEY **pkey)); -int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx)) (SSL *ssl, X509 **x509, - EVP_PKEY **pkey); -# ifndef OPENSSL_NO_ENGINE -__owur int SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e); -# endif -void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, - int (*app_gen_cookie_cb) (SSL *ssl, - unsigned char - *cookie, - unsigned int - *cookie_len)); -void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, - int (*app_verify_cookie_cb) (SSL *ssl, - const unsigned - char *cookie, - unsigned int - cookie_len)); - -void SSL_CTX_set_stateless_cookie_generate_cb( - SSL_CTX *ctx, - int (*gen_stateless_cookie_cb) (SSL *ssl, - unsigned char *cookie, - size_t *cookie_len)); -void SSL_CTX_set_stateless_cookie_verify_cb( - SSL_CTX *ctx, - int (*verify_stateless_cookie_cb) (SSL *ssl, - const unsigned char *cookie, - size_t cookie_len)); -# ifndef OPENSSL_NO_NEXTPROTONEG - -typedef int (*SSL_CTX_npn_advertised_cb_func)(SSL *ssl, - const unsigned char **out, - unsigned int *outlen, - void *arg); -void SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s, - SSL_CTX_npn_advertised_cb_func cb, - void *arg); -# define SSL_CTX_set_npn_advertised_cb SSL_CTX_set_next_protos_advertised_cb - -typedef int (*SSL_CTX_npn_select_cb_func)(SSL *s, - unsigned char **out, - unsigned char *outlen, - const unsigned char *in, - unsigned int inlen, - void *arg); -void SSL_CTX_set_next_proto_select_cb(SSL_CTX *s, - SSL_CTX_npn_select_cb_func cb, - void *arg); -# define SSL_CTX_set_npn_select_cb SSL_CTX_set_next_proto_select_cb - -void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, - unsigned *len); -# define SSL_get0_npn_negotiated SSL_get0_next_proto_negotiated -# endif - -__owur int SSL_select_next_proto(unsigned char **out, unsigned char *outlen, - const unsigned char *in, unsigned int inlen, - const unsigned char *client, - unsigned int client_len); - -# define OPENSSL_NPN_UNSUPPORTED 0 -# define OPENSSL_NPN_NEGOTIATED 1 -# define OPENSSL_NPN_NO_OVERLAP 2 - -__owur int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, - unsigned int protos_len); -__owur int SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos, - unsigned int protos_len); -typedef int (*SSL_CTX_alpn_select_cb_func)(SSL *ssl, - const unsigned char **out, - unsigned char *outlen, - const unsigned char *in, - unsigned int inlen, - void *arg); -void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx, - SSL_CTX_alpn_select_cb_func cb, - void *arg); -void SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data, - unsigned int *len); - -# ifndef OPENSSL_NO_PSK -/* - * the maximum length of the buffer given to callbacks containing the - * resulting identity/psk - */ -# define PSK_MAX_IDENTITY_LEN 128 -# define PSK_MAX_PSK_LEN 256 -typedef unsigned int (*SSL_psk_client_cb_func)(SSL *ssl, - const char *hint, - char *identity, - unsigned int max_identity_len, - unsigned char *psk, - unsigned int max_psk_len); -void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, SSL_psk_client_cb_func cb); -void SSL_set_psk_client_callback(SSL *ssl, SSL_psk_client_cb_func cb); - -typedef unsigned int (*SSL_psk_server_cb_func)(SSL *ssl, - const char *identity, - unsigned char *psk, - unsigned int max_psk_len); -void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, SSL_psk_server_cb_func cb); -void SSL_set_psk_server_callback(SSL *ssl, SSL_psk_server_cb_func cb); - -__owur int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint); -__owur int SSL_use_psk_identity_hint(SSL *s, const char *identity_hint); -const char *SSL_get_psk_identity_hint(const SSL *s); -const char *SSL_get_psk_identity(const SSL *s); -# endif - -typedef int (*SSL_psk_find_session_cb_func)(SSL *ssl, - const unsigned char *identity, - size_t identity_len, - SSL_SESSION **sess); -typedef int (*SSL_psk_use_session_cb_func)(SSL *ssl, const EVP_MD *md, - const unsigned char **id, - size_t *idlen, - SSL_SESSION **sess); - -void SSL_set_psk_find_session_callback(SSL *s, SSL_psk_find_session_cb_func cb); -void SSL_CTX_set_psk_find_session_callback(SSL_CTX *ctx, - SSL_psk_find_session_cb_func cb); -void SSL_set_psk_use_session_callback(SSL *s, SSL_psk_use_session_cb_func cb); -void SSL_CTX_set_psk_use_session_callback(SSL_CTX *ctx, - SSL_psk_use_session_cb_func cb); - -/* Register callbacks to handle custom TLS Extensions for client or server. */ - -__owur int SSL_CTX_has_client_custom_ext(const SSL_CTX *ctx, - unsigned int ext_type); - -__owur int SSL_CTX_add_client_custom_ext(SSL_CTX *ctx, - unsigned int ext_type, - custom_ext_add_cb add_cb, - custom_ext_free_cb free_cb, - void *add_arg, - custom_ext_parse_cb parse_cb, - void *parse_arg); - -__owur int SSL_CTX_add_server_custom_ext(SSL_CTX *ctx, - unsigned int ext_type, - custom_ext_add_cb add_cb, - custom_ext_free_cb free_cb, - void *add_arg, - custom_ext_parse_cb parse_cb, - void *parse_arg); - -__owur int SSL_CTX_add_custom_ext(SSL_CTX *ctx, unsigned int ext_type, - unsigned int context, - SSL_custom_ext_add_cb_ex add_cb, - SSL_custom_ext_free_cb_ex free_cb, - void *add_arg, - SSL_custom_ext_parse_cb_ex parse_cb, - void *parse_arg); - -__owur int SSL_extension_supported(unsigned int ext_type); - -# define SSL_NOTHING 1 -# define SSL_WRITING 2 -# define SSL_READING 3 -# define SSL_X509_LOOKUP 4 -# define SSL_ASYNC_PAUSED 5 -# define SSL_ASYNC_NO_JOBS 6 -# define SSL_CLIENT_HELLO_CB 7 - -/* These will only be used when doing non-blocking IO */ -# define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING) -# define SSL_want_read(s) (SSL_want(s) == SSL_READING) -# define SSL_want_write(s) (SSL_want(s) == SSL_WRITING) -# define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP) -# define SSL_want_async(s) (SSL_want(s) == SSL_ASYNC_PAUSED) -# define SSL_want_async_job(s) (SSL_want(s) == SSL_ASYNC_NO_JOBS) -# define SSL_want_client_hello_cb(s) (SSL_want(s) == SSL_CLIENT_HELLO_CB) - -# define SSL_MAC_FLAG_READ_MAC_STREAM 1 -# define SSL_MAC_FLAG_WRITE_MAC_STREAM 2 - -/* - * A callback for logging out TLS key material. This callback should log out - * |line| followed by a newline. - */ -typedef void (*SSL_CTX_keylog_cb_func)(const SSL *ssl, const char *line); - -/* - * SSL_CTX_set_keylog_callback configures a callback to log key material. This - * is intended for debugging use with tools like Wireshark. The cb function - * should log line followed by a newline. - */ -void SSL_CTX_set_keylog_callback(SSL_CTX *ctx, SSL_CTX_keylog_cb_func cb); - -/* - * SSL_CTX_get_keylog_callback returns the callback configured by - * SSL_CTX_set_keylog_callback. - */ -SSL_CTX_keylog_cb_func SSL_CTX_get_keylog_callback(const SSL_CTX *ctx); - -int SSL_CTX_set_max_early_data(SSL_CTX *ctx, uint32_t max_early_data); -uint32_t SSL_CTX_get_max_early_data(const SSL_CTX *ctx); -int SSL_set_max_early_data(SSL *s, uint32_t max_early_data); -uint32_t SSL_get_max_early_data(const SSL *s); -int SSL_CTX_set_recv_max_early_data(SSL_CTX *ctx, uint32_t recv_max_early_data); -uint32_t SSL_CTX_get_recv_max_early_data(const SSL_CTX *ctx); -int SSL_set_recv_max_early_data(SSL *s, uint32_t recv_max_early_data); -uint32_t SSL_get_recv_max_early_data(const SSL *s); - -#ifdef __cplusplus -} -#endif - -# include -# include -# include /* This is mostly sslv3 with a few tweaks */ -# include /* Datagram TLS */ -# include /* Support for the use_srtp extension */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * These need to be after the above set of includes due to a compiler bug - * in VisualStudio 2015 - */ -DEFINE_STACK_OF_CONST(SSL_CIPHER) -DEFINE_STACK_OF(SSL_COMP) - -/* compatibility */ -# define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)(arg))) -# define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) -# define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0, \ - (char *)(a))) -# define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s,0)) -# define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0)) -# define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0, \ - (char *)(arg))) -DEPRECATEDIN_1_1_0(void SSL_set_debug(SSL *s, int debug)) - -/* TLSv1.3 KeyUpdate message types */ -/* -1 used so that this is an invalid value for the on-the-wire protocol */ -#define SSL_KEY_UPDATE_NONE -1 -/* Values as defined for the on-the-wire protocol */ -#define SSL_KEY_UPDATE_NOT_REQUESTED 0 -#define SSL_KEY_UPDATE_REQUESTED 1 - -/* - * The valid handshake states (one for each type message sent and one for each - * type of message received). There are also two "special" states: - * TLS = TLS or DTLS state - * DTLS = DTLS specific state - * CR/SR = Client Read/Server Read - * CW/SW = Client Write/Server Write - * - * The "special" states are: - * TLS_ST_BEFORE = No handshake has been initiated yet - * TLS_ST_OK = A handshake has been successfully completed - */ -typedef enum { - TLS_ST_BEFORE, - TLS_ST_OK, - DTLS_ST_CR_HELLO_VERIFY_REQUEST, - TLS_ST_CR_SRVR_HELLO, - TLS_ST_CR_CERT, - TLS_ST_CR_CERT_STATUS, - TLS_ST_CR_KEY_EXCH, - TLS_ST_CR_CERT_REQ, - TLS_ST_CR_SRVR_DONE, - TLS_ST_CR_SESSION_TICKET, - TLS_ST_CR_CHANGE, - TLS_ST_CR_FINISHED, - TLS_ST_CW_CLNT_HELLO, - TLS_ST_CW_CERT, - TLS_ST_CW_KEY_EXCH, - TLS_ST_CW_CERT_VRFY, - TLS_ST_CW_CHANGE, - TLS_ST_CW_NEXT_PROTO, - TLS_ST_CW_FINISHED, - TLS_ST_SW_HELLO_REQ, - TLS_ST_SR_CLNT_HELLO, - DTLS_ST_SW_HELLO_VERIFY_REQUEST, - TLS_ST_SW_SRVR_HELLO, - TLS_ST_SW_CERT, - TLS_ST_SW_KEY_EXCH, - TLS_ST_SW_CERT_REQ, - TLS_ST_SW_SRVR_DONE, - TLS_ST_SR_CERT, - TLS_ST_SR_KEY_EXCH, - TLS_ST_SR_CERT_VRFY, - TLS_ST_SR_NEXT_PROTO, - TLS_ST_SR_CHANGE, - TLS_ST_SR_FINISHED, - TLS_ST_SW_SESSION_TICKET, - TLS_ST_SW_CERT_STATUS, - TLS_ST_SW_CHANGE, - TLS_ST_SW_FINISHED, - TLS_ST_SW_ENCRYPTED_EXTENSIONS, - TLS_ST_CR_ENCRYPTED_EXTENSIONS, - TLS_ST_CR_CERT_VRFY, - TLS_ST_SW_CERT_VRFY, - TLS_ST_CR_HELLO_REQ, - TLS_ST_SW_KEY_UPDATE, - TLS_ST_CW_KEY_UPDATE, - TLS_ST_SR_KEY_UPDATE, - TLS_ST_CR_KEY_UPDATE, - TLS_ST_EARLY_DATA, - TLS_ST_PENDING_EARLY_DATA_END, - TLS_ST_CW_END_OF_EARLY_DATA, - TLS_ST_SR_END_OF_EARLY_DATA -} OSSL_HANDSHAKE_STATE; - -/* - * Most of the following state values are no longer used and are defined to be - * the closest equivalent value in the current state machine code. Not all - * defines have an equivalent and are set to a dummy value (-1). SSL_ST_CONNECT - * and SSL_ST_ACCEPT are still in use in the definition of SSL_CB_ACCEPT_LOOP, - * SSL_CB_ACCEPT_EXIT, SSL_CB_CONNECT_LOOP and SSL_CB_CONNECT_EXIT. - */ - -# define SSL_ST_CONNECT 0x1000 -# define SSL_ST_ACCEPT 0x2000 - -# define SSL_ST_MASK 0x0FFF - -# define SSL_CB_LOOP 0x01 -# define SSL_CB_EXIT 0x02 -# define SSL_CB_READ 0x04 -# define SSL_CB_WRITE 0x08 -# define SSL_CB_ALERT 0x4000/* used in callback */ -# define SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ) -# define SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE) -# define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP) -# define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT) -# define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP) -# define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT) -# define SSL_CB_HANDSHAKE_START 0x10 -# define SSL_CB_HANDSHAKE_DONE 0x20 - -/* Is the SSL_connection established? */ -# define SSL_in_connect_init(a) (SSL_in_init(a) && !SSL_is_server(a)) -# define SSL_in_accept_init(a) (SSL_in_init(a) && SSL_is_server(a)) -int SSL_in_init(const SSL *s); -int SSL_in_before(const SSL *s); -int SSL_is_init_finished(const SSL *s); - -/* - * The following 3 states are kept in ssl->rlayer.rstate when reads fail, you - * should not need these - */ -# define SSL_ST_READ_HEADER 0xF0 -# define SSL_ST_READ_BODY 0xF1 -# define SSL_ST_READ_DONE 0xF2 - -/*- - * Obtain latest Finished message - * -- that we sent (SSL_get_finished) - * -- that we expected from peer (SSL_get_peer_finished). - * Returns length (0 == no Finished so far), copies up to 'count' bytes. - */ -size_t SSL_get_finished(const SSL *s, void *buf, size_t count); -size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count); - -/* - * use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 3 options are - * 'ored' with SSL_VERIFY_PEER if they are desired - */ -# define SSL_VERIFY_NONE 0x00 -# define SSL_VERIFY_PEER 0x01 -# define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 -# define SSL_VERIFY_CLIENT_ONCE 0x04 -# define SSL_VERIFY_POST_HANDSHAKE 0x08 - -# if OPENSSL_API_COMPAT < 0x10100000L -# define OpenSSL_add_ssl_algorithms() SSL_library_init() -# define SSLeay_add_ssl_algorithms() SSL_library_init() -# endif - -/* More backward compatibility */ -# define SSL_get_cipher(s) \ - SSL_CIPHER_get_name(SSL_get_current_cipher(s)) -# define SSL_get_cipher_bits(s,np) \ - SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np) -# define SSL_get_cipher_version(s) \ - SSL_CIPHER_get_version(SSL_get_current_cipher(s)) -# define SSL_get_cipher_name(s) \ - SSL_CIPHER_get_name(SSL_get_current_cipher(s)) -# define SSL_get_time(a) SSL_SESSION_get_time(a) -# define SSL_set_time(a,b) SSL_SESSION_set_time((a),(b)) -# define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) -# define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b)) - -# define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id) -# define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id) - -DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) -# define SSL_AD_REASON_OFFSET 1000/* offset to get SSL_R_... value - * from SSL_AD_... */ -/* These alert types are for SSLv3 and TLSv1 */ -# define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY -/* fatal */ -# define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE -/* fatal */ -# define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC -# define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED -# define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW -/* fatal */ -# define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE -/* fatal */ -# define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE -/* Not for TLS */ -# define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE -# define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE -# define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE -# define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED -# define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED -# define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN -/* fatal */ -# define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER -/* fatal */ -# define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA -/* fatal */ -# define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED -/* fatal */ -# define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR -# define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR -/* fatal */ -# define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION -/* fatal */ -# define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION -/* fatal */ -# define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY -/* fatal */ -# define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR -# define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED -# define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION -# define SSL_AD_MISSING_EXTENSION TLS13_AD_MISSING_EXTENSION -# define SSL_AD_CERTIFICATE_REQUIRED TLS13_AD_CERTIFICATE_REQUIRED -# define SSL_AD_UNSUPPORTED_EXTENSION TLS1_AD_UNSUPPORTED_EXTENSION -# define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE -# define SSL_AD_UNRECOGNIZED_NAME TLS1_AD_UNRECOGNIZED_NAME -# define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE -# define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE -/* fatal */ -# define SSL_AD_UNKNOWN_PSK_IDENTITY TLS1_AD_UNKNOWN_PSK_IDENTITY -/* fatal */ -# define SSL_AD_INAPPROPRIATE_FALLBACK TLS1_AD_INAPPROPRIATE_FALLBACK -# define SSL_AD_NO_APPLICATION_PROTOCOL TLS1_AD_NO_APPLICATION_PROTOCOL -# define SSL_ERROR_NONE 0 -# define SSL_ERROR_SSL 1 -# define SSL_ERROR_WANT_READ 2 -# define SSL_ERROR_WANT_WRITE 3 -# define SSL_ERROR_WANT_X509_LOOKUP 4 -# define SSL_ERROR_SYSCALL 5/* look at error stack/return - * value/errno */ -# define SSL_ERROR_ZERO_RETURN 6 -# define SSL_ERROR_WANT_CONNECT 7 -# define SSL_ERROR_WANT_ACCEPT 8 -# define SSL_ERROR_WANT_ASYNC 9 -# define SSL_ERROR_WANT_ASYNC_JOB 10 -# define SSL_ERROR_WANT_CLIENT_HELLO_CB 11 -# define SSL_CTRL_SET_TMP_DH 3 -# define SSL_CTRL_SET_TMP_ECDH 4 -# define SSL_CTRL_SET_TMP_DH_CB 6 -# define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9 -# define SSL_CTRL_GET_NUM_RENEGOTIATIONS 10 -# define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11 -# define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12 -# define SSL_CTRL_GET_FLAGS 13 -# define SSL_CTRL_EXTRA_CHAIN_CERT 14 -# define SSL_CTRL_SET_MSG_CALLBACK 15 -# define SSL_CTRL_SET_MSG_CALLBACK_ARG 16 -/* only applies to datagram connections */ -# define SSL_CTRL_SET_MTU 17 -/* Stats */ -# define SSL_CTRL_SESS_NUMBER 20 -# define SSL_CTRL_SESS_CONNECT 21 -# define SSL_CTRL_SESS_CONNECT_GOOD 22 -# define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23 -# define SSL_CTRL_SESS_ACCEPT 24 -# define SSL_CTRL_SESS_ACCEPT_GOOD 25 -# define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26 -# define SSL_CTRL_SESS_HIT 27 -# define SSL_CTRL_SESS_CB_HIT 28 -# define SSL_CTRL_SESS_MISSES 29 -# define SSL_CTRL_SESS_TIMEOUTS 30 -# define SSL_CTRL_SESS_CACHE_FULL 31 -# define SSL_CTRL_MODE 33 -# define SSL_CTRL_GET_READ_AHEAD 40 -# define SSL_CTRL_SET_READ_AHEAD 41 -# define SSL_CTRL_SET_SESS_CACHE_SIZE 42 -# define SSL_CTRL_GET_SESS_CACHE_SIZE 43 -# define SSL_CTRL_SET_SESS_CACHE_MODE 44 -# define SSL_CTRL_GET_SESS_CACHE_MODE 45 -# define SSL_CTRL_GET_MAX_CERT_LIST 50 -# define SSL_CTRL_SET_MAX_CERT_LIST 51 -# define SSL_CTRL_SET_MAX_SEND_FRAGMENT 52 -/* see tls1.h for macros based on these */ -# define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB 53 -# define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG 54 -# define SSL_CTRL_SET_TLSEXT_HOSTNAME 55 -# define SSL_CTRL_SET_TLSEXT_DEBUG_CB 56 -# define SSL_CTRL_SET_TLSEXT_DEBUG_ARG 57 -# define SSL_CTRL_GET_TLSEXT_TICKET_KEYS 58 -# define SSL_CTRL_SET_TLSEXT_TICKET_KEYS 59 -/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT 60 */ -/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB 61 */ -/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG 62 */ -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB 63 -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG 64 -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE 65 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS 66 -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS 67 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS 68 -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS 69 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP 70 -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP 71 -# define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB 72 -# define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB 75 -# define SSL_CTRL_SET_SRP_VERIFY_PARAM_CB 76 -# define SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB 77 -# define SSL_CTRL_SET_SRP_ARG 78 -# define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME 79 -# define SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH 80 -# define SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD 81 -# ifndef OPENSSL_NO_HEARTBEATS -# define SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT 85 -# define SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING 86 -# define SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS 87 -# endif -# define DTLS_CTRL_GET_TIMEOUT 73 -# define DTLS_CTRL_HANDLE_TIMEOUT 74 -# define SSL_CTRL_GET_RI_SUPPORT 76 -# define SSL_CTRL_CLEAR_MODE 78 -# define SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB 79 -# define SSL_CTRL_GET_EXTRA_CHAIN_CERTS 82 -# define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS 83 -# define SSL_CTRL_CHAIN 88 -# define SSL_CTRL_CHAIN_CERT 89 -# define SSL_CTRL_GET_GROUPS 90 -# define SSL_CTRL_SET_GROUPS 91 -# define SSL_CTRL_SET_GROUPS_LIST 92 -# define SSL_CTRL_GET_SHARED_GROUP 93 -# define SSL_CTRL_SET_SIGALGS 97 -# define SSL_CTRL_SET_SIGALGS_LIST 98 -# define SSL_CTRL_CERT_FLAGS 99 -# define SSL_CTRL_CLEAR_CERT_FLAGS 100 -# define SSL_CTRL_SET_CLIENT_SIGALGS 101 -# define SSL_CTRL_SET_CLIENT_SIGALGS_LIST 102 -# define SSL_CTRL_GET_CLIENT_CERT_TYPES 103 -# define SSL_CTRL_SET_CLIENT_CERT_TYPES 104 -# define SSL_CTRL_BUILD_CERT_CHAIN 105 -# define SSL_CTRL_SET_VERIFY_CERT_STORE 106 -# define SSL_CTRL_SET_CHAIN_CERT_STORE 107 -# define SSL_CTRL_GET_PEER_SIGNATURE_NID 108 -# define SSL_CTRL_GET_PEER_TMP_KEY 109 -# define SSL_CTRL_GET_RAW_CIPHERLIST 110 -# define SSL_CTRL_GET_EC_POINT_FORMATS 111 -# define SSL_CTRL_GET_CHAIN_CERTS 115 -# define SSL_CTRL_SELECT_CURRENT_CERT 116 -# define SSL_CTRL_SET_CURRENT_CERT 117 -# define SSL_CTRL_SET_DH_AUTO 118 -# define DTLS_CTRL_SET_LINK_MTU 120 -# define DTLS_CTRL_GET_LINK_MIN_MTU 121 -# define SSL_CTRL_GET_EXTMS_SUPPORT 122 -# define SSL_CTRL_SET_MIN_PROTO_VERSION 123 -# define SSL_CTRL_SET_MAX_PROTO_VERSION 124 -# define SSL_CTRL_SET_SPLIT_SEND_FRAGMENT 125 -# define SSL_CTRL_SET_MAX_PIPELINES 126 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE 127 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB 128 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG 129 -# define SSL_CTRL_GET_MIN_PROTO_VERSION 130 -# define SSL_CTRL_GET_MAX_PROTO_VERSION 131 -# define SSL_CTRL_GET_SIGNATURE_NID 132 -# define SSL_CTRL_GET_TMP_KEY 133 -# define SSL_CERT_SET_FIRST 1 -# define SSL_CERT_SET_NEXT 2 -# define SSL_CERT_SET_SERVER 3 -# define DTLSv1_get_timeout(ssl, arg) \ - SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)(arg)) -# define DTLSv1_handle_timeout(ssl) \ - SSL_ctrl(ssl,DTLS_CTRL_HANDLE_TIMEOUT,0, NULL) -# define SSL_num_renegotiations(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL) -# define SSL_clear_num_renegotiations(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL) -# define SSL_total_renegotiations(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL) -# define SSL_CTX_set_tmp_dh(ctx,dh) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)(dh)) -# define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)(ecdh)) -# define SSL_CTX_set_dh_auto(ctx, onoff) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_DH_AUTO,onoff,NULL) -# define SSL_set_dh_auto(s, onoff) \ - SSL_ctrl(s,SSL_CTRL_SET_DH_AUTO,onoff,NULL) -# define SSL_set_tmp_dh(ssl,dh) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)(dh)) -# define SSL_set_tmp_ecdh(ssl,ecdh) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)(ecdh)) -# define SSL_CTX_add_extra_chain_cert(ctx,x509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)(x509)) -# define SSL_CTX_get_extra_chain_certs(ctx,px509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,0,px509) -# define SSL_CTX_get_extra_chain_certs_only(ctx,px509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,1,px509) -# define SSL_CTX_clear_extra_chain_certs(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS,0,NULL) -# define SSL_CTX_set0_chain(ctx,sk) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)(sk)) -# define SSL_CTX_set1_chain(ctx,sk) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)(sk)) -# define SSL_CTX_add0_chain_cert(ctx,x509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)(x509)) -# define SSL_CTX_add1_chain_cert(ctx,x509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)(x509)) -# define SSL_CTX_get0_chain_certs(ctx,px509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509) -# define SSL_CTX_clear_chain_certs(ctx) \ - SSL_CTX_set0_chain(ctx,NULL) -# define SSL_CTX_build_cert_chain(ctx, flags) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) -# define SSL_CTX_select_current_cert(ctx,x509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509)) -# define SSL_CTX_set_current_cert(ctx, op) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL) -# define SSL_CTX_set0_verify_cert_store(ctx,st) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)(st)) -# define SSL_CTX_set1_verify_cert_store(ctx,st) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)(st)) -# define SSL_CTX_set0_chain_cert_store(ctx,st) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st)) -# define SSL_CTX_set1_chain_cert_store(ctx,st) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st)) -# define SSL_set0_chain(s,sk) \ - SSL_ctrl(s,SSL_CTRL_CHAIN,0,(char *)(sk)) -# define SSL_set1_chain(s,sk) \ - SSL_ctrl(s,SSL_CTRL_CHAIN,1,(char *)(sk)) -# define SSL_add0_chain_cert(s,x509) \ - SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,0,(char *)(x509)) -# define SSL_add1_chain_cert(s,x509) \ - SSL_ctrl(s,SSL_CTRL_CHAIN_CERT,1,(char *)(x509)) -# define SSL_get0_chain_certs(s,px509) \ - SSL_ctrl(s,SSL_CTRL_GET_CHAIN_CERTS,0,px509) -# define SSL_clear_chain_certs(s) \ - SSL_set0_chain(s,NULL) -# define SSL_build_cert_chain(s, flags) \ - SSL_ctrl(s,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) -# define SSL_select_current_cert(s,x509) \ - SSL_ctrl(s,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)(x509)) -# define SSL_set_current_cert(s,op) \ - SSL_ctrl(s,SSL_CTRL_SET_CURRENT_CERT, op, NULL) -# define SSL_set0_verify_cert_store(s,st) \ - SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)(st)) -# define SSL_set1_verify_cert_store(s,st) \ - SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)(st)) -# define SSL_set0_chain_cert_store(s,st) \ - SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)(st)) -# define SSL_set1_chain_cert_store(s,st) \ - SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)(st)) -# define SSL_get1_groups(s, glist) \ - SSL_ctrl(s,SSL_CTRL_GET_GROUPS,0,(int*)(glist)) -# define SSL_CTX_set1_groups(ctx, glist, glistlen) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS,glistlen,(int *)(glist)) -# define SSL_CTX_set1_groups_list(ctx, s) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(s)) -# define SSL_set1_groups(s, glist, glistlen) \ - SSL_ctrl(s,SSL_CTRL_SET_GROUPS,glistlen,(char *)(glist)) -# define SSL_set1_groups_list(s, str) \ - SSL_ctrl(s,SSL_CTRL_SET_GROUPS_LIST,0,(char *)(str)) -# define SSL_get_shared_group(s, n) \ - SSL_ctrl(s,SSL_CTRL_GET_SHARED_GROUP,n,NULL) -# define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist)) -# define SSL_CTX_set1_sigalgs_list(ctx, s) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(s)) -# define SSL_set1_sigalgs(s, slist, slistlen) \ - SSL_ctrl(s,SSL_CTRL_SET_SIGALGS,slistlen,(int *)(slist)) -# define SSL_set1_sigalgs_list(s, str) \ - SSL_ctrl(s,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)(str)) -# define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist)) -# define SSL_CTX_set1_client_sigalgs_list(ctx, s) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(s)) -# define SSL_set1_client_sigalgs(s, slist, slistlen) \ - SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)(slist)) -# define SSL_set1_client_sigalgs_list(s, str) \ - SSL_ctrl(s,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)(str)) -# define SSL_get0_certificate_types(s, clist) \ - SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)(clist)) -# define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen, \ - (char *)(clist)) -# define SSL_set1_client_certificate_types(s, clist, clistlen) \ - SSL_ctrl(s,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)(clist)) -# define SSL_get_signature_nid(s, pn) \ - SSL_ctrl(s,SSL_CTRL_GET_SIGNATURE_NID,0,pn) -# define SSL_get_peer_signature_nid(s, pn) \ - SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NID,0,pn) -# define SSL_get_peer_tmp_key(s, pk) \ - SSL_ctrl(s,SSL_CTRL_GET_PEER_TMP_KEY,0,pk) -# define SSL_get_tmp_key(s, pk) \ - SSL_ctrl(s,SSL_CTRL_GET_TMP_KEY,0,pk) -# define SSL_get0_raw_cipherlist(s, plst) \ - SSL_ctrl(s,SSL_CTRL_GET_RAW_CIPHERLIST,0,plst) -# define SSL_get0_ec_point_formats(s, plst) \ - SSL_ctrl(s,SSL_CTRL_GET_EC_POINT_FORMATS,0,plst) -# define SSL_CTX_set_min_proto_version(ctx, version) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL) -# define SSL_CTX_set_max_proto_version(ctx, version) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL) -# define SSL_CTX_get_min_proto_version(ctx) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL) -# define SSL_CTX_get_max_proto_version(ctx) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL) -# define SSL_set_min_proto_version(s, version) \ - SSL_ctrl(s, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL) -# define SSL_set_max_proto_version(s, version) \ - SSL_ctrl(s, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL) -# define SSL_get_min_proto_version(s) \ - SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, NULL) -# define SSL_get_max_proto_version(s) \ - SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, NULL) - -/* Backwards compatibility, original 1.1.0 names */ -# define SSL_CTRL_GET_SERVER_TMP_KEY \ - SSL_CTRL_GET_PEER_TMP_KEY -# define SSL_get_server_tmp_key(s, pk) \ - SSL_get_peer_tmp_key(s, pk) - -/* - * The following symbol names are old and obsolete. They are kept - * for compatibility reasons only and should not be used anymore. - */ -# define SSL_CTRL_GET_CURVES SSL_CTRL_GET_GROUPS -# define SSL_CTRL_SET_CURVES SSL_CTRL_SET_GROUPS -# define SSL_CTRL_SET_CURVES_LIST SSL_CTRL_SET_GROUPS_LIST -# define SSL_CTRL_GET_SHARED_CURVE SSL_CTRL_GET_SHARED_GROUP - -# define SSL_get1_curves SSL_get1_groups -# define SSL_CTX_set1_curves SSL_CTX_set1_groups -# define SSL_CTX_set1_curves_list SSL_CTX_set1_groups_list -# define SSL_set1_curves SSL_set1_groups -# define SSL_set1_curves_list SSL_set1_groups_list -# define SSL_get_shared_curve SSL_get_shared_group - - -# if OPENSSL_API_COMPAT < 0x10100000L -/* Provide some compatibility macros for removed functionality. */ -# define SSL_CTX_need_tmp_RSA(ctx) 0 -# define SSL_CTX_set_tmp_rsa(ctx,rsa) 1 -# define SSL_need_tmp_RSA(ssl) 0 -# define SSL_set_tmp_rsa(ssl,rsa) 1 -# define SSL_CTX_set_ecdh_auto(dummy, onoff) ((onoff) != 0) -# define SSL_set_ecdh_auto(dummy, onoff) ((onoff) != 0) -/* - * We "pretend" to call the callback to avoid warnings about unused static - * functions. - */ -# define SSL_CTX_set_tmp_rsa_callback(ctx, cb) while(0) (cb)(NULL, 0, 0) -# define SSL_set_tmp_rsa_callback(ssl, cb) while(0) (cb)(NULL, 0, 0) -# endif -__owur const BIO_METHOD *BIO_f_ssl(void); -__owur BIO *BIO_new_ssl(SSL_CTX *ctx, int client); -__owur BIO *BIO_new_ssl_connect(SSL_CTX *ctx); -__owur BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx); -__owur int BIO_ssl_copy_session_id(BIO *to, BIO *from); -void BIO_ssl_shutdown(BIO *ssl_bio); - -__owur int SSL_CTX_set_cipher_list(SSL_CTX *, const char *str); -__owur SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth); -int SSL_CTX_up_ref(SSL_CTX *ctx); -void SSL_CTX_free(SSL_CTX *); -__owur long SSL_CTX_set_timeout(SSL_CTX *ctx, long t); -__owur long SSL_CTX_get_timeout(const SSL_CTX *ctx); -__owur X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); -void SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *); -void SSL_CTX_set1_cert_store(SSL_CTX *, X509_STORE *); -__owur int SSL_want(const SSL *s); -__owur int SSL_clear(SSL *s); - -void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm); - -__owur const SSL_CIPHER *SSL_get_current_cipher(const SSL *s); -__owur const SSL_CIPHER *SSL_get_pending_cipher(const SSL *s); -__owur int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits); -__owur const char *SSL_CIPHER_get_version(const SSL_CIPHER *c); -__owur const char *SSL_CIPHER_get_name(const SSL_CIPHER *c); -__owur const char *SSL_CIPHER_standard_name(const SSL_CIPHER *c); -__owur const char *OPENSSL_cipher_name(const char *rfc_name); -__owur uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *c); -__owur uint16_t SSL_CIPHER_get_protocol_id(const SSL_CIPHER *c); -__owur int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c); -__owur int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c); -__owur const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c); -__owur int SSL_CIPHER_is_aead(const SSL_CIPHER *c); - -__owur int SSL_get_fd(const SSL *s); -__owur int SSL_get_rfd(const SSL *s); -__owur int SSL_get_wfd(const SSL *s); -__owur const char *SSL_get_cipher_list(const SSL *s, int n); -__owur char *SSL_get_shared_ciphers(const SSL *s, char *buf, int size); -__owur int SSL_get_read_ahead(const SSL *s); -__owur int SSL_pending(const SSL *s); -__owur int SSL_has_pending(const SSL *s); -# ifndef OPENSSL_NO_SOCK -__owur int SSL_set_fd(SSL *s, int fd); -__owur int SSL_set_rfd(SSL *s, int fd); -__owur int SSL_set_wfd(SSL *s, int fd); -# endif -void SSL_set0_rbio(SSL *s, BIO *rbio); -void SSL_set0_wbio(SSL *s, BIO *wbio); -void SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio); -__owur BIO *SSL_get_rbio(const SSL *s); -__owur BIO *SSL_get_wbio(const SSL *s); -__owur int SSL_set_cipher_list(SSL *s, const char *str); -__owur int SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str); -__owur int SSL_set_ciphersuites(SSL *s, const char *str); -void SSL_set_read_ahead(SSL *s, int yes); -__owur int SSL_get_verify_mode(const SSL *s); -__owur int SSL_get_verify_depth(const SSL *s); -__owur SSL_verify_cb SSL_get_verify_callback(const SSL *s); -void SSL_set_verify(SSL *s, int mode, SSL_verify_cb callback); -void SSL_set_verify_depth(SSL *s, int depth); -void SSL_set_cert_cb(SSL *s, int (*cb) (SSL *ssl, void *arg), void *arg); -# ifndef OPENSSL_NO_RSA -__owur int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); -__owur int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const unsigned char *d, - long len); -# endif -__owur int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); -__owur int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d, - long len); -__owur int SSL_use_certificate(SSL *ssl, X509 *x); -__owur int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len); -__owur int SSL_use_cert_and_key(SSL *ssl, X509 *x509, EVP_PKEY *privatekey, - STACK_OF(X509) *chain, int override); - - -/* serverinfo file format versions */ -# define SSL_SERVERINFOV1 1 -# define SSL_SERVERINFOV2 2 - -/* Set serverinfo data for the current active cert. */ -__owur int SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo, - size_t serverinfo_length); -__owur int SSL_CTX_use_serverinfo_ex(SSL_CTX *ctx, unsigned int version, - const unsigned char *serverinfo, - size_t serverinfo_length); -__owur int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file); - -#ifndef OPENSSL_NO_RSA -__owur int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); -#endif - -__owur int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); -__owur int SSL_use_certificate_file(SSL *ssl, const char *file, int type); - -#ifndef OPENSSL_NO_RSA -__owur int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, - int type); -#endif -__owur int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, - int type); -__owur int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, - int type); -/* PEM type */ -__owur int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); -__owur int SSL_use_certificate_chain_file(SSL *ssl, const char *file); -__owur STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); -__owur int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, - const char *file); -int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, - const char *dir); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define SSL_load_error_strings() \ - OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \ - | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) -# endif - -__owur const char *SSL_state_string(const SSL *s); -__owur const char *SSL_rstate_string(const SSL *s); -__owur const char *SSL_state_string_long(const SSL *s); -__owur const char *SSL_rstate_string_long(const SSL *s); -__owur long SSL_SESSION_get_time(const SSL_SESSION *s); -__owur long SSL_SESSION_set_time(SSL_SESSION *s, long t); -__owur long SSL_SESSION_get_timeout(const SSL_SESSION *s); -__owur long SSL_SESSION_set_timeout(SSL_SESSION *s, long t); -__owur int SSL_SESSION_get_protocol_version(const SSL_SESSION *s); -__owur int SSL_SESSION_set_protocol_version(SSL_SESSION *s, int version); - -__owur const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s); -__owur int SSL_SESSION_set1_hostname(SSL_SESSION *s, const char *hostname); -void SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s, - const unsigned char **alpn, - size_t *len); -__owur int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s, - const unsigned char *alpn, - size_t len); -__owur const SSL_CIPHER *SSL_SESSION_get0_cipher(const SSL_SESSION *s); -__owur int SSL_SESSION_set_cipher(SSL_SESSION *s, const SSL_CIPHER *cipher); -__owur int SSL_SESSION_has_ticket(const SSL_SESSION *s); -__owur unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *s); -void SSL_SESSION_get0_ticket(const SSL_SESSION *s, const unsigned char **tick, - size_t *len); -__owur uint32_t SSL_SESSION_get_max_early_data(const SSL_SESSION *s); -__owur int SSL_SESSION_set_max_early_data(SSL_SESSION *s, - uint32_t max_early_data); -__owur int SSL_copy_session_id(SSL *to, const SSL *from); -__owur X509 *SSL_SESSION_get0_peer(SSL_SESSION *s); -__owur int SSL_SESSION_set1_id_context(SSL_SESSION *s, - const unsigned char *sid_ctx, - unsigned int sid_ctx_len); -__owur int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid, - unsigned int sid_len); -__owur int SSL_SESSION_is_resumable(const SSL_SESSION *s); - -__owur SSL_SESSION *SSL_SESSION_new(void); -__owur SSL_SESSION *SSL_SESSION_dup(SSL_SESSION *src); -const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, - unsigned int *len); -const unsigned char *SSL_SESSION_get0_id_context(const SSL_SESSION *s, - unsigned int *len); -__owur unsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s); -# ifndef OPENSSL_NO_STDIO -int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses); -# endif -int SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses); -int SSL_SESSION_print_keylog(BIO *bp, const SSL_SESSION *x); -int SSL_SESSION_up_ref(SSL_SESSION *ses); -void SSL_SESSION_free(SSL_SESSION *ses); -__owur int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp); -__owur int SSL_set_session(SSL *to, SSL_SESSION *session); -int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *session); -int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *session); -__owur int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb); -__owur int SSL_set_generate_session_id(SSL *s, GEN_SESSION_CB cb); -__owur int SSL_has_matching_session_id(const SSL *s, - const unsigned char *id, - unsigned int id_len); -SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, - long length); - -# ifdef HEADER_X509_H -__owur X509 *SSL_get_peer_certificate(const SSL *s); -# endif - -__owur STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s); - -__owur int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); -__owur int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); -__owur SSL_verify_cb SSL_CTX_get_verify_callback(const SSL_CTX *ctx); -void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, SSL_verify_cb callback); -void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth); -void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, - int (*cb) (X509_STORE_CTX *, void *), - void *arg); -void SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cb) (SSL *ssl, void *arg), - void *arg); -# ifndef OPENSSL_NO_RSA -__owur int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); -__owur int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, - long len); -# endif -__owur int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); -__owur int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, - const unsigned char *d, long len); -__owur int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); -__owur int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, - const unsigned char *d); -__owur int SSL_CTX_use_cert_and_key(SSL_CTX *ctx, X509 *x509, EVP_PKEY *privatekey, - STACK_OF(X509) *chain, int override); - -void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); -void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u); -pem_password_cb *SSL_CTX_get_default_passwd_cb(SSL_CTX *ctx); -void *SSL_CTX_get_default_passwd_cb_userdata(SSL_CTX *ctx); -void SSL_set_default_passwd_cb(SSL *s, pem_password_cb *cb); -void SSL_set_default_passwd_cb_userdata(SSL *s, void *u); -pem_password_cb *SSL_get_default_passwd_cb(SSL *s); -void *SSL_get_default_passwd_cb_userdata(SSL *s); - -__owur int SSL_CTX_check_private_key(const SSL_CTX *ctx); -__owur int SSL_check_private_key(const SSL *ctx); - -__owur int SSL_CTX_set_session_id_context(SSL_CTX *ctx, - const unsigned char *sid_ctx, - unsigned int sid_ctx_len); - -SSL *SSL_new(SSL_CTX *ctx); -int SSL_up_ref(SSL *s); -int SSL_is_dtls(const SSL *s); -__owur int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx, - unsigned int sid_ctx_len); - -__owur int SSL_CTX_set_purpose(SSL_CTX *ctx, int purpose); -__owur int SSL_set_purpose(SSL *ssl, int purpose); -__owur int SSL_CTX_set_trust(SSL_CTX *ctx, int trust); -__owur int SSL_set_trust(SSL *ssl, int trust); - -__owur int SSL_set1_host(SSL *s, const char *hostname); -__owur int SSL_add1_host(SSL *s, const char *hostname); -__owur const char *SSL_get0_peername(SSL *s); -void SSL_set_hostflags(SSL *s, unsigned int flags); - -__owur int SSL_CTX_dane_enable(SSL_CTX *ctx); -__owur int SSL_CTX_dane_mtype_set(SSL_CTX *ctx, const EVP_MD *md, - uint8_t mtype, uint8_t ord); -__owur int SSL_dane_enable(SSL *s, const char *basedomain); -__owur int SSL_dane_tlsa_add(SSL *s, uint8_t usage, uint8_t selector, - uint8_t mtype, unsigned const char *data, size_t dlen); -__owur int SSL_get0_dane_authority(SSL *s, X509 **mcert, EVP_PKEY **mspki); -__owur int SSL_get0_dane_tlsa(SSL *s, uint8_t *usage, uint8_t *selector, - uint8_t *mtype, unsigned const char **data, - size_t *dlen); -/* - * Bridge opacity barrier between libcrypt and libssl, also needed to support - * offline testing in test/danetest.c - */ -SSL_DANE *SSL_get0_dane(SSL *ssl); -/* - * DANE flags - */ -unsigned long SSL_CTX_dane_set_flags(SSL_CTX *ctx, unsigned long flags); -unsigned long SSL_CTX_dane_clear_flags(SSL_CTX *ctx, unsigned long flags); -unsigned long SSL_dane_set_flags(SSL *ssl, unsigned long flags); -unsigned long SSL_dane_clear_flags(SSL *ssl, unsigned long flags); - -__owur int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm); -__owur int SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm); - -__owur X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx); -__owur X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl); - -# ifndef OPENSSL_NO_SRP -int SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name); -int SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password); -int SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength); -int SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx, - char *(*cb) (SSL *, void *)); -int SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx, - int (*cb) (SSL *, void *)); -int SSL_CTX_set_srp_username_callback(SSL_CTX *ctx, - int (*cb) (SSL *, int *, void *)); -int SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg); - -int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g, - BIGNUM *sa, BIGNUM *v, char *info); -int SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass, - const char *grp); - -__owur BIGNUM *SSL_get_srp_g(SSL *s); -__owur BIGNUM *SSL_get_srp_N(SSL *s); - -__owur char *SSL_get_srp_username(SSL *s); -__owur char *SSL_get_srp_userinfo(SSL *s); -# endif - -/* - * ClientHello callback and helpers. - */ - -# define SSL_CLIENT_HELLO_SUCCESS 1 -# define SSL_CLIENT_HELLO_ERROR 0 -# define SSL_CLIENT_HELLO_RETRY (-1) - -typedef int (*SSL_client_hello_cb_fn) (SSL *s, int *al, void *arg); -void SSL_CTX_set_client_hello_cb(SSL_CTX *c, SSL_client_hello_cb_fn cb, - void *arg); -int SSL_client_hello_isv2(SSL *s); -unsigned int SSL_client_hello_get0_legacy_version(SSL *s); -size_t SSL_client_hello_get0_random(SSL *s, const unsigned char **out); -size_t SSL_client_hello_get0_session_id(SSL *s, const unsigned char **out); -size_t SSL_client_hello_get0_ciphers(SSL *s, const unsigned char **out); -size_t SSL_client_hello_get0_compression_methods(SSL *s, - const unsigned char **out); -int SSL_client_hello_get1_extensions_present(SSL *s, int **out, size_t *outlen); -int SSL_client_hello_get0_ext(SSL *s, unsigned int type, - const unsigned char **out, size_t *outlen); - -void SSL_certs_clear(SSL *s); -void SSL_free(SSL *ssl); -# ifdef OSSL_ASYNC_FD -/* - * Windows application developer has to include windows.h to use these. - */ -__owur int SSL_waiting_for_async(SSL *s); -__owur int SSL_get_all_async_fds(SSL *s, OSSL_ASYNC_FD *fds, size_t *numfds); -__owur int SSL_get_changed_async_fds(SSL *s, OSSL_ASYNC_FD *addfd, - size_t *numaddfds, OSSL_ASYNC_FD *delfd, - size_t *numdelfds); -# endif -__owur int SSL_accept(SSL *ssl); -__owur int SSL_stateless(SSL *s); -__owur int SSL_connect(SSL *ssl); -__owur int SSL_read(SSL *ssl, void *buf, int num); -__owur int SSL_read_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes); - -# define SSL_READ_EARLY_DATA_ERROR 0 -# define SSL_READ_EARLY_DATA_SUCCESS 1 -# define SSL_READ_EARLY_DATA_FINISH 2 - -__owur int SSL_read_early_data(SSL *s, void *buf, size_t num, - size_t *readbytes); -__owur int SSL_peek(SSL *ssl, void *buf, int num); -__owur int SSL_peek_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes); -__owur int SSL_write(SSL *ssl, const void *buf, int num); -__owur int SSL_write_ex(SSL *s, const void *buf, size_t num, size_t *written); -__owur int SSL_write_early_data(SSL *s, const void *buf, size_t num, - size_t *written); -long SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg); -long SSL_callback_ctrl(SSL *, int, void (*)(void)); -long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg); -long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void)); - -# define SSL_EARLY_DATA_NOT_SENT 0 -# define SSL_EARLY_DATA_REJECTED 1 -# define SSL_EARLY_DATA_ACCEPTED 2 - -__owur int SSL_get_early_data_status(const SSL *s); - -__owur int SSL_get_error(const SSL *s, int ret_code); -__owur const char *SSL_get_version(const SSL *s); - -/* This sets the 'default' SSL version that SSL_new() will create */ -__owur int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth); - -# ifndef OPENSSL_NO_SSL3_METHOD -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_method(void)) /* SSLv3 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_server_method(void)) -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_client_method(void)) -# endif - -#define SSLv23_method TLS_method -#define SSLv23_server_method TLS_server_method -#define SSLv23_client_method TLS_client_method - -/* Negotiate highest available SSL/TLS version */ -__owur const SSL_METHOD *TLS_method(void); -__owur const SSL_METHOD *TLS_server_method(void); -__owur const SSL_METHOD *TLS_client_method(void); - -# ifndef OPENSSL_NO_TLS1_METHOD -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_method(void)) /* TLSv1.0 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_server_method(void)) -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_client_method(void)) -# endif - -# ifndef OPENSSL_NO_TLS1_1_METHOD -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_method(void)) /* TLSv1.1 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_server_method(void)) -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_client_method(void)) -# endif - -# ifndef OPENSSL_NO_TLS1_2_METHOD -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_method(void)) /* TLSv1.2 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_server_method(void)) -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_client_method(void)) -# endif - -# ifndef OPENSSL_NO_DTLS1_METHOD -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_method(void)) /* DTLSv1.0 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_server_method(void)) -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_client_method(void)) -# endif - -# ifndef OPENSSL_NO_DTLS1_2_METHOD -/* DTLSv1.2 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_method(void)) -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_server_method(void)) -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_client_method(void)) -# endif - -__owur const SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */ -__owur const SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */ -__owur const SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */ - -__owur size_t DTLS_get_data_mtu(const SSL *s); - -__owur STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s); -__owur STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx); -__owur STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *s); -__owur STACK_OF(SSL_CIPHER) *SSL_get1_supported_ciphers(SSL *s); - -__owur int SSL_do_handshake(SSL *s); -int SSL_key_update(SSL *s, int updatetype); -int SSL_get_key_update_type(const SSL *s); -int SSL_renegotiate(SSL *s); -int SSL_renegotiate_abbreviated(SSL *s); -__owur int SSL_renegotiate_pending(const SSL *s); -int SSL_shutdown(SSL *s); -__owur int SSL_verify_client_post_handshake(SSL *s); -void SSL_CTX_set_post_handshake_auth(SSL_CTX *ctx, int val); -void SSL_set_post_handshake_auth(SSL *s, int val); - -__owur const SSL_METHOD *SSL_CTX_get_ssl_method(const SSL_CTX *ctx); -__owur const SSL_METHOD *SSL_get_ssl_method(const SSL *s); -__owur int SSL_set_ssl_method(SSL *s, const SSL_METHOD *method); -__owur const char *SSL_alert_type_string_long(int value); -__owur const char *SSL_alert_type_string(int value); -__owur const char *SSL_alert_desc_string_long(int value); -__owur const char *SSL_alert_desc_string(int value); - -void SSL_set0_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list); -void SSL_CTX_set0_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list); -__owur const STACK_OF(X509_NAME) *SSL_get0_CA_list(const SSL *s); -__owur const STACK_OF(X509_NAME) *SSL_CTX_get0_CA_list(const SSL_CTX *ctx); -__owur int SSL_add1_to_CA_list(SSL *ssl, const X509 *x); -__owur int SSL_CTX_add1_to_CA_list(SSL_CTX *ctx, const X509 *x); -__owur const STACK_OF(X509_NAME) *SSL_get0_peer_CA_list(const SSL *s); - -void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list); -void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list); -__owur STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s); -__owur STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s); -__owur int SSL_add_client_CA(SSL *ssl, X509 *x); -__owur int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x); - -void SSL_set_connect_state(SSL *s); -void SSL_set_accept_state(SSL *s); - -__owur long SSL_get_default_timeout(const SSL *s); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define SSL_library_init() OPENSSL_init_ssl(0, NULL) -# endif - -__owur char *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size); -__owur STACK_OF(X509_NAME) *SSL_dup_CA_list(const STACK_OF(X509_NAME) *sk); - -__owur SSL *SSL_dup(SSL *ssl); - -__owur X509 *SSL_get_certificate(const SSL *ssl); -/* - * EVP_PKEY - */ -struct evp_pkey_st *SSL_get_privatekey(const SSL *ssl); - -__owur X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx); -__owur EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx); - -void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode); -__owur int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); -void SSL_set_quiet_shutdown(SSL *ssl, int mode); -__owur int SSL_get_quiet_shutdown(const SSL *ssl); -void SSL_set_shutdown(SSL *ssl, int mode); -__owur int SSL_get_shutdown(const SSL *ssl); -__owur int SSL_version(const SSL *ssl); -__owur int SSL_client_version(const SSL *s); -__owur int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); -__owur int SSL_CTX_set_default_verify_dir(SSL_CTX *ctx); -__owur int SSL_CTX_set_default_verify_file(SSL_CTX *ctx); -__owur int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, - const char *CApath); -# define SSL_get0_session SSL_get_session/* just peek at pointer */ -__owur SSL_SESSION *SSL_get_session(const SSL *ssl); -__owur SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ -__owur SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); -SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx); -void SSL_set_info_callback(SSL *ssl, - void (*cb) (const SSL *ssl, int type, int val)); -void (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type, - int val); -__owur OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl); - -void SSL_set_verify_result(SSL *ssl, long v); -__owur long SSL_get_verify_result(const SSL *ssl); -__owur STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s); - -__owur size_t SSL_get_client_random(const SSL *ssl, unsigned char *out, - size_t outlen); -__owur size_t SSL_get_server_random(const SSL *ssl, unsigned char *out, - size_t outlen); -__owur size_t SSL_SESSION_get_master_key(const SSL_SESSION *sess, - unsigned char *out, size_t outlen); -__owur int SSL_SESSION_set1_master_key(SSL_SESSION *sess, - const unsigned char *in, size_t len); -uint8_t SSL_SESSION_get_max_fragment_length(const SSL_SESSION *sess); - -#define SSL_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef) -__owur int SSL_set_ex_data(SSL *ssl, int idx, void *data); -void *SSL_get_ex_data(const SSL *ssl, int idx); -#define SSL_SESSION_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, l, p, newf, dupf, freef) -__owur int SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, void *data); -void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx); -#define SSL_CTX_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, l, p, newf, dupf, freef) -__owur int SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data); -void *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx); - -__owur int SSL_get_ex_data_X509_STORE_CTX_idx(void); - -# define SSL_CTX_sess_set_cache_size(ctx,t) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL) -# define SSL_CTX_sess_get_cache_size(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL) -# define SSL_CTX_set_session_cache_mode(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL) -# define SSL_CTX_get_session_cache_mode(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL) - -# define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx) -# define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m) -# define SSL_CTX_get_read_ahead(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL) -# define SSL_CTX_set_read_ahead(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL) -# define SSL_CTX_get_max_cert_list(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) -# define SSL_CTX_set_max_cert_list(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) -# define SSL_get_max_cert_list(ssl) \ - SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) -# define SSL_set_max_cert_list(ssl,m) \ - SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) - -# define SSL_CTX_set_max_send_fragment(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL) -# define SSL_set_max_send_fragment(ssl,m) \ - SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL) -# define SSL_CTX_set_split_send_fragment(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL) -# define SSL_set_split_send_fragment(ssl,m) \ - SSL_ctrl(ssl,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL) -# define SSL_CTX_set_max_pipelines(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_PIPELINES,m,NULL) -# define SSL_set_max_pipelines(ssl,m) \ - SSL_ctrl(ssl,SSL_CTRL_SET_MAX_PIPELINES,m,NULL) - -void SSL_CTX_set_default_read_buffer_len(SSL_CTX *ctx, size_t len); -void SSL_set_default_read_buffer_len(SSL *s, size_t len); - -# ifndef OPENSSL_NO_DH -/* NB: the |keylength| is only applicable when is_export is true */ -void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, - DH *(*dh) (SSL *ssl, int is_export, - int keylength)); -void SSL_set_tmp_dh_callback(SSL *ssl, - DH *(*dh) (SSL *ssl, int is_export, - int keylength)); -# endif - -__owur const COMP_METHOD *SSL_get_current_compression(const SSL *s); -__owur const COMP_METHOD *SSL_get_current_expansion(const SSL *s); -__owur const char *SSL_COMP_get_name(const COMP_METHOD *comp); -__owur const char *SSL_COMP_get0_name(const SSL_COMP *comp); -__owur int SSL_COMP_get_id(const SSL_COMP *comp); -STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void); -__owur STACK_OF(SSL_COMP) *SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP) - *meths); -# if OPENSSL_API_COMPAT < 0x10100000L -# define SSL_COMP_free_compression_methods() while(0) continue -# endif -__owur int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm); - -const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr); -int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c); -int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c); -int SSL_bytes_to_cipher_list(SSL *s, const unsigned char *bytes, size_t len, - int isv2format, STACK_OF(SSL_CIPHER) **sk, - STACK_OF(SSL_CIPHER) **scsvs); - -/* TLS extensions functions */ -__owur int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len); - -__owur int SSL_set_session_ticket_ext_cb(SSL *s, - tls_session_ticket_ext_cb_fn cb, - void *arg); - -/* Pre-shared secret session resumption functions */ -__owur int SSL_set_session_secret_cb(SSL *s, - tls_session_secret_cb_fn session_secret_cb, - void *arg); - -void SSL_CTX_set_not_resumable_session_callback(SSL_CTX *ctx, - int (*cb) (SSL *ssl, - int - is_forward_secure)); - -void SSL_set_not_resumable_session_callback(SSL *ssl, - int (*cb) (SSL *ssl, - int is_forward_secure)); - -void SSL_CTX_set_record_padding_callback(SSL_CTX *ctx, - size_t (*cb) (SSL *ssl, int type, - size_t len, void *arg)); -void SSL_CTX_set_record_padding_callback_arg(SSL_CTX *ctx, void *arg); -void *SSL_CTX_get_record_padding_callback_arg(const SSL_CTX *ctx); -int SSL_CTX_set_block_padding(SSL_CTX *ctx, size_t block_size); - -void SSL_set_record_padding_callback(SSL *ssl, - size_t (*cb) (SSL *ssl, int type, - size_t len, void *arg)); -void SSL_set_record_padding_callback_arg(SSL *ssl, void *arg); -void *SSL_get_record_padding_callback_arg(const SSL *ssl); -int SSL_set_block_padding(SSL *ssl, size_t block_size); - -int SSL_set_num_tickets(SSL *s, size_t num_tickets); -size_t SSL_get_num_tickets(const SSL *s); -int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets); -size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define SSL_cache_hit(s) SSL_session_reused(s) -# endif - -__owur int SSL_session_reused(const SSL *s); -__owur int SSL_is_server(const SSL *s); - -__owur __owur SSL_CONF_CTX *SSL_CONF_CTX_new(void); -int SSL_CONF_CTX_finish(SSL_CONF_CTX *cctx); -void SSL_CONF_CTX_free(SSL_CONF_CTX *cctx); -unsigned int SSL_CONF_CTX_set_flags(SSL_CONF_CTX *cctx, unsigned int flags); -__owur unsigned int SSL_CONF_CTX_clear_flags(SSL_CONF_CTX *cctx, - unsigned int flags); -__owur int SSL_CONF_CTX_set1_prefix(SSL_CONF_CTX *cctx, const char *pre); - -void SSL_CONF_CTX_set_ssl(SSL_CONF_CTX *cctx, SSL *ssl); -void SSL_CONF_CTX_set_ssl_ctx(SSL_CONF_CTX *cctx, SSL_CTX *ctx); - -__owur int SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value); -__owur int SSL_CONF_cmd_argv(SSL_CONF_CTX *cctx, int *pargc, char ***pargv); -__owur int SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd); - -void SSL_add_ssl_module(void); -int SSL_config(SSL *s, const char *name); -int SSL_CTX_config(SSL_CTX *ctx, const char *name); - -# ifndef OPENSSL_NO_SSL_TRACE -void SSL_trace(int write_p, int version, int content_type, - const void *buf, size_t len, SSL *ssl, void *arg); -# endif - -# ifndef OPENSSL_NO_SOCK -int DTLSv1_listen(SSL *s, BIO_ADDR *client); -# endif - -# ifndef OPENSSL_NO_CT - -/* - * A callback for verifying that the received SCTs are sufficient. - * Expected to return 1 if they are sufficient, otherwise 0. - * May return a negative integer if an error occurs. - * A connection should be aborted if the SCTs are deemed insufficient. - */ -typedef int (*ssl_ct_validation_cb)(const CT_POLICY_EVAL_CTX *ctx, - const STACK_OF(SCT) *scts, void *arg); - -/* - * Sets a |callback| that is invoked upon receipt of ServerHelloDone to validate - * the received SCTs. - * If the callback returns a non-positive result, the connection is terminated. - * Call this function before beginning a handshake. - * If a NULL |callback| is provided, SCT validation is disabled. - * |arg| is arbitrary userdata that will be passed to the callback whenever it - * is invoked. Ownership of |arg| remains with the caller. - * - * NOTE: A side-effect of setting a CT callback is that an OCSP stapled response - * will be requested. - */ -int SSL_set_ct_validation_callback(SSL *s, ssl_ct_validation_cb callback, - void *arg); -int SSL_CTX_set_ct_validation_callback(SSL_CTX *ctx, - ssl_ct_validation_cb callback, - void *arg); -#define SSL_disable_ct(s) \ - ((void) SSL_set_validation_callback((s), NULL, NULL)) -#define SSL_CTX_disable_ct(ctx) \ - ((void) SSL_CTX_set_validation_callback((ctx), NULL, NULL)) - -/* - * The validation type enumerates the available behaviours of the built-in SSL - * CT validation callback selected via SSL_enable_ct() and SSL_CTX_enable_ct(). - * The underlying callback is a static function in libssl. - */ -enum { - SSL_CT_VALIDATION_PERMISSIVE = 0, - SSL_CT_VALIDATION_STRICT -}; - -/* - * Enable CT by setting up a callback that implements one of the built-in - * validation variants. The SSL_CT_VALIDATION_PERMISSIVE variant always - * continues the handshake, the application can make appropriate decisions at - * handshake completion. The SSL_CT_VALIDATION_STRICT variant requires at - * least one valid SCT, or else handshake termination will be requested. The - * handshake may continue anyway if SSL_VERIFY_NONE is in effect. - */ -int SSL_enable_ct(SSL *s, int validation_mode); -int SSL_CTX_enable_ct(SSL_CTX *ctx, int validation_mode); - -/* - * Report whether a non-NULL callback is enabled. - */ -int SSL_ct_is_enabled(const SSL *s); -int SSL_CTX_ct_is_enabled(const SSL_CTX *ctx); - -/* Gets the SCTs received from a connection */ -const STACK_OF(SCT) *SSL_get0_peer_scts(SSL *s); - -/* - * Loads the CT log list from the default location. - * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store, - * the log information loaded from this file will be appended to the - * CTLOG_STORE. - * Returns 1 on success, 0 otherwise. - */ -int SSL_CTX_set_default_ctlog_list_file(SSL_CTX *ctx); - -/* - * Loads the CT log list from the specified file path. - * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store, - * the log information loaded from this file will be appended to the - * CTLOG_STORE. - * Returns 1 on success, 0 otherwise. - */ -int SSL_CTX_set_ctlog_list_file(SSL_CTX *ctx, const char *path); - -/* - * Sets the CT log list used by all SSL connections created from this SSL_CTX. - * Ownership of the CTLOG_STORE is transferred to the SSL_CTX. - */ -void SSL_CTX_set0_ctlog_store(SSL_CTX *ctx, CTLOG_STORE *logs); - -/* - * Gets the CT log list used by all SSL connections created from this SSL_CTX. - * This will be NULL unless one of the following functions has been called: - * - SSL_CTX_set_default_ctlog_list_file - * - SSL_CTX_set_ctlog_list_file - * - SSL_CTX_set_ctlog_store - */ -const CTLOG_STORE *SSL_CTX_get0_ctlog_store(const SSL_CTX *ctx); - -# endif /* OPENSSL_NO_CT */ - -/* What the "other" parameter contains in security callback */ -/* Mask for type */ -# define SSL_SECOP_OTHER_TYPE 0xffff0000 -# define SSL_SECOP_OTHER_NONE 0 -# define SSL_SECOP_OTHER_CIPHER (1 << 16) -# define SSL_SECOP_OTHER_CURVE (2 << 16) -# define SSL_SECOP_OTHER_DH (3 << 16) -# define SSL_SECOP_OTHER_PKEY (4 << 16) -# define SSL_SECOP_OTHER_SIGALG (5 << 16) -# define SSL_SECOP_OTHER_CERT (6 << 16) - -/* Indicated operation refers to peer key or certificate */ -# define SSL_SECOP_PEER 0x1000 - -/* Values for "op" parameter in security callback */ - -/* Called to filter ciphers */ -/* Ciphers client supports */ -# define SSL_SECOP_CIPHER_SUPPORTED (1 | SSL_SECOP_OTHER_CIPHER) -/* Cipher shared by client/server */ -# define SSL_SECOP_CIPHER_SHARED (2 | SSL_SECOP_OTHER_CIPHER) -/* Sanity check of cipher server selects */ -# define SSL_SECOP_CIPHER_CHECK (3 | SSL_SECOP_OTHER_CIPHER) -/* Curves supported by client */ -# define SSL_SECOP_CURVE_SUPPORTED (4 | SSL_SECOP_OTHER_CURVE) -/* Curves shared by client/server */ -# define SSL_SECOP_CURVE_SHARED (5 | SSL_SECOP_OTHER_CURVE) -/* Sanity check of curve server selects */ -# define SSL_SECOP_CURVE_CHECK (6 | SSL_SECOP_OTHER_CURVE) -/* Temporary DH key */ -# define SSL_SECOP_TMP_DH (7 | SSL_SECOP_OTHER_PKEY) -/* SSL/TLS version */ -# define SSL_SECOP_VERSION (9 | SSL_SECOP_OTHER_NONE) -/* Session tickets */ -# define SSL_SECOP_TICKET (10 | SSL_SECOP_OTHER_NONE) -/* Supported signature algorithms sent to peer */ -# define SSL_SECOP_SIGALG_SUPPORTED (11 | SSL_SECOP_OTHER_SIGALG) -/* Shared signature algorithm */ -# define SSL_SECOP_SIGALG_SHARED (12 | SSL_SECOP_OTHER_SIGALG) -/* Sanity check signature algorithm allowed */ -# define SSL_SECOP_SIGALG_CHECK (13 | SSL_SECOP_OTHER_SIGALG) -/* Used to get mask of supported public key signature algorithms */ -# define SSL_SECOP_SIGALG_MASK (14 | SSL_SECOP_OTHER_SIGALG) -/* Use to see if compression is allowed */ -# define SSL_SECOP_COMPRESSION (15 | SSL_SECOP_OTHER_NONE) -/* EE key in certificate */ -# define SSL_SECOP_EE_KEY (16 | SSL_SECOP_OTHER_CERT) -/* CA key in certificate */ -# define SSL_SECOP_CA_KEY (17 | SSL_SECOP_OTHER_CERT) -/* CA digest algorithm in certificate */ -# define SSL_SECOP_CA_MD (18 | SSL_SECOP_OTHER_CERT) -/* Peer EE key in certificate */ -# define SSL_SECOP_PEER_EE_KEY (SSL_SECOP_EE_KEY | SSL_SECOP_PEER) -/* Peer CA key in certificate */ -# define SSL_SECOP_PEER_CA_KEY (SSL_SECOP_CA_KEY | SSL_SECOP_PEER) -/* Peer CA digest algorithm in certificate */ -# define SSL_SECOP_PEER_CA_MD (SSL_SECOP_CA_MD | SSL_SECOP_PEER) - -void SSL_set_security_level(SSL *s, int level); -__owur int SSL_get_security_level(const SSL *s); -void SSL_set_security_callback(SSL *s, - int (*cb) (const SSL *s, const SSL_CTX *ctx, - int op, int bits, int nid, - void *other, void *ex)); -int (*SSL_get_security_callback(const SSL *s)) (const SSL *s, - const SSL_CTX *ctx, int op, - int bits, int nid, void *other, - void *ex); -void SSL_set0_security_ex_data(SSL *s, void *ex); -__owur void *SSL_get0_security_ex_data(const SSL *s); - -void SSL_CTX_set_security_level(SSL_CTX *ctx, int level); -__owur int SSL_CTX_get_security_level(const SSL_CTX *ctx); -void SSL_CTX_set_security_callback(SSL_CTX *ctx, - int (*cb) (const SSL *s, const SSL_CTX *ctx, - int op, int bits, int nid, - void *other, void *ex)); -int (*SSL_CTX_get_security_callback(const SSL_CTX *ctx)) (const SSL *s, - const SSL_CTX *ctx, - int op, int bits, - int nid, - void *other, - void *ex); -void SSL_CTX_set0_security_ex_data(SSL_CTX *ctx, void *ex); -__owur void *SSL_CTX_get0_security_ex_data(const SSL_CTX *ctx); - -/* OPENSSL_INIT flag 0x010000 reserved for internal use */ -# define OPENSSL_INIT_NO_LOAD_SSL_STRINGS 0x00100000L -# define OPENSSL_INIT_LOAD_SSL_STRINGS 0x00200000L - -# define OPENSSL_INIT_SSL_DEFAULT \ - (OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS) - -int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); - -# ifndef OPENSSL_NO_UNIT_TEST -__owur const struct openssl_ssl_test_functions *SSL_test_functions(void); -# endif - -__owur int SSL_free_buffers(SSL *ssl); -__owur int SSL_alloc_buffers(SSL *ssl); - -/* Status codes passed to the decrypt session ticket callback. Some of these - * are for internal use only and are never passed to the callback. */ -typedef int SSL_TICKET_STATUS; - -/* Support for ticket appdata */ -/* fatal error, malloc failure */ -# define SSL_TICKET_FATAL_ERR_MALLOC 0 -/* fatal error, either from parsing or decrypting the ticket */ -# define SSL_TICKET_FATAL_ERR_OTHER 1 -/* No ticket present */ -# define SSL_TICKET_NONE 2 -/* Empty ticket present */ -# define SSL_TICKET_EMPTY 3 -/* the ticket couldn't be decrypted */ -# define SSL_TICKET_NO_DECRYPT 4 -/* a ticket was successfully decrypted */ -# define SSL_TICKET_SUCCESS 5 -/* same as above but the ticket needs to be renewed */ -# define SSL_TICKET_SUCCESS_RENEW 6 - -/* Return codes for the decrypt session ticket callback */ -typedef int SSL_TICKET_RETURN; - -/* An error occurred */ -#define SSL_TICKET_RETURN_ABORT 0 -/* Do not use the ticket, do not send a renewed ticket to the client */ -#define SSL_TICKET_RETURN_IGNORE 1 -/* Do not use the ticket, send a renewed ticket to the client */ -#define SSL_TICKET_RETURN_IGNORE_RENEW 2 -/* Use the ticket, do not send a renewed ticket to the client */ -#define SSL_TICKET_RETURN_USE 3 -/* Use the ticket, send a renewed ticket to the client */ -#define SSL_TICKET_RETURN_USE_RENEW 4 - -typedef int (*SSL_CTX_generate_session_ticket_fn)(SSL *s, void *arg); -typedef SSL_TICKET_RETURN (*SSL_CTX_decrypt_session_ticket_fn)(SSL *s, SSL_SESSION *ss, - const unsigned char *keyname, - size_t keyname_length, - SSL_TICKET_STATUS status, - void *arg); -int SSL_CTX_set_session_ticket_cb(SSL_CTX *ctx, - SSL_CTX_generate_session_ticket_fn gen_cb, - SSL_CTX_decrypt_session_ticket_fn dec_cb, - void *arg); -int SSL_SESSION_set1_ticket_appdata(SSL_SESSION *ss, const void *data, size_t len); -int SSL_SESSION_get0_ticket_appdata(SSL_SESSION *ss, void **data, size_t *len); - -extern const char SSL_version_str[]; - -typedef unsigned int (*DTLS_timer_cb)(SSL *s, unsigned int timer_us); - -void DTLS_set_timer_cb(SSL *s, DTLS_timer_cb cb); - - -typedef int (*SSL_allow_early_data_cb_fn)(SSL *s, void *arg); -void SSL_CTX_set_allow_early_data_cb(SSL_CTX *ctx, - SSL_allow_early_data_cb_fn cb, - void *arg); -void SSL_set_allow_early_data_cb(SSL *s, - SSL_allow_early_data_cb_fn cb, - void *arg); - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ssl2.h b/client/3rd/OpenSSL/include/openssl/ssl2.h deleted file mode 100644 index 5321bd27..00000000 --- a/client/3rd/OpenSSL/include/openssl/ssl2.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SSL2_H -# define HEADER_SSL2_H - -#ifdef __cplusplus -extern "C" { -#endif - -# define SSL2_VERSION 0x0002 - -# define SSL2_MT_CLIENT_HELLO 1 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ssl3.h b/client/3rd/OpenSSL/include/openssl/ssl3.h deleted file mode 100644 index 07effba2..00000000 --- a/client/3rd/OpenSSL/include/openssl/ssl3.h +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SSL3_H -# define HEADER_SSL3_H - -# include -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Signalling cipher suite value from RFC 5746 - * (TLS_EMPTY_RENEGOTIATION_INFO_SCSV) - */ -# define SSL3_CK_SCSV 0x030000FF - -/* - * Signalling cipher suite value from draft-ietf-tls-downgrade-scsv-00 - * (TLS_FALLBACK_SCSV) - */ -# define SSL3_CK_FALLBACK_SCSV 0x03005600 - -# define SSL3_CK_RSA_NULL_MD5 0x03000001 -# define SSL3_CK_RSA_NULL_SHA 0x03000002 -# define SSL3_CK_RSA_RC4_40_MD5 0x03000003 -# define SSL3_CK_RSA_RC4_128_MD5 0x03000004 -# define SSL3_CK_RSA_RC4_128_SHA 0x03000005 -# define SSL3_CK_RSA_RC2_40_MD5 0x03000006 -# define SSL3_CK_RSA_IDEA_128_SHA 0x03000007 -# define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008 -# define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009 -# define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A - -# define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B -# define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C -# define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D -# define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E -# define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F -# define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010 - -# define SSL3_CK_DHE_DSS_DES_40_CBC_SHA 0x03000011 -# define SSL3_CK_EDH_DSS_DES_40_CBC_SHA SSL3_CK_DHE_DSS_DES_40_CBC_SHA -# define SSL3_CK_DHE_DSS_DES_64_CBC_SHA 0x03000012 -# define SSL3_CK_EDH_DSS_DES_64_CBC_SHA SSL3_CK_DHE_DSS_DES_64_CBC_SHA -# define SSL3_CK_DHE_DSS_DES_192_CBC3_SHA 0x03000013 -# define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA SSL3_CK_DHE_DSS_DES_192_CBC3_SHA -# define SSL3_CK_DHE_RSA_DES_40_CBC_SHA 0x03000014 -# define SSL3_CK_EDH_RSA_DES_40_CBC_SHA SSL3_CK_DHE_RSA_DES_40_CBC_SHA -# define SSL3_CK_DHE_RSA_DES_64_CBC_SHA 0x03000015 -# define SSL3_CK_EDH_RSA_DES_64_CBC_SHA SSL3_CK_DHE_RSA_DES_64_CBC_SHA -# define SSL3_CK_DHE_RSA_DES_192_CBC3_SHA 0x03000016 -# define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA SSL3_CK_DHE_RSA_DES_192_CBC3_SHA - -# define SSL3_CK_ADH_RC4_40_MD5 0x03000017 -# define SSL3_CK_ADH_RC4_128_MD5 0x03000018 -# define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019 -# define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A -# define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B - -/* a bundle of RFC standard cipher names, generated from ssl3_ciphers[] */ -# define SSL3_RFC_RSA_NULL_MD5 "TLS_RSA_WITH_NULL_MD5" -# define SSL3_RFC_RSA_NULL_SHA "TLS_RSA_WITH_NULL_SHA" -# define SSL3_RFC_RSA_DES_192_CBC3_SHA "TLS_RSA_WITH_3DES_EDE_CBC_SHA" -# define SSL3_RFC_DHE_DSS_DES_192_CBC3_SHA "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA" -# define SSL3_RFC_DHE_RSA_DES_192_CBC3_SHA "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA" -# define SSL3_RFC_ADH_DES_192_CBC_SHA "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA" -# define SSL3_RFC_RSA_IDEA_128_SHA "TLS_RSA_WITH_IDEA_CBC_SHA" -# define SSL3_RFC_RSA_RC4_128_MD5 "TLS_RSA_WITH_RC4_128_MD5" -# define SSL3_RFC_RSA_RC4_128_SHA "TLS_RSA_WITH_RC4_128_SHA" -# define SSL3_RFC_ADH_RC4_128_MD5 "TLS_DH_anon_WITH_RC4_128_MD5" - -# define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" -# define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" -# define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" -# define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5" -# define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA" -# define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5" -# define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA" -# define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA" -# define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA" -# define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA" - -# define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA" -# define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA" -# define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA" -# define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA" -# define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA" -# define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA" - -# define SSL3_TXT_DHE_DSS_DES_40_CBC_SHA "EXP-DHE-DSS-DES-CBC-SHA" -# define SSL3_TXT_DHE_DSS_DES_64_CBC_SHA "DHE-DSS-DES-CBC-SHA" -# define SSL3_TXT_DHE_DSS_DES_192_CBC3_SHA "DHE-DSS-DES-CBC3-SHA" -# define SSL3_TXT_DHE_RSA_DES_40_CBC_SHA "EXP-DHE-RSA-DES-CBC-SHA" -# define SSL3_TXT_DHE_RSA_DES_64_CBC_SHA "DHE-RSA-DES-CBC-SHA" -# define SSL3_TXT_DHE_RSA_DES_192_CBC3_SHA "DHE-RSA-DES-CBC3-SHA" - -/* - * This next block of six "EDH" labels is for backward compatibility with - * older versions of OpenSSL. New code should use the six "DHE" labels above - * instead: - */ -# define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA" -# define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA" -# define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA" -# define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA" -# define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA" -# define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA" - -# define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5" -# define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5" -# define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA" -# define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA" -# define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA" - -# define SSL3_SSL_SESSION_ID_LENGTH 32 -# define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 - -# define SSL3_MASTER_SECRET_SIZE 48 -# define SSL3_RANDOM_SIZE 32 -# define SSL3_SESSION_ID_SIZE 32 -# define SSL3_RT_HEADER_LENGTH 5 - -# define SSL3_HM_HEADER_LENGTH 4 - -# ifndef SSL3_ALIGN_PAYLOAD - /* - * Some will argue that this increases memory footprint, but it's not - * actually true. Point is that malloc has to return at least 64-bit aligned - * pointers, meaning that allocating 5 bytes wastes 3 bytes in either case. - * Suggested pre-gaping simply moves these wasted bytes from the end of - * allocated region to its front, but makes data payload aligned, which - * improves performance:-) - */ -# define SSL3_ALIGN_PAYLOAD 8 -# else -# if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0 -# error "insane SSL3_ALIGN_PAYLOAD" -# undef SSL3_ALIGN_PAYLOAD -# endif -# endif - -/* - * This is the maximum MAC (digest) size used by the SSL library. Currently - * maximum of 20 is used by SHA1, but we reserve for future extension for - * 512-bit hashes. - */ - -# define SSL3_RT_MAX_MD_SIZE 64 - -/* - * Maximum block size used in all ciphersuites. Currently 16 for AES. - */ - -# define SSL_RT_MAX_CIPHER_BLOCK_SIZE 16 - -# define SSL3_RT_MAX_EXTRA (16384) - -/* Maximum plaintext length: defined by SSL/TLS standards */ -# define SSL3_RT_MAX_PLAIN_LENGTH 16384 -/* Maximum compression overhead: defined by SSL/TLS standards */ -# define SSL3_RT_MAX_COMPRESSED_OVERHEAD 1024 - -/* - * The standards give a maximum encryption overhead of 1024 bytes. In - * practice the value is lower than this. The overhead is the maximum number - * of padding bytes (256) plus the mac size. - */ -# define SSL3_RT_MAX_ENCRYPTED_OVERHEAD (256 + SSL3_RT_MAX_MD_SIZE) -# define SSL3_RT_MAX_TLS13_ENCRYPTED_OVERHEAD 256 - -/* - * OpenSSL currently only uses a padding length of at most one block so the - * send overhead is smaller. - */ - -# define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \ - (SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE) - -/* If compression isn't used don't include the compression overhead */ - -# ifdef OPENSSL_NO_COMP -# define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH -# else -# define SSL3_RT_MAX_COMPRESSED_LENGTH \ - (SSL3_RT_MAX_PLAIN_LENGTH+SSL3_RT_MAX_COMPRESSED_OVERHEAD) -# endif -# define SSL3_RT_MAX_ENCRYPTED_LENGTH \ - (SSL3_RT_MAX_ENCRYPTED_OVERHEAD+SSL3_RT_MAX_COMPRESSED_LENGTH) -# define SSL3_RT_MAX_TLS13_ENCRYPTED_LENGTH \ - (SSL3_RT_MAX_PLAIN_LENGTH + SSL3_RT_MAX_TLS13_ENCRYPTED_OVERHEAD) -# define SSL3_RT_MAX_PACKET_SIZE \ - (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) - -# define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" -# define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" - -# define SSL3_VERSION 0x0300 -# define SSL3_VERSION_MAJOR 0x03 -# define SSL3_VERSION_MINOR 0x00 - -# define SSL3_RT_CHANGE_CIPHER_SPEC 20 -# define SSL3_RT_ALERT 21 -# define SSL3_RT_HANDSHAKE 22 -# define SSL3_RT_APPLICATION_DATA 23 -# define DTLS1_RT_HEARTBEAT 24 - -/* Pseudo content types to indicate additional parameters */ -# define TLS1_RT_CRYPTO 0x1000 -# define TLS1_RT_CRYPTO_PREMASTER (TLS1_RT_CRYPTO | 0x1) -# define TLS1_RT_CRYPTO_CLIENT_RANDOM (TLS1_RT_CRYPTO | 0x2) -# define TLS1_RT_CRYPTO_SERVER_RANDOM (TLS1_RT_CRYPTO | 0x3) -# define TLS1_RT_CRYPTO_MASTER (TLS1_RT_CRYPTO | 0x4) - -# define TLS1_RT_CRYPTO_READ 0x0000 -# define TLS1_RT_CRYPTO_WRITE 0x0100 -# define TLS1_RT_CRYPTO_MAC (TLS1_RT_CRYPTO | 0x5) -# define TLS1_RT_CRYPTO_KEY (TLS1_RT_CRYPTO | 0x6) -# define TLS1_RT_CRYPTO_IV (TLS1_RT_CRYPTO | 0x7) -# define TLS1_RT_CRYPTO_FIXED_IV (TLS1_RT_CRYPTO | 0x8) - -/* Pseudo content types for SSL/TLS header info */ -# define SSL3_RT_HEADER 0x100 -# define SSL3_RT_INNER_CONTENT_TYPE 0x101 - -# define SSL3_AL_WARNING 1 -# define SSL3_AL_FATAL 2 - -# define SSL3_AD_CLOSE_NOTIFY 0 -# define SSL3_AD_UNEXPECTED_MESSAGE 10/* fatal */ -# define SSL3_AD_BAD_RECORD_MAC 20/* fatal */ -# define SSL3_AD_DECOMPRESSION_FAILURE 30/* fatal */ -# define SSL3_AD_HANDSHAKE_FAILURE 40/* fatal */ -# define SSL3_AD_NO_CERTIFICATE 41 -# define SSL3_AD_BAD_CERTIFICATE 42 -# define SSL3_AD_UNSUPPORTED_CERTIFICATE 43 -# define SSL3_AD_CERTIFICATE_REVOKED 44 -# define SSL3_AD_CERTIFICATE_EXPIRED 45 -# define SSL3_AD_CERTIFICATE_UNKNOWN 46 -# define SSL3_AD_ILLEGAL_PARAMETER 47/* fatal */ - -# define TLS1_HB_REQUEST 1 -# define TLS1_HB_RESPONSE 2 - - -# define SSL3_CT_RSA_SIGN 1 -# define SSL3_CT_DSS_SIGN 2 -# define SSL3_CT_RSA_FIXED_DH 3 -# define SSL3_CT_DSS_FIXED_DH 4 -# define SSL3_CT_RSA_EPHEMERAL_DH 5 -# define SSL3_CT_DSS_EPHEMERAL_DH 6 -# define SSL3_CT_FORTEZZA_DMS 20 -/* - * SSL3_CT_NUMBER is used to size arrays and it must be large enough to - * contain all of the cert types defined for *either* SSLv3 and TLSv1. - */ -# define SSL3_CT_NUMBER 10 - -# if defined(TLS_CT_NUMBER) -# if TLS_CT_NUMBER != SSL3_CT_NUMBER -# error "SSL/TLS CT_NUMBER values do not match" -# endif -# endif - -/* No longer used as of OpenSSL 1.1.1 */ -# define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 - -/* Removed from OpenSSL 1.1.0 */ -# define TLS1_FLAGS_TLS_PADDING_BUG 0x0 - -# define TLS1_FLAGS_SKIP_CERT_VERIFY 0x0010 - -/* Set if we encrypt then mac instead of usual mac then encrypt */ -# define TLS1_FLAGS_ENCRYPT_THEN_MAC_READ 0x0100 -# define TLS1_FLAGS_ENCRYPT_THEN_MAC TLS1_FLAGS_ENCRYPT_THEN_MAC_READ - -/* Set if extended master secret extension received from peer */ -# define TLS1_FLAGS_RECEIVED_EXTMS 0x0200 - -# define TLS1_FLAGS_ENCRYPT_THEN_MAC_WRITE 0x0400 - -# define TLS1_FLAGS_STATELESS 0x0800 - -/* Set if extended master secret extension required on renegotiation */ -# define TLS1_FLAGS_REQUIRED_EXTMS 0x1000 - -# define SSL3_MT_HELLO_REQUEST 0 -# define SSL3_MT_CLIENT_HELLO 1 -# define SSL3_MT_SERVER_HELLO 2 -# define SSL3_MT_NEWSESSION_TICKET 4 -# define SSL3_MT_END_OF_EARLY_DATA 5 -# define SSL3_MT_ENCRYPTED_EXTENSIONS 8 -# define SSL3_MT_CERTIFICATE 11 -# define SSL3_MT_SERVER_KEY_EXCHANGE 12 -# define SSL3_MT_CERTIFICATE_REQUEST 13 -# define SSL3_MT_SERVER_DONE 14 -# define SSL3_MT_CERTIFICATE_VERIFY 15 -# define SSL3_MT_CLIENT_KEY_EXCHANGE 16 -# define SSL3_MT_FINISHED 20 -# define SSL3_MT_CERTIFICATE_URL 21 -# define SSL3_MT_CERTIFICATE_STATUS 22 -# define SSL3_MT_SUPPLEMENTAL_DATA 23 -# define SSL3_MT_KEY_UPDATE 24 -# ifndef OPENSSL_NO_NEXTPROTONEG -# define SSL3_MT_NEXT_PROTO 67 -# endif -# define SSL3_MT_MESSAGE_HASH 254 -# define DTLS1_MT_HELLO_VERIFY_REQUEST 3 - -/* Dummy message type for handling CCS like a normal handshake message */ -# define SSL3_MT_CHANGE_CIPHER_SPEC 0x0101 - -# define SSL3_MT_CCS 1 - -/* These are used when changing over to a new cipher */ -# define SSL3_CC_READ 0x001 -# define SSL3_CC_WRITE 0x002 -# define SSL3_CC_CLIENT 0x010 -# define SSL3_CC_SERVER 0x020 -# define SSL3_CC_EARLY 0x040 -# define SSL3_CC_HANDSHAKE 0x080 -# define SSL3_CC_APPLICATION 0x100 -# define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE) -# define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER|SSL3_CC_READ) -# define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT|SSL3_CC_READ) -# define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE) - -#ifdef __cplusplus -} -#endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/sslerr.h b/client/3rd/OpenSSL/include/openssl/sslerr.h deleted file mode 100644 index 701d61c6..00000000 --- a/client/3rd/OpenSSL/include/openssl/sslerr.h +++ /dev/null @@ -1,776 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SSLERR_H -# define HEADER_SSLERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_SSL_strings(void); - -/* - * SSL function codes. - */ -# define SSL_F_ADD_CLIENT_KEY_SHARE_EXT 438 -# define SSL_F_ADD_KEY_SHARE 512 -# define SSL_F_BYTES_TO_CIPHER_LIST 519 -# define SSL_F_CHECK_SUITEB_CIPHER_LIST 331 -# define SSL_F_CIPHERSUITE_CB 622 -# define SSL_F_CONSTRUCT_CA_NAMES 552 -# define SSL_F_CONSTRUCT_KEY_EXCHANGE_TBS 553 -# define SSL_F_CONSTRUCT_STATEFUL_TICKET 636 -# define SSL_F_CONSTRUCT_STATELESS_TICKET 637 -# define SSL_F_CREATE_SYNTHETIC_MESSAGE_HASH 539 -# define SSL_F_CREATE_TICKET_PREQUEL 638 -# define SSL_F_CT_MOVE_SCTS 345 -# define SSL_F_CT_STRICT 349 -# define SSL_F_CUSTOM_EXT_ADD 554 -# define SSL_F_CUSTOM_EXT_PARSE 555 -# define SSL_F_D2I_SSL_SESSION 103 -# define SSL_F_DANE_CTX_ENABLE 347 -# define SSL_F_DANE_MTYPE_SET 393 -# define SSL_F_DANE_TLSA_ADD 394 -# define SSL_F_DERIVE_SECRET_KEY_AND_IV 514 -# define SSL_F_DO_DTLS1_WRITE 245 -# define SSL_F_DO_SSL3_WRITE 104 -# define SSL_F_DTLS1_BUFFER_RECORD 247 -# define SSL_F_DTLS1_CHECK_TIMEOUT_NUM 318 -# define SSL_F_DTLS1_HEARTBEAT 305 -# define SSL_F_DTLS1_HM_FRAGMENT_NEW 623 -# define SSL_F_DTLS1_PREPROCESS_FRAGMENT 288 -# define SSL_F_DTLS1_PROCESS_BUFFERED_RECORDS 424 -# define SSL_F_DTLS1_PROCESS_RECORD 257 -# define SSL_F_DTLS1_READ_BYTES 258 -# define SSL_F_DTLS1_READ_FAILED 339 -# define SSL_F_DTLS1_RETRANSMIT_MESSAGE 390 -# define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 268 -# define SSL_F_DTLS1_WRITE_BYTES 545 -# define SSL_F_DTLSV1_LISTEN 350 -# define SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC 371 -# define SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST 385 -# define SSL_F_DTLS_GET_REASSEMBLED_MESSAGE 370 -# define SSL_F_DTLS_PROCESS_HELLO_VERIFY 386 -# define SSL_F_DTLS_RECORD_LAYER_NEW 635 -# define SSL_F_DTLS_WAIT_FOR_DRY 592 -# define SSL_F_EARLY_DATA_COUNT_OK 532 -# define SSL_F_FINAL_EARLY_DATA 556 -# define SSL_F_FINAL_EC_PT_FORMATS 485 -# define SSL_F_FINAL_EMS 486 -# define SSL_F_FINAL_KEY_SHARE 503 -# define SSL_F_FINAL_MAXFRAGMENTLEN 557 -# define SSL_F_FINAL_PSK 639 -# define SSL_F_FINAL_RENEGOTIATE 483 -# define SSL_F_FINAL_SERVER_NAME 558 -# define SSL_F_FINAL_SIG_ALGS 497 -# define SSL_F_GET_CERT_VERIFY_TBS_DATA 588 -# define SSL_F_NSS_KEYLOG_INT 500 -# define SSL_F_OPENSSL_INIT_SSL 342 -# define SSL_F_OSSL_STATEM_CLIENT13_READ_TRANSITION 436 -# define SSL_F_OSSL_STATEM_CLIENT13_WRITE_TRANSITION 598 -# define SSL_F_OSSL_STATEM_CLIENT_CONSTRUCT_MESSAGE 430 -# define SSL_F_OSSL_STATEM_CLIENT_POST_PROCESS_MESSAGE 593 -# define SSL_F_OSSL_STATEM_CLIENT_PROCESS_MESSAGE 594 -# define SSL_F_OSSL_STATEM_CLIENT_READ_TRANSITION 417 -# define SSL_F_OSSL_STATEM_CLIENT_WRITE_TRANSITION 599 -# define SSL_F_OSSL_STATEM_SERVER13_READ_TRANSITION 437 -# define SSL_F_OSSL_STATEM_SERVER13_WRITE_TRANSITION 600 -# define SSL_F_OSSL_STATEM_SERVER_CONSTRUCT_MESSAGE 431 -# define SSL_F_OSSL_STATEM_SERVER_POST_PROCESS_MESSAGE 601 -# define SSL_F_OSSL_STATEM_SERVER_POST_WORK 602 -# define SSL_F_OSSL_STATEM_SERVER_PRE_WORK 640 -# define SSL_F_OSSL_STATEM_SERVER_PROCESS_MESSAGE 603 -# define SSL_F_OSSL_STATEM_SERVER_READ_TRANSITION 418 -# define SSL_F_OSSL_STATEM_SERVER_WRITE_TRANSITION 604 -# define SSL_F_PARSE_CA_NAMES 541 -# define SSL_F_PITEM_NEW 624 -# define SSL_F_PQUEUE_NEW 625 -# define SSL_F_PROCESS_KEY_SHARE_EXT 439 -# define SSL_F_READ_STATE_MACHINE 352 -# define SSL_F_SET_CLIENT_CIPHERSUITE 540 -# define SSL_F_SRP_GENERATE_CLIENT_MASTER_SECRET 595 -# define SSL_F_SRP_GENERATE_SERVER_MASTER_SECRET 589 -# define SSL_F_SRP_VERIFY_SERVER_PARAM 596 -# define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 -# define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 -# define SSL_F_SSL3_CTRL 213 -# define SSL_F_SSL3_CTX_CTRL 133 -# define SSL_F_SSL3_DIGEST_CACHED_RECORDS 293 -# define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC 292 -# define SSL_F_SSL3_ENC 608 -# define SSL_F_SSL3_FINAL_FINISH_MAC 285 -# define SSL_F_SSL3_FINISH_MAC 587 -# define SSL_F_SSL3_GENERATE_KEY_BLOCK 238 -# define SSL_F_SSL3_GENERATE_MASTER_SECRET 388 -# define SSL_F_SSL3_GET_RECORD 143 -# define SSL_F_SSL3_INIT_FINISHED_MAC 397 -# define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147 -# define SSL_F_SSL3_READ_BYTES 148 -# define SSL_F_SSL3_READ_N 149 -# define SSL_F_SSL3_SETUP_KEY_BLOCK 157 -# define SSL_F_SSL3_SETUP_READ_BUFFER 156 -# define SSL_F_SSL3_SETUP_WRITE_BUFFER 291 -# define SSL_F_SSL3_WRITE_BYTES 158 -# define SSL_F_SSL3_WRITE_PENDING 159 -# define SSL_F_SSL_ADD_CERT_CHAIN 316 -# define SSL_F_SSL_ADD_CERT_TO_BUF 319 -# define SSL_F_SSL_ADD_CERT_TO_WPACKET 493 -# define SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT 298 -# define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT 277 -# define SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT 307 -# define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 215 -# define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 216 -# define SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT 299 -# define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT 278 -# define SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT 308 -# define SSL_F_SSL_BAD_METHOD 160 -# define SSL_F_SSL_BUILD_CERT_CHAIN 332 -# define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161 -# define SSL_F_SSL_CACHE_CIPHERLIST 520 -# define SSL_F_SSL_CERT_ADD0_CHAIN_CERT 346 -# define SSL_F_SSL_CERT_DUP 221 -# define SSL_F_SSL_CERT_NEW 162 -# define SSL_F_SSL_CERT_SET0_CHAIN 340 -# define SSL_F_SSL_CHECK_PRIVATE_KEY 163 -# define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT 280 -# define SSL_F_SSL_CHECK_SRP_EXT_CLIENTHELLO 606 -# define SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG 279 -# define SSL_F_SSL_CHOOSE_CLIENT_VERSION 607 -# define SSL_F_SSL_CIPHER_DESCRIPTION 626 -# define SSL_F_SSL_CIPHER_LIST_TO_BYTES 425 -# define SSL_F_SSL_CIPHER_PROCESS_RULESTR 230 -# define SSL_F_SSL_CIPHER_STRENGTH_SORT 231 -# define SSL_F_SSL_CLEAR 164 -# define SSL_F_SSL_CLIENT_HELLO_GET1_EXTENSIONS_PRESENT 627 -# define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165 -# define SSL_F_SSL_CONF_CMD 334 -# define SSL_F_SSL_CREATE_CIPHER_LIST 166 -# define SSL_F_SSL_CTRL 232 -# define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168 -# define SSL_F_SSL_CTX_ENABLE_CT 398 -# define SSL_F_SSL_CTX_MAKE_PROFILES 309 -# define SSL_F_SSL_CTX_NEW 169 -# define SSL_F_SSL_CTX_SET_ALPN_PROTOS 343 -# define SSL_F_SSL_CTX_SET_CIPHER_LIST 269 -# define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE 290 -# define SSL_F_SSL_CTX_SET_CT_VALIDATION_CALLBACK 396 -# define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219 -# define SSL_F_SSL_CTX_SET_SSL_VERSION 170 -# define SSL_F_SSL_CTX_SET_TLSEXT_MAX_FRAGMENT_LENGTH 551 -# define SSL_F_SSL_CTX_USE_CERTIFICATE 171 -# define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172 -# define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 173 -# define SSL_F_SSL_CTX_USE_PRIVATEKEY 174 -# define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 175 -# define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 176 -# define SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT 272 -# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 177 -# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 178 -# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 179 -# define SSL_F_SSL_CTX_USE_SERVERINFO 336 -# define SSL_F_SSL_CTX_USE_SERVERINFO_EX 543 -# define SSL_F_SSL_CTX_USE_SERVERINFO_FILE 337 -# define SSL_F_SSL_DANE_DUP 403 -# define SSL_F_SSL_DANE_ENABLE 395 -# define SSL_F_SSL_DERIVE 590 -# define SSL_F_SSL_DO_CONFIG 391 -# define SSL_F_SSL_DO_HANDSHAKE 180 -# define SSL_F_SSL_DUP_CA_LIST 408 -# define SSL_F_SSL_ENABLE_CT 402 -# define SSL_F_SSL_GENERATE_PKEY_GROUP 559 -# define SSL_F_SSL_GENERATE_SESSION_ID 547 -# define SSL_F_SSL_GET_NEW_SESSION 181 -# define SSL_F_SSL_GET_PREV_SESSION 217 -# define SSL_F_SSL_GET_SERVER_CERT_INDEX 322 -# define SSL_F_SSL_GET_SIGN_PKEY 183 -# define SSL_F_SSL_HANDSHAKE_HASH 560 -# define SSL_F_SSL_INIT_WBIO_BUFFER 184 -# define SSL_F_SSL_KEY_UPDATE 515 -# define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185 -# define SSL_F_SSL_LOG_MASTER_SECRET 498 -# define SSL_F_SSL_LOG_RSA_CLIENT_KEY_EXCHANGE 499 -# define SSL_F_SSL_MODULE_INIT 392 -# define SSL_F_SSL_NEW 186 -# define SSL_F_SSL_NEXT_PROTO_VALIDATE 565 -# define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT 300 -# define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT 302 -# define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT 310 -# define SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT 301 -# define SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT 303 -# define SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT 311 -# define SSL_F_SSL_PEEK 270 -# define SSL_F_SSL_PEEK_EX 432 -# define SSL_F_SSL_PEEK_INTERNAL 522 -# define SSL_F_SSL_READ 223 -# define SSL_F_SSL_READ_EARLY_DATA 529 -# define SSL_F_SSL_READ_EX 434 -# define SSL_F_SSL_READ_INTERNAL 523 -# define SSL_F_SSL_RENEGOTIATE 516 -# define SSL_F_SSL_RENEGOTIATE_ABBREVIATED 546 -# define SSL_F_SSL_SCAN_CLIENTHELLO_TLSEXT 320 -# define SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT 321 -# define SSL_F_SSL_SESSION_DUP 348 -# define SSL_F_SSL_SESSION_NEW 189 -# define SSL_F_SSL_SESSION_PRINT_FP 190 -# define SSL_F_SSL_SESSION_SET1_ID 423 -# define SSL_F_SSL_SESSION_SET1_ID_CONTEXT 312 -# define SSL_F_SSL_SET_ALPN_PROTOS 344 -# define SSL_F_SSL_SET_CERT 191 -# define SSL_F_SSL_SET_CERT_AND_KEY 621 -# define SSL_F_SSL_SET_CIPHER_LIST 271 -# define SSL_F_SSL_SET_CT_VALIDATION_CALLBACK 399 -# define SSL_F_SSL_SET_FD 192 -# define SSL_F_SSL_SET_PKEY 193 -# define SSL_F_SSL_SET_RFD 194 -# define SSL_F_SSL_SET_SESSION 195 -# define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218 -# define SSL_F_SSL_SET_SESSION_TICKET_EXT 294 -# define SSL_F_SSL_SET_TLSEXT_MAX_FRAGMENT_LENGTH 550 -# define SSL_F_SSL_SET_WFD 196 -# define SSL_F_SSL_SHUTDOWN 224 -# define SSL_F_SSL_SRP_CTX_INIT 313 -# define SSL_F_SSL_START_ASYNC_JOB 389 -# define SSL_F_SSL_UNDEFINED_FUNCTION 197 -# define SSL_F_SSL_UNDEFINED_VOID_FUNCTION 244 -# define SSL_F_SSL_USE_CERTIFICATE 198 -# define SSL_F_SSL_USE_CERTIFICATE_ASN1 199 -# define SSL_F_SSL_USE_CERTIFICATE_FILE 200 -# define SSL_F_SSL_USE_PRIVATEKEY 201 -# define SSL_F_SSL_USE_PRIVATEKEY_ASN1 202 -# define SSL_F_SSL_USE_PRIVATEKEY_FILE 203 -# define SSL_F_SSL_USE_PSK_IDENTITY_HINT 273 -# define SSL_F_SSL_USE_RSAPRIVATEKEY 204 -# define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 205 -# define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 206 -# define SSL_F_SSL_VALIDATE_CT 400 -# define SSL_F_SSL_VERIFY_CERT_CHAIN 207 -# define SSL_F_SSL_VERIFY_CLIENT_POST_HANDSHAKE 616 -# define SSL_F_SSL_WRITE 208 -# define SSL_F_SSL_WRITE_EARLY_DATA 526 -# define SSL_F_SSL_WRITE_EARLY_FINISH 527 -# define SSL_F_SSL_WRITE_EX 433 -# define SSL_F_SSL_WRITE_INTERNAL 524 -# define SSL_F_STATE_MACHINE 353 -# define SSL_F_TLS12_CHECK_PEER_SIGALG 333 -# define SSL_F_TLS12_COPY_SIGALGS 533 -# define SSL_F_TLS13_CHANGE_CIPHER_STATE 440 -# define SSL_F_TLS13_ENC 609 -# define SSL_F_TLS13_FINAL_FINISH_MAC 605 -# define SSL_F_TLS13_GENERATE_SECRET 591 -# define SSL_F_TLS13_HKDF_EXPAND 561 -# define SSL_F_TLS13_RESTORE_HANDSHAKE_DIGEST_FOR_PHA 617 -# define SSL_F_TLS13_SAVE_HANDSHAKE_DIGEST_FOR_PHA 618 -# define SSL_F_TLS13_SETUP_KEY_BLOCK 441 -# define SSL_F_TLS1_CHANGE_CIPHER_STATE 209 -# define SSL_F_TLS1_CHECK_DUPLICATE_EXTENSIONS 341 -# define SSL_F_TLS1_ENC 401 -# define SSL_F_TLS1_EXPORT_KEYING_MATERIAL 314 -# define SSL_F_TLS1_GET_CURVELIST 338 -# define SSL_F_TLS1_PRF 284 -# define SSL_F_TLS1_SAVE_U16 628 -# define SSL_F_TLS1_SETUP_KEY_BLOCK 211 -# define SSL_F_TLS1_SET_GROUPS 629 -# define SSL_F_TLS1_SET_RAW_SIGALGS 630 -# define SSL_F_TLS1_SET_SERVER_SIGALGS 335 -# define SSL_F_TLS1_SET_SHARED_SIGALGS 631 -# define SSL_F_TLS1_SET_SIGALGS 632 -# define SSL_F_TLS_CHOOSE_SIGALG 513 -# define SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK 354 -# define SSL_F_TLS_COLLECT_EXTENSIONS 435 -# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_AUTHORITIES 542 -# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST 372 -# define SSL_F_TLS_CONSTRUCT_CERT_STATUS 429 -# define SSL_F_TLS_CONSTRUCT_CERT_STATUS_BODY 494 -# define SSL_F_TLS_CONSTRUCT_CERT_VERIFY 496 -# define SSL_F_TLS_CONSTRUCT_CHANGE_CIPHER_SPEC 427 -# define SSL_F_TLS_CONSTRUCT_CKE_DHE 404 -# define SSL_F_TLS_CONSTRUCT_CKE_ECDHE 405 -# define SSL_F_TLS_CONSTRUCT_CKE_GOST 406 -# define SSL_F_TLS_CONSTRUCT_CKE_PSK_PREAMBLE 407 -# define SSL_F_TLS_CONSTRUCT_CKE_RSA 409 -# define SSL_F_TLS_CONSTRUCT_CKE_SRP 410 -# define SSL_F_TLS_CONSTRUCT_CLIENT_CERTIFICATE 484 -# define SSL_F_TLS_CONSTRUCT_CLIENT_HELLO 487 -# define SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE 488 -# define SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY 489 -# define SSL_F_TLS_CONSTRUCT_CTOS_ALPN 466 -# define SSL_F_TLS_CONSTRUCT_CTOS_CERTIFICATE 355 -# define SSL_F_TLS_CONSTRUCT_CTOS_COOKIE 535 -# define SSL_F_TLS_CONSTRUCT_CTOS_EARLY_DATA 530 -# define SSL_F_TLS_CONSTRUCT_CTOS_EC_PT_FORMATS 467 -# define SSL_F_TLS_CONSTRUCT_CTOS_EMS 468 -# define SSL_F_TLS_CONSTRUCT_CTOS_ETM 469 -# define SSL_F_TLS_CONSTRUCT_CTOS_HELLO 356 -# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_EXCHANGE 357 -# define SSL_F_TLS_CONSTRUCT_CTOS_KEY_SHARE 470 -# define SSL_F_TLS_CONSTRUCT_CTOS_MAXFRAGMENTLEN 549 -# define SSL_F_TLS_CONSTRUCT_CTOS_NPN 471 -# define SSL_F_TLS_CONSTRUCT_CTOS_PADDING 472 -# define SSL_F_TLS_CONSTRUCT_CTOS_POST_HANDSHAKE_AUTH 619 -# define SSL_F_TLS_CONSTRUCT_CTOS_PSK 501 -# define SSL_F_TLS_CONSTRUCT_CTOS_PSK_KEX_MODES 509 -# define SSL_F_TLS_CONSTRUCT_CTOS_RENEGOTIATE 473 -# define SSL_F_TLS_CONSTRUCT_CTOS_SCT 474 -# define SSL_F_TLS_CONSTRUCT_CTOS_SERVER_NAME 475 -# define SSL_F_TLS_CONSTRUCT_CTOS_SESSION_TICKET 476 -# define SSL_F_TLS_CONSTRUCT_CTOS_SIG_ALGS 477 -# define SSL_F_TLS_CONSTRUCT_CTOS_SRP 478 -# define SSL_F_TLS_CONSTRUCT_CTOS_STATUS_REQUEST 479 -# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_GROUPS 480 -# define SSL_F_TLS_CONSTRUCT_CTOS_SUPPORTED_VERSIONS 481 -# define SSL_F_TLS_CONSTRUCT_CTOS_USE_SRTP 482 -# define SSL_F_TLS_CONSTRUCT_CTOS_VERIFY 358 -# define SSL_F_TLS_CONSTRUCT_ENCRYPTED_EXTENSIONS 443 -# define SSL_F_TLS_CONSTRUCT_END_OF_EARLY_DATA 536 -# define SSL_F_TLS_CONSTRUCT_EXTENSIONS 447 -# define SSL_F_TLS_CONSTRUCT_FINISHED 359 -# define SSL_F_TLS_CONSTRUCT_HELLO_REQUEST 373 -# define SSL_F_TLS_CONSTRUCT_HELLO_RETRY_REQUEST 510 -# define SSL_F_TLS_CONSTRUCT_KEY_UPDATE 517 -# define SSL_F_TLS_CONSTRUCT_NEW_SESSION_TICKET 428 -# define SSL_F_TLS_CONSTRUCT_NEXT_PROTO 426 -# define SSL_F_TLS_CONSTRUCT_SERVER_CERTIFICATE 490 -# define SSL_F_TLS_CONSTRUCT_SERVER_HELLO 491 -# define SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE 492 -# define SSL_F_TLS_CONSTRUCT_STOC_ALPN 451 -# define SSL_F_TLS_CONSTRUCT_STOC_CERTIFICATE 374 -# define SSL_F_TLS_CONSTRUCT_STOC_COOKIE 613 -# define SSL_F_TLS_CONSTRUCT_STOC_CRYPTOPRO_BUG 452 -# define SSL_F_TLS_CONSTRUCT_STOC_DONE 375 -# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA 531 -# define SSL_F_TLS_CONSTRUCT_STOC_EARLY_DATA_INFO 525 -# define SSL_F_TLS_CONSTRUCT_STOC_EC_PT_FORMATS 453 -# define SSL_F_TLS_CONSTRUCT_STOC_EMS 454 -# define SSL_F_TLS_CONSTRUCT_STOC_ETM 455 -# define SSL_F_TLS_CONSTRUCT_STOC_HELLO 376 -# define SSL_F_TLS_CONSTRUCT_STOC_KEY_EXCHANGE 377 -# define SSL_F_TLS_CONSTRUCT_STOC_KEY_SHARE 456 -# define SSL_F_TLS_CONSTRUCT_STOC_MAXFRAGMENTLEN 548 -# define SSL_F_TLS_CONSTRUCT_STOC_NEXT_PROTO_NEG 457 -# define SSL_F_TLS_CONSTRUCT_STOC_PSK 504 -# define SSL_F_TLS_CONSTRUCT_STOC_RENEGOTIATE 458 -# define SSL_F_TLS_CONSTRUCT_STOC_SERVER_NAME 459 -# define SSL_F_TLS_CONSTRUCT_STOC_SESSION_TICKET 460 -# define SSL_F_TLS_CONSTRUCT_STOC_STATUS_REQUEST 461 -# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_GROUPS 544 -# define SSL_F_TLS_CONSTRUCT_STOC_SUPPORTED_VERSIONS 611 -# define SSL_F_TLS_CONSTRUCT_STOC_USE_SRTP 462 -# define SSL_F_TLS_EARLY_POST_PROCESS_CLIENT_HELLO 521 -# define SSL_F_TLS_FINISH_HANDSHAKE 597 -# define SSL_F_TLS_GET_MESSAGE_BODY 351 -# define SSL_F_TLS_GET_MESSAGE_HEADER 387 -# define SSL_F_TLS_HANDLE_ALPN 562 -# define SSL_F_TLS_HANDLE_STATUS_REQUEST 563 -# define SSL_F_TLS_PARSE_CERTIFICATE_AUTHORITIES 566 -# define SSL_F_TLS_PARSE_CLIENTHELLO_TLSEXT 449 -# define SSL_F_TLS_PARSE_CTOS_ALPN 567 -# define SSL_F_TLS_PARSE_CTOS_COOKIE 614 -# define SSL_F_TLS_PARSE_CTOS_EARLY_DATA 568 -# define SSL_F_TLS_PARSE_CTOS_EC_PT_FORMATS 569 -# define SSL_F_TLS_PARSE_CTOS_EMS 570 -# define SSL_F_TLS_PARSE_CTOS_KEY_SHARE 463 -# define SSL_F_TLS_PARSE_CTOS_MAXFRAGMENTLEN 571 -# define SSL_F_TLS_PARSE_CTOS_POST_HANDSHAKE_AUTH 620 -# define SSL_F_TLS_PARSE_CTOS_PSK 505 -# define SSL_F_TLS_PARSE_CTOS_PSK_KEX_MODES 572 -# define SSL_F_TLS_PARSE_CTOS_RENEGOTIATE 464 -# define SSL_F_TLS_PARSE_CTOS_SERVER_NAME 573 -# define SSL_F_TLS_PARSE_CTOS_SESSION_TICKET 574 -# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS 575 -# define SSL_F_TLS_PARSE_CTOS_SIG_ALGS_CERT 615 -# define SSL_F_TLS_PARSE_CTOS_SRP 576 -# define SSL_F_TLS_PARSE_CTOS_STATUS_REQUEST 577 -# define SSL_F_TLS_PARSE_CTOS_SUPPORTED_GROUPS 578 -# define SSL_F_TLS_PARSE_CTOS_USE_SRTP 465 -# define SSL_F_TLS_PARSE_STOC_ALPN 579 -# define SSL_F_TLS_PARSE_STOC_COOKIE 534 -# define SSL_F_TLS_PARSE_STOC_EARLY_DATA 538 -# define SSL_F_TLS_PARSE_STOC_EARLY_DATA_INFO 528 -# define SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS 580 -# define SSL_F_TLS_PARSE_STOC_KEY_SHARE 445 -# define SSL_F_TLS_PARSE_STOC_MAXFRAGMENTLEN 581 -# define SSL_F_TLS_PARSE_STOC_NPN 582 -# define SSL_F_TLS_PARSE_STOC_PSK 502 -# define SSL_F_TLS_PARSE_STOC_RENEGOTIATE 448 -# define SSL_F_TLS_PARSE_STOC_SCT 564 -# define SSL_F_TLS_PARSE_STOC_SERVER_NAME 583 -# define SSL_F_TLS_PARSE_STOC_SESSION_TICKET 584 -# define SSL_F_TLS_PARSE_STOC_STATUS_REQUEST 585 -# define SSL_F_TLS_PARSE_STOC_SUPPORTED_VERSIONS 612 -# define SSL_F_TLS_PARSE_STOC_USE_SRTP 446 -# define SSL_F_TLS_POST_PROCESS_CLIENT_HELLO 378 -# define SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE 384 -# define SSL_F_TLS_PREPARE_CLIENT_CERTIFICATE 360 -# define SSL_F_TLS_PROCESS_AS_HELLO_RETRY_REQUEST 610 -# define SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST 361 -# define SSL_F_TLS_PROCESS_CERT_STATUS 362 -# define SSL_F_TLS_PROCESS_CERT_STATUS_BODY 495 -# define SSL_F_TLS_PROCESS_CERT_VERIFY 379 -# define SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC 363 -# define SSL_F_TLS_PROCESS_CKE_DHE 411 -# define SSL_F_TLS_PROCESS_CKE_ECDHE 412 -# define SSL_F_TLS_PROCESS_CKE_GOST 413 -# define SSL_F_TLS_PROCESS_CKE_PSK_PREAMBLE 414 -# define SSL_F_TLS_PROCESS_CKE_RSA 415 -# define SSL_F_TLS_PROCESS_CKE_SRP 416 -# define SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE 380 -# define SSL_F_TLS_PROCESS_CLIENT_HELLO 381 -# define SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE 382 -# define SSL_F_TLS_PROCESS_ENCRYPTED_EXTENSIONS 444 -# define SSL_F_TLS_PROCESS_END_OF_EARLY_DATA 537 -# define SSL_F_TLS_PROCESS_FINISHED 364 -# define SSL_F_TLS_PROCESS_HELLO_REQ 507 -# define SSL_F_TLS_PROCESS_HELLO_RETRY_REQUEST 511 -# define SSL_F_TLS_PROCESS_INITIAL_SERVER_FLIGHT 442 -# define SSL_F_TLS_PROCESS_KEY_EXCHANGE 365 -# define SSL_F_TLS_PROCESS_KEY_UPDATE 518 -# define SSL_F_TLS_PROCESS_NEW_SESSION_TICKET 366 -# define SSL_F_TLS_PROCESS_NEXT_PROTO 383 -# define SSL_F_TLS_PROCESS_SERVER_CERTIFICATE 367 -# define SSL_F_TLS_PROCESS_SERVER_DONE 368 -# define SSL_F_TLS_PROCESS_SERVER_HELLO 369 -# define SSL_F_TLS_PROCESS_SKE_DHE 419 -# define SSL_F_TLS_PROCESS_SKE_ECDHE 420 -# define SSL_F_TLS_PROCESS_SKE_PSK_PREAMBLE 421 -# define SSL_F_TLS_PROCESS_SKE_SRP 422 -# define SSL_F_TLS_PSK_DO_BINDER 506 -# define SSL_F_TLS_SCAN_CLIENTHELLO_TLSEXT 450 -# define SSL_F_TLS_SETUP_HANDSHAKE 508 -# define SSL_F_USE_CERTIFICATE_CHAIN_FILE 220 -# define SSL_F_WPACKET_INTERN_INIT_LEN 633 -# define SSL_F_WPACKET_START_SUB_PACKET_LEN__ 634 -# define SSL_F_WRITE_STATE_MACHINE 586 - -/* - * SSL reason codes. - */ -# define SSL_R_APPLICATION_DATA_AFTER_CLOSE_NOTIFY 291 -# define SSL_R_APP_DATA_IN_HANDSHAKE 100 -# define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272 -# define SSL_R_AT_LEAST_TLS_1_0_NEEDED_IN_FIPS_MODE 143 -# define SSL_R_AT_LEAST_TLS_1_2_NEEDED_IN_SUITEB_MODE 158 -# define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 -# define SSL_R_BAD_CIPHER 186 -# define SSL_R_BAD_DATA 390 -# define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 -# define SSL_R_BAD_DECOMPRESSION 107 -# define SSL_R_BAD_DH_VALUE 102 -# define SSL_R_BAD_DIGEST_LENGTH 111 -# define SSL_R_BAD_EARLY_DATA 233 -# define SSL_R_BAD_ECC_CERT 304 -# define SSL_R_BAD_ECPOINT 306 -# define SSL_R_BAD_EXTENSION 110 -# define SSL_R_BAD_HANDSHAKE_LENGTH 332 -# define SSL_R_BAD_HANDSHAKE_STATE 236 -# define SSL_R_BAD_HELLO_REQUEST 105 -# define SSL_R_BAD_HRR_VERSION 263 -# define SSL_R_BAD_KEY_SHARE 108 -# define SSL_R_BAD_KEY_UPDATE 122 -# define SSL_R_BAD_LEGACY_VERSION 292 -# define SSL_R_BAD_LENGTH 271 -# define SSL_R_BAD_PACKET 240 -# define SSL_R_BAD_PACKET_LENGTH 115 -# define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116 -# define SSL_R_BAD_PSK 219 -# define SSL_R_BAD_PSK_IDENTITY 114 -# define SSL_R_BAD_RECORD_TYPE 443 -# define SSL_R_BAD_RSA_ENCRYPT 119 -# define SSL_R_BAD_SIGNATURE 123 -# define SSL_R_BAD_SRP_A_LENGTH 347 -# define SSL_R_BAD_SRP_PARAMETERS 371 -# define SSL_R_BAD_SRTP_MKI_VALUE 352 -# define SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST 353 -# define SSL_R_BAD_SSL_FILETYPE 124 -# define SSL_R_BAD_VALUE 384 -# define SSL_R_BAD_WRITE_RETRY 127 -# define SSL_R_BINDER_DOES_NOT_VERIFY 253 -# define SSL_R_BIO_NOT_SET 128 -# define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129 -# define SSL_R_BN_LIB 130 -# define SSL_R_CALLBACK_FAILED 234 -# define SSL_R_CANNOT_CHANGE_CIPHER 109 -# define SSL_R_CA_DN_LENGTH_MISMATCH 131 -# define SSL_R_CA_KEY_TOO_SMALL 397 -# define SSL_R_CA_MD_TOO_WEAK 398 -# define SSL_R_CCS_RECEIVED_EARLY 133 -# define SSL_R_CERTIFICATE_VERIFY_FAILED 134 -# define SSL_R_CERT_CB_ERROR 377 -# define SSL_R_CERT_LENGTH_MISMATCH 135 -# define SSL_R_CIPHERSUITE_DIGEST_HAS_CHANGED 218 -# define SSL_R_CIPHER_CODE_WRONG_LENGTH 137 -# define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 138 -# define SSL_R_CLIENTHELLO_TLSEXT 226 -# define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140 -# define SSL_R_COMPRESSION_DISABLED 343 -# define SSL_R_COMPRESSION_FAILURE 141 -# define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE 307 -# define SSL_R_COMPRESSION_LIBRARY_ERROR 142 -# define SSL_R_CONNECTION_TYPE_NOT_SET 144 -# define SSL_R_CONTEXT_NOT_DANE_ENABLED 167 -# define SSL_R_COOKIE_GEN_CALLBACK_FAILURE 400 -# define SSL_R_COOKIE_MISMATCH 308 -# define SSL_R_CUSTOM_EXT_HANDLER_ALREADY_INSTALLED 206 -# define SSL_R_DANE_ALREADY_ENABLED 172 -# define SSL_R_DANE_CANNOT_OVERRIDE_MTYPE_FULL 173 -# define SSL_R_DANE_NOT_ENABLED 175 -# define SSL_R_DANE_TLSA_BAD_CERTIFICATE 180 -# define SSL_R_DANE_TLSA_BAD_CERTIFICATE_USAGE 184 -# define SSL_R_DANE_TLSA_BAD_DATA_LENGTH 189 -# define SSL_R_DANE_TLSA_BAD_DIGEST_LENGTH 192 -# define SSL_R_DANE_TLSA_BAD_MATCHING_TYPE 200 -# define SSL_R_DANE_TLSA_BAD_PUBLIC_KEY 201 -# define SSL_R_DANE_TLSA_BAD_SELECTOR 202 -# define SSL_R_DANE_TLSA_NULL_DATA 203 -# define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145 -# define SSL_R_DATA_LENGTH_TOO_LONG 146 -# define SSL_R_DECRYPTION_FAILED 147 -# define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 281 -# define SSL_R_DH_KEY_TOO_SMALL 394 -# define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 -# define SSL_R_DIGEST_CHECK_FAILED 149 -# define SSL_R_DTLS_MESSAGE_TOO_BIG 334 -# define SSL_R_DUPLICATE_COMPRESSION_ID 309 -# define SSL_R_ECC_CERT_NOT_FOR_SIGNING 318 -# define SSL_R_ECDH_REQUIRED_FOR_SUITEB_MODE 374 -# define SSL_R_EE_KEY_TOO_SMALL 399 -# define SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST 354 -# define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 -# define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151 -# define SSL_R_ERROR_SETTING_TLSA_BASE_DOMAIN 204 -# define SSL_R_EXCEEDS_MAX_FRAGMENT_SIZE 194 -# define SSL_R_EXCESSIVE_MESSAGE_SIZE 152 -# define SSL_R_EXTENSION_NOT_RECEIVED 279 -# define SSL_R_EXTRA_DATA_IN_MESSAGE 153 -# define SSL_R_EXT_LENGTH_MISMATCH 163 -# define SSL_R_FAILED_TO_INIT_ASYNC 405 -# define SSL_R_FRAGMENTED_CLIENT_HELLO 401 -# define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154 -# define SSL_R_HTTPS_PROXY_REQUEST 155 -# define SSL_R_HTTP_REQUEST 156 -# define SSL_R_ILLEGAL_POINT_COMPRESSION 162 -# define SSL_R_ILLEGAL_SUITEB_DIGEST 380 -# define SSL_R_INAPPROPRIATE_FALLBACK 373 -# define SSL_R_INCONSISTENT_COMPRESSION 340 -# define SSL_R_INCONSISTENT_EARLY_DATA_ALPN 222 -# define SSL_R_INCONSISTENT_EARLY_DATA_SNI 231 -# define SSL_R_INCONSISTENT_EXTMS 104 -# define SSL_R_INSUFFICIENT_SECURITY 241 -# define SSL_R_INVALID_ALERT 205 -# define SSL_R_INVALID_CCS_MESSAGE 260 -# define SSL_R_INVALID_CERTIFICATE_OR_ALG 238 -# define SSL_R_INVALID_COMMAND 280 -# define SSL_R_INVALID_COMPRESSION_ALGORITHM 341 -# define SSL_R_INVALID_CONFIG 283 -# define SSL_R_INVALID_CONFIGURATION_NAME 113 -# define SSL_R_INVALID_CONTEXT 282 -# define SSL_R_INVALID_CT_VALIDATION_TYPE 212 -# define SSL_R_INVALID_KEY_UPDATE_TYPE 120 -# define SSL_R_INVALID_MAX_EARLY_DATA 174 -# define SSL_R_INVALID_NULL_CMD_NAME 385 -# define SSL_R_INVALID_SEQUENCE_NUMBER 402 -# define SSL_R_INVALID_SERVERINFO_DATA 388 -# define SSL_R_INVALID_SESSION_ID 999 -# define SSL_R_INVALID_SRP_USERNAME 357 -# define SSL_R_INVALID_STATUS_RESPONSE 328 -# define SSL_R_INVALID_TICKET_KEYS_LENGTH 325 -# define SSL_R_LENGTH_MISMATCH 159 -# define SSL_R_LENGTH_TOO_LONG 404 -# define SSL_R_LENGTH_TOO_SHORT 160 -# define SSL_R_LIBRARY_BUG 274 -# define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 -# define SSL_R_MISSING_DSA_SIGNING_CERT 165 -# define SSL_R_MISSING_ECDSA_SIGNING_CERT 381 -# define SSL_R_MISSING_FATAL 256 -# define SSL_R_MISSING_PARAMETERS 290 -# define SSL_R_MISSING_PSK_KEX_MODES_EXTENSION 310 -# define SSL_R_MISSING_RSA_CERTIFICATE 168 -# define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169 -# define SSL_R_MISSING_RSA_SIGNING_CERT 170 -# define SSL_R_MISSING_SIGALGS_EXTENSION 112 -# define SSL_R_MISSING_SIGNING_CERT 221 -# define SSL_R_MISSING_SRP_PARAM 358 -# define SSL_R_MISSING_SUPPORTED_GROUPS_EXTENSION 209 -# define SSL_R_MISSING_TMP_DH_KEY 171 -# define SSL_R_MISSING_TMP_ECDH_KEY 311 -# define SSL_R_MIXED_HANDSHAKE_AND_NON_HANDSHAKE_DATA 293 -# define SSL_R_NOT_ON_RECORD_BOUNDARY 182 -# define SSL_R_NOT_REPLACING_CERTIFICATE 289 -# define SSL_R_NOT_SERVER 284 -# define SSL_R_NO_APPLICATION_PROTOCOL 235 -# define SSL_R_NO_CERTIFICATES_RETURNED 176 -# define SSL_R_NO_CERTIFICATE_ASSIGNED 177 -# define SSL_R_NO_CERTIFICATE_SET 179 -# define SSL_R_NO_CHANGE_FOLLOWING_HRR 214 -# define SSL_R_NO_CIPHERS_AVAILABLE 181 -# define SSL_R_NO_CIPHERS_SPECIFIED 183 -# define SSL_R_NO_CIPHER_MATCH 185 -# define SSL_R_NO_CLIENT_CERT_METHOD 331 -# define SSL_R_NO_COMPRESSION_SPECIFIED 187 -# define SSL_R_NO_COOKIE_CALLBACK_SET 287 -# define SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER 330 -# define SSL_R_NO_METHOD_SPECIFIED 188 -# define SSL_R_NO_PEM_EXTENSIONS 389 -# define SSL_R_NO_PRIVATE_KEY_ASSIGNED 190 -# define SSL_R_NO_PROTOCOLS_AVAILABLE 191 -# define SSL_R_NO_RENEGOTIATION 339 -# define SSL_R_NO_REQUIRED_DIGEST 324 -# define SSL_R_NO_SHARED_CIPHER 193 -# define SSL_R_NO_SHARED_GROUPS 410 -# define SSL_R_NO_SHARED_SIGNATURE_ALGORITHMS 376 -# define SSL_R_NO_SRTP_PROFILES 359 -# define SSL_R_NO_SUITABLE_KEY_SHARE 101 -# define SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM 118 -# define SSL_R_NO_VALID_SCTS 216 -# define SSL_R_NO_VERIFY_COOKIE_CALLBACK 403 -# define SSL_R_NULL_SSL_CTX 195 -# define SSL_R_NULL_SSL_METHOD_PASSED 196 -# define SSL_R_OCSP_CALLBACK_FAILURE 294 -# define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 197 -# define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344 -# define SSL_R_OVERFLOW_ERROR 237 -# define SSL_R_PACKET_LENGTH_TOO_LONG 198 -# define SSL_R_PARSE_TLSEXT 227 -# define SSL_R_PATH_TOO_LONG 270 -# define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 199 -# define SSL_R_PEM_NAME_BAD_PREFIX 391 -# define SSL_R_PEM_NAME_TOO_SHORT 392 -# define SSL_R_PIPELINE_FAILURE 406 -# define SSL_R_POST_HANDSHAKE_AUTH_ENCODING_ERR 278 -# define SSL_R_PRIVATE_KEY_MISMATCH 288 -# define SSL_R_PROTOCOL_IS_SHUTDOWN 207 -# define SSL_R_PSK_IDENTITY_NOT_FOUND 223 -# define SSL_R_PSK_NO_CLIENT_CB 224 -# define SSL_R_PSK_NO_SERVER_CB 225 -# define SSL_R_READ_BIO_NOT_SET 211 -# define SSL_R_READ_TIMEOUT_EXPIRED 312 -# define SSL_R_RECORD_LENGTH_MISMATCH 213 -# define SSL_R_RECORD_TOO_SMALL 298 -# define SSL_R_RENEGOTIATE_EXT_TOO_LONG 335 -# define SSL_R_RENEGOTIATION_ENCODING_ERR 336 -# define SSL_R_RENEGOTIATION_MISMATCH 337 -# define SSL_R_REQUEST_PENDING 285 -# define SSL_R_REQUEST_SENT 286 -# define SSL_R_REQUIRED_CIPHER_MISSING 215 -# define SSL_R_REQUIRED_COMPRESSION_ALGORITHM_MISSING 342 -# define SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING 345 -# define SSL_R_SCT_VERIFICATION_FAILED 208 -# define SSL_R_SERVERHELLO_TLSEXT 275 -# define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 277 -# define SSL_R_SHUTDOWN_WHILE_IN_INIT 407 -# define SSL_R_SIGNATURE_ALGORITHMS_ERROR 360 -# define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220 -# define SSL_R_SRP_A_CALC 361 -# define SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES 362 -# define SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG 363 -# define SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE 364 -# define SSL_R_SSL3_EXT_INVALID_MAX_FRAGMENT_LENGTH 232 -# define SSL_R_SSL3_EXT_INVALID_SERVERNAME 319 -# define SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE 320 -# define SSL_R_SSL3_SESSION_ID_TOO_LONG 300 -# define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 -# define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 -# define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 -# define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 -# define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 -# define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 -# define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 -# define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 -# define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 -# define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 -# define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 -# define SSL_R_SSL_COMMAND_SECTION_EMPTY 117 -# define SSL_R_SSL_COMMAND_SECTION_NOT_FOUND 125 -# define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228 -# define SSL_R_SSL_HANDSHAKE_FAILURE 229 -# define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230 -# define SSL_R_SSL_NEGATIVE_LENGTH 372 -# define SSL_R_SSL_SECTION_EMPTY 126 -# define SSL_R_SSL_SECTION_NOT_FOUND 136 -# define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 301 -# define SSL_R_SSL_SESSION_ID_CONFLICT 302 -# define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273 -# define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 303 -# define SSL_R_SSL_SESSION_ID_TOO_LONG 408 -# define SSL_R_SSL_SESSION_VERSION_MISMATCH 210 -# define SSL_R_STILL_IN_INIT 121 -# define SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED 1116 -# define SSL_R_TLSV13_ALERT_MISSING_EXTENSION 1109 -# define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 -# define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 -# define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 -# define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 -# define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 -# define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086 -# define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 -# define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 -# define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 -# define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 -# define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 -# define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 -# define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 -# define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE 1114 -# define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE 1113 -# define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE 1111 -# define SSL_R_TLSV1_UNRECOGNIZED_NAME 1112 -# define SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110 -# define SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT 365 -# define SSL_R_TLS_HEARTBEAT_PENDING 366 -# define SSL_R_TLS_ILLEGAL_EXPORTER_LABEL 367 -# define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST 157 -# define SSL_R_TOO_MANY_KEY_UPDATES 132 -# define SSL_R_TOO_MANY_WARN_ALERTS 409 -# define SSL_R_TOO_MUCH_EARLY_DATA 164 -# define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS 314 -# define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 239 -# define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 242 -# define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 243 -# define SSL_R_UNEXPECTED_CCS_MESSAGE 262 -# define SSL_R_UNEXPECTED_END_OF_EARLY_DATA 178 -# define SSL_R_UNEXPECTED_MESSAGE 244 -# define SSL_R_UNEXPECTED_RECORD 245 -# define SSL_R_UNINITIALIZED 276 -# define SSL_R_UNKNOWN_ALERT_TYPE 246 -# define SSL_R_UNKNOWN_CERTIFICATE_TYPE 247 -# define SSL_R_UNKNOWN_CIPHER_RETURNED 248 -# define SSL_R_UNKNOWN_CIPHER_TYPE 249 -# define SSL_R_UNKNOWN_CMD_NAME 386 -# define SSL_R_UNKNOWN_COMMAND 139 -# define SSL_R_UNKNOWN_DIGEST 368 -# define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 250 -# define SSL_R_UNKNOWN_PKEY_TYPE 251 -# define SSL_R_UNKNOWN_PROTOCOL 252 -# define SSL_R_UNKNOWN_SSL_VERSION 254 -# define SSL_R_UNKNOWN_STATE 255 -# define SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED 338 -# define SSL_R_UNSOLICITED_EXTENSION 217 -# define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 -# define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE 315 -# define SSL_R_UNSUPPORTED_PROTOCOL 258 -# define SSL_R_UNSUPPORTED_SSL_VERSION 259 -# define SSL_R_UNSUPPORTED_STATUS_TYPE 329 -# define SSL_R_USE_SRTP_NOT_NEGOTIATED 369 -# define SSL_R_VERSION_TOO_HIGH 166 -# define SSL_R_VERSION_TOO_LOW 396 -# define SSL_R_WRONG_CERTIFICATE_TYPE 383 -# define SSL_R_WRONG_CIPHER_RETURNED 261 -# define SSL_R_WRONG_CURVE 378 -# define SSL_R_WRONG_SIGNATURE_LENGTH 264 -# define SSL_R_WRONG_SIGNATURE_SIZE 265 -# define SSL_R_WRONG_SIGNATURE_TYPE 370 -# define SSL_R_WRONG_SSL_VERSION 266 -# define SSL_R_WRONG_VERSION_NUMBER 267 -# define SSL_R_X509_LIB 268 -# define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 269 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/stack.h b/client/3rd/OpenSSL/include/openssl/stack.h deleted file mode 100644 index cfc07505..00000000 --- a/client/3rd/OpenSSL/include/openssl/stack.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_STACK_H -# define HEADER_STACK_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct stack_st OPENSSL_STACK; /* Use STACK_OF(...) instead */ - -typedef int (*OPENSSL_sk_compfunc)(const void *, const void *); -typedef void (*OPENSSL_sk_freefunc)(void *); -typedef void *(*OPENSSL_sk_copyfunc)(const void *); - -int OPENSSL_sk_num(const OPENSSL_STACK *); -void *OPENSSL_sk_value(const OPENSSL_STACK *, int); - -void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data); - -OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc cmp); -OPENSSL_STACK *OPENSSL_sk_new_null(void); -OPENSSL_STACK *OPENSSL_sk_new_reserve(OPENSSL_sk_compfunc c, int n); -int OPENSSL_sk_reserve(OPENSSL_STACK *st, int n); -void OPENSSL_sk_free(OPENSSL_STACK *); -void OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *)); -OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *, - OPENSSL_sk_copyfunc c, - OPENSSL_sk_freefunc f); -int OPENSSL_sk_insert(OPENSSL_STACK *sk, const void *data, int where); -void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc); -void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p); -int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data); -int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data); -int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data); -int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data); -void *OPENSSL_sk_shift(OPENSSL_STACK *st); -void *OPENSSL_sk_pop(OPENSSL_STACK *st); -void OPENSSL_sk_zero(OPENSSL_STACK *st); -OPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, - OPENSSL_sk_compfunc cmp); -OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st); -void OPENSSL_sk_sort(OPENSSL_STACK *st); -int OPENSSL_sk_is_sorted(const OPENSSL_STACK *st); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define _STACK OPENSSL_STACK -# define sk_num OPENSSL_sk_num -# define sk_value OPENSSL_sk_value -# define sk_set OPENSSL_sk_set -# define sk_new OPENSSL_sk_new -# define sk_new_null OPENSSL_sk_new_null -# define sk_free OPENSSL_sk_free -# define sk_pop_free OPENSSL_sk_pop_free -# define sk_deep_copy OPENSSL_sk_deep_copy -# define sk_insert OPENSSL_sk_insert -# define sk_delete OPENSSL_sk_delete -# define sk_delete_ptr OPENSSL_sk_delete_ptr -# define sk_find OPENSSL_sk_find -# define sk_find_ex OPENSSL_sk_find_ex -# define sk_push OPENSSL_sk_push -# define sk_unshift OPENSSL_sk_unshift -# define sk_shift OPENSSL_sk_shift -# define sk_pop OPENSSL_sk_pop -# define sk_zero OPENSSL_sk_zero -# define sk_set_cmp_func OPENSSL_sk_set_cmp_func -# define sk_dup OPENSSL_sk_dup -# define sk_sort OPENSSL_sk_sort -# define sk_is_sorted OPENSSL_sk_is_sorted -# endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/store.h b/client/3rd/OpenSSL/include/openssl/store.h deleted file mode 100644 index a40a7339..00000000 --- a/client/3rd/OpenSSL/include/openssl/store.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OSSL_STORE_H -# define HEADER_OSSL_STORE_H - -# include -# include -# include -# include - -# ifdef __cplusplus -extern "C" { -# endif - -/*- - * The main OSSL_STORE functions. - * ------------------------------ - * - * These allow applications to open a channel to a resource with supported - * data (keys, certs, crls, ...), read the data a piece at a time and decide - * what to do with it, and finally close. - */ - -typedef struct ossl_store_ctx_st OSSL_STORE_CTX; - -/* - * Typedef for the OSSL_STORE_INFO post processing callback. This can be used - * to massage the given OSSL_STORE_INFO, or to drop it entirely (by returning - * NULL). - */ -typedef OSSL_STORE_INFO *(*OSSL_STORE_post_process_info_fn)(OSSL_STORE_INFO *, - void *); - -/* - * Open a channel given a URI. The given UI method will be used any time the - * loader needs extra input, for example when a password or pin is needed, and - * will be passed the same user data every time it's needed in this context. - * - * Returns a context reference which represents the channel to communicate - * through. - */ -OSSL_STORE_CTX *OSSL_STORE_open(const char *uri, const UI_METHOD *ui_method, - void *ui_data, - OSSL_STORE_post_process_info_fn post_process, - void *post_process_data); - -/* - * Control / fine tune the OSSL_STORE channel. |cmd| determines what is to be - * done, and depends on the underlying loader (use OSSL_STORE_get0_scheme to - * determine which loader is used), except for common commands (see below). - * Each command takes different arguments. - */ -int OSSL_STORE_ctrl(OSSL_STORE_CTX *ctx, int cmd, ... /* args */); -int OSSL_STORE_vctrl(OSSL_STORE_CTX *ctx, int cmd, va_list args); - -/* - * Common ctrl commands that different loaders may choose to support. - */ -/* int on = 0 or 1; STORE_ctrl(ctx, STORE_C_USE_SECMEM, &on); */ -# define OSSL_STORE_C_USE_SECMEM 1 -/* Where custom commands start */ -# define OSSL_STORE_C_CUSTOM_START 100 - -/* - * Read one data item (a key, a cert, a CRL) that is supported by the OSSL_STORE - * functionality, given a context. - * Returns a OSSL_STORE_INFO pointer, from which OpenSSL typed data can be - * extracted with OSSL_STORE_INFO_get0_PKEY(), OSSL_STORE_INFO_get0_CERT(), ... - * NULL is returned on error, which may include that the data found at the URI - * can't be figured out for certain or is ambiguous. - */ -OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx); - -/* - * Check if end of data (end of file) is reached - * Returns 1 on end, 0 otherwise. - */ -int OSSL_STORE_eof(OSSL_STORE_CTX *ctx); - -/* - * Check if an error occurred - * Returns 1 if it did, 0 otherwise. - */ -int OSSL_STORE_error(OSSL_STORE_CTX *ctx); - -/* - * Close the channel - * Returns 1 on success, 0 on error. - */ -int OSSL_STORE_close(OSSL_STORE_CTX *ctx); - - -/*- - * Extracting OpenSSL types from and creating new OSSL_STORE_INFOs - * --------------------------------------------------------------- - */ - -/* - * Types of data that can be ossl_stored in a OSSL_STORE_INFO. - * OSSL_STORE_INFO_NAME is typically found when getting a listing of - * available "files" / "tokens" / what have you. - */ -# define OSSL_STORE_INFO_NAME 1 /* char * */ -# define OSSL_STORE_INFO_PARAMS 2 /* EVP_PKEY * */ -# define OSSL_STORE_INFO_PKEY 3 /* EVP_PKEY * */ -# define OSSL_STORE_INFO_CERT 4 /* X509 * */ -# define OSSL_STORE_INFO_CRL 5 /* X509_CRL * */ - -/* - * Functions to generate OSSL_STORE_INFOs, one function for each type we - * support having in them, as well as a generic constructor. - * - * In all cases, ownership of the object is transferred to the OSSL_STORE_INFO - * and will therefore be freed when the OSSL_STORE_INFO is freed. - */ -OSSL_STORE_INFO *OSSL_STORE_INFO_new_NAME(char *name); -int OSSL_STORE_INFO_set0_NAME_description(OSSL_STORE_INFO *info, char *desc); -OSSL_STORE_INFO *OSSL_STORE_INFO_new_PARAMS(EVP_PKEY *params); -OSSL_STORE_INFO *OSSL_STORE_INFO_new_PKEY(EVP_PKEY *pkey); -OSSL_STORE_INFO *OSSL_STORE_INFO_new_CERT(X509 *x509); -OSSL_STORE_INFO *OSSL_STORE_INFO_new_CRL(X509_CRL *crl); - -/* - * Functions to try to extract data from a OSSL_STORE_INFO. - */ -int OSSL_STORE_INFO_get_type(const OSSL_STORE_INFO *info); -const char *OSSL_STORE_INFO_get0_NAME(const OSSL_STORE_INFO *info); -char *OSSL_STORE_INFO_get1_NAME(const OSSL_STORE_INFO *info); -const char *OSSL_STORE_INFO_get0_NAME_description(const OSSL_STORE_INFO *info); -char *OSSL_STORE_INFO_get1_NAME_description(const OSSL_STORE_INFO *info); -EVP_PKEY *OSSL_STORE_INFO_get0_PARAMS(const OSSL_STORE_INFO *info); -EVP_PKEY *OSSL_STORE_INFO_get1_PARAMS(const OSSL_STORE_INFO *info); -EVP_PKEY *OSSL_STORE_INFO_get0_PKEY(const OSSL_STORE_INFO *info); -EVP_PKEY *OSSL_STORE_INFO_get1_PKEY(const OSSL_STORE_INFO *info); -X509 *OSSL_STORE_INFO_get0_CERT(const OSSL_STORE_INFO *info); -X509 *OSSL_STORE_INFO_get1_CERT(const OSSL_STORE_INFO *info); -X509_CRL *OSSL_STORE_INFO_get0_CRL(const OSSL_STORE_INFO *info); -X509_CRL *OSSL_STORE_INFO_get1_CRL(const OSSL_STORE_INFO *info); - -const char *OSSL_STORE_INFO_type_string(int type); - -/* - * Free the OSSL_STORE_INFO - */ -void OSSL_STORE_INFO_free(OSSL_STORE_INFO *info); - - -/*- - * Functions to construct a search URI from a base URI and search criteria - * ----------------------------------------------------------------------- - */ - -/* OSSL_STORE search types */ -# define OSSL_STORE_SEARCH_BY_NAME 1 /* subject in certs, issuer in CRLs */ -# define OSSL_STORE_SEARCH_BY_ISSUER_SERIAL 2 -# define OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT 3 -# define OSSL_STORE_SEARCH_BY_ALIAS 4 - -/* To check what search types the scheme handler supports */ -int OSSL_STORE_supports_search(OSSL_STORE_CTX *ctx, int search_type); - -/* Search term constructors */ -/* - * The input is considered to be owned by the caller, and must therefore - * remain present throughout the lifetime of the returned OSSL_STORE_SEARCH - */ -OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_name(X509_NAME *name); -OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_issuer_serial(X509_NAME *name, - const ASN1_INTEGER - *serial); -OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_key_fingerprint(const EVP_MD *digest, - const unsigned char - *bytes, size_t len); -OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_alias(const char *alias); - -/* Search term destructor */ -void OSSL_STORE_SEARCH_free(OSSL_STORE_SEARCH *search); - -/* Search term accessors */ -int OSSL_STORE_SEARCH_get_type(const OSSL_STORE_SEARCH *criterion); -X509_NAME *OSSL_STORE_SEARCH_get0_name(OSSL_STORE_SEARCH *criterion); -const ASN1_INTEGER *OSSL_STORE_SEARCH_get0_serial(const OSSL_STORE_SEARCH - *criterion); -const unsigned char *OSSL_STORE_SEARCH_get0_bytes(const OSSL_STORE_SEARCH - *criterion, size_t *length); -const char *OSSL_STORE_SEARCH_get0_string(const OSSL_STORE_SEARCH *criterion); -const EVP_MD *OSSL_STORE_SEARCH_get0_digest(const OSSL_STORE_SEARCH *criterion); - -/* - * Add search criterion and expected return type (which can be unspecified) - * to the loading channel. This MUST happen before the first OSSL_STORE_load(). - */ -int OSSL_STORE_expect(OSSL_STORE_CTX *ctx, int expected_type); -int OSSL_STORE_find(OSSL_STORE_CTX *ctx, OSSL_STORE_SEARCH *search); - - -/*- - * Function to register a loader for the given URI scheme. - * ------------------------------------------------------- - * - * The loader receives all the main components of an URI except for the - * scheme. - */ - -typedef struct ossl_store_loader_st OSSL_STORE_LOADER; -OSSL_STORE_LOADER *OSSL_STORE_LOADER_new(ENGINE *e, const char *scheme); -const ENGINE *OSSL_STORE_LOADER_get0_engine(const OSSL_STORE_LOADER *loader); -const char *OSSL_STORE_LOADER_get0_scheme(const OSSL_STORE_LOADER *loader); -/* struct ossl_store_loader_ctx_st is defined differently by each loader */ -typedef struct ossl_store_loader_ctx_st OSSL_STORE_LOADER_CTX; -typedef OSSL_STORE_LOADER_CTX *(*OSSL_STORE_open_fn)(const OSSL_STORE_LOADER - *loader, - const char *uri, - const UI_METHOD *ui_method, - void *ui_data); -int OSSL_STORE_LOADER_set_open(OSSL_STORE_LOADER *loader, - OSSL_STORE_open_fn open_function); -typedef int (*OSSL_STORE_ctrl_fn)(OSSL_STORE_LOADER_CTX *ctx, int cmd, - va_list args); -int OSSL_STORE_LOADER_set_ctrl(OSSL_STORE_LOADER *loader, - OSSL_STORE_ctrl_fn ctrl_function); -typedef int (*OSSL_STORE_expect_fn)(OSSL_STORE_LOADER_CTX *ctx, int expected); -int OSSL_STORE_LOADER_set_expect(OSSL_STORE_LOADER *loader, - OSSL_STORE_expect_fn expect_function); -typedef int (*OSSL_STORE_find_fn)(OSSL_STORE_LOADER_CTX *ctx, - OSSL_STORE_SEARCH *criteria); -int OSSL_STORE_LOADER_set_find(OSSL_STORE_LOADER *loader, - OSSL_STORE_find_fn find_function); -typedef OSSL_STORE_INFO *(*OSSL_STORE_load_fn)(OSSL_STORE_LOADER_CTX *ctx, - const UI_METHOD *ui_method, - void *ui_data); -int OSSL_STORE_LOADER_set_load(OSSL_STORE_LOADER *loader, - OSSL_STORE_load_fn load_function); -typedef int (*OSSL_STORE_eof_fn)(OSSL_STORE_LOADER_CTX *ctx); -int OSSL_STORE_LOADER_set_eof(OSSL_STORE_LOADER *loader, - OSSL_STORE_eof_fn eof_function); -typedef int (*OSSL_STORE_error_fn)(OSSL_STORE_LOADER_CTX *ctx); -int OSSL_STORE_LOADER_set_error(OSSL_STORE_LOADER *loader, - OSSL_STORE_error_fn error_function); -typedef int (*OSSL_STORE_close_fn)(OSSL_STORE_LOADER_CTX *ctx); -int OSSL_STORE_LOADER_set_close(OSSL_STORE_LOADER *loader, - OSSL_STORE_close_fn close_function); -void OSSL_STORE_LOADER_free(OSSL_STORE_LOADER *loader); - -int OSSL_STORE_register_loader(OSSL_STORE_LOADER *loader); -OSSL_STORE_LOADER *OSSL_STORE_unregister_loader(const char *scheme); - -/*- - * Functions to list STORE loaders - * ------------------------------- - */ -int OSSL_STORE_do_all_loaders(void (*do_function) (const OSSL_STORE_LOADER - *loader, void *do_arg), - void *do_arg); - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/storeerr.h b/client/3rd/OpenSSL/include/openssl/storeerr.h deleted file mode 100644 index 190eab07..00000000 --- a/client/3rd/OpenSSL/include/openssl/storeerr.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OSSL_STOREERR_H -# define HEADER_OSSL_STOREERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_OSSL_STORE_strings(void); - -/* - * OSSL_STORE function codes. - */ -# define OSSL_STORE_F_FILE_CTRL 129 -# define OSSL_STORE_F_FILE_FIND 138 -# define OSSL_STORE_F_FILE_GET_PASS 118 -# define OSSL_STORE_F_FILE_LOAD 119 -# define OSSL_STORE_F_FILE_LOAD_TRY_DECODE 124 -# define OSSL_STORE_F_FILE_NAME_TO_URI 126 -# define OSSL_STORE_F_FILE_OPEN 120 -# define OSSL_STORE_F_OSSL_STORE_ATTACH_PEM_BIO 127 -# define OSSL_STORE_F_OSSL_STORE_EXPECT 130 -# define OSSL_STORE_F_OSSL_STORE_FILE_ATTACH_PEM_BIO_INT 128 -# define OSSL_STORE_F_OSSL_STORE_FIND 131 -# define OSSL_STORE_F_OSSL_STORE_GET0_LOADER_INT 100 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CERT 101 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_CRL 102 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME 103 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_NAME_DESCRIPTION 135 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PARAMS 104 -# define OSSL_STORE_F_OSSL_STORE_INFO_GET1_PKEY 105 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CERT 106 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_CRL 107 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_EMBEDDED 123 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_NAME 109 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PARAMS 110 -# define OSSL_STORE_F_OSSL_STORE_INFO_NEW_PKEY 111 -# define OSSL_STORE_F_OSSL_STORE_INFO_SET0_NAME_DESCRIPTION 134 -# define OSSL_STORE_F_OSSL_STORE_INIT_ONCE 112 -# define OSSL_STORE_F_OSSL_STORE_LOADER_NEW 113 -# define OSSL_STORE_F_OSSL_STORE_OPEN 114 -# define OSSL_STORE_F_OSSL_STORE_OPEN_INT 115 -# define OSSL_STORE_F_OSSL_STORE_REGISTER_LOADER_INT 117 -# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ALIAS 132 -# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_ISSUER_SERIAL 133 -# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT 136 -# define OSSL_STORE_F_OSSL_STORE_SEARCH_BY_NAME 137 -# define OSSL_STORE_F_OSSL_STORE_UNREGISTER_LOADER_INT 116 -# define OSSL_STORE_F_TRY_DECODE_PARAMS 121 -# define OSSL_STORE_F_TRY_DECODE_PKCS12 122 -# define OSSL_STORE_F_TRY_DECODE_PKCS8ENCRYPTED 125 - -/* - * OSSL_STORE reason codes. - */ -# define OSSL_STORE_R_AMBIGUOUS_CONTENT_TYPE 107 -# define OSSL_STORE_R_BAD_PASSWORD_READ 115 -# define OSSL_STORE_R_ERROR_VERIFYING_PKCS12_MAC 113 -# define OSSL_STORE_R_FINGERPRINT_SIZE_DOES_NOT_MATCH_DIGEST 121 -# define OSSL_STORE_R_INVALID_SCHEME 106 -# define OSSL_STORE_R_IS_NOT_A 112 -# define OSSL_STORE_R_LOADER_INCOMPLETE 116 -# define OSSL_STORE_R_LOADING_STARTED 117 -# define OSSL_STORE_R_NOT_A_CERTIFICATE 100 -# define OSSL_STORE_R_NOT_A_CRL 101 -# define OSSL_STORE_R_NOT_A_KEY 102 -# define OSSL_STORE_R_NOT_A_NAME 103 -# define OSSL_STORE_R_NOT_PARAMETERS 104 -# define OSSL_STORE_R_PASSPHRASE_CALLBACK_ERROR 114 -# define OSSL_STORE_R_PATH_MUST_BE_ABSOLUTE 108 -# define OSSL_STORE_R_SEARCH_ONLY_SUPPORTED_FOR_DIRECTORIES 119 -# define OSSL_STORE_R_UI_PROCESS_INTERRUPTED_OR_CANCELLED 109 -# define OSSL_STORE_R_UNREGISTERED_SCHEME 105 -# define OSSL_STORE_R_UNSUPPORTED_CONTENT_TYPE 110 -# define OSSL_STORE_R_UNSUPPORTED_OPERATION 118 -# define OSSL_STORE_R_UNSUPPORTED_SEARCH_TYPE 120 -# define OSSL_STORE_R_URI_AUTHORITY_UNSUPPORTED 111 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/symhacks.h b/client/3rd/OpenSSL/include/openssl/symhacks.h deleted file mode 100644 index 156ea6e4..00000000 --- a/client/3rd/OpenSSL/include/openssl/symhacks.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SYMHACKS_H -# define HEADER_SYMHACKS_H - -# include - -/* Case insensitive linking causes problems.... */ -# if defined(OPENSSL_SYS_VMS) -# undef ERR_load_CRYPTO_strings -# define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings -# undef OCSP_crlID_new -# define OCSP_crlID_new OCSP_crlID2_new - -# undef d2i_ECPARAMETERS -# define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS -# undef i2d_ECPARAMETERS -# define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS -# undef d2i_ECPKPARAMETERS -# define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS -# undef i2d_ECPKPARAMETERS -# define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS - -/* This one clashes with CMS_data_create */ -# undef cms_Data_create -# define cms_Data_create priv_cms_Data_create - -# endif - -#endif /* ! defined HEADER_VMS_IDHACKS_H */ diff --git a/client/3rd/OpenSSL/include/openssl/tls1.h b/client/3rd/OpenSSL/include/openssl/tls1.h deleted file mode 100644 index 76d9fda4..00000000 --- a/client/3rd/OpenSSL/include/openssl/tls1.h +++ /dev/null @@ -1,1237 +0,0 @@ -/* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved - * Copyright 2005 Nokia. All rights reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_TLS1_H -# define HEADER_TLS1_H - -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Default security level if not overridden at config time */ -# ifndef OPENSSL_TLS_SECURITY_LEVEL -# define OPENSSL_TLS_SECURITY_LEVEL 1 -# endif - -# define TLS1_VERSION 0x0301 -# define TLS1_1_VERSION 0x0302 -# define TLS1_2_VERSION 0x0303 -# define TLS1_3_VERSION 0x0304 -# define TLS_MAX_VERSION TLS1_3_VERSION - -/* Special value for method supporting multiple versions */ -# define TLS_ANY_VERSION 0x10000 - -# define TLS1_VERSION_MAJOR 0x03 -# define TLS1_VERSION_MINOR 0x01 - -# define TLS1_1_VERSION_MAJOR 0x03 -# define TLS1_1_VERSION_MINOR 0x02 - -# define TLS1_2_VERSION_MAJOR 0x03 -# define TLS1_2_VERSION_MINOR 0x03 - -# define TLS1_get_version(s) \ - ((SSL_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_version(s) : 0) - -# define TLS1_get_client_version(s) \ - ((SSL_client_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_client_version(s) : 0) - -# define TLS1_AD_DECRYPTION_FAILED 21 -# define TLS1_AD_RECORD_OVERFLOW 22 -# define TLS1_AD_UNKNOWN_CA 48/* fatal */ -# define TLS1_AD_ACCESS_DENIED 49/* fatal */ -# define TLS1_AD_DECODE_ERROR 50/* fatal */ -# define TLS1_AD_DECRYPT_ERROR 51 -# define TLS1_AD_EXPORT_RESTRICTION 60/* fatal */ -# define TLS1_AD_PROTOCOL_VERSION 70/* fatal */ -# define TLS1_AD_INSUFFICIENT_SECURITY 71/* fatal */ -# define TLS1_AD_INTERNAL_ERROR 80/* fatal */ -# define TLS1_AD_INAPPROPRIATE_FALLBACK 86/* fatal */ -# define TLS1_AD_USER_CANCELLED 90 -# define TLS1_AD_NO_RENEGOTIATION 100 -/* TLSv1.3 alerts */ -# define TLS13_AD_MISSING_EXTENSION 109 /* fatal */ -# define TLS13_AD_CERTIFICATE_REQUIRED 116 /* fatal */ -/* codes 110-114 are from RFC3546 */ -# define TLS1_AD_UNSUPPORTED_EXTENSION 110 -# define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111 -# define TLS1_AD_UNRECOGNIZED_NAME 112 -# define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113 -# define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114 -# define TLS1_AD_UNKNOWN_PSK_IDENTITY 115/* fatal */ -# define TLS1_AD_NO_APPLICATION_PROTOCOL 120 /* fatal */ - -/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */ -# define TLSEXT_TYPE_server_name 0 -# define TLSEXT_TYPE_max_fragment_length 1 -# define TLSEXT_TYPE_client_certificate_url 2 -# define TLSEXT_TYPE_trusted_ca_keys 3 -# define TLSEXT_TYPE_truncated_hmac 4 -# define TLSEXT_TYPE_status_request 5 -/* ExtensionType values from RFC4681 */ -# define TLSEXT_TYPE_user_mapping 6 -/* ExtensionType values from RFC5878 */ -# define TLSEXT_TYPE_client_authz 7 -# define TLSEXT_TYPE_server_authz 8 -/* ExtensionType values from RFC6091 */ -# define TLSEXT_TYPE_cert_type 9 - -/* ExtensionType values from RFC4492 */ -/* - * Prior to TLSv1.3 the supported_groups extension was known as - * elliptic_curves - */ -# define TLSEXT_TYPE_supported_groups 10 -# define TLSEXT_TYPE_elliptic_curves TLSEXT_TYPE_supported_groups -# define TLSEXT_TYPE_ec_point_formats 11 - - -/* ExtensionType value from RFC5054 */ -# define TLSEXT_TYPE_srp 12 - -/* ExtensionType values from RFC5246 */ -# define TLSEXT_TYPE_signature_algorithms 13 - -/* ExtensionType value from RFC5764 */ -# define TLSEXT_TYPE_use_srtp 14 - -/* ExtensionType value from RFC5620 */ -# define TLSEXT_TYPE_heartbeat 15 - -/* ExtensionType value from RFC7301 */ -# define TLSEXT_TYPE_application_layer_protocol_negotiation 16 - -/* - * Extension type for Certificate Transparency - * https://tools.ietf.org/html/rfc6962#section-3.3.1 - */ -# define TLSEXT_TYPE_signed_certificate_timestamp 18 - -/* - * ExtensionType value for TLS padding extension. - * http://tools.ietf.org/html/draft-agl-tls-padding - */ -# define TLSEXT_TYPE_padding 21 - -/* ExtensionType value from RFC7366 */ -# define TLSEXT_TYPE_encrypt_then_mac 22 - -/* ExtensionType value from RFC7627 */ -# define TLSEXT_TYPE_extended_master_secret 23 - -/* ExtensionType value from RFC4507 */ -# define TLSEXT_TYPE_session_ticket 35 - -/* As defined for TLS1.3 */ -# define TLSEXT_TYPE_psk 41 -# define TLSEXT_TYPE_early_data 42 -# define TLSEXT_TYPE_supported_versions 43 -# define TLSEXT_TYPE_cookie 44 -# define TLSEXT_TYPE_psk_kex_modes 45 -# define TLSEXT_TYPE_certificate_authorities 47 -# define TLSEXT_TYPE_post_handshake_auth 49 -# define TLSEXT_TYPE_signature_algorithms_cert 50 -# define TLSEXT_TYPE_key_share 51 - -/* Temporary extension type */ -# define TLSEXT_TYPE_renegotiate 0xff01 - -# ifndef OPENSSL_NO_NEXTPROTONEG -/* This is not an IANA defined extension number */ -# define TLSEXT_TYPE_next_proto_neg 13172 -# endif - -/* NameType value from RFC3546 */ -# define TLSEXT_NAMETYPE_host_name 0 -/* status request value from RFC3546 */ -# define TLSEXT_STATUSTYPE_ocsp 1 - -/* ECPointFormat values from RFC4492 */ -# define TLSEXT_ECPOINTFORMAT_first 0 -# define TLSEXT_ECPOINTFORMAT_uncompressed 0 -# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime 1 -# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 2 -# define TLSEXT_ECPOINTFORMAT_last 2 - -/* Signature and hash algorithms from RFC5246 */ -# define TLSEXT_signature_anonymous 0 -# define TLSEXT_signature_rsa 1 -# define TLSEXT_signature_dsa 2 -# define TLSEXT_signature_ecdsa 3 -# define TLSEXT_signature_gostr34102001 237 -# define TLSEXT_signature_gostr34102012_256 238 -# define TLSEXT_signature_gostr34102012_512 239 - -/* Total number of different signature algorithms */ -# define TLSEXT_signature_num 7 - -# define TLSEXT_hash_none 0 -# define TLSEXT_hash_md5 1 -# define TLSEXT_hash_sha1 2 -# define TLSEXT_hash_sha224 3 -# define TLSEXT_hash_sha256 4 -# define TLSEXT_hash_sha384 5 -# define TLSEXT_hash_sha512 6 -# define TLSEXT_hash_gostr3411 237 -# define TLSEXT_hash_gostr34112012_256 238 -# define TLSEXT_hash_gostr34112012_512 239 - -/* Total number of different digest algorithms */ - -# define TLSEXT_hash_num 10 - -/* Flag set for unrecognised algorithms */ -# define TLSEXT_nid_unknown 0x1000000 - -/* ECC curves */ - -# define TLSEXT_curve_P_256 23 -# define TLSEXT_curve_P_384 24 - -/* OpenSSL value to disable maximum fragment length extension */ -# define TLSEXT_max_fragment_length_DISABLED 0 -/* Allowed values for max fragment length extension */ -# define TLSEXT_max_fragment_length_512 1 -# define TLSEXT_max_fragment_length_1024 2 -# define TLSEXT_max_fragment_length_2048 3 -# define TLSEXT_max_fragment_length_4096 4 - -int SSL_CTX_set_tlsext_max_fragment_length(SSL_CTX *ctx, uint8_t mode); -int SSL_set_tlsext_max_fragment_length(SSL *ssl, uint8_t mode); - -# define TLSEXT_MAXLEN_host_name 255 - -__owur const char *SSL_get_servername(const SSL *s, const int type); -__owur int SSL_get_servername_type(const SSL *s); -/* - * SSL_export_keying_material exports a value derived from the master secret, - * as specified in RFC 5705. It writes |olen| bytes to |out| given a label and - * optional context. (Since a zero length context is allowed, the |use_context| - * flag controls whether a context is included.) It returns 1 on success and - * 0 or -1 otherwise. - */ -__owur int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, - const char *label, size_t llen, - const unsigned char *context, - size_t contextlen, int use_context); - -/* - * SSL_export_keying_material_early exports a value derived from the - * early exporter master secret, as specified in - * https://tools.ietf.org/html/draft-ietf-tls-tls13-23. It writes - * |olen| bytes to |out| given a label and optional context. It - * returns 1 on success and 0 otherwise. - */ -__owur int SSL_export_keying_material_early(SSL *s, unsigned char *out, - size_t olen, const char *label, - size_t llen, - const unsigned char *context, - size_t contextlen); - -int SSL_get_peer_signature_type_nid(const SSL *s, int *pnid); -int SSL_get_signature_type_nid(const SSL *s, int *pnid); - -int SSL_get_sigalgs(SSL *s, int idx, - int *psign, int *phash, int *psignandhash, - unsigned char *rsig, unsigned char *rhash); - -int SSL_get_shared_sigalgs(SSL *s, int idx, - int *psign, int *phash, int *psignandhash, - unsigned char *rsig, unsigned char *rhash); - -__owur int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain); - -# define SSL_set_tlsext_host_name(s,name) \ - SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,\ - (void *)name) - -# define SSL_set_tlsext_debug_callback(ssl, cb) \ - SSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,\ - (void (*)(void))cb) - -# define SSL_set_tlsext_debug_arg(ssl, arg) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0,arg) - -# define SSL_get_tlsext_status_type(ssl) \ - SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE,0,NULL) - -# define SSL_set_tlsext_status_type(ssl, type) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type,NULL) - -# define SSL_get_tlsext_status_exts(ssl, arg) \ - SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0,arg) - -# define SSL_set_tlsext_status_exts(ssl, arg) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0,arg) - -# define SSL_get_tlsext_status_ids(ssl, arg) \ - SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0,arg) - -# define SSL_set_tlsext_status_ids(ssl, arg) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0,arg) - -# define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \ - SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0,arg) - -# define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen,arg) - -# define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \ - SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,\ - (void (*)(void))cb) - -# define SSL_TLSEXT_ERR_OK 0 -# define SSL_TLSEXT_ERR_ALERT_WARNING 1 -# define SSL_TLSEXT_ERR_ALERT_FATAL 2 -# define SSL_TLSEXT_ERR_NOACK 3 - -# define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0,arg) - -# define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_TLSEXT_TICKET_KEYS,keylen,keys) -# define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_TICKET_KEYS,keylen,keys) - -# define SSL_CTX_get_tlsext_status_cb(ssl, cb) \ - SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB,0,(void *)cb) -# define SSL_CTX_set_tlsext_status_cb(ssl, cb) \ - SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,\ - (void (*)(void))cb) - -# define SSL_CTX_get_tlsext_status_arg(ssl, arg) \ - SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG,0,arg) -# define SSL_CTX_set_tlsext_status_arg(ssl, arg) \ - SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0,arg) - -# define SSL_CTX_set_tlsext_status_type(ssl, type) \ - SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type,NULL) - -# define SSL_CTX_get_tlsext_status_type(ssl) \ - SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE,0,NULL) - -# define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \ - SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,\ - (void (*)(void))cb) - -# ifndef OPENSSL_NO_HEARTBEATS -# define SSL_DTLSEXT_HB_ENABLED 0x01 -# define SSL_DTLSEXT_HB_DONT_SEND_REQUESTS 0x02 -# define SSL_DTLSEXT_HB_DONT_RECV_REQUESTS 0x04 -# define SSL_get_dtlsext_heartbeat_pending(ssl) \ - SSL_ctrl(ssl,SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING,0,NULL) -# define SSL_set_dtlsext_heartbeat_no_requests(ssl, arg) \ - SSL_ctrl(ssl,SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS,arg,NULL) - -# if OPENSSL_API_COMPAT < 0x10100000L -# define SSL_CTRL_TLS_EXT_SEND_HEARTBEAT \ - SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT -# define SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING \ - SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING -# define SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS \ - SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS -# define SSL_TLSEXT_HB_ENABLED \ - SSL_DTLSEXT_HB_ENABLED -# define SSL_TLSEXT_HB_DONT_SEND_REQUESTS \ - SSL_DTLSEXT_HB_DONT_SEND_REQUESTS -# define SSL_TLSEXT_HB_DONT_RECV_REQUESTS \ - SSL_DTLSEXT_HB_DONT_RECV_REQUESTS -# define SSL_get_tlsext_heartbeat_pending(ssl) \ - SSL_get_dtlsext_heartbeat_pending(ssl) -# define SSL_set_tlsext_heartbeat_no_requests(ssl, arg) \ - SSL_set_dtlsext_heartbeat_no_requests(ssl,arg) -# endif -# endif - -/* PSK ciphersuites from 4279 */ -# define TLS1_CK_PSK_WITH_RC4_128_SHA 0x0300008A -# define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA 0x0300008B -# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA 0x0300008C -# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA 0x0300008D -# define TLS1_CK_DHE_PSK_WITH_RC4_128_SHA 0x0300008E -# define TLS1_CK_DHE_PSK_WITH_3DES_EDE_CBC_SHA 0x0300008F -# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA 0x03000090 -# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA 0x03000091 -# define TLS1_CK_RSA_PSK_WITH_RC4_128_SHA 0x03000092 -# define TLS1_CK_RSA_PSK_WITH_3DES_EDE_CBC_SHA 0x03000093 -# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA 0x03000094 -# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA 0x03000095 - -/* PSK ciphersuites from 5487 */ -# define TLS1_CK_PSK_WITH_AES_128_GCM_SHA256 0x030000A8 -# define TLS1_CK_PSK_WITH_AES_256_GCM_SHA384 0x030000A9 -# define TLS1_CK_DHE_PSK_WITH_AES_128_GCM_SHA256 0x030000AA -# define TLS1_CK_DHE_PSK_WITH_AES_256_GCM_SHA384 0x030000AB -# define TLS1_CK_RSA_PSK_WITH_AES_128_GCM_SHA256 0x030000AC -# define TLS1_CK_RSA_PSK_WITH_AES_256_GCM_SHA384 0x030000AD -# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA256 0x030000AE -# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA384 0x030000AF -# define TLS1_CK_PSK_WITH_NULL_SHA256 0x030000B0 -# define TLS1_CK_PSK_WITH_NULL_SHA384 0x030000B1 -# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA256 0x030000B2 -# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA384 0x030000B3 -# define TLS1_CK_DHE_PSK_WITH_NULL_SHA256 0x030000B4 -# define TLS1_CK_DHE_PSK_WITH_NULL_SHA384 0x030000B5 -# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA256 0x030000B6 -# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA384 0x030000B7 -# define TLS1_CK_RSA_PSK_WITH_NULL_SHA256 0x030000B8 -# define TLS1_CK_RSA_PSK_WITH_NULL_SHA384 0x030000B9 - -/* NULL PSK ciphersuites from RFC4785 */ -# define TLS1_CK_PSK_WITH_NULL_SHA 0x0300002C -# define TLS1_CK_DHE_PSK_WITH_NULL_SHA 0x0300002D -# define TLS1_CK_RSA_PSK_WITH_NULL_SHA 0x0300002E - -/* AES ciphersuites from RFC3268 */ -# define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F -# define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 -# define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 -# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032 -# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033 -# define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034 -# define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035 -# define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036 -# define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037 -# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038 -# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039 -# define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A - -/* TLS v1.2 ciphersuites */ -# define TLS1_CK_RSA_WITH_NULL_SHA256 0x0300003B -# define TLS1_CK_RSA_WITH_AES_128_SHA256 0x0300003C -# define TLS1_CK_RSA_WITH_AES_256_SHA256 0x0300003D -# define TLS1_CK_DH_DSS_WITH_AES_128_SHA256 0x0300003E -# define TLS1_CK_DH_RSA_WITH_AES_128_SHA256 0x0300003F -# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256 0x03000040 - -/* Camellia ciphersuites from RFC4132 */ -# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000041 -# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000042 -# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000043 -# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000044 -# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000045 -# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA 0x03000046 - -/* TLS v1.2 ciphersuites */ -# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256 0x03000067 -# define TLS1_CK_DH_DSS_WITH_AES_256_SHA256 0x03000068 -# define TLS1_CK_DH_RSA_WITH_AES_256_SHA256 0x03000069 -# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256 0x0300006A -# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256 0x0300006B -# define TLS1_CK_ADH_WITH_AES_128_SHA256 0x0300006C -# define TLS1_CK_ADH_WITH_AES_256_SHA256 0x0300006D - -/* Camellia ciphersuites from RFC4132 */ -# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000084 -# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000085 -# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000086 -# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000087 -# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000088 -# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA 0x03000089 - -/* SEED ciphersuites from RFC4162 */ -# define TLS1_CK_RSA_WITH_SEED_SHA 0x03000096 -# define TLS1_CK_DH_DSS_WITH_SEED_SHA 0x03000097 -# define TLS1_CK_DH_RSA_WITH_SEED_SHA 0x03000098 -# define TLS1_CK_DHE_DSS_WITH_SEED_SHA 0x03000099 -# define TLS1_CK_DHE_RSA_WITH_SEED_SHA 0x0300009A -# define TLS1_CK_ADH_WITH_SEED_SHA 0x0300009B - -/* TLS v1.2 GCM ciphersuites from RFC5288 */ -# define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256 0x0300009C -# define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384 0x0300009D -# define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256 0x0300009E -# define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384 0x0300009F -# define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256 0x030000A0 -# define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384 0x030000A1 -# define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256 0x030000A2 -# define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384 0x030000A3 -# define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256 0x030000A4 -# define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384 0x030000A5 -# define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256 0x030000A6 -# define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384 0x030000A7 - -/* CCM ciphersuites from RFC6655 */ -# define TLS1_CK_RSA_WITH_AES_128_CCM 0x0300C09C -# define TLS1_CK_RSA_WITH_AES_256_CCM 0x0300C09D -# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM 0x0300C09E -# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM 0x0300C09F -# define TLS1_CK_RSA_WITH_AES_128_CCM_8 0x0300C0A0 -# define TLS1_CK_RSA_WITH_AES_256_CCM_8 0x0300C0A1 -# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM_8 0x0300C0A2 -# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM_8 0x0300C0A3 -# define TLS1_CK_PSK_WITH_AES_128_CCM 0x0300C0A4 -# define TLS1_CK_PSK_WITH_AES_256_CCM 0x0300C0A5 -# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM 0x0300C0A6 -# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM 0x0300C0A7 -# define TLS1_CK_PSK_WITH_AES_128_CCM_8 0x0300C0A8 -# define TLS1_CK_PSK_WITH_AES_256_CCM_8 0x0300C0A9 -# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM_8 0x0300C0AA -# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM_8 0x0300C0AB - -/* CCM ciphersuites from RFC7251 */ -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM 0x0300C0AC -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM 0x0300C0AD -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM_8 0x0300C0AE -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM_8 0x0300C0AF - -/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */ -# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BA -# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 0x030000BB -# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BC -# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 0x030000BD -# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BE -# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA256 0x030000BF - -# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C0 -# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 0x030000C1 -# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C2 -# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 0x030000C3 -# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C4 -# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA256 0x030000C5 - -/* ECC ciphersuites from RFC4492 */ -# define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001 -# define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002 -# define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003 -# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004 -# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005 - -# define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006 -# define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007 -# define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008 -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009 -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A - -# define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B -# define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C -# define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D -# define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E -# define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F - -# define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010 -# define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011 -# define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012 -# define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013 -# define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014 - -# define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015 -# define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016 -# define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017 -# define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018 -# define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019 - -/* SRP ciphersuites from RFC 5054 */ -# define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA 0x0300C01A -# define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA 0x0300C01B -# define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA 0x0300C01C -# define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA 0x0300C01D -# define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA 0x0300C01E -# define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA 0x0300C01F -# define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA 0x0300C020 -# define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA 0x0300C021 -# define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA 0x0300C022 - -/* ECDH HMAC based ciphersuites from RFC5289 */ -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256 0x0300C023 -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384 0x0300C024 -# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256 0x0300C025 -# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384 0x0300C026 -# define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256 0x0300C027 -# define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384 0x0300C028 -# define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256 0x0300C029 -# define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384 0x0300C02A - -/* ECDH GCM based ciphersuites from RFC5289 */ -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02B -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02C -# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02D -# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02E -# define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256 0x0300C02F -# define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384 0x0300C030 -# define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256 0x0300C031 -# define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384 0x0300C032 - -/* ECDHE PSK ciphersuites from RFC5489 */ -# define TLS1_CK_ECDHE_PSK_WITH_RC4_128_SHA 0x0300C033 -# define TLS1_CK_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA 0x0300C034 -# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA 0x0300C035 -# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA 0x0300C036 - -# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA256 0x0300C037 -# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA384 0x0300C038 - -/* NULL PSK ciphersuites from RFC4785 */ -# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA 0x0300C039 -# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA256 0x0300C03A -# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA384 0x0300C03B - -/* Camellia-CBC ciphersuites from RFC6367 */ -# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C072 -# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C073 -# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C074 -# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C075 -# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C076 -# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C077 -# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C078 -# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C079 - -# define TLS1_CK_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C094 -# define TLS1_CK_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C095 -# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C096 -# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C097 -# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C098 -# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C099 -# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C09A -# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C09B - -/* draft-ietf-tls-chacha20-poly1305-03 */ -# define TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305 0x0300CCA8 -# define TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 0x0300CCA9 -# define TLS1_CK_DHE_RSA_WITH_CHACHA20_POLY1305 0x0300CCAA -# define TLS1_CK_PSK_WITH_CHACHA20_POLY1305 0x0300CCAB -# define TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305 0x0300CCAC -# define TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305 0x0300CCAD -# define TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305 0x0300CCAE - -/* TLS v1.3 ciphersuites */ -# define TLS1_3_CK_AES_128_GCM_SHA256 0x03001301 -# define TLS1_3_CK_AES_256_GCM_SHA384 0x03001302 -# define TLS1_3_CK_CHACHA20_POLY1305_SHA256 0x03001303 -# define TLS1_3_CK_AES_128_CCM_SHA256 0x03001304 -# define TLS1_3_CK_AES_128_CCM_8_SHA256 0x03001305 - -/* Aria ciphersuites from RFC6209 */ -# define TLS1_CK_RSA_WITH_ARIA_128_GCM_SHA256 0x0300C050 -# define TLS1_CK_RSA_WITH_ARIA_256_GCM_SHA384 0x0300C051 -# define TLS1_CK_DHE_RSA_WITH_ARIA_128_GCM_SHA256 0x0300C052 -# define TLS1_CK_DHE_RSA_WITH_ARIA_256_GCM_SHA384 0x0300C053 -# define TLS1_CK_DH_RSA_WITH_ARIA_128_GCM_SHA256 0x0300C054 -# define TLS1_CK_DH_RSA_WITH_ARIA_256_GCM_SHA384 0x0300C055 -# define TLS1_CK_DHE_DSS_WITH_ARIA_128_GCM_SHA256 0x0300C056 -# define TLS1_CK_DHE_DSS_WITH_ARIA_256_GCM_SHA384 0x0300C057 -# define TLS1_CK_DH_DSS_WITH_ARIA_128_GCM_SHA256 0x0300C058 -# define TLS1_CK_DH_DSS_WITH_ARIA_256_GCM_SHA384 0x0300C059 -# define TLS1_CK_DH_anon_WITH_ARIA_128_GCM_SHA256 0x0300C05A -# define TLS1_CK_DH_anon_WITH_ARIA_256_GCM_SHA384 0x0300C05B -# define TLS1_CK_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 0x0300C05C -# define TLS1_CK_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 0x0300C05D -# define TLS1_CK_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 0x0300C05E -# define TLS1_CK_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 0x0300C05F -# define TLS1_CK_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 0x0300C060 -# define TLS1_CK_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 0x0300C061 -# define TLS1_CK_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 0x0300C062 -# define TLS1_CK_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 0x0300C063 -# define TLS1_CK_PSK_WITH_ARIA_128_GCM_SHA256 0x0300C06A -# define TLS1_CK_PSK_WITH_ARIA_256_GCM_SHA384 0x0300C06B -# define TLS1_CK_DHE_PSK_WITH_ARIA_128_GCM_SHA256 0x0300C06C -# define TLS1_CK_DHE_PSK_WITH_ARIA_256_GCM_SHA384 0x0300C06D -# define TLS1_CK_RSA_PSK_WITH_ARIA_128_GCM_SHA256 0x0300C06E -# define TLS1_CK_RSA_PSK_WITH_ARIA_256_GCM_SHA384 0x0300C06F - -/* a bundle of RFC standard cipher names, generated from ssl3_ciphers[] */ -# define TLS1_RFC_RSA_WITH_AES_128_SHA "TLS_RSA_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_DHE_DSS_WITH_AES_128_SHA "TLS_DHE_DSS_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_DHE_RSA_WITH_AES_128_SHA "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_ADH_WITH_AES_128_SHA "TLS_DH_anon_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_RSA_WITH_AES_256_SHA "TLS_RSA_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_DHE_DSS_WITH_AES_256_SHA "TLS_DHE_DSS_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_DHE_RSA_WITH_AES_256_SHA "TLS_DHE_RSA_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_ADH_WITH_AES_256_SHA "TLS_DH_anon_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_RSA_WITH_NULL_SHA256 "TLS_RSA_WITH_NULL_SHA256" -# define TLS1_RFC_RSA_WITH_AES_128_SHA256 "TLS_RSA_WITH_AES_128_CBC_SHA256" -# define TLS1_RFC_RSA_WITH_AES_256_SHA256 "TLS_RSA_WITH_AES_256_CBC_SHA256" -# define TLS1_RFC_DHE_DSS_WITH_AES_128_SHA256 "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256" -# define TLS1_RFC_DHE_RSA_WITH_AES_128_SHA256 "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" -# define TLS1_RFC_DHE_DSS_WITH_AES_256_SHA256 "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256" -# define TLS1_RFC_DHE_RSA_WITH_AES_256_SHA256 "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256" -# define TLS1_RFC_ADH_WITH_AES_128_SHA256 "TLS_DH_anon_WITH_AES_128_CBC_SHA256" -# define TLS1_RFC_ADH_WITH_AES_256_SHA256 "TLS_DH_anon_WITH_AES_256_CBC_SHA256" -# define TLS1_RFC_RSA_WITH_AES_128_GCM_SHA256 "TLS_RSA_WITH_AES_128_GCM_SHA256" -# define TLS1_RFC_RSA_WITH_AES_256_GCM_SHA384 "TLS_RSA_WITH_AES_256_GCM_SHA384" -# define TLS1_RFC_DHE_RSA_WITH_AES_128_GCM_SHA256 "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" -# define TLS1_RFC_DHE_RSA_WITH_AES_256_GCM_SHA384 "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" -# define TLS1_RFC_DHE_DSS_WITH_AES_128_GCM_SHA256 "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256" -# define TLS1_RFC_DHE_DSS_WITH_AES_256_GCM_SHA384 "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384" -# define TLS1_RFC_ADH_WITH_AES_128_GCM_SHA256 "TLS_DH_anon_WITH_AES_128_GCM_SHA256" -# define TLS1_RFC_ADH_WITH_AES_256_GCM_SHA384 "TLS_DH_anon_WITH_AES_256_GCM_SHA384" -# define TLS1_RFC_RSA_WITH_AES_128_CCM "TLS_RSA_WITH_AES_128_CCM" -# define TLS1_RFC_RSA_WITH_AES_256_CCM "TLS_RSA_WITH_AES_256_CCM" -# define TLS1_RFC_DHE_RSA_WITH_AES_128_CCM "TLS_DHE_RSA_WITH_AES_128_CCM" -# define TLS1_RFC_DHE_RSA_WITH_AES_256_CCM "TLS_DHE_RSA_WITH_AES_256_CCM" -# define TLS1_RFC_RSA_WITH_AES_128_CCM_8 "TLS_RSA_WITH_AES_128_CCM_8" -# define TLS1_RFC_RSA_WITH_AES_256_CCM_8 "TLS_RSA_WITH_AES_256_CCM_8" -# define TLS1_RFC_DHE_RSA_WITH_AES_128_CCM_8 "TLS_DHE_RSA_WITH_AES_128_CCM_8" -# define TLS1_RFC_DHE_RSA_WITH_AES_256_CCM_8 "TLS_DHE_RSA_WITH_AES_256_CCM_8" -# define TLS1_RFC_PSK_WITH_AES_128_CCM "TLS_PSK_WITH_AES_128_CCM" -# define TLS1_RFC_PSK_WITH_AES_256_CCM "TLS_PSK_WITH_AES_256_CCM" -# define TLS1_RFC_DHE_PSK_WITH_AES_128_CCM "TLS_DHE_PSK_WITH_AES_128_CCM" -# define TLS1_RFC_DHE_PSK_WITH_AES_256_CCM "TLS_DHE_PSK_WITH_AES_256_CCM" -# define TLS1_RFC_PSK_WITH_AES_128_CCM_8 "TLS_PSK_WITH_AES_128_CCM_8" -# define TLS1_RFC_PSK_WITH_AES_256_CCM_8 "TLS_PSK_WITH_AES_256_CCM_8" -# define TLS1_RFC_DHE_PSK_WITH_AES_128_CCM_8 "TLS_PSK_DHE_WITH_AES_128_CCM_8" -# define TLS1_RFC_DHE_PSK_WITH_AES_256_CCM_8 "TLS_PSK_DHE_WITH_AES_256_CCM_8" -# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CCM "TLS_ECDHE_ECDSA_WITH_AES_128_CCM" -# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CCM "TLS_ECDHE_ECDSA_WITH_AES_256_CCM" -# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CCM_8 "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8" -# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CCM_8 "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8" -# define TLS1_3_RFC_AES_128_GCM_SHA256 "TLS_AES_128_GCM_SHA256" -# define TLS1_3_RFC_AES_256_GCM_SHA384 "TLS_AES_256_GCM_SHA384" -# define TLS1_3_RFC_CHACHA20_POLY1305_SHA256 "TLS_CHACHA20_POLY1305_SHA256" -# define TLS1_3_RFC_AES_128_CCM_SHA256 "TLS_AES_128_CCM_SHA256" -# define TLS1_3_RFC_AES_128_CCM_8_SHA256 "TLS_AES_128_CCM_8_SHA256" -# define TLS1_RFC_ECDHE_ECDSA_WITH_NULL_SHA "TLS_ECDHE_ECDSA_WITH_NULL_SHA" -# define TLS1_RFC_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA" -# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_ECDHE_RSA_WITH_NULL_SHA "TLS_ECDHE_RSA_WITH_NULL_SHA" -# define TLS1_RFC_ECDHE_RSA_WITH_DES_192_CBC3_SHA "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA" -# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_CBC_SHA "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_CBC_SHA "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_ECDH_anon_WITH_NULL_SHA "TLS_ECDH_anon_WITH_NULL_SHA" -# define TLS1_RFC_ECDH_anon_WITH_DES_192_CBC3_SHA "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA" -# define TLS1_RFC_ECDH_anon_WITH_AES_128_CBC_SHA "TLS_ECDH_anon_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_ECDH_anon_WITH_AES_256_CBC_SHA "TLS_ECDH_anon_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_SHA256 "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" -# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_SHA384 "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384" -# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_SHA256 "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" -# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_SHA384 "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" -# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" -# define TLS1_RFC_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" -# define TLS1_RFC_ECDHE_RSA_WITH_AES_128_GCM_SHA256 "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" -# define TLS1_RFC_ECDHE_RSA_WITH_AES_256_GCM_SHA384 "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" -# define TLS1_RFC_PSK_WITH_NULL_SHA "TLS_PSK_WITH_NULL_SHA" -# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA "TLS_DHE_PSK_WITH_NULL_SHA" -# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA "TLS_RSA_PSK_WITH_NULL_SHA" -# define TLS1_RFC_PSK_WITH_3DES_EDE_CBC_SHA "TLS_PSK_WITH_3DES_EDE_CBC_SHA" -# define TLS1_RFC_PSK_WITH_AES_128_CBC_SHA "TLS_PSK_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_PSK_WITH_AES_256_CBC_SHA "TLS_PSK_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_DHE_PSK_WITH_3DES_EDE_CBC_SHA "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA" -# define TLS1_RFC_DHE_PSK_WITH_AES_128_CBC_SHA "TLS_DHE_PSK_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_DHE_PSK_WITH_AES_256_CBC_SHA "TLS_DHE_PSK_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_RSA_PSK_WITH_3DES_EDE_CBC_SHA "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA" -# define TLS1_RFC_RSA_PSK_WITH_AES_128_CBC_SHA "TLS_RSA_PSK_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_RSA_PSK_WITH_AES_256_CBC_SHA "TLS_RSA_PSK_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_PSK_WITH_AES_128_GCM_SHA256 "TLS_PSK_WITH_AES_128_GCM_SHA256" -# define TLS1_RFC_PSK_WITH_AES_256_GCM_SHA384 "TLS_PSK_WITH_AES_256_GCM_SHA384" -# define TLS1_RFC_DHE_PSK_WITH_AES_128_GCM_SHA256 "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256" -# define TLS1_RFC_DHE_PSK_WITH_AES_256_GCM_SHA384 "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384" -# define TLS1_RFC_RSA_PSK_WITH_AES_128_GCM_SHA256 "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256" -# define TLS1_RFC_RSA_PSK_WITH_AES_256_GCM_SHA384 "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384" -# define TLS1_RFC_PSK_WITH_AES_128_CBC_SHA256 "TLS_PSK_WITH_AES_128_CBC_SHA256" -# define TLS1_RFC_PSK_WITH_AES_256_CBC_SHA384 "TLS_PSK_WITH_AES_256_CBC_SHA384" -# define TLS1_RFC_PSK_WITH_NULL_SHA256 "TLS_PSK_WITH_NULL_SHA256" -# define TLS1_RFC_PSK_WITH_NULL_SHA384 "TLS_PSK_WITH_NULL_SHA384" -# define TLS1_RFC_DHE_PSK_WITH_AES_128_CBC_SHA256 "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256" -# define TLS1_RFC_DHE_PSK_WITH_AES_256_CBC_SHA384 "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384" -# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA256 "TLS_DHE_PSK_WITH_NULL_SHA256" -# define TLS1_RFC_DHE_PSK_WITH_NULL_SHA384 "TLS_DHE_PSK_WITH_NULL_SHA384" -# define TLS1_RFC_RSA_PSK_WITH_AES_128_CBC_SHA256 "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256" -# define TLS1_RFC_RSA_PSK_WITH_AES_256_CBC_SHA384 "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384" -# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA256 "TLS_RSA_PSK_WITH_NULL_SHA256" -# define TLS1_RFC_RSA_PSK_WITH_NULL_SHA384 "TLS_RSA_PSK_WITH_NULL_SHA384" -# define TLS1_RFC_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA "TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA" -# define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_ECDHE_PSK_WITH_AES_128_CBC_SHA256 "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256" -# define TLS1_RFC_ECDHE_PSK_WITH_AES_256_CBC_SHA384 "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384" -# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA "TLS_ECDHE_PSK_WITH_NULL_SHA" -# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA256 "TLS_ECDHE_PSK_WITH_NULL_SHA256" -# define TLS1_RFC_ECDHE_PSK_WITH_NULL_SHA384 "TLS_ECDHE_PSK_WITH_NULL_SHA384" -# define TLS1_RFC_SRP_SHA_WITH_3DES_EDE_CBC_SHA "TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA" -# define TLS1_RFC_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA "TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA" -# define TLS1_RFC_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA "TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA" -# define TLS1_RFC_SRP_SHA_WITH_AES_128_CBC_SHA "TLS_SRP_SHA_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_SRP_SHA_RSA_WITH_AES_128_CBC_SHA "TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_SRP_SHA_DSS_WITH_AES_128_CBC_SHA "TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA" -# define TLS1_RFC_SRP_SHA_WITH_AES_256_CBC_SHA "TLS_SRP_SHA_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_SRP_SHA_RSA_WITH_AES_256_CBC_SHA "TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_SRP_SHA_DSS_WITH_AES_256_CBC_SHA "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA" -# define TLS1_RFC_DHE_RSA_WITH_CHACHA20_POLY1305 "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256" -# define TLS1_RFC_ECDHE_RSA_WITH_CHACHA20_POLY1305 "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" -# define TLS1_RFC_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" -# define TLS1_RFC_PSK_WITH_CHACHA20_POLY1305 "TLS_PSK_WITH_CHACHA20_POLY1305_SHA256" -# define TLS1_RFC_ECDHE_PSK_WITH_CHACHA20_POLY1305 "TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256" -# define TLS1_RFC_DHE_PSK_WITH_CHACHA20_POLY1305 "TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256" -# define TLS1_RFC_RSA_PSK_WITH_CHACHA20_POLY1305 "TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256" -# define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA256 "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256" -# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256" -# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" -# define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256" -# define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA256 "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256" -# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256" -# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256" -# define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA256 "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256" -# define TLS1_RFC_RSA_WITH_CAMELLIA_256_CBC_SHA "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA" -# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA" -# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA" -# define TLS1_RFC_ADH_WITH_CAMELLIA_256_CBC_SHA "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA" -# define TLS1_RFC_RSA_WITH_CAMELLIA_128_CBC_SHA "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA" -# define TLS1_RFC_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA" -# define TLS1_RFC_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA" -# define TLS1_RFC_ADH_WITH_CAMELLIA_128_CBC_SHA "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA" -# define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256" -# define TLS1_RFC_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384" -# define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" -# define TLS1_RFC_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384" -# define TLS1_RFC_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256" -# define TLS1_RFC_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384" -# define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" -# define TLS1_RFC_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" -# define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256" -# define TLS1_RFC_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384" -# define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" -# define TLS1_RFC_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" -# define TLS1_RFC_RSA_WITH_SEED_SHA "TLS_RSA_WITH_SEED_CBC_SHA" -# define TLS1_RFC_DHE_DSS_WITH_SEED_SHA "TLS_DHE_DSS_WITH_SEED_CBC_SHA" -# define TLS1_RFC_DHE_RSA_WITH_SEED_SHA "TLS_DHE_RSA_WITH_SEED_CBC_SHA" -# define TLS1_RFC_ADH_WITH_SEED_SHA "TLS_DH_anon_WITH_SEED_CBC_SHA" -# define TLS1_RFC_ECDHE_PSK_WITH_RC4_128_SHA "TLS_ECDHE_PSK_WITH_RC4_128_SHA" -# define TLS1_RFC_ECDH_anon_WITH_RC4_128_SHA "TLS_ECDH_anon_WITH_RC4_128_SHA" -# define TLS1_RFC_ECDHE_ECDSA_WITH_RC4_128_SHA "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA" -# define TLS1_RFC_ECDHE_RSA_WITH_RC4_128_SHA "TLS_ECDHE_RSA_WITH_RC4_128_SHA" -# define TLS1_RFC_PSK_WITH_RC4_128_SHA "TLS_PSK_WITH_RC4_128_SHA" -# define TLS1_RFC_RSA_PSK_WITH_RC4_128_SHA "TLS_RSA_PSK_WITH_RC4_128_SHA" -# define TLS1_RFC_DHE_PSK_WITH_RC4_128_SHA "TLS_DHE_PSK_WITH_RC4_128_SHA" -# define TLS1_RFC_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_RSA_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_RSA_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_DHE_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_DHE_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_DH_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_DH_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_DHE_DSS_WITH_ARIA_128_GCM_SHA256 "TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_DHE_DSS_WITH_ARIA_256_GCM_SHA384 "TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_DH_DSS_WITH_ARIA_128_GCM_SHA256 "TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_DH_DSS_WITH_ARIA_256_GCM_SHA384 "TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_DH_anon_WITH_ARIA_128_GCM_SHA256 "TLS_DH_anon_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_DH_anon_WITH_ARIA_256_GCM_SHA384 "TLS_DH_anon_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_PSK_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_PSK_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_DHE_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_DHE_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384" -# define TLS1_RFC_RSA_PSK_WITH_ARIA_128_GCM_SHA256 "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256" -# define TLS1_RFC_RSA_PSK_WITH_ARIA_256_GCM_SHA384 "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384" - - -/* - * XXX Backward compatibility alert: Older versions of OpenSSL gave some DHE - * ciphers names with "EDH" instead of "DHE". Going forward, we should be - * using DHE everywhere, though we may indefinitely maintain aliases for - * users or configurations that used "EDH" - */ -# define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" - -# define TLS1_TXT_PSK_WITH_NULL_SHA "PSK-NULL-SHA" -# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA "DHE-PSK-NULL-SHA" -# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA "RSA-PSK-NULL-SHA" - -/* AES ciphersuites from RFC3268 */ -# define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA" -# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA" -# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA" -# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA" -# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA" -# define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA" - -# define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA" -# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA" -# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA" -# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA" -# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" -# define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" - -/* ECC ciphersuites from RFC4492 */ -# define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" -# define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" -# define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA" - -# define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA" -# define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA" -# define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA" - -# define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA" -# define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA" -# define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA" -# define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA" -# define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA" - -# define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA" -# define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA" -# define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA" - -# define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA" -# define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA" -# define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA" -# define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA" -# define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA" - -/* PSK ciphersuites from RFC 4279 */ -# define TLS1_TXT_PSK_WITH_RC4_128_SHA "PSK-RC4-SHA" -# define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA "PSK-3DES-EDE-CBC-SHA" -# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA "PSK-AES128-CBC-SHA" -# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA "PSK-AES256-CBC-SHA" - -# define TLS1_TXT_DHE_PSK_WITH_RC4_128_SHA "DHE-PSK-RC4-SHA" -# define TLS1_TXT_DHE_PSK_WITH_3DES_EDE_CBC_SHA "DHE-PSK-3DES-EDE-CBC-SHA" -# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA "DHE-PSK-AES128-CBC-SHA" -# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA "DHE-PSK-AES256-CBC-SHA" -# define TLS1_TXT_RSA_PSK_WITH_RC4_128_SHA "RSA-PSK-RC4-SHA" -# define TLS1_TXT_RSA_PSK_WITH_3DES_EDE_CBC_SHA "RSA-PSK-3DES-EDE-CBC-SHA" -# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA "RSA-PSK-AES128-CBC-SHA" -# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA "RSA-PSK-AES256-CBC-SHA" - -/* PSK ciphersuites from RFC 5487 */ -# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256 "PSK-AES128-GCM-SHA256" -# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384 "PSK-AES256-GCM-SHA384" -# define TLS1_TXT_DHE_PSK_WITH_AES_128_GCM_SHA256 "DHE-PSK-AES128-GCM-SHA256" -# define TLS1_TXT_DHE_PSK_WITH_AES_256_GCM_SHA384 "DHE-PSK-AES256-GCM-SHA384" -# define TLS1_TXT_RSA_PSK_WITH_AES_128_GCM_SHA256 "RSA-PSK-AES128-GCM-SHA256" -# define TLS1_TXT_RSA_PSK_WITH_AES_256_GCM_SHA384 "RSA-PSK-AES256-GCM-SHA384" - -# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA256 "PSK-AES128-CBC-SHA256" -# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA384 "PSK-AES256-CBC-SHA384" -# define TLS1_TXT_PSK_WITH_NULL_SHA256 "PSK-NULL-SHA256" -# define TLS1_TXT_PSK_WITH_NULL_SHA384 "PSK-NULL-SHA384" - -# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA256 "DHE-PSK-AES128-CBC-SHA256" -# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA384 "DHE-PSK-AES256-CBC-SHA384" -# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA256 "DHE-PSK-NULL-SHA256" -# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA384 "DHE-PSK-NULL-SHA384" - -# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA256 "RSA-PSK-AES128-CBC-SHA256" -# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA384 "RSA-PSK-AES256-CBC-SHA384" -# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA256 "RSA-PSK-NULL-SHA256" -# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA384 "RSA-PSK-NULL-SHA384" - -/* SRP ciphersuite from RFC 5054 */ -# define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA "SRP-3DES-EDE-CBC-SHA" -# define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA "SRP-RSA-3DES-EDE-CBC-SHA" -# define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA "SRP-DSS-3DES-EDE-CBC-SHA" -# define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA "SRP-AES-128-CBC-SHA" -# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA "SRP-RSA-AES-128-CBC-SHA" -# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA "SRP-DSS-AES-128-CBC-SHA" -# define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA "SRP-AES-256-CBC-SHA" -# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA "SRP-RSA-AES-256-CBC-SHA" -# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA "SRP-DSS-AES-256-CBC-SHA" - -/* Camellia ciphersuites from RFC4132 */ -# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA "CAMELLIA128-SHA" -# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA "DH-DSS-CAMELLIA128-SHA" -# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA "DH-RSA-CAMELLIA128-SHA" -# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "DHE-DSS-CAMELLIA128-SHA" -# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "DHE-RSA-CAMELLIA128-SHA" -# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA "ADH-CAMELLIA128-SHA" - -# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA "CAMELLIA256-SHA" -# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA "DH-DSS-CAMELLIA256-SHA" -# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA "DH-RSA-CAMELLIA256-SHA" -# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "DHE-DSS-CAMELLIA256-SHA" -# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "DHE-RSA-CAMELLIA256-SHA" -# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA "ADH-CAMELLIA256-SHA" - -/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */ -# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA256 "CAMELLIA128-SHA256" -# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 "DH-DSS-CAMELLIA128-SHA256" -# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 "DH-RSA-CAMELLIA128-SHA256" -# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 "DHE-DSS-CAMELLIA128-SHA256" -# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "DHE-RSA-CAMELLIA128-SHA256" -# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA256 "ADH-CAMELLIA128-SHA256" - -# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA256 "CAMELLIA256-SHA256" -# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 "DH-DSS-CAMELLIA256-SHA256" -# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 "DH-RSA-CAMELLIA256-SHA256" -# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 "DHE-DSS-CAMELLIA256-SHA256" -# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 "DHE-RSA-CAMELLIA256-SHA256" -# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA256 "ADH-CAMELLIA256-SHA256" - -# define TLS1_TXT_PSK_WITH_CAMELLIA_128_CBC_SHA256 "PSK-CAMELLIA128-SHA256" -# define TLS1_TXT_PSK_WITH_CAMELLIA_256_CBC_SHA384 "PSK-CAMELLIA256-SHA384" -# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "DHE-PSK-CAMELLIA128-SHA256" -# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "DHE-PSK-CAMELLIA256-SHA384" -# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 "RSA-PSK-CAMELLIA128-SHA256" -# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 "RSA-PSK-CAMELLIA256-SHA384" -# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-PSK-CAMELLIA128-SHA256" -# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-PSK-CAMELLIA256-SHA384" - -/* SEED ciphersuites from RFC4162 */ -# define TLS1_TXT_RSA_WITH_SEED_SHA "SEED-SHA" -# define TLS1_TXT_DH_DSS_WITH_SEED_SHA "DH-DSS-SEED-SHA" -# define TLS1_TXT_DH_RSA_WITH_SEED_SHA "DH-RSA-SEED-SHA" -# define TLS1_TXT_DHE_DSS_WITH_SEED_SHA "DHE-DSS-SEED-SHA" -# define TLS1_TXT_DHE_RSA_WITH_SEED_SHA "DHE-RSA-SEED-SHA" -# define TLS1_TXT_ADH_WITH_SEED_SHA "ADH-SEED-SHA" - -/* TLS v1.2 ciphersuites */ -# define TLS1_TXT_RSA_WITH_NULL_SHA256 "NULL-SHA256" -# define TLS1_TXT_RSA_WITH_AES_128_SHA256 "AES128-SHA256" -# define TLS1_TXT_RSA_WITH_AES_256_SHA256 "AES256-SHA256" -# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256 "DH-DSS-AES128-SHA256" -# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256 "DH-RSA-AES128-SHA256" -# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256 "DHE-DSS-AES128-SHA256" -# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256 "DHE-RSA-AES128-SHA256" -# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256 "DH-DSS-AES256-SHA256" -# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256 "DH-RSA-AES256-SHA256" -# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256 "DHE-DSS-AES256-SHA256" -# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256 "DHE-RSA-AES256-SHA256" -# define TLS1_TXT_ADH_WITH_AES_128_SHA256 "ADH-AES128-SHA256" -# define TLS1_TXT_ADH_WITH_AES_256_SHA256 "ADH-AES256-SHA256" - -/* TLS v1.2 GCM ciphersuites from RFC5288 */ -# define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256 "AES128-GCM-SHA256" -# define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384 "AES256-GCM-SHA384" -# define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256 "DHE-RSA-AES128-GCM-SHA256" -# define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384 "DHE-RSA-AES256-GCM-SHA384" -# define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256 "DH-RSA-AES128-GCM-SHA256" -# define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384 "DH-RSA-AES256-GCM-SHA384" -# define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256 "DHE-DSS-AES128-GCM-SHA256" -# define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384 "DHE-DSS-AES256-GCM-SHA384" -# define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256 "DH-DSS-AES128-GCM-SHA256" -# define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384 "DH-DSS-AES256-GCM-SHA384" -# define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256 "ADH-AES128-GCM-SHA256" -# define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384 "ADH-AES256-GCM-SHA384" - -/* CCM ciphersuites from RFC6655 */ -# define TLS1_TXT_RSA_WITH_AES_128_CCM "AES128-CCM" -# define TLS1_TXT_RSA_WITH_AES_256_CCM "AES256-CCM" -# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM "DHE-RSA-AES128-CCM" -# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM "DHE-RSA-AES256-CCM" - -# define TLS1_TXT_RSA_WITH_AES_128_CCM_8 "AES128-CCM8" -# define TLS1_TXT_RSA_WITH_AES_256_CCM_8 "AES256-CCM8" -# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM_8 "DHE-RSA-AES128-CCM8" -# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM_8 "DHE-RSA-AES256-CCM8" - -# define TLS1_TXT_PSK_WITH_AES_128_CCM "PSK-AES128-CCM" -# define TLS1_TXT_PSK_WITH_AES_256_CCM "PSK-AES256-CCM" -# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM "DHE-PSK-AES128-CCM" -# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM "DHE-PSK-AES256-CCM" - -# define TLS1_TXT_PSK_WITH_AES_128_CCM_8 "PSK-AES128-CCM8" -# define TLS1_TXT_PSK_WITH_AES_256_CCM_8 "PSK-AES256-CCM8" -# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM_8 "DHE-PSK-AES128-CCM8" -# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM_8 "DHE-PSK-AES256-CCM8" - -/* CCM ciphersuites from RFC7251 */ -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM "ECDHE-ECDSA-AES128-CCM" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM "ECDHE-ECDSA-AES256-CCM" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM_8 "ECDHE-ECDSA-AES128-CCM8" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM_8 "ECDHE-ECDSA-AES256-CCM8" - -/* ECDH HMAC based ciphersuites from RFC5289 */ -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256 "ECDHE-ECDSA-AES128-SHA256" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384 "ECDHE-ECDSA-AES256-SHA384" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256 "ECDH-ECDSA-AES128-SHA256" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384 "ECDH-ECDSA-AES256-SHA384" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256 "ECDHE-RSA-AES128-SHA256" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384 "ECDHE-RSA-AES256-SHA384" -# define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256 "ECDH-RSA-AES128-SHA256" -# define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384 "ECDH-RSA-AES256-SHA384" - -/* ECDH GCM based ciphersuites from RFC5289 */ -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 "ECDHE-ECDSA-AES128-GCM-SHA256" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 "ECDHE-ECDSA-AES256-GCM-SHA384" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 "ECDH-ECDSA-AES128-GCM-SHA256" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 "ECDH-ECDSA-AES256-GCM-SHA384" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 "ECDHE-RSA-AES128-GCM-SHA256" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384 "ECDHE-RSA-AES256-GCM-SHA384" -# define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256 "ECDH-RSA-AES128-GCM-SHA256" -# define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384 "ECDH-RSA-AES256-GCM-SHA384" - -/* TLS v1.2 PSK GCM ciphersuites from RFC5487 */ -# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256 "PSK-AES128-GCM-SHA256" -# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384 "PSK-AES256-GCM-SHA384" - -/* ECDHE PSK ciphersuites from RFC 5489 */ -# define TLS1_TXT_ECDHE_PSK_WITH_RC4_128_SHA "ECDHE-PSK-RC4-SHA" -# define TLS1_TXT_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA "ECDHE-PSK-3DES-EDE-CBC-SHA" -# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA "ECDHE-PSK-AES128-CBC-SHA" -# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA "ECDHE-PSK-AES256-CBC-SHA" - -# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA256 "ECDHE-PSK-AES128-CBC-SHA256" -# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA384 "ECDHE-PSK-AES256-CBC-SHA384" - -# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA "ECDHE-PSK-NULL-SHA" -# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA256 "ECDHE-PSK-NULL-SHA256" -# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA384 "ECDHE-PSK-NULL-SHA384" - -/* Camellia-CBC ciphersuites from RFC6367 */ -# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-ECDSA-CAMELLIA128-SHA256" -# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-ECDSA-CAMELLIA256-SHA384" -# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDH-ECDSA-CAMELLIA128-SHA256" -# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDH-ECDSA-CAMELLIA256-SHA384" -# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-RSA-CAMELLIA128-SHA256" -# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-RSA-CAMELLIA256-SHA384" -# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDH-RSA-CAMELLIA128-SHA256" -# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDH-RSA-CAMELLIA256-SHA384" - -/* draft-ietf-tls-chacha20-poly1305-03 */ -# define TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305 "ECDHE-RSA-CHACHA20-POLY1305" -# define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 "ECDHE-ECDSA-CHACHA20-POLY1305" -# define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305 "DHE-RSA-CHACHA20-POLY1305" -# define TLS1_TXT_PSK_WITH_CHACHA20_POLY1305 "PSK-CHACHA20-POLY1305" -# define TLS1_TXT_ECDHE_PSK_WITH_CHACHA20_POLY1305 "ECDHE-PSK-CHACHA20-POLY1305" -# define TLS1_TXT_DHE_PSK_WITH_CHACHA20_POLY1305 "DHE-PSK-CHACHA20-POLY1305" -# define TLS1_TXT_RSA_PSK_WITH_CHACHA20_POLY1305 "RSA-PSK-CHACHA20-POLY1305" - -/* Aria ciphersuites from RFC6209 */ -# define TLS1_TXT_RSA_WITH_ARIA_128_GCM_SHA256 "ARIA128-GCM-SHA256" -# define TLS1_TXT_RSA_WITH_ARIA_256_GCM_SHA384 "ARIA256-GCM-SHA384" -# define TLS1_TXT_DHE_RSA_WITH_ARIA_128_GCM_SHA256 "DHE-RSA-ARIA128-GCM-SHA256" -# define TLS1_TXT_DHE_RSA_WITH_ARIA_256_GCM_SHA384 "DHE-RSA-ARIA256-GCM-SHA384" -# define TLS1_TXT_DH_RSA_WITH_ARIA_128_GCM_SHA256 "DH-RSA-ARIA128-GCM-SHA256" -# define TLS1_TXT_DH_RSA_WITH_ARIA_256_GCM_SHA384 "DH-RSA-ARIA256-GCM-SHA384" -# define TLS1_TXT_DHE_DSS_WITH_ARIA_128_GCM_SHA256 "DHE-DSS-ARIA128-GCM-SHA256" -# define TLS1_TXT_DHE_DSS_WITH_ARIA_256_GCM_SHA384 "DHE-DSS-ARIA256-GCM-SHA384" -# define TLS1_TXT_DH_DSS_WITH_ARIA_128_GCM_SHA256 "DH-DSS-ARIA128-GCM-SHA256" -# define TLS1_TXT_DH_DSS_WITH_ARIA_256_GCM_SHA384 "DH-DSS-ARIA256-GCM-SHA384" -# define TLS1_TXT_DH_anon_WITH_ARIA_128_GCM_SHA256 "ADH-ARIA128-GCM-SHA256" -# define TLS1_TXT_DH_anon_WITH_ARIA_256_GCM_SHA384 "ADH-ARIA256-GCM-SHA384" -# define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 "ECDHE-ECDSA-ARIA128-GCM-SHA256" -# define TLS1_TXT_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 "ECDHE-ECDSA-ARIA256-GCM-SHA384" -# define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 "ECDH-ECDSA-ARIA128-GCM-SHA256" -# define TLS1_TXT_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 "ECDH-ECDSA-ARIA256-GCM-SHA384" -# define TLS1_TXT_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 "ECDHE-ARIA128-GCM-SHA256" -# define TLS1_TXT_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 "ECDHE-ARIA256-GCM-SHA384" -# define TLS1_TXT_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 "ECDH-ARIA128-GCM-SHA256" -# define TLS1_TXT_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 "ECDH-ARIA256-GCM-SHA384" -# define TLS1_TXT_PSK_WITH_ARIA_128_GCM_SHA256 "PSK-ARIA128-GCM-SHA256" -# define TLS1_TXT_PSK_WITH_ARIA_256_GCM_SHA384 "PSK-ARIA256-GCM-SHA384" -# define TLS1_TXT_DHE_PSK_WITH_ARIA_128_GCM_SHA256 "DHE-PSK-ARIA128-GCM-SHA256" -# define TLS1_TXT_DHE_PSK_WITH_ARIA_256_GCM_SHA384 "DHE-PSK-ARIA256-GCM-SHA384" -# define TLS1_TXT_RSA_PSK_WITH_ARIA_128_GCM_SHA256 "RSA-PSK-ARIA128-GCM-SHA256" -# define TLS1_TXT_RSA_PSK_WITH_ARIA_256_GCM_SHA384 "RSA-PSK-ARIA256-GCM-SHA384" - -# define TLS_CT_RSA_SIGN 1 -# define TLS_CT_DSS_SIGN 2 -# define TLS_CT_RSA_FIXED_DH 3 -# define TLS_CT_DSS_FIXED_DH 4 -# define TLS_CT_ECDSA_SIGN 64 -# define TLS_CT_RSA_FIXED_ECDH 65 -# define TLS_CT_ECDSA_FIXED_ECDH 66 -# define TLS_CT_GOST01_SIGN 22 -# define TLS_CT_GOST12_SIGN 238 -# define TLS_CT_GOST12_512_SIGN 239 - -/* - * when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see - * comment there) - */ -# define TLS_CT_NUMBER 10 - -# if defined(SSL3_CT_NUMBER) -# if TLS_CT_NUMBER != SSL3_CT_NUMBER -# error "SSL/TLS CT_NUMBER values do not match" -# endif -# endif - -# define TLS1_FINISH_MAC_LENGTH 12 - -# define TLS_MD_MAX_CONST_SIZE 22 -# define TLS_MD_CLIENT_FINISH_CONST "client finished" -# define TLS_MD_CLIENT_FINISH_CONST_SIZE 15 -# define TLS_MD_SERVER_FINISH_CONST "server finished" -# define TLS_MD_SERVER_FINISH_CONST_SIZE 15 -# define TLS_MD_KEY_EXPANSION_CONST "key expansion" -# define TLS_MD_KEY_EXPANSION_CONST_SIZE 13 -# define TLS_MD_CLIENT_WRITE_KEY_CONST "client write key" -# define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16 -# define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" -# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 -# define TLS_MD_IV_BLOCK_CONST "IV block" -# define TLS_MD_IV_BLOCK_CONST_SIZE 8 -# define TLS_MD_MASTER_SECRET_CONST "master secret" -# define TLS_MD_MASTER_SECRET_CONST_SIZE 13 -# define TLS_MD_EXTENDED_MASTER_SECRET_CONST "extended master secret" -# define TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE 22 - -# ifdef CHARSET_EBCDIC -# undef TLS_MD_CLIENT_FINISH_CONST -/* - * client finished - */ -# define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" - -# undef TLS_MD_SERVER_FINISH_CONST -/* - * server finished - */ -# define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" - -# undef TLS_MD_SERVER_WRITE_KEY_CONST -/* - * server write key - */ -# define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" - -# undef TLS_MD_KEY_EXPANSION_CONST -/* - * key expansion - */ -# define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" - -# undef TLS_MD_CLIENT_WRITE_KEY_CONST -/* - * client write key - */ -# define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" - -# undef TLS_MD_SERVER_WRITE_KEY_CONST -/* - * server write key - */ -# define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" - -# undef TLS_MD_IV_BLOCK_CONST -/* - * IV block - */ -# define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" - -# undef TLS_MD_MASTER_SECRET_CONST -/* - * master secret - */ -# define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" -# undef TLS_MD_EXTENDED_MASTER_SECRET_CONST -/* - * extended master secret - */ -# define TLS_MD_EXTENDED_MASTER_SECRET_CONST "\x65\x78\x74\x65\x6e\x64\x65\x64\x20\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" -# endif - -/* TLS Session Ticket extension struct */ -struct tls_session_ticket_ext_st { - unsigned short length; - void *data; -}; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ts.h b/client/3rd/OpenSSL/include/openssl/ts.h deleted file mode 100644 index 3b58aa52..00000000 --- a/client/3rd/OpenSSL/include/openssl/ts.h +++ /dev/null @@ -1,559 +0,0 @@ -/* - * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_TS_H -# define HEADER_TS_H - -# include - -# ifndef OPENSSL_NO_TS -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# ifdef __cplusplus -extern "C" { -# endif - -# include -# include - -typedef struct TS_msg_imprint_st TS_MSG_IMPRINT; -typedef struct TS_req_st TS_REQ; -typedef struct TS_accuracy_st TS_ACCURACY; -typedef struct TS_tst_info_st TS_TST_INFO; - -/* Possible values for status. */ -# define TS_STATUS_GRANTED 0 -# define TS_STATUS_GRANTED_WITH_MODS 1 -# define TS_STATUS_REJECTION 2 -# define TS_STATUS_WAITING 3 -# define TS_STATUS_REVOCATION_WARNING 4 -# define TS_STATUS_REVOCATION_NOTIFICATION 5 - -/* Possible values for failure_info. */ -# define TS_INFO_BAD_ALG 0 -# define TS_INFO_BAD_REQUEST 2 -# define TS_INFO_BAD_DATA_FORMAT 5 -# define TS_INFO_TIME_NOT_AVAILABLE 14 -# define TS_INFO_UNACCEPTED_POLICY 15 -# define TS_INFO_UNACCEPTED_EXTENSION 16 -# define TS_INFO_ADD_INFO_NOT_AVAILABLE 17 -# define TS_INFO_SYSTEM_FAILURE 25 - - -typedef struct TS_status_info_st TS_STATUS_INFO; -typedef struct ESS_issuer_serial ESS_ISSUER_SERIAL; -typedef struct ESS_cert_id ESS_CERT_ID; -typedef struct ESS_signing_cert ESS_SIGNING_CERT; - -DEFINE_STACK_OF(ESS_CERT_ID) - -typedef struct ESS_cert_id_v2_st ESS_CERT_ID_V2; -typedef struct ESS_signing_cert_v2_st ESS_SIGNING_CERT_V2; - -DEFINE_STACK_OF(ESS_CERT_ID_V2) - -typedef struct TS_resp_st TS_RESP; - -TS_REQ *TS_REQ_new(void); -void TS_REQ_free(TS_REQ *a); -int i2d_TS_REQ(const TS_REQ *a, unsigned char **pp); -TS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length); - -TS_REQ *TS_REQ_dup(TS_REQ *a); - -#ifndef OPENSSL_NO_STDIO -TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a); -int i2d_TS_REQ_fp(FILE *fp, TS_REQ *a); -#endif -TS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a); -int i2d_TS_REQ_bio(BIO *fp, TS_REQ *a); - -TS_MSG_IMPRINT *TS_MSG_IMPRINT_new(void); -void TS_MSG_IMPRINT_free(TS_MSG_IMPRINT *a); -int i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *a, unsigned char **pp); -TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a, - const unsigned char **pp, long length); - -TS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a); - -#ifndef OPENSSL_NO_STDIO -TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a); -int i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a); -#endif -TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT **a); -int i2d_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT *a); - -TS_RESP *TS_RESP_new(void); -void TS_RESP_free(TS_RESP *a); -int i2d_TS_RESP(const TS_RESP *a, unsigned char **pp); -TS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length); -TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token); -TS_RESP *TS_RESP_dup(TS_RESP *a); - -#ifndef OPENSSL_NO_STDIO -TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a); -int i2d_TS_RESP_fp(FILE *fp, TS_RESP *a); -#endif -TS_RESP *d2i_TS_RESP_bio(BIO *bio, TS_RESP **a); -int i2d_TS_RESP_bio(BIO *bio, TS_RESP *a); - -TS_STATUS_INFO *TS_STATUS_INFO_new(void); -void TS_STATUS_INFO_free(TS_STATUS_INFO *a); -int i2d_TS_STATUS_INFO(const TS_STATUS_INFO *a, unsigned char **pp); -TS_STATUS_INFO *d2i_TS_STATUS_INFO(TS_STATUS_INFO **a, - const unsigned char **pp, long length); -TS_STATUS_INFO *TS_STATUS_INFO_dup(TS_STATUS_INFO *a); - -TS_TST_INFO *TS_TST_INFO_new(void); -void TS_TST_INFO_free(TS_TST_INFO *a); -int i2d_TS_TST_INFO(const TS_TST_INFO *a, unsigned char **pp); -TS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp, - long length); -TS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a); - -#ifndef OPENSSL_NO_STDIO -TS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a); -int i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a); -#endif -TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO **a); -int i2d_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO *a); - -TS_ACCURACY *TS_ACCURACY_new(void); -void TS_ACCURACY_free(TS_ACCURACY *a); -int i2d_TS_ACCURACY(const TS_ACCURACY *a, unsigned char **pp); -TS_ACCURACY *d2i_TS_ACCURACY(TS_ACCURACY **a, const unsigned char **pp, - long length); -TS_ACCURACY *TS_ACCURACY_dup(TS_ACCURACY *a); - -ESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_new(void); -void ESS_ISSUER_SERIAL_free(ESS_ISSUER_SERIAL *a); -int i2d_ESS_ISSUER_SERIAL(const ESS_ISSUER_SERIAL *a, unsigned char **pp); -ESS_ISSUER_SERIAL *d2i_ESS_ISSUER_SERIAL(ESS_ISSUER_SERIAL **a, - const unsigned char **pp, - long length); -ESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_dup(ESS_ISSUER_SERIAL *a); - -ESS_CERT_ID *ESS_CERT_ID_new(void); -void ESS_CERT_ID_free(ESS_CERT_ID *a); -int i2d_ESS_CERT_ID(const ESS_CERT_ID *a, unsigned char **pp); -ESS_CERT_ID *d2i_ESS_CERT_ID(ESS_CERT_ID **a, const unsigned char **pp, - long length); -ESS_CERT_ID *ESS_CERT_ID_dup(ESS_CERT_ID *a); - -ESS_SIGNING_CERT *ESS_SIGNING_CERT_new(void); -void ESS_SIGNING_CERT_free(ESS_SIGNING_CERT *a); -int i2d_ESS_SIGNING_CERT(const ESS_SIGNING_CERT *a, unsigned char **pp); -ESS_SIGNING_CERT *d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a, - const unsigned char **pp, long length); -ESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a); - -ESS_CERT_ID_V2 *ESS_CERT_ID_V2_new(void); -void ESS_CERT_ID_V2_free(ESS_CERT_ID_V2 *a); -int i2d_ESS_CERT_ID_V2(const ESS_CERT_ID_V2 *a, unsigned char **pp); -ESS_CERT_ID_V2 *d2i_ESS_CERT_ID_V2(ESS_CERT_ID_V2 **a, - const unsigned char **pp, long length); -ESS_CERT_ID_V2 *ESS_CERT_ID_V2_dup(ESS_CERT_ID_V2 *a); - -ESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_new(void); -void ESS_SIGNING_CERT_V2_free(ESS_SIGNING_CERT_V2 *a); -int i2d_ESS_SIGNING_CERT_V2(const ESS_SIGNING_CERT_V2 *a, unsigned char **pp); -ESS_SIGNING_CERT_V2 *d2i_ESS_SIGNING_CERT_V2(ESS_SIGNING_CERT_V2 **a, - const unsigned char **pp, - long length); -ESS_SIGNING_CERT_V2 *ESS_SIGNING_CERT_V2_dup(ESS_SIGNING_CERT_V2 *a); - -int TS_REQ_set_version(TS_REQ *a, long version); -long TS_REQ_get_version(const TS_REQ *a); - -int TS_STATUS_INFO_set_status(TS_STATUS_INFO *a, int i); -const ASN1_INTEGER *TS_STATUS_INFO_get0_status(const TS_STATUS_INFO *a); - -const STACK_OF(ASN1_UTF8STRING) * -TS_STATUS_INFO_get0_text(const TS_STATUS_INFO *a); - -const ASN1_BIT_STRING * -TS_STATUS_INFO_get0_failure_info(const TS_STATUS_INFO *a); - -int TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint); -TS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a); - -int TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg); -X509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a); - -int TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len); -ASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a); - -int TS_REQ_set_policy_id(TS_REQ *a, const ASN1_OBJECT *policy); -ASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a); - -int TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce); -const ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a); - -int TS_REQ_set_cert_req(TS_REQ *a, int cert_req); -int TS_REQ_get_cert_req(const TS_REQ *a); - -STACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a); -void TS_REQ_ext_free(TS_REQ *a); -int TS_REQ_get_ext_count(TS_REQ *a); -int TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos); -int TS_REQ_get_ext_by_OBJ(TS_REQ *a, const ASN1_OBJECT *obj, int lastpos); -int TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos); -X509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc); -X509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc); -int TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc); -void *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx); - -/* Function declarations for TS_REQ defined in ts/ts_req_print.c */ - -int TS_REQ_print_bio(BIO *bio, TS_REQ *a); - -/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */ - -int TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info); -TS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a); - -/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */ -void TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info); -PKCS7 *TS_RESP_get_token(TS_RESP *a); -TS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a); - -int TS_TST_INFO_set_version(TS_TST_INFO *a, long version); -long TS_TST_INFO_get_version(const TS_TST_INFO *a); - -int TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id); -ASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a); - -int TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint); -TS_MSG_IMPRINT *TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a); - -int TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial); -const ASN1_INTEGER *TS_TST_INFO_get_serial(const TS_TST_INFO *a); - -int TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime); -const ASN1_GENERALIZEDTIME *TS_TST_INFO_get_time(const TS_TST_INFO *a); - -int TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy); -TS_ACCURACY *TS_TST_INFO_get_accuracy(TS_TST_INFO *a); - -int TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds); -const ASN1_INTEGER *TS_ACCURACY_get_seconds(const TS_ACCURACY *a); - -int TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis); -const ASN1_INTEGER *TS_ACCURACY_get_millis(const TS_ACCURACY *a); - -int TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros); -const ASN1_INTEGER *TS_ACCURACY_get_micros(const TS_ACCURACY *a); - -int TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering); -int TS_TST_INFO_get_ordering(const TS_TST_INFO *a); - -int TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce); -const ASN1_INTEGER *TS_TST_INFO_get_nonce(const TS_TST_INFO *a); - -int TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa); -GENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a); - -STACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a); -void TS_TST_INFO_ext_free(TS_TST_INFO *a); -int TS_TST_INFO_get_ext_count(TS_TST_INFO *a); -int TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos); -int TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj, - int lastpos); -int TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos); -X509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc); -X509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc); -int TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc); -void *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx); - -/* - * Declarations related to response generation, defined in ts/ts_resp_sign.c. - */ - -/* Optional flags for response generation. */ - -/* Don't include the TSA name in response. */ -# define TS_TSA_NAME 0x01 - -/* Set ordering to true in response. */ -# define TS_ORDERING 0x02 - -/* - * Include the signer certificate and the other specified certificates in - * the ESS signing certificate attribute beside the PKCS7 signed data. - * Only the signer certificates is included by default. - */ -# define TS_ESS_CERT_ID_CHAIN 0x04 - -/* Forward declaration. */ -struct TS_resp_ctx; - -/* This must return a unique number less than 160 bits long. */ -typedef ASN1_INTEGER *(*TS_serial_cb) (struct TS_resp_ctx *, void *); - -/* - * This must return the seconds and microseconds since Jan 1, 1970 in the sec - * and usec variables allocated by the caller. Return non-zero for success - * and zero for failure. - */ -typedef int (*TS_time_cb) (struct TS_resp_ctx *, void *, long *sec, - long *usec); - -/* - * This must process the given extension. It can modify the TS_TST_INFO - * object of the context. Return values: !0 (processed), 0 (error, it must - * set the status info/failure info of the response). - */ -typedef int (*TS_extension_cb) (struct TS_resp_ctx *, X509_EXTENSION *, - void *); - -typedef struct TS_resp_ctx TS_RESP_CTX; - -DEFINE_STACK_OF_CONST(EVP_MD) - -/* Creates a response context that can be used for generating responses. */ -TS_RESP_CTX *TS_RESP_CTX_new(void); -void TS_RESP_CTX_free(TS_RESP_CTX *ctx); - -/* This parameter must be set. */ -int TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer); - -/* This parameter must be set. */ -int TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key); - -int TS_RESP_CTX_set_signer_digest(TS_RESP_CTX *ctx, - const EVP_MD *signer_digest); -int TS_RESP_CTX_set_ess_cert_id_digest(TS_RESP_CTX *ctx, const EVP_MD *md); - -/* This parameter must be set. */ -int TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *def_policy); - -/* No additional certs are included in the response by default. */ -int TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs); - -/* - * Adds a new acceptable policy, only the default policy is accepted by - * default. - */ -int TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *policy); - -/* - * Adds a new acceptable message digest. Note that no message digests are - * accepted by default. The md argument is shared with the caller. - */ -int TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md); - -/* Accuracy is not included by default. */ -int TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx, - int secs, int millis, int micros); - -/* - * Clock precision digits, i.e. the number of decimal digits: '0' means sec, - * '3' msec, '6' usec, and so on. Default is 0. - */ -int TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx, - unsigned clock_precision_digits); -/* At most we accept usec precision. */ -# define TS_MAX_CLOCK_PRECISION_DIGITS 6 - -/* Maximum status message length */ -# define TS_MAX_STATUS_LENGTH (1024 * 1024) - -/* No flags are set by default. */ -void TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags); - -/* Default callback always returns a constant. */ -void TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data); - -/* Default callback uses the gettimeofday() and gmtime() system calls. */ -void TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data); - -/* - * Default callback rejects all extensions. The extension callback is called - * when the TS_TST_INFO object is already set up and not signed yet. - */ -/* FIXME: extension handling is not tested yet. */ -void TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx, - TS_extension_cb cb, void *data); - -/* The following methods can be used in the callbacks. */ -int TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx, - int status, const char *text); - -/* Sets the status info only if it is still TS_STATUS_GRANTED. */ -int TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx, - int status, const char *text); - -int TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure); - -/* The get methods below can be used in the extension callback. */ -TS_REQ *TS_RESP_CTX_get_request(TS_RESP_CTX *ctx); - -TS_TST_INFO *TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx); - -/* - * Creates the signed TS_TST_INFO and puts it in TS_RESP. - * In case of errors it sets the status info properly. - * Returns NULL only in case of memory allocation/fatal error. - */ -TS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio); - -/* - * Declarations related to response verification, - * they are defined in ts/ts_resp_verify.c. - */ - -int TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs, - X509_STORE *store, X509 **signer_out); - -/* Context structure for the generic verify method. */ - -/* Verify the signer's certificate and the signature of the response. */ -# define TS_VFY_SIGNATURE (1u << 0) -/* Verify the version number of the response. */ -# define TS_VFY_VERSION (1u << 1) -/* Verify if the policy supplied by the user matches the policy of the TSA. */ -# define TS_VFY_POLICY (1u << 2) -/* - * Verify the message imprint provided by the user. This flag should not be - * specified with TS_VFY_DATA. - */ -# define TS_VFY_IMPRINT (1u << 3) -/* - * Verify the message imprint computed by the verify method from the user - * provided data and the MD algorithm of the response. This flag should not - * be specified with TS_VFY_IMPRINT. - */ -# define TS_VFY_DATA (1u << 4) -/* Verify the nonce value. */ -# define TS_VFY_NONCE (1u << 5) -/* Verify if the TSA name field matches the signer certificate. */ -# define TS_VFY_SIGNER (1u << 6) -/* Verify if the TSA name field equals to the user provided name. */ -# define TS_VFY_TSA_NAME (1u << 7) - -/* You can use the following convenience constants. */ -# define TS_VFY_ALL_IMPRINT (TS_VFY_SIGNATURE \ - | TS_VFY_VERSION \ - | TS_VFY_POLICY \ - | TS_VFY_IMPRINT \ - | TS_VFY_NONCE \ - | TS_VFY_SIGNER \ - | TS_VFY_TSA_NAME) -# define TS_VFY_ALL_DATA (TS_VFY_SIGNATURE \ - | TS_VFY_VERSION \ - | TS_VFY_POLICY \ - | TS_VFY_DATA \ - | TS_VFY_NONCE \ - | TS_VFY_SIGNER \ - | TS_VFY_TSA_NAME) - -typedef struct TS_verify_ctx TS_VERIFY_CTX; - -int TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response); -int TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token); - -/* - * Declarations related to response verification context, - */ -TS_VERIFY_CTX *TS_VERIFY_CTX_new(void); -void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx); -void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx); -void TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx); -int TS_VERIFY_CTX_set_flags(TS_VERIFY_CTX *ctx, int f); -int TS_VERIFY_CTX_add_flags(TS_VERIFY_CTX *ctx, int f); -BIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b); -unsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx, - unsigned char *hexstr, long len); -X509_STORE *TS_VERIFY_CTX_set_store(TS_VERIFY_CTX *ctx, X509_STORE *s); -STACK_OF(X509) *TS_VERIFY_CTS_set_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) *certs); - -/*- - * If ctx is NULL, it allocates and returns a new object, otherwise - * it returns ctx. It initialises all the members as follows: - * flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE) - * certs = NULL - * store = NULL - * policy = policy from the request or NULL if absent (in this case - * TS_VFY_POLICY is cleared from flags as well) - * md_alg = MD algorithm from request - * imprint, imprint_len = imprint from request - * data = NULL - * nonce, nonce_len = nonce from the request or NULL if absent (in this case - * TS_VFY_NONCE is cleared from flags as well) - * tsa_name = NULL - * Important: after calling this method TS_VFY_SIGNATURE should be added! - */ -TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx); - -/* Function declarations for TS_RESP defined in ts/ts_resp_print.c */ - -int TS_RESP_print_bio(BIO *bio, TS_RESP *a); -int TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a); -int TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a); - -/* Common utility functions defined in ts/ts_lib.c */ - -int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num); -int TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj); -int TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions); -int TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg); -int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg); - -/* - * Function declarations for handling configuration options, defined in - * ts/ts_conf.c - */ - -X509 *TS_CONF_load_cert(const char *file); -STACK_OF(X509) *TS_CONF_load_certs(const char *file); -EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass); -const char *TS_CONF_get_tsa_section(CONF *conf, const char *section); -int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb, - TS_RESP_CTX *ctx); -#ifndef OPENSSL_NO_ENGINE -int TS_CONF_set_crypto_device(CONF *conf, const char *section, - const char *device); -int TS_CONF_set_default_engine(const char *name); -#endif -int TS_CONF_set_signer_cert(CONF *conf, const char *section, - const char *cert, TS_RESP_CTX *ctx); -int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs, - TS_RESP_CTX *ctx); -int TS_CONF_set_signer_key(CONF *conf, const char *section, - const char *key, const char *pass, - TS_RESP_CTX *ctx); -int TS_CONF_set_signer_digest(CONF *conf, const char *section, - const char *md, TS_RESP_CTX *ctx); -int TS_CONF_set_def_policy(CONF *conf, const char *section, - const char *policy, TS_RESP_CTX *ctx); -int TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_clock_precision_digits(CONF *conf, const char *section, - TS_RESP_CTX *ctx); -int TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section, - TS_RESP_CTX *ctx); -int TS_CONF_set_ess_cert_id_digest(CONF *conf, const char *section, - TS_RESP_CTX *ctx); - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/tserr.h b/client/3rd/OpenSSL/include/openssl/tserr.h deleted file mode 100644 index 07f23339..00000000 --- a/client/3rd/OpenSSL/include/openssl/tserr.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_TSERR_H -# define HEADER_TSERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# include - -# ifndef OPENSSL_NO_TS - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_TS_strings(void); - -/* - * TS function codes. - */ -# define TS_F_DEF_SERIAL_CB 110 -# define TS_F_DEF_TIME_CB 111 -# define TS_F_ESS_ADD_SIGNING_CERT 112 -# define TS_F_ESS_ADD_SIGNING_CERT_V2 147 -# define TS_F_ESS_CERT_ID_NEW_INIT 113 -# define TS_F_ESS_CERT_ID_V2_NEW_INIT 156 -# define TS_F_ESS_SIGNING_CERT_NEW_INIT 114 -# define TS_F_ESS_SIGNING_CERT_V2_NEW_INIT 157 -# define TS_F_INT_TS_RESP_VERIFY_TOKEN 149 -# define TS_F_PKCS7_TO_TS_TST_INFO 148 -# define TS_F_TS_ACCURACY_SET_MICROS 115 -# define TS_F_TS_ACCURACY_SET_MILLIS 116 -# define TS_F_TS_ACCURACY_SET_SECONDS 117 -# define TS_F_TS_CHECK_IMPRINTS 100 -# define TS_F_TS_CHECK_NONCES 101 -# define TS_F_TS_CHECK_POLICY 102 -# define TS_F_TS_CHECK_SIGNING_CERTS 103 -# define TS_F_TS_CHECK_STATUS_INFO 104 -# define TS_F_TS_COMPUTE_IMPRINT 145 -# define TS_F_TS_CONF_INVALID 151 -# define TS_F_TS_CONF_LOAD_CERT 153 -# define TS_F_TS_CONF_LOAD_CERTS 154 -# define TS_F_TS_CONF_LOAD_KEY 155 -# define TS_F_TS_CONF_LOOKUP_FAIL 152 -# define TS_F_TS_CONF_SET_DEFAULT_ENGINE 146 -# define TS_F_TS_GET_STATUS_TEXT 105 -# define TS_F_TS_MSG_IMPRINT_SET_ALGO 118 -# define TS_F_TS_REQ_SET_MSG_IMPRINT 119 -# define TS_F_TS_REQ_SET_NONCE 120 -# define TS_F_TS_REQ_SET_POLICY_ID 121 -# define TS_F_TS_RESP_CREATE_RESPONSE 122 -# define TS_F_TS_RESP_CREATE_TST_INFO 123 -# define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO 124 -# define TS_F_TS_RESP_CTX_ADD_MD 125 -# define TS_F_TS_RESP_CTX_ADD_POLICY 126 -# define TS_F_TS_RESP_CTX_NEW 127 -# define TS_F_TS_RESP_CTX_SET_ACCURACY 128 -# define TS_F_TS_RESP_CTX_SET_CERTS 129 -# define TS_F_TS_RESP_CTX_SET_DEF_POLICY 130 -# define TS_F_TS_RESP_CTX_SET_SIGNER_CERT 131 -# define TS_F_TS_RESP_CTX_SET_STATUS_INFO 132 -# define TS_F_TS_RESP_GET_POLICY 133 -# define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION 134 -# define TS_F_TS_RESP_SET_STATUS_INFO 135 -# define TS_F_TS_RESP_SET_TST_INFO 150 -# define TS_F_TS_RESP_SIGN 136 -# define TS_F_TS_RESP_VERIFY_SIGNATURE 106 -# define TS_F_TS_TST_INFO_SET_ACCURACY 137 -# define TS_F_TS_TST_INFO_SET_MSG_IMPRINT 138 -# define TS_F_TS_TST_INFO_SET_NONCE 139 -# define TS_F_TS_TST_INFO_SET_POLICY_ID 140 -# define TS_F_TS_TST_INFO_SET_SERIAL 141 -# define TS_F_TS_TST_INFO_SET_TIME 142 -# define TS_F_TS_TST_INFO_SET_TSA 143 -# define TS_F_TS_VERIFY 108 -# define TS_F_TS_VERIFY_CERT 109 -# define TS_F_TS_VERIFY_CTX_NEW 144 - -/* - * TS reason codes. - */ -# define TS_R_BAD_PKCS7_TYPE 132 -# define TS_R_BAD_TYPE 133 -# define TS_R_CANNOT_LOAD_CERT 137 -# define TS_R_CANNOT_LOAD_KEY 138 -# define TS_R_CERTIFICATE_VERIFY_ERROR 100 -# define TS_R_COULD_NOT_SET_ENGINE 127 -# define TS_R_COULD_NOT_SET_TIME 115 -# define TS_R_DETACHED_CONTENT 134 -# define TS_R_ESS_ADD_SIGNING_CERT_ERROR 116 -# define TS_R_ESS_ADD_SIGNING_CERT_V2_ERROR 139 -# define TS_R_ESS_SIGNING_CERTIFICATE_ERROR 101 -# define TS_R_INVALID_NULL_POINTER 102 -# define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE 117 -# define TS_R_MESSAGE_IMPRINT_MISMATCH 103 -# define TS_R_NONCE_MISMATCH 104 -# define TS_R_NONCE_NOT_RETURNED 105 -# define TS_R_NO_CONTENT 106 -# define TS_R_NO_TIME_STAMP_TOKEN 107 -# define TS_R_PKCS7_ADD_SIGNATURE_ERROR 118 -# define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR 119 -# define TS_R_PKCS7_TO_TS_TST_INFO_FAILED 129 -# define TS_R_POLICY_MISMATCH 108 -# define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 120 -# define TS_R_RESPONSE_SETUP_ERROR 121 -# define TS_R_SIGNATURE_FAILURE 109 -# define TS_R_THERE_MUST_BE_ONE_SIGNER 110 -# define TS_R_TIME_SYSCALL_ERROR 122 -# define TS_R_TOKEN_NOT_PRESENT 130 -# define TS_R_TOKEN_PRESENT 131 -# define TS_R_TSA_NAME_MISMATCH 111 -# define TS_R_TSA_UNTRUSTED 112 -# define TS_R_TST_INFO_SETUP_ERROR 123 -# define TS_R_TS_DATASIGN 124 -# define TS_R_UNACCEPTABLE_POLICY 125 -# define TS_R_UNSUPPORTED_MD_ALGORITHM 126 -# define TS_R_UNSUPPORTED_VERSION 113 -# define TS_R_VAR_BAD_VALUE 135 -# define TS_R_VAR_LOOKUP_FAILURE 136 -# define TS_R_WRONG_CONTENT_TYPE 114 - -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/txt_db.h b/client/3rd/OpenSSL/include/openssl/txt_db.h deleted file mode 100644 index ec981a43..00000000 --- a/client/3rd/OpenSSL/include/openssl/txt_db.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_TXT_DB_H -# define HEADER_TXT_DB_H - -# include -# include -# include -# include - -# define DB_ERROR_OK 0 -# define DB_ERROR_MALLOC 1 -# define DB_ERROR_INDEX_CLASH 2 -# define DB_ERROR_INDEX_OUT_OF_RANGE 3 -# define DB_ERROR_NO_INDEX 4 -# define DB_ERROR_INSERT_INDEX_CLASH 5 -# define DB_ERROR_WRONG_NUM_FIELDS 6 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef OPENSSL_STRING *OPENSSL_PSTRING; -DEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING) - -typedef struct txt_db_st { - int num_fields; - STACK_OF(OPENSSL_PSTRING) *data; - LHASH_OF(OPENSSL_STRING) **index; - int (**qual) (OPENSSL_STRING *); - long error; - long arg1; - long arg2; - OPENSSL_STRING *arg_row; -} TXT_DB; - -TXT_DB *TXT_DB_read(BIO *in, int num); -long TXT_DB_write(BIO *out, TXT_DB *db); -int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *), - OPENSSL_LH_HASHFUNC hash, OPENSSL_LH_COMPFUNC cmp); -void TXT_DB_free(TXT_DB *db); -OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, - OPENSSL_STRING *value); -int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/ui.h b/client/3rd/OpenSSL/include/openssl/ui.h deleted file mode 100644 index 7c721ec8..00000000 --- a/client/3rd/OpenSSL/include/openssl/ui.h +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_UI_H -# define HEADER_UI_H - -# include - -# if OPENSSL_API_COMPAT < 0x10100000L -# include -# endif -# include -# include -# include -# include - -/* For compatibility reasons, the macro OPENSSL_NO_UI is currently retained */ -# if OPENSSL_API_COMPAT < 0x10200000L -# ifdef OPENSSL_NO_UI_CONSOLE -# define OPENSSL_NO_UI -# endif -# endif - -# ifdef __cplusplus -extern "C" { -# endif - -/* - * All the following functions return -1 or NULL on error and in some cases - * (UI_process()) -2 if interrupted or in some other way cancelled. When - * everything is fine, they return 0, a positive value or a non-NULL pointer, - * all depending on their purpose. - */ - -/* Creators and destructor. */ -UI *UI_new(void); -UI *UI_new_method(const UI_METHOD *method); -void UI_free(UI *ui); - -/*- - The following functions are used to add strings to be printed and prompt - strings to prompt for data. The names are UI_{add,dup}__string - and UI_{add,dup}_input_boolean. - - UI_{add,dup}__string have the following meanings: - add add a text or prompt string. The pointers given to these - functions are used verbatim, no copying is done. - dup make a copy of the text or prompt string, then add the copy - to the collection of strings in the user interface. - - The function is a name for the functionality that the given - string shall be used for. It can be one of: - input use the string as data prompt. - verify use the string as verification prompt. This - is used to verify a previous input. - info use the string for informational output. - error use the string for error output. - Honestly, there's currently no difference between info and error for the - moment. - - UI_{add,dup}_input_boolean have the same semantics for "add" and "dup", - and are typically used when one wants to prompt for a yes/no response. - - All of the functions in this group take a UI and a prompt string. - The string input and verify addition functions also take a flag argument, - a buffer for the result to end up with, a minimum input size and a maximum - input size (the result buffer MUST be large enough to be able to contain - the maximum number of characters). Additionally, the verify addition - functions takes another buffer to compare the result against. - The boolean input functions take an action description string (which should - be safe to ignore if the expected user action is obvious, for example with - a dialog box with an OK button and a Cancel button), a string of acceptable - characters to mean OK and to mean Cancel. The two last strings are checked - to make sure they don't have common characters. Additionally, the same - flag argument as for the string input is taken, as well as a result buffer. - The result buffer is required to be at least one byte long. Depending on - the answer, the first character from the OK or the Cancel character strings - will be stored in the first byte of the result buffer. No NUL will be - added, so the result is *not* a string. - - On success, the all return an index of the added information. That index - is useful when retrieving results with UI_get0_result(). */ -int UI_add_input_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize); -int UI_dup_input_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize); -int UI_add_verify_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize, - const char *test_buf); -int UI_dup_verify_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize, - const char *test_buf); -int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, - const char *ok_chars, const char *cancel_chars, - int flags, char *result_buf); -int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, - const char *ok_chars, const char *cancel_chars, - int flags, char *result_buf); -int UI_add_info_string(UI *ui, const char *text); -int UI_dup_info_string(UI *ui, const char *text); -int UI_add_error_string(UI *ui, const char *text); -int UI_dup_error_string(UI *ui, const char *text); - -/* These are the possible flags. They can be or'ed together. */ -/* Use to have echoing of input */ -# define UI_INPUT_FLAG_ECHO 0x01 -/* - * Use a default password. Where that password is found is completely up to - * the application, it might for example be in the user data set with - * UI_add_user_data(). It is not recommended to have more than one input in - * each UI being marked with this flag, or the application might get - * confused. - */ -# define UI_INPUT_FLAG_DEFAULT_PWD 0x02 - -/*- - * The user of these routines may want to define flags of their own. The core - * UI won't look at those, but will pass them on to the method routines. They - * must use higher bits so they don't get confused with the UI bits above. - * UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good - * example of use is this: - * - * #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE) - * -*/ -# define UI_INPUT_FLAG_USER_BASE 16 - -/*- - * The following function helps construct a prompt. object_desc is a - * textual short description of the object, for example "pass phrase", - * and object_name is the name of the object (might be a card name or - * a file name. - * The returned string shall always be allocated on the heap with - * OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). - * - * If the ui_method doesn't contain a pointer to a user-defined prompt - * constructor, a default string is built, looking like this: - * - * "Enter {object_desc} for {object_name}:" - * - * So, if object_desc has the value "pass phrase" and object_name has - * the value "foo.key", the resulting string is: - * - * "Enter pass phrase for foo.key:" -*/ -char *UI_construct_prompt(UI *ui_method, - const char *object_desc, const char *object_name); - -/* - * The following function is used to store a pointer to user-specific data. - * Any previous such pointer will be returned and replaced. - * - * For callback purposes, this function makes a lot more sense than using - * ex_data, since the latter requires that different parts of OpenSSL or - * applications share the same ex_data index. - * - * Note that the UI_OpenSSL() method completely ignores the user data. Other - * methods may not, however. - */ -void *UI_add_user_data(UI *ui, void *user_data); -/* - * Alternatively, this function is used to duplicate the user data. - * This uses the duplicator method function. The destroy function will - * be used to free the user data in this case. - */ -int UI_dup_user_data(UI *ui, void *user_data); -/* We need a user data retrieving function as well. */ -void *UI_get0_user_data(UI *ui); - -/* Return the result associated with a prompt given with the index i. */ -const char *UI_get0_result(UI *ui, int i); -int UI_get_result_length(UI *ui, int i); - -/* When all strings have been added, process the whole thing. */ -int UI_process(UI *ui); - -/* - * Give a user interface parameterised control commands. This can be used to - * send down an integer, a data pointer or a function pointer, as well as be - * used to get information from a UI. - */ -int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void)); - -/* The commands */ -/* - * Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the - * OpenSSL error stack before printing any info or added error messages and - * before any prompting. - */ -# define UI_CTRL_PRINT_ERRORS 1 -/* - * Check if a UI_process() is possible to do again with the same instance of - * a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0 - * if not. - */ -# define UI_CTRL_IS_REDOABLE 2 - -/* Some methods may use extra data */ -# define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg) -# define UI_get_app_data(s) UI_get_ex_data(s,0) - -# define UI_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, l, p, newf, dupf, freef) -int UI_set_ex_data(UI *r, int idx, void *arg); -void *UI_get_ex_data(UI *r, int idx); - -/* Use specific methods instead of the built-in one */ -void UI_set_default_method(const UI_METHOD *meth); -const UI_METHOD *UI_get_default_method(void); -const UI_METHOD *UI_get_method(UI *ui); -const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth); - -# ifndef OPENSSL_NO_UI_CONSOLE - -/* The method with all the built-in thingies */ -UI_METHOD *UI_OpenSSL(void); - -# endif - -/* - * NULL method. Literally does nothing, but may serve as a placeholder - * to avoid internal default. - */ -const UI_METHOD *UI_null(void); - -/* ---------- For method writers ---------- */ -/*- - A method contains a number of functions that implement the low level - of the User Interface. The functions are: - - an opener This function starts a session, maybe by opening - a channel to a tty, or by opening a window. - a writer This function is called to write a given string, - maybe to the tty, maybe as a field label in a - window. - a flusher This function is called to flush everything that - has been output so far. It can be used to actually - display a dialog box after it has been built. - a reader This function is called to read a given prompt, - maybe from the tty, maybe from a field in a - window. Note that it's called with all string - structures, not only the prompt ones, so it must - check such things itself. - a closer This function closes the session, maybe by closing - the channel to the tty, or closing the window. - - All these functions are expected to return: - - 0 on error. - 1 on success. - -1 on out-of-band events, for example if some prompting has - been canceled (by pressing Ctrl-C, for example). This is - only checked when returned by the flusher or the reader. - - The way this is used, the opener is first called, then the writer for all - strings, then the flusher, then the reader for all strings and finally the - closer. Note that if you want to prompt from a terminal or other command - line interface, the best is to have the reader also write the prompts - instead of having the writer do it. If you want to prompt from a dialog - box, the writer can be used to build up the contents of the box, and the - flusher to actually display the box and run the event loop until all data - has been given, after which the reader only grabs the given data and puts - them back into the UI strings. - - All method functions take a UI as argument. Additionally, the writer and - the reader take a UI_STRING. -*/ - -/* - * The UI_STRING type is the data structure that contains all the needed info - * about a string or a prompt, including test data for a verification prompt. - */ -typedef struct ui_string_st UI_STRING; -DEFINE_STACK_OF(UI_STRING) - -/* - * The different types of strings that are currently supported. This is only - * needed by method authors. - */ -enum UI_string_types { - UIT_NONE = 0, - UIT_PROMPT, /* Prompt for a string */ - UIT_VERIFY, /* Prompt for a string and verify */ - UIT_BOOLEAN, /* Prompt for a yes/no response */ - UIT_INFO, /* Send info to the user */ - UIT_ERROR /* Send an error message to the user */ -}; - -/* Create and manipulate methods */ -UI_METHOD *UI_create_method(const char *name); -void UI_destroy_method(UI_METHOD *ui_method); -int UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui)); -int UI_method_set_writer(UI_METHOD *method, - int (*writer) (UI *ui, UI_STRING *uis)); -int UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui)); -int UI_method_set_reader(UI_METHOD *method, - int (*reader) (UI *ui, UI_STRING *uis)); -int UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui)); -int UI_method_set_data_duplicator(UI_METHOD *method, - void *(*duplicator) (UI *ui, void *ui_data), - void (*destructor)(UI *ui, void *ui_data)); -int UI_method_set_prompt_constructor(UI_METHOD *method, - char *(*prompt_constructor) (UI *ui, - const char - *object_desc, - const char - *object_name)); -int UI_method_set_ex_data(UI_METHOD *method, int idx, void *data); -int (*UI_method_get_opener(const UI_METHOD *method)) (UI *); -int (*UI_method_get_writer(const UI_METHOD *method)) (UI *, UI_STRING *); -int (*UI_method_get_flusher(const UI_METHOD *method)) (UI *); -int (*UI_method_get_reader(const UI_METHOD *method)) (UI *, UI_STRING *); -int (*UI_method_get_closer(const UI_METHOD *method)) (UI *); -char *(*UI_method_get_prompt_constructor(const UI_METHOD *method)) - (UI *, const char *, const char *); -void *(*UI_method_get_data_duplicator(const UI_METHOD *method)) (UI *, void *); -void (*UI_method_get_data_destructor(const UI_METHOD *method)) (UI *, void *); -const void *UI_method_get_ex_data(const UI_METHOD *method, int idx); - -/* - * The following functions are helpers for method writers to access relevant - * data from a UI_STRING. - */ - -/* Return type of the UI_STRING */ -enum UI_string_types UI_get_string_type(UI_STRING *uis); -/* Return input flags of the UI_STRING */ -int UI_get_input_flags(UI_STRING *uis); -/* Return the actual string to output (the prompt, info or error) */ -const char *UI_get0_output_string(UI_STRING *uis); -/* - * Return the optional action string to output (the boolean prompt - * instruction) - */ -const char *UI_get0_action_string(UI_STRING *uis); -/* Return the result of a prompt */ -const char *UI_get0_result_string(UI_STRING *uis); -int UI_get_result_string_length(UI_STRING *uis); -/* - * Return the string to test the result against. Only useful with verifies. - */ -const char *UI_get0_test_string(UI_STRING *uis); -/* Return the required minimum size of the result */ -int UI_get_result_minsize(UI_STRING *uis); -/* Return the required maximum size of the result */ -int UI_get_result_maxsize(UI_STRING *uis); -/* Set the result of a UI_STRING. */ -int UI_set_result(UI *ui, UI_STRING *uis, const char *result); -int UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len); - -/* A couple of popular utility functions */ -int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, - int verify); -int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, - int verify); -UI_METHOD *UI_UTIL_wrap_read_pem_callback(pem_password_cb *cb, int rwflag); - - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/uierr.h b/client/3rd/OpenSSL/include/openssl/uierr.h deleted file mode 100644 index bd68864d..00000000 --- a/client/3rd/OpenSSL/include/openssl/uierr.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_UIERR_H -# define HEADER_UIERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_UI_strings(void); - -/* - * UI function codes. - */ -# define UI_F_CLOSE_CONSOLE 115 -# define UI_F_ECHO_CONSOLE 116 -# define UI_F_GENERAL_ALLOCATE_BOOLEAN 108 -# define UI_F_GENERAL_ALLOCATE_PROMPT 109 -# define UI_F_NOECHO_CONSOLE 117 -# define UI_F_OPEN_CONSOLE 114 -# define UI_F_UI_CONSTRUCT_PROMPT 121 -# define UI_F_UI_CREATE_METHOD 112 -# define UI_F_UI_CTRL 111 -# define UI_F_UI_DUP_ERROR_STRING 101 -# define UI_F_UI_DUP_INFO_STRING 102 -# define UI_F_UI_DUP_INPUT_BOOLEAN 110 -# define UI_F_UI_DUP_INPUT_STRING 103 -# define UI_F_UI_DUP_USER_DATA 118 -# define UI_F_UI_DUP_VERIFY_STRING 106 -# define UI_F_UI_GET0_RESULT 107 -# define UI_F_UI_GET_RESULT_LENGTH 119 -# define UI_F_UI_NEW_METHOD 104 -# define UI_F_UI_PROCESS 113 -# define UI_F_UI_SET_RESULT 105 -# define UI_F_UI_SET_RESULT_EX 120 - -/* - * UI reason codes. - */ -# define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104 -# define UI_R_INDEX_TOO_LARGE 102 -# define UI_R_INDEX_TOO_SMALL 103 -# define UI_R_NO_RESULT_BUFFER 105 -# define UI_R_PROCESSING_ERROR 107 -# define UI_R_RESULT_TOO_LARGE 100 -# define UI_R_RESULT_TOO_SMALL 101 -# define UI_R_SYSASSIGN_ERROR 109 -# define UI_R_SYSDASSGN_ERROR 110 -# define UI_R_SYSQIOW_ERROR 111 -# define UI_R_UNKNOWN_CONTROL_COMMAND 106 -# define UI_R_UNKNOWN_TTYGET_ERRNO_VALUE 108 -# define UI_R_USER_DATA_DUPLICATION_UNSUPPORTED 112 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/whrlpool.h b/client/3rd/OpenSSL/include/openssl/whrlpool.h deleted file mode 100644 index 20ea3503..00000000 --- a/client/3rd/OpenSSL/include/openssl/whrlpool.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_WHRLPOOL_H -# define HEADER_WHRLPOOL_H - -#include - -# ifndef OPENSSL_NO_WHIRLPOOL -# include -# include -# ifdef __cplusplus -extern "C" { -# endif - -# define WHIRLPOOL_DIGEST_LENGTH (512/8) -# define WHIRLPOOL_BBLOCK 512 -# define WHIRLPOOL_COUNTER (256/8) - -typedef struct { - union { - unsigned char c[WHIRLPOOL_DIGEST_LENGTH]; - /* double q is here to ensure 64-bit alignment */ - double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)]; - } H; - unsigned char data[WHIRLPOOL_BBLOCK / 8]; - unsigned int bitoff; - size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)]; -} WHIRLPOOL_CTX; - -int WHIRLPOOL_Init(WHIRLPOOL_CTX *c); -int WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes); -void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits); -int WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c); -unsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/x509.h b/client/3rd/OpenSSL/include/openssl/x509.h deleted file mode 100644 index 3ff86ec7..00000000 --- a/client/3rd/OpenSSL/include/openssl/x509.h +++ /dev/null @@ -1,1050 +0,0 @@ -/* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_X509_H -# define HEADER_X509_H - -# include -# include -# include -# include -# include -# include -# include -# include -# include - -# if OPENSSL_API_COMPAT < 0x10100000L -# include -# include -# include -# endif - -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Flags for X509_get_signature_info() */ -/* Signature info is valid */ -# define X509_SIG_INFO_VALID 0x1 -/* Signature is suitable for TLS use */ -# define X509_SIG_INFO_TLS 0x2 - -# define X509_FILETYPE_PEM 1 -# define X509_FILETYPE_ASN1 2 -# define X509_FILETYPE_DEFAULT 3 - -# define X509v3_KU_DIGITAL_SIGNATURE 0x0080 -# define X509v3_KU_NON_REPUDIATION 0x0040 -# define X509v3_KU_KEY_ENCIPHERMENT 0x0020 -# define X509v3_KU_DATA_ENCIPHERMENT 0x0010 -# define X509v3_KU_KEY_AGREEMENT 0x0008 -# define X509v3_KU_KEY_CERT_SIGN 0x0004 -# define X509v3_KU_CRL_SIGN 0x0002 -# define X509v3_KU_ENCIPHER_ONLY 0x0001 -# define X509v3_KU_DECIPHER_ONLY 0x8000 -# define X509v3_KU_UNDEF 0xffff - -struct X509_algor_st { - ASN1_OBJECT *algorithm; - ASN1_TYPE *parameter; -} /* X509_ALGOR */ ; - -typedef STACK_OF(X509_ALGOR) X509_ALGORS; - -typedef struct X509_val_st { - ASN1_TIME *notBefore; - ASN1_TIME *notAfter; -} X509_VAL; - -typedef struct X509_sig_st X509_SIG; - -typedef struct X509_name_entry_st X509_NAME_ENTRY; - -DEFINE_STACK_OF(X509_NAME_ENTRY) - -DEFINE_STACK_OF(X509_NAME) - -# define X509_EX_V_NETSCAPE_HACK 0x8000 -# define X509_EX_V_INIT 0x0001 -typedef struct X509_extension_st X509_EXTENSION; - -typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS; - -DEFINE_STACK_OF(X509_EXTENSION) - -typedef struct x509_attributes_st X509_ATTRIBUTE; - -DEFINE_STACK_OF(X509_ATTRIBUTE) - -typedef struct X509_req_info_st X509_REQ_INFO; - -typedef struct X509_req_st X509_REQ; - -typedef struct x509_cert_aux_st X509_CERT_AUX; - -typedef struct x509_cinf_st X509_CINF; - -DEFINE_STACK_OF(X509) - -/* This is used for a table of trust checking functions */ - -typedef struct x509_trust_st { - int trust; - int flags; - int (*check_trust) (struct x509_trust_st *, X509 *, int); - char *name; - int arg1; - void *arg2; -} X509_TRUST; - -DEFINE_STACK_OF(X509_TRUST) - -/* standard trust ids */ - -# define X509_TRUST_DEFAULT 0 /* Only valid in purpose settings */ - -# define X509_TRUST_COMPAT 1 -# define X509_TRUST_SSL_CLIENT 2 -# define X509_TRUST_SSL_SERVER 3 -# define X509_TRUST_EMAIL 4 -# define X509_TRUST_OBJECT_SIGN 5 -# define X509_TRUST_OCSP_SIGN 6 -# define X509_TRUST_OCSP_REQUEST 7 -# define X509_TRUST_TSA 8 - -/* Keep these up to date! */ -# define X509_TRUST_MIN 1 -# define X509_TRUST_MAX 8 - -/* trust_flags values */ -# define X509_TRUST_DYNAMIC (1U << 0) -# define X509_TRUST_DYNAMIC_NAME (1U << 1) -/* No compat trust if self-signed, preempts "DO_SS" */ -# define X509_TRUST_NO_SS_COMPAT (1U << 2) -/* Compat trust if no explicit accepted trust EKUs */ -# define X509_TRUST_DO_SS_COMPAT (1U << 3) -/* Accept "anyEKU" as a wildcard trust OID */ -# define X509_TRUST_OK_ANY_EKU (1U << 4) - -/* check_trust return codes */ - -# define X509_TRUST_TRUSTED 1 -# define X509_TRUST_REJECTED 2 -# define X509_TRUST_UNTRUSTED 3 - -/* Flags for X509_print_ex() */ - -# define X509_FLAG_COMPAT 0 -# define X509_FLAG_NO_HEADER 1L -# define X509_FLAG_NO_VERSION (1L << 1) -# define X509_FLAG_NO_SERIAL (1L << 2) -# define X509_FLAG_NO_SIGNAME (1L << 3) -# define X509_FLAG_NO_ISSUER (1L << 4) -# define X509_FLAG_NO_VALIDITY (1L << 5) -# define X509_FLAG_NO_SUBJECT (1L << 6) -# define X509_FLAG_NO_PUBKEY (1L << 7) -# define X509_FLAG_NO_EXTENSIONS (1L << 8) -# define X509_FLAG_NO_SIGDUMP (1L << 9) -# define X509_FLAG_NO_AUX (1L << 10) -# define X509_FLAG_NO_ATTRIBUTES (1L << 11) -# define X509_FLAG_NO_IDS (1L << 12) - -/* Flags specific to X509_NAME_print_ex() */ - -/* The field separator information */ - -# define XN_FLAG_SEP_MASK (0xf << 16) - -# define XN_FLAG_COMPAT 0/* Traditional; use old X509_NAME_print */ -# define XN_FLAG_SEP_COMMA_PLUS (1 << 16)/* RFC2253 ,+ */ -# define XN_FLAG_SEP_CPLUS_SPC (2 << 16)/* ,+ spaced: more readable */ -# define XN_FLAG_SEP_SPLUS_SPC (3 << 16)/* ;+ spaced */ -# define XN_FLAG_SEP_MULTILINE (4 << 16)/* One line per field */ - -# define XN_FLAG_DN_REV (1 << 20)/* Reverse DN order */ - -/* How the field name is shown */ - -# define XN_FLAG_FN_MASK (0x3 << 21) - -# define XN_FLAG_FN_SN 0/* Object short name */ -# define XN_FLAG_FN_LN (1 << 21)/* Object long name */ -# define XN_FLAG_FN_OID (2 << 21)/* Always use OIDs */ -# define XN_FLAG_FN_NONE (3 << 21)/* No field names */ - -# define XN_FLAG_SPC_EQ (1 << 23)/* Put spaces round '=' */ - -/* - * This determines if we dump fields we don't recognise: RFC2253 requires - * this. - */ - -# define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) - -# define XN_FLAG_FN_ALIGN (1 << 25)/* Align field names to 20 - * characters */ - -/* Complete set of RFC2253 flags */ - -# define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \ - XN_FLAG_SEP_COMMA_PLUS | \ - XN_FLAG_DN_REV | \ - XN_FLAG_FN_SN | \ - XN_FLAG_DUMP_UNKNOWN_FIELDS) - -/* readable oneline form */ - -# define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \ - ASN1_STRFLGS_ESC_QUOTE | \ - XN_FLAG_SEP_CPLUS_SPC | \ - XN_FLAG_SPC_EQ | \ - XN_FLAG_FN_SN) - -/* readable multiline form */ - -# define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \ - ASN1_STRFLGS_ESC_MSB | \ - XN_FLAG_SEP_MULTILINE | \ - XN_FLAG_SPC_EQ | \ - XN_FLAG_FN_LN | \ - XN_FLAG_FN_ALIGN) - -DEFINE_STACK_OF(X509_REVOKED) - -typedef struct X509_crl_info_st X509_CRL_INFO; - -DEFINE_STACK_OF(X509_CRL) - -typedef struct private_key_st { - int version; - /* The PKCS#8 data types */ - X509_ALGOR *enc_algor; - ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ - /* When decrypted, the following will not be NULL */ - EVP_PKEY *dec_pkey; - /* used to encrypt and decrypt */ - int key_length; - char *key_data; - int key_free; /* true if we should auto free key_data */ - /* expanded version of 'enc_algor' */ - EVP_CIPHER_INFO cipher; -} X509_PKEY; - -typedef struct X509_info_st { - X509 *x509; - X509_CRL *crl; - X509_PKEY *x_pkey; - EVP_CIPHER_INFO enc_cipher; - int enc_len; - char *enc_data; -} X509_INFO; - -DEFINE_STACK_OF(X509_INFO) - -/* - * The next 2 structures and their 8 routines are used to manipulate Netscape's - * spki structures - useful if you are writing a CA web page - */ -typedef struct Netscape_spkac_st { - X509_PUBKEY *pubkey; - ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ -} NETSCAPE_SPKAC; - -typedef struct Netscape_spki_st { - NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ - X509_ALGOR sig_algor; - ASN1_BIT_STRING *signature; -} NETSCAPE_SPKI; - -/* Netscape certificate sequence structure */ -typedef struct Netscape_certificate_sequence { - ASN1_OBJECT *type; - STACK_OF(X509) *certs; -} NETSCAPE_CERT_SEQUENCE; - -/*- Unused (and iv length is wrong) -typedef struct CBCParameter_st - { - unsigned char iv[8]; - } CBC_PARAM; -*/ - -/* Password based encryption structure */ - -typedef struct PBEPARAM_st { - ASN1_OCTET_STRING *salt; - ASN1_INTEGER *iter; -} PBEPARAM; - -/* Password based encryption V2 structures */ - -typedef struct PBE2PARAM_st { - X509_ALGOR *keyfunc; - X509_ALGOR *encryption; -} PBE2PARAM; - -typedef struct PBKDF2PARAM_st { -/* Usually OCTET STRING but could be anything */ - ASN1_TYPE *salt; - ASN1_INTEGER *iter; - ASN1_INTEGER *keylength; - X509_ALGOR *prf; -} PBKDF2PARAM; - -#ifndef OPENSSL_NO_SCRYPT -typedef struct SCRYPT_PARAMS_st { - ASN1_OCTET_STRING *salt; - ASN1_INTEGER *costParameter; - ASN1_INTEGER *blockSize; - ASN1_INTEGER *parallelizationParameter; - ASN1_INTEGER *keyLength; -} SCRYPT_PARAMS; -#endif - -#ifdef __cplusplus -} -#endif - -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -# define X509_EXT_PACK_UNKNOWN 1 -# define X509_EXT_PACK_STRING 2 - -# define X509_extract_key(x) X509_get_pubkey(x)/*****/ -# define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) -# define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) - -void X509_CRL_set_default_method(const X509_CRL_METHOD *meth); -X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl), - int (*crl_free) (X509_CRL *crl), - int (*crl_lookup) (X509_CRL *crl, - X509_REVOKED **ret, - ASN1_INTEGER *ser, - X509_NAME *issuer), - int (*crl_verify) (X509_CRL *crl, - EVP_PKEY *pk)); -void X509_CRL_METHOD_free(X509_CRL_METHOD *m); - -void X509_CRL_set_meth_data(X509_CRL *crl, void *dat); -void *X509_CRL_get_meth_data(X509_CRL *crl); - -const char *X509_verify_cert_error_string(long n); - -int X509_verify(X509 *a, EVP_PKEY *r); - -int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); -int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); -int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); - -NETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len); -char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x); -EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x); -int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); - -int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); - -int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent); -int X509_signature_print(BIO *bp, const X509_ALGOR *alg, - const ASN1_STRING *sig); - -int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); -int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx); -# ifndef OPENSSL_NO_OCSP -int X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert); -# endif -int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); -int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx); -int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); -int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx); -# ifndef OPENSSL_NO_OCSP -int X509_CRL_http_nbio(OCSP_REQ_CTX *rctx, X509_CRL **pcrl); -# endif -int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); - -int X509_pubkey_digest(const X509 *data, const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_digest(const X509 *data, const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, - unsigned char *md, unsigned int *len); - -# ifndef OPENSSL_NO_STDIO -X509 *d2i_X509_fp(FILE *fp, X509 **x509); -int i2d_X509_fp(FILE *fp, X509 *x509); -X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl); -int i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl); -X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req); -int i2d_X509_REQ_fp(FILE *fp, X509_REQ *req); -# ifndef OPENSSL_NO_RSA -RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa); -int i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa); -RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa); -int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa); -RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa); -int i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa); -# endif -# ifndef OPENSSL_NO_DSA -DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa); -int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa); -DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); -int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa); -# endif -# ifndef OPENSSL_NO_EC -EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey); -int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey); -EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey); -int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey); -# endif -X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8); -int i2d_PKCS8_fp(FILE *fp, X509_SIG *p8); -PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, - PKCS8_PRIV_KEY_INFO **p8inf); -int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf); -int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key); -int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a); -int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a); -# endif - -X509 *d2i_X509_bio(BIO *bp, X509 **x509); -int i2d_X509_bio(BIO *bp, X509 *x509); -X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl); -int i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl); -X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req); -int i2d_X509_REQ_bio(BIO *bp, X509_REQ *req); -# ifndef OPENSSL_NO_RSA -RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa); -int i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa); -RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa); -int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa); -RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa); -int i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa); -# endif -# ifndef OPENSSL_NO_DSA -DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa); -int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa); -DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); -int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa); -# endif -# ifndef OPENSSL_NO_EC -EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey); -int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey); -EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey); -int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey); -# endif -X509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8); -int i2d_PKCS8_bio(BIO *bp, X509_SIG *p8); -PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, - PKCS8_PRIV_KEY_INFO **p8inf); -int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf); -int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key); -int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a); -int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a); - -X509 *X509_dup(X509 *x509); -X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa); -X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex); -X509_CRL *X509_CRL_dup(X509_CRL *crl); -X509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev); -X509_REQ *X509_REQ_dup(X509_REQ *req); -X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn); -int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, - void *pval); -void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype, - const void **ppval, const X509_ALGOR *algor); -void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md); -int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b); -int X509_ALGOR_copy(X509_ALGOR *dest, const X509_ALGOR *src); - -X509_NAME *X509_NAME_dup(X509_NAME *xn); -X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne); - -int X509_cmp_time(const ASN1_TIME *s, time_t *t); -int X509_cmp_current_time(const ASN1_TIME *s); -ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t); -ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s, - int offset_day, long offset_sec, time_t *t); -ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj); - -const char *X509_get_default_cert_area(void); -const char *X509_get_default_cert_dir(void); -const char *X509_get_default_cert_file(void); -const char *X509_get_default_cert_dir_env(void); -const char *X509_get_default_cert_file_env(void); -const char *X509_get_default_private_dir(void); - -X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); -X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey); - -DECLARE_ASN1_FUNCTIONS(X509_ALGOR) -DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS) -DECLARE_ASN1_FUNCTIONS(X509_VAL) - -DECLARE_ASN1_FUNCTIONS(X509_PUBKEY) - -int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); -EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key); -EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key); -int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain); -long X509_get_pathlen(X509 *x); -int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp); -EVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length); -# ifndef OPENSSL_NO_RSA -int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp); -RSA *d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length); -# endif -# ifndef OPENSSL_NO_DSA -int i2d_DSA_PUBKEY(DSA *a, unsigned char **pp); -DSA *d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length); -# endif -# ifndef OPENSSL_NO_EC -int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp); -EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length); -# endif - -DECLARE_ASN1_FUNCTIONS(X509_SIG) -void X509_SIG_get0(const X509_SIG *sig, const X509_ALGOR **palg, - const ASN1_OCTET_STRING **pdigest); -void X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg, - ASN1_OCTET_STRING **pdigest); - -DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) -DECLARE_ASN1_FUNCTIONS(X509_REQ) - -DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE) -X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); - -DECLARE_ASN1_FUNCTIONS(X509_EXTENSION) -DECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS) - -DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY) - -DECLARE_ASN1_FUNCTIONS(X509_NAME) - -int X509_NAME_set(X509_NAME **xn, X509_NAME *name); - -DECLARE_ASN1_FUNCTIONS(X509_CINF) - -DECLARE_ASN1_FUNCTIONS(X509) -DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX) - -#define X509_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, l, p, newf, dupf, freef) -int X509_set_ex_data(X509 *r, int idx, void *arg); -void *X509_get_ex_data(X509 *r, int idx); -int i2d_X509_AUX(X509 *a, unsigned char **pp); -X509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length); - -int i2d_re_X509_tbs(X509 *x, unsigned char **pp); - -int X509_SIG_INFO_get(const X509_SIG_INFO *siginf, int *mdnid, int *pknid, - int *secbits, uint32_t *flags); -void X509_SIG_INFO_set(X509_SIG_INFO *siginf, int mdnid, int pknid, - int secbits, uint32_t flags); - -int X509_get_signature_info(X509 *x, int *mdnid, int *pknid, int *secbits, - uint32_t *flags); - -void X509_get0_signature(const ASN1_BIT_STRING **psig, - const X509_ALGOR **palg, const X509 *x); -int X509_get_signature_nid(const X509 *x); - -int X509_trusted(const X509 *x); -int X509_alias_set1(X509 *x, const unsigned char *name, int len); -int X509_keyid_set1(X509 *x, const unsigned char *id, int len); -unsigned char *X509_alias_get0(X509 *x, int *len); -unsigned char *X509_keyid_get0(X509 *x, int *len); -int (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *, - int); -int X509_TRUST_set(int *t, int trust); -int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj); -int X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj); -void X509_trust_clear(X509 *x); -void X509_reject_clear(X509 *x); - -STACK_OF(ASN1_OBJECT) *X509_get0_trust_objects(X509 *x); -STACK_OF(ASN1_OBJECT) *X509_get0_reject_objects(X509 *x); - -DECLARE_ASN1_FUNCTIONS(X509_REVOKED) -DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO) -DECLARE_ASN1_FUNCTIONS(X509_CRL) - -int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); -int X509_CRL_get0_by_serial(X509_CRL *crl, - X509_REVOKED **ret, ASN1_INTEGER *serial); -int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x); - -X509_PKEY *X509_PKEY_new(void); -void X509_PKEY_free(X509_PKEY *a); - -DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI) -DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC) -DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE) - -X509_INFO *X509_INFO_new(void); -void X509_INFO_free(X509_INFO *a); -char *X509_NAME_oneline(const X509_NAME *a, char *buf, int size); - -int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1, - ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey); - -int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data, - unsigned char *md, unsigned int *len); - -int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, - X509_ALGOR *algor2, ASN1_BIT_STRING *signature, - char *data, EVP_PKEY *pkey, const EVP_MD *type); - -int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data, - unsigned char *md, unsigned int *len); - -int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1, - ASN1_BIT_STRING *signature, void *data, EVP_PKEY *pkey); - -int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, - X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *data, - EVP_PKEY *pkey, const EVP_MD *type); -int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, - X509_ALGOR *algor2, ASN1_BIT_STRING *signature, - void *asn, EVP_MD_CTX *ctx); - -long X509_get_version(const X509 *x); -int X509_set_version(X509 *x, long version); -int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); -ASN1_INTEGER *X509_get_serialNumber(X509 *x); -const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x); -int X509_set_issuer_name(X509 *x, X509_NAME *name); -X509_NAME *X509_get_issuer_name(const X509 *a); -int X509_set_subject_name(X509 *x, X509_NAME *name); -X509_NAME *X509_get_subject_name(const X509 *a); -const ASN1_TIME * X509_get0_notBefore(const X509 *x); -ASN1_TIME *X509_getm_notBefore(const X509 *x); -int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm); -const ASN1_TIME *X509_get0_notAfter(const X509 *x); -ASN1_TIME *X509_getm_notAfter(const X509 *x); -int X509_set1_notAfter(X509 *x, const ASN1_TIME *tm); -int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); -int X509_up_ref(X509 *x); -int X509_get_signature_type(const X509 *x); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define X509_get_notBefore X509_getm_notBefore -# define X509_get_notAfter X509_getm_notAfter -# define X509_set_notBefore X509_set1_notBefore -# define X509_set_notAfter X509_set1_notAfter -#endif - - -/* - * This one is only used so that a binary form can output, as in - * i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), &buf) - */ -X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x); -const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x); -void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid, - const ASN1_BIT_STRING **psuid); -const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x); - -EVP_PKEY *X509_get0_pubkey(const X509 *x); -EVP_PKEY *X509_get_pubkey(X509 *x); -ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x); -int X509_certificate_type(const X509 *x, const EVP_PKEY *pubkey); - -long X509_REQ_get_version(const X509_REQ *req); -int X509_REQ_set_version(X509_REQ *x, long version); -X509_NAME *X509_REQ_get_subject_name(const X509_REQ *req); -int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name); -void X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig, - const X509_ALGOR **palg); -void X509_REQ_set0_signature(X509_REQ *req, ASN1_BIT_STRING *psig); -int X509_REQ_set1_signature_algo(X509_REQ *req, X509_ALGOR *palg); -int X509_REQ_get_signature_nid(const X509_REQ *req); -int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp); -int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); -EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req); -EVP_PKEY *X509_REQ_get0_pubkey(X509_REQ *req); -X509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *req); -int X509_REQ_extension_nid(int nid); -int *X509_REQ_get_extension_nids(void); -void X509_REQ_set_extension_nids(int *nids); -STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req); -int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, - int nid); -int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts); -int X509_REQ_get_attr_count(const X509_REQ *req); -int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos); -int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj, - int lastpos); -X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); -X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); -int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); -int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); -int X509_REQ_add1_attr_by_NID(X509_REQ *req, - int nid, int type, - const unsigned char *bytes, int len); -int X509_REQ_add1_attr_by_txt(X509_REQ *req, - const char *attrname, int type, - const unsigned char *bytes, int len); - -int X509_CRL_set_version(X509_CRL *x, long version); -int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name); -int X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm); -int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm); -int X509_CRL_sort(X509_CRL *crl); -int X509_CRL_up_ref(X509_CRL *crl); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define X509_CRL_set_lastUpdate X509_CRL_set1_lastUpdate -# define X509_CRL_set_nextUpdate X509_CRL_set1_nextUpdate -#endif - -long X509_CRL_get_version(const X509_CRL *crl); -const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl); -const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl); -DEPRECATEDIN_1_1_0(ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl)) -DEPRECATEDIN_1_1_0(ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl)) -X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl); -const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl); -STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl); -void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig, - const X509_ALGOR **palg); -int X509_CRL_get_signature_nid(const X509_CRL *crl); -int i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp); - -const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x); -int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); -const ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x); -int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm); -const STACK_OF(X509_EXTENSION) * -X509_REVOKED_get0_extensions(const X509_REVOKED *r); - -X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer, - EVP_PKEY *skey, const EVP_MD *md, unsigned int flags); - -int X509_REQ_check_private_key(X509_REQ *x509, EVP_PKEY *pkey); - -int X509_check_private_key(const X509 *x509, const EVP_PKEY *pkey); -int X509_chain_check_suiteb(int *perror_depth, - X509 *x, STACK_OF(X509) *chain, - unsigned long flags); -int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags); -STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain); - -int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); -unsigned long X509_issuer_and_serial_hash(X509 *a); - -int X509_issuer_name_cmp(const X509 *a, const X509 *b); -unsigned long X509_issuer_name_hash(X509 *a); - -int X509_subject_name_cmp(const X509 *a, const X509 *b); -unsigned long X509_subject_name_hash(X509 *x); - -# ifndef OPENSSL_NO_MD5 -unsigned long X509_issuer_name_hash_old(X509 *a); -unsigned long X509_subject_name_hash_old(X509 *x); -# endif - -int X509_cmp(const X509 *a, const X509 *b); -int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); -unsigned long X509_NAME_hash(X509_NAME *x); -unsigned long X509_NAME_hash_old(X509_NAME *x); - -int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); -int X509_CRL_match(const X509_CRL *a, const X509_CRL *b); -int X509_aux_print(BIO *out, X509 *x, int indent); -# ifndef OPENSSL_NO_STDIO -int X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag, - unsigned long cflag); -int X509_print_fp(FILE *bp, X509 *x); -int X509_CRL_print_fp(FILE *bp, X509_CRL *x); -int X509_REQ_print_fp(FILE *bp, X509_REQ *req); -int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent, - unsigned long flags); -# endif - -int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase); -int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent, - unsigned long flags); -int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag, - unsigned long cflag); -int X509_print(BIO *bp, X509 *x); -int X509_ocspid_print(BIO *bp, X509 *x); -int X509_CRL_print_ex(BIO *out, X509_CRL *x, unsigned long nmflag); -int X509_CRL_print(BIO *bp, X509_CRL *x); -int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, - unsigned long cflag); -int X509_REQ_print(BIO *bp, X509_REQ *req); - -int X509_NAME_entry_count(const X509_NAME *name); -int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len); -int X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, - char *buf, int len); - -/* - * NOTE: you should be passing -1, not 0 as lastpos. The functions that use - * lastpos, search after that position on. - */ -int X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos); -int X509_NAME_get_index_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, - int lastpos); -X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc); -X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); -int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, - int loc, int set); -int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len, int loc, - int set); -int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, - const unsigned char *bytes, int len, int loc, - int set); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, - const char *field, int type, - const unsigned char *bytes, - int len); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, - int type, - const unsigned char *bytes, - int len); -int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, - const unsigned char *bytes, int len, int loc, - int set); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, - int len); -int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj); -int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, - const unsigned char *bytes, int len); -ASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne); -ASN1_STRING * X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne); -int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne); - -int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, - size_t *pderlen); - -int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); -int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, - int nid, int lastpos); -int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, - const ASN1_OBJECT *obj, int lastpos); -int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, - int crit, int lastpos); -X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); -X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); -STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, - X509_EXTENSION *ex, int loc); - -int X509_get_ext_count(const X509 *x); -int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos); -int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos); -int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos); -X509_EXTENSION *X509_get_ext(const X509 *x, int loc); -X509_EXTENSION *X509_delete_ext(X509 *x, int loc); -int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); -void *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx); -int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, - unsigned long flags); - -int X509_CRL_get_ext_count(const X509_CRL *x); -int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos); -int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj, - int lastpos); -int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos); -X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc); -X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); -int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); -void *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx); -int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, - unsigned long flags); - -int X509_REVOKED_get_ext_count(const X509_REVOKED *x); -int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos); -int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj, - int lastpos); -int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit, - int lastpos); -X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc); -X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); -int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); -void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit, - int *idx); -int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, - unsigned long flags); - -X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, - int nid, int crit, - ASN1_OCTET_STRING *data); -X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, - const ASN1_OBJECT *obj, int crit, - ASN1_OCTET_STRING *data); -int X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj); -int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); -int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data); -ASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex); -ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); -int X509_EXTENSION_get_critical(const X509_EXTENSION *ex); - -int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x); -int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, - int lastpos); -int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, - const ASN1_OBJECT *obj, int lastpos); -X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc); -X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, - X509_ATTRIBUTE *attr); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) - **x, const ASN1_OBJECT *obj, - int type, - const unsigned char *bytes, - int len); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) - **x, int nid, int type, - const unsigned char *bytes, - int len); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) - **x, const char *attrname, - int type, - const unsigned char *bytes, - int len); -void *X509at_get0_data_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *x, - const ASN1_OBJECT *obj, int lastpos, int type); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, - int atrtype, const void *data, - int len); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, - const ASN1_OBJECT *obj, - int atrtype, const void *data, - int len); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, - const char *atrname, int type, - const unsigned char *bytes, - int len); -int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj); -int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, - const void *data, int len); -void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype, - void *data); -int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr); -ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); -ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx); - -int EVP_PKEY_get_attr_count(const EVP_PKEY *key); -int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos); -int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj, - int lastpos); -X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc); -X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc); -int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr); -int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); -int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, - int nid, int type, - const unsigned char *bytes, int len); -int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key, - const char *attrname, int type, - const unsigned char *bytes, int len); - -int X509_verify_cert(X509_STORE_CTX *ctx); - -/* lookup a cert from a X509 STACK */ -X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name, - ASN1_INTEGER *serial); -X509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name); - -DECLARE_ASN1_FUNCTIONS(PBEPARAM) -DECLARE_ASN1_FUNCTIONS(PBE2PARAM) -DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) -#ifndef OPENSSL_NO_SCRYPT -DECLARE_ASN1_FUNCTIONS(SCRYPT_PARAMS) -#endif - -int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, - const unsigned char *salt, int saltlen); - -X509_ALGOR *PKCS5_pbe_set(int alg, int iter, - const unsigned char *salt, int saltlen); -X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, - unsigned char *salt, int saltlen); -X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, - unsigned char *salt, int saltlen, - unsigned char *aiv, int prf_nid); - -#ifndef OPENSSL_NO_SCRYPT -X509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher, - const unsigned char *salt, int saltlen, - unsigned char *aiv, uint64_t N, uint64_t r, - uint64_t p); -#endif - -X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen, - int prf_nid, int keylen); - -/* PKCS#8 utilities */ - -DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) - -EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8); -PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); - -int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, - int version, int ptype, void *pval, - unsigned char *penc, int penclen); -int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg, - const unsigned char **pk, int *ppklen, - const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8); - -const STACK_OF(X509_ATTRIBUTE) * -PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8); -int PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type, - const unsigned char *bytes, int len); - -int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj, - int ptype, void *pval, - unsigned char *penc, int penclen); -int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg, - const unsigned char **pk, int *ppklen, - X509_ALGOR **pa, X509_PUBKEY *pub); - -int X509_check_trust(X509 *x, int id, int flags); -int X509_TRUST_get_count(void); -X509_TRUST *X509_TRUST_get0(int idx); -int X509_TRUST_get_by_id(int id); -int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int), - const char *name, int arg1, void *arg2); -void X509_TRUST_cleanup(void); -int X509_TRUST_get_flags(const X509_TRUST *xp); -char *X509_TRUST_get0_name(const X509_TRUST *xp); -int X509_TRUST_get_trust(const X509_TRUST *xp); - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/x509_vfy.h b/client/3rd/OpenSSL/include/openssl/x509_vfy.h deleted file mode 100644 index 25c79f1b..00000000 --- a/client/3rd/OpenSSL/include/openssl/x509_vfy.h +++ /dev/null @@ -1,632 +0,0 @@ -/* - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_X509_VFY_H -# define HEADER_X509_VFY_H - -/* - * Protect against recursion, x509.h and x509_vfy.h each include the other. - */ -# ifndef HEADER_X509_H -# include -# endif - -# include -# include -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/*- -SSL_CTX -> X509_STORE - -> X509_LOOKUP - ->X509_LOOKUP_METHOD - -> X509_LOOKUP - ->X509_LOOKUP_METHOD - -SSL -> X509_STORE_CTX - ->X509_STORE - -The X509_STORE holds the tables etc for verification stuff. -A X509_STORE_CTX is used while validating a single certificate. -The X509_STORE has X509_LOOKUPs for looking up certs. -The X509_STORE then calls a function to actually verify the -certificate chain. -*/ - -typedef enum { - X509_LU_NONE = 0, - X509_LU_X509, X509_LU_CRL -} X509_LOOKUP_TYPE; - -#if OPENSSL_API_COMPAT < 0x10100000L -#define X509_LU_RETRY -1 -#define X509_LU_FAIL 0 -#endif - -DEFINE_STACK_OF(X509_LOOKUP) -DEFINE_STACK_OF(X509_OBJECT) -DEFINE_STACK_OF(X509_VERIFY_PARAM) - -int X509_STORE_set_depth(X509_STORE *store, int depth); - -typedef int (*X509_STORE_CTX_verify_cb)(int, X509_STORE_CTX *); -typedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *); -typedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer, - X509_STORE_CTX *ctx, X509 *x); -typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx, - X509 *x, X509 *issuer); -typedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx); -typedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx, - X509_CRL **crl, X509 *x); -typedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl); -typedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx, - X509_CRL *crl, X509 *x); -typedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx); -typedef STACK_OF(X509) *(*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx, - X509_NAME *nm); -typedef STACK_OF(X509_CRL) *(*X509_STORE_CTX_lookup_crls_fn)(X509_STORE_CTX *ctx, - X509_NAME *nm); -typedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx); - - -void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); - -# define X509_STORE_CTX_set_app_data(ctx,data) \ - X509_STORE_CTX_set_ex_data(ctx,0,data) -# define X509_STORE_CTX_get_app_data(ctx) \ - X509_STORE_CTX_get_ex_data(ctx,0) - -# define X509_L_FILE_LOAD 1 -# define X509_L_ADD_DIR 2 - -# define X509_LOOKUP_load_file(x,name,type) \ - X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL) - -# define X509_LOOKUP_add_dir(x,name,type) \ - X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) - -# define X509_V_OK 0 -# define X509_V_ERR_UNSPECIFIED 1 -# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 -# define X509_V_ERR_UNABLE_TO_GET_CRL 3 -# define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4 -# define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5 -# define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6 -# define X509_V_ERR_CERT_SIGNATURE_FAILURE 7 -# define X509_V_ERR_CRL_SIGNATURE_FAILURE 8 -# define X509_V_ERR_CERT_NOT_YET_VALID 9 -# define X509_V_ERR_CERT_HAS_EXPIRED 10 -# define X509_V_ERR_CRL_NOT_YET_VALID 11 -# define X509_V_ERR_CRL_HAS_EXPIRED 12 -# define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13 -# define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14 -# define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15 -# define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16 -# define X509_V_ERR_OUT_OF_MEM 17 -# define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18 -# define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19 -# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20 -# define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 -# define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 -# define X509_V_ERR_CERT_REVOKED 23 -# define X509_V_ERR_INVALID_CA 24 -# define X509_V_ERR_PATH_LENGTH_EXCEEDED 25 -# define X509_V_ERR_INVALID_PURPOSE 26 -# define X509_V_ERR_CERT_UNTRUSTED 27 -# define X509_V_ERR_CERT_REJECTED 28 -/* These are 'informational' when looking for issuer cert */ -# define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29 -# define X509_V_ERR_AKID_SKID_MISMATCH 30 -# define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 -# define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 -# define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33 -# define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 -# define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35 -# define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36 -# define X509_V_ERR_INVALID_NON_CA 37 -# define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38 -# define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 -# define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 -# define X509_V_ERR_INVALID_EXTENSION 41 -# define X509_V_ERR_INVALID_POLICY_EXTENSION 42 -# define X509_V_ERR_NO_EXPLICIT_POLICY 43 -# define X509_V_ERR_DIFFERENT_CRL_SCOPE 44 -# define X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE 45 -# define X509_V_ERR_UNNESTED_RESOURCE 46 -# define X509_V_ERR_PERMITTED_VIOLATION 47 -# define X509_V_ERR_EXCLUDED_VIOLATION 48 -# define X509_V_ERR_SUBTREE_MINMAX 49 -/* The application is not happy */ -# define X509_V_ERR_APPLICATION_VERIFICATION 50 -# define X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE 51 -# define X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX 52 -# define X509_V_ERR_UNSUPPORTED_NAME_SYNTAX 53 -# define X509_V_ERR_CRL_PATH_VALIDATION_ERROR 54 -/* Another issuer check debug option */ -# define X509_V_ERR_PATH_LOOP 55 -/* Suite B mode algorithm violation */ -# define X509_V_ERR_SUITE_B_INVALID_VERSION 56 -# define X509_V_ERR_SUITE_B_INVALID_ALGORITHM 57 -# define X509_V_ERR_SUITE_B_INVALID_CURVE 58 -# define X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM 59 -# define X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED 60 -# define X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61 -/* Host, email and IP check errors */ -# define X509_V_ERR_HOSTNAME_MISMATCH 62 -# define X509_V_ERR_EMAIL_MISMATCH 63 -# define X509_V_ERR_IP_ADDRESS_MISMATCH 64 -/* DANE TLSA errors */ -# define X509_V_ERR_DANE_NO_MATCH 65 -/* security level errors */ -# define X509_V_ERR_EE_KEY_TOO_SMALL 66 -# define X509_V_ERR_CA_KEY_TOO_SMALL 67 -# define X509_V_ERR_CA_MD_TOO_WEAK 68 -/* Caller error */ -# define X509_V_ERR_INVALID_CALL 69 -/* Issuer lookup error */ -# define X509_V_ERR_STORE_LOOKUP 70 -/* Certificate transparency */ -# define X509_V_ERR_NO_VALID_SCTS 71 - -# define X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION 72 -/* OCSP status errors */ -# define X509_V_ERR_OCSP_VERIFY_NEEDED 73 /* Need OCSP verification */ -# define X509_V_ERR_OCSP_VERIFY_FAILED 74 /* Couldn't verify cert through OCSP */ -# define X509_V_ERR_OCSP_CERT_UNKNOWN 75 /* Certificate wasn't recognized by the OCSP responder */ -# define X509_V_ERR_SIGNATURE_ALGORITHM_MISMATCH 76 -# define X509_V_ERR_NO_ISSUER_PUBLIC_KEY 77 -# define X509_V_ERR_UNSUPPORTED_SIGNATURE_ALGORITHM 78 -# define X509_V_ERR_EC_KEY_EXPLICIT_PARAMS 79 - -/* Certificate verify flags */ - -# if OPENSSL_API_COMPAT < 0x10100000L -# define X509_V_FLAG_CB_ISSUER_CHECK 0x0 /* Deprecated */ -# endif -/* Use check time instead of current time */ -# define X509_V_FLAG_USE_CHECK_TIME 0x2 -/* Lookup CRLs */ -# define X509_V_FLAG_CRL_CHECK 0x4 -/* Lookup CRLs for whole chain */ -# define X509_V_FLAG_CRL_CHECK_ALL 0x8 -/* Ignore unhandled critical extensions */ -# define X509_V_FLAG_IGNORE_CRITICAL 0x10 -/* Disable workarounds for broken certificates */ -# define X509_V_FLAG_X509_STRICT 0x20 -/* Enable proxy certificate validation */ -# define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 -/* Enable policy checking */ -# define X509_V_FLAG_POLICY_CHECK 0x80 -/* Policy variable require-explicit-policy */ -# define X509_V_FLAG_EXPLICIT_POLICY 0x100 -/* Policy variable inhibit-any-policy */ -# define X509_V_FLAG_INHIBIT_ANY 0x200 -/* Policy variable inhibit-policy-mapping */ -# define X509_V_FLAG_INHIBIT_MAP 0x400 -/* Notify callback that policy is OK */ -# define X509_V_FLAG_NOTIFY_POLICY 0x800 -/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */ -# define X509_V_FLAG_EXTENDED_CRL_SUPPORT 0x1000 -/* Delta CRL support */ -# define X509_V_FLAG_USE_DELTAS 0x2000 -/* Check self-signed CA signature */ -# define X509_V_FLAG_CHECK_SS_SIGNATURE 0x4000 -/* Use trusted store first */ -# define X509_V_FLAG_TRUSTED_FIRST 0x8000 -/* Suite B 128 bit only mode: not normally used */ -# define X509_V_FLAG_SUITEB_128_LOS_ONLY 0x10000 -/* Suite B 192 bit only mode */ -# define X509_V_FLAG_SUITEB_192_LOS 0x20000 -/* Suite B 128 bit mode allowing 192 bit algorithms */ -# define X509_V_FLAG_SUITEB_128_LOS 0x30000 -/* Allow partial chains if at least one certificate is in trusted store */ -# define X509_V_FLAG_PARTIAL_CHAIN 0x80000 -/* - * If the initial chain is not trusted, do not attempt to build an alternative - * chain. Alternate chain checking was introduced in 1.1.0. Setting this flag - * will force the behaviour to match that of previous versions. - */ -# define X509_V_FLAG_NO_ALT_CHAINS 0x100000 -/* Do not check certificate/CRL validity against current time */ -# define X509_V_FLAG_NO_CHECK_TIME 0x200000 - -# define X509_VP_FLAG_DEFAULT 0x1 -# define X509_VP_FLAG_OVERWRITE 0x2 -# define X509_VP_FLAG_RESET_FLAGS 0x4 -# define X509_VP_FLAG_LOCKED 0x8 -# define X509_VP_FLAG_ONCE 0x10 - -/* Internal use: mask of policy related options */ -# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \ - | X509_V_FLAG_EXPLICIT_POLICY \ - | X509_V_FLAG_INHIBIT_ANY \ - | X509_V_FLAG_INHIBIT_MAP) - -int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type, - X509_NAME *name); -X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, - X509_LOOKUP_TYPE type, - X509_NAME *name); -X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, - X509_OBJECT *x); -int X509_OBJECT_up_ref_count(X509_OBJECT *a); -X509_OBJECT *X509_OBJECT_new(void); -void X509_OBJECT_free(X509_OBJECT *a); -X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a); -X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a); -int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj); -X509_CRL *X509_OBJECT_get0_X509_CRL(X509_OBJECT *a); -int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj); -X509_STORE *X509_STORE_new(void); -void X509_STORE_free(X509_STORE *v); -int X509_STORE_lock(X509_STORE *ctx); -int X509_STORE_unlock(X509_STORE *ctx); -int X509_STORE_up_ref(X509_STORE *v); -STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(X509_STORE *v); - -STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *st, X509_NAME *nm); -STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(X509_STORE_CTX *st, X509_NAME *nm); -int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); -int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); -int X509_STORE_set_trust(X509_STORE *ctx, int trust); -int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); -X509_VERIFY_PARAM *X509_STORE_get0_param(X509_STORE *ctx); - -void X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify); -#define X509_STORE_set_verify_func(ctx, func) \ - X509_STORE_set_verify((ctx),(func)) -void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, - X509_STORE_CTX_verify_fn verify); -X509_STORE_CTX_verify_fn X509_STORE_get_verify(X509_STORE *ctx); -void X509_STORE_set_verify_cb(X509_STORE *ctx, - X509_STORE_CTX_verify_cb verify_cb); -# define X509_STORE_set_verify_cb_func(ctx,func) \ - X509_STORE_set_verify_cb((ctx),(func)) -X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(X509_STORE *ctx); -void X509_STORE_set_get_issuer(X509_STORE *ctx, - X509_STORE_CTX_get_issuer_fn get_issuer); -X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(X509_STORE *ctx); -void X509_STORE_set_check_issued(X509_STORE *ctx, - X509_STORE_CTX_check_issued_fn check_issued); -X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(X509_STORE *ctx); -void X509_STORE_set_check_revocation(X509_STORE *ctx, - X509_STORE_CTX_check_revocation_fn check_revocation); -X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(X509_STORE *ctx); -void X509_STORE_set_get_crl(X509_STORE *ctx, - X509_STORE_CTX_get_crl_fn get_crl); -X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(X509_STORE *ctx); -void X509_STORE_set_check_crl(X509_STORE *ctx, - X509_STORE_CTX_check_crl_fn check_crl); -X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(X509_STORE *ctx); -void X509_STORE_set_cert_crl(X509_STORE *ctx, - X509_STORE_CTX_cert_crl_fn cert_crl); -X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(X509_STORE *ctx); -void X509_STORE_set_check_policy(X509_STORE *ctx, - X509_STORE_CTX_check_policy_fn check_policy); -X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(X509_STORE *ctx); -void X509_STORE_set_lookup_certs(X509_STORE *ctx, - X509_STORE_CTX_lookup_certs_fn lookup_certs); -X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(X509_STORE *ctx); -void X509_STORE_set_lookup_crls(X509_STORE *ctx, - X509_STORE_CTX_lookup_crls_fn lookup_crls); -#define X509_STORE_set_lookup_crls_cb(ctx, func) \ - X509_STORE_set_lookup_crls((ctx), (func)) -X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(X509_STORE *ctx); -void X509_STORE_set_cleanup(X509_STORE *ctx, - X509_STORE_CTX_cleanup_fn cleanup); -X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(X509_STORE *ctx); - -#define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, l, p, newf, dupf, freef) -int X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data); -void *X509_STORE_get_ex_data(X509_STORE *ctx, int idx); - -X509_STORE_CTX *X509_STORE_CTX_new(void); - -int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); - -void X509_STORE_CTX_free(X509_STORE_CTX *ctx); -int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, - X509 *x509, STACK_OF(X509) *chain); -void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); -void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); - -X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx); -X509 *X509_STORE_CTX_get0_cert(X509_STORE_CTX *ctx); -STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); -void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, - X509_STORE_CTX_verify_cb verify); -X509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(X509_STORE_CTX *ctx); -X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(X509_STORE_CTX *ctx); -X509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(X509_STORE_CTX *ctx); -X509_STORE_CTX_check_issued_fn X509_STORE_CTX_get_check_issued(X509_STORE_CTX *ctx); -X509_STORE_CTX_check_revocation_fn X509_STORE_CTX_get_check_revocation(X509_STORE_CTX *ctx); -X509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(X509_STORE_CTX *ctx); -X509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(X509_STORE_CTX *ctx); -X509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(X509_STORE_CTX *ctx); -X509_STORE_CTX_check_policy_fn X509_STORE_CTX_get_check_policy(X509_STORE_CTX *ctx); -X509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(X509_STORE_CTX *ctx); -X509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(X509_STORE_CTX *ctx); -X509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(X509_STORE_CTX *ctx); - -#if OPENSSL_API_COMPAT < 0x10100000L -# define X509_STORE_CTX_get_chain X509_STORE_CTX_get0_chain -# define X509_STORE_CTX_set_chain X509_STORE_CTX_set0_untrusted -# define X509_STORE_CTX_trusted_stack X509_STORE_CTX_set0_trusted_stack -# define X509_STORE_get_by_subject X509_STORE_CTX_get_by_subject -# define X509_STORE_get1_certs X509_STORE_CTX_get1_certs -# define X509_STORE_get1_crls X509_STORE_CTX_get1_crls -/* the following macro is misspelled; use X509_STORE_get1_certs instead */ -# define X509_STORE_get1_cert X509_STORE_CTX_get1_certs -/* the following macro is misspelled; use X509_STORE_get1_crls instead */ -# define X509_STORE_get1_crl X509_STORE_CTX_get1_crls -#endif - -X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m); -X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); -X509_LOOKUP_METHOD *X509_LOOKUP_file(void); - -typedef int (*X509_LOOKUP_ctrl_fn)(X509_LOOKUP *ctx, int cmd, const char *argc, - long argl, char **ret); -typedef int (*X509_LOOKUP_get_by_subject_fn)(X509_LOOKUP *ctx, - X509_LOOKUP_TYPE type, - X509_NAME *name, - X509_OBJECT *ret); -typedef int (*X509_LOOKUP_get_by_issuer_serial_fn)(X509_LOOKUP *ctx, - X509_LOOKUP_TYPE type, - X509_NAME *name, - ASN1_INTEGER *serial, - X509_OBJECT *ret); -typedef int (*X509_LOOKUP_get_by_fingerprint_fn)(X509_LOOKUP *ctx, - X509_LOOKUP_TYPE type, - const unsigned char* bytes, - int len, - X509_OBJECT *ret); -typedef int (*X509_LOOKUP_get_by_alias_fn)(X509_LOOKUP *ctx, - X509_LOOKUP_TYPE type, - const char *str, - int len, - X509_OBJECT *ret); - -X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name); -void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method); - -int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method, - int (*new_item) (X509_LOOKUP *ctx)); -int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method)) - (X509_LOOKUP *ctx); - -int X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method, - void (*free_fn) (X509_LOOKUP *ctx)); -void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method)) - (X509_LOOKUP *ctx); - -int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method, - int (*init) (X509_LOOKUP *ctx)); -int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD* method)) - (X509_LOOKUP *ctx); - -int X509_LOOKUP_meth_set_shutdown(X509_LOOKUP_METHOD *method, - int (*shutdown) (X509_LOOKUP *ctx)); -int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD* method)) - (X509_LOOKUP *ctx); - -int X509_LOOKUP_meth_set_ctrl(X509_LOOKUP_METHOD *method, - X509_LOOKUP_ctrl_fn ctrl_fn); -X509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method); - -int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method, - X509_LOOKUP_get_by_subject_fn fn); -X509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject( - const X509_LOOKUP_METHOD *method); - -int X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD *method, - X509_LOOKUP_get_by_issuer_serial_fn fn); -X509_LOOKUP_get_by_issuer_serial_fn X509_LOOKUP_meth_get_get_by_issuer_serial( - const X509_LOOKUP_METHOD *method); - -int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method, - X509_LOOKUP_get_by_fingerprint_fn fn); -X509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint( - const X509_LOOKUP_METHOD *method); - -int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method, - X509_LOOKUP_get_by_alias_fn fn); -X509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias( - const X509_LOOKUP_METHOD *method); - - -int X509_STORE_add_cert(X509_STORE *ctx, X509 *x); -int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x); - -int X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type, - X509_NAME *name, X509_OBJECT *ret); -X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs, - X509_LOOKUP_TYPE type, - X509_NAME *name); - -int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, - long argl, char **ret); - -int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); -int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); -int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); - -X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); -void X509_LOOKUP_free(X509_LOOKUP *ctx); -int X509_LOOKUP_init(X509_LOOKUP *ctx); -int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - X509_NAME *name, X509_OBJECT *ret); -int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - X509_NAME *name, ASN1_INTEGER *serial, - X509_OBJECT *ret); -int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - const unsigned char *bytes, int len, - X509_OBJECT *ret); -int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - const char *str, int len, X509_OBJECT *ret); -int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data); -void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx); -X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx); -int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); - -int X509_STORE_load_locations(X509_STORE *ctx, - const char *file, const char *dir); -int X509_STORE_set_default_paths(X509_STORE *ctx); - -#define X509_STORE_CTX_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, l, p, newf, dupf, freef) -int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data); -void *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx); -int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s); -int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth); -X509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x); -X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx); -X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx); -X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx); -STACK_OF(X509) *X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx); -STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set_cert(X509_STORE_CTX *c, X509 *x); -void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk); -void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, STACK_OF(X509_CRL) *sk); -int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); -int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); -int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, - int purpose, int trust); -void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); -void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, - time_t t); - -X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx); -int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx); -int X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx); - -X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); -int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); - -/* - * Bridge opacity barrier between libcrypt and libssl, also needed to support - * offline testing in test/danetest.c - */ -void X509_STORE_CTX_set0_dane(X509_STORE_CTX *ctx, SSL_DANE *dane); -#define DANE_FLAG_NO_DANE_EE_NAMECHECKS (1L << 0) - -/* X509_VERIFY_PARAM functions */ - -X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); -void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, - const X509_VERIFY_PARAM *from); -int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, - const X509_VERIFY_PARAM *from); -int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); -int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, - unsigned long flags); -int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, - unsigned long flags); -unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); -int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); -void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); -void X509_VERIFY_PARAM_set_auth_level(X509_VERIFY_PARAM *param, int auth_level); -time_t X509_VERIFY_PARAM_get_time(const X509_VERIFY_PARAM *param); -void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); -int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, - ASN1_OBJECT *policy); -int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, - STACK_OF(ASN1_OBJECT) *policies); - -int X509_VERIFY_PARAM_set_inh_flags(X509_VERIFY_PARAM *param, - uint32_t flags); -uint32_t X509_VERIFY_PARAM_get_inh_flags(const X509_VERIFY_PARAM *param); - -int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param, - const char *name, size_t namelen); -int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param, - const char *name, size_t namelen); -void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param, - unsigned int flags); -unsigned int X509_VERIFY_PARAM_get_hostflags(const X509_VERIFY_PARAM *param); -char *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *); -void X509_VERIFY_PARAM_move_peername(X509_VERIFY_PARAM *, X509_VERIFY_PARAM *); -int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param, - const char *email, size_t emaillen); -int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, - const unsigned char *ip, size_t iplen); -int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param, - const char *ipasc); - -int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_get_auth_level(const X509_VERIFY_PARAM *param); -const char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param); - -int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_get_count(void); -const X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id); -const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); -void X509_VERIFY_PARAM_table_cleanup(void); - -/* Non positive return values are errors */ -#define X509_PCY_TREE_FAILURE -2 /* Failure to satisfy explicit policy */ -#define X509_PCY_TREE_INVALID -1 /* Inconsistent or invalid extensions */ -#define X509_PCY_TREE_INTERNAL 0 /* Internal error, most likely malloc */ - -/* - * Positive return values form a bit mask, all but the first are internal to - * the library and don't appear in results from X509_policy_check(). - */ -#define X509_PCY_TREE_VALID 1 /* The policy tree is valid */ -#define X509_PCY_TREE_EMPTY 2 /* The policy tree is empty */ -#define X509_PCY_TREE_EXPLICIT 4 /* Explicit policy required */ - -int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, - STACK_OF(X509) *certs, - STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags); - -void X509_policy_tree_free(X509_POLICY_TREE *tree); - -int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); -X509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, - int i); - -STACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const - X509_POLICY_TREE - *tree); - -STACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_user_policies(const - X509_POLICY_TREE - *tree); - -int X509_policy_level_node_count(X509_POLICY_LEVEL *level); - -X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, - int i); - -const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); - -STACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const - X509_POLICY_NODE - *node); -const X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE - *node); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/x509err.h b/client/3rd/OpenSSL/include/openssl/x509err.h deleted file mode 100644 index cd08673f..00000000 --- a/client/3rd/OpenSSL/include/openssl/x509err.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_X509ERR_H -# define HEADER_X509ERR_H - -# include - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_X509_strings(void); - -/* - * X509 function codes. - */ -# define X509_F_ADD_CERT_DIR 100 -# define X509_F_BUILD_CHAIN 106 -# define X509_F_BY_FILE_CTRL 101 -# define X509_F_CHECK_NAME_CONSTRAINTS 149 -# define X509_F_CHECK_POLICY 145 -# define X509_F_DANE_I2D 107 -# define X509_F_DIR_CTRL 102 -# define X509_F_GET_CERT_BY_SUBJECT 103 -# define X509_F_I2D_X509_AUX 151 -# define X509_F_LOOKUP_CERTS_SK 152 -# define X509_F_NETSCAPE_SPKI_B64_DECODE 129 -# define X509_F_NETSCAPE_SPKI_B64_ENCODE 130 -# define X509_F_NEW_DIR 153 -# define X509_F_X509AT_ADD1_ATTR 135 -# define X509_F_X509V3_ADD_EXT 104 -# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136 -# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137 -# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140 -# define X509_F_X509_ATTRIBUTE_GET0_DATA 139 -# define X509_F_X509_ATTRIBUTE_SET1_DATA 138 -# define X509_F_X509_CHECK_PRIVATE_KEY 128 -# define X509_F_X509_CRL_DIFF 105 -# define X509_F_X509_CRL_METHOD_NEW 154 -# define X509_F_X509_CRL_PRINT_FP 147 -# define X509_F_X509_EXTENSION_CREATE_BY_NID 108 -# define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 -# define X509_F_X509_GET_PUBKEY_PARAMETERS 110 -# define X509_F_X509_LOAD_CERT_CRL_FILE 132 -# define X509_F_X509_LOAD_CERT_FILE 111 -# define X509_F_X509_LOAD_CRL_FILE 112 -# define X509_F_X509_LOOKUP_METH_NEW 160 -# define X509_F_X509_LOOKUP_NEW 155 -# define X509_F_X509_NAME_ADD_ENTRY 113 -# define X509_F_X509_NAME_CANON 156 -# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 -# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131 -# define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 -# define X509_F_X509_NAME_ONELINE 116 -# define X509_F_X509_NAME_PRINT 117 -# define X509_F_X509_OBJECT_NEW 150 -# define X509_F_X509_PRINT_EX_FP 118 -# define X509_F_X509_PUBKEY_DECODE 148 -# define X509_F_X509_PUBKEY_GET 161 -# define X509_F_X509_PUBKEY_GET0 119 -# define X509_F_X509_PUBKEY_SET 120 -# define X509_F_X509_REQ_CHECK_PRIVATE_KEY 144 -# define X509_F_X509_REQ_PRINT_EX 121 -# define X509_F_X509_REQ_PRINT_FP 122 -# define X509_F_X509_REQ_TO_X509 123 -# define X509_F_X509_STORE_ADD_CERT 124 -# define X509_F_X509_STORE_ADD_CRL 125 -# define X509_F_X509_STORE_ADD_LOOKUP 157 -# define X509_F_X509_STORE_CTX_GET1_ISSUER 146 -# define X509_F_X509_STORE_CTX_INIT 143 -# define X509_F_X509_STORE_CTX_NEW 142 -# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134 -# define X509_F_X509_STORE_NEW 158 -# define X509_F_X509_TO_X509_REQ 126 -# define X509_F_X509_TRUST_ADD 133 -# define X509_F_X509_TRUST_SET 141 -# define X509_F_X509_VERIFY_CERT 127 -# define X509_F_X509_VERIFY_PARAM_NEW 159 - -/* - * X509 reason codes. - */ -# define X509_R_AKID_MISMATCH 110 -# define X509_R_BAD_SELECTOR 133 -# define X509_R_BAD_X509_FILETYPE 100 -# define X509_R_BASE64_DECODE_ERROR 118 -# define X509_R_CANT_CHECK_DH_KEY 114 -# define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 -# define X509_R_CRL_ALREADY_DELTA 127 -# define X509_R_CRL_VERIFY_FAILURE 131 -# define X509_R_IDP_MISMATCH 128 -# define X509_R_INVALID_ATTRIBUTES 138 -# define X509_R_INVALID_DIRECTORY 113 -# define X509_R_INVALID_FIELD_NAME 119 -# define X509_R_INVALID_TRUST 123 -# define X509_R_ISSUER_MISMATCH 129 -# define X509_R_KEY_TYPE_MISMATCH 115 -# define X509_R_KEY_VALUES_MISMATCH 116 -# define X509_R_LOADING_CERT_DIR 103 -# define X509_R_LOADING_DEFAULTS 104 -# define X509_R_METHOD_NOT_SUPPORTED 124 -# define X509_R_NAME_TOO_LONG 134 -# define X509_R_NEWER_CRL_NOT_NEWER 132 -# define X509_R_NO_CERTIFICATE_FOUND 135 -# define X509_R_NO_CERTIFICATE_OR_CRL_FOUND 136 -# define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 -# define X509_R_NO_CRL_FOUND 137 -# define X509_R_NO_CRL_NUMBER 130 -# define X509_R_PUBLIC_KEY_DECODE_ERROR 125 -# define X509_R_PUBLIC_KEY_ENCODE_ERROR 126 -# define X509_R_SHOULD_RETRY 106 -# define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 -# define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 -# define X509_R_UNKNOWN_KEY_TYPE 117 -# define X509_R_UNKNOWN_NID 109 -# define X509_R_UNKNOWN_PURPOSE_ID 121 -# define X509_R_UNKNOWN_TRUST_ID 120 -# define X509_R_UNSUPPORTED_ALGORITHM 111 -# define X509_R_WRONG_LOOKUP_TYPE 112 -# define X509_R_WRONG_TYPE 122 - -#endif diff --git a/client/3rd/OpenSSL/include/openssl/x509v3.h b/client/3rd/OpenSSL/include/openssl/x509v3.h deleted file mode 100644 index 90fa3592..00000000 --- a/client/3rd/OpenSSL/include/openssl/x509v3.h +++ /dev/null @@ -1,938 +0,0 @@ -/* - * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_X509V3_H -# define HEADER_X509V3_H - -# include -# include -# include -# include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Forward reference */ -struct v3_ext_method; -struct v3_ext_ctx; - -/* Useful typedefs */ - -typedef void *(*X509V3_EXT_NEW)(void); -typedef void (*X509V3_EXT_FREE) (void *); -typedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long); -typedef int (*X509V3_EXT_I2D) (void *, unsigned char **); -typedef STACK_OF(CONF_VALUE) * - (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext, - STACK_OF(CONF_VALUE) *extlist); -typedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method, - struct v3_ext_ctx *ctx, - STACK_OF(CONF_VALUE) *values); -typedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method, - void *ext); -typedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method, - struct v3_ext_ctx *ctx, const char *str); -typedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext, - BIO *out, int indent); -typedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method, - struct v3_ext_ctx *ctx, const char *str); - -/* V3 extension structure */ - -struct v3_ext_method { - int ext_nid; - int ext_flags; -/* If this is set the following four fields are ignored */ - ASN1_ITEM_EXP *it; -/* Old style ASN1 calls */ - X509V3_EXT_NEW ext_new; - X509V3_EXT_FREE ext_free; - X509V3_EXT_D2I d2i; - X509V3_EXT_I2D i2d; -/* The following pair is used for string extensions */ - X509V3_EXT_I2S i2s; - X509V3_EXT_S2I s2i; -/* The following pair is used for multi-valued extensions */ - X509V3_EXT_I2V i2v; - X509V3_EXT_V2I v2i; -/* The following are used for raw extensions */ - X509V3_EXT_I2R i2r; - X509V3_EXT_R2I r2i; - void *usr_data; /* Any extension specific data */ -}; - -typedef struct X509V3_CONF_METHOD_st { - char *(*get_string) (void *db, const char *section, const char *value); - STACK_OF(CONF_VALUE) *(*get_section) (void *db, const char *section); - void (*free_string) (void *db, char *string); - void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section); -} X509V3_CONF_METHOD; - -/* Context specific info */ -struct v3_ext_ctx { -# define CTX_TEST 0x1 -# define X509V3_CTX_REPLACE 0x2 - int flags; - X509 *issuer_cert; - X509 *subject_cert; - X509_REQ *subject_req; - X509_CRL *crl; - X509V3_CONF_METHOD *db_meth; - void *db; -/* Maybe more here */ -}; - -typedef struct v3_ext_method X509V3_EXT_METHOD; - -DEFINE_STACK_OF(X509V3_EXT_METHOD) - -/* ext_flags values */ -# define X509V3_EXT_DYNAMIC 0x1 -# define X509V3_EXT_CTX_DEP 0x2 -# define X509V3_EXT_MULTILINE 0x4 - -typedef BIT_STRING_BITNAME ENUMERATED_NAMES; - -typedef struct BASIC_CONSTRAINTS_st { - int ca; - ASN1_INTEGER *pathlen; -} BASIC_CONSTRAINTS; - -typedef struct PKEY_USAGE_PERIOD_st { - ASN1_GENERALIZEDTIME *notBefore; - ASN1_GENERALIZEDTIME *notAfter; -} PKEY_USAGE_PERIOD; - -typedef struct otherName_st { - ASN1_OBJECT *type_id; - ASN1_TYPE *value; -} OTHERNAME; - -typedef struct EDIPartyName_st { - ASN1_STRING *nameAssigner; - ASN1_STRING *partyName; -} EDIPARTYNAME; - -typedef struct GENERAL_NAME_st { -# define GEN_OTHERNAME 0 -# define GEN_EMAIL 1 -# define GEN_DNS 2 -# define GEN_X400 3 -# define GEN_DIRNAME 4 -# define GEN_EDIPARTY 5 -# define GEN_URI 6 -# define GEN_IPADD 7 -# define GEN_RID 8 - int type; - union { - char *ptr; - OTHERNAME *otherName; /* otherName */ - ASN1_IA5STRING *rfc822Name; - ASN1_IA5STRING *dNSName; - ASN1_TYPE *x400Address; - X509_NAME *directoryName; - EDIPARTYNAME *ediPartyName; - ASN1_IA5STRING *uniformResourceIdentifier; - ASN1_OCTET_STRING *iPAddress; - ASN1_OBJECT *registeredID; - /* Old names */ - ASN1_OCTET_STRING *ip; /* iPAddress */ - X509_NAME *dirn; /* dirn */ - ASN1_IA5STRING *ia5; /* rfc822Name, dNSName, - * uniformResourceIdentifier */ - ASN1_OBJECT *rid; /* registeredID */ - ASN1_TYPE *other; /* x400Address */ - } d; -} GENERAL_NAME; - -typedef struct ACCESS_DESCRIPTION_st { - ASN1_OBJECT *method; - GENERAL_NAME *location; -} ACCESS_DESCRIPTION; - -typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; - -typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; - -typedef STACK_OF(ASN1_INTEGER) TLS_FEATURE; - -DEFINE_STACK_OF(GENERAL_NAME) -typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; -DEFINE_STACK_OF(GENERAL_NAMES) - -DEFINE_STACK_OF(ACCESS_DESCRIPTION) - -typedef struct DIST_POINT_NAME_st { - int type; - union { - GENERAL_NAMES *fullname; - STACK_OF(X509_NAME_ENTRY) *relativename; - } name; -/* If relativename then this contains the full distribution point name */ - X509_NAME *dpname; -} DIST_POINT_NAME; -/* All existing reasons */ -# define CRLDP_ALL_REASONS 0x807f - -# define CRL_REASON_NONE -1 -# define CRL_REASON_UNSPECIFIED 0 -# define CRL_REASON_KEY_COMPROMISE 1 -# define CRL_REASON_CA_COMPROMISE 2 -# define CRL_REASON_AFFILIATION_CHANGED 3 -# define CRL_REASON_SUPERSEDED 4 -# define CRL_REASON_CESSATION_OF_OPERATION 5 -# define CRL_REASON_CERTIFICATE_HOLD 6 -# define CRL_REASON_REMOVE_FROM_CRL 8 -# define CRL_REASON_PRIVILEGE_WITHDRAWN 9 -# define CRL_REASON_AA_COMPROMISE 10 - -struct DIST_POINT_st { - DIST_POINT_NAME *distpoint; - ASN1_BIT_STRING *reasons; - GENERAL_NAMES *CRLissuer; - int dp_reasons; -}; - -typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; - -DEFINE_STACK_OF(DIST_POINT) - -struct AUTHORITY_KEYID_st { - ASN1_OCTET_STRING *keyid; - GENERAL_NAMES *issuer; - ASN1_INTEGER *serial; -}; - -/* Strong extranet structures */ - -typedef struct SXNET_ID_st { - ASN1_INTEGER *zone; - ASN1_OCTET_STRING *user; -} SXNETID; - -DEFINE_STACK_OF(SXNETID) - -typedef struct SXNET_st { - ASN1_INTEGER *version; - STACK_OF(SXNETID) *ids; -} SXNET; - -typedef struct NOTICEREF_st { - ASN1_STRING *organization; - STACK_OF(ASN1_INTEGER) *noticenos; -} NOTICEREF; - -typedef struct USERNOTICE_st { - NOTICEREF *noticeref; - ASN1_STRING *exptext; -} USERNOTICE; - -typedef struct POLICYQUALINFO_st { - ASN1_OBJECT *pqualid; - union { - ASN1_IA5STRING *cpsuri; - USERNOTICE *usernotice; - ASN1_TYPE *other; - } d; -} POLICYQUALINFO; - -DEFINE_STACK_OF(POLICYQUALINFO) - -typedef struct POLICYINFO_st { - ASN1_OBJECT *policyid; - STACK_OF(POLICYQUALINFO) *qualifiers; -} POLICYINFO; - -typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; - -DEFINE_STACK_OF(POLICYINFO) - -typedef struct POLICY_MAPPING_st { - ASN1_OBJECT *issuerDomainPolicy; - ASN1_OBJECT *subjectDomainPolicy; -} POLICY_MAPPING; - -DEFINE_STACK_OF(POLICY_MAPPING) - -typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; - -typedef struct GENERAL_SUBTREE_st { - GENERAL_NAME *base; - ASN1_INTEGER *minimum; - ASN1_INTEGER *maximum; -} GENERAL_SUBTREE; - -DEFINE_STACK_OF(GENERAL_SUBTREE) - -struct NAME_CONSTRAINTS_st { - STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; - STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; -}; - -typedef struct POLICY_CONSTRAINTS_st { - ASN1_INTEGER *requireExplicitPolicy; - ASN1_INTEGER *inhibitPolicyMapping; -} POLICY_CONSTRAINTS; - -/* Proxy certificate structures, see RFC 3820 */ -typedef struct PROXY_POLICY_st { - ASN1_OBJECT *policyLanguage; - ASN1_OCTET_STRING *policy; -} PROXY_POLICY; - -typedef struct PROXY_CERT_INFO_EXTENSION_st { - ASN1_INTEGER *pcPathLengthConstraint; - PROXY_POLICY *proxyPolicy; -} PROXY_CERT_INFO_EXTENSION; - -DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) -DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) - -struct ISSUING_DIST_POINT_st { - DIST_POINT_NAME *distpoint; - int onlyuser; - int onlyCA; - ASN1_BIT_STRING *onlysomereasons; - int indirectCRL; - int onlyattr; -}; - -/* Values in idp_flags field */ -/* IDP present */ -# define IDP_PRESENT 0x1 -/* IDP values inconsistent */ -# define IDP_INVALID 0x2 -/* onlyuser true */ -# define IDP_ONLYUSER 0x4 -/* onlyCA true */ -# define IDP_ONLYCA 0x8 -/* onlyattr true */ -# define IDP_ONLYATTR 0x10 -/* indirectCRL true */ -# define IDP_INDIRECT 0x20 -/* onlysomereasons present */ -# define IDP_REASONS 0x40 - -# define X509V3_conf_err(val) ERR_add_error_data(6, \ - "section:", (val)->section, \ - ",name:", (val)->name, ",value:", (val)->value) - -# define X509V3_set_ctx_test(ctx) \ - X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) -# define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; - -# define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ - 0,0,0,0, \ - 0,0, \ - (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ - (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ - NULL, NULL, \ - table} - -# define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ - 0,0,0,0, \ - (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ - (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ - 0,0,0,0, \ - NULL} - -# define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - -/* X509_PURPOSE stuff */ - -# define EXFLAG_BCONS 0x1 -# define EXFLAG_KUSAGE 0x2 -# define EXFLAG_XKUSAGE 0x4 -# define EXFLAG_NSCERT 0x8 - -# define EXFLAG_CA 0x10 -/* Really self issued not necessarily self signed */ -# define EXFLAG_SI 0x20 -# define EXFLAG_V1 0x40 -# define EXFLAG_INVALID 0x80 -/* EXFLAG_SET is set to indicate that some values have been precomputed */ -# define EXFLAG_SET 0x100 -# define EXFLAG_CRITICAL 0x200 -# define EXFLAG_PROXY 0x400 - -# define EXFLAG_INVALID_POLICY 0x800 -# define EXFLAG_FRESHEST 0x1000 -# define EXFLAG_SS 0x2000 /* cert is apparently self-signed */ - -# define EXFLAG_NO_FINGERPRINT 0x100000 - -# define KU_DIGITAL_SIGNATURE 0x0080 -# define KU_NON_REPUDIATION 0x0040 -# define KU_KEY_ENCIPHERMENT 0x0020 -# define KU_DATA_ENCIPHERMENT 0x0010 -# define KU_KEY_AGREEMENT 0x0008 -# define KU_KEY_CERT_SIGN 0x0004 -# define KU_CRL_SIGN 0x0002 -# define KU_ENCIPHER_ONLY 0x0001 -# define KU_DECIPHER_ONLY 0x8000 - -# define NS_SSL_CLIENT 0x80 -# define NS_SSL_SERVER 0x40 -# define NS_SMIME 0x20 -# define NS_OBJSIGN 0x10 -# define NS_SSL_CA 0x04 -# define NS_SMIME_CA 0x02 -# define NS_OBJSIGN_CA 0x01 -# define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) - -# define XKU_SSL_SERVER 0x1 -# define XKU_SSL_CLIENT 0x2 -# define XKU_SMIME 0x4 -# define XKU_CODE_SIGN 0x8 -# define XKU_SGC 0x10 -# define XKU_OCSP_SIGN 0x20 -# define XKU_TIMESTAMP 0x40 -# define XKU_DVCS 0x80 -# define XKU_ANYEKU 0x100 - -# define X509_PURPOSE_DYNAMIC 0x1 -# define X509_PURPOSE_DYNAMIC_NAME 0x2 - -typedef struct x509_purpose_st { - int purpose; - int trust; /* Default trust ID */ - int flags; - int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int); - char *name; - char *sname; - void *usr_data; -} X509_PURPOSE; - -# define X509_PURPOSE_SSL_CLIENT 1 -# define X509_PURPOSE_SSL_SERVER 2 -# define X509_PURPOSE_NS_SSL_SERVER 3 -# define X509_PURPOSE_SMIME_SIGN 4 -# define X509_PURPOSE_SMIME_ENCRYPT 5 -# define X509_PURPOSE_CRL_SIGN 6 -# define X509_PURPOSE_ANY 7 -# define X509_PURPOSE_OCSP_HELPER 8 -# define X509_PURPOSE_TIMESTAMP_SIGN 9 - -# define X509_PURPOSE_MIN 1 -# define X509_PURPOSE_MAX 9 - -/* Flags for X509V3_EXT_print() */ - -# define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) -/* Return error for unknown extensions */ -# define X509V3_EXT_DEFAULT 0 -/* Print error for unknown extensions */ -# define X509V3_EXT_ERROR_UNKNOWN (1L << 16) -/* ASN1 parse unknown extensions */ -# define X509V3_EXT_PARSE_UNKNOWN (2L << 16) -/* BIO_dump unknown extensions */ -# define X509V3_EXT_DUMP_UNKNOWN (3L << 16) - -/* Flags for X509V3_add1_i2d */ - -# define X509V3_ADD_OP_MASK 0xfL -# define X509V3_ADD_DEFAULT 0L -# define X509V3_ADD_APPEND 1L -# define X509V3_ADD_REPLACE 2L -# define X509V3_ADD_REPLACE_EXISTING 3L -# define X509V3_ADD_KEEP_EXISTING 4L -# define X509V3_ADD_DELETE 5L -# define X509V3_ADD_SILENT 0x10 - -DEFINE_STACK_OF(X509_PURPOSE) - -DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) - -DECLARE_ASN1_FUNCTIONS(SXNET) -DECLARE_ASN1_FUNCTIONS(SXNETID) - -int SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userlen); -int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user, - int userlen); -int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, const char *user, - int userlen); - -ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, const char *zone); -ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); -ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); - -DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) - -DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) - -DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) -GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a); -int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b); - -ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, - STACK_OF(CONF_VALUE) *nval); -STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, - ASN1_BIT_STRING *bits, - STACK_OF(CONF_VALUE) *extlist); -char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5); -ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, const char *str); - -STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, - GENERAL_NAME *gen, - STACK_OF(CONF_VALUE) *ret); -int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); - -DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) - -STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, - GENERAL_NAMES *gen, - STACK_OF(CONF_VALUE) *extlist); -GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); - -DECLARE_ASN1_FUNCTIONS(OTHERNAME) -DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) -int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b); -void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value); -void *GENERAL_NAME_get0_value(const GENERAL_NAME *a, int *ptype); -int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, - ASN1_OBJECT *oid, ASN1_TYPE *value); -int GENERAL_NAME_get0_otherName(const GENERAL_NAME *gen, - ASN1_OBJECT **poid, ASN1_TYPE **pvalue); - -char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, - const ASN1_OCTET_STRING *ia5); -ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, const char *str); - -DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) -int i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION *a); - -DECLARE_ASN1_ALLOC_FUNCTIONS(TLS_FEATURE) - -DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) -DECLARE_ASN1_FUNCTIONS(POLICYINFO) -DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) -DECLARE_ASN1_FUNCTIONS(USERNOTICE) -DECLARE_ASN1_FUNCTIONS(NOTICEREF) - -DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) -DECLARE_ASN1_FUNCTIONS(DIST_POINT) -DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) -DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT) - -int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname); - -int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc); -int NAME_CONSTRAINTS_check_CN(X509 *x, NAME_CONSTRAINTS *nc); - -DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) -DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) - -DECLARE_ASN1_ITEM(POLICY_MAPPING) -DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) -DECLARE_ASN1_ITEM(POLICY_MAPPINGS) - -DECLARE_ASN1_ITEM(GENERAL_SUBTREE) -DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) - -DECLARE_ASN1_ITEM(NAME_CONSTRAINTS) -DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) - -DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) -DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) - -GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, - const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, int gen_type, - const char *value, int is_nc); - -# ifdef HEADER_CONF_H -GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, CONF_VALUE *cnf); -GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, - const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, CONF_VALUE *cnf, - int is_nc); -void X509V3_conf_free(CONF_VALUE *val); - -X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, - const char *value); -X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name, - const char *value); -int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section, - STACK_OF(X509_EXTENSION) **sk); -int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, - X509 *cert); -int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, - X509_REQ *req); -int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, - X509_CRL *crl); - -X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, - X509V3_CTX *ctx, int ext_nid, - const char *value); -X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - const char *name, const char *value); -int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - const char *section, X509 *cert); -int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - const char *section, X509_REQ *req); -int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - const char *section, X509_CRL *crl); - -int X509V3_add_value_bool_nf(const char *name, int asn1_bool, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool); -int X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint); -void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); -void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash); -# endif - -char *X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section); -STACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, const char *section); -void X509V3_string_free(X509V3_CTX *ctx, char *str); -void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); -void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, - X509_REQ *req, X509_CRL *crl, int flags); - -int X509V3_add_value(const char *name, const char *value, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_add_value_uchar(const char *name, const unsigned char *value, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_add_value_bool(const char *name, int asn1_bool, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint, - STACK_OF(CONF_VALUE) **extlist); -char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const ASN1_INTEGER *aint); -ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const char *value); -char *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, const ASN1_ENUMERATED *aint); -char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, - const ASN1_ENUMERATED *aint); -int X509V3_EXT_add(X509V3_EXT_METHOD *ext); -int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); -int X509V3_EXT_add_alias(int nid_to, int nid_from); -void X509V3_EXT_cleanup(void); - -const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); -const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); -int X509V3_add_standard_extensions(void); -STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); -void *X509V3_EXT_d2i(X509_EXTENSION *ext); -void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, - int *idx); - -X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); -int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, - int crit, unsigned long flags); - -#if OPENSSL_API_COMPAT < 0x10100000L -/* The new declarations are in crypto.h, but the old ones were here. */ -# define hex_to_string OPENSSL_buf2hexstr -# define string_to_hex OPENSSL_hexstr2buf -#endif - -void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, - int ml); -int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, - int indent); -#ifndef OPENSSL_NO_STDIO -int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); -#endif -int X509V3_extensions_print(BIO *out, const char *title, - const STACK_OF(X509_EXTENSION) *exts, - unsigned long flag, int indent); - -int X509_check_ca(X509 *x); -int X509_check_purpose(X509 *x, int id, int ca); -int X509_supported_extension(X509_EXTENSION *ex); -int X509_PURPOSE_set(int *p, int purpose); -int X509_check_issued(X509 *issuer, X509 *subject); -int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid); -void X509_set_proxy_flag(X509 *x); -void X509_set_proxy_pathlen(X509 *x, long l); -long X509_get_proxy_pathlen(X509 *x); - -uint32_t X509_get_extension_flags(X509 *x); -uint32_t X509_get_key_usage(X509 *x); -uint32_t X509_get_extended_key_usage(X509 *x); -const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x); -const ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x); -const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x); -const ASN1_INTEGER *X509_get0_authority_serial(X509 *x); - -int X509_PURPOSE_get_count(void); -X509_PURPOSE *X509_PURPOSE_get0(int idx); -int X509_PURPOSE_get_by_sname(const char *sname); -int X509_PURPOSE_get_by_id(int id); -int X509_PURPOSE_add(int id, int trust, int flags, - int (*ck) (const X509_PURPOSE *, const X509 *, int), - const char *name, const char *sname, void *arg); -char *X509_PURPOSE_get0_name(const X509_PURPOSE *xp); -char *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp); -int X509_PURPOSE_get_trust(const X509_PURPOSE *xp); -void X509_PURPOSE_cleanup(void); -int X509_PURPOSE_get_id(const X509_PURPOSE *); - -STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x); -STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x); -void X509_email_free(STACK_OF(OPENSSL_STRING) *sk); -STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x); -/* Flags for X509_check_* functions */ - -/* - * Always check subject name for host match even if subject alt names present - */ -# define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT 0x1 -/* Disable wildcard matching for dnsName fields and common name. */ -# define X509_CHECK_FLAG_NO_WILDCARDS 0x2 -/* Wildcards must not match a partial label. */ -# define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4 -/* Allow (non-partial) wildcards to match multiple labels. */ -# define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8 -/* Constraint verifier subdomain patterns to match a single labels. */ -# define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10 -/* Never check the subject CN */ -# define X509_CHECK_FLAG_NEVER_CHECK_SUBJECT 0x20 -/* - * Match reference identifiers starting with "." to any sub-domain. - * This is a non-public flag, turned on implicitly when the subject - * reference identity is a DNS name. - */ -# define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000 - -int X509_check_host(X509 *x, const char *chk, size_t chklen, - unsigned int flags, char **peername); -int X509_check_email(X509 *x, const char *chk, size_t chklen, - unsigned int flags); -int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen, - unsigned int flags); -int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags); - -ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); -ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); -int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk, - unsigned long chtype); - -void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); -DEFINE_STACK_OF(X509_POLICY_NODE) - -#ifndef OPENSSL_NO_RFC3779 -typedef struct ASRange_st { - ASN1_INTEGER *min, *max; -} ASRange; - -# define ASIdOrRange_id 0 -# define ASIdOrRange_range 1 - -typedef struct ASIdOrRange_st { - int type; - union { - ASN1_INTEGER *id; - ASRange *range; - } u; -} ASIdOrRange; - -typedef STACK_OF(ASIdOrRange) ASIdOrRanges; -DEFINE_STACK_OF(ASIdOrRange) - -# define ASIdentifierChoice_inherit 0 -# define ASIdentifierChoice_asIdsOrRanges 1 - -typedef struct ASIdentifierChoice_st { - int type; - union { - ASN1_NULL *inherit; - ASIdOrRanges *asIdsOrRanges; - } u; -} ASIdentifierChoice; - -typedef struct ASIdentifiers_st { - ASIdentifierChoice *asnum, *rdi; -} ASIdentifiers; - -DECLARE_ASN1_FUNCTIONS(ASRange) -DECLARE_ASN1_FUNCTIONS(ASIdOrRange) -DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice) -DECLARE_ASN1_FUNCTIONS(ASIdentifiers) - -typedef struct IPAddressRange_st { - ASN1_BIT_STRING *min, *max; -} IPAddressRange; - -# define IPAddressOrRange_addressPrefix 0 -# define IPAddressOrRange_addressRange 1 - -typedef struct IPAddressOrRange_st { - int type; - union { - ASN1_BIT_STRING *addressPrefix; - IPAddressRange *addressRange; - } u; -} IPAddressOrRange; - -typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges; -DEFINE_STACK_OF(IPAddressOrRange) - -# define IPAddressChoice_inherit 0 -# define IPAddressChoice_addressesOrRanges 1 - -typedef struct IPAddressChoice_st { - int type; - union { - ASN1_NULL *inherit; - IPAddressOrRanges *addressesOrRanges; - } u; -} IPAddressChoice; - -typedef struct IPAddressFamily_st { - ASN1_OCTET_STRING *addressFamily; - IPAddressChoice *ipAddressChoice; -} IPAddressFamily; - -typedef STACK_OF(IPAddressFamily) IPAddrBlocks; -DEFINE_STACK_OF(IPAddressFamily) - -DECLARE_ASN1_FUNCTIONS(IPAddressRange) -DECLARE_ASN1_FUNCTIONS(IPAddressOrRange) -DECLARE_ASN1_FUNCTIONS(IPAddressChoice) -DECLARE_ASN1_FUNCTIONS(IPAddressFamily) - -/* - * API tag for elements of the ASIdentifer SEQUENCE. - */ -# define V3_ASID_ASNUM 0 -# define V3_ASID_RDI 1 - -/* - * AFI values, assigned by IANA. It'd be nice to make the AFI - * handling code totally generic, but there are too many little things - * that would need to be defined for other address families for it to - * be worth the trouble. - */ -# define IANA_AFI_IPV4 1 -# define IANA_AFI_IPV6 2 - -/* - * Utilities to construct and extract values from RFC3779 extensions, - * since some of the encodings (particularly for IP address prefixes - * and ranges) are a bit tedious to work with directly. - */ -int X509v3_asid_add_inherit(ASIdentifiers *asid, int which); -int X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which, - ASN1_INTEGER *min, ASN1_INTEGER *max); -int X509v3_addr_add_inherit(IPAddrBlocks *addr, - const unsigned afi, const unsigned *safi); -int X509v3_addr_add_prefix(IPAddrBlocks *addr, - const unsigned afi, const unsigned *safi, - unsigned char *a, const int prefixlen); -int X509v3_addr_add_range(IPAddrBlocks *addr, - const unsigned afi, const unsigned *safi, - unsigned char *min, unsigned char *max); -unsigned X509v3_addr_get_afi(const IPAddressFamily *f); -int X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, - unsigned char *min, unsigned char *max, - const int length); - -/* - * Canonical forms. - */ -int X509v3_asid_is_canonical(ASIdentifiers *asid); -int X509v3_addr_is_canonical(IPAddrBlocks *addr); -int X509v3_asid_canonize(ASIdentifiers *asid); -int X509v3_addr_canonize(IPAddrBlocks *addr); - -/* - * Tests for inheritance and containment. - */ -int X509v3_asid_inherits(ASIdentifiers *asid); -int X509v3_addr_inherits(IPAddrBlocks *addr); -int X509v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b); -int X509v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b); - -/* - * Check whether RFC 3779 extensions nest properly in chains. - */ -int X509v3_asid_validate_path(X509_STORE_CTX *); -int X509v3_addr_validate_path(X509_STORE_CTX *); -int X509v3_asid_validate_resource_set(STACK_OF(X509) *chain, - ASIdentifiers *ext, - int allow_inheritance); -int X509v3_addr_validate_resource_set(STACK_OF(X509) *chain, - IPAddrBlocks *ext, int allow_inheritance); - -#endif /* OPENSSL_NO_RFC3779 */ - -DEFINE_STACK_OF(ASN1_STRING) - -/* - * Admission Syntax - */ -typedef struct NamingAuthority_st NAMING_AUTHORITY; -typedef struct ProfessionInfo_st PROFESSION_INFO; -typedef struct Admissions_st ADMISSIONS; -typedef struct AdmissionSyntax_st ADMISSION_SYNTAX; -DECLARE_ASN1_FUNCTIONS(NAMING_AUTHORITY) -DECLARE_ASN1_FUNCTIONS(PROFESSION_INFO) -DECLARE_ASN1_FUNCTIONS(ADMISSIONS) -DECLARE_ASN1_FUNCTIONS(ADMISSION_SYNTAX) -DEFINE_STACK_OF(ADMISSIONS) -DEFINE_STACK_OF(PROFESSION_INFO) -typedef STACK_OF(PROFESSION_INFO) PROFESSION_INFOS; - -const ASN1_OBJECT *NAMING_AUTHORITY_get0_authorityId( - const NAMING_AUTHORITY *n); -const ASN1_IA5STRING *NAMING_AUTHORITY_get0_authorityURL( - const NAMING_AUTHORITY *n); -const ASN1_STRING *NAMING_AUTHORITY_get0_authorityText( - const NAMING_AUTHORITY *n); -void NAMING_AUTHORITY_set0_authorityId(NAMING_AUTHORITY *n, - ASN1_OBJECT* namingAuthorityId); -void NAMING_AUTHORITY_set0_authorityURL(NAMING_AUTHORITY *n, - ASN1_IA5STRING* namingAuthorityUrl); -void NAMING_AUTHORITY_set0_authorityText(NAMING_AUTHORITY *n, - ASN1_STRING* namingAuthorityText); - -const GENERAL_NAME *ADMISSION_SYNTAX_get0_admissionAuthority( - const ADMISSION_SYNTAX *as); -void ADMISSION_SYNTAX_set0_admissionAuthority( - ADMISSION_SYNTAX *as, GENERAL_NAME *aa); -const STACK_OF(ADMISSIONS) *ADMISSION_SYNTAX_get0_contentsOfAdmissions( - const ADMISSION_SYNTAX *as); -void ADMISSION_SYNTAX_set0_contentsOfAdmissions( - ADMISSION_SYNTAX *as, STACK_OF(ADMISSIONS) *a); -const GENERAL_NAME *ADMISSIONS_get0_admissionAuthority(const ADMISSIONS *a); -void ADMISSIONS_set0_admissionAuthority(ADMISSIONS *a, GENERAL_NAME *aa); -const NAMING_AUTHORITY *ADMISSIONS_get0_namingAuthority(const ADMISSIONS *a); -void ADMISSIONS_set0_namingAuthority(ADMISSIONS *a, NAMING_AUTHORITY *na); -const PROFESSION_INFOS *ADMISSIONS_get0_professionInfos(const ADMISSIONS *a); -void ADMISSIONS_set0_professionInfos(ADMISSIONS *a, PROFESSION_INFOS *pi); -const ASN1_OCTET_STRING *PROFESSION_INFO_get0_addProfessionInfo( - const PROFESSION_INFO *pi); -void PROFESSION_INFO_set0_addProfessionInfo( - PROFESSION_INFO *pi, ASN1_OCTET_STRING *aos); -const NAMING_AUTHORITY *PROFESSION_INFO_get0_namingAuthority( - const PROFESSION_INFO *pi); -void PROFESSION_INFO_set0_namingAuthority( - PROFESSION_INFO *pi, NAMING_AUTHORITY *na); -const STACK_OF(ASN1_STRING) *PROFESSION_INFO_get0_professionItems( - const PROFESSION_INFO *pi); -void PROFESSION_INFO_set0_professionItems( - PROFESSION_INFO *pi, STACK_OF(ASN1_STRING) *as); -const STACK_OF(ASN1_OBJECT) *PROFESSION_INFO_get0_professionOIDs( - const PROFESSION_INFO *pi); -void PROFESSION_INFO_set0_professionOIDs( - PROFESSION_INFO *pi, STACK_OF(ASN1_OBJECT) *po); -const ASN1_PRINTABLESTRING *PROFESSION_INFO_get0_registrationNumber( - const PROFESSION_INFO *pi); -void PROFESSION_INFO_set0_registrationNumber( - PROFESSION_INFO *pi, ASN1_PRINTABLESTRING *rn); - -# ifdef __cplusplus -} -# endif -#endif diff --git a/client/3rd/OpenSSL/include/openssl/x509v3err.h b/client/3rd/OpenSSL/include/openssl/x509v3err.h deleted file mode 100644 index 3b9f7139..00000000 --- a/client/3rd/OpenSSL/include/openssl/x509v3err.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_X509V3ERR_H -# define HEADER_X509V3ERR_H - -# ifndef HEADER_SYMHACKS_H -# include -# endif - -# ifdef __cplusplus -extern "C" -# endif -int ERR_load_X509V3_strings(void); - -/* - * X509V3 function codes. - */ -# define X509V3_F_A2I_GENERAL_NAME 164 -# define X509V3_F_ADDR_VALIDATE_PATH_INTERNAL 166 -# define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 161 -# define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 162 -# define X509V3_F_BIGNUM_TO_STRING 167 -# define X509V3_F_COPY_EMAIL 122 -# define X509V3_F_COPY_ISSUER 123 -# define X509V3_F_DO_DIRNAME 144 -# define X509V3_F_DO_EXT_I2D 135 -# define X509V3_F_DO_EXT_NCONF 151 -# define X509V3_F_GNAMES_FROM_SECTNAME 156 -# define X509V3_F_I2S_ASN1_ENUMERATED 121 -# define X509V3_F_I2S_ASN1_IA5STRING 149 -# define X509V3_F_I2S_ASN1_INTEGER 120 -# define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138 -# define X509V3_F_I2V_AUTHORITY_KEYID 173 -# define X509V3_F_LEVEL_ADD_NODE 168 -# define X509V3_F_NOTICE_SECTION 132 -# define X509V3_F_NREF_NOS 133 -# define X509V3_F_POLICY_CACHE_CREATE 169 -# define X509V3_F_POLICY_CACHE_NEW 170 -# define X509V3_F_POLICY_DATA_NEW 171 -# define X509V3_F_POLICY_SECTION 131 -# define X509V3_F_PROCESS_PCI_VALUE 150 -# define X509V3_F_R2I_CERTPOL 130 -# define X509V3_F_R2I_PCI 155 -# define X509V3_F_S2I_ASN1_IA5STRING 100 -# define X509V3_F_S2I_ASN1_INTEGER 108 -# define X509V3_F_S2I_ASN1_OCTET_STRING 112 -# define X509V3_F_S2I_SKEY_ID 115 -# define X509V3_F_SET_DIST_POINT_NAME 158 -# define X509V3_F_SXNET_ADD_ID_ASC 125 -# define X509V3_F_SXNET_ADD_ID_INTEGER 126 -# define X509V3_F_SXNET_ADD_ID_ULONG 127 -# define X509V3_F_SXNET_GET_ID_ASC 128 -# define X509V3_F_SXNET_GET_ID_ULONG 129 -# define X509V3_F_TREE_INIT 172 -# define X509V3_F_V2I_ASIDENTIFIERS 163 -# define X509V3_F_V2I_ASN1_BIT_STRING 101 -# define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139 -# define X509V3_F_V2I_AUTHORITY_KEYID 119 -# define X509V3_F_V2I_BASIC_CONSTRAINTS 102 -# define X509V3_F_V2I_CRLD 134 -# define X509V3_F_V2I_EXTENDED_KEY_USAGE 103 -# define X509V3_F_V2I_GENERAL_NAMES 118 -# define X509V3_F_V2I_GENERAL_NAME_EX 117 -# define X509V3_F_V2I_IDP 157 -# define X509V3_F_V2I_IPADDRBLOCKS 159 -# define X509V3_F_V2I_ISSUER_ALT 153 -# define X509V3_F_V2I_NAME_CONSTRAINTS 147 -# define X509V3_F_V2I_POLICY_CONSTRAINTS 146 -# define X509V3_F_V2I_POLICY_MAPPINGS 145 -# define X509V3_F_V2I_SUBJECT_ALT 154 -# define X509V3_F_V2I_TLS_FEATURE 165 -# define X509V3_F_V3_GENERIC_EXTENSION 116 -# define X509V3_F_X509V3_ADD1_I2D 140 -# define X509V3_F_X509V3_ADD_LEN_VALUE 174 -# define X509V3_F_X509V3_ADD_VALUE 105 -# define X509V3_F_X509V3_EXT_ADD 104 -# define X509V3_F_X509V3_EXT_ADD_ALIAS 106 -# define X509V3_F_X509V3_EXT_I2D 136 -# define X509V3_F_X509V3_EXT_NCONF 152 -# define X509V3_F_X509V3_GET_SECTION 142 -# define X509V3_F_X509V3_GET_STRING 143 -# define X509V3_F_X509V3_GET_VALUE_BOOL 110 -# define X509V3_F_X509V3_PARSE_LIST 109 -# define X509V3_F_X509_PURPOSE_ADD 137 -# define X509V3_F_X509_PURPOSE_SET 141 - -/* - * X509V3 reason codes. - */ -# define X509V3_R_BAD_IP_ADDRESS 118 -# define X509V3_R_BAD_OBJECT 119 -# define X509V3_R_BN_DEC2BN_ERROR 100 -# define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 -# define X509V3_R_DIRNAME_ERROR 149 -# define X509V3_R_DISTPOINT_ALREADY_SET 160 -# define X509V3_R_DUPLICATE_ZONE_ID 133 -# define X509V3_R_ERROR_CONVERTING_ZONE 131 -# define X509V3_R_ERROR_CREATING_EXTENSION 144 -# define X509V3_R_ERROR_IN_EXTENSION 128 -# define X509V3_R_EXPECTED_A_SECTION_NAME 137 -# define X509V3_R_EXTENSION_EXISTS 145 -# define X509V3_R_EXTENSION_NAME_ERROR 115 -# define X509V3_R_EXTENSION_NOT_FOUND 102 -# define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103 -# define X509V3_R_EXTENSION_VALUE_ERROR 116 -# define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151 -# define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152 -# define X509V3_R_INVALID_ASNUMBER 162 -# define X509V3_R_INVALID_ASRANGE 163 -# define X509V3_R_INVALID_BOOLEAN_STRING 104 -# define X509V3_R_INVALID_EXTENSION_STRING 105 -# define X509V3_R_INVALID_INHERITANCE 165 -# define X509V3_R_INVALID_IPADDRESS 166 -# define X509V3_R_INVALID_MULTIPLE_RDNS 161 -# define X509V3_R_INVALID_NAME 106 -# define X509V3_R_INVALID_NULL_ARGUMENT 107 -# define X509V3_R_INVALID_NULL_NAME 108 -# define X509V3_R_INVALID_NULL_VALUE 109 -# define X509V3_R_INVALID_NUMBER 140 -# define X509V3_R_INVALID_NUMBERS 141 -# define X509V3_R_INVALID_OBJECT_IDENTIFIER 110 -# define X509V3_R_INVALID_OPTION 138 -# define X509V3_R_INVALID_POLICY_IDENTIFIER 134 -# define X509V3_R_INVALID_PROXY_POLICY_SETTING 153 -# define X509V3_R_INVALID_PURPOSE 146 -# define X509V3_R_INVALID_SAFI 164 -# define X509V3_R_INVALID_SECTION 135 -# define X509V3_R_INVALID_SYNTAX 143 -# define X509V3_R_ISSUER_DECODE_ERROR 126 -# define X509V3_R_MISSING_VALUE 124 -# define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 -# define X509V3_R_NO_CONFIG_DATABASE 136 -# define X509V3_R_NO_ISSUER_CERTIFICATE 121 -# define X509V3_R_NO_ISSUER_DETAILS 127 -# define X509V3_R_NO_POLICY_IDENTIFIER 139 -# define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 154 -# define X509V3_R_NO_PUBLIC_KEY 114 -# define X509V3_R_NO_SUBJECT_DETAILS 125 -# define X509V3_R_OPERATION_NOT_DEFINED 148 -# define X509V3_R_OTHERNAME_ERROR 147 -# define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED 155 -# define X509V3_R_POLICY_PATH_LENGTH 156 -# define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED 157 -# define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159 -# define X509V3_R_SECTION_NOT_FOUND 150 -# define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122 -# define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123 -# define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111 -# define X509V3_R_UNKNOWN_EXTENSION 129 -# define X509V3_R_UNKNOWN_EXTENSION_NAME 130 -# define X509V3_R_UNKNOWN_OPTION 120 -# define X509V3_R_UNSUPPORTED_OPTION 117 -# define X509V3_R_UNSUPPORTED_TYPE 167 -# define X509V3_R_USER_TOO_LONG 132 - -#endif diff --git a/client/3rd/OpenSSL/lib/android/arm64-v8a/libcrypto.a b/client/3rd/OpenSSL/lib/android/arm64-v8a/libcrypto.a deleted file mode 100644 index 0b5fb5e8..00000000 Binary files a/client/3rd/OpenSSL/lib/android/arm64-v8a/libcrypto.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/android/arm64-v8a/libssl.a b/client/3rd/OpenSSL/lib/android/arm64-v8a/libssl.a deleted file mode 100644 index c15c6a0e..00000000 Binary files a/client/3rd/OpenSSL/lib/android/arm64-v8a/libssl.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/android/armeabi-v7a/libcrypto.a b/client/3rd/OpenSSL/lib/android/armeabi-v7a/libcrypto.a deleted file mode 100644 index 60fca065..00000000 Binary files a/client/3rd/OpenSSL/lib/android/armeabi-v7a/libcrypto.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/android/armeabi-v7a/libssl.a b/client/3rd/OpenSSL/lib/android/armeabi-v7a/libssl.a deleted file mode 100644 index 0698640e..00000000 Binary files a/client/3rd/OpenSSL/lib/android/armeabi-v7a/libssl.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/android/x86/libcrypto.a b/client/3rd/OpenSSL/lib/android/x86/libcrypto.a deleted file mode 100644 index a620ec89..00000000 Binary files a/client/3rd/OpenSSL/lib/android/x86/libcrypto.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/android/x86/libssl.a b/client/3rd/OpenSSL/lib/android/x86/libssl.a deleted file mode 100644 index 6508ace5..00000000 Binary files a/client/3rd/OpenSSL/lib/android/x86/libssl.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/android/x86_64/libcrypto.a b/client/3rd/OpenSSL/lib/android/x86_64/libcrypto.a deleted file mode 100644 index 21fac25f..00000000 Binary files a/client/3rd/OpenSSL/lib/android/x86_64/libcrypto.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/android/x86_64/libssl.a b/client/3rd/OpenSSL/lib/android/x86_64/libssl.a deleted file mode 100644 index 2c371f4f..00000000 Binary files a/client/3rd/OpenSSL/lib/android/x86_64/libssl.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/ios/iphone/libcrypto.a b/client/3rd/OpenSSL/lib/ios/iphone/libcrypto.a deleted file mode 100644 index 8e1eb95c..00000000 Binary files a/client/3rd/OpenSSL/lib/ios/iphone/libcrypto.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/ios/iphone/libssl.a b/client/3rd/OpenSSL/lib/ios/iphone/libssl.a deleted file mode 100644 index fc424af7..00000000 Binary files a/client/3rd/OpenSSL/lib/ios/iphone/libssl.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/ios/simulator/libcrypto.a b/client/3rd/OpenSSL/lib/ios/simulator/libcrypto.a deleted file mode 100644 index e73f0e88..00000000 Binary files a/client/3rd/OpenSSL/lib/ios/simulator/libcrypto.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/ios/simulator/libssl.a b/client/3rd/OpenSSL/lib/ios/simulator/libssl.a deleted file mode 100644 index 6f05969a..00000000 Binary files a/client/3rd/OpenSSL/lib/ios/simulator/libssl.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/macos/x86_64/libcrypto.a b/client/3rd/OpenSSL/lib/macos/x86_64/libcrypto.a deleted file mode 100644 index 85a1047e..00000000 Binary files a/client/3rd/OpenSSL/lib/macos/x86_64/libcrypto.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/macos/x86_64/libssl.a b/client/3rd/OpenSSL/lib/macos/x86_64/libssl.a deleted file mode 100644 index 2e981617..00000000 Binary files a/client/3rd/OpenSSL/lib/macos/x86_64/libssl.a and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/windows/x86/libcrypto.lib b/client/3rd/OpenSSL/lib/windows/x86/libcrypto.lib deleted file mode 100644 index d8516d7f..00000000 Binary files a/client/3rd/OpenSSL/lib/windows/x86/libcrypto.lib and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/windows/x86/libssl.lib b/client/3rd/OpenSSL/lib/windows/x86/libssl.lib deleted file mode 100644 index 10f1ae41..00000000 Binary files a/client/3rd/OpenSSL/lib/windows/x86/libssl.lib and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/windows/x86_64/libcrypto.lib b/client/3rd/OpenSSL/lib/windows/x86_64/libcrypto.lib deleted file mode 100644 index 2c7d1a0a..00000000 Binary files a/client/3rd/OpenSSL/lib/windows/x86_64/libcrypto.lib and /dev/null differ diff --git a/client/3rd/OpenSSL/lib/windows/x86_64/libssl.lib b/client/3rd/OpenSSL/lib/windows/x86_64/libssl.lib deleted file mode 100644 index 188270ef..00000000 Binary files a/client/3rd/OpenSSL/lib/windows/x86_64/libssl.lib and /dev/null differ diff --git a/client/3rd/OpenVPNAdapter b/client/3rd/OpenVPNAdapter deleted file mode 160000 index 0e2db0ba..00000000 --- a/client/3rd/OpenVPNAdapter +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0e2db0baa0d66029cbb18d74b78bc7a5c9013fba diff --git a/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.pbxproj b/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.pbxproj deleted file mode 100644 index 04cc4654..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.pbxproj +++ /dev/null @@ -1,1640 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 55; - objects = { - -/* Begin PBXBuildFile section */ - 19D0CCED277092B50010B299 /* PacketProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 19D0CCEC277092B50010B299 /* PacketProcessor.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 19D0D6092770982F0010B299 /* BSocksClient.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D44F2770982C0010B299 /* BSocksClient.c */; }; - 19D0D64B277098300010B299 /* sys.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4942770982D0010B299 /* sys.c */; }; - 19D0D64F277098300010B299 /* memp.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D49B2770982D0010B299 /* memp.c */; }; - 19D0D650277098300010B299 /* inet_chksum.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D49C2770982D0010B299 /* inet_chksum.c */; }; - 19D0D651277098300010B299 /* tcp_out.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D49D2770982D0010B299 /* tcp_out.c */; }; - 19D0D652277098300010B299 /* init.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D49E2770982D0010B299 /* init.c */; }; - 19D0D653277098300010B299 /* mem.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D49F2770982D0010B299 /* mem.c */; }; - 19D0D654277098300010B299 /* def.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4A02770982D0010B299 /* def.c */; }; - 19D0D655277098300010B299 /* udp.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4A12770982D0010B299 /* udp.c */; }; - 19D0D656277098300010B299 /* stats.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4A22770982D0010B299 /* stats.c */; }; - 19D0D657277098300010B299 /* tcp_in.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4A32770982D0010B299 /* tcp_in.c */; }; - 19D0D658277098300010B299 /* ip_frag.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4A52770982D0010B299 /* ip_frag.c */; }; - 19D0D659277098300010B299 /* icmp.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4A62770982D0010B299 /* icmp.c */; }; - 19D0D65A277098300010B299 /* ip4.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4A72770982D0010B299 /* ip4.c */; }; - 19D0D65B277098300010B299 /* ip4_addr.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4A82770982D0010B299 /* ip4_addr.c */; }; - 19D0D65C277098300010B299 /* netif.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4A92770982D0010B299 /* netif.c */; }; - 19D0D65D277098300010B299 /* tcp.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4AA2770982D0010B299 /* tcp.c */; }; - 19D0D65E277098300010B299 /* timers.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4AB2770982D0010B299 /* timers.c */; }; - 19D0D65F277098300010B299 /* pbuf.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4AC2770982D0010B299 /* pbuf.c */; }; - 19D0D660277098300010B299 /* ip6.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4AE2770982D0010B299 /* ip6.c */; }; - 19D0D661277098300010B299 /* icmp6.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4AF2770982D0010B299 /* icmp6.c */; }; - 19D0D662277098300010B299 /* nd6.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4B02770982D0010B299 /* nd6.c */; }; - 19D0D663277098300010B299 /* ip6_addr.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4B12770982D0010B299 /* ip6_addr.c */; }; - 19D0D664277098300010B299 /* ip6_frag.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4B22770982D0010B299 /* ip6_frag.c */; }; - 19D0D69D277098310010B299 /* BTap.m in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4F52770982D0010B299 /* BTap.m */; }; - 19D0D6A0277098310010B299 /* udpgw.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D4F92770982D0010B299 /* udpgw.c */; }; - 19D0D6A9277098310010B299 /* addr.bproto in Resources */ = {isa = PBXBuildFile; fileRef = 19D0D5032770982D0010B299 /* addr.bproto */; }; - 19D0D6AB277098310010B299 /* msgproto.bproto in Resources */ = {isa = PBXBuildFile; fileRef = 19D0D5052770982D0010B299 /* msgproto.bproto */; }; - 19D0D6AE277098310010B299 /* BNetwork.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5092770982D0010B299 /* BNetwork.c */; }; - 19D0D6B0277098310010B299 /* BConnection_common.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D50B2770982D0010B299 /* BConnection_common.c */; }; - 19D0D6B5277098310010B299 /* BTime.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5102770982D0010B299 /* BTime.c */; }; - 19D0D6B6277098310010B299 /* BSignal.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5112770982D0010B299 /* BSignal.c */; }; - 19D0D6B8277098310010B299 /* BDatagram_unix.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5132770982D0010B299 /* BDatagram_unix.c */; }; - 19D0D6BA277098310010B299 /* BUnixSignal.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5152770982D0010B299 /* BUnixSignal.c */; }; - 19D0D6BC277098310010B299 /* BReactor_badvpn.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5172770982D0010B299 /* BReactor_badvpn.c */; }; - 19D0D6BF277098310010B299 /* BConnection_unix.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D51A2770982D0010B299 /* BConnection_unix.c */; }; - 19D0D6C0277098310010B299 /* tun2socks.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D51C2770982D0010B299 /* tun2socks.c */; }; - 19D0D6C3277098310010B299 /* SocksUdpGwClient.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D51F2770982D0010B299 /* SocksUdpGwClient.c */; }; - 19D0D6E6277098310010B299 /* PacketPassInactivityMonitor.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5442770982D0010B299 /* PacketPassInactivityMonitor.c */; }; - 19D0D6E7277098310010B299 /* BLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5462770982D0010B299 /* BLog.m */; }; - 19D0D6E8277098310010B299 /* BLog_syslog.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5472770982E0010B299 /* BLog_syslog.c */; }; - 19D0D6EA277098310010B299 /* DebugObject.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5492770982E0010B299 /* DebugObject.c */; }; - 19D0D6EF277098310010B299 /* BPending.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D54E2770982E0010B299 /* BPending.c */; }; - 19D0D6F1277098310010B299 /* UdpGwClient.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5512770982E0010B299 /* UdpGwClient.c */; }; - 19D0D6F3277098310010B299 /* PacketBuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5542770982E0010B299 /* PacketBuffer.c */; }; - 19D0D6F5277098310010B299 /* BufferWriter.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5562770982E0010B299 /* BufferWriter.c */; }; - 19D0D6F6277098310010B299 /* PacketRecvInterface.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5572770982E0010B299 /* PacketRecvInterface.c */; }; - 19D0D6FA277098320010B299 /* StreamRecvInterface.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D55B2770982E0010B299 /* StreamRecvInterface.c */; }; - 19D0D6FB277098320010B299 /* PacketProtoEncoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D55C2770982E0010B299 /* PacketProtoEncoder.c */; }; - 19D0D6FC277098320010B299 /* StreamPassInterface.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D55D2770982E0010B299 /* StreamPassInterface.c */; }; - 19D0D6FD277098320010B299 /* PacketPassConnector.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D55E2770982E0010B299 /* PacketPassConnector.c */; }; - 19D0D6FF277098320010B299 /* PacketProtoFlow.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5602770982E0010B299 /* PacketProtoFlow.c */; }; - 19D0D700277098320010B299 /* PacketPassInterface.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5612770982E0010B299 /* PacketPassInterface.c */; }; - 19D0D704277098320010B299 /* PacketStreamSender.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5652770982E0010B299 /* PacketStreamSender.c */; }; - 19D0D706277098320010B299 /* PacketProtoDecoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5672770982E0010B299 /* PacketProtoDecoder.c */; }; - 19D0D707277098320010B299 /* SinglePacketBuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5682770982E0010B299 /* SinglePacketBuffer.c */; }; - 19D0D708277098320010B299 /* PacketPassFairQueue.c in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5692770982E0010B299 /* PacketPassFairQueue.c */; }; - 19D0D70F277098320010B299 /* TunnelInterface.m in Sources */ = {isa = PBXBuildFile; fileRef = 19D0D5702770982E0010B299 /* TunnelInterface.m */; }; - 19D0D710277098610010B299 /* TunnelInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 19D0D56F2770982E0010B299 /* TunnelInterface.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 19D0D718277099960010B299 /* CocoaAsyncSocket.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 19D0D7162770998F0010B299 /* CocoaAsyncSocket.framework */; }; - 19D0D719277099970010B299 /* CocoaAsyncSocket.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 19D0D7162770998F0010B299 /* CocoaAsyncSocket.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 19D0D71C2770A3AD0010B299 /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 19D0D71B2770A3AD0010B299 /* libresolv.tbd */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 19D0CCF9277096980010B299 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 19D0D719277099970010B299 /* CocoaAsyncSocket.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 19D0CCE9277092B50010B299 /* PacketProcessor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PacketProcessor.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 19D0CCEC277092B50010B299 /* PacketProcessor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PacketProcessor.h; sourceTree = ""; }; - 19D0D3B62770982C0010B299 /* blog_channel_SocksUdpGwClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_SocksUdpGwClient.h; sourceTree = ""; }; - 19D0D3B72770982C0010B299 /* blog_channel_ncd_file_open.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_file_open.h; sourceTree = ""; }; - 19D0D3B82770982C0010B299 /* blog_channel_BReactor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BReactor.h; sourceTree = ""; }; - 19D0D3B92770982C0010B299 /* blog_channel_BSSLConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BSSLConnection.h; sourceTree = ""; }; - 19D0D3BA2770982C0010B299 /* blog_channel_BConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BConnection.h; sourceTree = ""; }; - 19D0D3BB2770982C0010B299 /* blog_channel_ncd_net_ipv4_route.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_ipv4_route.h; sourceTree = ""; }; - 19D0D3BC2770982C0010B299 /* blog_channel_ncd_sys_request_server.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_sys_request_server.h; sourceTree = ""; }; - 19D0D3BD2770982C0010B299 /* blog_channel_ncd_sys_watch_usb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_sys_watch_usb.h; sourceTree = ""; }; - 19D0D3BE2770982C0010B299 /* blog_channel_ncd_run.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_run.h; sourceTree = ""; }; - 19D0D3BF2770982C0010B299 /* blog_channels_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channels_list.h; sourceTree = ""; }; - 19D0D3C02770982C0010B299 /* blog_channel_NCDValGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDValGenerator.h; sourceTree = ""; }; - 19D0D3C12770982C0010B299 /* blog_channel_FrameDecider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_FrameDecider.h; sourceTree = ""; }; - 19D0D3C22770982C0010B299 /* blog_channel_ncd_dynamic_depend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_dynamic_depend.h; sourceTree = ""; }; - 19D0D3C32770982C0010B299 /* blog_channel_ncd_net_ipv6_wait_dynamic_addr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_ipv6_wait_dynamic_addr.h; sourceTree = ""; }; - 19D0D3C42770982C0010B299 /* blog_channel_udpgw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_udpgw.h; sourceTree = ""; }; - 19D0D3C52770982C0010B299 /* blog_channel_BUnixSignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BUnixSignal.h; sourceTree = ""; }; - 19D0D3C62770982C0010B299 /* blog_channel_ncd_parse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_parse.h; sourceTree = ""; }; - 19D0D3C72770982C0010B299 /* blog_channel_ncd_ref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_ref.h; sourceTree = ""; }; - 19D0D3C82770982C0010B299 /* blog_channel_NCDConfigTokenizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDConfigTokenizer.h; sourceTree = ""; }; - 19D0D3C92770982C0010B299 /* blog_channel_BDHCPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BDHCPClient.h; sourceTree = ""; }; - 19D0D3CA2770982C0010B299 /* blog_channel_ncd_spawn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_spawn.h; sourceTree = ""; }; - 19D0D3CB2770982C0010B299 /* blog_channel_NCDModuleIndex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDModuleIndex.h; sourceTree = ""; }; - 19D0D3CC2770982C0010B299 /* blog_channel_ncd_logical.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_logical.h; sourceTree = ""; }; - 19D0D3CD2770982C0010B299 /* bproto_msgproto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bproto_msgproto.h; sourceTree = ""; }; - 19D0D3CE2770982C0010B299 /* blog_channel_ncd_process_manager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_process_manager.h; sourceTree = ""; }; - 19D0D3CF2770982C0010B299 /* blog_channel_ncd_net_backend_wpa_supplicant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_backend_wpa_supplicant.h; sourceTree = ""; }; - 19D0D3D02770982C0010B299 /* blog_channel_BThreadWork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BThreadWork.h; sourceTree = ""; }; - 19D0D3D12770982C0010B299 /* blog_channel_ncd_try.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_try.h; sourceTree = ""; }; - 19D0D3D22770982C0010B299 /* blog_channel_BDatagram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BDatagram.h; sourceTree = ""; }; - 19D0D3D32770982C0010B299 /* blog_channel_ncd_sys_watch_input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_sys_watch_input.h; sourceTree = ""; }; - 19D0D3D42770982C0010B299 /* blog_channel_ncd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd.h; sourceTree = ""; }; - 19D0D3D52770982C0010B299 /* blog_channel_ncd_implode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_implode.h; sourceTree = ""; }; - 19D0D3D62770982C0010B299 /* blog_channel_NCDBuildProgram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDBuildProgram.h; sourceTree = ""; }; - 19D0D3D72770982C0010B299 /* blog_channel_ncd_file.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_file.h; sourceTree = ""; }; - 19D0D3D82770982C0010B299 /* blog_channel_ncd_strcmp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_strcmp.h; sourceTree = ""; }; - 19D0D3D92770982C0010B299 /* blog_channel_ncd_value.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_value.h; sourceTree = ""; }; - 19D0D3DA2770982C0010B299 /* blog_channel_NCDValParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDValParser.h; sourceTree = ""; }; - 19D0D3DB2770982C0010B299 /* blog_channel_BPredicate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BPredicate.h; sourceTree = ""; }; - 19D0D3DC2770982C0010B299 /* blog_channel_dostest_attacker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_dostest_attacker.h; sourceTree = ""; }; - 19D0D3DD2770982C0010B299 /* blog_channel_client.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_client.h; sourceTree = ""; }; - 19D0D3DE2770982C0010B299 /* blog_channel_ncd_daemon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_daemon.h; sourceTree = ""; }; - 19D0D3DF2770982C0010B299 /* blog_channel_NCDUdevManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDUdevManager.h; sourceTree = ""; }; - 19D0D3E02770982C0010B299 /* blog_channel_PRStreamSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_PRStreamSource.h; sourceTree = ""; }; - 19D0D3E12770982C0010B299 /* blog_channel_BSignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BSignal.h; sourceTree = ""; }; - 19D0D3E22770982C0010B299 /* blog_channel_ncd_foreach.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_foreach.h; sourceTree = ""; }; - 19D0D3E32770982C0010B299 /* blog_channel_ncd_netmask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_netmask.h; sourceTree = ""; }; - 19D0D3E42770982C0010B299 /* blog_channel_NCDVal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDVal.h; sourceTree = ""; }; - 19D0D3E52770982C0010B299 /* blog_channel_ncd_imperative.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_imperative.h; sourceTree = ""; }; - 19D0D3E62770982C0010B299 /* blog_channel_NCDUdevCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDUdevCache.h; sourceTree = ""; }; - 19D0D3E72770982C0010B299 /* blog_channel_ncd_index.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_index.h; sourceTree = ""; }; - 19D0D3E82770982C0010B299 /* blog_channel_ncd_if.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_if.h; sourceTree = ""; }; - 19D0D3E92770982C0010B299 /* blog_channel_NCDInterfaceMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDInterfaceMonitor.h; sourceTree = ""; }; - 19D0D3EA2770982C0010B299 /* blog_channel_PacketProtoDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_PacketProtoDecoder.h; sourceTree = ""; }; - 19D0D3EB2770982C0010B299 /* blog_channel_ncd_net_ipv4_addr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_ipv4_addr.h; sourceTree = ""; }; - 19D0D3EC2770982C0010B299 /* blog_channel_ncd_explode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_explode.h; sourceTree = ""; }; - 19D0D3ED2770982C0010B299 /* blog_channels_defines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channels_defines.h; sourceTree = ""; }; - 19D0D3EE2770982C0010B299 /* blog_channel_ncd_log_msg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_log_msg.h; sourceTree = ""; }; - 19D0D3EF2770982C0010B299 /* blog_channel_BArpProbe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BArpProbe.h; sourceTree = ""; }; - 19D0D3F02770982C0010B299 /* blog_channel_ncd_sleep.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_sleep.h; sourceTree = ""; }; - 19D0D3F12770982C0010B299 /* blog_channel_ncd_sys_start_process.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_sys_start_process.h; sourceTree = ""; }; - 19D0D3F22770982C0010B299 /* blog_channel_ncd_substr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_substr.h; sourceTree = ""; }; - 19D0D3F32770982C0010B299 /* blog_channel_ncd_log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_log.h; sourceTree = ""; }; - 19D0D3F42770982C0010B299 /* blog_channel_ncd_request.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_request.h; sourceTree = ""; }; - 19D0D3F52770982C0010B299 /* blog_channel_ncd_net_backend_rfkill.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_backend_rfkill.h; sourceTree = ""; }; - 19D0D3F62770982C0010B299 /* blog_channel_ncd_objref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_objref.h; sourceTree = ""; }; - 19D0D3F72770982C0010B299 /* blog_channel_ncd_net_watch_interfaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_watch_interfaces.h; sourceTree = ""; }; - 19D0D3F82770982C0010B299 /* blog_channel_ncd_from_string.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_from_string.h; sourceTree = ""; }; - 19D0D3F92770982C0010B299 /* blog_channel_BThreadSignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BThreadSignal.h; sourceTree = ""; }; - 19D0D3FA2770982C0010B299 /* blog_channel_BEncryption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BEncryption.h; sourceTree = ""; }; - 19D0D3FB2770982C0010B299 /* blog_channel_ncd_sys_watch_directory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_sys_watch_directory.h; sourceTree = ""; }; - 19D0D3FC2770982C0010B299 /* blog_channel_ncd_net_ipv4_dhcp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_ipv4_dhcp.h; sourceTree = ""; }; - 19D0D3FD2770982C0010B299 /* blog_channel_ncd_net_ipv6_route.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_ipv6_route.h; sourceTree = ""; }; - 19D0D3FE2770982C0010B299 /* blog_channel_ncd_arithmetic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_arithmetic.h; sourceTree = ""; }; - 19D0D3FF2770982C0010B299 /* blog_channel_ncd_alias.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_alias.h; sourceTree = ""; }; - 19D0D4002770982C0010B299 /* blog_channel_ncd_concat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_concat.h; sourceTree = ""; }; - 19D0D4012770982C0010B299 /* blog_channel_DataProto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_DataProto.h; sourceTree = ""; }; - 19D0D4022770982C0010B299 /* blog_channel_ncd_net_ipv4_arp_probe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_ipv4_arp_probe.h; sourceTree = ""; }; - 19D0D4032770982C0010B299 /* blog_channel_ncd_net_ipv6_addr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_ipv6_addr.h; sourceTree = ""; }; - 19D0D4042770982C0010B299 /* blog_channel_NCDIfConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDIfConfig.h; sourceTree = ""; }; - 19D0D4052770982C0010B299 /* blog_channel_Listener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_Listener.h; sourceTree = ""; }; - 19D0D4062770982C0010B299 /* blog_channel_tun2socks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_tun2socks.h; sourceTree = ""; }; - 19D0D4072770982C0010B299 /* blog_channel_ncd_call2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_call2.h; sourceTree = ""; }; - 19D0D4082770982C0010B299 /* blog_channel_ncd_buffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_buffer.h; sourceTree = ""; }; - 19D0D4092770982C0010B299 /* blog_channel_NCDModuleProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDModuleProcess.h; sourceTree = ""; }; - 19D0D40A2770982C0010B299 /* blog_channel_ncd_load_module.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_load_module.h; sourceTree = ""; }; - 19D0D40B2770982C0010B299 /* blog_channel_ncd_depend_scope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_depend_scope.h; sourceTree = ""; }; - 19D0D40C2770982C0010B299 /* blog_channel_ncd_var.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_var.h; sourceTree = ""; }; - 19D0D40D2770982C0010B299 /* blog_channel_NCDConfigParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDConfigParser.h; sourceTree = ""; }; - 19D0D40E2770982C0010B299 /* blog_channel_lwip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_lwip.h; sourceTree = ""; }; - 19D0D40F2770982C0010B299 /* blog_channel_NCDRequestClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDRequestClient.h; sourceTree = ""; }; - 19D0D4102770982C0010B299 /* blog_channel_DPRelay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_DPRelay.h; sourceTree = ""; }; - 19D0D4112770982C0010B299 /* blog_channel_BInputProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BInputProcess.h; sourceTree = ""; }; - 19D0D4122770982C0010B299 /* blog_channel_ncd_net_ipv4_addr_in_network.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_ipv4_addr_in_network.h; sourceTree = ""; }; - 19D0D4132770982C0010B299 /* blog_channel_ncd_sys_evdev.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_sys_evdev.h; sourceTree = ""; }; - 19D0D4142770982C0010B299 /* blog_channel_ncd_exit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_exit.h; sourceTree = ""; }; - 19D0D4152770982C0010B299 /* blog_channel_SPProtoDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_SPProtoDecoder.h; sourceTree = ""; }; - 19D0D4162770982C0010B299 /* blog_channel_addr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_addr.h; sourceTree = ""; }; - 19D0D4172770982C0010B299 /* blog_channel_ncd_backtrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_backtrack.h; sourceTree = ""; }; - 19D0D4182770982C0010B299 /* blog_channel_PasswordListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_PasswordListener.h; sourceTree = ""; }; - 19D0D4192770982C0010B299 /* blog_channel_ncd_to_string.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_to_string.h; sourceTree = ""; }; - 19D0D41A2770982C0010B299 /* blog_channel_ncd_net_backend_waitlink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_backend_waitlink.h; sourceTree = ""; }; - 19D0D41B2770982C0010B299 /* blog_channel_nsskey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_nsskey.h; sourceTree = ""; }; - 19D0D41C2770982C0010B299 /* blog_channel_DatagramPeerIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_DatagramPeerIO.h; sourceTree = ""; }; - 19D0D41D2770982C0010B299 /* blog_channel_ncd_regex_match.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_regex_match.h; sourceTree = ""; }; - 19D0D41E2770982C0010B299 /* blog_channel_DPReceive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_DPReceive.h; sourceTree = ""; }; - 19D0D41F2770982C0010B299 /* blog_channel_ncd_valuemetic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_valuemetic.h; sourceTree = ""; }; - 19D0D4202770982C0010B299 /* blog_channel_BTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BTime.h; sourceTree = ""; }; - 19D0D4212770982C0010B299 /* blog_channel_ncd_timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_timer.h; sourceTree = ""; }; - 19D0D4222770982C0010B299 /* bproto_bproto_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bproto_bproto_test.h; sourceTree = ""; }; - 19D0D4232770982C0010B299 /* blog_channel_ncd_multidepend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_multidepend.h; sourceTree = ""; }; - 19D0D4242770982C0010B299 /* blog_channel_server.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_server.h; sourceTree = ""; }; - 19D0D4252770982C0010B299 /* blog_channel_ncd_runonce.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_runonce.h; sourceTree = ""; }; - 19D0D4262770982C0010B299 /* blog_channel_dostest_server.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_dostest_server.h; sourceTree = ""; }; - 19D0D4272770982C0010B299 /* blog_channel_ncd_net_up.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_up.h; sourceTree = ""; }; - 19D0D4282770982C0010B299 /* blog_channel_BTap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BTap.h; sourceTree = ""; }; - 19D0D4292770982C0010B299 /* blog_channel_ncd_net_ipv6_addr_in_network.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_ipv6_addr_in_network.h; sourceTree = ""; }; - 19D0D42A2770982C0010B299 /* blog_channel_BProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BProcess.h; sourceTree = ""; }; - 19D0D42B2770982C0010B299 /* blog_channel_StreamPeerIO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_StreamPeerIO.h; sourceTree = ""; }; - 19D0D42C2770982C0010B299 /* blog_channel_NCDRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDRequest.h; sourceTree = ""; }; - 19D0D42D2770982C0010B299 /* blog_channel_NCDRfkillMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDRfkillMonitor.h; sourceTree = ""; }; - 19D0D42E2770982C0010B299 /* blog_channel_NCDUdevMonitorParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDUdevMonitorParser.h; sourceTree = ""; }; - 19D0D42F2770982C0010B299 /* blog_channel_ServerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ServerConnection.h; sourceTree = ""; }; - 19D0D4302770982C0010B299 /* blog_channel_ncd_getargs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_getargs.h; sourceTree = ""; }; - 19D0D4312770982C0010B299 /* blog_channel_BDHCPClientCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BDHCPClientCore.h; sourceTree = ""; }; - 19D0D4322770982C0010B299 /* blog_channel_PRStreamSink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_PRStreamSink.h; sourceTree = ""; }; - 19D0D4332770982C0010B299 /* blog_channel_ncd_getenv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_getenv.h; sourceTree = ""; }; - 19D0D4342770982C0010B299 /* bproto_addr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bproto_addr.h; sourceTree = ""; }; - 19D0D4352770982C0010B299 /* blog_channel_ncd_blocker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_blocker.h; sourceTree = ""; }; - 19D0D4362770982C0010B299 /* blog_channel_ncd_reboot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_reboot.h; sourceTree = ""; }; - 19D0D4372770982C0010B299 /* blog_channel_ncd_choose.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_choose.h; sourceTree = ""; }; - 19D0D4382770982C0010B299 /* blog_channel_LineBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_LineBuffer.h; sourceTree = ""; }; - 19D0D4392770982C0010B299 /* blog_channel_FragmentProtoAssembler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_FragmentProtoAssembler.h; sourceTree = ""; }; - 19D0D43A2770982C0010B299 /* blog_channel_ncd_socket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_socket.h; sourceTree = ""; }; - 19D0D43B2770982C0010B299 /* blog_channel_UdpGwClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_UdpGwClient.h; sourceTree = ""; }; - 19D0D43C2770982C0010B299 /* blog_channel_flooder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_flooder.h; sourceTree = ""; }; - 19D0D43D2770982C0010B299 /* blog_channel_ncd_assert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_assert.h; sourceTree = ""; }; - 19D0D43E2770982C0010B299 /* blog_channel_ncd_net_backend_waitdevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_backend_waitdevice.h; sourceTree = ""; }; - 19D0D43F2770982C0010B299 /* blog_channel_ncd_basic_functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_basic_functions.h; sourceTree = ""; }; - 19D0D4402770982C0010B299 /* blog_channel_NCDPlaceholderDb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDPlaceholderDb.h; sourceTree = ""; }; - 19D0D4412770982C0010B299 /* blog_channel_ncd_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_list.h; sourceTree = ""; }; - 19D0D4422770982C0010B299 /* blog_channel_PeerChat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_PeerChat.h; sourceTree = ""; }; - 19D0D4432770982C0010B299 /* blog_channel_ncd_net_backend_badvpn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_backend_badvpn.h; sourceTree = ""; }; - 19D0D4442770982C0010B299 /* blog_channel_ncd_print.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_print.h; sourceTree = ""; }; - 19D0D4452770982C0010B299 /* blog_channel_BNetwork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BNetwork.h; sourceTree = ""; }; - 19D0D4462770982C0010B299 /* blog_channel_BLockReactor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BLockReactor.h; sourceTree = ""; }; - 19D0D4472770982C0010B299 /* blog_channel_ncd_ondemand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_ondemand.h; sourceTree = ""; }; - 19D0D4482770982C0010B299 /* blog_channel_ncd_net_iptables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_iptables.h; sourceTree = ""; }; - 19D0D4492770982C0010B299 /* blog_channel_ncd_depend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_depend.h; sourceTree = ""; }; - 19D0D44A2770982C0010B299 /* blog_channel_ncd_sys_request_client.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_sys_request_client.h; sourceTree = ""; }; - 19D0D44B2770982C0010B299 /* blog_channel_ncd_net_dns.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_ncd_net_dns.h; sourceTree = ""; }; - 19D0D44C2770982C0010B299 /* blog_channel_NCDUdevMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_NCDUdevMonitor.h; sourceTree = ""; }; - 19D0D44D2770982C0010B299 /* blog_channel_BSocksClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blog_channel_BSocksClient.h; sourceTree = ""; }; - 19D0D44F2770982C0010B299 /* BSocksClient.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BSocksClient.c; sourceTree = ""; }; - 19D0D4502770982C0010B299 /* BSocksClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSocksClient.h; sourceTree = ""; }; - 19D0D4522770982C0010B299 /* packed.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = packed.h; sourceTree = ""; }; - 19D0D4532770982C0010B299 /* concat_strings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = concat_strings.h; sourceTree = ""; }; - 19D0D4542770982C0010B299 /* Utf8Decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utf8Decoder.h; sourceTree = ""; }; - 19D0D4552770982C0010B299 /* parse_number.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parse_number.h; sourceTree = ""; }; - 19D0D4562770982C0010B299 /* udp_proto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = udp_proto.h; sourceTree = ""; }; - 19D0D4572770982C0010B299 /* find_program.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = find_program.h; sourceTree = ""; }; - 19D0D4582770982C0010B299 /* minmax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = minmax.h; sourceTree = ""; }; - 19D0D4592770982C0010B299 /* socks_proto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = socks_proto.h; sourceTree = ""; }; - 19D0D45A2770982C0010B299 /* string_begins_with.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string_begins_with.h; sourceTree = ""; }; - 19D0D45B2770982C0010B299 /* dead.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dead.h; sourceTree = ""; }; - 19D0D45C2770982C0010B299 /* strdup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strdup.h; sourceTree = ""; }; - 19D0D45D2770982C0010B299 /* debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = debug.h; sourceTree = ""; }; - 19D0D45E2770982C0010B299 /* array_length.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = array_length.h; sourceTree = ""; }; - 19D0D45F2770982C0010B299 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = ""; }; - 19D0D4602770982C0010B299 /* bsort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bsort.h; sourceTree = ""; }; - 19D0D4612770982C0010B299 /* debugcounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = debugcounter.h; sourceTree = ""; }; - 19D0D4622770982C0010B299 /* byteorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = byteorder.h; sourceTree = ""; }; - 19D0D4632770982C0010B299 /* unicode_funcs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unicode_funcs.h; sourceTree = ""; }; - 19D0D4642770982C0010B299 /* Utf16Decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utf16Decoder.h; sourceTree = ""; }; - 19D0D4652770982C0010B299 /* bstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bstring.h; sourceTree = ""; }; - 19D0D4662770982C0010B299 /* maxalign.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = maxalign.h; sourceTree = ""; }; - 19D0D4672770982C0010B299 /* offset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = offset.h; sourceTree = ""; }; - 19D0D4682770982C0010B299 /* cmdline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cmdline.h; sourceTree = ""; }; - 19D0D4692770982C0010B299 /* expstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = expstring.h; sourceTree = ""; }; - 19D0D46A2770982C0010B299 /* merge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = merge.h; sourceTree = ""; }; - 19D0D46B2770982C0010B299 /* ipaddr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ipaddr.h; sourceTree = ""; }; - 19D0D46C2770982D0010B299 /* write_file.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = write_file.h; sourceTree = ""; }; - 19D0D46D2770982D0010B299 /* print_macros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = print_macros.h; sourceTree = ""; }; - 19D0D46E2770982D0010B299 /* substring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = substring.h; sourceTree = ""; }; - 19D0D46F2770982D0010B299 /* balign.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = balign.h; sourceTree = ""; }; - 19D0D4702770982D0010B299 /* debugerror.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = debugerror.h; sourceTree = ""; }; - 19D0D4712770982D0010B299 /* memref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memref.h; sourceTree = ""; }; - 19D0D4722770982D0010B299 /* hashfun.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hashfun.h; sourceTree = ""; }; - 19D0D4732770982D0010B299 /* igmp_proto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = igmp_proto.h; sourceTree = ""; }; - 19D0D4742770982D0010B299 /* mswsock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mswsock.h; sourceTree = ""; }; - 19D0D4752770982D0010B299 /* get_iface_info.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = get_iface_info.h; sourceTree = ""; }; - 19D0D4762770982D0010B299 /* sslsocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sslsocket.h; sourceTree = ""; }; - 19D0D4772770982D0010B299 /* blimits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blimits.h; sourceTree = ""; }; - 19D0D4782770982D0010B299 /* balloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = balloc.h; sourceTree = ""; }; - 19D0D4792770982D0010B299 /* ipaddr6.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ipaddr6.h; sourceTree = ""; }; - 19D0D47A2770982D0010B299 /* compare.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = compare.h; sourceTree = ""; }; - 19D0D47B2770982D0010B299 /* nonblocking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nonblocking.h; sourceTree = ""; }; - 19D0D47C2770982D0010B299 /* loglevel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = loglevel.h; sourceTree = ""; }; - 19D0D47D2770982D0010B299 /* modadd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = modadd.h; sourceTree = ""; }; - 19D0D47E2770982D0010B299 /* nsskey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nsskey.h; sourceTree = ""; }; - 19D0D47F2770982D0010B299 /* ethernet_proto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ethernet_proto.h; sourceTree = ""; }; - 19D0D4802770982D0010B299 /* find_char.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = find_char.h; sourceTree = ""; }; - 19D0D4812770982D0010B299 /* read_write_int.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = read_write_int.h; sourceTree = ""; }; - 19D0D4822770982D0010B299 /* ipv6_proto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ipv6_proto.h; sourceTree = ""; }; - 19D0D4832770982D0010B299 /* loggers_string.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = loggers_string.h; sourceTree = ""; }; - 19D0D4842770982D0010B299 /* overflow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = overflow.h; sourceTree = ""; }; - 19D0D4852770982D0010B299 /* open_standard_streams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = open_standard_streams.h; sourceTree = ""; }; - 19D0D4862770982D0010B299 /* Utf16Encoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utf16Encoder.h; sourceTree = ""; }; - 19D0D4872770982D0010B299 /* read_file.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = read_file.h; sourceTree = ""; }; - 19D0D4882770982D0010B299 /* dhcp_proto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dhcp_proto.h; sourceTree = ""; }; - 19D0D4892770982D0010B299 /* exparray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = exparray.h; sourceTree = ""; }; - 19D0D48A2770982D0010B299 /* BRefTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRefTarget.h; sourceTree = ""; }; - 19D0D48B2770982D0010B299 /* ipv4_proto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ipv4_proto.h; sourceTree = ""; }; - 19D0D48C2770982D0010B299 /* grow_array.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = grow_array.h; sourceTree = ""; }; - 19D0D48D2770982D0010B299 /* stdbuf_cmdline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stdbuf_cmdline.h; sourceTree = ""; }; - 19D0D48E2770982D0010B299 /* arp_proto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = arp_proto.h; sourceTree = ""; }; - 19D0D48F2770982D0010B299 /* ascii_utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ascii_utils.h; sourceTree = ""; }; - 19D0D4902770982D0010B299 /* bsize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bsize.h; sourceTree = ""; }; - 19D0D4912770982D0010B299 /* Utf8Encoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utf8Encoder.h; sourceTree = ""; }; - 19D0D4942770982D0010B299 /* sys.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sys.c; sourceTree = ""; }; - 19D0D4962770982D0010B299 /* cc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cc.h; sourceTree = ""; }; - 19D0D4972770982D0010B299 /* perf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = perf.h; sourceTree = ""; }; - 19D0D4982770982D0010B299 /* lwipopts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lwipopts.h; sourceTree = ""; }; - 19D0D49B2770982D0010B299 /* memp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = memp.c; sourceTree = ""; }; - 19D0D49C2770982D0010B299 /* inet_chksum.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = inet_chksum.c; sourceTree = ""; }; - 19D0D49D2770982D0010B299 /* tcp_out.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tcp_out.c; sourceTree = ""; }; - 19D0D49E2770982D0010B299 /* init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = init.c; sourceTree = ""; }; - 19D0D49F2770982D0010B299 /* mem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mem.c; sourceTree = ""; }; - 19D0D4A02770982D0010B299 /* def.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = def.c; sourceTree = ""; }; - 19D0D4A12770982D0010B299 /* udp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = udp.c; sourceTree = ""; }; - 19D0D4A22770982D0010B299 /* stats.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stats.c; sourceTree = ""; }; - 19D0D4A32770982D0010B299 /* tcp_in.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tcp_in.c; sourceTree = ""; }; - 19D0D4A52770982D0010B299 /* ip_frag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ip_frag.c; sourceTree = ""; }; - 19D0D4A62770982D0010B299 /* icmp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = icmp.c; sourceTree = ""; }; - 19D0D4A72770982D0010B299 /* ip4.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ip4.c; sourceTree = ""; }; - 19D0D4A82770982D0010B299 /* ip4_addr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ip4_addr.c; sourceTree = ""; }; - 19D0D4A92770982D0010B299 /* netif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = netif.c; sourceTree = ""; }; - 19D0D4AA2770982D0010B299 /* tcp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tcp.c; sourceTree = ""; }; - 19D0D4AB2770982D0010B299 /* timers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = timers.c; sourceTree = ""; }; - 19D0D4AC2770982D0010B299 /* pbuf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pbuf.c; sourceTree = ""; }; - 19D0D4AE2770982D0010B299 /* ip6.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ip6.c; sourceTree = ""; }; - 19D0D4AF2770982D0010B299 /* icmp6.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = icmp6.c; sourceTree = ""; }; - 19D0D4B02770982D0010B299 /* nd6.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nd6.c; sourceTree = ""; }; - 19D0D4B12770982D0010B299 /* ip6_addr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ip6_addr.c; sourceTree = ""; }; - 19D0D4B22770982D0010B299 /* ip6_frag.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ip6_frag.c; sourceTree = ""; }; - 19D0D4B62770982D0010B299 /* socket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = socket.h; sourceTree = ""; }; - 19D0D4B72770982D0010B299 /* netdb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = netdb.h; sourceTree = ""; }; - 19D0D4B92770982D0010B299 /* timers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = timers.h; sourceTree = ""; }; - 19D0D4BA2770982D0010B299 /* pbuf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pbuf.h; sourceTree = ""; }; - 19D0D4BB2770982D0010B299 /* tcp_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tcp_impl.h; sourceTree = ""; }; - 19D0D4BC2770982D0010B299 /* tcp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tcp.h; sourceTree = ""; }; - 19D0D4BD2770982D0010B299 /* err.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = err.h; sourceTree = ""; }; - 19D0D4BE2770982D0010B299 /* snmp_asn1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = snmp_asn1.h; sourceTree = ""; }; - 19D0D4BF2770982D0010B299 /* netif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = netif.h; sourceTree = ""; }; - 19D0D4C02770982D0010B299 /* sio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sio.h; sourceTree = ""; }; - 19D0D4C12770982D0010B299 /* debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = debug.h; sourceTree = ""; }; - 19D0D4C22770982D0010B299 /* tcpip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tcpip.h; sourceTree = ""; }; - 19D0D4C32770982D0010B299 /* snmp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = snmp.h; sourceTree = ""; }; - 19D0D4C42770982D0010B299 /* snmp_structs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = snmp_structs.h; sourceTree = ""; }; - 19D0D4C52770982D0010B299 /* api_msg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = api_msg.h; sourceTree = ""; }; - 19D0D4C62770982D0010B299 /* netifapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = netifapi.h; sourceTree = ""; }; - 19D0D4C72770982D0010B299 /* netbuf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = netbuf.h; sourceTree = ""; }; - 19D0D4C82770982D0010B299 /* api.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = api.h; sourceTree = ""; }; - 19D0D4C92770982D0010B299 /* dhcp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dhcp.h; sourceTree = ""; }; - 19D0D4CA2770982D0010B299 /* memp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memp.h; sourceTree = ""; }; - 19D0D4CB2770982D0010B299 /* sockets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sockets.h; sourceTree = ""; }; - 19D0D4CC2770982D0010B299 /* ip_addr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ip_addr.h; sourceTree = ""; }; - 19D0D4CD2770982D0010B299 /* opt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = opt.h; sourceTree = ""; }; - 19D0D4CE2770982D0010B299 /* inet_chksum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inet_chksum.h; sourceTree = ""; }; - 19D0D4CF2770982D0010B299 /* raw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = raw.h; sourceTree = ""; }; - 19D0D4D02770982D0010B299 /* sys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sys.h; sourceTree = ""; }; - 19D0D4D12770982D0010B299 /* netdb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = netdb.h; sourceTree = ""; }; - 19D0D4D22770982D0010B299 /* def.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = def.h; sourceTree = ""; }; - 19D0D4D32770982D0010B299 /* mem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mem.h; sourceTree = ""; }; - 19D0D4D42770982D0010B299 /* dns.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dns.h; sourceTree = ""; }; - 19D0D4D52770982D0010B299 /* ip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ip.h; sourceTree = ""; }; - 19D0D4D62770982D0010B299 /* init.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = init.h; sourceTree = ""; }; - 19D0D4D72770982D0010B299 /* snmp_msg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = snmp_msg.h; sourceTree = ""; }; - 19D0D4D82770982D0010B299 /* stats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stats.h; sourceTree = ""; }; - 19D0D4D92770982D0010B299 /* memp_std.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memp_std.h; sourceTree = ""; }; - 19D0D4DA2770982D0010B299 /* udp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = udp.h; sourceTree = ""; }; - 19D0D4DB2770982D0010B299 /* arch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = arch.h; sourceTree = ""; }; - 19D0D4DD2770982D0010B299 /* etharp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = etharp.h; sourceTree = ""; }; - 19D0D4DE2770982D0010B299 /* ppp_oe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ppp_oe.h; sourceTree = ""; }; - 19D0D4DF2770982D0010B299 /* slipif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = slipif.h; sourceTree = ""; }; - 19D0D4E22770982D0010B299 /* igmp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = igmp.h; sourceTree = ""; }; - 19D0D4E32770982D0010B299 /* ip4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ip4.h; sourceTree = ""; }; - 19D0D4E42770982D0010B299 /* icmp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = icmp.h; sourceTree = ""; }; - 19D0D4E52770982D0010B299 /* inet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inet.h; sourceTree = ""; }; - 19D0D4E62770982D0010B299 /* ip4_addr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ip4_addr.h; sourceTree = ""; }; - 19D0D4E72770982D0010B299 /* autoip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = autoip.h; sourceTree = ""; }; - 19D0D4E82770982D0010B299 /* ip_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ip_frag.h; sourceTree = ""; }; - 19D0D4EB2770982D0010B299 /* nd6.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nd6.h; sourceTree = ""; }; - 19D0D4EC2770982D0010B299 /* ethip6.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ethip6.h; sourceTree = ""; }; - 19D0D4ED2770982D0010B299 /* inet6.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inet6.h; sourceTree = ""; }; - 19D0D4EE2770982D0010B299 /* ip6_addr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ip6_addr.h; sourceTree = ""; }; - 19D0D4EF2770982D0010B299 /* ip6_frag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ip6_frag.h; sourceTree = ""; }; - 19D0D4F02770982D0010B299 /* ip6.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ip6.h; sourceTree = ""; }; - 19D0D4F12770982D0010B299 /* icmp6.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = icmp6.h; sourceTree = ""; }; - 19D0D4F22770982D0010B299 /* dhcp6.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dhcp6.h; sourceTree = ""; }; - 19D0D4F32770982D0010B299 /* mld6.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mld6.h; sourceTree = ""; }; - 19D0D4F52770982D0010B299 /* BTap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BTap.m; sourceTree = ""; }; - 19D0D4F62770982D0010B299 /* BTap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BTap.h; sourceTree = ""; }; - 19D0D4F82770982D0010B299 /* udpgw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = udpgw.h; sourceTree = ""; }; - 19D0D4F92770982D0010B299 /* udpgw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = udpgw.c; sourceTree = ""; }; - 19D0D4FB2770982D0010B299 /* udpgw_proto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = udpgw_proto.h; sourceTree = ""; }; - 19D0D4FC2770982D0010B299 /* requestproto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = requestproto.h; sourceTree = ""; }; - 19D0D4FD2770982D0010B299 /* msgproto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = msgproto.h; sourceTree = ""; }; - 19D0D4FE2770982D0010B299 /* spproto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spproto.h; sourceTree = ""; }; - 19D0D4FF2770982D0010B299 /* packetproto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = packetproto.h; sourceTree = ""; }; - 19D0D5002770982D0010B299 /* dataproto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dataproto.h; sourceTree = ""; }; - 19D0D5012770982D0010B299 /* addr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = addr.h; sourceTree = ""; }; - 19D0D5022770982D0010B299 /* scproto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = scproto.h; sourceTree = ""; }; - 19D0D5032770982D0010B299 /* addr.bproto */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = addr.bproto; sourceTree = ""; }; - 19D0D5042770982D0010B299 /* fragmentproto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fragmentproto.h; sourceTree = ""; }; - 19D0D5052770982D0010B299 /* msgproto.bproto */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = msgproto.bproto; sourceTree = ""; }; - 19D0D5072770982D0010B299 /* BDatagram_unix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDatagram_unix.h; sourceTree = ""; }; - 19D0D5082770982D0010B299 /* BUnixSignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUnixSignal.h; sourceTree = ""; }; - 19D0D5092770982D0010B299 /* BNetwork.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BNetwork.c; sourceTree = ""; }; - 19D0D50A2770982D0010B299 /* BConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BConnection.h; sourceTree = ""; }; - 19D0D50B2770982D0010B299 /* BConnection_common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BConnection_common.c; sourceTree = ""; }; - 19D0D50C2770982D0010B299 /* BReactor_badvpn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BReactor_badvpn.h; sourceTree = ""; }; - 19D0D50D2770982D0010B299 /* BAddr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BAddr.h; sourceTree = ""; }; - 19D0D50E2770982D0010B299 /* BReactor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BReactor.h; sourceTree = ""; }; - 19D0D50F2770982D0010B299 /* BConnection_unix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BConnection_unix.h; sourceTree = ""; }; - 19D0D5102770982D0010B299 /* BTime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BTime.c; sourceTree = ""; }; - 19D0D5112770982D0010B299 /* BSignal.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BSignal.c; sourceTree = ""; }; - 19D0D5122770982D0010B299 /* BReactor_badvpn_timerstree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BReactor_badvpn_timerstree.h; sourceTree = ""; }; - 19D0D5132770982D0010B299 /* BDatagram_unix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BDatagram_unix.c; sourceTree = ""; }; - 19D0D5142770982D0010B299 /* BNetwork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BNetwork.h; sourceTree = ""; }; - 19D0D5152770982D0010B299 /* BUnixSignal.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BUnixSignal.c; sourceTree = ""; }; - 19D0D5162770982D0010B299 /* BDatagram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDatagram.h; sourceTree = ""; }; - 19D0D5172770982D0010B299 /* BReactor_badvpn.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BReactor_badvpn.c; sourceTree = ""; }; - 19D0D5182770982D0010B299 /* BSignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSignal.h; sourceTree = ""; }; - 19D0D5192770982D0010B299 /* BTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BTime.h; sourceTree = ""; }; - 19D0D51A2770982D0010B299 /* BConnection_unix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BConnection_unix.c; sourceTree = ""; }; - 19D0D51C2770982D0010B299 /* tun2socks.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tun2socks.c; sourceTree = ""; }; - 19D0D51D2770982D0010B299 /* SocksUdpGwClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocksUdpGwClient.h; sourceTree = ""; }; - 19D0D51E2770982D0010B299 /* tun2socks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tun2socks.h; sourceTree = ""; }; - 19D0D51F2770982D0010B299 /* SocksUdpGwClient.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SocksUdpGwClient.c; sourceTree = ""; }; - 19D0D5212770982D0010B299 /* SAvl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAvl.h; sourceTree = ""; }; - 19D0D5222770982D0010B299 /* Vector_footer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vector_footer.h; sourceTree = ""; }; - 19D0D5232770982D0010B299 /* ChunkBuffer2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChunkBuffer2.h; sourceTree = ""; }; - 19D0D5242770982D0010B299 /* IndexedList_tree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexedList_tree.h; sourceTree = ""; }; - 19D0D5252770982D0010B299 /* LinkedList1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkedList1.h; sourceTree = ""; }; - 19D0D5262770982D0010B299 /* Vector_header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vector_header.h; sourceTree = ""; }; - 19D0D5272770982D0010B299 /* CAvl_header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAvl_header.h; sourceTree = ""; }; - 19D0D5282770982D0010B299 /* Vector_decl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vector_decl.h; sourceTree = ""; }; - 19D0D5292770982D0010B299 /* CHash_decl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHash_decl.h; sourceTree = ""; }; - 19D0D52A2770982D0010B299 /* CAvl_footer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAvl_footer.h; sourceTree = ""; }; - 19D0D52B2770982D0010B299 /* SLinkedList_decl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLinkedList_decl.h; sourceTree = ""; }; - 19D0D52C2770982D0010B299 /* CAvl_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAvl_impl.h; sourceTree = ""; }; - 19D0D52D2770982D0010B299 /* SAvl_decl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAvl_decl.h; sourceTree = ""; }; - 19D0D52E2770982D0010B299 /* CHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHash.h; sourceTree = ""; }; - 19D0D52F2770982D0010B299 /* SAvl_footer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAvl_footer.h; sourceTree = ""; }; - 19D0D5302770982D0010B299 /* SAvl_tree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAvl_tree.h; sourceTree = ""; }; - 19D0D5312770982D0010B299 /* IndexedList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexedList.h; sourceTree = ""; }; - 19D0D5322770982D0010B299 /* SAvl_header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAvl_header.h; sourceTree = ""; }; - 19D0D5332770982D0010B299 /* LinkedList3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkedList3.h; sourceTree = ""; }; - 19D0D5342770982D0010B299 /* BAVL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BAVL.h; sourceTree = ""; }; - 19D0D5352770982D0010B299 /* SLinkedList_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLinkedList_impl.h; sourceTree = ""; }; - 19D0D5362770982D0010B299 /* CAvl_decl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAvl_decl.h; sourceTree = ""; }; - 19D0D5372770982D0010B299 /* CAvl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CAvl.h; sourceTree = ""; }; - 19D0D5382770982D0010B299 /* Vector_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vector_impl.h; sourceTree = ""; }; - 19D0D5392770982D0010B299 /* SLinkedList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLinkedList.h; sourceTree = ""; }; - 19D0D53A2770982D0010B299 /* CHash_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHash_impl.h; sourceTree = ""; }; - 19D0D53B2770982D0010B299 /* CHash_footer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHash_footer.h; sourceTree = ""; }; - 19D0D53C2770982D0010B299 /* LinkedList0.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkedList0.h; sourceTree = ""; }; - 19D0D53D2770982D0010B299 /* CHash_header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHash_header.h; sourceTree = ""; }; - 19D0D53E2770982D0010B299 /* SAvl_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SAvl_impl.h; sourceTree = ""; }; - 19D0D53F2770982D0010B299 /* Vector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vector.h; sourceTree = ""; }; - 19D0D5402770982D0010B299 /* SLinkedList_footer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLinkedList_footer.h; sourceTree = ""; }; - 19D0D5412770982D0010B299 /* SLinkedList_header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLinkedList_header.h; sourceTree = ""; }; - 19D0D5432770982D0010B299 /* PacketPassInactivityMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketPassInactivityMonitor.h; sourceTree = ""; }; - 19D0D5442770982D0010B299 /* PacketPassInactivityMonitor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = PacketPassInactivityMonitor.c; sourceTree = ""; }; - 19D0D5462770982D0010B299 /* BLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BLog.m; sourceTree = ""; }; - 19D0D5472770982E0010B299 /* BLog_syslog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BLog_syslog.c; sourceTree = ""; }; - 19D0D5482770982E0010B299 /* BPending_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BPending_list.h; sourceTree = ""; }; - 19D0D5492770982E0010B299 /* DebugObject.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = DebugObject.c; sourceTree = ""; }; - 19D0D54A2770982E0010B299 /* BPending.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BPending.h; sourceTree = ""; }; - 19D0D54B2770982E0010B299 /* BLog_syslog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BLog_syslog.h; sourceTree = ""; }; - 19D0D54C2770982E0010B299 /* BLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BLog.h; sourceTree = ""; }; - 19D0D54D2770982E0010B299 /* BMutex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BMutex.h; sourceTree = ""; }; - 19D0D54E2770982E0010B299 /* BPending.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BPending.c; sourceTree = ""; }; - 19D0D54F2770982E0010B299 /* DebugObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DebugObject.h; sourceTree = ""; }; - 19D0D5512770982E0010B299 /* UdpGwClient.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = UdpGwClient.c; sourceTree = ""; }; - 19D0D5522770982E0010B299 /* UdpGwClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UdpGwClient.h; sourceTree = ""; }; - 19D0D5542770982E0010B299 /* PacketBuffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = PacketBuffer.c; sourceTree = ""; }; - 19D0D5552770982E0010B299 /* PacketStreamSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketStreamSender.h; sourceTree = ""; }; - 19D0D5562770982E0010B299 /* BufferWriter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BufferWriter.c; sourceTree = ""; }; - 19D0D5572770982E0010B299 /* PacketRecvInterface.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = PacketRecvInterface.c; sourceTree = ""; }; - 19D0D5582770982E0010B299 /* PacketPassFairQueue_tree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketPassFairQueue_tree.h; sourceTree = ""; }; - 19D0D5592770982E0010B299 /* SinglePacketBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SinglePacketBuffer.h; sourceTree = ""; }; - 19D0D55A2770982E0010B299 /* PacketProtoDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketProtoDecoder.h; sourceTree = ""; }; - 19D0D55B2770982E0010B299 /* StreamRecvInterface.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = StreamRecvInterface.c; sourceTree = ""; }; - 19D0D55C2770982E0010B299 /* PacketProtoEncoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = PacketProtoEncoder.c; sourceTree = ""; }; - 19D0D55D2770982E0010B299 /* StreamPassInterface.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = StreamPassInterface.c; sourceTree = ""; }; - 19D0D55E2770982E0010B299 /* PacketPassConnector.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = PacketPassConnector.c; sourceTree = ""; }; - 19D0D55F2770982E0010B299 /* PacketPassFairQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketPassFairQueue.h; sourceTree = ""; }; - 19D0D5602770982E0010B299 /* PacketProtoFlow.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = PacketProtoFlow.c; sourceTree = ""; }; - 19D0D5612770982E0010B299 /* PacketPassInterface.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = PacketPassInterface.c; sourceTree = ""; }; - 19D0D5622770982E0010B299 /* BufferWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BufferWriter.h; sourceTree = ""; }; - 19D0D5632770982E0010B299 /* PacketRecvInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketRecvInterface.h; sourceTree = ""; }; - 19D0D5642770982E0010B299 /* PacketBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketBuffer.h; sourceTree = ""; }; - 19D0D5652770982E0010B299 /* PacketStreamSender.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = PacketStreamSender.c; sourceTree = ""; }; - 19D0D5662770982E0010B299 /* StreamRecvInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamRecvInterface.h; sourceTree = ""; }; - 19D0D5672770982E0010B299 /* PacketProtoDecoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = PacketProtoDecoder.c; sourceTree = ""; }; - 19D0D5682770982E0010B299 /* SinglePacketBuffer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SinglePacketBuffer.c; sourceTree = ""; }; - 19D0D5692770982E0010B299 /* PacketPassFairQueue.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = PacketPassFairQueue.c; sourceTree = ""; }; - 19D0D56A2770982E0010B299 /* PacketPassConnector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketPassConnector.h; sourceTree = ""; }; - 19D0D56B2770982E0010B299 /* StreamPassInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamPassInterface.h; sourceTree = ""; }; - 19D0D56C2770982E0010B299 /* PacketProtoEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketProtoEncoder.h; sourceTree = ""; }; - 19D0D56D2770982E0010B299 /* PacketPassInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketPassInterface.h; sourceTree = ""; }; - 19D0D56E2770982E0010B299 /* PacketProtoFlow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PacketProtoFlow.h; sourceTree = ""; }; - 19D0D56F2770982E0010B299 /* TunnelInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TunnelInterface.h; sourceTree = ""; }; - 19D0D5702770982E0010B299 /* TunnelInterface.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TunnelInterface.m; sourceTree = ""; }; - 19D0D7162770998F0010B299 /* CocoaAsyncSocket.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CocoaAsyncSocket.framework; path = PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework; sourceTree = ""; }; - 19D0D71A27709B4F0010B299 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; - 19D0D71B2770A3AD0010B299 /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/usr/lib/libresolv.tbd; sourceTree = DEVELOPER_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 19D0CCE6277092B50010B299 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 19D0D71C2770A3AD0010B299 /* libresolv.tbd in Frameworks */, - 19D0D718277099960010B299 /* CocoaAsyncSocket.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 19D0CCDF277092B50010B299 = { - isa = PBXGroup; - children = ( - 19D0CCEB277092B50010B299 /* PacketProcessor */, - 19D0CCEA277092B50010B299 /* Products */, - 19D0CCF4277096720010B299 /* Frameworks */, - ); - sourceTree = ""; - }; - 19D0CCEA277092B50010B299 /* Products */ = { - isa = PBXGroup; - children = ( - 19D0CCE9277092B50010B299 /* PacketProcessor.framework */, - ); - name = Products; - sourceTree = ""; - }; - 19D0CCEB277092B50010B299 /* PacketProcessor */ = { - isa = PBXGroup; - children = ( - 19D0D3B42770982C0010B299 /* tun2socks-iOS */, - 19D0D56F2770982E0010B299 /* TunnelInterface.h */, - 19D0D5702770982E0010B299 /* TunnelInterface.m */, - 19D0CCEC277092B50010B299 /* PacketProcessor.h */, - 19D0D71A27709B4F0010B299 /* Info.plist */, - ); - path = PacketProcessor; - sourceTree = ""; - }; - 19D0CCF4277096720010B299 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 19D0D71B2770A3AD0010B299 /* libresolv.tbd */, - 19D0D7162770998F0010B299 /* CocoaAsyncSocket.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - 19D0D3B42770982C0010B299 /* tun2socks-iOS */ = { - isa = PBXGroup; - children = ( - 19D0D3B52770982C0010B299 /* generated */, - 19D0D44E2770982C0010B299 /* socksclient */, - 19D0D4512770982C0010B299 /* misc */, - 19D0D4922770982D0010B299 /* lwip */, - 19D0D4F42770982D0010B299 /* tuntap */, - 19D0D4F72770982D0010B299 /* udpgw */, - 19D0D4FA2770982D0010B299 /* protocol */, - 19D0D5062770982D0010B299 /* system */, - 19D0D51B2770982D0010B299 /* tun2socks */, - 19D0D5202770982D0010B299 /* structure */, - 19D0D5422770982D0010B299 /* flowextra */, - 19D0D5452770982D0010B299 /* base */, - 19D0D5502770982E0010B299 /* udpgw_client */, - 19D0D5532770982E0010B299 /* flow */, - ); - path = "tun2socks-iOS"; - sourceTree = ""; - }; - 19D0D3B52770982C0010B299 /* generated */ = { - isa = PBXGroup; - children = ( - 19D0D3B62770982C0010B299 /* blog_channel_SocksUdpGwClient.h */, - 19D0D3B72770982C0010B299 /* blog_channel_ncd_file_open.h */, - 19D0D3B82770982C0010B299 /* blog_channel_BReactor.h */, - 19D0D3B92770982C0010B299 /* blog_channel_BSSLConnection.h */, - 19D0D3BA2770982C0010B299 /* blog_channel_BConnection.h */, - 19D0D3BB2770982C0010B299 /* blog_channel_ncd_net_ipv4_route.h */, - 19D0D3BC2770982C0010B299 /* blog_channel_ncd_sys_request_server.h */, - 19D0D3BD2770982C0010B299 /* blog_channel_ncd_sys_watch_usb.h */, - 19D0D3BE2770982C0010B299 /* blog_channel_ncd_run.h */, - 19D0D3BF2770982C0010B299 /* blog_channels_list.h */, - 19D0D3C02770982C0010B299 /* blog_channel_NCDValGenerator.h */, - 19D0D3C12770982C0010B299 /* blog_channel_FrameDecider.h */, - 19D0D3C22770982C0010B299 /* blog_channel_ncd_dynamic_depend.h */, - 19D0D3C32770982C0010B299 /* blog_channel_ncd_net_ipv6_wait_dynamic_addr.h */, - 19D0D3C42770982C0010B299 /* blog_channel_udpgw.h */, - 19D0D3C52770982C0010B299 /* blog_channel_BUnixSignal.h */, - 19D0D3C62770982C0010B299 /* blog_channel_ncd_parse.h */, - 19D0D3C72770982C0010B299 /* blog_channel_ncd_ref.h */, - 19D0D3C82770982C0010B299 /* blog_channel_NCDConfigTokenizer.h */, - 19D0D3C92770982C0010B299 /* blog_channel_BDHCPClient.h */, - 19D0D3CA2770982C0010B299 /* blog_channel_ncd_spawn.h */, - 19D0D3CB2770982C0010B299 /* blog_channel_NCDModuleIndex.h */, - 19D0D3CC2770982C0010B299 /* blog_channel_ncd_logical.h */, - 19D0D3CD2770982C0010B299 /* bproto_msgproto.h */, - 19D0D3CE2770982C0010B299 /* blog_channel_ncd_process_manager.h */, - 19D0D3CF2770982C0010B299 /* blog_channel_ncd_net_backend_wpa_supplicant.h */, - 19D0D3D02770982C0010B299 /* blog_channel_BThreadWork.h */, - 19D0D3D12770982C0010B299 /* blog_channel_ncd_try.h */, - 19D0D3D22770982C0010B299 /* blog_channel_BDatagram.h */, - 19D0D3D32770982C0010B299 /* blog_channel_ncd_sys_watch_input.h */, - 19D0D3D42770982C0010B299 /* blog_channel_ncd.h */, - 19D0D3D52770982C0010B299 /* blog_channel_ncd_implode.h */, - 19D0D3D62770982C0010B299 /* blog_channel_NCDBuildProgram.h */, - 19D0D3D72770982C0010B299 /* blog_channel_ncd_file.h */, - 19D0D3D82770982C0010B299 /* blog_channel_ncd_strcmp.h */, - 19D0D3D92770982C0010B299 /* blog_channel_ncd_value.h */, - 19D0D3DA2770982C0010B299 /* blog_channel_NCDValParser.h */, - 19D0D3DB2770982C0010B299 /* blog_channel_BPredicate.h */, - 19D0D3DC2770982C0010B299 /* blog_channel_dostest_attacker.h */, - 19D0D3DD2770982C0010B299 /* blog_channel_client.h */, - 19D0D3DE2770982C0010B299 /* blog_channel_ncd_daemon.h */, - 19D0D3DF2770982C0010B299 /* blog_channel_NCDUdevManager.h */, - 19D0D3E02770982C0010B299 /* blog_channel_PRStreamSource.h */, - 19D0D3E12770982C0010B299 /* blog_channel_BSignal.h */, - 19D0D3E22770982C0010B299 /* blog_channel_ncd_foreach.h */, - 19D0D3E32770982C0010B299 /* blog_channel_ncd_netmask.h */, - 19D0D3E42770982C0010B299 /* blog_channel_NCDVal.h */, - 19D0D3E52770982C0010B299 /* blog_channel_ncd_imperative.h */, - 19D0D3E62770982C0010B299 /* blog_channel_NCDUdevCache.h */, - 19D0D3E72770982C0010B299 /* blog_channel_ncd_index.h */, - 19D0D3E82770982C0010B299 /* blog_channel_ncd_if.h */, - 19D0D3E92770982C0010B299 /* blog_channel_NCDInterfaceMonitor.h */, - 19D0D3EA2770982C0010B299 /* blog_channel_PacketProtoDecoder.h */, - 19D0D3EB2770982C0010B299 /* blog_channel_ncd_net_ipv4_addr.h */, - 19D0D3EC2770982C0010B299 /* blog_channel_ncd_explode.h */, - 19D0D3ED2770982C0010B299 /* blog_channels_defines.h */, - 19D0D3EE2770982C0010B299 /* blog_channel_ncd_log_msg.h */, - 19D0D3EF2770982C0010B299 /* blog_channel_BArpProbe.h */, - 19D0D3F02770982C0010B299 /* blog_channel_ncd_sleep.h */, - 19D0D3F12770982C0010B299 /* blog_channel_ncd_sys_start_process.h */, - 19D0D3F22770982C0010B299 /* blog_channel_ncd_substr.h */, - 19D0D3F32770982C0010B299 /* blog_channel_ncd_log.h */, - 19D0D3F42770982C0010B299 /* blog_channel_ncd_request.h */, - 19D0D3F52770982C0010B299 /* blog_channel_ncd_net_backend_rfkill.h */, - 19D0D3F62770982C0010B299 /* blog_channel_ncd_objref.h */, - 19D0D3F72770982C0010B299 /* blog_channel_ncd_net_watch_interfaces.h */, - 19D0D3F82770982C0010B299 /* blog_channel_ncd_from_string.h */, - 19D0D3F92770982C0010B299 /* blog_channel_BThreadSignal.h */, - 19D0D3FA2770982C0010B299 /* blog_channel_BEncryption.h */, - 19D0D3FB2770982C0010B299 /* blog_channel_ncd_sys_watch_directory.h */, - 19D0D3FC2770982C0010B299 /* blog_channel_ncd_net_ipv4_dhcp.h */, - 19D0D3FD2770982C0010B299 /* blog_channel_ncd_net_ipv6_route.h */, - 19D0D3FE2770982C0010B299 /* blog_channel_ncd_arithmetic.h */, - 19D0D3FF2770982C0010B299 /* blog_channel_ncd_alias.h */, - 19D0D4002770982C0010B299 /* blog_channel_ncd_concat.h */, - 19D0D4012770982C0010B299 /* blog_channel_DataProto.h */, - 19D0D4022770982C0010B299 /* blog_channel_ncd_net_ipv4_arp_probe.h */, - 19D0D4032770982C0010B299 /* blog_channel_ncd_net_ipv6_addr.h */, - 19D0D4042770982C0010B299 /* blog_channel_NCDIfConfig.h */, - 19D0D4052770982C0010B299 /* blog_channel_Listener.h */, - 19D0D4062770982C0010B299 /* blog_channel_tun2socks.h */, - 19D0D4072770982C0010B299 /* blog_channel_ncd_call2.h */, - 19D0D4082770982C0010B299 /* blog_channel_ncd_buffer.h */, - 19D0D4092770982C0010B299 /* blog_channel_NCDModuleProcess.h */, - 19D0D40A2770982C0010B299 /* blog_channel_ncd_load_module.h */, - 19D0D40B2770982C0010B299 /* blog_channel_ncd_depend_scope.h */, - 19D0D40C2770982C0010B299 /* blog_channel_ncd_var.h */, - 19D0D40D2770982C0010B299 /* blog_channel_NCDConfigParser.h */, - 19D0D40E2770982C0010B299 /* blog_channel_lwip.h */, - 19D0D40F2770982C0010B299 /* blog_channel_NCDRequestClient.h */, - 19D0D4102770982C0010B299 /* blog_channel_DPRelay.h */, - 19D0D4112770982C0010B299 /* blog_channel_BInputProcess.h */, - 19D0D4122770982C0010B299 /* blog_channel_ncd_net_ipv4_addr_in_network.h */, - 19D0D4132770982C0010B299 /* blog_channel_ncd_sys_evdev.h */, - 19D0D4142770982C0010B299 /* blog_channel_ncd_exit.h */, - 19D0D4152770982C0010B299 /* blog_channel_SPProtoDecoder.h */, - 19D0D4162770982C0010B299 /* blog_channel_addr.h */, - 19D0D4172770982C0010B299 /* blog_channel_ncd_backtrack.h */, - 19D0D4182770982C0010B299 /* blog_channel_PasswordListener.h */, - 19D0D4192770982C0010B299 /* blog_channel_ncd_to_string.h */, - 19D0D41A2770982C0010B299 /* blog_channel_ncd_net_backend_waitlink.h */, - 19D0D41B2770982C0010B299 /* blog_channel_nsskey.h */, - 19D0D41C2770982C0010B299 /* blog_channel_DatagramPeerIO.h */, - 19D0D41D2770982C0010B299 /* blog_channel_ncd_regex_match.h */, - 19D0D41E2770982C0010B299 /* blog_channel_DPReceive.h */, - 19D0D41F2770982C0010B299 /* blog_channel_ncd_valuemetic.h */, - 19D0D4202770982C0010B299 /* blog_channel_BTime.h */, - 19D0D4212770982C0010B299 /* blog_channel_ncd_timer.h */, - 19D0D4222770982C0010B299 /* bproto_bproto_test.h */, - 19D0D4232770982C0010B299 /* blog_channel_ncd_multidepend.h */, - 19D0D4242770982C0010B299 /* blog_channel_server.h */, - 19D0D4252770982C0010B299 /* blog_channel_ncd_runonce.h */, - 19D0D4262770982C0010B299 /* blog_channel_dostest_server.h */, - 19D0D4272770982C0010B299 /* blog_channel_ncd_net_up.h */, - 19D0D4282770982C0010B299 /* blog_channel_BTap.h */, - 19D0D4292770982C0010B299 /* blog_channel_ncd_net_ipv6_addr_in_network.h */, - 19D0D42A2770982C0010B299 /* blog_channel_BProcess.h */, - 19D0D42B2770982C0010B299 /* blog_channel_StreamPeerIO.h */, - 19D0D42C2770982C0010B299 /* blog_channel_NCDRequest.h */, - 19D0D42D2770982C0010B299 /* blog_channel_NCDRfkillMonitor.h */, - 19D0D42E2770982C0010B299 /* blog_channel_NCDUdevMonitorParser.h */, - 19D0D42F2770982C0010B299 /* blog_channel_ServerConnection.h */, - 19D0D4302770982C0010B299 /* blog_channel_ncd_getargs.h */, - 19D0D4312770982C0010B299 /* blog_channel_BDHCPClientCore.h */, - 19D0D4322770982C0010B299 /* blog_channel_PRStreamSink.h */, - 19D0D4332770982C0010B299 /* blog_channel_ncd_getenv.h */, - 19D0D4342770982C0010B299 /* bproto_addr.h */, - 19D0D4352770982C0010B299 /* blog_channel_ncd_blocker.h */, - 19D0D4362770982C0010B299 /* blog_channel_ncd_reboot.h */, - 19D0D4372770982C0010B299 /* blog_channel_ncd_choose.h */, - 19D0D4382770982C0010B299 /* blog_channel_LineBuffer.h */, - 19D0D4392770982C0010B299 /* blog_channel_FragmentProtoAssembler.h */, - 19D0D43A2770982C0010B299 /* blog_channel_ncd_socket.h */, - 19D0D43B2770982C0010B299 /* blog_channel_UdpGwClient.h */, - 19D0D43C2770982C0010B299 /* blog_channel_flooder.h */, - 19D0D43D2770982C0010B299 /* blog_channel_ncd_assert.h */, - 19D0D43E2770982C0010B299 /* blog_channel_ncd_net_backend_waitdevice.h */, - 19D0D43F2770982C0010B299 /* blog_channel_ncd_basic_functions.h */, - 19D0D4402770982C0010B299 /* blog_channel_NCDPlaceholderDb.h */, - 19D0D4412770982C0010B299 /* blog_channel_ncd_list.h */, - 19D0D4422770982C0010B299 /* blog_channel_PeerChat.h */, - 19D0D4432770982C0010B299 /* blog_channel_ncd_net_backend_badvpn.h */, - 19D0D4442770982C0010B299 /* blog_channel_ncd_print.h */, - 19D0D4452770982C0010B299 /* blog_channel_BNetwork.h */, - 19D0D4462770982C0010B299 /* blog_channel_BLockReactor.h */, - 19D0D4472770982C0010B299 /* blog_channel_ncd_ondemand.h */, - 19D0D4482770982C0010B299 /* blog_channel_ncd_net_iptables.h */, - 19D0D4492770982C0010B299 /* blog_channel_ncd_depend.h */, - 19D0D44A2770982C0010B299 /* blog_channel_ncd_sys_request_client.h */, - 19D0D44B2770982C0010B299 /* blog_channel_ncd_net_dns.h */, - 19D0D44C2770982C0010B299 /* blog_channel_NCDUdevMonitor.h */, - 19D0D44D2770982C0010B299 /* blog_channel_BSocksClient.h */, - ); - path = generated; - sourceTree = ""; - }; - 19D0D44E2770982C0010B299 /* socksclient */ = { - isa = PBXGroup; - children = ( - 19D0D44F2770982C0010B299 /* BSocksClient.c */, - 19D0D4502770982C0010B299 /* BSocksClient.h */, - ); - path = socksclient; - sourceTree = ""; - }; - 19D0D4512770982C0010B299 /* misc */ = { - isa = PBXGroup; - children = ( - 19D0D4522770982C0010B299 /* packed.h */, - 19D0D4532770982C0010B299 /* concat_strings.h */, - 19D0D4542770982C0010B299 /* Utf8Decoder.h */, - 19D0D4552770982C0010B299 /* parse_number.h */, - 19D0D4562770982C0010B299 /* udp_proto.h */, - 19D0D4572770982C0010B299 /* find_program.h */, - 19D0D4582770982C0010B299 /* minmax.h */, - 19D0D4592770982C0010B299 /* socks_proto.h */, - 19D0D45A2770982C0010B299 /* string_begins_with.h */, - 19D0D45B2770982C0010B299 /* dead.h */, - 19D0D45C2770982C0010B299 /* strdup.h */, - 19D0D45D2770982C0010B299 /* debug.h */, - 19D0D45E2770982C0010B299 /* array_length.h */, - 19D0D45F2770982C0010B299 /* version.h */, - 19D0D4602770982C0010B299 /* bsort.h */, - 19D0D4612770982C0010B299 /* debugcounter.h */, - 19D0D4622770982C0010B299 /* byteorder.h */, - 19D0D4632770982C0010B299 /* unicode_funcs.h */, - 19D0D4642770982C0010B299 /* Utf16Decoder.h */, - 19D0D4652770982C0010B299 /* bstring.h */, - 19D0D4662770982C0010B299 /* maxalign.h */, - 19D0D4672770982C0010B299 /* offset.h */, - 19D0D4682770982C0010B299 /* cmdline.h */, - 19D0D4692770982C0010B299 /* expstring.h */, - 19D0D46A2770982C0010B299 /* merge.h */, - 19D0D46B2770982C0010B299 /* ipaddr.h */, - 19D0D46C2770982D0010B299 /* write_file.h */, - 19D0D46D2770982D0010B299 /* print_macros.h */, - 19D0D46E2770982D0010B299 /* substring.h */, - 19D0D46F2770982D0010B299 /* balign.h */, - 19D0D4702770982D0010B299 /* debugerror.h */, - 19D0D4712770982D0010B299 /* memref.h */, - 19D0D4722770982D0010B299 /* hashfun.h */, - 19D0D4732770982D0010B299 /* igmp_proto.h */, - 19D0D4742770982D0010B299 /* mswsock.h */, - 19D0D4752770982D0010B299 /* get_iface_info.h */, - 19D0D4762770982D0010B299 /* sslsocket.h */, - 19D0D4772770982D0010B299 /* blimits.h */, - 19D0D4782770982D0010B299 /* balloc.h */, - 19D0D4792770982D0010B299 /* ipaddr6.h */, - 19D0D47A2770982D0010B299 /* compare.h */, - 19D0D47B2770982D0010B299 /* nonblocking.h */, - 19D0D47C2770982D0010B299 /* loglevel.h */, - 19D0D47D2770982D0010B299 /* modadd.h */, - 19D0D47E2770982D0010B299 /* nsskey.h */, - 19D0D47F2770982D0010B299 /* ethernet_proto.h */, - 19D0D4802770982D0010B299 /* find_char.h */, - 19D0D4812770982D0010B299 /* read_write_int.h */, - 19D0D4822770982D0010B299 /* ipv6_proto.h */, - 19D0D4832770982D0010B299 /* loggers_string.h */, - 19D0D4842770982D0010B299 /* overflow.h */, - 19D0D4852770982D0010B299 /* open_standard_streams.h */, - 19D0D4862770982D0010B299 /* Utf16Encoder.h */, - 19D0D4872770982D0010B299 /* read_file.h */, - 19D0D4882770982D0010B299 /* dhcp_proto.h */, - 19D0D4892770982D0010B299 /* exparray.h */, - 19D0D48A2770982D0010B299 /* BRefTarget.h */, - 19D0D48B2770982D0010B299 /* ipv4_proto.h */, - 19D0D48C2770982D0010B299 /* grow_array.h */, - 19D0D48D2770982D0010B299 /* stdbuf_cmdline.h */, - 19D0D48E2770982D0010B299 /* arp_proto.h */, - 19D0D48F2770982D0010B299 /* ascii_utils.h */, - 19D0D4902770982D0010B299 /* bsize.h */, - 19D0D4912770982D0010B299 /* Utf8Encoder.h */, - ); - path = misc; - sourceTree = ""; - }; - 19D0D4922770982D0010B299 /* lwip */ = { - isa = PBXGroup; - children = ( - 19D0D4932770982D0010B299 /* custom */, - 19D0D4992770982D0010B299 /* src */, - ); - path = lwip; - sourceTree = ""; - }; - 19D0D4932770982D0010B299 /* custom */ = { - isa = PBXGroup; - children = ( - 19D0D4942770982D0010B299 /* sys.c */, - 19D0D4952770982D0010B299 /* arch */, - 19D0D4982770982D0010B299 /* lwipopts.h */, - ); - path = custom; - sourceTree = ""; - }; - 19D0D4952770982D0010B299 /* arch */ = { - isa = PBXGroup; - children = ( - 19D0D4962770982D0010B299 /* cc.h */, - 19D0D4972770982D0010B299 /* perf.h */, - ); - path = arch; - sourceTree = ""; - }; - 19D0D4992770982D0010B299 /* src */ = { - isa = PBXGroup; - children = ( - 19D0D49A2770982D0010B299 /* core */, - 19D0D4B32770982D0010B299 /* include */, - ); - path = src; - sourceTree = ""; - }; - 19D0D49A2770982D0010B299 /* core */ = { - isa = PBXGroup; - children = ( - 19D0D49B2770982D0010B299 /* memp.c */, - 19D0D49C2770982D0010B299 /* inet_chksum.c */, - 19D0D49D2770982D0010B299 /* tcp_out.c */, - 19D0D49E2770982D0010B299 /* init.c */, - 19D0D49F2770982D0010B299 /* mem.c */, - 19D0D4A02770982D0010B299 /* def.c */, - 19D0D4A12770982D0010B299 /* udp.c */, - 19D0D4A22770982D0010B299 /* stats.c */, - 19D0D4A32770982D0010B299 /* tcp_in.c */, - 19D0D4A42770982D0010B299 /* ipv4 */, - 19D0D4A92770982D0010B299 /* netif.c */, - 19D0D4AA2770982D0010B299 /* tcp.c */, - 19D0D4AB2770982D0010B299 /* timers.c */, - 19D0D4AC2770982D0010B299 /* pbuf.c */, - 19D0D4AD2770982D0010B299 /* ipv6 */, - ); - path = core; - sourceTree = ""; - }; - 19D0D4A42770982D0010B299 /* ipv4 */ = { - isa = PBXGroup; - children = ( - 19D0D4A52770982D0010B299 /* ip_frag.c */, - 19D0D4A62770982D0010B299 /* icmp.c */, - 19D0D4A72770982D0010B299 /* ip4.c */, - 19D0D4A82770982D0010B299 /* ip4_addr.c */, - ); - path = ipv4; - sourceTree = ""; - }; - 19D0D4AD2770982D0010B299 /* ipv6 */ = { - isa = PBXGroup; - children = ( - 19D0D4AE2770982D0010B299 /* ip6.c */, - 19D0D4AF2770982D0010B299 /* icmp6.c */, - 19D0D4B02770982D0010B299 /* nd6.c */, - 19D0D4B12770982D0010B299 /* ip6_addr.c */, - 19D0D4B22770982D0010B299 /* ip6_frag.c */, - ); - path = ipv6; - sourceTree = ""; - }; - 19D0D4B32770982D0010B299 /* include */ = { - isa = PBXGroup; - children = ( - 19D0D4B42770982D0010B299 /* posix */, - 19D0D4B82770982D0010B299 /* lwip */, - 19D0D4DC2770982D0010B299 /* netif */, - 19D0D4E02770982D0010B299 /* ipv4 */, - 19D0D4E92770982D0010B299 /* ipv6 */, - ); - path = include; - sourceTree = ""; - }; - 19D0D4B42770982D0010B299 /* posix */ = { - isa = PBXGroup; - children = ( - 19D0D4B52770982D0010B299 /* sys */, - 19D0D4B72770982D0010B299 /* netdb.h */, - ); - path = posix; - sourceTree = ""; - }; - 19D0D4B52770982D0010B299 /* sys */ = { - isa = PBXGroup; - children = ( - 19D0D4B62770982D0010B299 /* socket.h */, - ); - path = sys; - sourceTree = ""; - }; - 19D0D4B82770982D0010B299 /* lwip */ = { - isa = PBXGroup; - children = ( - 19D0D4B92770982D0010B299 /* timers.h */, - 19D0D4BA2770982D0010B299 /* pbuf.h */, - 19D0D4BB2770982D0010B299 /* tcp_impl.h */, - 19D0D4BC2770982D0010B299 /* tcp.h */, - 19D0D4BD2770982D0010B299 /* err.h */, - 19D0D4BE2770982D0010B299 /* snmp_asn1.h */, - 19D0D4BF2770982D0010B299 /* netif.h */, - 19D0D4C02770982D0010B299 /* sio.h */, - 19D0D4C12770982D0010B299 /* debug.h */, - 19D0D4C22770982D0010B299 /* tcpip.h */, - 19D0D4C32770982D0010B299 /* snmp.h */, - 19D0D4C42770982D0010B299 /* snmp_structs.h */, - 19D0D4C52770982D0010B299 /* api_msg.h */, - 19D0D4C62770982D0010B299 /* netifapi.h */, - 19D0D4C72770982D0010B299 /* netbuf.h */, - 19D0D4C82770982D0010B299 /* api.h */, - 19D0D4C92770982D0010B299 /* dhcp.h */, - 19D0D4CA2770982D0010B299 /* memp.h */, - 19D0D4CB2770982D0010B299 /* sockets.h */, - 19D0D4CC2770982D0010B299 /* ip_addr.h */, - 19D0D4CD2770982D0010B299 /* opt.h */, - 19D0D4CE2770982D0010B299 /* inet_chksum.h */, - 19D0D4CF2770982D0010B299 /* raw.h */, - 19D0D4D02770982D0010B299 /* sys.h */, - 19D0D4D12770982D0010B299 /* netdb.h */, - 19D0D4D22770982D0010B299 /* def.h */, - 19D0D4D32770982D0010B299 /* mem.h */, - 19D0D4D42770982D0010B299 /* dns.h */, - 19D0D4D52770982D0010B299 /* ip.h */, - 19D0D4D62770982D0010B299 /* init.h */, - 19D0D4D72770982D0010B299 /* snmp_msg.h */, - 19D0D4D82770982D0010B299 /* stats.h */, - 19D0D4D92770982D0010B299 /* memp_std.h */, - 19D0D4DA2770982D0010B299 /* udp.h */, - 19D0D4DB2770982D0010B299 /* arch.h */, - ); - path = lwip; - sourceTree = ""; - }; - 19D0D4DC2770982D0010B299 /* netif */ = { - isa = PBXGroup; - children = ( - 19D0D4DD2770982D0010B299 /* etharp.h */, - 19D0D4DE2770982D0010B299 /* ppp_oe.h */, - 19D0D4DF2770982D0010B299 /* slipif.h */, - ); - path = netif; - sourceTree = ""; - }; - 19D0D4E02770982D0010B299 /* ipv4 */ = { - isa = PBXGroup; - children = ( - 19D0D4E12770982D0010B299 /* lwip */, - ); - path = ipv4; - sourceTree = ""; - }; - 19D0D4E12770982D0010B299 /* lwip */ = { - isa = PBXGroup; - children = ( - 19D0D4E22770982D0010B299 /* igmp.h */, - 19D0D4E32770982D0010B299 /* ip4.h */, - 19D0D4E42770982D0010B299 /* icmp.h */, - 19D0D4E52770982D0010B299 /* inet.h */, - 19D0D4E62770982D0010B299 /* ip4_addr.h */, - 19D0D4E72770982D0010B299 /* autoip.h */, - 19D0D4E82770982D0010B299 /* ip_frag.h */, - ); - path = lwip; - sourceTree = ""; - }; - 19D0D4E92770982D0010B299 /* ipv6 */ = { - isa = PBXGroup; - children = ( - 19D0D4EA2770982D0010B299 /* lwip */, - ); - path = ipv6; - sourceTree = ""; - }; - 19D0D4EA2770982D0010B299 /* lwip */ = { - isa = PBXGroup; - children = ( - 19D0D4EB2770982D0010B299 /* nd6.h */, - 19D0D4EC2770982D0010B299 /* ethip6.h */, - 19D0D4ED2770982D0010B299 /* inet6.h */, - 19D0D4EE2770982D0010B299 /* ip6_addr.h */, - 19D0D4EF2770982D0010B299 /* ip6_frag.h */, - 19D0D4F02770982D0010B299 /* ip6.h */, - 19D0D4F12770982D0010B299 /* icmp6.h */, - 19D0D4F22770982D0010B299 /* dhcp6.h */, - 19D0D4F32770982D0010B299 /* mld6.h */, - ); - path = lwip; - sourceTree = ""; - }; - 19D0D4F42770982D0010B299 /* tuntap */ = { - isa = PBXGroup; - children = ( - 19D0D4F52770982D0010B299 /* BTap.m */, - 19D0D4F62770982D0010B299 /* BTap.h */, - ); - path = tuntap; - sourceTree = ""; - }; - 19D0D4F72770982D0010B299 /* udpgw */ = { - isa = PBXGroup; - children = ( - 19D0D4F82770982D0010B299 /* udpgw.h */, - 19D0D4F92770982D0010B299 /* udpgw.c */, - ); - path = udpgw; - sourceTree = ""; - }; - 19D0D4FA2770982D0010B299 /* protocol */ = { - isa = PBXGroup; - children = ( - 19D0D4FB2770982D0010B299 /* udpgw_proto.h */, - 19D0D4FC2770982D0010B299 /* requestproto.h */, - 19D0D4FD2770982D0010B299 /* msgproto.h */, - 19D0D4FE2770982D0010B299 /* spproto.h */, - 19D0D4FF2770982D0010B299 /* packetproto.h */, - 19D0D5002770982D0010B299 /* dataproto.h */, - 19D0D5012770982D0010B299 /* addr.h */, - 19D0D5022770982D0010B299 /* scproto.h */, - 19D0D5032770982D0010B299 /* addr.bproto */, - 19D0D5042770982D0010B299 /* fragmentproto.h */, - 19D0D5052770982D0010B299 /* msgproto.bproto */, - ); - path = protocol; - sourceTree = ""; - }; - 19D0D5062770982D0010B299 /* system */ = { - isa = PBXGroup; - children = ( - 19D0D5072770982D0010B299 /* BDatagram_unix.h */, - 19D0D5082770982D0010B299 /* BUnixSignal.h */, - 19D0D5092770982D0010B299 /* BNetwork.c */, - 19D0D50A2770982D0010B299 /* BConnection.h */, - 19D0D50B2770982D0010B299 /* BConnection_common.c */, - 19D0D50C2770982D0010B299 /* BReactor_badvpn.h */, - 19D0D50D2770982D0010B299 /* BAddr.h */, - 19D0D50E2770982D0010B299 /* BReactor.h */, - 19D0D50F2770982D0010B299 /* BConnection_unix.h */, - 19D0D5102770982D0010B299 /* BTime.c */, - 19D0D5112770982D0010B299 /* BSignal.c */, - 19D0D5122770982D0010B299 /* BReactor_badvpn_timerstree.h */, - 19D0D5132770982D0010B299 /* BDatagram_unix.c */, - 19D0D5142770982D0010B299 /* BNetwork.h */, - 19D0D5152770982D0010B299 /* BUnixSignal.c */, - 19D0D5162770982D0010B299 /* BDatagram.h */, - 19D0D5172770982D0010B299 /* BReactor_badvpn.c */, - 19D0D5182770982D0010B299 /* BSignal.h */, - 19D0D5192770982D0010B299 /* BTime.h */, - 19D0D51A2770982D0010B299 /* BConnection_unix.c */, - ); - path = system; - sourceTree = ""; - }; - 19D0D51B2770982D0010B299 /* tun2socks */ = { - isa = PBXGroup; - children = ( - 19D0D51C2770982D0010B299 /* tun2socks.c */, - 19D0D51D2770982D0010B299 /* SocksUdpGwClient.h */, - 19D0D51E2770982D0010B299 /* tun2socks.h */, - 19D0D51F2770982D0010B299 /* SocksUdpGwClient.c */, - ); - path = tun2socks; - sourceTree = ""; - }; - 19D0D5202770982D0010B299 /* structure */ = { - isa = PBXGroup; - children = ( - 19D0D5212770982D0010B299 /* SAvl.h */, - 19D0D5222770982D0010B299 /* Vector_footer.h */, - 19D0D5232770982D0010B299 /* ChunkBuffer2.h */, - 19D0D5242770982D0010B299 /* IndexedList_tree.h */, - 19D0D5252770982D0010B299 /* LinkedList1.h */, - 19D0D5262770982D0010B299 /* Vector_header.h */, - 19D0D5272770982D0010B299 /* CAvl_header.h */, - 19D0D5282770982D0010B299 /* Vector_decl.h */, - 19D0D5292770982D0010B299 /* CHash_decl.h */, - 19D0D52A2770982D0010B299 /* CAvl_footer.h */, - 19D0D52B2770982D0010B299 /* SLinkedList_decl.h */, - 19D0D52C2770982D0010B299 /* CAvl_impl.h */, - 19D0D52D2770982D0010B299 /* SAvl_decl.h */, - 19D0D52E2770982D0010B299 /* CHash.h */, - 19D0D52F2770982D0010B299 /* SAvl_footer.h */, - 19D0D5302770982D0010B299 /* SAvl_tree.h */, - 19D0D5312770982D0010B299 /* IndexedList.h */, - 19D0D5322770982D0010B299 /* SAvl_header.h */, - 19D0D5332770982D0010B299 /* LinkedList3.h */, - 19D0D5342770982D0010B299 /* BAVL.h */, - 19D0D5352770982D0010B299 /* SLinkedList_impl.h */, - 19D0D5362770982D0010B299 /* CAvl_decl.h */, - 19D0D5372770982D0010B299 /* CAvl.h */, - 19D0D5382770982D0010B299 /* Vector_impl.h */, - 19D0D5392770982D0010B299 /* SLinkedList.h */, - 19D0D53A2770982D0010B299 /* CHash_impl.h */, - 19D0D53B2770982D0010B299 /* CHash_footer.h */, - 19D0D53C2770982D0010B299 /* LinkedList0.h */, - 19D0D53D2770982D0010B299 /* CHash_header.h */, - 19D0D53E2770982D0010B299 /* SAvl_impl.h */, - 19D0D53F2770982D0010B299 /* Vector.h */, - 19D0D5402770982D0010B299 /* SLinkedList_footer.h */, - 19D0D5412770982D0010B299 /* SLinkedList_header.h */, - ); - path = structure; - sourceTree = ""; - }; - 19D0D5422770982D0010B299 /* flowextra */ = { - isa = PBXGroup; - children = ( - 19D0D5432770982D0010B299 /* PacketPassInactivityMonitor.h */, - 19D0D5442770982D0010B299 /* PacketPassInactivityMonitor.c */, - ); - path = flowextra; - sourceTree = ""; - }; - 19D0D5452770982D0010B299 /* base */ = { - isa = PBXGroup; - children = ( - 19D0D5462770982D0010B299 /* BLog.m */, - 19D0D5472770982E0010B299 /* BLog_syslog.c */, - 19D0D5482770982E0010B299 /* BPending_list.h */, - 19D0D5492770982E0010B299 /* DebugObject.c */, - 19D0D54A2770982E0010B299 /* BPending.h */, - 19D0D54B2770982E0010B299 /* BLog_syslog.h */, - 19D0D54C2770982E0010B299 /* BLog.h */, - 19D0D54D2770982E0010B299 /* BMutex.h */, - 19D0D54E2770982E0010B299 /* BPending.c */, - 19D0D54F2770982E0010B299 /* DebugObject.h */, - ); - path = base; - sourceTree = ""; - }; - 19D0D5502770982E0010B299 /* udpgw_client */ = { - isa = PBXGroup; - children = ( - 19D0D5512770982E0010B299 /* UdpGwClient.c */, - 19D0D5522770982E0010B299 /* UdpGwClient.h */, - ); - path = udpgw_client; - sourceTree = ""; - }; - 19D0D5532770982E0010B299 /* flow */ = { - isa = PBXGroup; - children = ( - 19D0D5542770982E0010B299 /* PacketBuffer.c */, - 19D0D5552770982E0010B299 /* PacketStreamSender.h */, - 19D0D5562770982E0010B299 /* BufferWriter.c */, - 19D0D5572770982E0010B299 /* PacketRecvInterface.c */, - 19D0D5582770982E0010B299 /* PacketPassFairQueue_tree.h */, - 19D0D5592770982E0010B299 /* SinglePacketBuffer.h */, - 19D0D55A2770982E0010B299 /* PacketProtoDecoder.h */, - 19D0D55B2770982E0010B299 /* StreamRecvInterface.c */, - 19D0D55C2770982E0010B299 /* PacketProtoEncoder.c */, - 19D0D55D2770982E0010B299 /* StreamPassInterface.c */, - 19D0D55E2770982E0010B299 /* PacketPassConnector.c */, - 19D0D55F2770982E0010B299 /* PacketPassFairQueue.h */, - 19D0D5602770982E0010B299 /* PacketProtoFlow.c */, - 19D0D5612770982E0010B299 /* PacketPassInterface.c */, - 19D0D5622770982E0010B299 /* BufferWriter.h */, - 19D0D5632770982E0010B299 /* PacketRecvInterface.h */, - 19D0D5642770982E0010B299 /* PacketBuffer.h */, - 19D0D5652770982E0010B299 /* PacketStreamSender.c */, - 19D0D5662770982E0010B299 /* StreamRecvInterface.h */, - 19D0D5672770982E0010B299 /* PacketProtoDecoder.c */, - 19D0D5682770982E0010B299 /* SinglePacketBuffer.c */, - 19D0D5692770982E0010B299 /* PacketPassFairQueue.c */, - 19D0D56A2770982E0010B299 /* PacketPassConnector.h */, - 19D0D56B2770982E0010B299 /* StreamPassInterface.h */, - 19D0D56C2770982E0010B299 /* PacketProtoEncoder.h */, - 19D0D56D2770982E0010B299 /* PacketPassInterface.h */, - 19D0D56E2770982E0010B299 /* PacketProtoFlow.h */, - ); - path = flow; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 19D0CCE4277092B50010B299 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 19D0CCED277092B50010B299 /* PacketProcessor.h in Headers */, - 19D0D710277098610010B299 /* TunnelInterface.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - 19D0CCE8277092B50010B299 /* PacketProcessor */ = { - isa = PBXNativeTarget; - buildConfigurationList = 19D0CCF0277092B50010B299 /* Build configuration list for PBXNativeTarget "PacketProcessor" */; - buildPhases = ( - 19D0CCE4277092B50010B299 /* Headers */, - 19D0CCE5277092B50010B299 /* Sources */, - 19D0CCE6277092B50010B299 /* Frameworks */, - 19D0CCE7277092B50010B299 /* Resources */, - 19D0CCF9277096980010B299 /* Embed Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = PacketProcessor; - productName = PacketProcessor; - productReference = 19D0CCE9277092B50010B299 /* PacketProcessor.framework */; - productType = "com.apple.product-type.framework"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 19D0CCE0277092B50010B299 /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastUpgradeCheck = 1320; - TargetAttributes = { - 19D0CCE8277092B50010B299 = { - CreatedOnToolsVersion = 13.2.1; - }; - }; - }; - buildConfigurationList = 19D0CCE3277092B50010B299 /* Build configuration list for PBXProject "PacketProcessor" */; - compatibilityVersion = "Xcode 13.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 19D0CCDF277092B50010B299; - productRefGroup = 19D0CCEA277092B50010B299 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 19D0CCE8277092B50010B299 /* PacketProcessor */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 19D0CCE7277092B50010B299 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 19D0D6AB277098310010B299 /* msgproto.bproto in Resources */, - 19D0D6A9277098310010B299 /* addr.bproto in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 19D0CCE5277092B50010B299 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 19D0D700277098320010B299 /* PacketPassInterface.c in Sources */, - 19D0D662277098300010B299 /* nd6.c in Sources */, - 19D0D664277098300010B299 /* ip6_frag.c in Sources */, - 19D0D6BA277098310010B299 /* BUnixSignal.c in Sources */, - 19D0D708277098320010B299 /* PacketPassFairQueue.c in Sources */, - 19D0D706277098320010B299 /* PacketProtoDecoder.c in Sources */, - 19D0D6E6277098310010B299 /* PacketPassInactivityMonitor.c in Sources */, - 19D0D659277098300010B299 /* icmp.c in Sources */, - 19D0D65E277098300010B299 /* timers.c in Sources */, - 19D0D651277098300010B299 /* tcp_out.c in Sources */, - 19D0D650277098300010B299 /* inet_chksum.c in Sources */, - 19D0D70F277098320010B299 /* TunnelInterface.m in Sources */, - 19D0D6FF277098320010B299 /* PacketProtoFlow.c in Sources */, - 19D0D658277098300010B299 /* ip_frag.c in Sources */, - 19D0D653277098300010B299 /* mem.c in Sources */, - 19D0D65F277098300010B299 /* pbuf.c in Sources */, - 19D0D6A0277098310010B299 /* udpgw.c in Sources */, - 19D0D663277098300010B299 /* ip6_addr.c in Sources */, - 19D0D6F3277098310010B299 /* PacketBuffer.c in Sources */, - 19D0D6B5277098310010B299 /* BTime.c in Sources */, - 19D0D6F6277098310010B299 /* PacketRecvInterface.c in Sources */, - 19D0D6B0277098310010B299 /* BConnection_common.c in Sources */, - 19D0D6B8277098310010B299 /* BDatagram_unix.c in Sources */, - 19D0D65B277098300010B299 /* ip4_addr.c in Sources */, - 19D0D6C3277098310010B299 /* SocksUdpGwClient.c in Sources */, - 19D0D704277098320010B299 /* PacketStreamSender.c in Sources */, - 19D0D6C0277098310010B299 /* tun2socks.c in Sources */, - 19D0D655277098300010B299 /* udp.c in Sources */, - 19D0D6EA277098310010B299 /* DebugObject.c in Sources */, - 19D0D6F5277098310010B299 /* BufferWriter.c in Sources */, - 19D0D661277098300010B299 /* icmp6.c in Sources */, - 19D0D6EF277098310010B299 /* BPending.c in Sources */, - 19D0D6FC277098320010B299 /* StreamPassInterface.c in Sources */, - 19D0D6BF277098310010B299 /* BConnection_unix.c in Sources */, - 19D0D6FB277098320010B299 /* PacketProtoEncoder.c in Sources */, - 19D0D6B6277098310010B299 /* BSignal.c in Sources */, - 19D0D660277098300010B299 /* ip6.c in Sources */, - 19D0D64F277098300010B299 /* memp.c in Sources */, - 19D0D6E8277098310010B299 /* BLog_syslog.c in Sources */, - 19D0D6F1277098310010B299 /* UdpGwClient.c in Sources */, - 19D0D6AE277098310010B299 /* BNetwork.c in Sources */, - 19D0D6BC277098310010B299 /* BReactor_badvpn.c in Sources */, - 19D0D69D277098310010B299 /* BTap.m in Sources */, - 19D0D657277098300010B299 /* tcp_in.c in Sources */, - 19D0D652277098300010B299 /* init.c in Sources */, - 19D0D654277098300010B299 /* def.c in Sources */, - 19D0D6E7277098310010B299 /* BLog.m in Sources */, - 19D0D6FA277098320010B299 /* StreamRecvInterface.c in Sources */, - 19D0D656277098300010B299 /* stats.c in Sources */, - 19D0D6092770982F0010B299 /* BSocksClient.c in Sources */, - 19D0D6FD277098320010B299 /* PacketPassConnector.c in Sources */, - 19D0D707277098320010B299 /* SinglePacketBuffer.c in Sources */, - 19D0D64B277098300010B299 /* sys.c in Sources */, - 19D0D65D277098300010B299 /* tcp.c in Sources */, - 19D0D65C277098300010B299 /* netif.c in Sources */, - 19D0D65A277098300010B299 /* ip4.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 19D0CCEE277092B50010B299 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.2; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - 19D0CCEF277092B50010B299 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.2; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - 19D0CCF1277092B50010B299 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 7VAGZXD78P; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/PacketProcessor/CocoaAsyncSocket", - ); - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - BADVPN_BREACTOR_BADVPN, - BADVPN_FREEBSD, - BADVPN_THREADWORK_USE_PTHREAD, - "BADVPN_THREAD_SAFE=1", - BADVPN_USE_KEVENT, - BADVPN_USE_SYSLOG, - BADVPN_BIG_ENDIAN, - BADVPN_LIBTSOCKS, - ); - GENERATE_INFOPLIST_FILE = YES; - HEADER_SEARCH_PATHS = ( - "${inherited}", - "\"${PROJECT_DIR}/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers\"", - ); - INFOPLIST_FILE = PacketProcessor/Info.plist; - INFOPLIST_KEY_NSPrincipalClass = ""; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - MARKETING_VERSION = 1.0; - OTHER_LDFLAGS = ( - "$(inherited)", - "-framework", - "\"CFNetwork\"", - "-framework", - "\"CocoaAsyncSocket\"", - "-framework", - "\"Security\"", - ); - PRODUCT_BUNDLE_IDENTIFIER = org.amnezia.Amnezia.PacketProcessor; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - SWIFT_EMIT_LOC_STRINGS = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ( - "${inherited}", - "${SRCROOT}/${TARGET_NAME}/tun2socks-iOS", - "${SRCROOT}/${TARGET_NAME}/tun2socks-iOS/lwip/src/include", - "${SRCROOT}/${TARGET_NAME}/tun2socks-iOS/lwip/custom", - "${SRCROOT}/${TARGET_NAME}/tun2socks-iOS/lwip/src/include/ipv4", - "${SRCROOT}/${TARGET_NAME}/tun2socks-iOS/lwip/src/include/ipv6", - ); - }; - name = Debug; - }; - 19D0CCF2277092B50010B299 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 7VAGZXD78P; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_BITCODE = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/PacketProcessor/CocoaAsyncSocket", - ); - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - BADVPN_BREACTOR_BADVPN, - BADVPN_FREEBSD, - BADVPN_THREADWORK_USE_PTHREAD, - "BADVPN_THREAD_SAFE=1", - BADVPN_USE_KEVENT, - BADVPN_USE_SYSLOG, - BADVPN_BIG_ENDIAN, - BADVPN_LIBTSOCKS, - ); - GENERATE_INFOPLIST_FILE = YES; - HEADER_SEARCH_PATHS = ( - "${inherited}", - "\"${PROJECT_DIR}/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers\"", - ); - INFOPLIST_FILE = PacketProcessor/Info.plist; - INFOPLIST_KEY_NSPrincipalClass = ""; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - MARKETING_VERSION = 1.0; - OTHER_LDFLAGS = ( - "$(inherited)", - "-framework", - "\"CFNetwork\"", - "-framework", - "\"CocoaAsyncSocket\"", - "-framework", - "\"Security\"", - ); - PRODUCT_BUNDLE_IDENTIFIER = org.amnezia.Amnezia.PacketProcessor; - PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; - SKIP_INSTALL = YES; - SWIFT_EMIT_LOC_STRINGS = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = ( - "${inherited}", - "${SRCROOT}/${TARGET_NAME}/tun2socks-iOS", - "${SRCROOT}/${TARGET_NAME}/tun2socks-iOS/lwip/src/include", - "${SRCROOT}/${TARGET_NAME}/tun2socks-iOS/lwip/custom", - "${SRCROOT}/${TARGET_NAME}/tun2socks-iOS/lwip/src/include/ipv4", - "${SRCROOT}/${TARGET_NAME}/tun2socks-iOS/lwip/src/include/ipv6", - ); - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 19D0CCE3277092B50010B299 /* Build configuration list for PBXProject "PacketProcessor" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 19D0CCEE277092B50010B299 /* Debug */, - 19D0CCEF277092B50010B299 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 19D0CCF0277092B50010B299 /* Build configuration list for PBXNativeTarget "PacketProcessor" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 19D0CCF1277092B50010B299 /* Debug */, - 19D0CCF2277092B50010B299 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 19D0CCE0277092B50010B299 /* Project object */; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a6..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d98100..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.xcworkspace/xcuserdata/sanchez.xcuserdatad/UserInterfaceState.xcuserstate b/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.xcworkspace/xcuserdata/sanchez.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index cdaab9f2..00000000 Binary files a/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/project.xcworkspace/xcuserdata/sanchez.xcuserdatad/UserInterfaceState.xcuserstate and /dev/null differ diff --git a/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/xcuserdata/sanchez.xcuserdatad/xcschemes/xcschememanagement.plist b/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/xcuserdata/sanchez.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 64a14287..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor.xcodeproj/xcuserdata/sanchez.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,14 +0,0 @@ - - - - - SchemeUserState - - PacketProcessor.xcscheme_^#shared#^_ - - orderHint - 0 - - - - diff --git a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/CocoaAsyncSocket b/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/CocoaAsyncSocket deleted file mode 100755 index 1ed5a5d0..00000000 Binary files a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/CocoaAsyncSocket and /dev/null differ diff --git a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers/CocoaAsyncSocket.h b/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers/CocoaAsyncSocket.h deleted file mode 100644 index c4e5ee8f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers/CocoaAsyncSocket.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// CocoaAsyncSocket.h -// CocoaAsyncSocket -// -// Created by Derek Clarkson on 10/08/2015. -// CocoaAsyncSocket project is in the public domain. -// - -#import - -//! Project version number for CocoaAsyncSocket. -FOUNDATION_EXPORT double cocoaAsyncSocketVersionNumber; - -//! Project version string for CocoaAsyncSocket. -FOUNDATION_EXPORT const unsigned char cocoaAsyncSocketVersionString[]; - -#import -#import diff --git a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers/GCDAsyncSocket.h b/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers/GCDAsyncSocket.h deleted file mode 100644 index c339f8ab..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers/GCDAsyncSocket.h +++ /dev/null @@ -1,1226 +0,0 @@ -// -// GCDAsyncSocket.h -// -// This class is in the public domain. -// Originally created by Robbie Hanson in Q3 2010. -// Updated and maintained by Deusty LLC and the Apple development community. -// -// https://github.com/robbiehanson/CocoaAsyncSocket -// - -#import -#import -#import -#import -#import - -#include // AF_INET, AF_INET6 - -@class GCDAsyncReadPacket; -@class GCDAsyncWritePacket; -@class GCDAsyncSocketPreBuffer; -@protocol GCDAsyncSocketDelegate; - -NS_ASSUME_NONNULL_BEGIN - -extern NSString *const GCDAsyncSocketException; -extern NSString *const GCDAsyncSocketErrorDomain; - -extern NSString *const GCDAsyncSocketQueueName; -extern NSString *const GCDAsyncSocketThreadName; - -extern NSString *const GCDAsyncSocketManuallyEvaluateTrust; -#if TARGET_OS_IPHONE -extern NSString *const GCDAsyncSocketUseCFStreamForTLS; -#endif -#define GCDAsyncSocketSSLPeerName (NSString *)kCFStreamSSLPeerName -#define GCDAsyncSocketSSLCertificates (NSString *)kCFStreamSSLCertificates -#define GCDAsyncSocketSSLIsServer (NSString *)kCFStreamSSLIsServer -extern NSString *const GCDAsyncSocketSSLPeerID; -extern NSString *const GCDAsyncSocketSSLProtocolVersionMin; -extern NSString *const GCDAsyncSocketSSLProtocolVersionMax; -extern NSString *const GCDAsyncSocketSSLSessionOptionFalseStart; -extern NSString *const GCDAsyncSocketSSLSessionOptionSendOneByteRecord; -extern NSString *const GCDAsyncSocketSSLCipherSuites; -extern NSString *const GCDAsyncSocketSSLALPN; -#if !TARGET_OS_IPHONE -extern NSString *const GCDAsyncSocketSSLDiffieHellmanParameters; -#endif - -#define GCDAsyncSocketLoggingContext 65535 - - -typedef NS_ERROR_ENUM(GCDAsyncSocketErrorDomain, GCDAsyncSocketError) { - GCDAsyncSocketNoError = 0, // Never used - GCDAsyncSocketBadConfigError, // Invalid configuration - GCDAsyncSocketBadParamError, // Invalid parameter was passed - GCDAsyncSocketConnectTimeoutError, // A connect operation timed out - GCDAsyncSocketReadTimeoutError, // A read operation timed out - GCDAsyncSocketWriteTimeoutError, // A write operation timed out - GCDAsyncSocketReadMaxedOutError, // Reached set maxLength without completing - GCDAsyncSocketClosedError, // The remote peer closed the connection - GCDAsyncSocketOtherError, // Description provided in userInfo -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - -@interface GCDAsyncSocket : NSObject - -/** - * GCDAsyncSocket uses the standard delegate paradigm, - * but executes all delegate callbacks on a given delegate dispatch queue. - * This allows for maximum concurrency, while at the same time providing easy thread safety. - * - * You MUST set a delegate AND delegate dispatch queue before attempting to - * use the socket, or you will get an error. - * - * The socket queue is optional. - * If you pass NULL, GCDAsyncSocket will automatically create it's own socket queue. - * If you choose to provide a socket queue, the socket queue must not be a concurrent queue. - * If you choose to provide a socket queue, and the socket queue has a configured target queue, - * then please see the discussion for the method markSocketQueueTargetQueue. - * - * The delegate queue and socket queue can optionally be the same. -**/ -- (instancetype)init; -- (instancetype)initWithSocketQueue:(nullable dispatch_queue_t)sq; -- (instancetype)initWithDelegate:(nullable id)aDelegate delegateQueue:(nullable dispatch_queue_t)dq; -- (instancetype)initWithDelegate:(nullable id)aDelegate delegateQueue:(nullable dispatch_queue_t)dq socketQueue:(nullable dispatch_queue_t)sq NS_DESIGNATED_INITIALIZER; - -/** - * Create GCDAsyncSocket from already connect BSD socket file descriptor -**/ -+ (nullable instancetype)socketFromConnectedSocketFD:(int)socketFD socketQueue:(nullable dispatch_queue_t)sq error:(NSError**)error; - -+ (nullable instancetype)socketFromConnectedSocketFD:(int)socketFD delegate:(nullable id)aDelegate delegateQueue:(nullable dispatch_queue_t)dq error:(NSError**)error; - -+ (nullable instancetype)socketFromConnectedSocketFD:(int)socketFD delegate:(nullable id)aDelegate delegateQueue:(nullable dispatch_queue_t)dq socketQueue:(nullable dispatch_queue_t)sq error:(NSError **)error; - -#pragma mark Configuration - -@property (atomic, weak, readwrite, nullable) id delegate; -#if OS_OBJECT_USE_OBJC -@property (atomic, strong, readwrite, nullable) dispatch_queue_t delegateQueue; -#else -@property (atomic, assign, readwrite, nullable) dispatch_queue_t delegateQueue; -#endif - -- (void)getDelegate:(id __nullable * __nullable)delegatePtr delegateQueue:(dispatch_queue_t __nullable * __nullable)delegateQueuePtr; -- (void)setDelegate:(nullable id)delegate delegateQueue:(nullable dispatch_queue_t)delegateQueue; - -/** - * If you are setting the delegate to nil within the delegate's dealloc method, - * you may need to use the synchronous versions below. -**/ -- (void)synchronouslySetDelegate:(nullable id)delegate; -- (void)synchronouslySetDelegateQueue:(nullable dispatch_queue_t)delegateQueue; -- (void)synchronouslySetDelegate:(nullable id)delegate delegateQueue:(nullable dispatch_queue_t)delegateQueue; - -/** - * By default, both IPv4 and IPv6 are enabled. - * - * For accepting incoming connections, this means GCDAsyncSocket automatically supports both protocols, - * and can simulataneously accept incoming connections on either protocol. - * - * For outgoing connections, this means GCDAsyncSocket can connect to remote hosts running either protocol. - * If a DNS lookup returns only IPv4 results, GCDAsyncSocket will automatically use IPv4. - * If a DNS lookup returns only IPv6 results, GCDAsyncSocket will automatically use IPv6. - * If a DNS lookup returns both IPv4 and IPv6 results, the preferred protocol will be chosen. - * By default, the preferred protocol is IPv4, but may be configured as desired. -**/ - -@property (atomic, assign, readwrite, getter=isIPv4Enabled) BOOL IPv4Enabled; -@property (atomic, assign, readwrite, getter=isIPv6Enabled) BOOL IPv6Enabled; - -@property (atomic, assign, readwrite, getter=isIPv4PreferredOverIPv6) BOOL IPv4PreferredOverIPv6; - -/** - * When connecting to both IPv4 and IPv6 using Happy Eyeballs (RFC 6555) https://tools.ietf.org/html/rfc6555 - * this is the delay between connecting to the preferred protocol and the fallback protocol. - * - * Defaults to 300ms. -**/ -@property (atomic, assign, readwrite) NSTimeInterval alternateAddressDelay; - -/** - * User data allows you to associate arbitrary information with the socket. - * This data is not used internally by socket in any way. -**/ -@property (atomic, strong, readwrite, nullable) id userData; - -#pragma mark Accepting - -/** - * Tells the socket to begin listening and accepting connections on the given port. - * When a connection is accepted, a new instance of GCDAsyncSocket will be spawned to handle it, - * and the socket:didAcceptNewSocket: delegate method will be invoked. - * - * The socket will listen on all available interfaces (e.g. wifi, ethernet, etc) -**/ -- (BOOL)acceptOnPort:(uint16_t)port error:(NSError **)errPtr; - -/** - * This method is the same as acceptOnPort:error: with the - * additional option of specifying which interface to listen on. - * - * For example, you could specify that the socket should only accept connections over ethernet, - * and not other interfaces such as wifi. - * - * The interface may be specified by name (e.g. "en1" or "lo0") or by IP address (e.g. "192.168.4.34"). - * You may also use the special strings "localhost" or "loopback" to specify that - * the socket only accept connections from the local machine. - * - * You can see the list of interfaces via the command line utility "ifconfig", - * or programmatically via the getifaddrs() function. - * - * To accept connections on any interface pass nil, or simply use the acceptOnPort:error: method. -**/ -- (BOOL)acceptOnInterface:(nullable NSString *)interface port:(uint16_t)port error:(NSError **)errPtr; - -/** - * Tells the socket to begin listening and accepting connections on the unix domain at the given url. - * When a connection is accepted, a new instance of GCDAsyncSocket will be spawned to handle it, - * and the socket:didAcceptNewSocket: delegate method will be invoked. - * - * The socket will listen on all available interfaces (e.g. wifi, ethernet, etc) - **/ -- (BOOL)acceptOnUrl:(NSURL *)url error:(NSError **)errPtr; - -#pragma mark Connecting - -/** - * Connects to the given host and port. - * - * This method invokes connectToHost:onPort:viaInterface:withTimeout:error: - * and uses the default interface, and no timeout. -**/ -- (BOOL)connectToHost:(NSString *)host onPort:(uint16_t)port error:(NSError **)errPtr; - -/** - * Connects to the given host and port with an optional timeout. - * - * This method invokes connectToHost:onPort:viaInterface:withTimeout:error: and uses the default interface. -**/ -- (BOOL)connectToHost:(NSString *)host - onPort:(uint16_t)port - withTimeout:(NSTimeInterval)timeout - error:(NSError **)errPtr; - -/** - * Connects to the given host & port, via the optional interface, with an optional timeout. - * - * The host may be a domain name (e.g. "deusty.com") or an IP address string (e.g. "192.168.0.2"). - * The host may also be the special strings "localhost" or "loopback" to specify connecting - * to a service on the local machine. - * - * The interface may be a name (e.g. "en1" or "lo0") or the corresponding IP address (e.g. "192.168.4.35"). - * The interface may also be used to specify the local port (see below). - * - * To not time out use a negative time interval. - * - * This method will return NO if an error is detected, and set the error pointer (if one was given). - * Possible errors would be a nil host, invalid interface, or socket is already connected. - * - * If no errors are detected, this method will start a background connect operation and immediately return YES. - * The delegate callbacks are used to notify you when the socket connects, or if the host was unreachable. - * - * Since this class supports queued reads and writes, you can immediately start reading and/or writing. - * All read/write operations will be queued, and upon socket connection, - * the operations will be dequeued and processed in order. - * - * The interface may optionally contain a port number at the end of the string, separated by a colon. - * This allows you to specify the local port that should be used for the outgoing connection. (read paragraph to end) - * To specify both interface and local port: "en1:8082" or "192.168.4.35:2424". - * To specify only local port: ":8082". - * Please note this is an advanced feature, and is somewhat hidden on purpose. - * You should understand that 99.999% of the time you should NOT specify the local port for an outgoing connection. - * If you think you need to, there is a very good chance you have a fundamental misunderstanding somewhere. - * Local ports do NOT need to match remote ports. In fact, they almost never do. - * This feature is here for networking professionals using very advanced techniques. -**/ -- (BOOL)connectToHost:(NSString *)host - onPort:(uint16_t)port - viaInterface:(nullable NSString *)interface - withTimeout:(NSTimeInterval)timeout - error:(NSError **)errPtr; - -/** - * Connects to the given address, specified as a sockaddr structure wrapped in a NSData object. - * For example, a NSData object returned from NSNetService's addresses method. - * - * If you have an existing struct sockaddr you can convert it to a NSData object like so: - * struct sockaddr sa -> NSData *dsa = [NSData dataWithBytes:&remoteAddr length:remoteAddr.sa_len]; - * struct sockaddr *sa -> NSData *dsa = [NSData dataWithBytes:remoteAddr length:remoteAddr->sa_len]; - * - * This method invokes connectToAddress:remoteAddr viaInterface:nil withTimeout:-1 error:errPtr. -**/ -- (BOOL)connectToAddress:(NSData *)remoteAddr error:(NSError **)errPtr; - -/** - * This method is the same as connectToAddress:error: with an additional timeout option. - * To not time out use a negative time interval, or simply use the connectToAddress:error: method. -**/ -- (BOOL)connectToAddress:(NSData *)remoteAddr withTimeout:(NSTimeInterval)timeout error:(NSError **)errPtr; - -/** - * Connects to the given address, using the specified interface and timeout. - * - * The address is specified as a sockaddr structure wrapped in a NSData object. - * For example, a NSData object returned from NSNetService's addresses method. - * - * If you have an existing struct sockaddr you can convert it to a NSData object like so: - * struct sockaddr sa -> NSData *dsa = [NSData dataWithBytes:&remoteAddr length:remoteAddr.sa_len]; - * struct sockaddr *sa -> NSData *dsa = [NSData dataWithBytes:remoteAddr length:remoteAddr->sa_len]; - * - * The interface may be a name (e.g. "en1" or "lo0") or the corresponding IP address (e.g. "192.168.4.35"). - * The interface may also be used to specify the local port (see below). - * - * The timeout is optional. To not time out use a negative time interval. - * - * This method will return NO if an error is detected, and set the error pointer (if one was given). - * Possible errors would be a nil host, invalid interface, or socket is already connected. - * - * If no errors are detected, this method will start a background connect operation and immediately return YES. - * The delegate callbacks are used to notify you when the socket connects, or if the host was unreachable. - * - * Since this class supports queued reads and writes, you can immediately start reading and/or writing. - * All read/write operations will be queued, and upon socket connection, - * the operations will be dequeued and processed in order. - * - * The interface may optionally contain a port number at the end of the string, separated by a colon. - * This allows you to specify the local port that should be used for the outgoing connection. (read paragraph to end) - * To specify both interface and local port: "en1:8082" or "192.168.4.35:2424". - * To specify only local port: ":8082". - * Please note this is an advanced feature, and is somewhat hidden on purpose. - * You should understand that 99.999% of the time you should NOT specify the local port for an outgoing connection. - * If you think you need to, there is a very good chance you have a fundamental misunderstanding somewhere. - * Local ports do NOT need to match remote ports. In fact, they almost never do. - * This feature is here for networking professionals using very advanced techniques. -**/ -- (BOOL)connectToAddress:(NSData *)remoteAddr - viaInterface:(nullable NSString *)interface - withTimeout:(NSTimeInterval)timeout - error:(NSError **)errPtr; -/** - * Connects to the unix domain socket at the given url, using the specified timeout. - */ -- (BOOL)connectToUrl:(NSURL *)url withTimeout:(NSTimeInterval)timeout error:(NSError **)errPtr; - -/** - * Iterates over the given NetService's addresses in order, and invokes connectToAddress:error:. Stops at the - * first invocation that succeeds and returns YES; otherwise returns NO. - */ -- (BOOL)connectToNetService:(NSNetService *)netService error:(NSError **)errPtr; - -#pragma mark Disconnecting - -/** - * Disconnects immediately (synchronously). Any pending reads or writes are dropped. - * - * If the socket is not already disconnected, an invocation to the socketDidDisconnect:withError: delegate method - * will be queued onto the delegateQueue asynchronously (behind any previously queued delegate methods). - * In other words, the disconnected delegate method will be invoked sometime shortly after this method returns. - * - * Please note the recommended way of releasing a GCDAsyncSocket instance (e.g. in a dealloc method) - * [asyncSocket setDelegate:nil]; - * [asyncSocket disconnect]; - * [asyncSocket release]; - * - * If you plan on disconnecting the socket, and then immediately asking it to connect again, - * you'll likely want to do so like this: - * [asyncSocket setDelegate:nil]; - * [asyncSocket disconnect]; - * [asyncSocket setDelegate:self]; - * [asyncSocket connect...]; -**/ -- (void)disconnect; - -/** - * Disconnects after all pending reads have completed. - * After calling this, the read and write methods will do nothing. - * The socket will disconnect even if there are still pending writes. -**/ -- (void)disconnectAfterReading; - -/** - * Disconnects after all pending writes have completed. - * After calling this, the read and write methods will do nothing. - * The socket will disconnect even if there are still pending reads. -**/ -- (void)disconnectAfterWriting; - -/** - * Disconnects after all pending reads and writes have completed. - * After calling this, the read and write methods will do nothing. -**/ -- (void)disconnectAfterReadingAndWriting; - -#pragma mark Diagnostics - -/** - * Returns whether the socket is disconnected or connected. - * - * A disconnected socket may be recycled. - * That is, it can be used again for connecting or listening. - * - * If a socket is in the process of connecting, it may be neither disconnected nor connected. -**/ -@property (atomic, readonly) BOOL isDisconnected; -@property (atomic, readonly) BOOL isConnected; - -/** - * Returns the local or remote host and port to which this socket is connected, or nil and 0 if not connected. - * The host will be an IP address. -**/ -@property (atomic, readonly, nullable) NSString *connectedHost; -@property (atomic, readonly) uint16_t connectedPort; -@property (atomic, readonly, nullable) NSURL *connectedUrl; - -@property (atomic, readonly, nullable) NSString *localHost; -@property (atomic, readonly) uint16_t localPort; - -/** - * Returns the local or remote address to which this socket is connected, - * specified as a sockaddr structure wrapped in a NSData object. - * - * @seealso connectedHost - * @seealso connectedPort - * @seealso localHost - * @seealso localPort -**/ -@property (atomic, readonly, nullable) NSData *connectedAddress; -@property (atomic, readonly, nullable) NSData *localAddress; - -/** - * Returns whether the socket is IPv4 or IPv6. - * An accepting socket may be both. -**/ -@property (atomic, readonly) BOOL isIPv4; -@property (atomic, readonly) BOOL isIPv6; - -/** - * Returns whether or not the socket has been secured via SSL/TLS. - * - * See also the startTLS method. -**/ -@property (atomic, readonly) BOOL isSecure; - -#pragma mark Reading - -// The readData and writeData methods won't block (they are asynchronous). -// -// When a read is complete the socket:didReadData:withTag: delegate method is dispatched on the delegateQueue. -// When a write is complete the socket:didWriteDataWithTag: delegate method is dispatched on the delegateQueue. -// -// You may optionally set a timeout for any read/write operation. (To not timeout, use a negative time interval.) -// If a read/write opertion times out, the corresponding "socket:shouldTimeout..." delegate method -// is called to optionally allow you to extend the timeout. -// Upon a timeout, the "socket:didDisconnectWithError:" method is called -// -// The tag is for your convenience. -// You can use it as an array index, step number, state id, pointer, etc. - -/** - * Reads the first available bytes that become available on the socket. - * - * If the timeout value is negative, the read operation will not use a timeout. -**/ -- (void)readDataWithTimeout:(NSTimeInterval)timeout tag:(long)tag; - -/** - * Reads the first available bytes that become available on the socket. - * The bytes will be appended to the given byte buffer starting at the given offset. - * The given buffer will automatically be increased in size if needed. - * - * If the timeout value is negative, the read operation will not use a timeout. - * If the buffer is nil, the socket will create a buffer for you. - * - * If the bufferOffset is greater than the length of the given buffer, - * the method will do nothing, and the delegate will not be called. - * - * If you pass a buffer, you must not alter it in any way while the socket is using it. - * After completion, the data returned in socket:didReadData:withTag: will be a subset of the given buffer. - * That is, it will reference the bytes that were appended to the given buffer via - * the method [NSData dataWithBytesNoCopy:length:freeWhenDone:NO]. -**/ -- (void)readDataWithTimeout:(NSTimeInterval)timeout - buffer:(nullable NSMutableData *)buffer - bufferOffset:(NSUInteger)offset - tag:(long)tag; - -/** - * Reads the first available bytes that become available on the socket. - * The bytes will be appended to the given byte buffer starting at the given offset. - * The given buffer will automatically be increased in size if needed. - * A maximum of length bytes will be read. - * - * If the timeout value is negative, the read operation will not use a timeout. - * If the buffer is nil, a buffer will automatically be created for you. - * If maxLength is zero, no length restriction is enforced. - * - * If the bufferOffset is greater than the length of the given buffer, - * the method will do nothing, and the delegate will not be called. - * - * If you pass a buffer, you must not alter it in any way while the socket is using it. - * After completion, the data returned in socket:didReadData:withTag: will be a subset of the given buffer. - * That is, it will reference the bytes that were appended to the given buffer via - * the method [NSData dataWithBytesNoCopy:length:freeWhenDone:NO]. -**/ -- (void)readDataWithTimeout:(NSTimeInterval)timeout - buffer:(nullable NSMutableData *)buffer - bufferOffset:(NSUInteger)offset - maxLength:(NSUInteger)length - tag:(long)tag; - -/** - * Reads the given number of bytes. - * - * If the timeout value is negative, the read operation will not use a timeout. - * - * If the length is 0, this method does nothing and the delegate is not called. -**/ -- (void)readDataToLength:(NSUInteger)length withTimeout:(NSTimeInterval)timeout tag:(long)tag; - -/** - * Reads the given number of bytes. - * The bytes will be appended to the given byte buffer starting at the given offset. - * The given buffer will automatically be increased in size if needed. - * - * If the timeout value is negative, the read operation will not use a timeout. - * If the buffer is nil, a buffer will automatically be created for you. - * - * If the length is 0, this method does nothing and the delegate is not called. - * If the bufferOffset is greater than the length of the given buffer, - * the method will do nothing, and the delegate will not be called. - * - * If you pass a buffer, you must not alter it in any way while AsyncSocket is using it. - * After completion, the data returned in socket:didReadData:withTag: will be a subset of the given buffer. - * That is, it will reference the bytes that were appended to the given buffer via - * the method [NSData dataWithBytesNoCopy:length:freeWhenDone:NO]. -**/ -- (void)readDataToLength:(NSUInteger)length - withTimeout:(NSTimeInterval)timeout - buffer:(nullable NSMutableData *)buffer - bufferOffset:(NSUInteger)offset - tag:(long)tag; - -/** - * Reads bytes until (and including) the passed "data" parameter, which acts as a separator. - * - * If the timeout value is negative, the read operation will not use a timeout. - * - * If you pass nil or zero-length data as the "data" parameter, - * the method will do nothing (except maybe print a warning), and the delegate will not be called. - * - * To read a line from the socket, use the line separator (e.g. CRLF for HTTP, see below) as the "data" parameter. - * If you're developing your own custom protocol, be sure your separator can not occur naturally as - * part of the data between separators. - * For example, imagine you want to send several small documents over a socket. - * Using CRLF as a separator is likely unwise, as a CRLF could easily exist within the documents. - * In this particular example, it would be better to use a protocol similar to HTTP with - * a header that includes the length of the document. - * Also be careful that your separator cannot occur naturally as part of the encoding for a character. - * - * The given data (separator) parameter should be immutable. - * For performance reasons, the socket will retain it, not copy it. - * So if it is immutable, don't modify it while the socket is using it. -**/ -- (void)readDataToData:(nullable NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag; - -/** - * Reads bytes until (and including) the passed "data" parameter, which acts as a separator. - * The bytes will be appended to the given byte buffer starting at the given offset. - * The given buffer will automatically be increased in size if needed. - * - * If the timeout value is negative, the read operation will not use a timeout. - * If the buffer is nil, a buffer will automatically be created for you. - * - * If the bufferOffset is greater than the length of the given buffer, - * the method will do nothing (except maybe print a warning), and the delegate will not be called. - * - * If you pass a buffer, you must not alter it in any way while the socket is using it. - * After completion, the data returned in socket:didReadData:withTag: will be a subset of the given buffer. - * That is, it will reference the bytes that were appended to the given buffer via - * the method [NSData dataWithBytesNoCopy:length:freeWhenDone:NO]. - * - * To read a line from the socket, use the line separator (e.g. CRLF for HTTP, see below) as the "data" parameter. - * If you're developing your own custom protocol, be sure your separator can not occur naturally as - * part of the data between separators. - * For example, imagine you want to send several small documents over a socket. - * Using CRLF as a separator is likely unwise, as a CRLF could easily exist within the documents. - * In this particular example, it would be better to use a protocol similar to HTTP with - * a header that includes the length of the document. - * Also be careful that your separator cannot occur naturally as part of the encoding for a character. - * - * The given data (separator) parameter should be immutable. - * For performance reasons, the socket will retain it, not copy it. - * So if it is immutable, don't modify it while the socket is using it. -**/ -- (void)readDataToData:(NSData *)data - withTimeout:(NSTimeInterval)timeout - buffer:(nullable NSMutableData *)buffer - bufferOffset:(NSUInteger)offset - tag:(long)tag; - -/** - * Reads bytes until (and including) the passed "data" parameter, which acts as a separator. - * - * If the timeout value is negative, the read operation will not use a timeout. - * - * If maxLength is zero, no length restriction is enforced. - * Otherwise if maxLength bytes are read without completing the read, - * it is treated similarly to a timeout - the socket is closed with a GCDAsyncSocketReadMaxedOutError. - * The read will complete successfully if exactly maxLength bytes are read and the given data is found at the end. - * - * If you pass nil or zero-length data as the "data" parameter, - * the method will do nothing (except maybe print a warning), and the delegate will not be called. - * If you pass a maxLength parameter that is less than the length of the data parameter, - * the method will do nothing (except maybe print a warning), and the delegate will not be called. - * - * To read a line from the socket, use the line separator (e.g. CRLF for HTTP, see below) as the "data" parameter. - * If you're developing your own custom protocol, be sure your separator can not occur naturally as - * part of the data between separators. - * For example, imagine you want to send several small documents over a socket. - * Using CRLF as a separator is likely unwise, as a CRLF could easily exist within the documents. - * In this particular example, it would be better to use a protocol similar to HTTP with - * a header that includes the length of the document. - * Also be careful that your separator cannot occur naturally as part of the encoding for a character. - * - * The given data (separator) parameter should be immutable. - * For performance reasons, the socket will retain it, not copy it. - * So if it is immutable, don't modify it while the socket is using it. -**/ -- (void)readDataToData:(NSData *)data withTimeout:(NSTimeInterval)timeout maxLength:(NSUInteger)length tag:(long)tag; - -/** - * Reads bytes until (and including) the passed "data" parameter, which acts as a separator. - * The bytes will be appended to the given byte buffer starting at the given offset. - * The given buffer will automatically be increased in size if needed. - * - * If the timeout value is negative, the read operation will not use a timeout. - * If the buffer is nil, a buffer will automatically be created for you. - * - * If maxLength is zero, no length restriction is enforced. - * Otherwise if maxLength bytes are read without completing the read, - * it is treated similarly to a timeout - the socket is closed with a GCDAsyncSocketReadMaxedOutError. - * The read will complete successfully if exactly maxLength bytes are read and the given data is found at the end. - * - * If you pass a maxLength parameter that is less than the length of the data (separator) parameter, - * the method will do nothing (except maybe print a warning), and the delegate will not be called. - * If the bufferOffset is greater than the length of the given buffer, - * the method will do nothing (except maybe print a warning), and the delegate will not be called. - * - * If you pass a buffer, you must not alter it in any way while the socket is using it. - * After completion, the data returned in socket:didReadData:withTag: will be a subset of the given buffer. - * That is, it will reference the bytes that were appended to the given buffer via - * the method [NSData dataWithBytesNoCopy:length:freeWhenDone:NO]. - * - * To read a line from the socket, use the line separator (e.g. CRLF for HTTP, see below) as the "data" parameter. - * If you're developing your own custom protocol, be sure your separator can not occur naturally as - * part of the data between separators. - * For example, imagine you want to send several small documents over a socket. - * Using CRLF as a separator is likely unwise, as a CRLF could easily exist within the documents. - * In this particular example, it would be better to use a protocol similar to HTTP with - * a header that includes the length of the document. - * Also be careful that your separator cannot occur naturally as part of the encoding for a character. - * - * The given data (separator) parameter should be immutable. - * For performance reasons, the socket will retain it, not copy it. - * So if it is immutable, don't modify it while the socket is using it. -**/ -- (void)readDataToData:(NSData *)data - withTimeout:(NSTimeInterval)timeout - buffer:(nullable NSMutableData *)buffer - bufferOffset:(NSUInteger)offset - maxLength:(NSUInteger)length - tag:(long)tag; - -/** - * Returns progress of the current read, from 0.0 to 1.0, or NaN if no current read (use isnan() to check). - * The parameters "tag", "done" and "total" will be filled in if they aren't NULL. -**/ -- (float)progressOfReadReturningTag:(nullable long *)tagPtr bytesDone:(nullable NSUInteger *)donePtr total:(nullable NSUInteger *)totalPtr; - -#pragma mark Writing - -/** - * Writes data to the socket, and calls the delegate when finished. - * - * If you pass in nil or zero-length data, this method does nothing and the delegate will not be called. - * If the timeout value is negative, the write operation will not use a timeout. - * - * Thread-Safety Note: - * If the given data parameter is mutable (NSMutableData) then you MUST NOT alter the data while - * the socket is writing it. In other words, it's not safe to alter the data until after the delegate method - * socket:didWriteDataWithTag: is invoked signifying that this particular write operation has completed. - * This is due to the fact that GCDAsyncSocket does NOT copy the data. It simply retains it. - * This is for performance reasons. Often times, if NSMutableData is passed, it is because - * a request/response was built up in memory. Copying this data adds an unwanted/unneeded overhead. - * If you need to write data from an immutable buffer, and you need to alter the buffer before the socket - * completes writing the bytes (which is NOT immediately after this method returns, but rather at a later time - * when the delegate method notifies you), then you should first copy the bytes, and pass the copy to this method. -**/ -- (void)writeData:(nullable NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag; - -/** - * Returns progress of the current write, from 0.0 to 1.0, or NaN if no current write (use isnan() to check). - * The parameters "tag", "done" and "total" will be filled in if they aren't NULL. -**/ -- (float)progressOfWriteReturningTag:(nullable long *)tagPtr bytesDone:(nullable NSUInteger *)donePtr total:(nullable NSUInteger *)totalPtr; - -#pragma mark Security - -/** - * Secures the connection using SSL/TLS. - * - * This method may be called at any time, and the TLS handshake will occur after all pending reads and writes - * are finished. This allows one the option of sending a protocol dependent StartTLS message, and queuing - * the upgrade to TLS at the same time, without having to wait for the write to finish. - * Any reads or writes scheduled after this method is called will occur over the secured connection. - * - * ==== The available TOP-LEVEL KEYS are: - * - * - GCDAsyncSocketManuallyEvaluateTrust - * The value must be of type NSNumber, encapsulating a BOOL value. - * If you set this to YES, then the underlying SecureTransport system will not evaluate the SecTrustRef of the peer. - * Instead it will pause at the moment evaulation would typically occur, - * and allow us to handle the security evaluation however we see fit. - * So GCDAsyncSocket will invoke the delegate method socket:shouldTrustPeer: passing the SecTrustRef. - * - * Note that if you set this option, then all other configuration keys are ignored. - * Evaluation will be completely up to you during the socket:didReceiveTrust:completionHandler: delegate method. - * - * For more information on trust evaluation see: - * Apple's Technical Note TN2232 - HTTPS Server Trust Evaluation - * https://developer.apple.com/library/ios/technotes/tn2232/_index.html - * - * If unspecified, the default value is NO. - * - * - GCDAsyncSocketUseCFStreamForTLS (iOS only) - * The value must be of type NSNumber, encapsulating a BOOL value. - * By default GCDAsyncSocket will use the SecureTransport layer to perform encryption. - * This gives us more control over the security protocol (many more configuration options), - * plus it allows us to optimize things like sys calls and buffer allocation. - * - * However, if you absolutely must, you can instruct GCDAsyncSocket to use the old-fashioned encryption - * technique by going through the CFStream instead. So instead of using SecureTransport, GCDAsyncSocket - * will instead setup a CFRead/CFWriteStream. And then set the kCFStreamPropertySSLSettings property - * (via CFReadStreamSetProperty / CFWriteStreamSetProperty) and will pass the given options to this method. - * - * Thus all the other keys in the given dictionary will be ignored by GCDAsyncSocket, - * and will passed directly CFReadStreamSetProperty / CFWriteStreamSetProperty. - * For more infomation on these keys, please see the documentation for kCFStreamPropertySSLSettings. - * - * If unspecified, the default value is NO. - * - * ==== The available CONFIGURATION KEYS are: - * - * - kCFStreamSSLPeerName - * The value must be of type NSString. - * It should match the name in the X.509 certificate given by the remote party. - * See Apple's documentation for SSLSetPeerDomainName. - * - * - kCFStreamSSLCertificates - * The value must be of type NSArray. - * See Apple's documentation for SSLSetCertificate. - * - * - kCFStreamSSLIsServer - * The value must be of type NSNumber, encapsulationg a BOOL value. - * See Apple's documentation for SSLCreateContext for iOS. - * This is optional for iOS. If not supplied, a NO value is the default. - * This is not needed for Mac OS X, and the value is ignored. - * - * - GCDAsyncSocketSSLPeerID - * The value must be of type NSData. - * You must set this value if you want to use TLS session resumption. - * See Apple's documentation for SSLSetPeerID. - * - * - GCDAsyncSocketSSLProtocolVersionMin - * - GCDAsyncSocketSSLProtocolVersionMax - * The value(s) must be of type NSNumber, encapsulting a SSLProtocol value. - * See Apple's documentation for SSLSetProtocolVersionMin & SSLSetProtocolVersionMax. - * See also the SSLProtocol typedef. - * - * - GCDAsyncSocketSSLSessionOptionFalseStart - * The value must be of type NSNumber, encapsulating a BOOL value. - * See Apple's documentation for kSSLSessionOptionFalseStart. - * - * - GCDAsyncSocketSSLSessionOptionSendOneByteRecord - * The value must be of type NSNumber, encapsulating a BOOL value. - * See Apple's documentation for kSSLSessionOptionSendOneByteRecord. - * - * - GCDAsyncSocketSSLCipherSuites - * The values must be of type NSArray. - * Each item within the array must be a NSNumber, encapsulating an SSLCipherSuite. - * See Apple's documentation for SSLSetEnabledCiphers. - * See also the SSLCipherSuite typedef. - * - * - GCDAsyncSocketSSLDiffieHellmanParameters (Mac OS X only) - * The value must be of type NSData. - * See Apple's documentation for SSLSetDiffieHellmanParams. - * - * ==== The following UNAVAILABLE KEYS are: (with throw an exception) - * - * - kCFStreamSSLAllowsAnyRoot (UNAVAILABLE) - * You MUST use manual trust evaluation instead (see GCDAsyncSocketManuallyEvaluateTrust). - * Corresponding deprecated method: SSLSetAllowsAnyRoot - * - * - kCFStreamSSLAllowsExpiredRoots (UNAVAILABLE) - * You MUST use manual trust evaluation instead (see GCDAsyncSocketManuallyEvaluateTrust). - * Corresponding deprecated method: SSLSetAllowsExpiredRoots - * - * - kCFStreamSSLAllowsExpiredCertificates (UNAVAILABLE) - * You MUST use manual trust evaluation instead (see GCDAsyncSocketManuallyEvaluateTrust). - * Corresponding deprecated method: SSLSetAllowsExpiredCerts - * - * - kCFStreamSSLValidatesCertificateChain (UNAVAILABLE) - * You MUST use manual trust evaluation instead (see GCDAsyncSocketManuallyEvaluateTrust). - * Corresponding deprecated method: SSLSetEnableCertVerify - * - * - kCFStreamSSLLevel (UNAVAILABLE) - * You MUST use GCDAsyncSocketSSLProtocolVersionMin & GCDAsyncSocketSSLProtocolVersionMin instead. - * Corresponding deprecated method: SSLSetProtocolVersionEnabled - * - * - * Please refer to Apple's documentation for corresponding SSLFunctions. - * - * If you pass in nil or an empty dictionary, the default settings will be used. - * - * IMPORTANT SECURITY NOTE: - * The default settings will check to make sure the remote party's certificate is signed by a - * trusted 3rd party certificate agency (e.g. verisign) and that the certificate is not expired. - * However it will not verify the name on the certificate unless you - * give it a name to verify against via the kCFStreamSSLPeerName key. - * The security implications of this are important to understand. - * Imagine you are attempting to create a secure connection to MySecureServer.com, - * but your socket gets directed to MaliciousServer.com because of a hacked DNS server. - * If you simply use the default settings, and MaliciousServer.com has a valid certificate, - * the default settings will not detect any problems since the certificate is valid. - * To properly secure your connection in this particular scenario you - * should set the kCFStreamSSLPeerName property to "MySecureServer.com". - * - * You can also perform additional validation in socketDidSecure. -**/ -- (void)startTLS:(nullable NSDictionary *)tlsSettings; - -#pragma mark Advanced - -/** - * Traditionally sockets are not closed until the conversation is over. - * However, it is technically possible for the remote enpoint to close its write stream. - * Our socket would then be notified that there is no more data to be read, - * but our socket would still be writeable and the remote endpoint could continue to receive our data. - * - * The argument for this confusing functionality stems from the idea that a client could shut down its - * write stream after sending a request to the server, thus notifying the server there are to be no further requests. - * In practice, however, this technique did little to help server developers. - * - * To make matters worse, from a TCP perspective there is no way to tell the difference from a read stream close - * and a full socket close. They both result in the TCP stack receiving a FIN packet. The only way to tell - * is by continuing to write to the socket. If it was only a read stream close, then writes will continue to work. - * Otherwise an error will be occur shortly (when the remote end sends us a RST packet). - * - * In addition to the technical challenges and confusion, many high level socket/stream API's provide - * no support for dealing with the problem. If the read stream is closed, the API immediately declares the - * socket to be closed, and shuts down the write stream as well. In fact, this is what Apple's CFStream API does. - * It might sound like poor design at first, but in fact it simplifies development. - * - * The vast majority of the time if the read stream is closed it's because the remote endpoint closed its socket. - * Thus it actually makes sense to close the socket at this point. - * And in fact this is what most networking developers want and expect to happen. - * However, if you are writing a server that interacts with a plethora of clients, - * you might encounter a client that uses the discouraged technique of shutting down its write stream. - * If this is the case, you can set this property to NO, - * and make use of the socketDidCloseReadStream delegate method. - * - * The default value is YES. -**/ -@property (atomic, assign, readwrite) BOOL autoDisconnectOnClosedReadStream; - -/** - * GCDAsyncSocket maintains thread safety by using an internal serial dispatch_queue. - * In most cases, the instance creates this queue itself. - * However, to allow for maximum flexibility, the internal queue may be passed in the init method. - * This allows for some advanced options such as controlling socket priority via target queues. - * However, when one begins to use target queues like this, they open the door to some specific deadlock issues. - * - * For example, imagine there are 2 queues: - * dispatch_queue_t socketQueue; - * dispatch_queue_t socketTargetQueue; - * - * If you do this (pseudo-code): - * socketQueue.targetQueue = socketTargetQueue; - * - * Then all socketQueue operations will actually get run on the given socketTargetQueue. - * This is fine and works great in most situations. - * But if you run code directly from within the socketTargetQueue that accesses the socket, - * you could potentially get deadlock. Imagine the following code: - * - * - (BOOL)socketHasSomething - * { - * __block BOOL result = NO; - * dispatch_block_t block = ^{ - * result = [self someInternalMethodToBeRunOnlyOnSocketQueue]; - * } - * if (is_executing_on_queue(socketQueue)) - * block(); - * else - * dispatch_sync(socketQueue, block); - * - * return result; - * } - * - * What happens if you call this method from the socketTargetQueue? The result is deadlock. - * This is because the GCD API offers no mechanism to discover a queue's targetQueue. - * Thus we have no idea if our socketQueue is configured with a targetQueue. - * If we had this information, we could easily avoid deadlock. - * But, since these API's are missing or unfeasible, you'll have to explicitly set it. - * - * IF you pass a socketQueue via the init method, - * AND you've configured the passed socketQueue with a targetQueue, - * THEN you should pass the end queue in the target hierarchy. - * - * For example, consider the following queue hierarchy: - * socketQueue -> ipQueue -> moduleQueue - * - * This example demonstrates priority shaping within some server. - * All incoming client connections from the same IP address are executed on the same target queue. - * And all connections for a particular module are executed on the same target queue. - * Thus, the priority of all networking for the entire module can be changed on the fly. - * Additionally, networking traffic from a single IP cannot monopolize the module. - * - * Here's how you would accomplish something like that: - * - (dispatch_queue_t)newSocketQueueForConnectionFromAddress:(NSData *)address onSocket:(GCDAsyncSocket *)sock - * { - * dispatch_queue_t socketQueue = dispatch_queue_create("", NULL); - * dispatch_queue_t ipQueue = [self ipQueueForAddress:address]; - * - * dispatch_set_target_queue(socketQueue, ipQueue); - * dispatch_set_target_queue(iqQueue, moduleQueue); - * - * return socketQueue; - * } - * - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket - * { - * [clientConnections addObject:newSocket]; - * [newSocket markSocketQueueTargetQueue:moduleQueue]; - * } - * - * Note: This workaround is ONLY needed if you intend to execute code directly on the ipQueue or moduleQueue. - * This is often NOT the case, as such queues are used solely for execution shaping. -**/ -- (void)markSocketQueueTargetQueue:(dispatch_queue_t)socketQueuesPreConfiguredTargetQueue; -- (void)unmarkSocketQueueTargetQueue:(dispatch_queue_t)socketQueuesPreviouslyConfiguredTargetQueue; - -/** - * It's not thread-safe to access certain variables from outside the socket's internal queue. - * - * For example, the socket file descriptor. - * File descriptors are simply integers which reference an index in the per-process file table. - * However, when one requests a new file descriptor (by opening a file or socket), - * the file descriptor returned is guaranteed to be the lowest numbered unused descriptor. - * So if we're not careful, the following could be possible: - * - * - Thread A invokes a method which returns the socket's file descriptor. - * - The socket is closed via the socket's internal queue on thread B. - * - Thread C opens a file, and subsequently receives the file descriptor that was previously the socket's FD. - * - Thread A is now accessing/altering the file instead of the socket. - * - * In addition to this, other variables are not actually objects, - * and thus cannot be retained/released or even autoreleased. - * An example is the sslContext, of type SSLContextRef, which is actually a malloc'd struct. - * - * Although there are internal variables that make it difficult to maintain thread-safety, - * it is important to provide access to these variables - * to ensure this class can be used in a wide array of environments. - * This method helps to accomplish this by invoking the current block on the socket's internal queue. - * The methods below can be invoked from within the block to access - * those generally thread-unsafe internal variables in a thread-safe manner. - * The given block will be invoked synchronously on the socket's internal queue. - * - * If you save references to any protected variables and use them outside the block, you do so at your own peril. -**/ -- (void)performBlock:(dispatch_block_t)block; - -/** - * These methods are only available from within the context of a performBlock: invocation. - * See the documentation for the performBlock: method above. - * - * Provides access to the socket's file descriptor(s). - * If the socket is a server socket (is accepting incoming connections), - * it might actually have multiple internal socket file descriptors - one for IPv4 and one for IPv6. -**/ -- (int)socketFD; -- (int)socket4FD; -- (int)socket6FD; - -#if TARGET_OS_IPHONE - -/** - * These methods are only available from within the context of a performBlock: invocation. - * See the documentation for the performBlock: method above. - * - * Provides access to the socket's internal CFReadStream/CFWriteStream. - * - * These streams are only used as workarounds for specific iOS shortcomings: - * - * - Apple has decided to keep the SecureTransport framework private is iOS. - * This means the only supplied way to do SSL/TLS is via CFStream or some other API layered on top of it. - * Thus, in order to provide SSL/TLS support on iOS we are forced to rely on CFStream, - * instead of the preferred and faster and more powerful SecureTransport. - * - * - If a socket doesn't have backgrounding enabled, and that socket is closed while the app is backgrounded, - * Apple only bothers to notify us via the CFStream API. - * The faster and more powerful GCD API isn't notified properly in this case. - * - * See also: (BOOL)enableBackgroundingOnSocket -**/ -- (nullable CFReadStreamRef)readStream; -- (nullable CFWriteStreamRef)writeStream; - -/** - * This method is only available from within the context of a performBlock: invocation. - * See the documentation for the performBlock: method above. - * - * Configures the socket to allow it to operate when the iOS application has been backgrounded. - * In other words, this method creates a read & write stream, and invokes: - * - * CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP); - * CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP); - * - * Returns YES if successful, NO otherwise. - * - * Note: Apple does not officially support backgrounding server sockets. - * That is, if your socket is accepting incoming connections, Apple does not officially support - * allowing iOS applications to accept incoming connections while an app is backgrounded. - * - * Example usage: - * - * - (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port - * { - * [asyncSocket performBlock:^{ - * [asyncSocket enableBackgroundingOnSocket]; - * }]; - * } -**/ -- (BOOL)enableBackgroundingOnSocket; - -#endif - -/** - * This method is only available from within the context of a performBlock: invocation. - * See the documentation for the performBlock: method above. - * - * Provides access to the socket's SSLContext, if SSL/TLS has been started on the socket. -**/ -- (nullable SSLContextRef)sslContext; - -#pragma mark Utilities - -/** - * The address lookup utility used by the class. - * This method is synchronous, so it's recommended you use it on a background thread/queue. - * - * The special strings "localhost" and "loopback" return the loopback address for IPv4 and IPv6. - * - * @returns - * A mutable array with all IPv4 and IPv6 addresses returned by getaddrinfo. - * The addresses are specifically for TCP connections. - * You can filter the addresses, if needed, using the other utility methods provided by the class. -**/ -+ (nullable NSMutableArray *)lookupHost:(NSString *)host port:(uint16_t)port error:(NSError **)errPtr; - -/** - * Extracting host and port information from raw address data. -**/ - -+ (nullable NSString *)hostFromAddress:(NSData *)address; -+ (uint16_t)portFromAddress:(NSData *)address; - -+ (BOOL)isIPv4Address:(NSData *)address; -+ (BOOL)isIPv6Address:(NSData *)address; - -+ (BOOL)getHost:( NSString * __nullable * __nullable)hostPtr port:(nullable uint16_t *)portPtr fromAddress:(NSData *)address; - -+ (BOOL)getHost:(NSString * __nullable * __nullable)hostPtr port:(nullable uint16_t *)portPtr family:(nullable sa_family_t *)afPtr fromAddress:(NSData *)address; - -/** - * A few common line separators, for use with the readDataToData:... methods. -**/ -+ (NSData *)CRLFData; // 0x0D0A -+ (NSData *)CRData; // 0x0D -+ (NSData *)LFData; // 0x0A -+ (NSData *)ZeroData; // 0x00 - -@end - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@protocol GCDAsyncSocketDelegate -@optional - -/** - * This method is called immediately prior to socket:didAcceptNewSocket:. - * It optionally allows a listening socket to specify the socketQueue for a new accepted socket. - * If this method is not implemented, or returns NULL, the new accepted socket will create its own default queue. - * - * Since you cannot autorelease a dispatch_queue, - * this method uses the "new" prefix in its name to specify that the returned queue has been retained. - * - * Thus you could do something like this in the implementation: - * return dispatch_queue_create("MyQueue", NULL); - * - * If you are placing multiple sockets on the same queue, - * then care should be taken to increment the retain count each time this method is invoked. - * - * For example, your implementation might look something like this: - * dispatch_retain(myExistingQueue); - * return myExistingQueue; -**/ -- (nullable dispatch_queue_t)newSocketQueueForConnectionFromAddress:(NSData *)address onSocket:(GCDAsyncSocket *)sock; - -/** - * Called when a socket accepts a connection. - * Another socket is automatically spawned to handle it. - * - * You must retain the newSocket if you wish to handle the connection. - * Otherwise the newSocket instance will be released and the spawned connection will be closed. - * - * By default the new socket will have the same delegate and delegateQueue. - * You may, of course, change this at any time. -**/ -- (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket; - -/** - * Called when a socket connects and is ready for reading and writing. - * The host parameter will be an IP address, not a DNS name. -**/ -- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(uint16_t)port; - -/** - * Called when a socket connects and is ready for reading and writing. - * The host parameter will be an IP address, not a DNS name. - **/ -- (void)socket:(GCDAsyncSocket *)sock didConnectToUrl:(NSURL *)url; - -/** - * Called when a socket has completed reading the requested data into memory. - * Not called if there is an error. -**/ -- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag; - -/** - * Called when a socket has read in data, but has not yet completed the read. - * This would occur if using readToData: or readToLength: methods. - * It may be used for things such as updating progress bars. -**/ -- (void)socket:(GCDAsyncSocket *)sock didReadPartialDataOfLength:(NSUInteger)partialLength tag:(long)tag; - -/** - * Called when a socket has completed writing the requested data. Not called if there is an error. -**/ -- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag; - -/** - * Called when a socket has written some data, but has not yet completed the entire write. - * It may be used for things such as updating progress bars. -**/ -- (void)socket:(GCDAsyncSocket *)sock didWritePartialDataOfLength:(NSUInteger)partialLength tag:(long)tag; - -/** - * Called if a read operation has reached its timeout without completing. - * This method allows you to optionally extend the timeout. - * If you return a positive time interval (> 0) the read's timeout will be extended by the given amount. - * If you don't implement this method, or return a non-positive time interval (<= 0) the read will timeout as usual. - * - * The elapsed parameter is the sum of the original timeout, plus any additions previously added via this method. - * The length parameter is the number of bytes that have been read so far for the read operation. - * - * Note that this method may be called multiple times for a single read if you return positive numbers. -**/ -- (NSTimeInterval)socket:(GCDAsyncSocket *)sock shouldTimeoutReadWithTag:(long)tag - elapsed:(NSTimeInterval)elapsed - bytesDone:(NSUInteger)length; - -/** - * Called if a write operation has reached its timeout without completing. - * This method allows you to optionally extend the timeout. - * If you return a positive time interval (> 0) the write's timeout will be extended by the given amount. - * If you don't implement this method, or return a non-positive time interval (<= 0) the write will timeout as usual. - * - * The elapsed parameter is the sum of the original timeout, plus any additions previously added via this method. - * The length parameter is the number of bytes that have been written so far for the write operation. - * - * Note that this method may be called multiple times for a single write if you return positive numbers. -**/ -- (NSTimeInterval)socket:(GCDAsyncSocket *)sock shouldTimeoutWriteWithTag:(long)tag - elapsed:(NSTimeInterval)elapsed - bytesDone:(NSUInteger)length; - -/** - * Conditionally called if the read stream closes, but the write stream may still be writeable. - * - * This delegate method is only called if autoDisconnectOnClosedReadStream has been set to NO. - * See the discussion on the autoDisconnectOnClosedReadStream method for more information. -**/ -- (void)socketDidCloseReadStream:(GCDAsyncSocket *)sock; - -/** - * Called when a socket disconnects with or without error. - * - * If you call the disconnect method, and the socket wasn't already disconnected, - * then an invocation of this delegate method will be enqueued on the delegateQueue - * before the disconnect method returns. - * - * Note: If the GCDAsyncSocket instance is deallocated while it is still connected, - * and the delegate is not also deallocated, then this method will be invoked, - * but the sock parameter will be nil. (It must necessarily be nil since it is no longer available.) - * This is a generally rare, but is possible if one writes code like this: - * - * asyncSocket = nil; // I'm implicitly disconnecting the socket - * - * In this case it may preferrable to nil the delegate beforehand, like this: - * - * asyncSocket.delegate = nil; // Don't invoke my delegate method - * asyncSocket = nil; // I'm implicitly disconnecting the socket - * - * Of course, this depends on how your state machine is configured. -**/ -- (void)socketDidDisconnect:(GCDAsyncSocket *)sock withError:(nullable NSError *)err; - -/** - * Called after the socket has successfully completed SSL/TLS negotiation. - * This method is not called unless you use the provided startTLS method. - * - * If a SSL/TLS negotiation fails (invalid certificate, etc) then the socket will immediately close, - * and the socketDidDisconnect:withError: delegate method will be called with the specific SSL error code. -**/ -- (void)socketDidSecure:(GCDAsyncSocket *)sock; - -/** - * Allows a socket delegate to hook into the TLS handshake and manually validate the peer it's connecting to. - * - * This is only called if startTLS is invoked with options that include: - * - GCDAsyncSocketManuallyEvaluateTrust == YES - * - * Typically the delegate will use SecTrustEvaluate (and related functions) to properly validate the peer. - * - * Note from Apple's documentation: - * Because [SecTrustEvaluate] might look on the network for certificates in the certificate chain, - * [it] might block while attempting network access. You should never call it from your main thread; - * call it only from within a function running on a dispatch queue or on a separate thread. - * - * Thus this method uses a completionHandler block rather than a normal return value. - * The completionHandler block is thread-safe, and may be invoked from a background queue/thread. - * It is safe to invoke the completionHandler block even if the socket has been closed. -**/ -- (void)socket:(GCDAsyncSocket *)sock didReceiveTrust:(SecTrustRef)trust - completionHandler:(void (^)(BOOL shouldTrustPeer))completionHandler; - -@end -NS_ASSUME_NONNULL_END diff --git a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers/GCDAsyncUdpSocket.h b/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers/GCDAsyncUdpSocket.h deleted file mode 100644 index af327e08..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Headers/GCDAsyncUdpSocket.h +++ /dev/null @@ -1,1036 +0,0 @@ -// -// GCDAsyncUdpSocket -// -// This class is in the public domain. -// Originally created by Robbie Hanson of Deusty LLC. -// Updated and maintained by Deusty LLC and the Apple development community. -// -// https://github.com/robbiehanson/CocoaAsyncSocket -// - -#import -#import -#import -#import - -NS_ASSUME_NONNULL_BEGIN -extern NSString *const GCDAsyncUdpSocketException; -extern NSString *const GCDAsyncUdpSocketErrorDomain; - -extern NSString *const GCDAsyncUdpSocketQueueName; -extern NSString *const GCDAsyncUdpSocketThreadName; - -typedef NS_ERROR_ENUM(GCDAsyncUdpSocketErrorDomain, GCDAsyncUdpSocketError) { - GCDAsyncUdpSocketNoError = 0, // Never used - GCDAsyncUdpSocketBadConfigError, // Invalid configuration - GCDAsyncUdpSocketBadParamError, // Invalid parameter was passed - GCDAsyncUdpSocketSendTimeoutError, // A send operation timed out - GCDAsyncUdpSocketClosedError, // The socket was closed - GCDAsyncUdpSocketOtherError, // Description provided in userInfo -}; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -@class GCDAsyncUdpSocket; - -@protocol GCDAsyncUdpSocketDelegate -@optional - -/** - * By design, UDP is a connectionless protocol, and connecting is not needed. - * However, you may optionally choose to connect to a particular host for reasons - * outlined in the documentation for the various connect methods listed above. - * - * This method is called if one of the connect methods are invoked, and the connection is successful. -**/ -- (void)udpSocket:(GCDAsyncUdpSocket *)sock didConnectToAddress:(NSData *)address; - -/** - * By design, UDP is a connectionless protocol, and connecting is not needed. - * However, you may optionally choose to connect to a particular host for reasons - * outlined in the documentation for the various connect methods listed above. - * - * This method is called if one of the connect methods are invoked, and the connection fails. - * This may happen, for example, if a domain name is given for the host and the domain name is unable to be resolved. -**/ -- (void)udpSocket:(GCDAsyncUdpSocket *)sock didNotConnect:(NSError * _Nullable)error; - -/** - * Called when the datagram with the given tag has been sent. -**/ -- (void)udpSocket:(GCDAsyncUdpSocket *)sock didSendDataWithTag:(long)tag; - -/** - * Called if an error occurs while trying to send a datagram. - * This could be due to a timeout, or something more serious such as the data being too large to fit in a sigle packet. -**/ -- (void)udpSocket:(GCDAsyncUdpSocket *)sock didNotSendDataWithTag:(long)tag dueToError:(NSError * _Nullable)error; - -/** - * Called when the socket has received the requested datagram. -**/ -- (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data - fromAddress:(NSData *)address - withFilterContext:(nullable id)filterContext; - -/** - * Called when the socket is closed. -**/ -- (void)udpSocketDidClose:(GCDAsyncUdpSocket *)sock withError:(NSError * _Nullable)error; - -@end - -/** - * You may optionally set a receive filter for the socket. - * A filter can provide several useful features: - * - * 1. Many times udp packets need to be parsed. - * Since the filter can run in its own independent queue, you can parallelize this parsing quite easily. - * The end result is a parallel socket io, datagram parsing, and packet processing. - * - * 2. Many times udp packets are discarded because they are duplicate/unneeded/unsolicited. - * The filter can prevent such packets from arriving at the delegate. - * And because the filter can run in its own independent queue, this doesn't slow down the delegate. - * - * - Since the udp protocol does not guarantee delivery, udp packets may be lost. - * Many protocols built atop udp thus provide various resend/re-request algorithms. - * This sometimes results in duplicate packets arriving. - * A filter may allow you to architect the duplicate detection code to run in parallel to normal processing. - * - * - Since the udp socket may be connectionless, its possible for unsolicited packets to arrive. - * Such packets need to be ignored. - * - * 3. Sometimes traffic shapers are needed to simulate real world environments. - * A filter allows you to write custom code to simulate such environments. - * The ability to code this yourself is especially helpful when your simulated environment - * is more complicated than simple traffic shaping (e.g. simulating a cone port restricted router), - * or the system tools to handle this aren't available (e.g. on a mobile device). - * - * @param data - The packet that was received. - * @param address - The address the data was received from. - * See utilities section for methods to extract info from address. - * @param context - Out parameter you may optionally set, which will then be passed to the delegate method. - * For example, filter block can parse the data and then, - * pass the parsed data to the delegate. - * - * @returns - YES if the received packet should be passed onto the delegate. - * NO if the received packet should be discarded, and not reported to the delegete. - * - * Example: - * - * GCDAsyncUdpSocketReceiveFilterBlock filter = ^BOOL (NSData *data, NSData *address, id *context) { - * - * MyProtocolMessage *msg = [MyProtocol parseMessage:data]; - * - * *context = response; - * return (response != nil); - * }; - * [udpSocket setReceiveFilter:filter withQueue:myParsingQueue]; - * -**/ -typedef BOOL (^GCDAsyncUdpSocketReceiveFilterBlock)(NSData *data, NSData *address, id __nullable * __nonnull context); - -/** - * You may optionally set a send filter for the socket. - * A filter can provide several interesting possibilities: - * - * 1. Optional caching of resolved addresses for domain names. - * The cache could later be consulted, resulting in fewer system calls to getaddrinfo. - * - * 2. Reusable modules of code for bandwidth monitoring. - * - * 3. Sometimes traffic shapers are needed to simulate real world environments. - * A filter allows you to write custom code to simulate such environments. - * The ability to code this yourself is especially helpful when your simulated environment - * is more complicated than simple traffic shaping (e.g. simulating a cone port restricted router), - * or the system tools to handle this aren't available (e.g. on a mobile device). - * - * @param data - The packet that was received. - * @param address - The address the data was received from. - * See utilities section for methods to extract info from address. - * @param tag - The tag that was passed in the send method. - * - * @returns - YES if the packet should actually be sent over the socket. - * NO if the packet should be silently dropped (not sent over the socket). - * - * Regardless of the return value, the delegate will be informed that the packet was successfully sent. - * -**/ -typedef BOOL (^GCDAsyncUdpSocketSendFilterBlock)(NSData *data, NSData *address, long tag); - - -@interface GCDAsyncUdpSocket : NSObject - -/** - * GCDAsyncUdpSocket uses the standard delegate paradigm, - * but executes all delegate callbacks on a given delegate dispatch queue. - * This allows for maximum concurrency, while at the same time providing easy thread safety. - * - * You MUST set a delegate AND delegate dispatch queue before attempting to - * use the socket, or you will get an error. - * - * The socket queue is optional. - * If you pass NULL, GCDAsyncSocket will automatically create its own socket queue. - * If you choose to provide a socket queue, the socket queue must not be a concurrent queue, - * then please see the discussion for the method markSocketQueueTargetQueue. - * - * The delegate queue and socket queue can optionally be the same. -**/ -- (instancetype)init; -- (instancetype)initWithSocketQueue:(nullable dispatch_queue_t)sq; -- (instancetype)initWithDelegate:(nullable id)aDelegate delegateQueue:(nullable dispatch_queue_t)dq; -- (instancetype)initWithDelegate:(nullable id)aDelegate delegateQueue:(nullable dispatch_queue_t)dq socketQueue:(nullable dispatch_queue_t)sq NS_DESIGNATED_INITIALIZER; - -#pragma mark Configuration - -- (nullable id)delegate; -- (void)setDelegate:(nullable id)delegate; -- (void)synchronouslySetDelegate:(nullable id)delegate; - -- (nullable dispatch_queue_t)delegateQueue; -- (void)setDelegateQueue:(nullable dispatch_queue_t)delegateQueue; -- (void)synchronouslySetDelegateQueue:(nullable dispatch_queue_t)delegateQueue; - -- (void)getDelegate:(id __nullable * __nullable)delegatePtr delegateQueue:(dispatch_queue_t __nullable * __nullable)delegateQueuePtr; -- (void)setDelegate:(nullable id)delegate delegateQueue:(nullable dispatch_queue_t)delegateQueue; -- (void)synchronouslySetDelegate:(nullable id)delegate delegateQueue:(nullable dispatch_queue_t)delegateQueue; - -/** - * By default, both IPv4 and IPv6 are enabled. - * - * This means GCDAsyncUdpSocket automatically supports both protocols, - * and can send to IPv4 or IPv6 addresses, - * as well as receive over IPv4 and IPv6. - * - * For operations that require DNS resolution, GCDAsyncUdpSocket supports both IPv4 and IPv6. - * If a DNS lookup returns only IPv4 results, GCDAsyncUdpSocket will automatically use IPv4. - * If a DNS lookup returns only IPv6 results, GCDAsyncUdpSocket will automatically use IPv6. - * If a DNS lookup returns both IPv4 and IPv6 results, then the protocol used depends on the configured preference. - * If IPv4 is preferred, then IPv4 is used. - * If IPv6 is preferred, then IPv6 is used. - * If neutral, then the first IP version in the resolved array will be used. - * - * Starting with Mac OS X 10.7 Lion and iOS 5, the default IP preference is neutral. - * On prior systems the default IP preference is IPv4. - **/ -- (BOOL)isIPv4Enabled; -- (void)setIPv4Enabled:(BOOL)flag; - -- (BOOL)isIPv6Enabled; -- (void)setIPv6Enabled:(BOOL)flag; - -- (BOOL)isIPv4Preferred; -- (BOOL)isIPv6Preferred; -- (BOOL)isIPVersionNeutral; - -- (void)setPreferIPv4; -- (void)setPreferIPv6; -- (void)setIPVersionNeutral; - -/** - * Gets/Sets the maximum size of the buffer that will be allocated for receive operations. - * The default maximum size is 65535 bytes. - * - * The theoretical maximum size of any IPv4 UDP packet is UINT16_MAX = 65535. - * The theoretical maximum size of any IPv6 UDP packet is UINT32_MAX = 4294967295. - * - * Since the OS/GCD notifies us of the size of each received UDP packet, - * the actual allocated buffer size for each packet is exact. - * And in practice the size of UDP packets is generally much smaller than the max. - * Indeed most protocols will send and receive packets of only a few bytes, - * or will set a limit on the size of packets to prevent fragmentation in the IP layer. - * - * If you set the buffer size too small, the sockets API in the OS will silently discard - * any extra data, and you will not be notified of the error. -**/ -- (uint16_t)maxReceiveIPv4BufferSize; -- (void)setMaxReceiveIPv4BufferSize:(uint16_t)max; - -- (uint32_t)maxReceiveIPv6BufferSize; -- (void)setMaxReceiveIPv6BufferSize:(uint32_t)max; - -/** - * Gets/Sets the maximum size of the buffer that will be allocated for send operations. - * The default maximum size is 65535 bytes. - * - * Given that a typical link MTU is 1500 bytes, a large UDP datagram will have to be - * fragmented, and that’s both expensive and risky (if one fragment goes missing, the - * entire datagram is lost). You are much better off sending a large number of smaller - * UDP datagrams, preferably using a path MTU algorithm to avoid fragmentation. - * - * You must set it before the sockt is created otherwise it won't work. - * - **/ -- (uint16_t)maxSendBufferSize; -- (void)setMaxSendBufferSize:(uint16_t)max; - -/** - * User data allows you to associate arbitrary information with the socket. - * This data is not used internally in any way. -**/ -- (nullable id)userData; -- (void)setUserData:(nullable id)arbitraryUserData; - -#pragma mark Diagnostics - -/** - * Returns the local address info for the socket. - * - * The localAddress method returns a sockaddr structure wrapped in a NSData object. - * The localHost method returns the human readable IP address as a string. - * - * Note: Address info may not be available until after the socket has been binded, connected - * or until after data has been sent. -**/ -- (nullable NSData *)localAddress; -- (nullable NSString *)localHost; -- (uint16_t)localPort; - -- (nullable NSData *)localAddress_IPv4; -- (nullable NSString *)localHost_IPv4; -- (uint16_t)localPort_IPv4; - -- (nullable NSData *)localAddress_IPv6; -- (nullable NSString *)localHost_IPv6; -- (uint16_t)localPort_IPv6; - -/** - * Returns the remote address info for the socket. - * - * The connectedAddress method returns a sockaddr structure wrapped in a NSData object. - * The connectedHost method returns the human readable IP address as a string. - * - * Note: Since UDP is connectionless by design, connected address info - * will not be available unless the socket is explicitly connected to a remote host/port. - * If the socket is not connected, these methods will return nil / 0. -**/ -- (nullable NSData *)connectedAddress; -- (nullable NSString *)connectedHost; -- (uint16_t)connectedPort; - -/** - * Returns whether or not this socket has been connected to a single host. - * By design, UDP is a connectionless protocol, and connecting is not needed. - * If connected, the socket will only be able to send/receive data to/from the connected host. -**/ -- (BOOL)isConnected; - -/** - * Returns whether or not this socket has been closed. - * The only way a socket can be closed is if you explicitly call one of the close methods. -**/ -- (BOOL)isClosed; - -/** - * Returns whether or not this socket is IPv4. - * - * By default this will be true, unless: - * - IPv4 is disabled (via setIPv4Enabled:) - * - The socket is explicitly bound to an IPv6 address - * - The socket is connected to an IPv6 address -**/ -- (BOOL)isIPv4; - -/** - * Returns whether or not this socket is IPv6. - * - * By default this will be true, unless: - * - IPv6 is disabled (via setIPv6Enabled:) - * - The socket is explicitly bound to an IPv4 address - * _ The socket is connected to an IPv4 address - * - * This method will also return false on platforms that do not support IPv6. - * Note: The iPhone does not currently support IPv6. -**/ -- (BOOL)isIPv6; - -#pragma mark Binding - -/** - * Binds the UDP socket to the given port. - * Binding should be done for server sockets that receive data prior to sending it. - * Client sockets can skip binding, - * as the OS will automatically assign the socket an available port when it starts sending data. - * - * You may optionally pass a port number of zero to immediately bind the socket, - * yet still allow the OS to automatically assign an available port. - * - * You cannot bind a socket after its been connected. - * You can only bind a socket once. - * You can still connect a socket (if desired) after binding. - * - * On success, returns YES. - * Otherwise returns NO, and sets errPtr. If you don't care about the error, you can pass NULL for errPtr. -**/ -- (BOOL)bindToPort:(uint16_t)port error:(NSError **)errPtr; - -/** - * Binds the UDP socket to the given port and optional interface. - * Binding should be done for server sockets that receive data prior to sending it. - * Client sockets can skip binding, - * as the OS will automatically assign the socket an available port when it starts sending data. - * - * You may optionally pass a port number of zero to immediately bind the socket, - * yet still allow the OS to automatically assign an available port. - * - * The interface may be a name (e.g. "en1" or "lo0") or the corresponding IP address (e.g. "192.168.4.35"). - * You may also use the special strings "localhost" or "loopback" to specify that - * the socket only accept packets from the local machine. - * - * You cannot bind a socket after its been connected. - * You can only bind a socket once. - * You can still connect a socket (if desired) after binding. - * - * On success, returns YES. - * Otherwise returns NO, and sets errPtr. If you don't care about the error, you can pass NULL for errPtr. -**/ -- (BOOL)bindToPort:(uint16_t)port interface:(nullable NSString *)interface error:(NSError **)errPtr; - -/** - * Binds the UDP socket to the given address, specified as a sockaddr structure wrapped in a NSData object. - * - * If you have an existing struct sockaddr you can convert it to a NSData object like so: - * struct sockaddr sa -> NSData *dsa = [NSData dataWithBytes:&remoteAddr length:remoteAddr.sa_len]; - * struct sockaddr *sa -> NSData *dsa = [NSData dataWithBytes:remoteAddr length:remoteAddr->sa_len]; - * - * Binding should be done for server sockets that receive data prior to sending it. - * Client sockets can skip binding, - * as the OS will automatically assign the socket an available port when it starts sending data. - * - * You cannot bind a socket after its been connected. - * You can only bind a socket once. - * You can still connect a socket (if desired) after binding. - * - * On success, returns YES. - * Otherwise returns NO, and sets errPtr. If you don't care about the error, you can pass NULL for errPtr. -**/ -- (BOOL)bindToAddress:(NSData *)localAddr error:(NSError **)errPtr; - -#pragma mark Connecting - -/** - * Connects the UDP socket to the given host and port. - * By design, UDP is a connectionless protocol, and connecting is not needed. - * - * Choosing to connect to a specific host/port has the following effect: - * - You will only be able to send data to the connected host/port. - * - You will only be able to receive data from the connected host/port. - * - You will receive ICMP messages that come from the connected host/port, such as "connection refused". - * - * The actual process of connecting a UDP socket does not result in any communication on the socket. - * It simply changes the internal state of the socket. - * - * You cannot bind a socket after it has been connected. - * You can only connect a socket once. - * - * The host may be a domain name (e.g. "deusty.com") or an IP address string (e.g. "192.168.0.2"). - * - * This method is asynchronous as it requires a DNS lookup to resolve the given host name. - * If an obvious error is detected, this method immediately returns NO and sets errPtr. - * If you don't care about the error, you can pass nil for errPtr. - * Otherwise, this method returns YES and begins the asynchronous connection process. - * The result of the asynchronous connection process will be reported via the delegate methods. - **/ -- (BOOL)connectToHost:(NSString *)host onPort:(uint16_t)port error:(NSError **)errPtr; - -/** - * Connects the UDP socket to the given address, specified as a sockaddr structure wrapped in a NSData object. - * - * If you have an existing struct sockaddr you can convert it to a NSData object like so: - * struct sockaddr sa -> NSData *dsa = [NSData dataWithBytes:&remoteAddr length:remoteAddr.sa_len]; - * struct sockaddr *sa -> NSData *dsa = [NSData dataWithBytes:remoteAddr length:remoteAddr->sa_len]; - * - * By design, UDP is a connectionless protocol, and connecting is not needed. - * - * Choosing to connect to a specific address has the following effect: - * - You will only be able to send data to the connected address. - * - You will only be able to receive data from the connected address. - * - You will receive ICMP messages that come from the connected address, such as "connection refused". - * - * Connecting a UDP socket does not result in any communication on the socket. - * It simply changes the internal state of the socket. - * - * You cannot bind a socket after its been connected. - * You can only connect a socket once. - * - * On success, returns YES. - * Otherwise returns NO, and sets errPtr. If you don't care about the error, you can pass nil for errPtr. - * - * Note: Unlike the connectToHost:onPort:error: method, this method does not require a DNS lookup. - * Thus when this method returns, the connection has either failed or fully completed. - * In other words, this method is synchronous, unlike the asynchronous connectToHost::: method. - * However, for compatibility and simplification of delegate code, if this method returns YES - * then the corresponding delegate method (udpSocket:didConnectToHost:port:) is still invoked. -**/ -- (BOOL)connectToAddress:(NSData *)remoteAddr error:(NSError **)errPtr; - -#pragma mark Multicast - -/** - * Join multicast group. - * Group should be an IP address (eg @"225.228.0.1"). - * - * On success, returns YES. - * Otherwise returns NO, and sets errPtr. If you don't care about the error, you can pass nil for errPtr. -**/ -- (BOOL)joinMulticastGroup:(NSString *)group error:(NSError **)errPtr; - -/** - * Join multicast group. - * Group should be an IP address (eg @"225.228.0.1"). - * The interface may be a name (e.g. "en1" or "lo0") or the corresponding IP address (e.g. "192.168.4.35"). - * - * On success, returns YES. - * Otherwise returns NO, and sets errPtr. If you don't care about the error, you can pass nil for errPtr. -**/ -- (BOOL)joinMulticastGroup:(NSString *)group onInterface:(nullable NSString *)interface error:(NSError **)errPtr; - -- (BOOL)leaveMulticastGroup:(NSString *)group error:(NSError **)errPtr; -- (BOOL)leaveMulticastGroup:(NSString *)group onInterface:(nullable NSString *)interface error:(NSError **)errPtr; - -/** - * Send multicast on a specified interface. - * For IPv4, interface should be the the IP address of the interface (eg @"192.168.10.1"). - * For IPv6, interface should be the a network interface name (eg @"en0"). - * - * On success, returns YES. - * Otherwise returns NO, and sets errPtr. If you don't care about the error, you can pass nil for errPtr. -**/ - -- (BOOL)sendIPv4MulticastOnInterface:(NSString*)interface error:(NSError **)errPtr; -- (BOOL)sendIPv6MulticastOnInterface:(NSString*)interface error:(NSError **)errPtr; - -#pragma mark Reuse Port - -/** - * By default, only one socket can be bound to a given IP address + port at a time. - * To enable multiple processes to simultaneously bind to the same address+port, - * you need to enable this functionality in the socket. All processes that wish to - * use the address+port simultaneously must all enable reuse port on the socket - * bound to that port. - **/ -- (BOOL)enableReusePort:(BOOL)flag error:(NSError **)errPtr; - -#pragma mark Broadcast - -/** - * By default, the underlying socket in the OS will not allow you to send broadcast messages. - * In order to send broadcast messages, you need to enable this functionality in the socket. - * - * A broadcast is a UDP message to addresses like "192.168.255.255" or "255.255.255.255" that is - * delivered to every host on the network. - * The reason this is generally disabled by default (by the OS) is to prevent - * accidental broadcast messages from flooding the network. -**/ -- (BOOL)enableBroadcast:(BOOL)flag error:(NSError **)errPtr; - -#pragma mark Sending - -/** - * Asynchronously sends the given data, with the given timeout and tag. - * - * This method may only be used with a connected socket. - * Recall that connecting is optional for a UDP socket. - * For connected sockets, data can only be sent to the connected address. - * For non-connected sockets, the remote destination is specified for each packet. - * For more information about optionally connecting udp sockets, see the documentation for the connect methods above. - * - * @param data - * The data to send. - * If data is nil or zero-length, this method does nothing. - * If passing NSMutableData, please read the thread-safety notice below. - * - * @param timeout - * The timeout for the send opeartion. - * If the timeout value is negative, the send operation will not use a timeout. - * - * @param tag - * The tag is for your convenience. - * It is not sent or received over the socket in any manner what-so-ever. - * It is reported back as a parameter in the udpSocket:didSendDataWithTag: - * or udpSocket:didNotSendDataWithTag:dueToError: methods. - * You can use it as an array index, state id, type constant, etc. - * - * - * Thread-Safety Note: - * If the given data parameter is mutable (NSMutableData) then you MUST NOT alter the data while - * the socket is sending it. In other words, it's not safe to alter the data until after the delegate method - * udpSocket:didSendDataWithTag: or udpSocket:didNotSendDataWithTag:dueToError: is invoked signifying - * that this particular send operation has completed. - * This is due to the fact that GCDAsyncUdpSocket does NOT copy the data. - * It simply retains it for performance reasons. - * Often times, if NSMutableData is passed, it is because a request/response was built up in memory. - * Copying this data adds an unwanted/unneeded overhead. - * If you need to write data from an immutable buffer, and you need to alter the buffer before the socket - * completes sending the bytes (which is NOT immediately after this method returns, but rather at a later time - * when the delegate method notifies you), then you should first copy the bytes, and pass the copy to this method. -**/ -- (void)sendData:(NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag; - -/** - * Asynchronously sends the given data, with the given timeout and tag, to the given host and port. - * - * This method cannot be used with a connected socket. - * Recall that connecting is optional for a UDP socket. - * For connected sockets, data can only be sent to the connected address. - * For non-connected sockets, the remote destination is specified for each packet. - * For more information about optionally connecting udp sockets, see the documentation for the connect methods above. - * - * @param data - * The data to send. - * If data is nil or zero-length, this method does nothing. - * If passing NSMutableData, please read the thread-safety notice below. - * - * @param host - * The destination to send the udp packet to. - * May be specified as a domain name (e.g. "deusty.com") or an IP address string (e.g. "192.168.0.2"). - * You may also use the convenience strings of "loopback" or "localhost". - * - * @param port - * The port of the host to send to. - * - * @param timeout - * The timeout for the send opeartion. - * If the timeout value is negative, the send operation will not use a timeout. - * - * @param tag - * The tag is for your convenience. - * It is not sent or received over the socket in any manner what-so-ever. - * It is reported back as a parameter in the udpSocket:didSendDataWithTag: - * or udpSocket:didNotSendDataWithTag:dueToError: methods. - * You can use it as an array index, state id, type constant, etc. - * - * - * Thread-Safety Note: - * If the given data parameter is mutable (NSMutableData) then you MUST NOT alter the data while - * the socket is sending it. In other words, it's not safe to alter the data until after the delegate method - * udpSocket:didSendDataWithTag: or udpSocket:didNotSendDataWithTag:dueToError: is invoked signifying - * that this particular send operation has completed. - * This is due to the fact that GCDAsyncUdpSocket does NOT copy the data. - * It simply retains it for performance reasons. - * Often times, if NSMutableData is passed, it is because a request/response was built up in memory. - * Copying this data adds an unwanted/unneeded overhead. - * If you need to write data from an immutable buffer, and you need to alter the buffer before the socket - * completes sending the bytes (which is NOT immediately after this method returns, but rather at a later time - * when the delegate method notifies you), then you should first copy the bytes, and pass the copy to this method. -**/ -- (void)sendData:(NSData *)data - toHost:(NSString *)host - port:(uint16_t)port - withTimeout:(NSTimeInterval)timeout - tag:(long)tag; - -/** - * Asynchronously sends the given data, with the given timeout and tag, to the given address. - * - * This method cannot be used with a connected socket. - * Recall that connecting is optional for a UDP socket. - * For connected sockets, data can only be sent to the connected address. - * For non-connected sockets, the remote destination is specified for each packet. - * For more information about optionally connecting udp sockets, see the documentation for the connect methods above. - * - * @param data - * The data to send. - * If data is nil or zero-length, this method does nothing. - * If passing NSMutableData, please read the thread-safety notice below. - * - * @param remoteAddr - * The address to send the data to (specified as a sockaddr structure wrapped in a NSData object). - * - * @param timeout - * The timeout for the send opeartion. - * If the timeout value is negative, the send operation will not use a timeout. - * - * @param tag - * The tag is for your convenience. - * It is not sent or received over the socket in any manner what-so-ever. - * It is reported back as a parameter in the udpSocket:didSendDataWithTag: - * or udpSocket:didNotSendDataWithTag:dueToError: methods. - * You can use it as an array index, state id, type constant, etc. - * - * - * Thread-Safety Note: - * If the given data parameter is mutable (NSMutableData) then you MUST NOT alter the data while - * the socket is sending it. In other words, it's not safe to alter the data until after the delegate method - * udpSocket:didSendDataWithTag: or udpSocket:didNotSendDataWithTag:dueToError: is invoked signifying - * that this particular send operation has completed. - * This is due to the fact that GCDAsyncUdpSocket does NOT copy the data. - * It simply retains it for performance reasons. - * Often times, if NSMutableData is passed, it is because a request/response was built up in memory. - * Copying this data adds an unwanted/unneeded overhead. - * If you need to write data from an immutable buffer, and you need to alter the buffer before the socket - * completes sending the bytes (which is NOT immediately after this method returns, but rather at a later time - * when the delegate method notifies you), then you should first copy the bytes, and pass the copy to this method. -**/ -- (void)sendData:(NSData *)data toAddress:(NSData *)remoteAddr withTimeout:(NSTimeInterval)timeout tag:(long)tag; - -/** - * You may optionally set a send filter for the socket. - * A filter can provide several interesting possibilities: - * - * 1. Optional caching of resolved addresses for domain names. - * The cache could later be consulted, resulting in fewer system calls to getaddrinfo. - * - * 2. Reusable modules of code for bandwidth monitoring. - * - * 3. Sometimes traffic shapers are needed to simulate real world environments. - * A filter allows you to write custom code to simulate such environments. - * The ability to code this yourself is especially helpful when your simulated environment - * is more complicated than simple traffic shaping (e.g. simulating a cone port restricted router), - * or the system tools to handle this aren't available (e.g. on a mobile device). - * - * For more information about GCDAsyncUdpSocketSendFilterBlock, see the documentation for its typedef. - * To remove a previously set filter, invoke this method and pass a nil filterBlock and NULL filterQueue. - * - * Note: This method invokes setSendFilter:withQueue:isAsynchronous: (documented below), - * passing YES for the isAsynchronous parameter. -**/ -- (void)setSendFilter:(nullable GCDAsyncUdpSocketSendFilterBlock)filterBlock withQueue:(nullable dispatch_queue_t)filterQueue; - -/** - * The receive filter can be run via dispatch_async or dispatch_sync. - * Most typical situations call for asynchronous operation. - * - * However, there are a few situations in which synchronous operation is preferred. - * Such is the case when the filter is extremely minimal and fast. - * This is because dispatch_sync is faster than dispatch_async. - * - * If you choose synchronous operation, be aware of possible deadlock conditions. - * Since the socket queue is executing your block via dispatch_sync, - * then you cannot perform any tasks which may invoke dispatch_sync on the socket queue. - * For example, you can't query properties on the socket. -**/ -- (void)setSendFilter:(nullable GCDAsyncUdpSocketSendFilterBlock)filterBlock - withQueue:(nullable dispatch_queue_t)filterQueue - isAsynchronous:(BOOL)isAsynchronous; - -#pragma mark Receiving - -/** - * There are two modes of operation for receiving packets: one-at-a-time & continuous. - * - * In one-at-a-time mode, you call receiveOnce everytime your delegate is ready to process an incoming udp packet. - * Receiving packets one-at-a-time may be better suited for implementing certain state machine code, - * where your state machine may not always be ready to process incoming packets. - * - * In continuous mode, the delegate is invoked immediately everytime incoming udp packets are received. - * Receiving packets continuously is better suited to real-time streaming applications. - * - * You may switch back and forth between one-at-a-time mode and continuous mode. - * If the socket is currently in continuous mode, calling this method will switch it to one-at-a-time mode. - * - * When a packet is received (and not filtered by the optional receive filter), - * the delegate method (udpSocket:didReceiveData:fromAddress:withFilterContext:) is invoked. - * - * If the socket is able to begin receiving packets, this method returns YES. - * Otherwise it returns NO, and sets the errPtr with appropriate error information. - * - * An example error: - * You created a udp socket to act as a server, and immediately called receive. - * You forgot to first bind the socket to a port number, and received a error with a message like: - * "Must bind socket before you can receive data." -**/ -- (BOOL)receiveOnce:(NSError **)errPtr; - -/** - * There are two modes of operation for receiving packets: one-at-a-time & continuous. - * - * In one-at-a-time mode, you call receiveOnce everytime your delegate is ready to process an incoming udp packet. - * Receiving packets one-at-a-time may be better suited for implementing certain state machine code, - * where your state machine may not always be ready to process incoming packets. - * - * In continuous mode, the delegate is invoked immediately everytime incoming udp packets are received. - * Receiving packets continuously is better suited to real-time streaming applications. - * - * You may switch back and forth between one-at-a-time mode and continuous mode. - * If the socket is currently in one-at-a-time mode, calling this method will switch it to continuous mode. - * - * For every received packet (not filtered by the optional receive filter), - * the delegate method (udpSocket:didReceiveData:fromAddress:withFilterContext:) is invoked. - * - * If the socket is able to begin receiving packets, this method returns YES. - * Otherwise it returns NO, and sets the errPtr with appropriate error information. - * - * An example error: - * You created a udp socket to act as a server, and immediately called receive. - * You forgot to first bind the socket to a port number, and received a error with a message like: - * "Must bind socket before you can receive data." -**/ -- (BOOL)beginReceiving:(NSError **)errPtr; - -/** - * If the socket is currently receiving (beginReceiving has been called), this method pauses the receiving. - * That is, it won't read any more packets from the underlying OS socket until beginReceiving is called again. - * - * Important Note: - * GCDAsyncUdpSocket may be running in parallel with your code. - * That is, your delegate is likely running on a separate thread/dispatch_queue. - * When you invoke this method, GCDAsyncUdpSocket may have already dispatched delegate methods to be invoked. - * Thus, if those delegate methods have already been dispatch_async'd, - * your didReceive delegate method may still be invoked after this method has been called. - * You should be aware of this, and program defensively. -**/ -- (void)pauseReceiving; - -/** - * You may optionally set a receive filter for the socket. - * This receive filter may be set to run in its own queue (independent of delegate queue). - * - * A filter can provide several useful features. - * - * 1. Many times udp packets need to be parsed. - * Since the filter can run in its own independent queue, you can parallelize this parsing quite easily. - * The end result is a parallel socket io, datagram parsing, and packet processing. - * - * 2. Many times udp packets are discarded because they are duplicate/unneeded/unsolicited. - * The filter can prevent such packets from arriving at the delegate. - * And because the filter can run in its own independent queue, this doesn't slow down the delegate. - * - * - Since the udp protocol does not guarantee delivery, udp packets may be lost. - * Many protocols built atop udp thus provide various resend/re-request algorithms. - * This sometimes results in duplicate packets arriving. - * A filter may allow you to architect the duplicate detection code to run in parallel to normal processing. - * - * - Since the udp socket may be connectionless, its possible for unsolicited packets to arrive. - * Such packets need to be ignored. - * - * 3. Sometimes traffic shapers are needed to simulate real world environments. - * A filter allows you to write custom code to simulate such environments. - * The ability to code this yourself is especially helpful when your simulated environment - * is more complicated than simple traffic shaping (e.g. simulating a cone port restricted router), - * or the system tools to handle this aren't available (e.g. on a mobile device). - * - * Example: - * - * GCDAsyncUdpSocketReceiveFilterBlock filter = ^BOOL (NSData *data, NSData *address, id *context) { - * - * MyProtocolMessage *msg = [MyProtocol parseMessage:data]; - * - * *context = response; - * return (response != nil); - * }; - * [udpSocket setReceiveFilter:filter withQueue:myParsingQueue]; - * - * For more information about GCDAsyncUdpSocketReceiveFilterBlock, see the documentation for its typedef. - * To remove a previously set filter, invoke this method and pass a nil filterBlock and NULL filterQueue. - * - * Note: This method invokes setReceiveFilter:withQueue:isAsynchronous: (documented below), - * passing YES for the isAsynchronous parameter. -**/ -- (void)setReceiveFilter:(nullable GCDAsyncUdpSocketReceiveFilterBlock)filterBlock withQueue:(nullable dispatch_queue_t)filterQueue; - -/** - * The receive filter can be run via dispatch_async or dispatch_sync. - * Most typical situations call for asynchronous operation. - * - * However, there are a few situations in which synchronous operation is preferred. - * Such is the case when the filter is extremely minimal and fast. - * This is because dispatch_sync is faster than dispatch_async. - * - * If you choose synchronous operation, be aware of possible deadlock conditions. - * Since the socket queue is executing your block via dispatch_sync, - * then you cannot perform any tasks which may invoke dispatch_sync on the socket queue. - * For example, you can't query properties on the socket. -**/ -- (void)setReceiveFilter:(nullable GCDAsyncUdpSocketReceiveFilterBlock)filterBlock - withQueue:(nullable dispatch_queue_t)filterQueue - isAsynchronous:(BOOL)isAsynchronous; - -#pragma mark Closing - -/** - * Immediately closes the underlying socket. - * Any pending send operations are discarded. - * - * The GCDAsyncUdpSocket instance may optionally be used again. - * (it will setup/configure/use another unnderlying BSD socket). -**/ -- (void)close; - -/** - * Closes the underlying socket after all pending send operations have been sent. - * - * The GCDAsyncUdpSocket instance may optionally be used again. - * (it will setup/configure/use another unnderlying BSD socket). -**/ -- (void)closeAfterSending; - -#pragma mark Advanced -/** - * GCDAsyncSocket maintains thread safety by using an internal serial dispatch_queue. - * In most cases, the instance creates this queue itself. - * However, to allow for maximum flexibility, the internal queue may be passed in the init method. - * This allows for some advanced options such as controlling socket priority via target queues. - * However, when one begins to use target queues like this, they open the door to some specific deadlock issues. - * - * For example, imagine there are 2 queues: - * dispatch_queue_t socketQueue; - * dispatch_queue_t socketTargetQueue; - * - * If you do this (pseudo-code): - * socketQueue.targetQueue = socketTargetQueue; - * - * Then all socketQueue operations will actually get run on the given socketTargetQueue. - * This is fine and works great in most situations. - * But if you run code directly from within the socketTargetQueue that accesses the socket, - * you could potentially get deadlock. Imagine the following code: - * - * - (BOOL)socketHasSomething - * { - * __block BOOL result = NO; - * dispatch_block_t block = ^{ - * result = [self someInternalMethodToBeRunOnlyOnSocketQueue]; - * } - * if (is_executing_on_queue(socketQueue)) - * block(); - * else - * dispatch_sync(socketQueue, block); - * - * return result; - * } - * - * What happens if you call this method from the socketTargetQueue? The result is deadlock. - * This is because the GCD API offers no mechanism to discover a queue's targetQueue. - * Thus we have no idea if our socketQueue is configured with a targetQueue. - * If we had this information, we could easily avoid deadlock. - * But, since these API's are missing or unfeasible, you'll have to explicitly set it. - * - * IF you pass a socketQueue via the init method, - * AND you've configured the passed socketQueue with a targetQueue, - * THEN you should pass the end queue in the target hierarchy. - * - * For example, consider the following queue hierarchy: - * socketQueue -> ipQueue -> moduleQueue - * - * This example demonstrates priority shaping within some server. - * All incoming client connections from the same IP address are executed on the same target queue. - * And all connections for a particular module are executed on the same target queue. - * Thus, the priority of all networking for the entire module can be changed on the fly. - * Additionally, networking traffic from a single IP cannot monopolize the module. - * - * Here's how you would accomplish something like that: - * - (dispatch_queue_t)newSocketQueueForConnectionFromAddress:(NSData *)address onSocket:(GCDAsyncSocket *)sock - * { - * dispatch_queue_t socketQueue = dispatch_queue_create("", NULL); - * dispatch_queue_t ipQueue = [self ipQueueForAddress:address]; - * - * dispatch_set_target_queue(socketQueue, ipQueue); - * dispatch_set_target_queue(iqQueue, moduleQueue); - * - * return socketQueue; - * } - * - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket - * { - * [clientConnections addObject:newSocket]; - * [newSocket markSocketQueueTargetQueue:moduleQueue]; - * } - * - * Note: This workaround is ONLY needed if you intend to execute code directly on the ipQueue or moduleQueue. - * This is often NOT the case, as such queues are used solely for execution shaping. - **/ -- (void)markSocketQueueTargetQueue:(dispatch_queue_t)socketQueuesPreConfiguredTargetQueue; -- (void)unmarkSocketQueueTargetQueue:(dispatch_queue_t)socketQueuesPreviouslyConfiguredTargetQueue; - -/** - * It's not thread-safe to access certain variables from outside the socket's internal queue. - * - * For example, the socket file descriptor. - * File descriptors are simply integers which reference an index in the per-process file table. - * However, when one requests a new file descriptor (by opening a file or socket), - * the file descriptor returned is guaranteed to be the lowest numbered unused descriptor. - * So if we're not careful, the following could be possible: - * - * - Thread A invokes a method which returns the socket's file descriptor. - * - The socket is closed via the socket's internal queue on thread B. - * - Thread C opens a file, and subsequently receives the file descriptor that was previously the socket's FD. - * - Thread A is now accessing/altering the file instead of the socket. - * - * In addition to this, other variables are not actually objects, - * and thus cannot be retained/released or even autoreleased. - * An example is the sslContext, of type SSLContextRef, which is actually a malloc'd struct. - * - * Although there are internal variables that make it difficult to maintain thread-safety, - * it is important to provide access to these variables - * to ensure this class can be used in a wide array of environments. - * This method helps to accomplish this by invoking the current block on the socket's internal queue. - * The methods below can be invoked from within the block to access - * those generally thread-unsafe internal variables in a thread-safe manner. - * The given block will be invoked synchronously on the socket's internal queue. - * - * If you save references to any protected variables and use them outside the block, you do so at your own peril. -**/ -- (void)performBlock:(dispatch_block_t)block; - -/** - * These methods are only available from within the context of a performBlock: invocation. - * See the documentation for the performBlock: method above. - * - * Provides access to the socket's file descriptor(s). - * If the socket isn't connected, or explicity bound to a particular interface, - * it might actually have multiple internal socket file descriptors - one for IPv4 and one for IPv6. -**/ -- (int)socketFD; -- (int)socket4FD; -- (int)socket6FD; - -#if TARGET_OS_IPHONE - -/** - * These methods are only available from within the context of a performBlock: invocation. - * See the documentation for the performBlock: method above. - * - * Returns (creating if necessary) a CFReadStream/CFWriteStream for the internal socket. - * - * Generally GCDAsyncUdpSocket doesn't use CFStream. (It uses the faster GCD API's.) - * However, if you need one for any reason, - * these methods are a convenient way to get access to a safe instance of one. -**/ -- (nullable CFReadStreamRef)readStream; -- (nullable CFWriteStreamRef)writeStream; - -/** - * This method is only available from within the context of a performBlock: invocation. - * See the documentation for the performBlock: method above. - * - * Configures the socket to allow it to operate when the iOS application has been backgrounded. - * In other words, this method creates a read & write stream, and invokes: - * - * CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP); - * CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP); - * - * Returns YES if successful, NO otherwise. - * - * Example usage: - * - * [asyncUdpSocket performBlock:^{ - * [asyncUdpSocket enableBackgroundingOnSocket]; - * }]; - * - * - * NOTE : Apple doesn't currently support backgrounding UDP sockets. (Only TCP for now). -**/ -//- (BOOL)enableBackgroundingOnSockets; - -#endif - -#pragma mark Utilities - -/** - * Extracting host/port/family information from raw address data. -**/ - -+ (nullable NSString *)hostFromAddress:(NSData *)address; -+ (uint16_t)portFromAddress:(NSData *)address; -+ (int)familyFromAddress:(NSData *)address; - -+ (BOOL)isIPv4Address:(NSData *)address; -+ (BOOL)isIPv6Address:(NSData *)address; - -+ (BOOL)getHost:(NSString * __nullable * __nullable)hostPtr port:(uint16_t * __nullable)portPtr fromAddress:(NSData *)address; -+ (BOOL)getHost:(NSString * __nullable * __nullable)hostPtr port:(uint16_t * __nullable)portPtr family:(int * __nullable)afPtr fromAddress:(NSData *)address; - -@end - -NS_ASSUME_NONNULL_END diff --git a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Info.plist b/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Info.plist deleted file mode 100644 index ff682d01..00000000 Binary files a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Info.plist and /dev/null differ diff --git a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Modules/module.modulemap b/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Modules/module.modulemap deleted file mode 100644 index 6c90f597..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/Modules/module.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module CocoaAsyncSocket { - umbrella header "CocoaAsyncSocket.h" - - export * - module * { export * } -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/_CodeSignature/CodeResources b/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/_CodeSignature/CodeResources deleted file mode 100644 index f9371095..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/CocoaAsyncSocket/CocoaAsyncSocket.framework/_CodeSignature/CodeResources +++ /dev/null @@ -1,162 +0,0 @@ - - - - - files - - Headers/CocoaAsyncSocket.h - - 19xueMkhcDCf6A2ihyiTCDjWjd4= - - Headers/GCDAsyncSocket.h - - JwDJxahaKup9fnB5MJuoxDHbdDs= - - Headers/GCDAsyncUdpSocket.h - - 9hL7D86xSUKQ1TBRDa+fDNkDlqI= - - Info.plist - - eCKEB+C8HfC7DIu6eNc6P3wxyLo= - - Modules/module.modulemap - - +n94rYTWDjekX3imyh+PSyA9vgA= - - - files2 - - Headers/CocoaAsyncSocket.h - - hash - - 19xueMkhcDCf6A2ihyiTCDjWjd4= - - hash2 - - VpE7gL1U1p/0urO77FEjPNjY06qrttQJnalOd+6VYDQ= - - - Headers/GCDAsyncSocket.h - - hash - - JwDJxahaKup9fnB5MJuoxDHbdDs= - - hash2 - - JL0b2lWPgVphz/ekZLsGMKrShDXTK2YY53aKtusc9hk= - - - Headers/GCDAsyncUdpSocket.h - - hash - - 9hL7D86xSUKQ1TBRDa+fDNkDlqI= - - hash2 - - uNVm5yZ0jBhGDXZuAynPXvem1qcBvAVdWXAewQdJbh8= - - - Modules/module.modulemap - - hash - - +n94rYTWDjekX3imyh+PSyA9vgA= - - hash2 - - RoVn8xMeEnU3Izg0DtYjYL/krI8V7qw0sa7Ggf+08Rs= - - - - rules - - ^.* - - ^.*\.lproj/ - - optional - - weight - 1000 - - ^.*\.lproj/locversion.plist$ - - omit - - weight - 1100 - - ^Base\.lproj/ - - weight - 1010 - - ^version.plist$ - - - rules2 - - .*\.dSYM($|/) - - weight - 11 - - ^(.*/)?\.DS_Store$ - - omit - - weight - 2000 - - ^.* - - ^.*\.lproj/ - - optional - - weight - 1000 - - ^.*\.lproj/locversion.plist$ - - omit - - weight - 1100 - - ^Base\.lproj/ - - weight - 1010 - - ^Info\.plist$ - - omit - - weight - 20 - - ^PkgInfo$ - - omit - - weight - 20 - - ^embedded\.provisionprofile$ - - weight - 20 - - ^version\.plist$ - - weight - 20 - - - - diff --git a/client/3rd/PacketProcessor/PacketProcessor/Info.plist b/client/3rd/PacketProcessor/PacketProcessor/Info.plist deleted file mode 100644 index 5f5e9abf..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/Info.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - CFBundleSignature - ???? - - diff --git a/client/3rd/PacketProcessor/PacketProcessor/PacketProcessor.h b/client/3rd/PacketProcessor/PacketProcessor/PacketProcessor.h deleted file mode 100644 index 861c4c10..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/PacketProcessor.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// PacketProcessor.h -// PacketProcessor -// -// Created by sanchez on 20.12.2021. -// - -#import - -//! Project version number for PacketProcessor. -FOUNDATION_EXPORT double PacketProcessorVersionNumber; - -//! Project version string for PacketProcessor. -FOUNDATION_EXPORT const unsigned char PacketProcessorVersionString[]; - -// In this header, you should import all the public headers of your framework using statements like #import - - -#import "TunnelInterface.h" \ No newline at end of file diff --git a/client/3rd/PacketProcessor/PacketProcessor/TunnelInterface.h b/client/3rd/PacketProcessor/PacketProcessor/TunnelInterface.h deleted file mode 100644 index 5de27d9f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/TunnelInterface.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// TunnelInterface.h -// Potatso -// -// Created by LEI on 12/23/15. -// Copyright © 2015 TouchingApp. All rights reserved. -// - -#import - -@import NetworkExtension; - -#define TunnelMTU 1600 -#define kTun2SocksStoppedNotification @"kTun2SocksStoppedNotification" - -@interface TunnelInterface : NSObject -+ (TunnelInterface *)sharedInterface; -+ (NSError *)setupWithPacketTunnelFlow:(NEPacketTunnelFlow *)packetFlow; -+ (void)processPackets; -+ (void)writePacket: (NSData *)packet; -+ (void)startTun2Socks: (int)socksServerPort; -+ (void)stop; -@end diff --git a/client/3rd/PacketProcessor/PacketProcessor/TunnelInterface.m b/client/3rd/PacketProcessor/PacketProcessor/TunnelInterface.m deleted file mode 100644 index 4a875ed1..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/TunnelInterface.m +++ /dev/null @@ -1,239 +0,0 @@ -// -// TunnelInterface.m -// Potatso -// -// Created by LEI on 12/23/15. -// Copyright © 2015 TouchingApp. All rights reserved. -// - -#import "TunnelInterface.h" -#import -#import "ipv4/lwip/ip4.h" -#import "lwip/udp.h" -#import "lwip/ip.h" -#import -#import "inet_chksum.h" -#import "tun2socks/tun2socks.h" -@import CocoaAsyncSocket; - -#define kTunnelInterfaceErrorDomain [NSString stringWithFormat:@"%@.TunnelInterface", [[NSBundle mainBundle] bundleIdentifier]] - -@interface TunnelInterface () -@property (nonatomic) NEPacketTunnelFlow *tunnelPacketFlow; -@property (nonatomic) NSMutableDictionary *udpSession; -@property (nonatomic) GCDAsyncUdpSocket *udpSocket; -@property (nonatomic) int readFd; -@property (nonatomic) int writeFd; -@end - -@implementation TunnelInterface - -+ (TunnelInterface *)sharedInterface { - static dispatch_once_t onceToken; - static TunnelInterface *interface; - dispatch_once(&onceToken, ^{ - interface = [TunnelInterface new]; - }); - return interface; -} - -- (instancetype)init { - self = [super init]; - if (self) { - _udpSession = [NSMutableDictionary dictionaryWithCapacity:5]; - _udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_queue_create("udp", NULL)]; - } - return self; -} - -+ (NSError *)setupWithPacketTunnelFlow:(NEPacketTunnelFlow *)packetFlow { - if (packetFlow == nil) { - return [NSError errorWithDomain:kTunnelInterfaceErrorDomain code:1 userInfo:@{NSLocalizedDescriptionKey: @"PacketTunnelFlow can't be nil."}]; - } - [TunnelInterface sharedInterface].tunnelPacketFlow = packetFlow; - - NSError *error; - GCDAsyncUdpSocket *udpSocket = [TunnelInterface sharedInterface].udpSocket; - [udpSocket bindToPort:0 error:&error]; - if (error) { - return [NSError errorWithDomain:kTunnelInterfaceErrorDomain code:1 userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"UDP bind fail(%@).", [error localizedDescription]]}]; - } - [udpSocket beginReceiving:&error]; - if (error) { - return [NSError errorWithDomain:kTunnelInterfaceErrorDomain code:1 userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"UDP bind fail(%@).", [error localizedDescription]]}]; - } - - int fds[2]; - if (pipe(fds) < 0) { - return [NSError errorWithDomain:kTunnelInterfaceErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey: @"Unable to pipe."}]; - } - [TunnelInterface sharedInterface].readFd = fds[0]; - [TunnelInterface sharedInterface].writeFd = fds[1]; - return nil; -} - -+ (void)startTun2Socks: (int)socksServerPort { - [NSThread detachNewThreadSelector:@selector(_startTun2Socks:) toTarget:[TunnelInterface sharedInterface] withObject:@(socksServerPort)]; -} - -+ (void)stop { - stop_tun2socks(); -} - -+ (void)writePacket:(NSData *)packet { - dispatch_async(dispatch_get_main_queue(), ^{ - [[TunnelInterface sharedInterface].tunnelPacketFlow writePackets:@[packet] withProtocols:@[@(AF_INET)]]; - }); -} - -+ (void)processPackets { - __weak typeof(self) weakSelf = self; - [[TunnelInterface sharedInterface].tunnelPacketFlow readPacketsWithCompletionHandler:^(NSArray * _Nonnull packets, NSArray * _Nonnull protocols) { - for (NSData *packet in packets) { - uint8_t *data = (uint8_t *)packet.bytes; - struct ip_hdr *iphdr = (struct ip_hdr *)data; - uint8_t proto = IPH_PROTO(iphdr); - if (proto == IP_PROTO_UDP) { - [[TunnelInterface sharedInterface] handleUDPPacket:packet]; - }else if (proto == IP_PROTO_TCP) { - [[TunnelInterface sharedInterface] handleTCPPPacket:packet]; - } - } - [weakSelf processPackets]; - }]; - -} - -- (void)_startTun2Socks: (NSNumber *)socksServerPort { - char socks_server[50]; - sprintf(socks_server, "127.0.0.1:%d", (int)([socksServerPort integerValue])); -#if TCP_DATA_LOG_ENABLE - char *log_lvel = "debug"; -#else - char *log_lvel = "none"; -#endif - char *argv[] = { - "tun2socks", - "--netif-ipaddr", - "192.0.2.4", - "--netif-netmask", - "255.255.255.0", - "--loglevel", - log_lvel, - "--socks-server-addr", - socks_server - }; - tun2socks_main(sizeof(argv)/sizeof(argv[0]), argv, self.readFd, TunnelMTU); - close(self.readFd); - close(self.writeFd); - [[NSNotificationCenter defaultCenter] postNotificationName:kTun2SocksStoppedNotification object:nil]; -} - -- (void)handleTCPPPacket: (NSData *)packet { - uint8_t message[TunnelMTU+2]; - memcpy(message + 2, packet.bytes, packet.length); - message[0] = packet.length / 256; - message[1] = packet.length % 256; - write(self.writeFd , message , packet.length + 2); -} - -- (void)handleUDPPacket: (NSData *)packet { - uint8_t *data = (uint8_t *)packet.bytes; - int data_len = (int)packet.length; - struct ip_hdr *iphdr = (struct ip_hdr *)data; - uint8_t version = IPH_V(iphdr); - - switch (version) { - case 4: { - uint16_t iphdr_hlen = IPH_HL(iphdr) * 4; - data = data + iphdr_hlen; - data_len -= iphdr_hlen; - struct udp_hdr *udphdr = (struct udp_hdr *)data; - - data = data + sizeof(struct udp_hdr *); - data_len -= sizeof(struct udp_hdr *); - - NSData *outData = [[NSData alloc] initWithBytes:data length:data_len]; - struct in_addr dest = { iphdr->dest.addr }; - NSString *destHost = [NSString stringWithUTF8String:inet_ntoa(dest)]; - NSString *key = [self strForHost:iphdr->dest.addr port:udphdr->dest]; - NSString *value = [self strForHost:iphdr->src.addr port:udphdr->src];; - self.udpSession[key] = value; - [self.udpSocket sendData:outData toHost:destHost port:ntohs(udphdr->dest) withTimeout:30 tag:0]; - } break; - case 6: { - - } break; - } -} - -- (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data fromAddress:(NSData *)address withFilterContext:(id)filterContext { - const struct sockaddr_in *addr = (const struct sockaddr_in *)[address bytes]; - ip_addr_p_t dest ={ addr->sin_addr.s_addr }; - in_port_t dest_port = addr->sin_port; - NSString *strHostPort = self.udpSession[[self strForHost:dest.addr port:dest_port]]; - NSArray *hostPortArray = [strHostPort componentsSeparatedByString:@":"]; - int src_ip = [hostPortArray[0] intValue]; - int src_port = [hostPortArray[1] intValue]; - uint8_t *bytes = (uint8_t *)[data bytes]; - int bytes_len = (int)data.length; - int udp_length = sizeof(struct udp_hdr) + bytes_len; - int total_len = IP_HLEN + udp_length; - - ip_addr_p_t src = {src_ip}; - struct ip_hdr *iphdr = generateNewIPHeader(IP_PROTO_UDP, dest, src, total_len); - - struct udp_hdr udphdr; - udphdr.src = dest_port; - udphdr.dest = src_port; - udphdr.len = hton16(udp_length); - udphdr.chksum = hton16(0); - - uint8_t *udpdata = malloc(sizeof(uint8_t) * udp_length); - memcpy(udpdata, &udphdr, sizeof(struct udp_hdr)); - memcpy(udpdata + sizeof(struct udp_hdr), bytes, bytes_len); - - ip_addr_t odest = { dest.addr }; - ip_addr_t osrc = { src_ip }; - - struct pbuf *p_udp = pbuf_alloc(PBUF_TRANSPORT, udp_length, PBUF_RAM); - pbuf_take(p_udp, udpdata, udp_length); - - struct udp_hdr *new_udphdr = (struct udp_hdr *) p_udp->payload; - new_udphdr->chksum = inet_chksum_pseudo(p_udp, IP_PROTO_UDP, p_udp->len, &odest, &osrc); - - uint8_t *ipdata = malloc(sizeof(uint8_t) * total_len); - memcpy(ipdata, iphdr, IP_HLEN); - memcpy(ipdata + sizeof(struct ip_hdr), p_udp->payload, udp_length); - - NSData *outData = [[NSData alloc] initWithBytes:ipdata length:total_len]; - free(ipdata); - free(iphdr); - free(udpdata); - pbuf_free(p_udp); - [TunnelInterface writePacket:outData]; -} - -struct ip_hdr *generateNewIPHeader(u8_t proto, ip_addr_p_t src, ip_addr_p_t dest, uint16_t total_len) { - struct ip_hdr *iphdr = malloc(sizeof(struct ip_hdr)); - IPH_VHL_SET(iphdr, 4, IP_HLEN / 4); - IPH_TOS_SET(iphdr, 0); - IPH_LEN_SET(iphdr, htons(total_len)); - IPH_ID_SET(iphdr, 0); - IPH_OFFSET_SET(iphdr, 0); - IPH_TTL_SET(iphdr, 64); - IPH_PROTO_SET(iphdr, IP_PROTO_UDP); - iphdr->src = src; - iphdr->dest = dest; - IPH_CHKSUM_SET(iphdr, 0); - IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); - return iphdr; -} - -- (NSString *)strForHost: (int)host port: (int)port { - return [NSString stringWithFormat:@"%d:%d",host, port]; -} - - - -@end diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog.h deleted file mode 100644 index b1881a5e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog.h +++ /dev/null @@ -1,400 +0,0 @@ -/** - * @file BLog.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * A global object for logging. - */ - -#ifndef BADVPN_BLOG_H -#define BADVPN_BLOG_H - -#include -#include - -#include "misc/debug.h" -#include "misc/memref.h" -#include "base/BMutex.h" - -// auto-generated channel numbers and number of channels -#include "generated/blog_channels_defines.h" - -// keep in sync with level names in BLog.c! -#define BLOG_ERROR 1 -#define BLOG_WARNING 2 -#define BLOG_NOTICE 3 -#define BLOG_INFO 4 -#define BLOG_DEBUG 5 - -#define BLog(...) BLog_LogToChannel(BLOG_CURRENT_CHANNEL, __VA_ARGS__) -#define BContextLog(context, ...) BLog_ContextLog((context), BLOG_CURRENT_CHANNEL, __VA_ARGS__) -#define BLOG_CCCC(context) BLog_MakeChannelContext((context), BLOG_CURRENT_CHANNEL) - -typedef void (*_BLog_log_func) (int channel, int level, const char *msg); -typedef void (*_BLog_free_func) (void); - -struct _BLog_channel { - const char *name; - int loglevel; -}; - -struct _BLog_global { - #ifndef NDEBUG - int initialized; // initialized statically - #endif - struct _BLog_channel channels[BLOG_NUM_CHANNELS]; - _BLog_log_func log_func; - _BLog_free_func free_func; - BMutex mutex; -#ifndef NDEBUG - int logging; -#endif - char logbuf[2048]; - int logbuf_pos; -}; - -extern struct _BLog_channel blog_channel_list[]; -extern struct _BLog_global blog_global; - -typedef void (*BLog_logfunc) (void *); - -typedef struct { - BLog_logfunc logfunc; - void *logfunc_user; -} BLogContext; - -typedef struct { - BLogContext context; - int channel; -} BLogChannelContext; - -static int BLogGlobal_GetChannelByName (const char *channel_name); - -static void BLog_Init (_BLog_log_func log_func, _BLog_free_func free_func); -static void BLog_Free (void); -static void BLog_SetChannelLoglevel (int channel, int loglevel); -static int BLog_WouldLog (int channel, int level); -static void BLog_Begin (void); -static void BLog_AppendVarArg (const char *fmt, va_list vl); -static void BLog_Append (const char *fmt, ...); -static void BLog_AppendBytes (MemRef data); -static void BLog_Finish (int channel, int level); -static void BLog_LogToChannelVarArg (int channel, int level, const char *fmt, va_list vl); -static void BLog_LogToChannel (int channel, int level, const char *fmt, ...); -static void BLog_LogViaFuncVarArg (BLog_logfunc func, void *arg, int channel, int level, const char *fmt, va_list vl); -static void BLog_LogViaFunc (BLog_logfunc func, void *arg, int channel, int level, const char *fmt, ...); -static BLogContext BLog_RootContext (void); -static BLogContext BLog_MakeContext (BLog_logfunc logfunc, void *logfunc_user); -static void BLog_ContextLogVarArg (BLogContext context, int channel, int level, const char *fmt, va_list vl); -static void BLog_ContextLog (BLogContext context, int channel, int level, const char *fmt, ...); -static BLogChannelContext BLog_MakeChannelContext (BLogContext context, int channel); -static void BLog_ChannelContextLogVarArg (BLogChannelContext ccontext, int level, const char *fmt, va_list vl); -static void BLog_ChannelContextLog (BLogChannelContext ccontext, int level, const char *fmt, ...); - -void BLog_InitStdout (void); -void BLog_InitStderr (void); - -int BLogGlobal_GetChannelByName (const char *channel_name) -{ - int i; - for (i = 0; i < BLOG_NUM_CHANNELS; i++) { - if (!strcmp(blog_channel_list[i].name, channel_name)) { - return i; - } - } - - return -1; -} - -void BLog_Init (_BLog_log_func log_func, _BLog_free_func free_func) -{ - ASSERT(!blog_global.initialized) - - #ifndef NDEBUG - blog_global.initialized = 1; - #endif - - // initialize channels - memcpy(blog_global.channels, blog_channel_list, BLOG_NUM_CHANNELS * sizeof(struct _BLog_channel)); - - blog_global.log_func = log_func; - blog_global.free_func = free_func; -#ifndef NDEBUG - blog_global.logging = 0; -#endif - blog_global.logbuf_pos = 0; - blog_global.logbuf[0] = '\0'; - - ASSERT_FORCE(BMutex_Init(&blog_global.mutex)) -} - -void BLog_Free (void) -{ - ASSERT(blog_global.initialized) -#ifndef NDEBUG - ASSERT(!blog_global.logging) -#endif - - BMutex_Free(&blog_global.mutex); - - #ifndef NDEBUG - blog_global.initialized = 0; - #endif - - blog_global.free_func(); -} - -void BLog_SetChannelLoglevel (int channel, int loglevel) -{ - ASSERT(blog_global.initialized) - ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS) - ASSERT(loglevel >= 0 && loglevel <= BLOG_DEBUG) - - blog_global.channels[channel].loglevel = loglevel; -} - -int BLog_WouldLog (int channel, int level) -{ - ASSERT(blog_global.initialized) - ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS) - ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG) - - return (level <= blog_global.channels[channel].loglevel); -} - -void BLog_Begin (void) -{ - ASSERT(blog_global.initialized) - - BMutex_Lock(&blog_global.mutex); - -#ifndef NDEBUG - ASSERT(!blog_global.logging) - blog_global.logging = 1; -#endif -} - -void BLog_AppendVarArg (const char *fmt, va_list vl) -{ - ASSERT(blog_global.initialized) -#ifndef NDEBUG - ASSERT(blog_global.logging) -#endif - ASSERT(blog_global.logbuf_pos >= 0) - ASSERT(blog_global.logbuf_pos < sizeof(blog_global.logbuf)) - - int w = vsnprintf(blog_global.logbuf + blog_global.logbuf_pos, sizeof(blog_global.logbuf) - blog_global.logbuf_pos, fmt, vl); - - if (w >= sizeof(blog_global.logbuf) - blog_global.logbuf_pos) { - blog_global.logbuf_pos = sizeof(blog_global.logbuf) - 1; - } else { - blog_global.logbuf_pos += w; - } -} - -void BLog_Append (const char *fmt, ...) -{ - ASSERT(blog_global.initialized) -#ifndef NDEBUG - ASSERT(blog_global.logging) -#endif - - va_list vl; - va_start(vl, fmt); - BLog_AppendVarArg(fmt, vl); - va_end(vl); -} - -void BLog_AppendBytes (MemRef data) -{ - ASSERT(blog_global.initialized) -#ifndef NDEBUG - ASSERT(blog_global.logging) -#endif - ASSERT(blog_global.logbuf_pos >= 0) - ASSERT(blog_global.logbuf_pos < sizeof(blog_global.logbuf)) - - size_t avail = (sizeof(blog_global.logbuf) - 1) - blog_global.logbuf_pos; - data.len = (data.len > avail ? avail : data.len); - - memcpy(blog_global.logbuf + blog_global.logbuf_pos, data.ptr, data.len); - blog_global.logbuf_pos += data.len; - blog_global.logbuf[blog_global.logbuf_pos] = '\0'; -} - -void BLog_Finish (int channel, int level) -{ - ASSERT(blog_global.initialized) -#ifndef NDEBUG - ASSERT(blog_global.logging) -#endif - ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS) - ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG) - ASSERT(BLog_WouldLog(channel, level)) - - ASSERT(blog_global.logbuf_pos >= 0) - ASSERT(blog_global.logbuf_pos < sizeof(blog_global.logbuf)) - ASSERT(blog_global.logbuf[blog_global.logbuf_pos] == '\0') - - blog_global.log_func(channel, level, blog_global.logbuf); - -#ifndef NDEBUG - blog_global.logging = 0; -#endif - blog_global.logbuf_pos = 0; - blog_global.logbuf[0] = '\0'; - - BMutex_Unlock(&blog_global.mutex); -} - -void BLog_LogToChannelVarArg (int channel, int level, const char *fmt, va_list vl) -{ - ASSERT(blog_global.initialized) - ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS) - ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG) - - if (!BLog_WouldLog(channel, level)) { - return; - } - - BLog_Begin(); - BLog_AppendVarArg(fmt, vl); - BLog_Finish(channel, level); -} - -void BLog_LogToChannel (int channel, int level, const char *fmt, ...) -{ - ASSERT(blog_global.initialized) - ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS) - ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG) - - if (!BLog_WouldLog(channel, level)) { - return; - } - - va_list vl; - va_start(vl, fmt); - - BLog_Begin(); - BLog_AppendVarArg(fmt, vl); - BLog_Finish(channel, level); - - va_end(vl); -} - -void BLog_LogViaFuncVarArg (BLog_logfunc func, void *arg, int channel, int level, const char *fmt, va_list vl) -{ - ASSERT(blog_global.initialized) - ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS) - ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG) - - if (!BLog_WouldLog(channel, level)) { - return; - } - - BLog_Begin(); - func(arg); - BLog_AppendVarArg(fmt, vl); - BLog_Finish(channel, level); -} - -void BLog_LogViaFunc (BLog_logfunc func, void *arg, int channel, int level, const char *fmt, ...) -{ - ASSERT(blog_global.initialized) - ASSERT(channel >= 0 && channel < BLOG_NUM_CHANNELS) - ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG) - - if (!BLog_WouldLog(channel, level)) { - return; - } - - va_list vl; - va_start(vl, fmt); - - BLog_Begin(); - func(arg); - BLog_AppendVarArg(fmt, vl); - BLog_Finish(channel, level); - - va_end(vl); -} - -static void BLog__root_logfunc (void *unused) -{ -} - -static BLogContext BLog_RootContext (void) -{ - return BLog_MakeContext(BLog__root_logfunc, NULL); -} - -static BLogContext BLog_MakeContext (BLog_logfunc logfunc, void *logfunc_user) -{ - ASSERT(logfunc) - - BLogContext context; - context.logfunc = logfunc; - context.logfunc_user = logfunc_user; - return context; -} - -static void BLog_ContextLogVarArg (BLogContext context, int channel, int level, const char *fmt, va_list vl) -{ - BLog_LogViaFuncVarArg(context.logfunc, context.logfunc_user, channel, level, fmt, vl); -} - -static void BLog_ContextLog (BLogContext context, int channel, int level, const char *fmt, ...) -{ - va_list vl; - va_start(vl, fmt); - BLog_ContextLogVarArg(context, channel, level, fmt, vl); - va_end(vl); -} - -static BLogChannelContext BLog_MakeChannelContext (BLogContext context, int channel) -{ - BLogChannelContext ccontext; - ccontext.context = context; - ccontext.channel = channel; - return ccontext; -} - -static void BLog_ChannelContextLogVarArg (BLogChannelContext ccontext, int level, const char *fmt, va_list vl) -{ - BLog_ContextLogVarArg(ccontext.context, ccontext.channel, level, fmt, vl); -} - -static void BLog_ChannelContextLog (BLogChannelContext ccontext, int level, const char *fmt, ...) -{ - va_list vl; - va_start(vl, fmt); - BLog_ChannelContextLogVarArg(ccontext, level, fmt, vl); - va_end(vl); -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog.m b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog.m deleted file mode 100644 index 18c79c24..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog.m +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @file BLog.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -#include "BLog.h" - -#ifndef BADVPN_PLUGIN - -struct _BLog_channel blog_channel_list[] = { -#include "generated/blog_channels_list.h" -}; - -struct _BLog_global blog_global = { - #ifndef NDEBUG - 0 - #endif -}; - -#endif - -// keep in sync with level numbers in BLog.h! -static char *level_names[] = { NULL, "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG" }; - -static void stdout_log (int channel, int level, const char *msg) -{ - NSLog(@"%s(%s): %s\n", level_names[level], blog_global.channels[channel].name, msg); -} - -static void stderr_log (int channel, int level, const char *msg) -{ - NSLog(@"%s(%s): %s\n", level_names[level], blog_global.channels[channel].name, msg); -} - -static void stdout_stderr_free (void) -{ -} - -void BLog_InitStdout (void) -{ - BLog_Init(stdout_log, stdout_stderr_free); -} - -void BLog_InitStderr (void) -{ - BLog_Init(stderr_log, stdout_stderr_free); -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog_syslog.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog_syslog.c deleted file mode 100644 index b32bbd44..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog_syslog.c +++ /dev/null @@ -1,150 +0,0 @@ -/** - * @file BLog_syslog.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -#include "misc/debug.h" - -#include "BLog_syslog.h" - -static int resolve_facility (char *str, int *out) -{ - if (!strcmp(str, "authpriv")) { - *out = LOG_AUTHPRIV; - } - else if (!strcmp(str, "cron")) { - *out = LOG_CRON; - } - else if (!strcmp(str, "daemon")) { - *out = LOG_DAEMON; - } - else if (!strcmp(str, "ftp")) { - *out = LOG_FTP; - } - else if (!strcmp(str, "local0")) { - *out = LOG_LOCAL0; - } - else if (!strcmp(str, "local1")) { - *out = LOG_LOCAL1; - } - else if (!strcmp(str, "local2")) { - *out = LOG_LOCAL2; - } - else if (!strcmp(str, "local3")) { - *out = LOG_LOCAL3; - } - else if (!strcmp(str, "local4")) { - *out = LOG_LOCAL4; - } - else if (!strcmp(str, "local5")) { - *out = LOG_LOCAL5; - } - else if (!strcmp(str, "local6")) { - *out = LOG_LOCAL6; - } - else if (!strcmp(str, "local7")) { - *out = LOG_LOCAL7; - } - else if (!strcmp(str, "lpr")) { - *out = LOG_LPR; - } - else if (!strcmp(str, "mail")) { - *out = LOG_MAIL; - } - else if (!strcmp(str, "news")) { - *out = LOG_NEWS; - } - else if (!strcmp(str, "syslog")) { - *out = LOG_SYSLOG; - } - else if (!strcmp(str, "user")) { - *out = LOG_USER; - } - else if (!strcmp(str, "uucp")) { - *out = LOG_UUCP; - } - else { - return 0; - } - - return 1; -} - -static int convert_level (int level) -{ - ASSERT(level >= BLOG_ERROR && level <= BLOG_DEBUG) - - switch (level) { - case BLOG_ERROR: - return LOG_ERR; - case BLOG_WARNING: - return LOG_WARNING; - case BLOG_NOTICE: - return LOG_NOTICE; - case BLOG_INFO: - return LOG_INFO; - case BLOG_DEBUG: - return LOG_DEBUG; - default: - ASSERT(0) - return 0; - } -} - -static struct { - char ident[200]; -} syslog_global; - -static void syslog_log (int channel, int level, const char *msg) -{ - syslog(convert_level(level), "%s: %s", blog_global.channels[channel].name, msg); -} - -static void syslog_free (void) -{ - closelog(); -} - -int BLog_InitSyslog (char *ident, char *facility_str) -{ - int facility; - if (!resolve_facility(facility_str, &facility)) { - return 0; - } - - snprintf(syslog_global.ident, sizeof(syslog_global.ident), "%s", ident); - - openlog(syslog_global.ident, 0, facility); - - BLog_Init(syslog_log, syslog_free); - - return 1; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog_syslog.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog_syslog.h deleted file mode 100644 index 234af902..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BLog_syslog.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file BLog_syslog.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * BLog syslog backend. - */ - -#ifndef BADVPN_BLOG_SYSLOG_H -#define BADVPN_BLOG_SYSLOG_H - -#include "misc/debug.h" -#include "base/BLog.h" - -int BLog_InitSyslog (char *ident, char *facility) WARN_UNUSED; - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BMutex.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BMutex.h deleted file mode 100644 index 2990c674..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BMutex.h +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file BMutex.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_BMUTEX_H -#define BADVPN_BMUTEX_H - -#if !defined(BADVPN_THREAD_SAFE) || (BADVPN_THREAD_SAFE != 0 && BADVPN_THREAD_SAFE != 1) -#error BADVPN_THREAD_SAFE is not defined or incorrect -#endif - -#if BADVPN_THREAD_SAFE -#include -#endif - -#include "misc/debug.h" -#include "base/DebugObject.h" - -typedef struct { -#if BADVPN_THREAD_SAFE - pthread_mutex_t pthread_mutex; -#endif - DebugObject d_obj; -} BMutex; - -static int BMutex_Init (BMutex *o) WARN_UNUSED; -static void BMutex_Free (BMutex *o); -static void BMutex_Lock (BMutex *o); -static void BMutex_Unlock (BMutex *o); - -static int BMutex_Init (BMutex *o) -{ -#if BADVPN_THREAD_SAFE - if (pthread_mutex_init(&o->pthread_mutex, NULL) != 0) { - return 0; - } -#endif - - DebugObject_Init(&o->d_obj); - return 1; -} - -static void BMutex_Free (BMutex *o) -{ - DebugObject_Free(&o->d_obj); - -#if BADVPN_THREAD_SAFE - int res = pthread_mutex_destroy(&o->pthread_mutex); - B_USE(res) - ASSERT(res == 0) -#endif -} - -static void BMutex_Lock (BMutex *o) -{ - DebugObject_Access(&o->d_obj); - -#if BADVPN_THREAD_SAFE - int res = pthread_mutex_lock(&o->pthread_mutex); - B_USE(res) - ASSERT(res == 0) -#endif -} - -static void BMutex_Unlock (BMutex *o) -{ - DebugObject_Access(&o->d_obj); - -#if BADVPN_THREAD_SAFE - int res = pthread_mutex_unlock(&o->pthread_mutex); - B_USE(res) - ASSERT(res == 0) -#endif -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BPending.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BPending.c deleted file mode 100644 index 474e974e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BPending.c +++ /dev/null @@ -1,205 +0,0 @@ -/** - * @file BPending.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "misc/debug.h" -#include "misc/offset.h" - -#include "BPending.h" - -#include "BPending_list.h" -#include "structure/SLinkedList_impl.h" - -void BPendingGroup_Init (BPendingGroup *g) -{ - // init jobs list - BPending__List_Init(&g->jobs); - - // init pending counter - DebugCounter_Init(&g->pending_ctr); - - // init debug object - DebugObject_Init(&g->d_obj); -} - -void BPendingGroup_Free (BPendingGroup *g) -{ - DebugCounter_Free(&g->pending_ctr); - ASSERT(BPending__List_IsEmpty(&g->jobs)) - DebugObject_Free(&g->d_obj); -} - -int BPendingGroup_HasJobs (BPendingGroup *g) -{ - DebugObject_Access(&g->d_obj); - - return !BPending__List_IsEmpty(&g->jobs); -} - -void BPendingGroup_ExecuteJob (BPendingGroup *g) -{ - ASSERT(!BPending__List_IsEmpty(&g->jobs)) - DebugObject_Access(&g->d_obj); - - // get a job - BSmallPending *p = BPending__List_First(&g->jobs); - ASSERT(!BPending__ListIsRemoved(p)) - ASSERT(p->pending) - - // remove from jobs list - BPending__List_RemoveFirst(&g->jobs); - - // set not pending - BPending__ListMarkRemoved(p); -#ifndef NDEBUG - p->pending = 0; -#endif - - // execute job - p->handler(p->user); - return; -} - -BSmallPending * BPendingGroup_PeekJob (BPendingGroup *g) -{ - DebugObject_Access(&g->d_obj); - - return BPending__List_First(&g->jobs); -} - -void BSmallPending_Init (BSmallPending *o, BPendingGroup *g, BSmallPending_handler handler, void *user) -{ - // init arguments - o->handler = handler; - o->user = user; - - // set not pending - BPending__ListMarkRemoved(o); -#ifndef NDEBUG - o->pending = 0; -#endif - - // increment pending counter - DebugCounter_Increment(&g->pending_ctr); - - // init debug object - DebugObject_Init(&o->d_obj); -} - -void BSmallPending_Free (BSmallPending *o, BPendingGroup *g) -{ - DebugCounter_Decrement(&g->pending_ctr); - DebugObject_Free(&o->d_obj); - ASSERT(o->pending == !BPending__ListIsRemoved(o)) - - // remove from jobs list - if (!BPending__ListIsRemoved(o)) { - BPending__List_Remove(&g->jobs, o); - } -} - -void BSmallPending_SetHandler (BSmallPending *o, BSmallPending_handler handler, void *user) -{ - DebugObject_Access(&o->d_obj); - - // set handler - o->handler = handler; - o->user = user; -} - -void BSmallPending_Set (BSmallPending *o, BPendingGroup *g) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->pending == !BPending__ListIsRemoved(o)) - - // remove from jobs list - if (!BPending__ListIsRemoved(o)) { - BPending__List_Remove(&g->jobs, o); - } - - // insert to jobs list - BPending__List_Prepend(&g->jobs, o); - - // set pending -#ifndef NDEBUG - o->pending = 1; -#endif -} - -void BSmallPending_Unset (BSmallPending *o, BPendingGroup *g) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->pending == !BPending__ListIsRemoved(o)) - - if (!BPending__ListIsRemoved(o)) { - // remove from jobs list - BPending__List_Remove(&g->jobs, o); - - // set not pending - BPending__ListMarkRemoved(o); -#ifndef NDEBUG - o->pending = 0; -#endif - } -} - -int BSmallPending_IsSet (BSmallPending *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->pending == !BPending__ListIsRemoved(o)) - - return !BPending__ListIsRemoved(o); -} - -void BPending_Init (BPending *o, BPendingGroup *g, BPending_handler handler, void *user) -{ - BSmallPending_Init(&o->base, g, handler, user); - o->g = g; -} - -void BPending_Free (BPending *o) -{ - BSmallPending_Free(&o->base, o->g); -} - -void BPending_Set (BPending *o) -{ - BSmallPending_Set(&o->base, o->g); -} - -void BPending_Unset (BPending *o) -{ - BSmallPending_Unset(&o->base, o->g); -} - -int BPending_IsSet (BPending *o) -{ - return BSmallPending_IsSet(&o->base); -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BPending.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BPending.h deleted file mode 100644 index 76044d14..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BPending.h +++ /dev/null @@ -1,250 +0,0 @@ -/** - * @file BPending.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Module for managing a queue of jobs pending execution. - */ - -#ifndef BADVPN_BPENDING_H -#define BADVPN_BPENDING_H - -#include - -#include "misc/debugcounter.h" -#include "structure/SLinkedList.h" -#include "base/DebugObject.h" - -struct BSmallPending_s; - -#include "BPending_list.h" -#include "structure/SLinkedList_decl.h" - -/** - * Job execution handler. - * It is guaranteed that the associated {@link BSmallPending} object was - * in set state. - * The {@link BSmallPending} object enters not set state before the handler - * is called. - * - * @param user as in {@link BSmallPending_Init} - */ -typedef void (*BSmallPending_handler) (void *user); - -/** - * Job execution handler. - * It is guaranteed that the associated {@link BPending} object was - * in set state. - * The {@link BPending} object enters not set state before the handler - * is called. - * - * @param user as in {@link BPending_Init} - */ -typedef void (*BPending_handler) (void *user); - -/** - * Object that contains a list of jobs pending execution. - */ -typedef struct { - BPending__List jobs; - DebugCounter pending_ctr; - DebugObject d_obj; -} BPendingGroup; - -/** - * Object for queuing a job for execution. - */ -typedef struct BSmallPending_s { - BPending_handler handler; - void *user; - BPending__ListNode pending_node; // optimization: if not pending, .next is this -#ifndef NDEBUG - uint8_t pending; -#endif - DebugObject d_obj; -} BSmallPending; - -/** - * Object for queuing a job for execution. This is a convenience wrapper - * around {@link BSmallPending} with an extra field to remember the - * {@link BPendingGroup} being used. - */ -typedef struct { - BSmallPending base; - BPendingGroup *g; -} BPending; - -/** - * Initializes the object. - * - * @param g the object - */ -void BPendingGroup_Init (BPendingGroup *g); - -/** - * Frees the object. - * There must be no {@link BPending} or {@link BSmallPending} objects using - * this group. - * - * @param g the object - */ -void BPendingGroup_Free (BPendingGroup *g); - -/** - * Checks if there is at least one job in the queue. - * - * @param g the object - * @return 1 if there is at least one job, 0 if not - */ -int BPendingGroup_HasJobs (BPendingGroup *g); - -/** - * Executes the top job on the job list. - * The job is removed from the list and enters - * not set state before being executed. - * There must be at least one job in job list. - * - * @param g the object - */ -void BPendingGroup_ExecuteJob (BPendingGroup *g); - -/** - * Returns the top job on the job list, or NULL if there are none. - * - * @param g the object - * @return the top job if there is at least one job, NULL if not - */ -BSmallPending * BPendingGroup_PeekJob (BPendingGroup *g); - -/** - * Initializes the object. - * The object is initialized in not set state. - * - * @param o the object - * @param g pending group to use - * @param handler job execution handler - * @param user value to pass to handler - */ -void BSmallPending_Init (BSmallPending *o, BPendingGroup *g, BSmallPending_handler handler, void *user); - -/** - * Frees the object. - * The execution handler will not be called after the object - * is freed. - * - * @param o the object - * @param g pending group. Must be the same as was used in {@link BSmallPending_Init}. - */ -void BSmallPending_Free (BSmallPending *o, BPendingGroup *g); - -/** - * Changes the job execution handler. - * - * @param o the object - * @param handler job execution handler - * @param user value to pass to handler - */ -void BSmallPending_SetHandler (BSmallPending *o, BSmallPending_handler handler, void *user); - -/** - * Enables the job, pushing it to the top of the job list. - * If the object was already in set state, the job is removed from its - * current position in the list before being pushed. - * The object enters set state. - * - * @param o the object - * @param g pending group. Must be the same as was used in {@link BSmallPending_Init}. - */ -void BSmallPending_Set (BSmallPending *o, BPendingGroup *g); - -/** - * Disables the job, removing it from the job list. - * If the object was not in set state, nothing is done. - * The object enters not set state. - * - * @param o the object - * @param g pending group. Must be the same as was used in {@link BSmallPending_Init}. - */ -void BSmallPending_Unset (BSmallPending *o, BPendingGroup *g); - -/** - * Checks if the job is in set state. - * - * @param o the object - * @return 1 if in set state, 0 if not - */ -int BSmallPending_IsSet (BSmallPending *o); - -/** - * Initializes the object. - * The object is initialized in not set state. - * - * @param o the object - * @param g pending group to use - * @param handler job execution handler - * @param user value to pass to handler - */ -void BPending_Init (BPending *o, BPendingGroup *g, BPending_handler handler, void *user); - -/** - * Frees the object. - * The execution handler will not be called after the object - * is freed. - * - * @param o the object - */ -void BPending_Free (BPending *o); - -/** - * Enables the job, pushing it to the top of the job list. - * If the object was already in set state, the job is removed from its - * current position in the list before being pushed. - * The object enters set state. - * - * @param o the object - */ -void BPending_Set (BPending *o); - -/** - * Disables the job, removing it from the job list. - * If the object was not in set state, nothing is done. - * The object enters not set state. - * - * @param o the object - */ -void BPending_Unset (BPending *o); - -/** - * Checks if the job is in set state. - * - * @param o the object - * @return 1 if in set state, 0 if not - */ -int BPending_IsSet (BPending *o); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BPending_list.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BPending_list.h deleted file mode 100644 index eadac61a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/BPending_list.h +++ /dev/null @@ -1,4 +0,0 @@ -#define SLINKEDLIST_PARAM_NAME BPending__List -#define SLINKEDLIST_PARAM_FEATURE_LAST 0 -#define SLINKEDLIST_PARAM_TYPE_ENTRY struct BSmallPending_s -#define SLINKEDLIST_PARAM_MEMBER_NODE pending_node diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/DebugObject.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/DebugObject.c deleted file mode 100644 index e6946177..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/DebugObject.c +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file DebugObject.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "DebugObject.h" - -#ifndef BADVPN_PLUGIN -#ifndef NDEBUG -DebugCounter debugobject_counter = DEBUGCOUNTER_STATIC; -#if BADVPN_THREAD_SAFE -pthread_mutex_t debugobject_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif -#endif -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/DebugObject.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/DebugObject.h deleted file mode 100644 index aeb9974d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/base/DebugObject.h +++ /dev/null @@ -1,147 +0,0 @@ -/** - * @file DebugObject.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Object used for detecting leaks. - */ - -#ifndef BADVPN_DEBUGOBJECT_H -#define BADVPN_DEBUGOBJECT_H - -#include - -#if !defined(BADVPN_THREAD_SAFE) || (BADVPN_THREAD_SAFE != 0 && BADVPN_THREAD_SAFE != 1) -#error BADVPN_THREAD_SAFE is not defined or incorrect -#endif - -#if BADVPN_THREAD_SAFE -#include -#endif - -#include "misc/debug.h" -#include "misc/debugcounter.h" - -#define DEBUGOBJECT_VALID UINT32_C(0x31415926) - -/** - * Object used for detecting leaks. - */ -typedef struct { - #ifndef NDEBUG - uint32_t c; - #endif -} DebugObject; - -/** - * Initializes the object. - * - * @param obj the object - */ -static void DebugObject_Init (DebugObject *obj); - -/** - * Frees the object. - * - * @param obj the object - */ -static void DebugObject_Free (DebugObject *obj); - -/** - * Does nothing. - * - * @param obj the object - */ -static void DebugObject_Access (const DebugObject *obj); - -/** - * Does nothing. - * There must be no {@link DebugObject}'s initialized. - */ -static void DebugObjectGlobal_Finish (void); - -#ifndef NDEBUG -extern DebugCounter debugobject_counter; -#if BADVPN_THREAD_SAFE -extern pthread_mutex_t debugobject_mutex; -#endif -#endif - -void DebugObject_Init (DebugObject *obj) -{ - #ifndef NDEBUG - - obj->c = DEBUGOBJECT_VALID; - - #if BADVPN_THREAD_SAFE - ASSERT_FORCE(pthread_mutex_lock(&debugobject_mutex) == 0) - #endif - - DebugCounter_Increment(&debugobject_counter); - - #if BADVPN_THREAD_SAFE - ASSERT_FORCE(pthread_mutex_unlock(&debugobject_mutex) == 0) - #endif - - #endif -} - -void DebugObject_Free (DebugObject *obj) -{ - ASSERT(obj->c == DEBUGOBJECT_VALID) - - #ifndef NDEBUG - - obj->c = 0; - - #if BADVPN_THREAD_SAFE - ASSERT_FORCE(pthread_mutex_lock(&debugobject_mutex) == 0) - #endif - - DebugCounter_Decrement(&debugobject_counter); - - #if BADVPN_THREAD_SAFE - ASSERT_FORCE(pthread_mutex_unlock(&debugobject_mutex) == 0) - #endif - - #endif -} - -void DebugObject_Access (const DebugObject *obj) -{ - ASSERT(obj->c == DEBUGOBJECT_VALID) -} - -void DebugObjectGlobal_Finish (void) -{ - #ifndef NDEBUG - DebugCounter_Free(&debugobject_counter); - #endif -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/BufferWriter.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/BufferWriter.c deleted file mode 100644 index 5a1d141f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/BufferWriter.c +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @file BufferWriter.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "misc/debug.h" - -#include "flow/BufferWriter.h" - -static void output_handler_recv (BufferWriter *o, uint8_t *data) -{ - ASSERT(!o->out_have) - - // set output packet - o->out_have = 1; - o->out = data; -} - -void BufferWriter_Init (BufferWriter *o, int mtu, BPendingGroup *pg) -{ - ASSERT(mtu >= 0) - - // init output - PacketRecvInterface_Init(&o->recv_interface, mtu, (PacketRecvInterface_handler_recv)output_handler_recv, o, pg); - - // set no output packet - o->out_have = 0; - - DebugObject_Init(&o->d_obj); - #ifndef NDEBUG - o->d_mtu = mtu; - o->d_writing = 0; - #endif -} - -void BufferWriter_Free (BufferWriter *o) -{ - DebugObject_Free(&o->d_obj); - - // free output - PacketRecvInterface_Free(&o->recv_interface); -} - -PacketRecvInterface * BufferWriter_GetOutput (BufferWriter *o) -{ - DebugObject_Access(&o->d_obj); - - return &o->recv_interface; -} - -int BufferWriter_StartPacket (BufferWriter *o, uint8_t **buf) -{ - ASSERT(!o->d_writing) - DebugObject_Access(&o->d_obj); - - if (!o->out_have) { - return 0; - } - - if (buf) { - *buf = o->out; - } - - #ifndef NDEBUG - o->d_writing = 1; - #endif - - return 1; -} - -void BufferWriter_EndPacket (BufferWriter *o, int len) -{ - ASSERT(len >= 0) - ASSERT(len <= o->d_mtu) - ASSERT(o->out_have) - ASSERT(o->d_writing) - DebugObject_Access(&o->d_obj); - - // set no output packet - o->out_have = 0; - - // finish packet - PacketRecvInterface_Done(&o->recv_interface, len); - - #ifndef NDEBUG - o->d_writing = 0; - #endif -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/BufferWriter.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/BufferWriter.h deleted file mode 100644 index e7848cfa..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/BufferWriter.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @file BufferWriter.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Object for writing packets to a {@link PacketRecvInterface} client - * in a best-effort fashion. - */ - -#ifndef BADVPN_FLOW_BUFFERWRITER_H -#define BADVPN_FLOW_BUFFERWRITER_H - -#include - -#include "misc/debug.h" -#include "base/DebugObject.h" -#include "flow/PacketRecvInterface.h" - -/** - * Object for writing packets to a {@link PacketRecvInterface} client - * in a best-effort fashion. - */ -typedef struct { - PacketRecvInterface recv_interface; - int out_have; - uint8_t *out; - DebugObject d_obj; - #ifndef NDEBUG - int d_mtu; - int d_writing; - #endif -} BufferWriter; - -/** - * Initializes the object. - * The object is initialized in not writing state. - * - * @param o the object - * @param mtu maximum input packet length - * @param pg pending group - */ -void BufferWriter_Init (BufferWriter *o, int mtu, BPendingGroup *pg); - -/** - * Frees the object. - * - * @param o the object - */ -void BufferWriter_Free (BufferWriter *o); - -/** - * Returns the output interface. - * - * @param o the object - * @return output interface - */ -PacketRecvInterface * BufferWriter_GetOutput (BufferWriter *o); - -/** - * Attempts to provide a memory location for writing a packet. - * The object must be in not writing state. - * On success, the object enters writing state. - * - * @param o the object - * @param buf if not NULL, on success, the memory location will be stored here. - * It will have space for MTU bytes. - * @return 1 on success, 0 on failure - */ -int BufferWriter_StartPacket (BufferWriter *o, uint8_t **buf) WARN_UNUSED; - -/** - * Submits a packet written to the buffer. - * The object must be in writing state. - * Yhe object enters not writing state. - * - * @param o the object - * @param len length of the packet that was written. Must be >=0 and - * <=MTU. - */ -void BufferWriter_EndPacket (BufferWriter *o, int len); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketBuffer.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketBuffer.c deleted file mode 100644 index 2367a390..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketBuffer.c +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @file PacketBuffer.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "misc/debug.h" -#include "misc/balloc.h" - -#include "flow/PacketBuffer.h" - -static void input_handler_done (PacketBuffer *buf, int in_len); -static void output_handler_done (PacketBuffer *buf); - -void input_handler_done (PacketBuffer *buf, int in_len) -{ - ASSERT(in_len >= 0) - ASSERT(in_len <= buf->input_mtu) - DebugObject_Access(&buf->d_obj); - - // remember if buffer is empty - int was_empty = (buf->buf.output_avail < 0); - - // submit packet to buffer - ChunkBuffer2_SubmitPacket(&buf->buf, in_len); - - // if there is space, schedule receive - if (buf->buf.input_avail >= buf->input_mtu) { - PacketRecvInterface_Receiver_Recv(buf->input, buf->buf.input_dest); - } - - // if buffer was empty, schedule send - if (was_empty) { - PacketPassInterface_Sender_Send(buf->output, buf->buf.output_dest, buf->buf.output_avail); - } -} - -void output_handler_done (PacketBuffer *buf) -{ - DebugObject_Access(&buf->d_obj); - - // remember if buffer is full - int was_full = (buf->buf.input_avail < buf->input_mtu); - - // remove packet from buffer - ChunkBuffer2_ConsumePacket(&buf->buf); - - // if buffer was full and there is space, schedule receive - if (was_full && buf->buf.input_avail >= buf->input_mtu) { - PacketRecvInterface_Receiver_Recv(buf->input, buf->buf.input_dest); - } - - // if there is more data, schedule send - if (buf->buf.output_avail >= 0) { - PacketPassInterface_Sender_Send(buf->output, buf->buf.output_dest, buf->buf.output_avail); - } -} - -int PacketBuffer_Init (PacketBuffer *buf, PacketRecvInterface *input, PacketPassInterface *output, int num_packets, BPendingGroup *pg) -{ - ASSERT(PacketPassInterface_GetMTU(output) >= PacketRecvInterface_GetMTU(input)) - ASSERT(num_packets > 0) - - // init arguments - buf->input = input; - buf->output = output; - - // init input - PacketRecvInterface_Receiver_Init(buf->input, (PacketRecvInterface_handler_done)input_handler_done, buf); - - // set input MTU - buf->input_mtu = PacketRecvInterface_GetMTU(buf->input); - - // init output - PacketPassInterface_Sender_Init(buf->output, (PacketPassInterface_handler_done)output_handler_done, buf); - - // allocate buffer - int num_blocks = ChunkBuffer2_calc_blocks(buf->input_mtu, num_packets); - if (num_blocks < 0) { - goto fail0; - } - if (!(buf->buf_data = (struct ChunkBuffer2_block *)BAllocArray(num_blocks, sizeof(buf->buf_data[0])))) { - goto fail0; - } - - // init buffer - ChunkBuffer2_Init(&buf->buf, buf->buf_data, num_blocks, buf->input_mtu); - - // schedule receive - PacketRecvInterface_Receiver_Recv(buf->input, buf->buf.input_dest); - - DebugObject_Init(&buf->d_obj); - - return 1; - -fail0: - return 0; -} - -void PacketBuffer_Free (PacketBuffer *buf) -{ - DebugObject_Free(&buf->d_obj); - - // free buffer - BFree(buf->buf_data); -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketBuffer.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketBuffer.h deleted file mode 100644 index 1cfa9afe..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketBuffer.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @file PacketBuffer.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Packet buffer with {@link PacketRecvInterface} input and {@link PacketPassInterface} output. - */ - -#ifndef BADVPN_FLOW_PACKETBUFFER_H -#define BADVPN_FLOW_PACKETBUFFER_H - -#include - -#include "misc/debug.h" -#include "base/DebugObject.h" -#include "structure/ChunkBuffer2.h" -#include "flow/PacketRecvInterface.h" -#include "flow/PacketPassInterface.h" - -/** - * Packet buffer with {@link PacketRecvInterface} input and {@link PacketPassInterface} output. - */ -typedef struct { - DebugObject d_obj; - PacketRecvInterface *input; - int input_mtu; - PacketPassInterface *output; - struct ChunkBuffer2_block *buf_data; - ChunkBuffer2 buf; -} PacketBuffer; - -/** - * Initializes the buffer. - * Output MTU must be >= input MTU. - * - * @param buf the object - * @param input input interface - * @param output output interface - * @param num_packets minimum number of packets the buffer must hold. Must be >0. - * @param pg pending group - * @return 1 on success, 0 on failure - */ -int PacketBuffer_Init (PacketBuffer *buf, PacketRecvInterface *input, PacketPassInterface *output, int num_packets, BPendingGroup *pg) WARN_UNUSED; - -/** - * Frees the buffer. - * - * @param buf the object - */ -void PacketBuffer_Free (PacketBuffer *buf); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassConnector.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassConnector.c deleted file mode 100644 index 3ccd4fec..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassConnector.c +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @file PacketPassConnector.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "misc/debug.h" - -#include "flow/PacketPassConnector.h" - -static void input_handler_send (PacketPassConnector *o, uint8_t *data, int data_len) -{ - ASSERT(data_len >= 0) - ASSERT(data_len <= o->input_mtu) - ASSERT(o->in_len == -1) - DebugObject_Access(&o->d_obj); - - // remember input packet - o->in_len = data_len; - o->in = data; - - if (o->output) { - // schedule send - PacketPassInterface_Sender_Send(o->output, o->in, o->in_len); - } -} - -static void output_handler_done (PacketPassConnector *o) -{ - ASSERT(o->in_len >= 0) - ASSERT(o->output) - DebugObject_Access(&o->d_obj); - - // have no input packet - o->in_len = -1; - - // allow input to send more packets - PacketPassInterface_Done(&o->input); -} - -void PacketPassConnector_Init (PacketPassConnector *o, int mtu, BPendingGroup *pg) -{ - ASSERT(mtu >= 0) - - // init arguments - o->input_mtu = mtu; - - // init input - PacketPassInterface_Init(&o->input, o->input_mtu, (PacketPassInterface_handler_send)input_handler_send, o, pg); - - // have no input packet - o->in_len = -1; - - // have no output - o->output = NULL; - - DebugObject_Init(&o->d_obj); -} - -void PacketPassConnector_Free (PacketPassConnector *o) -{ - DebugObject_Free(&o->d_obj); - - // free input - PacketPassInterface_Free(&o->input); -} - -PacketPassInterface * PacketPassConnector_GetInput (PacketPassConnector *o) -{ - DebugObject_Access(&o->d_obj); - - return &o->input; -} - -void PacketPassConnector_ConnectOutput (PacketPassConnector *o, PacketPassInterface *output) -{ - ASSERT(!o->output) - ASSERT(PacketPassInterface_GetMTU(output) >= o->input_mtu) - DebugObject_Access(&o->d_obj); - - // set output - o->output = output; - - // init output - PacketPassInterface_Sender_Init(o->output, (PacketPassInterface_handler_done)output_handler_done, o); - - // if we have an input packet, schedule send - if (o->in_len >= 0) { - PacketPassInterface_Sender_Send(o->output, o->in, o->in_len); - } -} - -void PacketPassConnector_DisconnectOutput (PacketPassConnector *o) -{ - ASSERT(o->output) - DebugObject_Access(&o->d_obj); - - // set no output - o->output = NULL; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassConnector.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassConnector.h deleted file mode 100644 index e960761c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassConnector.h +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @file PacketPassConnector.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * A {@link PacketPassInterface} layer which allows the output to be - * connected and disconnected on the fly. - */ - -#ifndef BADVPN_FLOW_PACKETPASSCONNECTOR_H -#define BADVPN_FLOW_PACKETPASSCONNECTOR_H - -#include - -#include "base/DebugObject.h" -#include "flow/PacketPassInterface.h" - -/** - * A {@link PacketPassInterface} layer which allows the output to be - * connected and disconnected on the fly. - */ -typedef struct { - PacketPassInterface input; - int input_mtu; - int in_len; - uint8_t *in; - PacketPassInterface *output; - DebugObject d_obj; -} PacketPassConnector; - -/** - * Initializes the object. - * The object is initialized in not connected state. - * - * @param o the object - * @param mtu maximum input packet size. Must be >=0. - * @param pg pending group - */ -void PacketPassConnector_Init (PacketPassConnector *o, int mtu, BPendingGroup *pg); - -/** - * Frees the object. - * - * @param o the object - */ -void PacketPassConnector_Free (PacketPassConnector *o); - -/** - * Returns the input interface. - * The MTU of the interface will be as in {@link PacketPassConnector_Init}. - * - * @param o the object - * @return input interface - */ -PacketPassInterface * PacketPassConnector_GetInput (PacketPassConnector *o); - -/** - * Connects output. - * The object must be in not connected state. - * The object enters connected state. - * - * @param o the object - * @param output output to connect. Its MTU must be >= MTU specified in - * {@link PacketPassConnector_Init}. - */ -void PacketPassConnector_ConnectOutput (PacketPassConnector *o, PacketPassInterface *output); - -/** - * Disconnects output. - * The object must be in connected state. - * The object enters not connected state. - * - * @param o the object - */ -void PacketPassConnector_DisconnectOutput (PacketPassConnector *o); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassFairQueue.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassFairQueue.c deleted file mode 100644 index 1037b8f8..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassFairQueue.c +++ /dev/null @@ -1,405 +0,0 @@ -/** - * @file PacketPassFairQueue.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "misc/debug.h" -#include "misc/offset.h" -#include "misc/minmax.h" -#include "misc/compare.h" - -#include "flow/PacketPassFairQueue.h" - -static int compare_flows (PacketPassFairQueueFlow *f1, PacketPassFairQueueFlow *f2) -{ - int cmp = B_COMPARE(f1->time, f2->time); - if (cmp) { - return cmp; - } - - return B_COMPARE((uintptr_t)f1, (uintptr_t)f2); -} - -#include "PacketPassFairQueue_tree.h" -#include "structure/SAvl_impl.h" - -static uint64_t get_current_time (PacketPassFairQueue *m) -{ - if (m->sending_flow) { - return m->sending_flow->time; - } - - uint64_t time = 0; // to remove warning - int have = 0; - - PacketPassFairQueueFlow *first_flow = PacketPassFairQueue__Tree_GetFirst(&m->queued_tree, 0); - if (first_flow) { - ASSERT(first_flow->is_queued) - - time = first_flow->time; - have = 1; - } - - if (m->previous_flow) { - if (!have || m->previous_flow->time < time) { - time = m->previous_flow->time; - have = 1; - } - } - - return (have ? time : 0); -} - -static void increment_sent_flow (PacketPassFairQueueFlow *flow, uint64_t amount) -{ - PacketPassFairQueue *m = flow->m; - - ASSERT(amount <= FAIRQUEUE_MAX_TIME) - ASSERT(!flow->is_queued) - ASSERT(!m->sending_flow) - - // does time overflow? - if (amount > FAIRQUEUE_MAX_TIME - flow->time) { - // get time to subtract - uint64_t subtract; - PacketPassFairQueueFlow *first_flow = PacketPassFairQueue__Tree_GetFirst(&m->queued_tree, 0); - if (!first_flow) { - subtract = flow->time; - } else { - ASSERT(first_flow->is_queued) - subtract = first_flow->time; - } - - // subtract time from all flows - for (LinkedList1Node *list_node = LinkedList1_GetFirst(&m->flows_list); list_node; list_node = LinkedList1Node_Next(list_node)) { - PacketPassFairQueueFlow *someflow = UPPER_OBJECT(list_node, PacketPassFairQueueFlow, list_node); - - // don't subtract more time than there is, except for the just finished flow, - // where we allow time to underflow and then overflow to the correct value after adding to it - if (subtract > someflow->time && someflow != flow) { - ASSERT(!someflow->is_queued) - someflow->time = 0; - } else { - someflow->time -= subtract; - } - } - } - - // add time to flow - flow->time += amount; -} - -static void schedule (PacketPassFairQueue *m) -{ - ASSERT(!m->sending_flow) - ASSERT(!m->previous_flow) - ASSERT(!m->freeing) - ASSERT(!PacketPassFairQueue__Tree_IsEmpty(&m->queued_tree)) - - // get first queued flow - PacketPassFairQueueFlow *qflow = PacketPassFairQueue__Tree_GetFirst(&m->queued_tree, 0); - ASSERT(qflow->is_queued) - - // remove flow from queue - PacketPassFairQueue__Tree_Remove(&m->queued_tree, 0, qflow); - qflow->is_queued = 0; - - // schedule send - PacketPassInterface_Sender_Send(m->output, qflow->queued.data, qflow->queued.data_len); - m->sending_flow = qflow; - m->sending_len = qflow->queued.data_len; -} - -static void schedule_job_handler (PacketPassFairQueue *m) -{ - ASSERT(!m->sending_flow) - ASSERT(!m->freeing) - DebugObject_Access(&m->d_obj); - - // remove previous flow - m->previous_flow = NULL; - - if (!PacketPassFairQueue__Tree_IsEmpty(&m->queued_tree)) { - schedule(m); - } -} - -static void input_handler_send (PacketPassFairQueueFlow *flow, uint8_t *data, int data_len) -{ - PacketPassFairQueue *m = flow->m; - - ASSERT(flow != m->sending_flow) - ASSERT(!flow->is_queued) - ASSERT(!m->freeing) - DebugObject_Access(&flow->d_obj); - - if (flow == m->previous_flow) { - // remove from previous flow - m->previous_flow = NULL; - } else { - // raise time - flow->time = bmax_uint64(flow->time, get_current_time(m)); - } - - // queue flow - flow->queued.data = data; - flow->queued.data_len = data_len; - int res = PacketPassFairQueue__Tree_Insert(&m->queued_tree, 0, flow, NULL); - ASSERT_EXECUTE(res) - flow->is_queued = 1; - - if (!m->sending_flow && !BPending_IsSet(&m->schedule_job)) { - schedule(m); - } -} - -static void output_handler_done (PacketPassFairQueue *m) -{ - ASSERT(m->sending_flow) - ASSERT(!m->previous_flow) - ASSERT(!BPending_IsSet(&m->schedule_job)) - ASSERT(!m->freeing) - ASSERT(!m->sending_flow->is_queued) - - PacketPassFairQueueFlow *flow = m->sending_flow; - - // sending finished - m->sending_flow = NULL; - - // remember this flow so the schedule job can remove its time if it didn's send - m->previous_flow = flow; - - // update flow time by packet size - increment_sent_flow(flow, (uint64_t)m->packet_weight + m->sending_len); - - // schedule schedule - BPending_Set(&m->schedule_job); - - // finish flow packet - PacketPassInterface_Done(&flow->input); - - // call busy handler if set - if (flow->handler_busy) { - // handler is one-shot, unset it before calling - PacketPassFairQueue_handler_busy handler = flow->handler_busy; - flow->handler_busy = NULL; - - // call handler - handler(flow->user); - return; - } -} - -int PacketPassFairQueue_Init (PacketPassFairQueue *m, PacketPassInterface *output, BPendingGroup *pg, int use_cancel, int packet_weight) -{ - ASSERT(packet_weight > 0) - ASSERT(use_cancel == 0 || use_cancel == 1) - ASSERT(!use_cancel || PacketPassInterface_HasCancel(output)) - - // init arguments - m->output = output; - m->pg = pg; - m->use_cancel = use_cancel; - m->packet_weight = packet_weight; - - // make sure that (output MTU + packet_weight <= FAIRQUEUE_MAX_TIME) - if (!( - (PacketPassInterface_GetMTU(output) <= FAIRQUEUE_MAX_TIME) && - (packet_weight <= FAIRQUEUE_MAX_TIME - PacketPassInterface_GetMTU(output)) - )) { - goto fail0; - } - - // init output - PacketPassInterface_Sender_Init(m->output, (PacketPassInterface_handler_done)output_handler_done, m); - - // not sending - m->sending_flow = NULL; - - // no previous flow - m->previous_flow = NULL; - - // init queued tree - PacketPassFairQueue__Tree_Init(&m->queued_tree); - - // init flows list - LinkedList1_Init(&m->flows_list); - - // not freeing - m->freeing = 0; - - // init schedule job - BPending_Init(&m->schedule_job, m->pg, (BPending_handler)schedule_job_handler, m); - - DebugObject_Init(&m->d_obj); - DebugCounter_Init(&m->d_ctr); - return 1; - -fail0: - return 0; -} - -void PacketPassFairQueue_Free (PacketPassFairQueue *m) -{ - ASSERT(LinkedList1_IsEmpty(&m->flows_list)) - ASSERT(PacketPassFairQueue__Tree_IsEmpty(&m->queued_tree)) - ASSERT(!m->previous_flow) - ASSERT(!m->sending_flow) - DebugCounter_Free(&m->d_ctr); - DebugObject_Free(&m->d_obj); - - // free schedule job - BPending_Free(&m->schedule_job); -} - -void PacketPassFairQueue_PrepareFree (PacketPassFairQueue *m) -{ - DebugObject_Access(&m->d_obj); - - // set freeing - m->freeing = 1; -} - -int PacketPassFairQueue_GetMTU (PacketPassFairQueue *m) -{ - DebugObject_Access(&m->d_obj); - - return PacketPassInterface_GetMTU(m->output); -} - -void PacketPassFairQueueFlow_Init (PacketPassFairQueueFlow *flow, PacketPassFairQueue *m) -{ - ASSERT(!m->freeing) - DebugObject_Access(&m->d_obj); - - // init arguments - flow->m = m; - - // have no canfree handler - flow->handler_busy = NULL; - - // init input - PacketPassInterface_Init(&flow->input, PacketPassInterface_GetMTU(flow->m->output), (PacketPassInterface_handler_send)input_handler_send, flow, m->pg); - - // set time - flow->time = 0; - - // add to flows list - LinkedList1_Append(&m->flows_list, &flow->list_node); - - // is not queued - flow->is_queued = 0; - - DebugObject_Init(&flow->d_obj); - DebugCounter_Increment(&m->d_ctr); -} - -void PacketPassFairQueueFlow_Free (PacketPassFairQueueFlow *flow) -{ - PacketPassFairQueue *m = flow->m; - - ASSERT(m->freeing || flow != m->sending_flow) - DebugCounter_Decrement(&m->d_ctr); - DebugObject_Free(&flow->d_obj); - - // remove from current flow - if (flow == m->sending_flow) { - m->sending_flow = NULL; - } - - // remove from previous flow - if (flow == m->previous_flow) { - m->previous_flow = NULL; - } - - // remove from queue - if (flow->is_queued) { - PacketPassFairQueue__Tree_Remove(&m->queued_tree, 0, flow); - } - - // remove from flows list - LinkedList1_Remove(&m->flows_list, &flow->list_node); - - // free input - PacketPassInterface_Free(&flow->input); -} - -void PacketPassFairQueueFlow_AssertFree (PacketPassFairQueueFlow *flow) -{ - PacketPassFairQueue *m = flow->m; - B_USE(m) - - ASSERT(m->freeing || flow != m->sending_flow) - DebugObject_Access(&flow->d_obj); -} - -int PacketPassFairQueueFlow_IsBusy (PacketPassFairQueueFlow *flow) -{ - PacketPassFairQueue *m = flow->m; - - ASSERT(!m->freeing) - DebugObject_Access(&flow->d_obj); - - return (flow == m->sending_flow); -} - -void PacketPassFairQueueFlow_RequestCancel (PacketPassFairQueueFlow *flow) -{ - PacketPassFairQueue *m = flow->m; - - ASSERT(flow == m->sending_flow) - ASSERT(m->use_cancel) - ASSERT(!m->freeing) - ASSERT(!BPending_IsSet(&m->schedule_job)) - DebugObject_Access(&flow->d_obj); - - // request cancel - PacketPassInterface_Sender_RequestCancel(m->output); -} - -void PacketPassFairQueueFlow_SetBusyHandler (PacketPassFairQueueFlow *flow, PacketPassFairQueue_handler_busy handler, void *user) -{ - PacketPassFairQueue *m = flow->m; - B_USE(m) - - ASSERT(flow == m->sending_flow) - ASSERT(!m->freeing) - DebugObject_Access(&flow->d_obj); - - // set handler - flow->handler_busy = handler; - flow->user = user; -} - -PacketPassInterface * PacketPassFairQueueFlow_GetInput (PacketPassFairQueueFlow *flow) -{ - DebugObject_Access(&flow->d_obj); - - return &flow->input; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassFairQueue.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassFairQueue.h deleted file mode 100644 index 47bf5161..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassFairQueue.h +++ /dev/null @@ -1,204 +0,0 @@ -/** - * @file PacketPassFairQueue.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Fair queue using {@link PacketPassInterface}. - */ - -#ifndef BADVPN_FLOW_PACKETPASSFAIRQUEUE_H -#define BADVPN_FLOW_PACKETPASSFAIRQUEUE_H - -#include - -#include "misc/debug.h" -#include "misc/debugcounter.h" -#include "structure/SAvl.h" -#include "structure/LinkedList1.h" -#include "base/DebugObject.h" -#include "base/BPending.h" -#include "flow/PacketPassInterface.h" - -// reduce this to test time overflow handling -#define FAIRQUEUE_MAX_TIME UINT64_MAX - -typedef void (*PacketPassFairQueue_handler_busy) (void *user); - -struct PacketPassFairQueueFlow_s; - -#include "PacketPassFairQueue_tree.h" -#include "structure/SAvl_decl.h" - -typedef struct PacketPassFairQueueFlow_s { - struct PacketPassFairQueue_s *m; - PacketPassFairQueue_handler_busy handler_busy; - void *user; - PacketPassInterface input; - uint64_t time; - LinkedList1Node list_node; - int is_queued; - struct { - PacketPassFairQueue__TreeNode tree_node; - uint8_t *data; - int data_len; - } queued; - DebugObject d_obj; -} PacketPassFairQueueFlow; - -/** - * Fair queue using {@link PacketPassInterface}. - */ -typedef struct PacketPassFairQueue_s { - PacketPassInterface *output; - BPendingGroup *pg; - int use_cancel; - int packet_weight; - struct PacketPassFairQueueFlow_s *sending_flow; - int sending_len; - struct PacketPassFairQueueFlow_s *previous_flow; - PacketPassFairQueue__Tree queued_tree; - LinkedList1 flows_list; - int freeing; - BPending schedule_job; - DebugObject d_obj; - DebugCounter d_ctr; -} PacketPassFairQueue; - -/** - * Initializes the queue. - * - * @param m the object - * @param output output interface - * @param pg pending group - * @param use_cancel whether cancel functionality is required. Must be 0 or 1. - * If 1, output must support cancel functionality. - * @param packet_weight additional weight a packet bears. Must be >0, to keep - * the queue fair for zero size packets. - * @return 1 on success, 0 on failure (because output MTU is too large) - */ -int PacketPassFairQueue_Init (PacketPassFairQueue *m, PacketPassInterface *output, BPendingGroup *pg, int use_cancel, int packet_weight) WARN_UNUSED; - -/** - * Frees the queue. - * All flows must have been freed. - * - * @param m the object - */ -void PacketPassFairQueue_Free (PacketPassFairQueue *m); - -/** - * Prepares for freeing the entire queue. Must be called to allow freeing - * the flows in the process of freeing the entire queue. - * After this function is called, flows and the queue must be freed - * before any further I/O. - * May be called multiple times. - * The queue enters freeing state. - * - * @param m the object - */ -void PacketPassFairQueue_PrepareFree (PacketPassFairQueue *m); - -/** - * Returns the MTU of the queue. - * - * @param m the object - */ -int PacketPassFairQueue_GetMTU (PacketPassFairQueue *m); - -/** - * Initializes a queue flow. - * Queue must not be in freeing state. - * Must not be called from queue calls to output. - * - * @param flow the object - * @param m queue to attach to - */ -void PacketPassFairQueueFlow_Init (PacketPassFairQueueFlow *flow, PacketPassFairQueue *m); - -/** - * Frees a queue flow. - * Unless the queue is in freeing state: - * - The flow must not be busy as indicated by {@link PacketPassFairQueueFlow_IsBusy}. - * - Must not be called from queue calls to output. - * - * @param flow the object - */ -void PacketPassFairQueueFlow_Free (PacketPassFairQueueFlow *flow); - -/** - * Does nothing. - * It must be possible to free the flow (see {@link PacketPassFairQueueFlow_Free}). - * - * @param flow the object - */ -void PacketPassFairQueueFlow_AssertFree (PacketPassFairQueueFlow *flow); - -/** - * Determines if the flow is busy. If the flow is considered busy, it must not - * be freed. At any given time, at most one flow will be indicated as busy. - * Queue must not be in freeing state. - * Must not be called from queue calls to output. - * - * @param flow the object - * @return 0 if not busy, 1 is busy - */ -int PacketPassFairQueueFlow_IsBusy (PacketPassFairQueueFlow *flow); - -/** - * Requests the output to stop processing the current packet as soon as possible. - * Cancel functionality must be enabled for the queue. - * The flow must be busy as indicated by {@link PacketPassFairQueueFlow_IsBusy}. - * Queue must not be in freeing state. - * - * @param flow the object - */ -void PacketPassFairQueueFlow_RequestCancel (PacketPassFairQueueFlow *flow); - -/** - * Sets up a callback to be called when the flow is no longer busy. - * The handler will be called as soon as the flow is no longer busy, i.e. it is not - * possible that this flow is no longer busy before the handler is called. - * The flow must be busy as indicated by {@link PacketPassFairQueueFlow_IsBusy}. - * Queue must not be in freeing state. - * Must not be called from queue calls to output. - * - * @param flow the object - * @param handler callback function. NULL to disable. - * @param user value passed to callback function. Ignored if handler is NULL. - */ -void PacketPassFairQueueFlow_SetBusyHandler (PacketPassFairQueueFlow *flow, PacketPassFairQueue_handler_busy handler, void *user); - -/** - * Returns the input interface of the flow. - * - * @param flow the object - * @return input interface - */ -PacketPassInterface * PacketPassFairQueueFlow_GetInput (PacketPassFairQueueFlow *flow); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassFairQueue_tree.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassFairQueue_tree.h deleted file mode 100644 index 5dd0a7d4..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassFairQueue_tree.h +++ /dev/null @@ -1,7 +0,0 @@ -#define SAVL_PARAM_NAME PacketPassFairQueue__Tree -#define SAVL_PARAM_FEATURE_COUNTS 0 -#define SAVL_PARAM_FEATURE_NOKEYS 1 -#define SAVL_PARAM_TYPE_ENTRY struct PacketPassFairQueueFlow_s -#define SAVL_PARAM_TYPE_ARG int -#define SAVL_PARAM_FUN_COMPARE_ENTRIES(arg, entry1, entry2) compare_flows((entry1), (entry2)) -#define SAVL_PARAM_MEMBER_NODE queued.tree_node diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassInterface.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassInterface.c deleted file mode 100644 index 9c53003b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassInterface.c +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file PacketPassInterface.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "flow/PacketPassInterface.h" - -void _PacketPassInterface_job_operation (PacketPassInterface *i) -{ - ASSERT(i->state == PPI_STATE_OPERATION_PENDING) - DebugObject_Access(&i->d_obj); - - // set state - i->state = PPI_STATE_BUSY; - - // call handler - i->handler_operation(i->user_provider, i->job_operation_data, i->job_operation_len); - return; -} - -void _PacketPassInterface_job_requestcancel (PacketPassInterface *i) -{ - ASSERT(i->state == PPI_STATE_BUSY) - ASSERT(i->cancel_requested) - ASSERT(i->handler_requestcancel) - DebugObject_Access(&i->d_obj); - - // call handler - i->handler_requestcancel(i->user_provider); - return; -} - -void _PacketPassInterface_job_done (PacketPassInterface *i) -{ - ASSERT(i->state == PPI_STATE_DONE_PENDING) - DebugObject_Access(&i->d_obj); - - // set state - i->state = PPI_STATE_NONE; - - // call handler - i->handler_done(i->user_user); - return; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassInterface.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassInterface.h deleted file mode 100644 index bcd5c619..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketPassInterface.h +++ /dev/null @@ -1,236 +0,0 @@ -/** - * @file PacketPassInterface.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Interface allowing a packet sender to pass data packets to a packet receiver. - */ - -#ifndef BADVPN_FLOW_PACKETPASSINTERFACE_H -#define BADVPN_FLOW_PACKETPASSINTERFACE_H - -#include -#include - -#include "misc/debug.h" -#include "base/DebugObject.h" -#include "base/BPending.h" - -#define PPI_STATE_NONE 1 -#define PPI_STATE_OPERATION_PENDING 2 -#define PPI_STATE_BUSY 3 -#define PPI_STATE_DONE_PENDING 4 - -typedef void (*PacketPassInterface_handler_send) (void *user, uint8_t *data, int data_len); - -typedef void (*PacketPassInterface_handler_requestcancel) (void *user); - -typedef void (*PacketPassInterface_handler_done) (void *user); - -typedef struct { - // provider data - int mtu; - PacketPassInterface_handler_send handler_operation; - PacketPassInterface_handler_requestcancel handler_requestcancel; - void *user_provider; - - // user data - PacketPassInterface_handler_done handler_done; - void *user_user; - - // operation job - BPending job_operation; - uint8_t *job_operation_data; - int job_operation_len; - - // requestcancel job - BPending job_requestcancel; - - // done job - BPending job_done; - - // state - int state; - int cancel_requested; - - DebugObject d_obj; -} PacketPassInterface; - -static void PacketPassInterface_Init (PacketPassInterface *i, int mtu, PacketPassInterface_handler_send handler_operation, void *user, BPendingGroup *pg); - -static void PacketPassInterface_Free (PacketPassInterface *i); - -static void PacketPassInterface_EnableCancel (PacketPassInterface *i, PacketPassInterface_handler_requestcancel handler_requestcancel); - -static void PacketPassInterface_Done (PacketPassInterface *i); - -static int PacketPassInterface_GetMTU (PacketPassInterface *i); - -static void PacketPassInterface_Sender_Init (PacketPassInterface *i, PacketPassInterface_handler_done handler_done, void *user); - -static void PacketPassInterface_Sender_Send (PacketPassInterface *i, uint8_t *data, int data_len); - -static void PacketPassInterface_Sender_RequestCancel (PacketPassInterface *i); - -static int PacketPassInterface_HasCancel (PacketPassInterface *i); - -void _PacketPassInterface_job_operation (PacketPassInterface *i); -void _PacketPassInterface_job_requestcancel (PacketPassInterface *i); -void _PacketPassInterface_job_done (PacketPassInterface *i); - -void PacketPassInterface_Init (PacketPassInterface *i, int mtu, PacketPassInterface_handler_send handler_operation, void *user, BPendingGroup *pg) -{ - ASSERT(mtu >= 0) - - // init arguments - i->mtu = mtu; - i->handler_operation = handler_operation; - i->handler_requestcancel = NULL; - i->user_provider = user; - - // set no user - i->handler_done = NULL; - - // init jobs - BPending_Init(&i->job_operation, pg, (BPending_handler)_PacketPassInterface_job_operation, i); - BPending_Init(&i->job_requestcancel, pg, (BPending_handler)_PacketPassInterface_job_requestcancel, i); - BPending_Init(&i->job_done, pg, (BPending_handler)_PacketPassInterface_job_done, i); - - // set state - i->state = PPI_STATE_NONE; - - DebugObject_Init(&i->d_obj); -} - -void PacketPassInterface_Free (PacketPassInterface *i) -{ - DebugObject_Free(&i->d_obj); - - // free jobs - BPending_Free(&i->job_done); - BPending_Free(&i->job_requestcancel); - BPending_Free(&i->job_operation); -} - -void PacketPassInterface_EnableCancel (PacketPassInterface *i, PacketPassInterface_handler_requestcancel handler_requestcancel) -{ - ASSERT(!i->handler_requestcancel) - ASSERT(!i->handler_done) - ASSERT(handler_requestcancel) - - i->handler_requestcancel = handler_requestcancel; -} - -void PacketPassInterface_Done (PacketPassInterface *i) -{ - ASSERT(i->state == PPI_STATE_BUSY) - DebugObject_Access(&i->d_obj); - - // unset requestcancel job - BPending_Unset(&i->job_requestcancel); - - // schedule done - BPending_Set(&i->job_done); - - // set state - i->state = PPI_STATE_DONE_PENDING; -} - -int PacketPassInterface_GetMTU (PacketPassInterface *i) -{ - DebugObject_Access(&i->d_obj); - - return i->mtu; -} - -void PacketPassInterface_Sender_Init (PacketPassInterface *i, PacketPassInterface_handler_done handler_done, void *user) -{ - ASSERT(handler_done) - ASSERT(!i->handler_done) - DebugObject_Access(&i->d_obj); - - i->handler_done = handler_done; - i->user_user = user; -} - -void PacketPassInterface_Sender_Send (PacketPassInterface *i, uint8_t *data, int data_len) -{ - ASSERT(data_len >= 0) - ASSERT(data_len <= i->mtu) - ASSERT(!(data_len > 0) || data) - ASSERT(i->state == PPI_STATE_NONE) - ASSERT(i->handler_done) - DebugObject_Access(&i->d_obj); - - // schedule operation - i->job_operation_data = data; - i->job_operation_len = data_len; - BPending_Set(&i->job_operation); - - // set state - i->state = PPI_STATE_OPERATION_PENDING; - i->cancel_requested = 0; -} - -void PacketPassInterface_Sender_RequestCancel (PacketPassInterface *i) -{ - ASSERT(i->state == PPI_STATE_OPERATION_PENDING || i->state == PPI_STATE_BUSY || i->state == PPI_STATE_DONE_PENDING) - ASSERT(i->handler_requestcancel) - DebugObject_Access(&i->d_obj); - - // ignore multiple cancel requests - if (i->cancel_requested) { - return; - } - - // remember we requested cancel - i->cancel_requested = 1; - - if (i->state == PPI_STATE_OPERATION_PENDING) { - // unset operation job - BPending_Unset(&i->job_operation); - - // set done job - BPending_Set(&i->job_done); - - // set state - i->state = PPI_STATE_DONE_PENDING; - } else if (i->state == PPI_STATE_BUSY) { - // set requestcancel job - BPending_Set(&i->job_requestcancel); - } -} - -int PacketPassInterface_HasCancel (PacketPassInterface *i) -{ - DebugObject_Access(&i->d_obj); - - return !!i->handler_requestcancel; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoDecoder.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoDecoder.c deleted file mode 100644 index a2cc2b63..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoDecoder.c +++ /dev/null @@ -1,182 +0,0 @@ -/** - * @file PacketProtoDecoder.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include "misc/debug.h" -#include "misc/byteorder.h" -#include "misc/minmax.h" -#include "base/BLog.h" - -#include "flow/PacketProtoDecoder.h" - -#include "generated/blog_channel_PacketProtoDecoder.h" - -static void process_data (PacketProtoDecoder *enc); -static void input_handler_done (PacketProtoDecoder *enc, int data_len); -static void output_handler_done (PacketProtoDecoder *enc); - -void process_data (PacketProtoDecoder *enc) -{ - int was_error = 0; - - do { - uint8_t *data = enc->buf + enc->buf_start; - int left = enc->buf_used; - - // check if header was received - if (left < sizeof(struct packetproto_header)) { - break; - } - struct packetproto_header header; - memcpy(&header, data, sizeof(header)); - data += sizeof(struct packetproto_header); - left -= sizeof(struct packetproto_header); - int data_len = ltoh16(header.len); - - // check data length - if (data_len > enc->output_mtu) { - BLog(BLOG_NOTICE, "error: packet too large"); - was_error = 1; - break; - } - - // check if whole packet was received - if (left < data_len) { - break; - } - - // update buffer - enc->buf_start += sizeof(struct packetproto_header) + data_len; - enc->buf_used -= sizeof(struct packetproto_header) + data_len; - - // submit packet - PacketPassInterface_Sender_Send(enc->output, data, data_len); - return; - } while (0); - - if (was_error) { - // reset buffer - enc->buf_start = 0; - enc->buf_used = 0; - } else { - // if we reached the end of the buffer, wrap around to allow more data to be received - if (enc->buf_start + enc->buf_used == enc->buf_size) { - memmove(enc->buf, enc->buf + enc->buf_start, enc->buf_used); - enc->buf_start = 0; - } - } - - // receive data - StreamRecvInterface_Receiver_Recv(enc->input, enc->buf + (enc->buf_start + enc->buf_used), enc->buf_size - (enc->buf_start + enc->buf_used)); - - // if we had error, report it - if (was_error) { - enc->handler_error(enc->user); - return; - } -} - -static void input_handler_done (PacketProtoDecoder *enc, int data_len) -{ - ASSERT(data_len > 0) - ASSERT(data_len <= enc->buf_size - (enc->buf_start + enc->buf_used)) - DebugObject_Access(&enc->d_obj); - - // update buffer - enc->buf_used += data_len; - - // process data - process_data(enc); - return; -} - -void output_handler_done (PacketProtoDecoder *enc) -{ - DebugObject_Access(&enc->d_obj); - - // process data - process_data(enc); - return; -} - -int PacketProtoDecoder_Init (PacketProtoDecoder *enc, StreamRecvInterface *input, PacketPassInterface *output, BPendingGroup *pg, void *user, PacketProtoDecoder_handler_error handler_error) -{ - // init arguments - enc->input = input; - enc->output = output; - enc->user = user; - enc->handler_error = handler_error; - - // init input - StreamRecvInterface_Receiver_Init(enc->input, (StreamRecvInterface_handler_done)input_handler_done, enc); - - // init output - PacketPassInterface_Sender_Init(enc->output, (PacketPassInterface_handler_done)output_handler_done, enc); - - // set output MTU, limit by maximum payload size - enc->output_mtu = bmin_int(PacketPassInterface_GetMTU(enc->output), PACKETPROTO_MAXPAYLOAD); - - // init buffer state - enc->buf_size = PACKETPROTO_ENCLEN(enc->output_mtu); - enc->buf_start = 0; - enc->buf_used = 0; - - // allocate buffer - if (!(enc->buf = (uint8_t *)malloc(enc->buf_size))) { - goto fail0; - } - - // start receiving - StreamRecvInterface_Receiver_Recv(enc->input, enc->buf, enc->buf_size); - - DebugObject_Init(&enc->d_obj); - - return 1; - -fail0: - return 0; -} - -void PacketProtoDecoder_Free (PacketProtoDecoder *enc) -{ - DebugObject_Free(&enc->d_obj); - - // free buffer - free(enc->buf); -} - -void PacketProtoDecoder_Reset (PacketProtoDecoder *enc) -{ - DebugObject_Access(&enc->d_obj); - - enc->buf_start += enc->buf_used; - enc->buf_used = 0; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoDecoder.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoDecoder.h deleted file mode 100644 index 8cece5ba..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoDecoder.h +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @file PacketProtoDecoder.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Object which decodes a stream according to PacketProto. - */ - -#ifndef BADVPN_FLOW_PACKETPROTODECODER_H -#define BADVPN_FLOW_PACKETPROTODECODER_H - -#include - -#include "protocol/packetproto.h" -#include "misc/debug.h" -#include "base/DebugObject.h" -#include "flow/StreamRecvInterface.h" -#include "flow/PacketPassInterface.h" - -/** - * Handler called when a protocol error occurs. - * When an error occurs, the decoder is reset to the initial state. - * - * @param user as in {@link PacketProtoDecoder_Init} - */ -typedef void (*PacketProtoDecoder_handler_error) (void *user); - -typedef struct { - StreamRecvInterface *input; - PacketPassInterface *output; - void *user; - PacketProtoDecoder_handler_error handler_error; - int output_mtu; - int buf_size; - int buf_start; - int buf_used; - uint8_t *buf; - DebugObject d_obj; -} PacketProtoDecoder; - -/** - * Initializes the object. - * - * @param enc the object - * @param input input interface. The decoder will accept packets with payload size up to its MTU - * (but the payload can never be more than PACKETPROTO_MAXPAYLOAD). - * @param output output interface - * @param pg pending group - * @param user argument to handlers - * @param handler_error error handler - * @return 1 on success, 0 on failure - */ -int PacketProtoDecoder_Init (PacketProtoDecoder *enc, StreamRecvInterface *input, PacketPassInterface *output, BPendingGroup *pg, void *user, PacketProtoDecoder_handler_error handler_error) WARN_UNUSED; - -/** - * Frees the object. - * - * @param enc the object - */ -void PacketProtoDecoder_Free (PacketProtoDecoder *enc); - -/** - * Clears the internal buffer. - * The next data received from the input will be treated as a new - * PacketProto stream. - * - * @param enc the object - */ -void PacketProtoDecoder_Reset (PacketProtoDecoder *enc); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoEncoder.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoEncoder.c deleted file mode 100644 index 64c542df..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoEncoder.c +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file PacketProtoEncoder.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include "protocol/packetproto.h" -#include "misc/balign.h" -#include "misc/debug.h" -#include "misc/byteorder.h" - -#include "flow/PacketProtoEncoder.h" - -static void output_handler_recv (PacketProtoEncoder *enc, uint8_t *data) -{ - ASSERT(!enc->output_packet) - ASSERT(data) - DebugObject_Access(&enc->d_obj); - - // schedule receive - enc->output_packet = data; - PacketRecvInterface_Receiver_Recv(enc->input, enc->output_packet + sizeof(struct packetproto_header)); -} - -static void input_handler_done (PacketProtoEncoder *enc, int in_len) -{ - ASSERT(enc->output_packet) - DebugObject_Access(&enc->d_obj); - - // write length - struct packetproto_header pp; - pp.len = htol16(in_len); - memcpy(enc->output_packet, &pp, sizeof(pp)); - - // finish output packet - enc->output_packet = NULL; - PacketRecvInterface_Done(&enc->output, PACKETPROTO_ENCLEN(in_len)); -} - -void PacketProtoEncoder_Init (PacketProtoEncoder *enc, PacketRecvInterface *input, BPendingGroup *pg) -{ - ASSERT(PacketRecvInterface_GetMTU(input) <= PACKETPROTO_MAXPAYLOAD) - - // init arguments - enc->input = input; - - // init input - PacketRecvInterface_Receiver_Init(enc->input, (PacketRecvInterface_handler_done)input_handler_done, enc); - - // init output - PacketRecvInterface_Init( - &enc->output, PACKETPROTO_ENCLEN(PacketRecvInterface_GetMTU(enc->input)), - (PacketRecvInterface_handler_recv)output_handler_recv, enc, pg - ); - - // set no output packet - enc->output_packet = NULL; - - DebugObject_Init(&enc->d_obj); -} - -void PacketProtoEncoder_Free (PacketProtoEncoder *enc) -{ - DebugObject_Free(&enc->d_obj); - - // free input - PacketRecvInterface_Free(&enc->output); -} - -PacketRecvInterface * PacketProtoEncoder_GetOutput (PacketProtoEncoder *enc) -{ - DebugObject_Access(&enc->d_obj); - - return &enc->output; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoEncoder.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoEncoder.h deleted file mode 100644 index c0bf9a2c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoEncoder.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @file PacketProtoEncoder.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Object which encodes packets according to PacketProto. - */ - -#ifndef BADVPN_FLOW_PACKETPROTOENCODER_H -#define BADVPN_FLOW_PACKETPROTOENCODER_H - -#include - -#include "base/DebugObject.h" -#include "flow/PacketRecvInterface.h" - -/** - * Object which encodes packets according to PacketProto. - * - * Input is with {@link PacketRecvInterface}. - * Output is with {@link PacketRecvInterface}. - */ -typedef struct { - PacketRecvInterface *input; - PacketRecvInterface output; - uint8_t *output_packet; - DebugObject d_obj; -} PacketProtoEncoder; - -/** - * Initializes the object. - * - * @param enc the object - * @param input input interface. Its MTU must be <=PACKETPROTO_MAXPAYLOAD. - * @param pg pending group - */ -void PacketProtoEncoder_Init (PacketProtoEncoder *enc, PacketRecvInterface *input, BPendingGroup *pg); - -/** - * Frees the object. - * - * @param enc the object - */ -void PacketProtoEncoder_Free (PacketProtoEncoder *enc); - -/** - * Returns the output interface. - * The MTU of the output interface is PACKETPROTO_ENCLEN(MTU of input interface). - * - * @param enc the object - * @return output interface - */ -PacketRecvInterface * PacketProtoEncoder_GetOutput (PacketProtoEncoder *enc); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoFlow.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoFlow.c deleted file mode 100644 index bb63eb52..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoFlow.c +++ /dev/null @@ -1,82 +0,0 @@ -/** - * @file PacketProtoFlow.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "protocol/packetproto.h" -#include "misc/debug.h" - -#include "flow/PacketProtoFlow.h" - -int PacketProtoFlow_Init (PacketProtoFlow *o, int input_mtu, int num_packets, PacketPassInterface *output, BPendingGroup *pg) -{ - ASSERT(input_mtu >= 0) - ASSERT(input_mtu <= PACKETPROTO_MAXPAYLOAD) - ASSERT(num_packets > 0) - ASSERT(PacketPassInterface_GetMTU(output) >= PACKETPROTO_ENCLEN(input_mtu)) - - // init async input - BufferWriter_Init(&o->ainput, input_mtu, pg); - - // init encoder - PacketProtoEncoder_Init(&o->encoder, BufferWriter_GetOutput(&o->ainput), pg); - - // init buffer - if (!PacketBuffer_Init(&o->buffer, PacketProtoEncoder_GetOutput(&o->encoder), output, num_packets, pg)) { - goto fail0; - } - - DebugObject_Init(&o->d_obj); - - return 1; - -fail0: - PacketProtoEncoder_Free(&o->encoder); - BufferWriter_Free(&o->ainput); - return 0; -} - -void PacketProtoFlow_Free (PacketProtoFlow *o) -{ - DebugObject_Free(&o->d_obj); - - // free buffer - PacketBuffer_Free(&o->buffer); - - // free encoder - PacketProtoEncoder_Free(&o->encoder); - - // free async input - BufferWriter_Free(&o->ainput); -} - -BufferWriter * PacketProtoFlow_GetInput (PacketProtoFlow *o) -{ - DebugObject_Access(&o->d_obj); - - return &o->ainput; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoFlow.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoFlow.h deleted file mode 100644 index da9b8ec4..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketProtoFlow.h +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @file PacketProtoFlow.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Buffer which encodes packets with PacketProto, with {@link BufferWriter} - * input and {@link PacketPassInterface} output. - */ - -#ifndef BADVPN_FLOW_PACKETPROTOFLOW_H -#define BADVPN_FLOW_PACKETPROTOFLOW_H - -#include "misc/debug.h" - -#include "base/DebugObject.h" -#include "flow/BufferWriter.h" -#include "flow/PacketProtoEncoder.h" -#include "flow/PacketBuffer.h" - -/** - * Buffer which encodes packets with PacketProto, with {@link BufferWriter} - * input and {@link PacketPassInterface} output. - */ -typedef struct { - BufferWriter ainput; - PacketProtoEncoder encoder; - PacketBuffer buffer; - DebugObject d_obj; -} PacketProtoFlow; - -/** - * Initializes the object. - * - * @param o the object - * @param input_mtu maximum input packet size. Must be >=0 and <=PACKETPROTO_MAXPAYLOAD. - * @param num_packets minimum number of packets the buffer should hold. Must be >0. - * @param output output interface. Its MTU must be >=PACKETPROTO_ENCLEN(input_mtu). - * @param pg pending group - * @return 1 on success, 0 on failure - */ -int PacketProtoFlow_Init (PacketProtoFlow *o, int input_mtu, int num_packets, PacketPassInterface *output, BPendingGroup *pg) WARN_UNUSED; - -/** - * Frees the object. - * - * @param o the object - */ -void PacketProtoFlow_Free (PacketProtoFlow *o); - -/** - * Returns the input interface. - * - * @param o the object - * @return input interface - */ -BufferWriter * PacketProtoFlow_GetInput (PacketProtoFlow *o); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketRecvInterface.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketRecvInterface.c deleted file mode 100644 index 244fbbfd..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketRecvInterface.c +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file PacketRecvInterface.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "flow/PacketRecvInterface.h" - -void _PacketRecvInterface_job_operation (PacketRecvInterface *i) -{ - ASSERT(i->state == PRI_STATE_OPERATION_PENDING) - DebugObject_Access(&i->d_obj); - - // set state - i->state = PRI_STATE_BUSY; - - // call handler - i->handler_operation(i->user_provider, i->job_operation_data); - return; -} - -void _PacketRecvInterface_job_done (PacketRecvInterface *i) -{ - ASSERT(i->state == PRI_STATE_DONE_PENDING) - DebugObject_Access(&i->d_obj); - - // set state - i->state = PRI_STATE_NONE; - - // call handler - i->handler_done(i->user_user, i->job_done_len); - return; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketRecvInterface.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketRecvInterface.h deleted file mode 100644 index 9dcc34eb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketRecvInterface.h +++ /dev/null @@ -1,170 +0,0 @@ -/** - * @file PacketRecvInterface.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Interface allowing a packet receiver to receive data packets from a packet sender. - */ - -#ifndef BADVPN_FLOW_PACKETRECVINTERFACE_H -#define BADVPN_FLOW_PACKETRECVINTERFACE_H - -#include -#include - -#include "misc/debug.h" -#include "base/DebugObject.h" -#include "base/BPending.h" - -#define PRI_STATE_NONE 1 -#define PRI_STATE_OPERATION_PENDING 2 -#define PRI_STATE_BUSY 3 -#define PRI_STATE_DONE_PENDING 4 - -typedef void (*PacketRecvInterface_handler_recv) (void *user, uint8_t *data); - -typedef void (*PacketRecvInterface_handler_done) (void *user, int data_len); - -typedef struct { - // provider data - int mtu; - PacketRecvInterface_handler_recv handler_operation; - void *user_provider; - - // user data - PacketRecvInterface_handler_done handler_done; - void *user_user; - - // operation job - BPending job_operation; - uint8_t *job_operation_data; - - // done job - BPending job_done; - int job_done_len; - - // state - int state; - - DebugObject d_obj; -} PacketRecvInterface; - -static void PacketRecvInterface_Init (PacketRecvInterface *i, int mtu, PacketRecvInterface_handler_recv handler_operation, void *user, BPendingGroup *pg); - -static void PacketRecvInterface_Free (PacketRecvInterface *i); - -static void PacketRecvInterface_Done (PacketRecvInterface *i, int data_len); - -static int PacketRecvInterface_GetMTU (PacketRecvInterface *i); - -static void PacketRecvInterface_Receiver_Init (PacketRecvInterface *i, PacketRecvInterface_handler_done handler_done, void *user); - -static void PacketRecvInterface_Receiver_Recv (PacketRecvInterface *i, uint8_t *data); - -void _PacketRecvInterface_job_operation (PacketRecvInterface *i); -void _PacketRecvInterface_job_done (PacketRecvInterface *i); - -void PacketRecvInterface_Init (PacketRecvInterface *i, int mtu, PacketRecvInterface_handler_recv handler_operation, void *user, BPendingGroup *pg) -{ - ASSERT(mtu >= 0) - - // init arguments - i->mtu = mtu; - i->handler_operation = handler_operation; - i->user_provider = user; - - // set no user - i->handler_done = NULL; - - // init jobs - BPending_Init(&i->job_operation, pg, (BPending_handler)_PacketRecvInterface_job_operation, i); - BPending_Init(&i->job_done, pg, (BPending_handler)_PacketRecvInterface_job_done, i); - - // set state - i->state = PRI_STATE_NONE; - - DebugObject_Init(&i->d_obj); -} - -void PacketRecvInterface_Free (PacketRecvInterface *i) -{ - DebugObject_Free(&i->d_obj); - - // free jobs - BPending_Free(&i->job_done); - BPending_Free(&i->job_operation); -} - -void PacketRecvInterface_Done (PacketRecvInterface *i, int data_len) -{ - ASSERT(data_len >= 0) - ASSERT(data_len <= i->mtu) - ASSERT(i->state == PRI_STATE_BUSY) - DebugObject_Access(&i->d_obj); - - // schedule done - i->job_done_len = data_len; - BPending_Set(&i->job_done); - - // set state - i->state = PRI_STATE_DONE_PENDING; -} - -int PacketRecvInterface_GetMTU (PacketRecvInterface *i) -{ - DebugObject_Access(&i->d_obj); - - return i->mtu; -} - -void PacketRecvInterface_Receiver_Init (PacketRecvInterface *i, PacketRecvInterface_handler_done handler_done, void *user) -{ - ASSERT(handler_done) - ASSERT(!i->handler_done) - DebugObject_Access(&i->d_obj); - - i->handler_done = handler_done; - i->user_user = user; -} - -void PacketRecvInterface_Receiver_Recv (PacketRecvInterface *i, uint8_t *data) -{ - ASSERT(!(i->mtu > 0) || data) - ASSERT(i->state == PRI_STATE_NONE) - ASSERT(i->handler_done) - DebugObject_Access(&i->d_obj); - - // schedule operation - i->job_operation_data = data; - BPending_Set(&i->job_operation); - - // set state - i->state = PRI_STATE_OPERATION_PENDING; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketStreamSender.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketStreamSender.c deleted file mode 100644 index 6a5eebdd..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketStreamSender.c +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @file PacketStreamSender.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "misc/debug.h" - -#include "flow/PacketStreamSender.h" - -static void send_data (PacketStreamSender *s) -{ - ASSERT(s->in_len >= 0) - - if (s->in_used < s->in_len) { - // send more data - StreamPassInterface_Sender_Send(s->output, s->in + s->in_used, s->in_len - s->in_used); - } else { - // finish input packet - s->in_len = -1; - PacketPassInterface_Done(&s->input); - } -} - -static void input_handler_send (PacketStreamSender *s, uint8_t *data, int data_len) -{ - ASSERT(s->in_len == -1) - ASSERT(data_len >= 0) - DebugObject_Access(&s->d_obj); - - // set input packet - s->in_len = data_len; - s->in = data; - s->in_used = 0; - - // send - send_data(s); -} - -static void output_handler_done (PacketStreamSender *s, int data_len) -{ - ASSERT(s->in_len >= 0) - ASSERT(data_len > 0) - ASSERT(data_len <= s->in_len - s->in_used) - DebugObject_Access(&s->d_obj); - - // update number of bytes sent - s->in_used += data_len; - - // send - send_data(s); -} - -void PacketStreamSender_Init (PacketStreamSender *s, StreamPassInterface *output, int mtu, BPendingGroup *pg) -{ - ASSERT(mtu >= 0) - - // init arguments - s->output = output; - - // init input - PacketPassInterface_Init(&s->input, mtu, (PacketPassInterface_handler_send)input_handler_send, s, pg); - - // init output - StreamPassInterface_Sender_Init(s->output, (StreamPassInterface_handler_done)output_handler_done, s); - - // have no input packet - s->in_len = -1; - - DebugObject_Init(&s->d_obj); -} - -void PacketStreamSender_Free (PacketStreamSender *s) -{ - DebugObject_Free(&s->d_obj); - - // free input - PacketPassInterface_Free(&s->input); -} - -PacketPassInterface * PacketStreamSender_GetInput (PacketStreamSender *s) -{ - DebugObject_Access(&s->d_obj); - - return &s->input; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketStreamSender.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketStreamSender.h deleted file mode 100644 index 53bdb2cb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/PacketStreamSender.h +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @file PacketStreamSender.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Object which forwards packets obtained with {@link PacketPassInterface} - * as a stream with {@link StreamPassInterface} (i.e. it concatenates them). - */ - -#ifndef BADVPN_FLOW_PACKETSTREAMSENDER_H -#define BADVPN_FLOW_PACKETSTREAMSENDER_H - -#include - -#include "base/DebugObject.h" -#include "flow/PacketPassInterface.h" -#include "flow/StreamPassInterface.h" - -/** - * Object which forwards packets obtained with {@link PacketPassInterface} - * as a stream with {@link StreamPassInterface} (i.e. it concatenates them). - */ -typedef struct { - DebugObject d_obj; - PacketPassInterface input; - StreamPassInterface *output; - int in_len; - uint8_t *in; - int in_used; -} PacketStreamSender; - -/** - * Initializes the object. - * - * @param s the object - * @param output output interface - * @param mtu input MTU. Must be >=0. - * @param pg pending group - */ -void PacketStreamSender_Init (PacketStreamSender *s, StreamPassInterface *output, int mtu, BPendingGroup *pg); - -/** - * Frees the object. - * - * @param s the object - */ -void PacketStreamSender_Free (PacketStreamSender *s); - -/** - * Returns the input interface. - * Its MTU will be as in {@link PacketStreamSender_Init}. - * - * @param s the object - * @return input interface - */ -PacketPassInterface * PacketStreamSender_GetInput (PacketStreamSender *s); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/SinglePacketBuffer.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/SinglePacketBuffer.c deleted file mode 100644 index 3e5d886c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/SinglePacketBuffer.c +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @file SinglePacketBuffer.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "misc/debug.h" -#include "misc/balloc.h" - -#include "flow/SinglePacketBuffer.h" - -static void input_handler_done (SinglePacketBuffer *o, int in_len) -{ - DebugObject_Access(&o->d_obj); - - PacketPassInterface_Sender_Send(o->output, o->buf, in_len); -} - -static void output_handler_done (SinglePacketBuffer *o) -{ - DebugObject_Access(&o->d_obj); - - PacketRecvInterface_Receiver_Recv(o->input, o->buf); -} - -int SinglePacketBuffer_Init (SinglePacketBuffer *o, PacketRecvInterface *input, PacketPassInterface *output, BPendingGroup *pg) -{ - ASSERT(PacketPassInterface_GetMTU(output) >= PacketRecvInterface_GetMTU(input)) - - // init arguments - o->input = input; - o->output = output; - - // init input - PacketRecvInterface_Receiver_Init(o->input, (PacketRecvInterface_handler_done)input_handler_done, o); - - // init output - PacketPassInterface_Sender_Init(o->output, (PacketPassInterface_handler_done)output_handler_done, o); - - // init buffer - if (!(o->buf = (uint8_t *)BAlloc(PacketRecvInterface_GetMTU(o->input)))) { - goto fail1; - } - - // schedule receive - PacketRecvInterface_Receiver_Recv(o->input, o->buf); - - DebugObject_Init(&o->d_obj); - - return 1; - -fail1: - return 0; -} - -void SinglePacketBuffer_Free (SinglePacketBuffer *o) -{ - DebugObject_Free(&o->d_obj); - - // free buffer - BFree(o->buf); -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/SinglePacketBuffer.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/SinglePacketBuffer.h deleted file mode 100644 index bbbd6794..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/SinglePacketBuffer.h +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @file SinglePacketBuffer.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Packet buffer with {@link PacketRecvInterface} input and {@link PacketPassInterface} output - * than can store only a single packet. - */ - -#ifndef BADVPN_FLOW_SINGLEPACKETBUFFER_H -#define BADVPN_FLOW_SINGLEPACKETBUFFER_H - -#include - -#include "misc/debug.h" -#include "base/DebugObject.h" -#include "flow/PacketRecvInterface.h" -#include "flow/PacketPassInterface.h" - -/** - * Packet buffer with {@link PacketRecvInterface} input and {@link PacketPassInterface} output - * than can store only a single packet. - */ -typedef struct { - DebugObject d_obj; - PacketRecvInterface *input; - PacketPassInterface *output; - uint8_t *buf; -} SinglePacketBuffer; - -/** - * Initializes the object. - * Output MTU must be >= input MTU. - * - * @param o the object - * @param input input interface - * @param output output interface - * @param pg pending group - * @return 1 on success, 0 on failure - */ -int SinglePacketBuffer_Init (SinglePacketBuffer *o, PacketRecvInterface *input, PacketPassInterface *output, BPendingGroup *pg) WARN_UNUSED; - -/** - * Frees the object - * - * @param o the object - */ -void SinglePacketBuffer_Free (SinglePacketBuffer *o); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamPassInterface.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamPassInterface.c deleted file mode 100644 index 1c57f565..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamPassInterface.c +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file StreamPassInterface.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "flow/StreamPassInterface.h" - -void _StreamPassInterface_job_operation (StreamPassInterface *i) -{ - ASSERT(i->state == SPI_STATE_OPERATION_PENDING) - DebugObject_Access(&i->d_obj); - - // set state - i->state = SPI_STATE_BUSY; - - // call handler - i->handler_operation(i->user_provider, i->job_operation_data, i->job_operation_len); - return; -} - -void _StreamPassInterface_job_done (StreamPassInterface *i) -{ - ASSERT(i->state == SPI_STATE_DONE_PENDING) - DebugObject_Access(&i->d_obj); - - // set state - i->state = SPI_STATE_NONE; - - // call handler - i->handler_done(i->user_user, i->job_done_len); - return; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamPassInterface.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamPassInterface.h deleted file mode 100644 index 69e1064e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamPassInterface.h +++ /dev/null @@ -1,165 +0,0 @@ -/** - * @file StreamPassInterface.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Interface allowing a stream sender to pass stream data to a stream receiver. - * - * Note that this interface behaves exactly the same and has the same code as - * {@link StreamRecvInterface} if names and its external semantics are disregarded. - * If you modify this file, you should probably modify {@link StreamRecvInterface} - * too. - */ - -#ifndef BADVPN_FLOW_STREAMPASSINTERFACE_H -#define BADVPN_FLOW_STREAMPASSINTERFACE_H - -#include -#include - -#include "misc/debug.h" -#include "base/DebugObject.h" -#include "base/BPending.h" - -#define SPI_STATE_NONE 1 -#define SPI_STATE_OPERATION_PENDING 2 -#define SPI_STATE_BUSY 3 -#define SPI_STATE_DONE_PENDING 4 - -typedef void (*StreamPassInterface_handler_send) (void *user, uint8_t *data, int data_len); - -typedef void (*StreamPassInterface_handler_done) (void *user, int data_len); - -typedef struct { - // provider data - StreamPassInterface_handler_send handler_operation; - void *user_provider; - - // user data - StreamPassInterface_handler_done handler_done; - void *user_user; - - // operation job - BPending job_operation; - uint8_t *job_operation_data; - int job_operation_len; - - // done job - BPending job_done; - int job_done_len; - - // state - int state; - - DebugObject d_obj; -} StreamPassInterface; - -static void StreamPassInterface_Init (StreamPassInterface *i, StreamPassInterface_handler_send handler_operation, void *user, BPendingGroup *pg); - -static void StreamPassInterface_Free (StreamPassInterface *i); - -static void StreamPassInterface_Done (StreamPassInterface *i, int data_len); - -static void StreamPassInterface_Sender_Init (StreamPassInterface *i, StreamPassInterface_handler_done handler_done, void *user); - -static void StreamPassInterface_Sender_Send (StreamPassInterface *i, uint8_t *data, int data_len); - -void _StreamPassInterface_job_operation (StreamPassInterface *i); -void _StreamPassInterface_job_done (StreamPassInterface *i); - -void StreamPassInterface_Init (StreamPassInterface *i, StreamPassInterface_handler_send handler_operation, void *user, BPendingGroup *pg) -{ - // init arguments - i->handler_operation = handler_operation; - i->user_provider = user; - - // set no user - i->handler_done = NULL; - - // init jobs - BPending_Init(&i->job_operation, pg, (BPending_handler)_StreamPassInterface_job_operation, i); - BPending_Init(&i->job_done, pg, (BPending_handler)_StreamPassInterface_job_done, i); - - // set state - i->state = SPI_STATE_NONE; - - DebugObject_Init(&i->d_obj); -} - -void StreamPassInterface_Free (StreamPassInterface *i) -{ - DebugObject_Free(&i->d_obj); - - // free jobs - BPending_Free(&i->job_done); - BPending_Free(&i->job_operation); -} - -void StreamPassInterface_Done (StreamPassInterface *i, int data_len) -{ - ASSERT(i->state == SPI_STATE_BUSY) - ASSERT(data_len > 0) - ASSERT(data_len <= i->job_operation_len) - DebugObject_Access(&i->d_obj); - - // schedule done - i->job_done_len = data_len; - BPending_Set(&i->job_done); - - // set state - i->state = SPI_STATE_DONE_PENDING; -} - -void StreamPassInterface_Sender_Init (StreamPassInterface *i, StreamPassInterface_handler_done handler_done, void *user) -{ - ASSERT(handler_done) - ASSERT(!i->handler_done) - DebugObject_Access(&i->d_obj); - - i->handler_done = handler_done; - i->user_user = user; -} - -void StreamPassInterface_Sender_Send (StreamPassInterface *i, uint8_t *data, int data_len) -{ - ASSERT(data_len > 0) - ASSERT(data) - ASSERT(i->state == SPI_STATE_NONE) - ASSERT(i->handler_done) - DebugObject_Access(&i->d_obj); - - // schedule operation - i->job_operation_data = data; - i->job_operation_len = data_len; - BPending_Set(&i->job_operation); - - // set state - i->state = SPI_STATE_OPERATION_PENDING; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamRecvInterface.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamRecvInterface.c deleted file mode 100644 index 0b7820dc..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamRecvInterface.c +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file StreamRecvInterface.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "flow/StreamRecvInterface.h" - -void _StreamRecvInterface_job_operation (StreamRecvInterface *i) -{ - ASSERT(i->state == SRI_STATE_OPERATION_PENDING) - DebugObject_Access(&i->d_obj); - - // set state - i->state = SRI_STATE_BUSY; - - // call handler - i->handler_operation(i->user_provider, i->job_operation_data, i->job_operation_len); - return; -} - -void _StreamRecvInterface_job_done (StreamRecvInterface *i) -{ - ASSERT(i->state == SRI_STATE_DONE_PENDING) - DebugObject_Access(&i->d_obj); - - // set state - i->state = SRI_STATE_NONE; - - // call handler - i->handler_done(i->user_user, i->job_done_len); - return; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamRecvInterface.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamRecvInterface.h deleted file mode 100644 index b50f5a39..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flow/StreamRecvInterface.h +++ /dev/null @@ -1,165 +0,0 @@ -/** - * @file StreamRecvInterface.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Interface allowing a stream receiver to receive stream data from a stream sender. - * - * Note that this interface behaves exactly the same and has the same code as - * {@link StreamPassInterface} if names and its external semantics are disregarded. - * If you modify this file, you should probably modify {@link StreamPassInterface} - * too. - */ - -#ifndef BADVPN_FLOW_STREAMRECVINTERFACE_H -#define BADVPN_FLOW_STREAMRECVINTERFACE_H - -#include -#include - -#include "misc/debug.h" -#include "base/DebugObject.h" -#include "base/BPending.h" - -#define SRI_STATE_NONE 1 -#define SRI_STATE_OPERATION_PENDING 2 -#define SRI_STATE_BUSY 3 -#define SRI_STATE_DONE_PENDING 4 - -typedef void (*StreamRecvInterface_handler_recv) (void *user, uint8_t *data, int data_len); - -typedef void (*StreamRecvInterface_handler_done) (void *user, int data_len); - -typedef struct { - // provider data - StreamRecvInterface_handler_recv handler_operation; - void *user_provider; - - // user data - StreamRecvInterface_handler_done handler_done; - void *user_user; - - // operation job - BPending job_operation; - uint8_t *job_operation_data; - int job_operation_len; - - // done job - BPending job_done; - int job_done_len; - - // state - int state; - - DebugObject d_obj; -} StreamRecvInterface; - -static void StreamRecvInterface_Init (StreamRecvInterface *i, StreamRecvInterface_handler_recv handler_operation, void *user, BPendingGroup *pg); - -static void StreamRecvInterface_Free (StreamRecvInterface *i); - -static void StreamRecvInterface_Done (StreamRecvInterface *i, int data_len); - -static void StreamRecvInterface_Receiver_Init (StreamRecvInterface *i, StreamRecvInterface_handler_done handler_done, void *user); - -static void StreamRecvInterface_Receiver_Recv (StreamRecvInterface *i, uint8_t *data, int data_len); - -void _StreamRecvInterface_job_operation (StreamRecvInterface *i); -void _StreamRecvInterface_job_done (StreamRecvInterface *i); - -void StreamRecvInterface_Init (StreamRecvInterface *i, StreamRecvInterface_handler_recv handler_operation, void *user, BPendingGroup *pg) -{ - // init arguments - i->handler_operation = handler_operation; - i->user_provider = user; - - // set no user - i->handler_done = NULL; - - // init jobs - BPending_Init(&i->job_operation, pg, (BPending_handler)_StreamRecvInterface_job_operation, i); - BPending_Init(&i->job_done, pg, (BPending_handler)_StreamRecvInterface_job_done, i); - - // set state - i->state = SRI_STATE_NONE; - - DebugObject_Init(&i->d_obj); -} - -void StreamRecvInterface_Free (StreamRecvInterface *i) -{ - DebugObject_Free(&i->d_obj); - - // free jobs - BPending_Free(&i->job_done); - BPending_Free(&i->job_operation); -} - -void StreamRecvInterface_Done (StreamRecvInterface *i, int data_len) -{ - ASSERT(i->state == SRI_STATE_BUSY) - ASSERT(data_len > 0) - ASSERT(data_len <= i->job_operation_len) - DebugObject_Access(&i->d_obj); - - // schedule done - i->job_done_len = data_len; - BPending_Set(&i->job_done); - - // set state - i->state = SRI_STATE_DONE_PENDING; -} - -void StreamRecvInterface_Receiver_Init (StreamRecvInterface *i, StreamRecvInterface_handler_done handler_done, void *user) -{ - ASSERT(handler_done) - ASSERT(!i->handler_done) - DebugObject_Access(&i->d_obj); - - i->handler_done = handler_done; - i->user_user = user; -} - -void StreamRecvInterface_Receiver_Recv (StreamRecvInterface *i, uint8_t *data, int data_len) -{ - ASSERT(data_len > 0) - ASSERT(data) - ASSERT(i->state == SRI_STATE_NONE) - ASSERT(i->handler_done) - DebugObject_Access(&i->d_obj); - - // schedule operation - i->job_operation_data = data; - i->job_operation_len = data_len; - BPending_Set(&i->job_operation); - - // set state - i->state = SRI_STATE_OPERATION_PENDING; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flowextra/PacketPassInactivityMonitor.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flowextra/PacketPassInactivityMonitor.c deleted file mode 100644 index 6531fe01..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flowextra/PacketPassInactivityMonitor.c +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @file PacketPassInactivityMonitor.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "PacketPassInactivityMonitor.h" - -static void input_handler_send (PacketPassInactivityMonitor *o, uint8_t *data, int data_len) -{ - DebugObject_Access(&o->d_obj); - - // schedule send - PacketPassInterface_Sender_Send(o->output, data, data_len); - - // stop timer - BReactor_RemoveTimer(o->reactor, &o->timer); -} - -static void input_handler_requestcancel (PacketPassInactivityMonitor *o) -{ - DebugObject_Access(&o->d_obj); - - // request cancel - PacketPassInterface_Sender_RequestCancel(o->output); -} - -static void output_handler_done (PacketPassInactivityMonitor *o) -{ - DebugObject_Access(&o->d_obj); - - // output no longer busy, restart timer - BReactor_SetTimer(o->reactor, &o->timer); - - // call done - PacketPassInterface_Done(&o->input); -} - -static void timer_handler (PacketPassInactivityMonitor *o) -{ - DebugObject_Access(&o->d_obj); - - // restart timer - BReactor_SetTimer(o->reactor, &o->timer); - - // call handler - if (o->handler) { - o->handler(o->user); - return; - } -} - -void PacketPassInactivityMonitor_Init (PacketPassInactivityMonitor *o, PacketPassInterface *output, BReactor *reactor, btime_t interval, PacketPassInactivityMonitor_handler handler, void *user) -{ - // init arguments - o->output = output; - o->reactor = reactor; - o->handler = handler; - o->user = user; - - // init input - PacketPassInterface_Init(&o->input, PacketPassInterface_GetMTU(o->output), (PacketPassInterface_handler_send)input_handler_send, o, BReactor_PendingGroup(o->reactor)); - if (PacketPassInterface_HasCancel(o->output)) { - PacketPassInterface_EnableCancel(&o->input, (PacketPassInterface_handler_requestcancel)input_handler_requestcancel); - } - - // init output - PacketPassInterface_Sender_Init(o->output, (PacketPassInterface_handler_done)output_handler_done, o); - - // init timer - BTimer_Init(&o->timer, interval, (BTimer_handler)timer_handler, o); - BReactor_SetTimer(o->reactor, &o->timer); - - DebugObject_Init(&o->d_obj); -} - -void PacketPassInactivityMonitor_Free (PacketPassInactivityMonitor *o) -{ - DebugObject_Free(&o->d_obj); - - // free timer - BReactor_RemoveTimer(o->reactor, &o->timer); - - // free input - PacketPassInterface_Free(&o->input); -} - -PacketPassInterface * PacketPassInactivityMonitor_GetInput (PacketPassInactivityMonitor *o) -{ - DebugObject_Access(&o->d_obj); - - return &o->input; -} - -void PacketPassInactivityMonitor_SetHandler (PacketPassInactivityMonitor *o, PacketPassInactivityMonitor_handler handler, void *user) -{ - DebugObject_Access(&o->d_obj); - - o->handler = handler; - o->user = user; -} - -void PacketPassInactivityMonitor_Force (PacketPassInactivityMonitor *o) -{ - DebugObject_Access(&o->d_obj); - - BReactor_SetTimerAfter(o->reactor, &o->timer, 0); -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flowextra/PacketPassInactivityMonitor.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flowextra/PacketPassInactivityMonitor.h deleted file mode 100644 index 7805d483..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/flowextra/PacketPassInactivityMonitor.h +++ /dev/null @@ -1,124 +0,0 @@ -/** - * @file PacketPassInactivityMonitor.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * A {@link PacketPassInterface} layer for detecting inactivity. - */ - -#ifndef BADVPN_PACKETPASSINACTIVITYMONITOR_H -#define BADVPN_PACKETPASSINACTIVITYMONITOR_H - -#include "base/DebugObject.h" -#include "system/BReactor.h" -#include "flow/PacketPassInterface.h" - -/** - * Handler function invoked when inactivity is detected. - * It is guaranteed that the interfaces are in not sending state. - * - * @param user value given to {@link PacketPassInactivityMonitor_Init} - */ -typedef void (*PacketPassInactivityMonitor_handler) (void *user); - -/** - * A {@link PacketPassInterface} layer for detecting inactivity. - * It reports inactivity to a user provided handler function. - * - * The object behaves like that: - * ("timer set" means started with the given timeout whether if was running or not, - * "timer unset" means stopped if it was running) - * - There is a timer. - * - The timer is set when the object is initialized. - * - When the input calls Send, the call is passed on to the output. - * If the output accepted the packet, the timer is set. If the output - * blocked the packet, the timer is unset. - * - When the output calls Done, the timer is set, and the call is - * passed on to the input. - * - When the input calls Cancel, the timer is set, and the call is - * passed on to the output. - * - When the timer expires, the timer is set, ant the user's handler - * function is invoked. - */ -typedef struct { - DebugObject d_obj; - PacketPassInterface *output; - BReactor *reactor; - PacketPassInactivityMonitor_handler handler; - void *user; - PacketPassInterface input; - BTimer timer; -} PacketPassInactivityMonitor; - -/** - * Initializes the object. - * See {@link PacketPassInactivityMonitor} for details. - * - * @param o the object - * @param output output interface - * @param reactor reactor we live in - * @param interval timer value in milliseconds - * @param handler handler function for reporting inactivity, or NULL to disable - * @param user value passed to handler functions - */ -void PacketPassInactivityMonitor_Init (PacketPassInactivityMonitor *o, PacketPassInterface *output, BReactor *reactor, btime_t interval, PacketPassInactivityMonitor_handler handler, void *user); - -/** - * Frees the object. - * - * @param o the object - */ -void PacketPassInactivityMonitor_Free (PacketPassInactivityMonitor *o); - -/** - * Returns the input interface. - * The MTU of the interface will be the same as of the output interface. - * The interface supports cancel functionality if the output interface supports it. - * - * @param o the object - * @return input interface - */ -PacketPassInterface * PacketPassInactivityMonitor_GetInput (PacketPassInactivityMonitor *o); - -/** - * Sets or removes the inactivity handler. - * - * @param o the object - * @param handler handler function for reporting inactivity, or NULL to disable - * @param user value passed to handler functions - */ -void PacketPassInactivityMonitor_SetHandler (PacketPassInactivityMonitor *o, PacketPassInactivityMonitor_handler handler, void *user); - -/** - * Sets the timer to expire immediately in order to force an inactivity report. - * - * @param o the object - */ -void PacketPassInactivityMonitor_Force (PacketPassInactivityMonitor *o); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BArpProbe.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BArpProbe.h deleted file mode 100644 index f168e638..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BArpProbe.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BArpProbe diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BConnection.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BConnection.h deleted file mode 100644 index 8447db02..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BConnection.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BConnection diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BDHCPClient.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BDHCPClient.h deleted file mode 100644 index aacf34db..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BDHCPClient.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BDHCPClient diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BDHCPClientCore.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BDHCPClientCore.h deleted file mode 100644 index 64fc74d3..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BDHCPClientCore.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BDHCPClientCore diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BDatagram.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BDatagram.h deleted file mode 100644 index d95cf245..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BDatagram.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BDatagram diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BEncryption.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BEncryption.h deleted file mode 100644 index 6991f370..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BEncryption.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BEncryption diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BInputProcess.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BInputProcess.h deleted file mode 100644 index f65f715a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BInputProcess.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BInputProcess diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BLockReactor.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BLockReactor.h deleted file mode 100644 index 5aab6d41..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BLockReactor.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BLockReactor diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BNetwork.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BNetwork.h deleted file mode 100644 index c5e3bc1e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BNetwork.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BNetwork diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BPredicate.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BPredicate.h deleted file mode 100644 index 1a683f13..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BPredicate.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BPredicate diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BProcess.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BProcess.h deleted file mode 100644 index e11e5a62..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BProcess.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BProcess diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BReactor.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BReactor.h deleted file mode 100644 index d111dc79..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BReactor.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BReactor diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BSSLConnection.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BSSLConnection.h deleted file mode 100644 index bd55826b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BSSLConnection.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BSSLConnection diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BSignal.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BSignal.h deleted file mode 100644 index 2820ebce..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BSignal.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BSignal diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BSocksClient.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BSocksClient.h deleted file mode 100644 index 72086fab..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BSocksClient.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BSocksClient diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BTap.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BTap.h deleted file mode 100644 index ab3e951e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BTap.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BTap diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BThreadSignal.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BThreadSignal.h deleted file mode 100644 index f39fc368..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BThreadSignal.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BThreadSignal diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BThreadWork.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BThreadWork.h deleted file mode 100644 index f68383c2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BThreadWork.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BThreadWork diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BTime.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BTime.h deleted file mode 100644 index b323ee76..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BTime.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BTime diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BUnixSignal.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BUnixSignal.h deleted file mode 100644 index 914b21b8..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_BUnixSignal.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_BUnixSignal diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DPReceive.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DPReceive.h deleted file mode 100644 index 99889b56..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DPReceive.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_DPReceive diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DPRelay.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DPRelay.h deleted file mode 100644 index bc0153be..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DPRelay.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_DPRelay diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DataProto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DataProto.h deleted file mode 100644 index a6f900a3..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DataProto.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_DataProto diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DatagramPeerIO.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DatagramPeerIO.h deleted file mode 100644 index 16e37b5b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_DatagramPeerIO.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_DatagramPeerIO diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_FragmentProtoAssembler.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_FragmentProtoAssembler.h deleted file mode 100644 index 25289efb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_FragmentProtoAssembler.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_FragmentProtoAssembler diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_FrameDecider.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_FrameDecider.h deleted file mode 100644 index 5dbf3c46..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_FrameDecider.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_FrameDecider diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_LineBuffer.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_LineBuffer.h deleted file mode 100644 index 4286a742..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_LineBuffer.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_LineBuffer diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_Listener.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_Listener.h deleted file mode 100644 index f61bfb3d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_Listener.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_Listener diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDBuildProgram.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDBuildProgram.h deleted file mode 100644 index 1a6cdf91..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDBuildProgram.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDBuildProgram diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDConfigParser.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDConfigParser.h deleted file mode 100644 index 92d98d06..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDConfigParser.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDConfigParser diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDConfigTokenizer.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDConfigTokenizer.h deleted file mode 100644 index 0b3b6892..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDConfigTokenizer.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDConfigTokenizer diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDIfConfig.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDIfConfig.h deleted file mode 100644 index 91bdbda5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDIfConfig.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDIfConfig diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDInterfaceMonitor.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDInterfaceMonitor.h deleted file mode 100644 index 22c0f8d6..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDInterfaceMonitor.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDInterfaceMonitor diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDModuleIndex.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDModuleIndex.h deleted file mode 100644 index 34876642..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDModuleIndex.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDModuleIndex diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDModuleProcess.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDModuleProcess.h deleted file mode 100644 index db34dcc0..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDModuleProcess.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDModuleProcess diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDPlaceholderDb.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDPlaceholderDb.h deleted file mode 100644 index f1f1db2c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDPlaceholderDb.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDPlaceholderDb diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDRequest.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDRequest.h deleted file mode 100644 index 5edc18a2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDRequest.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDRequest diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDRequestClient.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDRequestClient.h deleted file mode 100644 index 1e696d8c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDRequestClient.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDRequestClient diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDRfkillMonitor.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDRfkillMonitor.h deleted file mode 100644 index 56eba888..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDRfkillMonitor.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDRfkillMonitor diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevCache.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevCache.h deleted file mode 100644 index 088fc9b3..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevCache.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDUdevCache diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevManager.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevManager.h deleted file mode 100644 index e9d63758..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevManager.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDUdevManager diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevMonitor.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevMonitor.h deleted file mode 100644 index bd93249a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevMonitor.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDUdevMonitor diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevMonitorParser.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevMonitorParser.h deleted file mode 100644 index a7d560f4..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDUdevMonitorParser.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDUdevMonitorParser diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDVal.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDVal.h deleted file mode 100644 index f2b67c28..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDVal.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDVal diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDValGenerator.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDValGenerator.h deleted file mode 100644 index 193826bb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDValGenerator.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDValGenerator diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDValParser.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDValParser.h deleted file mode 100644 index 1d44acb7..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_NCDValParser.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_NCDValParser diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PRStreamSink.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PRStreamSink.h deleted file mode 100644 index b70b61cd..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PRStreamSink.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_PRStreamSink diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PRStreamSource.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PRStreamSource.h deleted file mode 100644 index e16d93db..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PRStreamSource.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_PRStreamSource diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PacketProtoDecoder.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PacketProtoDecoder.h deleted file mode 100644 index fbfa5d81..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PacketProtoDecoder.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_PacketProtoDecoder diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PasswordListener.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PasswordListener.h deleted file mode 100644 index 6ff0bb58..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PasswordListener.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_PasswordListener diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PeerChat.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PeerChat.h deleted file mode 100644 index cadf2308..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_PeerChat.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_PeerChat diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_SPProtoDecoder.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_SPProtoDecoder.h deleted file mode 100644 index 09bf2599..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_SPProtoDecoder.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_SPProtoDecoder diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ServerConnection.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ServerConnection.h deleted file mode 100644 index faea1ddd..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ServerConnection.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ServerConnection diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_SocksUdpGwClient.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_SocksUdpGwClient.h deleted file mode 100644 index 6ba39aed..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_SocksUdpGwClient.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_SocksUdpGwClient diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_StreamPeerIO.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_StreamPeerIO.h deleted file mode 100644 index 0359736e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_StreamPeerIO.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_StreamPeerIO diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_UdpGwClient.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_UdpGwClient.h deleted file mode 100644 index 85303768..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_UdpGwClient.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_UdpGwClient diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_addr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_addr.h deleted file mode 100644 index 512db286..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_addr.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_addr diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_client.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_client.h deleted file mode 100644 index c851b77b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_client.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_client diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_dostest_attacker.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_dostest_attacker.h deleted file mode 100644 index b267c8f4..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_dostest_attacker.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_dostest_attacker diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_dostest_server.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_dostest_server.h deleted file mode 100644 index 8d3988e0..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_dostest_server.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_dostest_server diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_flooder.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_flooder.h deleted file mode 100644 index 94f595eb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_flooder.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_flooder diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_lwip.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_lwip.h deleted file mode 100644 index fb5687df..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_lwip.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_lwip diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd.h deleted file mode 100644 index 9bf29567..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_alias.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_alias.h deleted file mode 100644 index 5b52bf26..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_alias.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_alias diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_arithmetic.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_arithmetic.h deleted file mode 100644 index 66c08a8e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_arithmetic.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_arithmetic diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_assert.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_assert.h deleted file mode 100644 index 21e4d419..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_assert.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_assert diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_backtrack.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_backtrack.h deleted file mode 100644 index ea669f79..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_backtrack.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_backtrack diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_basic_functions.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_basic_functions.h deleted file mode 100644 index 9f0bfdd4..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_basic_functions.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_basic_functions diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_blocker.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_blocker.h deleted file mode 100644 index a897b9f5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_blocker.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_blocker diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_buffer.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_buffer.h deleted file mode 100644 index 64e44333..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_buffer.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_buffer diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_call2.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_call2.h deleted file mode 100644 index 4b64608d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_call2.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_call2 diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_choose.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_choose.h deleted file mode 100644 index a915036f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_choose.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_choose diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_concat.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_concat.h deleted file mode 100644 index 8c54ccbb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_concat.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_concat diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_daemon.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_daemon.h deleted file mode 100644 index 0a3ae3fa..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_daemon.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_daemon diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_depend.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_depend.h deleted file mode 100644 index ae1ff8e9..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_depend.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_depend diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_depend_scope.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_depend_scope.h deleted file mode 100644 index 1168714d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_depend_scope.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_depend_scope diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_dynamic_depend.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_dynamic_depend.h deleted file mode 100644 index 7ff305ea..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_dynamic_depend.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_dynamic_depend diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_exit.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_exit.h deleted file mode 100644 index 2d2e3af1..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_exit.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_exit diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_explode.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_explode.h deleted file mode 100644 index b7dc820e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_explode.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_explode diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_file.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_file.h deleted file mode 100644 index 6cfa5a55..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_file.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_file diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_file_open.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_file_open.h deleted file mode 100644 index dd4ecb5f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_file_open.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_file_open diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_foreach.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_foreach.h deleted file mode 100644 index 430b2294..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_foreach.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_foreach diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_from_string.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_from_string.h deleted file mode 100644 index e409fffa..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_from_string.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_from_string diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_getargs.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_getargs.h deleted file mode 100644 index da7631d4..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_getargs.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_getargs diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_getenv.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_getenv.h deleted file mode 100644 index 4f290216..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_getenv.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_getenv diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_if.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_if.h deleted file mode 100644 index 11a09a2a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_if.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_if diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_imperative.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_imperative.h deleted file mode 100644 index 362df87a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_imperative.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_imperative diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_implode.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_implode.h deleted file mode 100644 index 5bb66d5b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_implode.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_implode diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_index.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_index.h deleted file mode 100644 index 666bbe9b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_index.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_index diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_list.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_list.h deleted file mode 100644 index f153be78..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_list.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_list diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_load_module.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_load_module.h deleted file mode 100644 index c27dddb8..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_load_module.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_load_module diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_log.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_log.h deleted file mode 100644 index 9ae2dc95..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_log.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_log diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_log_msg.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_log_msg.h deleted file mode 100644 index 9e51b7eb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_log_msg.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_log_msg diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_logical.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_logical.h deleted file mode 100644 index 688453d8..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_logical.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_logical diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_multidepend.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_multidepend.h deleted file mode 100644 index a82953df..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_multidepend.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_multidepend diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_badvpn.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_badvpn.h deleted file mode 100644 index c9964c16..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_badvpn.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_backend_badvpn diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_rfkill.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_rfkill.h deleted file mode 100644 index e69896f9..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_rfkill.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_backend_rfkill diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_waitdevice.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_waitdevice.h deleted file mode 100644 index 63c4f242..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_waitdevice.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_backend_waitdevice diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_waitlink.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_waitlink.h deleted file mode 100644 index 96244c0a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_waitlink.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_backend_waitlink diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_wpa_supplicant.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_wpa_supplicant.h deleted file mode 100644 index 22572d36..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_backend_wpa_supplicant.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_backend_wpa_supplicant diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_dns.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_dns.h deleted file mode 100644 index 01c37448..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_dns.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_dns diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_iptables.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_iptables.h deleted file mode 100644 index 42e23827..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_iptables.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_iptables diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_addr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_addr.h deleted file mode 100644 index 75bcb24d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_addr.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_ipv4_addr diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_addr_in_network.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_addr_in_network.h deleted file mode 100644 index 41f2df2e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_addr_in_network.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_ipv4_addr_in_network diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_arp_probe.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_arp_probe.h deleted file mode 100644 index 18f7c783..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_arp_probe.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_ipv4_arp_probe diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_dhcp.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_dhcp.h deleted file mode 100644 index 51fa61fb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_dhcp.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_ipv4_dhcp diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_route.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_route.h deleted file mode 100644 index e181a90b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv4_route.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_ipv4_route diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_addr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_addr.h deleted file mode 100644 index bd6bd10a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_addr.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_ipv6_addr diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_addr_in_network.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_addr_in_network.h deleted file mode 100644 index ba33921f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_addr_in_network.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_ipv6_addr_in_network diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_route.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_route.h deleted file mode 100644 index b72e4d38..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_route.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_ipv6_route diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_wait_dynamic_addr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_wait_dynamic_addr.h deleted file mode 100644 index ff7d6e1e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_ipv6_wait_dynamic_addr.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_ipv6_wait_dynamic_addr diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_up.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_up.h deleted file mode 100644 index 7acdedef..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_up.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_up diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_watch_interfaces.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_watch_interfaces.h deleted file mode 100644 index 7fc078f7..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_net_watch_interfaces.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_net_watch_interfaces diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_netmask.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_netmask.h deleted file mode 100644 index 10993f00..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_netmask.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_netmask diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_objref.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_objref.h deleted file mode 100644 index 783ee6e5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_objref.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_objref diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_ondemand.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_ondemand.h deleted file mode 100644 index c7a0578c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_ondemand.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_ondemand diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_parse.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_parse.h deleted file mode 100644 index 672155be..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_parse.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_parse diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_print.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_print.h deleted file mode 100644 index 22638f3b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_print.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_print diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_process_manager.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_process_manager.h deleted file mode 100644 index 627ba0e5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_process_manager.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_process_manager diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_reboot.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_reboot.h deleted file mode 100644 index 0e31d555..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_reboot.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_reboot diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_ref.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_ref.h deleted file mode 100644 index 4f9f24ae..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_ref.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_ref diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_regex_match.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_regex_match.h deleted file mode 100644 index 30813479..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_regex_match.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_regex_match diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_request.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_request.h deleted file mode 100644 index 00103ea8..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_request.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_request diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_run.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_run.h deleted file mode 100644 index 036a93e3..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_run.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_run diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_runonce.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_runonce.h deleted file mode 100644 index 2e544520..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_runonce.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_runonce diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sleep.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sleep.h deleted file mode 100644 index fb6c7fe3..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sleep.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_sleep diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_socket.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_socket.h deleted file mode 100644 index 3c1f0c42..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_socket.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_socket diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_spawn.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_spawn.h deleted file mode 100644 index b9b3b24f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_spawn.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_spawn diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_strcmp.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_strcmp.h deleted file mode 100644 index 6ef09adc..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_strcmp.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_strcmp diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_substr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_substr.h deleted file mode 100644 index 691ad0e2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_substr.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_substr diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_evdev.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_evdev.h deleted file mode 100644 index 4a7244e5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_evdev.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_sys_evdev diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_request_client.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_request_client.h deleted file mode 100644 index ce0f9e4c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_request_client.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_sys_request_client diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_request_server.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_request_server.h deleted file mode 100644 index 11979588..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_request_server.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_sys_request_server diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_start_process.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_start_process.h deleted file mode 100644 index 45c2edc0..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_start_process.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_sys_start_process diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_watch_directory.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_watch_directory.h deleted file mode 100644 index e190da51..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_watch_directory.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_sys_watch_directory diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_watch_input.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_watch_input.h deleted file mode 100644 index b8995556..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_watch_input.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_sys_watch_input diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_watch_usb.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_watch_usb.h deleted file mode 100644 index bc5102a0..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_sys_watch_usb.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_sys_watch_usb diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_timer.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_timer.h deleted file mode 100644 index beaa73db..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_timer.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_timer diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_to_string.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_to_string.h deleted file mode 100644 index 41cd8b98..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_to_string.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_to_string diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_try.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_try.h deleted file mode 100644 index bb76c685..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_try.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_try diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_value.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_value.h deleted file mode 100644 index fa624e8f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_value.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_value diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_valuemetic.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_valuemetic.h deleted file mode 100644 index 385d2bb1..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_valuemetic.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_valuemetic diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_var.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_var.h deleted file mode 100644 index fa5c0c43..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_ncd_var.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_ncd_var diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_nsskey.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_nsskey.h deleted file mode 100644 index 66e6a72d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_nsskey.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_nsskey diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_server.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_server.h deleted file mode 100644 index acb3ed0d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_server.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_server diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_tun2socks.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_tun2socks.h deleted file mode 100644 index 21c1ce2d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_tun2socks.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_tun2socks diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_udpgw.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_udpgw.h deleted file mode 100644 index 504a3522..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channel_udpgw.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifdef BLOG_CURRENT_CHANNEL -#undef BLOG_CURRENT_CHANNEL -#endif -#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_udpgw diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channels_defines.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channels_defines.h deleted file mode 100644 index 4f554e40..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channels_defines.h +++ /dev/null @@ -1,148 +0,0 @@ -#define BLOG_CHANNEL_server 0 -#define BLOG_CHANNEL_client 1 -#define BLOG_CHANNEL_flooder 2 -#define BLOG_CHANNEL_tun2socks 3 -#define BLOG_CHANNEL_ncd 4 -#define BLOG_CHANNEL_ncd_var 5 -#define BLOG_CHANNEL_ncd_list 6 -#define BLOG_CHANNEL_ncd_depend 7 -#define BLOG_CHANNEL_ncd_multidepend 8 -#define BLOG_CHANNEL_ncd_dynamic_depend 9 -#define BLOG_CHANNEL_ncd_concat 10 -#define BLOG_CHANNEL_ncd_if 11 -#define BLOG_CHANNEL_ncd_strcmp 12 -#define BLOG_CHANNEL_ncd_regex_match 13 -#define BLOG_CHANNEL_ncd_logical 14 -#define BLOG_CHANNEL_ncd_sleep 15 -#define BLOG_CHANNEL_ncd_print 16 -#define BLOG_CHANNEL_ncd_blocker 17 -#define BLOG_CHANNEL_ncd_run 18 -#define BLOG_CHANNEL_ncd_runonce 19 -#define BLOG_CHANNEL_ncd_daemon 20 -#define BLOG_CHANNEL_ncd_spawn 21 -#define BLOG_CHANNEL_ncd_imperative 22 -#define BLOG_CHANNEL_ncd_ref 23 -#define BLOG_CHANNEL_ncd_index 24 -#define BLOG_CHANNEL_ncd_alias 25 -#define BLOG_CHANNEL_ncd_process_manager 26 -#define BLOG_CHANNEL_ncd_ondemand 27 -#define BLOG_CHANNEL_ncd_foreach 28 -#define BLOG_CHANNEL_ncd_choose 29 -#define BLOG_CHANNEL_ncd_net_backend_waitdevice 30 -#define BLOG_CHANNEL_ncd_net_backend_waitlink 31 -#define BLOG_CHANNEL_ncd_net_backend_badvpn 32 -#define BLOG_CHANNEL_ncd_net_backend_wpa_supplicant 33 -#define BLOG_CHANNEL_ncd_net_backend_rfkill 34 -#define BLOG_CHANNEL_ncd_net_up 35 -#define BLOG_CHANNEL_ncd_net_dns 36 -#define BLOG_CHANNEL_ncd_net_iptables 37 -#define BLOG_CHANNEL_ncd_net_ipv4_addr 38 -#define BLOG_CHANNEL_ncd_net_ipv4_route 39 -#define BLOG_CHANNEL_ncd_net_ipv4_dhcp 40 -#define BLOG_CHANNEL_ncd_net_ipv4_arp_probe 41 -#define BLOG_CHANNEL_ncd_net_watch_interfaces 42 -#define BLOG_CHANNEL_ncd_sys_watch_input 43 -#define BLOG_CHANNEL_ncd_sys_watch_usb 44 -#define BLOG_CHANNEL_ncd_sys_evdev 45 -#define BLOG_CHANNEL_ncd_sys_watch_directory 46 -#define BLOG_CHANNEL_StreamPeerIO 47 -#define BLOG_CHANNEL_DatagramPeerIO 48 -#define BLOG_CHANNEL_BReactor 49 -#define BLOG_CHANNEL_BSignal 50 -#define BLOG_CHANNEL_FragmentProtoAssembler 51 -#define BLOG_CHANNEL_BPredicate 52 -#define BLOG_CHANNEL_ServerConnection 53 -#define BLOG_CHANNEL_Listener 54 -#define BLOG_CHANNEL_DataProto 55 -#define BLOG_CHANNEL_FrameDecider 56 -#define BLOG_CHANNEL_BSocksClient 57 -#define BLOG_CHANNEL_BDHCPClientCore 58 -#define BLOG_CHANNEL_BDHCPClient 59 -#define BLOG_CHANNEL_NCDIfConfig 60 -#define BLOG_CHANNEL_BUnixSignal 61 -#define BLOG_CHANNEL_BProcess 62 -#define BLOG_CHANNEL_PRStreamSink 63 -#define BLOG_CHANNEL_PRStreamSource 64 -#define BLOG_CHANNEL_PacketProtoDecoder 65 -#define BLOG_CHANNEL_DPRelay 66 -#define BLOG_CHANNEL_BThreadWork 67 -#define BLOG_CHANNEL_DPReceive 68 -#define BLOG_CHANNEL_BInputProcess 69 -#define BLOG_CHANNEL_NCDUdevMonitorParser 70 -#define BLOG_CHANNEL_NCDUdevMonitor 71 -#define BLOG_CHANNEL_NCDUdevCache 72 -#define BLOG_CHANNEL_NCDUdevManager 73 -#define BLOG_CHANNEL_BTime 74 -#define BLOG_CHANNEL_BEncryption 75 -#define BLOG_CHANNEL_SPProtoDecoder 76 -#define BLOG_CHANNEL_LineBuffer 77 -#define BLOG_CHANNEL_BTap 78 -#define BLOG_CHANNEL_lwip 79 -#define BLOG_CHANNEL_NCDConfigTokenizer 80 -#define BLOG_CHANNEL_NCDConfigParser 81 -#define BLOG_CHANNEL_NCDValParser 82 -#define BLOG_CHANNEL_nsskey 83 -#define BLOG_CHANNEL_addr 84 -#define BLOG_CHANNEL_PasswordListener 85 -#define BLOG_CHANNEL_NCDInterfaceMonitor 86 -#define BLOG_CHANNEL_NCDRfkillMonitor 87 -#define BLOG_CHANNEL_udpgw 88 -#define BLOG_CHANNEL_UdpGwClient 89 -#define BLOG_CHANNEL_SocksUdpGwClient 90 -#define BLOG_CHANNEL_BNetwork 91 -#define BLOG_CHANNEL_BConnection 92 -#define BLOG_CHANNEL_BSSLConnection 93 -#define BLOG_CHANNEL_BDatagram 94 -#define BLOG_CHANNEL_PeerChat 95 -#define BLOG_CHANNEL_BArpProbe 96 -#define BLOG_CHANNEL_NCDModuleIndex 97 -#define BLOG_CHANNEL_NCDModuleProcess 98 -#define BLOG_CHANNEL_NCDValGenerator 99 -#define BLOG_CHANNEL_ncd_from_string 100 -#define BLOG_CHANNEL_ncd_to_string 101 -#define BLOG_CHANNEL_ncd_value 102 -#define BLOG_CHANNEL_ncd_try 103 -#define BLOG_CHANNEL_ncd_sys_request_server 104 -#define BLOG_CHANNEL_NCDRequest 105 -#define BLOG_CHANNEL_ncd_net_ipv6_wait_dynamic_addr 106 -#define BLOG_CHANNEL_NCDRequestClient 107 -#define BLOG_CHANNEL_ncd_request 108 -#define BLOG_CHANNEL_ncd_sys_request_client 109 -#define BLOG_CHANNEL_ncd_exit 110 -#define BLOG_CHANNEL_ncd_getargs 111 -#define BLOG_CHANNEL_ncd_arithmetic 112 -#define BLOG_CHANNEL_ncd_parse 113 -#define BLOG_CHANNEL_ncd_valuemetic 114 -#define BLOG_CHANNEL_ncd_file 115 -#define BLOG_CHANNEL_ncd_netmask 116 -#define BLOG_CHANNEL_ncd_implode 117 -#define BLOG_CHANNEL_ncd_call2 118 -#define BLOG_CHANNEL_ncd_assert 119 -#define BLOG_CHANNEL_ncd_reboot 120 -#define BLOG_CHANNEL_ncd_explode 121 -#define BLOG_CHANNEL_NCDPlaceholderDb 122 -#define BLOG_CHANNEL_NCDVal 123 -#define BLOG_CHANNEL_ncd_net_ipv6_addr 124 -#define BLOG_CHANNEL_ncd_net_ipv6_route 125 -#define BLOG_CHANNEL_ncd_net_ipv4_addr_in_network 126 -#define BLOG_CHANNEL_ncd_net_ipv6_addr_in_network 127 -#define BLOG_CHANNEL_dostest_server 128 -#define BLOG_CHANNEL_dostest_attacker 129 -#define BLOG_CHANNEL_ncd_timer 130 -#define BLOG_CHANNEL_ncd_file_open 131 -#define BLOG_CHANNEL_ncd_backtrack 132 -#define BLOG_CHANNEL_ncd_socket 133 -#define BLOG_CHANNEL_ncd_depend_scope 134 -#define BLOG_CHANNEL_ncd_substr 135 -#define BLOG_CHANNEL_ncd_sys_start_process 136 -#define BLOG_CHANNEL_NCDBuildProgram 137 -#define BLOG_CHANNEL_ncd_log 138 -#define BLOG_CHANNEL_ncd_log_msg 139 -#define BLOG_CHANNEL_ncd_buffer 140 -#define BLOG_CHANNEL_ncd_getenv 141 -#define BLOG_CHANNEL_BThreadSignal 142 -#define BLOG_CHANNEL_BLockReactor 143 -#define BLOG_CHANNEL_ncd_load_module 144 -#define BLOG_CHANNEL_ncd_basic_functions 145 -#define BLOG_CHANNEL_ncd_objref 146 -#define BLOG_NUM_CHANNELS 147 diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channels_list.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channels_list.h deleted file mode 100644 index d099b2ba..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/blog_channels_list.h +++ /dev/null @@ -1,147 +0,0 @@ -{"server", 4}, -{"client", 4}, -{"flooder", 4}, -{"tun2socks", 4}, -{"ncd", 4}, -{"ncd_var", 4}, -{"ncd_list", 4}, -{"ncd_depend", 4}, -{"ncd_multidepend", 4}, -{"ncd_dynamic_depend", 4}, -{"ncd_concat", 4}, -{"ncd_if", 4}, -{"ncd_strcmp", 4}, -{"ncd_regex_match", 4}, -{"ncd_logical", 4}, -{"ncd_sleep", 4}, -{"ncd_print", 4}, -{"ncd_blocker", 4}, -{"ncd_run", 4}, -{"ncd_runonce", 4}, -{"ncd_daemon", 4}, -{"ncd_spawn", 4}, -{"ncd_imperative", 4}, -{"ncd_ref", 4}, -{"ncd_index", 4}, -{"ncd_alias", 4}, -{"ncd_process_manager", 4}, -{"ncd_ondemand", 4}, -{"ncd_foreach", 4}, -{"ncd_choose", 4}, -{"ncd_net_backend_waitdevice", 4}, -{"ncd_net_backend_waitlink", 4}, -{"ncd_net_backend_badvpn", 4}, -{"ncd_net_backend_wpa_supplicant", 4}, -{"ncd_net_backend_rfkill", 4}, -{"ncd_net_up", 4}, -{"ncd_net_dns", 4}, -{"ncd_net_iptables", 4}, -{"ncd_net_ipv4_addr", 4}, -{"ncd_net_ipv4_route", 4}, -{"ncd_net_ipv4_dhcp", 4}, -{"ncd_net_ipv4_arp_probe", 4}, -{"ncd_net_watch_interfaces", 4}, -{"ncd_sys_watch_input", 4}, -{"ncd_sys_watch_usb", 4}, -{"ncd_sys_evdev", 4}, -{"ncd_sys_watch_directory", 4}, -{"StreamPeerIO", 4}, -{"DatagramPeerIO", 4}, -{"BReactor", 3}, -{"BSignal", 3}, -{"FragmentProtoAssembler", 4}, -{"BPredicate", 3}, -{"ServerConnection", 4}, -{"Listener", 4}, -{"DataProto", 4}, -{"FrameDecider", 4}, -{"BSocksClient", 4}, -{"BDHCPClientCore", 4}, -{"BDHCPClient", 4}, -{"NCDIfConfig", 4}, -{"BUnixSignal", 4}, -{"BProcess", 4}, -{"PRStreamSink", 4}, -{"PRStreamSource", 4}, -{"PacketProtoDecoder", 4}, -{"DPRelay", 4}, -{"BThreadWork", 4}, -{"DPReceive", 4}, -{"BInputProcess", 4}, -{"NCDUdevMonitorParser", 4}, -{"NCDUdevMonitor", 4}, -{"NCDUdevCache", 4}, -{"NCDUdevManager", 4}, -{"BTime", 4}, -{"BEncryption", 4}, -{"SPProtoDecoder", 4}, -{"LineBuffer", 4}, -{"BTap", 4}, -{"lwip", 4}, -{"NCDConfigTokenizer", 4}, -{"NCDConfigParser", 4}, -{"NCDValParser", 4}, -{"nsskey", 4}, -{"addr", 4}, -{"PasswordListener", 4}, -{"NCDInterfaceMonitor", 4}, -{"NCDRfkillMonitor", 4}, -{"udpgw", 4}, -{"UdpGwClient", 4}, -{"SocksUdpGwClient", 4}, -{"BNetwork", 4}, -{"BConnection", 4}, -{"BSSLConnection", 4}, -{"BDatagram", 4}, -{"PeerChat", 4}, -{"BArpProbe", 4}, -{"NCDModuleIndex", 4}, -{"NCDModuleProcess", 4}, -{"NCDValGenerator", 4}, -{"ncd_from_string", 4}, -{"ncd_to_string", 4}, -{"ncd_value", 4}, -{"ncd_try", 4}, -{"ncd_sys_request_server", 4}, -{"NCDRequest", 4}, -{"ncd_net_ipv6_wait_dynamic_addr", 4}, -{"NCDRequestClient", 4}, -{"ncd_request", 4}, -{"ncd_sys_request_client", 4}, -{"ncd_exit", 4}, -{"ncd_getargs", 4}, -{"ncd_arithmetic", 4}, -{"ncd_parse", 4}, -{"ncd_valuemetic", 4}, -{"ncd_file", 4}, -{"ncd_netmask", 4}, -{"ncd_implode", 4}, -{"ncd_call2", 4}, -{"ncd_assert", 4}, -{"ncd_reboot", 4}, -{"ncd_explode", 4}, -{"NCDPlaceholderDb", 4}, -{"NCDVal", 4}, -{"ncd_net_ipv6_addr", 4}, -{"ncd_net_ipv6_route", 4}, -{"ncd_net_ipv4_addr_in_network", 4}, -{"ncd_net_ipv6_addr_in_network", 4}, -{"dostest_server", 4}, -{"dostest_attacker", 4}, -{"ncd_timer", 4}, -{"ncd_file_open", 4}, -{"ncd_backtrack", 4}, -{"ncd_socket", 4}, -{"ncd_depend_scope", 4}, -{"ncd_substr", 4}, -{"ncd_sys_start_process", 4}, -{"NCDBuildProgram", 4}, -{"ncd_log", 4}, -{"ncd_log_msg", 4}, -{"ncd_buffer", 4}, -{"ncd_getenv", 4}, -{"BThreadSignal", 4}, -{"BLockReactor", 4}, -{"ncd_load_module", 4}, -{"ncd_basic_functions", 4}, -{"ncd_objref", 4}, diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/bproto_addr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/bproto_addr.h deleted file mode 100644 index fbd96a80..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/bproto_addr.h +++ /dev/null @@ -1,675 +0,0 @@ -/* - DO NOT EDIT THIS FILE! - This file was automatically generated by the bproto generator. -*/ - -#include -#include - -#include -#include -#include - - -#define addr_SIZEtype (sizeof(struct BProto_header_s) + sizeof(struct BProto_uint8_s)) -#define addr_SIZEip_port (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (2)) -#define addr_SIZEipv4_addr (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (4)) -#define addr_SIZEipv6_addr (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (16)) - -typedef struct { - uint8_t *out; - int used; - int type_count; - int ip_port_count; - int ipv4_addr_count; - int ipv6_addr_count; -} addrWriter; - -static void addrWriter_Init (addrWriter *o, uint8_t *out); -static int addrWriter_Finish (addrWriter *o); -static void addrWriter_Addtype (addrWriter *o, uint8_t v); -static uint8_t * addrWriter_Addip_port (addrWriter *o); -static uint8_t * addrWriter_Addipv4_addr (addrWriter *o); -static uint8_t * addrWriter_Addipv6_addr (addrWriter *o); - -typedef struct { - uint8_t *buf; - int buf_len; - int type_start; - int type_span; - int type_pos; - int ip_port_start; - int ip_port_span; - int ip_port_pos; - int ipv4_addr_start; - int ipv4_addr_span; - int ipv4_addr_pos; - int ipv6_addr_start; - int ipv6_addr_span; - int ipv6_addr_pos; -} addrParser; - -static int addrParser_Init (addrParser *o, uint8_t *buf, int buf_len); -static int addrParser_GotEverything (addrParser *o); -static int addrParser_Gettype (addrParser *o, uint8_t *v); -static void addrParser_Resettype (addrParser *o); -static void addrParser_Forwardtype (addrParser *o); -static int addrParser_Getip_port (addrParser *o, uint8_t **data); -static void addrParser_Resetip_port (addrParser *o); -static void addrParser_Forwardip_port (addrParser *o); -static int addrParser_Getipv4_addr (addrParser *o, uint8_t **data); -static void addrParser_Resetipv4_addr (addrParser *o); -static void addrParser_Forwardipv4_addr (addrParser *o); -static int addrParser_Getipv6_addr (addrParser *o, uint8_t **data); -static void addrParser_Resetipv6_addr (addrParser *o); -static void addrParser_Forwardipv6_addr (addrParser *o); - -void addrWriter_Init (addrWriter *o, uint8_t *out) -{ - o->out = out; - o->used = 0; - o->type_count = 0; - o->ip_port_count = 0; - o->ipv4_addr_count = 0; - o->ipv6_addr_count = 0; -} - -int addrWriter_Finish (addrWriter *o) -{ - ASSERT(o->used >= 0) - ASSERT(o->type_count == 1) - ASSERT(o->ip_port_count >= 0 && o->ip_port_count <= 1) - ASSERT(o->ipv4_addr_count >= 0 && o->ipv4_addr_count <= 1) - ASSERT(o->ipv6_addr_count >= 0 && o->ipv6_addr_count <= 1) - - return o->used; -} - -void addrWriter_Addtype (addrWriter *o, uint8_t v) -{ - ASSERT(o->used >= 0) - ASSERT(o->type_count == 0) - - - struct BProto_header_s header; - header.id = htol16(1); - header.type = htol16(BPROTO_TYPE_UINT8); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_uint8_s data; - data.v = htol8(v); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_uint8_s); - - o->type_count++; -} - -uint8_t * addrWriter_Addip_port (addrWriter *o) -{ - ASSERT(o->used >= 0) - ASSERT(o->ip_port_count == 0) - - - struct BProto_header_s header; - header.id = htol16(2); - header.type = htol16(BPROTO_TYPE_CONSTDATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(2); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += (2); - - o->ip_port_count++; - - return dest; -} - -uint8_t * addrWriter_Addipv4_addr (addrWriter *o) -{ - ASSERT(o->used >= 0) - ASSERT(o->ipv4_addr_count == 0) - - - struct BProto_header_s header; - header.id = htol16(3); - header.type = htol16(BPROTO_TYPE_CONSTDATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(4); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += (4); - - o->ipv4_addr_count++; - - return dest; -} - -uint8_t * addrWriter_Addipv6_addr (addrWriter *o) -{ - ASSERT(o->used >= 0) - ASSERT(o->ipv6_addr_count == 0) - - - struct BProto_header_s header; - header.id = htol16(4); - header.type = htol16(BPROTO_TYPE_CONSTDATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(16); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += (16); - - o->ipv6_addr_count++; - - return dest; -} - -int addrParser_Init (addrParser *o, uint8_t *buf, int buf_len) -{ - ASSERT(buf_len >= 0) - - o->buf = buf; - o->buf_len = buf_len; - o->type_start = o->buf_len; - o->type_span = 0; - o->type_pos = 0; - o->ip_port_start = o->buf_len; - o->ip_port_span = 0; - o->ip_port_pos = 0; - o->ipv4_addr_start = o->buf_len; - o->ipv4_addr_span = 0; - o->ipv4_addr_pos = 0; - o->ipv6_addr_start = o->buf_len; - o->ipv6_addr_span = 0; - o->ipv6_addr_pos = 0; - - int type_count = 0; - int ip_port_count = 0; - int ipv4_addr_count = 0; - int ipv6_addr_count = 0; - - int pos = 0; - int left = o->buf_len; - - while (left > 0) { - int entry_pos = pos; - - if (!(left >= sizeof(struct BProto_header_s))) { - return 0; - } - struct BProto_header_s header; - memcpy(&header, o->buf + pos, sizeof(header)); - pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - if (!(left >= sizeof(struct BProto_uint8_s))) { - return 0; - } - pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - - switch (id) { - case 1: - if (o->type_start == o->buf_len) { - o->type_start = entry_pos; - } - o->type_span = pos - o->type_start; - type_count++; - break; - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT16: { - if (!(left >= sizeof(struct BProto_uint16_s))) { - return 0; - } - pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT32: { - if (!(left >= sizeof(struct BProto_uint32_s))) { - return 0; - } - pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT64: { - if (!(left >= sizeof(struct BProto_uint64_s))) { - return 0; - } - pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - if (!(left >= sizeof(struct BProto_data_header_s))) { - return 0; - } - struct BProto_data_header_s val; - memcpy(&val, o->buf + pos, sizeof(val)); - pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - if (!(left >= payload_len)) { - return 0; - } - pos += payload_len; - left -= payload_len; - - switch (id) { - case 2: - if (!(type == BPROTO_TYPE_CONSTDATA)) { - return 0; - } - if (!(payload_len == (2))) { - return 0; - } - if (o->ip_port_start == o->buf_len) { - o->ip_port_start = entry_pos; - } - o->ip_port_span = pos - o->ip_port_start; - ip_port_count++; - break; - case 3: - if (!(type == BPROTO_TYPE_CONSTDATA)) { - return 0; - } - if (!(payload_len == (4))) { - return 0; - } - if (o->ipv4_addr_start == o->buf_len) { - o->ipv4_addr_start = entry_pos; - } - o->ipv4_addr_span = pos - o->ipv4_addr_start; - ipv4_addr_count++; - break; - case 4: - if (!(type == BPROTO_TYPE_CONSTDATA)) { - return 0; - } - if (!(payload_len == (16))) { - return 0; - } - if (o->ipv6_addr_start == o->buf_len) { - o->ipv6_addr_start = entry_pos; - } - o->ipv6_addr_span = pos - o->ipv6_addr_start; - ipv6_addr_count++; - break; - default: - return 0; - } - } break; - default: - return 0; - } - } - - if (!(type_count == 1)) { - return 0; - } - if (!(ip_port_count <= 1)) { - return 0; - } - if (!(ipv4_addr_count <= 1)) { - return 0; - } - if (!(ipv6_addr_count <= 1)) { - return 0; - } - - return 1; -} - -int addrParser_GotEverything (addrParser *o) -{ - return ( - o->type_pos == o->type_span - && - o->ip_port_pos == o->ip_port_span - && - o->ipv4_addr_pos == o->ipv4_addr_span - && - o->ipv6_addr_pos == o->ipv6_addr_span - ); -} - -int addrParser_Gettype (addrParser *o, uint8_t *v) -{ - ASSERT(o->type_pos >= 0) - ASSERT(o->type_pos <= o->type_span) - - int left = o->type_span - o->type_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->type_start + o->type_pos, sizeof(header)); - o->type_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - struct BProto_uint8_s val; - memcpy(&val, o->buf + o->type_start + o->type_pos, sizeof(val)); - o->type_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - - if (id == 1) { - *v = ltoh8(val.v); - return 1; - } - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->type_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->type_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->type_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->type_start + o->type_pos, sizeof(val)); - o->type_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - o->type_pos += payload_len; - left -= payload_len; - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void addrParser_Resettype (addrParser *o) -{ - o->type_pos = 0; -} - -void addrParser_Forwardtype (addrParser *o) -{ - o->type_pos = o->type_span; -} - -int addrParser_Getip_port (addrParser *o, uint8_t **data) -{ - ASSERT(o->ip_port_pos >= 0) - ASSERT(o->ip_port_pos <= o->ip_port_span) - - int left = o->ip_port_span - o->ip_port_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->ip_port_start + o->ip_port_pos, sizeof(header)); - o->ip_port_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->ip_port_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->ip_port_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->ip_port_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->ip_port_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->ip_port_start + o->ip_port_pos, sizeof(val)); - o->ip_port_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->ip_port_start + o->ip_port_pos; - o->ip_port_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_CONSTDATA && id == 2) { - *data = payload; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void addrParser_Resetip_port (addrParser *o) -{ - o->ip_port_pos = 0; -} - -void addrParser_Forwardip_port (addrParser *o) -{ - o->ip_port_pos = o->ip_port_span; -} - -int addrParser_Getipv4_addr (addrParser *o, uint8_t **data) -{ - ASSERT(o->ipv4_addr_pos >= 0) - ASSERT(o->ipv4_addr_pos <= o->ipv4_addr_span) - - int left = o->ipv4_addr_span - o->ipv4_addr_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->ipv4_addr_start + o->ipv4_addr_pos, sizeof(header)); - o->ipv4_addr_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->ipv4_addr_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->ipv4_addr_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->ipv4_addr_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->ipv4_addr_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->ipv4_addr_start + o->ipv4_addr_pos, sizeof(val)); - o->ipv4_addr_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->ipv4_addr_start + o->ipv4_addr_pos; - o->ipv4_addr_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_CONSTDATA && id == 3) { - *data = payload; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void addrParser_Resetipv4_addr (addrParser *o) -{ - o->ipv4_addr_pos = 0; -} - -void addrParser_Forwardipv4_addr (addrParser *o) -{ - o->ipv4_addr_pos = o->ipv4_addr_span; -} - -int addrParser_Getipv6_addr (addrParser *o, uint8_t **data) -{ - ASSERT(o->ipv6_addr_pos >= 0) - ASSERT(o->ipv6_addr_pos <= o->ipv6_addr_span) - - int left = o->ipv6_addr_span - o->ipv6_addr_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->ipv6_addr_start + o->ipv6_addr_pos, sizeof(header)); - o->ipv6_addr_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->ipv6_addr_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->ipv6_addr_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->ipv6_addr_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->ipv6_addr_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->ipv6_addr_start + o->ipv6_addr_pos, sizeof(val)); - o->ipv6_addr_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->ipv6_addr_start + o->ipv6_addr_pos; - o->ipv6_addr_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_CONSTDATA && id == 4) { - *data = payload; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void addrParser_Resetipv6_addr (addrParser *o) -{ - o->ipv6_addr_pos = 0; -} - -void addrParser_Forwardipv6_addr (addrParser *o) -{ - o->ipv6_addr_pos = o->ipv6_addr_span; -} - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/bproto_bproto_test.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/bproto_bproto_test.h deleted file mode 100644 index dc4ad804..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/bproto_bproto_test.h +++ /dev/null @@ -1,1029 +0,0 @@ -/* - DO NOT EDIT THIS FILE! - This file was automatically generated by the bproto generator. -*/ - -#include -#include - -#include -#include -#include - - -#define msg1_SIZEa (sizeof(struct BProto_header_s) + sizeof(struct BProto_uint16_s)) -#define msg1_SIZEb (sizeof(struct BProto_header_s) + sizeof(struct BProto_uint32_s)) -#define msg1_SIZEc (sizeof(struct BProto_header_s) + sizeof(struct BProto_uint64_s)) -#define msg1_SIZEd (sizeof(struct BProto_header_s) + sizeof(struct BProto_uint16_s)) -#define msg1_SIZEe (sizeof(struct BProto_header_s) + sizeof(struct BProto_uint8_s)) -#define msg1_SIZEf(_len) (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (_len)) -#define msg1_SIZEg (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (4)) - -typedef struct { - uint8_t *out; - int used; - int a_count; - int b_count; - int c_count; - int d_count; - int e_count; - int f_count; - int g_count; -} msg1Writer; - -static void msg1Writer_Init (msg1Writer *o, uint8_t *out); -static int msg1Writer_Finish (msg1Writer *o); -static void msg1Writer_Adda (msg1Writer *o, uint16_t v); -static void msg1Writer_Addb (msg1Writer *o, uint32_t v); -static void msg1Writer_Addc (msg1Writer *o, uint64_t v); -static void msg1Writer_Addd (msg1Writer *o, uint16_t v); -static void msg1Writer_Adde (msg1Writer *o, uint8_t v); -static uint8_t * msg1Writer_Addf (msg1Writer *o, int len); -static uint8_t * msg1Writer_Addg (msg1Writer *o); - -typedef struct { - uint8_t *buf; - int buf_len; - int a_start; - int a_span; - int a_pos; - int b_start; - int b_span; - int b_pos; - int c_start; - int c_span; - int c_pos; - int d_start; - int d_span; - int d_pos; - int e_start; - int e_span; - int e_pos; - int f_start; - int f_span; - int f_pos; - int g_start; - int g_span; - int g_pos; -} msg1Parser; - -static int msg1Parser_Init (msg1Parser *o, uint8_t *buf, int buf_len); -static int msg1Parser_GotEverything (msg1Parser *o); -static int msg1Parser_Geta (msg1Parser *o, uint16_t *v); -static void msg1Parser_Reseta (msg1Parser *o); -static void msg1Parser_Forwarda (msg1Parser *o); -static int msg1Parser_Getb (msg1Parser *o, uint32_t *v); -static void msg1Parser_Resetb (msg1Parser *o); -static void msg1Parser_Forwardb (msg1Parser *o); -static int msg1Parser_Getc (msg1Parser *o, uint64_t *v); -static void msg1Parser_Resetc (msg1Parser *o); -static void msg1Parser_Forwardc (msg1Parser *o); -static int msg1Parser_Getd (msg1Parser *o, uint16_t *v); -static void msg1Parser_Resetd (msg1Parser *o); -static void msg1Parser_Forwardd (msg1Parser *o); -static int msg1Parser_Gete (msg1Parser *o, uint8_t *v); -static void msg1Parser_Resete (msg1Parser *o); -static void msg1Parser_Forwarde (msg1Parser *o); -static int msg1Parser_Getf (msg1Parser *o, uint8_t **data, int *data_len); -static void msg1Parser_Resetf (msg1Parser *o); -static void msg1Parser_Forwardf (msg1Parser *o); -static int msg1Parser_Getg (msg1Parser *o, uint8_t **data); -static void msg1Parser_Resetg (msg1Parser *o); -static void msg1Parser_Forwardg (msg1Parser *o); - -void msg1Writer_Init (msg1Writer *o, uint8_t *out) -{ - o->out = out; - o->used = 0; - o->a_count = 0; - o->b_count = 0; - o->c_count = 0; - o->d_count = 0; - o->e_count = 0; - o->f_count = 0; - o->g_count = 0; -} - -int msg1Writer_Finish (msg1Writer *o) -{ - ASSERT(o->used >= 0) - ASSERT(o->a_count == 1) - ASSERT(o->b_count >= 0 && o->b_count <= 1) - ASSERT(o->c_count >= 1) - ASSERT(o->d_count >= 0) - ASSERT(o->e_count == 1) - ASSERT(o->f_count == 1) - ASSERT(o->g_count == 1) - - return o->used; -} - -void msg1Writer_Adda (msg1Writer *o, uint16_t v) -{ - ASSERT(o->used >= 0) - ASSERT(o->a_count == 0) - - - struct BProto_header_s header; - header.id = htol16(5); - header.type = htol16(BPROTO_TYPE_UINT16); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_uint16_s data; - data.v = htol16(v); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_uint16_s); - - o->a_count++; -} - -void msg1Writer_Addb (msg1Writer *o, uint32_t v) -{ - ASSERT(o->used >= 0) - ASSERT(o->b_count == 0) - - - struct BProto_header_s header; - header.id = htol16(6); - header.type = htol16(BPROTO_TYPE_UINT32); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_uint32_s data; - data.v = htol32(v); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_uint32_s); - - o->b_count++; -} - -void msg1Writer_Addc (msg1Writer *o, uint64_t v) -{ - ASSERT(o->used >= 0) - - - - struct BProto_header_s header; - header.id = htol16(7); - header.type = htol16(BPROTO_TYPE_UINT64); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_uint64_s data; - data.v = htol64(v); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_uint64_s); - - o->c_count++; -} - -void msg1Writer_Addd (msg1Writer *o, uint16_t v) -{ - ASSERT(o->used >= 0) - - - - struct BProto_header_s header; - header.id = htol16(8); - header.type = htol16(BPROTO_TYPE_UINT16); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_uint16_s data; - data.v = htol16(v); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_uint16_s); - - o->d_count++; -} - -void msg1Writer_Adde (msg1Writer *o, uint8_t v) -{ - ASSERT(o->used >= 0) - ASSERT(o->e_count == 0) - - - struct BProto_header_s header; - header.id = htol16(9); - header.type = htol16(BPROTO_TYPE_UINT8); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_uint8_s data; - data.v = htol8(v); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_uint8_s); - - o->e_count++; -} - -uint8_t * msg1Writer_Addf (msg1Writer *o, int len) -{ - ASSERT(o->used >= 0) - ASSERT(o->f_count == 0) - ASSERT(len >= 0 && len <= UINT32_MAX) - - struct BProto_header_s header; - header.id = htol16(10); - header.type = htol16(BPROTO_TYPE_DATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(len); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += len; - - o->f_count++; - - return dest; -} - -uint8_t * msg1Writer_Addg (msg1Writer *o) -{ - ASSERT(o->used >= 0) - ASSERT(o->g_count == 0) - - - struct BProto_header_s header; - header.id = htol16(11); - header.type = htol16(BPROTO_TYPE_CONSTDATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(4); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += (4); - - o->g_count++; - - return dest; -} - -int msg1Parser_Init (msg1Parser *o, uint8_t *buf, int buf_len) -{ - ASSERT(buf_len >= 0) - - o->buf = buf; - o->buf_len = buf_len; - o->a_start = o->buf_len; - o->a_span = 0; - o->a_pos = 0; - o->b_start = o->buf_len; - o->b_span = 0; - o->b_pos = 0; - o->c_start = o->buf_len; - o->c_span = 0; - o->c_pos = 0; - o->d_start = o->buf_len; - o->d_span = 0; - o->d_pos = 0; - o->e_start = o->buf_len; - o->e_span = 0; - o->e_pos = 0; - o->f_start = o->buf_len; - o->f_span = 0; - o->f_pos = 0; - o->g_start = o->buf_len; - o->g_span = 0; - o->g_pos = 0; - - int a_count = 0; - int b_count = 0; - int c_count = 0; - int d_count = 0; - int e_count = 0; - int f_count = 0; - int g_count = 0; - - int pos = 0; - int left = o->buf_len; - - while (left > 0) { - int entry_pos = pos; - - if (!(left >= sizeof(struct BProto_header_s))) { - return 0; - } - struct BProto_header_s header; - memcpy(&header, o->buf + pos, sizeof(header)); - pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - if (!(left >= sizeof(struct BProto_uint8_s))) { - return 0; - } - pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - - switch (id) { - case 9: - if (o->e_start == o->buf_len) { - o->e_start = entry_pos; - } - o->e_span = pos - o->e_start; - e_count++; - break; - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT16: { - if (!(left >= sizeof(struct BProto_uint16_s))) { - return 0; - } - pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - switch (id) { - case 5: - if (o->a_start == o->buf_len) { - o->a_start = entry_pos; - } - o->a_span = pos - o->a_start; - a_count++; - break; - case 8: - if (o->d_start == o->buf_len) { - o->d_start = entry_pos; - } - o->d_span = pos - o->d_start; - d_count++; - break; - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT32: { - if (!(left >= sizeof(struct BProto_uint32_s))) { - return 0; - } - pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - - switch (id) { - case 6: - if (o->b_start == o->buf_len) { - o->b_start = entry_pos; - } - o->b_span = pos - o->b_start; - b_count++; - break; - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT64: { - if (!(left >= sizeof(struct BProto_uint64_s))) { - return 0; - } - pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - - switch (id) { - case 7: - if (o->c_start == o->buf_len) { - o->c_start = entry_pos; - } - o->c_span = pos - o->c_start; - c_count++; - break; - default: - return 0; - } - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - if (!(left >= sizeof(struct BProto_data_header_s))) { - return 0; - } - struct BProto_data_header_s val; - memcpy(&val, o->buf + pos, sizeof(val)); - pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - if (!(left >= payload_len)) { - return 0; - } - pos += payload_len; - left -= payload_len; - - switch (id) { - case 10: - if (!(type == BPROTO_TYPE_DATA)) { - return 0; - } - if (o->f_start == o->buf_len) { - o->f_start = entry_pos; - } - o->f_span = pos - o->f_start; - f_count++; - break; - case 11: - if (!(type == BPROTO_TYPE_CONSTDATA)) { - return 0; - } - if (!(payload_len == (4))) { - return 0; - } - if (o->g_start == o->buf_len) { - o->g_start = entry_pos; - } - o->g_span = pos - o->g_start; - g_count++; - break; - default: - return 0; - } - } break; - default: - return 0; - } - } - - if (!(a_count == 1)) { - return 0; - } - if (!(b_count <= 1)) { - return 0; - } - if (!(c_count >= 1)) { - return 0; - } - if (!(e_count == 1)) { - return 0; - } - if (!(f_count == 1)) { - return 0; - } - if (!(g_count == 1)) { - return 0; - } - - return 1; -} - -int msg1Parser_GotEverything (msg1Parser *o) -{ - return ( - o->a_pos == o->a_span - && - o->b_pos == o->b_span - && - o->c_pos == o->c_span - && - o->d_pos == o->d_span - && - o->e_pos == o->e_span - && - o->f_pos == o->f_span - && - o->g_pos == o->g_span - ); -} - -int msg1Parser_Geta (msg1Parser *o, uint16_t *v) -{ - ASSERT(o->a_pos >= 0) - ASSERT(o->a_pos <= o->a_span) - - int left = o->a_span - o->a_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->a_start + o->a_pos, sizeof(header)); - o->a_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->a_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - struct BProto_uint16_s val; - memcpy(&val, o->buf + o->a_start + o->a_pos, sizeof(val)); - o->a_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - if (id == 5) { - *v = ltoh16(val.v); - return 1; - } - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->a_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->a_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->a_start + o->a_pos, sizeof(val)); - o->a_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - o->a_pos += payload_len; - left -= payload_len; - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg1Parser_Reseta (msg1Parser *o) -{ - o->a_pos = 0; -} - -void msg1Parser_Forwarda (msg1Parser *o) -{ - o->a_pos = o->a_span; -} - -int msg1Parser_Getb (msg1Parser *o, uint32_t *v) -{ - ASSERT(o->b_pos >= 0) - ASSERT(o->b_pos <= o->b_span) - - int left = o->b_span - o->b_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->b_start + o->b_pos, sizeof(header)); - o->b_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->b_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->b_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - struct BProto_uint32_s val; - memcpy(&val, o->buf + o->b_start + o->b_pos, sizeof(val)); - o->b_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - - if (id == 6) { - *v = ltoh32(val.v); - return 1; - } - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->b_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->b_start + o->b_pos, sizeof(val)); - o->b_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - o->b_pos += payload_len; - left -= payload_len; - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg1Parser_Resetb (msg1Parser *o) -{ - o->b_pos = 0; -} - -void msg1Parser_Forwardb (msg1Parser *o) -{ - o->b_pos = o->b_span; -} - -int msg1Parser_Getc (msg1Parser *o, uint64_t *v) -{ - ASSERT(o->c_pos >= 0) - ASSERT(o->c_pos <= o->c_span) - - int left = o->c_span - o->c_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->c_start + o->c_pos, sizeof(header)); - o->c_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->c_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->c_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->c_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - struct BProto_uint64_s val; - memcpy(&val, o->buf + o->c_start + o->c_pos, sizeof(val)); - o->c_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - - if (id == 7) { - *v = ltoh64(val.v); - return 1; - } - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->c_start + o->c_pos, sizeof(val)); - o->c_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - o->c_pos += payload_len; - left -= payload_len; - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg1Parser_Resetc (msg1Parser *o) -{ - o->c_pos = 0; -} - -void msg1Parser_Forwardc (msg1Parser *o) -{ - o->c_pos = o->c_span; -} - -int msg1Parser_Getd (msg1Parser *o, uint16_t *v) -{ - ASSERT(o->d_pos >= 0) - ASSERT(o->d_pos <= o->d_span) - - int left = o->d_span - o->d_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->d_start + o->d_pos, sizeof(header)); - o->d_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->d_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - struct BProto_uint16_s val; - memcpy(&val, o->buf + o->d_start + o->d_pos, sizeof(val)); - o->d_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - if (id == 8) { - *v = ltoh16(val.v); - return 1; - } - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->d_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->d_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->d_start + o->d_pos, sizeof(val)); - o->d_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - o->d_pos += payload_len; - left -= payload_len; - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg1Parser_Resetd (msg1Parser *o) -{ - o->d_pos = 0; -} - -void msg1Parser_Forwardd (msg1Parser *o) -{ - o->d_pos = o->d_span; -} - -int msg1Parser_Gete (msg1Parser *o, uint8_t *v) -{ - ASSERT(o->e_pos >= 0) - ASSERT(o->e_pos <= o->e_span) - - int left = o->e_span - o->e_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->e_start + o->e_pos, sizeof(header)); - o->e_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - struct BProto_uint8_s val; - memcpy(&val, o->buf + o->e_start + o->e_pos, sizeof(val)); - o->e_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - - if (id == 9) { - *v = ltoh8(val.v); - return 1; - } - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->e_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->e_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->e_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->e_start + o->e_pos, sizeof(val)); - o->e_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - o->e_pos += payload_len; - left -= payload_len; - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg1Parser_Resete (msg1Parser *o) -{ - o->e_pos = 0; -} - -void msg1Parser_Forwarde (msg1Parser *o) -{ - o->e_pos = o->e_span; -} - -int msg1Parser_Getf (msg1Parser *o, uint8_t **data, int *data_len) -{ - ASSERT(o->f_pos >= 0) - ASSERT(o->f_pos <= o->f_span) - - int left = o->f_span - o->f_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->f_start + o->f_pos, sizeof(header)); - o->f_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->f_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->f_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->f_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->f_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->f_start + o->f_pos, sizeof(val)); - o->f_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->f_start + o->f_pos; - o->f_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_DATA && id == 10) { - *data = payload; - *data_len = payload_len; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg1Parser_Resetf (msg1Parser *o) -{ - o->f_pos = 0; -} - -void msg1Parser_Forwardf (msg1Parser *o) -{ - o->f_pos = o->f_span; -} - -int msg1Parser_Getg (msg1Parser *o, uint8_t **data) -{ - ASSERT(o->g_pos >= 0) - ASSERT(o->g_pos <= o->g_span) - - int left = o->g_span - o->g_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->g_start + o->g_pos, sizeof(header)); - o->g_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->g_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->g_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->g_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->g_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->g_start + o->g_pos, sizeof(val)); - o->g_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->g_start + o->g_pos; - o->g_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_CONSTDATA && id == 11) { - *data = payload; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg1Parser_Resetg (msg1Parser *o) -{ - o->g_pos = 0; -} - -void msg1Parser_Forwardg (msg1Parser *o) -{ - o->g_pos = o->g_span; -} - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/bproto_msgproto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/bproto_msgproto.h deleted file mode 100644 index e429223d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/generated/bproto_msgproto.h +++ /dev/null @@ -1,2122 +0,0 @@ -/* - DO NOT EDIT THIS FILE! - This file was automatically generated by the bproto generator. -*/ - -#include -#include - -#include -#include -#include - - -#define msg_SIZEtype (sizeof(struct BProto_header_s) + sizeof(struct BProto_uint16_s)) -#define msg_SIZEpayload(_len) (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (_len)) - -typedef struct { - uint8_t *out; - int used; - int type_count; - int payload_count; -} msgWriter; - -static void msgWriter_Init (msgWriter *o, uint8_t *out); -static int msgWriter_Finish (msgWriter *o); -static void msgWriter_Addtype (msgWriter *o, uint16_t v); -static uint8_t * msgWriter_Addpayload (msgWriter *o, int len); - -typedef struct { - uint8_t *buf; - int buf_len; - int type_start; - int type_span; - int type_pos; - int payload_start; - int payload_span; - int payload_pos; -} msgParser; - -static int msgParser_Init (msgParser *o, uint8_t *buf, int buf_len); -static int msgParser_GotEverything (msgParser *o); -static int msgParser_Gettype (msgParser *o, uint16_t *v); -static void msgParser_Resettype (msgParser *o); -static void msgParser_Forwardtype (msgParser *o); -static int msgParser_Getpayload (msgParser *o, uint8_t **data, int *data_len); -static void msgParser_Resetpayload (msgParser *o); -static void msgParser_Forwardpayload (msgParser *o); - -void msgWriter_Init (msgWriter *o, uint8_t *out) -{ - o->out = out; - o->used = 0; - o->type_count = 0; - o->payload_count = 0; -} - -int msgWriter_Finish (msgWriter *o) -{ - ASSERT(o->used >= 0) - ASSERT(o->type_count == 1) - ASSERT(o->payload_count == 1) - - return o->used; -} - -void msgWriter_Addtype (msgWriter *o, uint16_t v) -{ - ASSERT(o->used >= 0) - ASSERT(o->type_count == 0) - - - struct BProto_header_s header; - header.id = htol16(1); - header.type = htol16(BPROTO_TYPE_UINT16); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_uint16_s data; - data.v = htol16(v); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_uint16_s); - - o->type_count++; -} - -uint8_t * msgWriter_Addpayload (msgWriter *o, int len) -{ - ASSERT(o->used >= 0) - ASSERT(o->payload_count == 0) - ASSERT(len >= 0 && len <= UINT32_MAX) - - struct BProto_header_s header; - header.id = htol16(2); - header.type = htol16(BPROTO_TYPE_DATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(len); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += len; - - o->payload_count++; - - return dest; -} - -int msgParser_Init (msgParser *o, uint8_t *buf, int buf_len) -{ - ASSERT(buf_len >= 0) - - o->buf = buf; - o->buf_len = buf_len; - o->type_start = o->buf_len; - o->type_span = 0; - o->type_pos = 0; - o->payload_start = o->buf_len; - o->payload_span = 0; - o->payload_pos = 0; - - int type_count = 0; - int payload_count = 0; - - int pos = 0; - int left = o->buf_len; - - while (left > 0) { - int entry_pos = pos; - - if (!(left >= sizeof(struct BProto_header_s))) { - return 0; - } - struct BProto_header_s header; - memcpy(&header, o->buf + pos, sizeof(header)); - pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - if (!(left >= sizeof(struct BProto_uint8_s))) { - return 0; - } - pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT16: { - if (!(left >= sizeof(struct BProto_uint16_s))) { - return 0; - } - pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - switch (id) { - case 1: - if (o->type_start == o->buf_len) { - o->type_start = entry_pos; - } - o->type_span = pos - o->type_start; - type_count++; - break; - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT32: { - if (!(left >= sizeof(struct BProto_uint32_s))) { - return 0; - } - pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT64: { - if (!(left >= sizeof(struct BProto_uint64_s))) { - return 0; - } - pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - if (!(left >= sizeof(struct BProto_data_header_s))) { - return 0; - } - struct BProto_data_header_s val; - memcpy(&val, o->buf + pos, sizeof(val)); - pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - if (!(left >= payload_len)) { - return 0; - } - pos += payload_len; - left -= payload_len; - - switch (id) { - case 2: - if (!(type == BPROTO_TYPE_DATA)) { - return 0; - } - if (o->payload_start == o->buf_len) { - o->payload_start = entry_pos; - } - o->payload_span = pos - o->payload_start; - payload_count++; - break; - default: - return 0; - } - } break; - default: - return 0; - } - } - - if (!(type_count == 1)) { - return 0; - } - if (!(payload_count == 1)) { - return 0; - } - - return 1; -} - -int msgParser_GotEverything (msgParser *o) -{ - return ( - o->type_pos == o->type_span - && - o->payload_pos == o->payload_span - ); -} - -int msgParser_Gettype (msgParser *o, uint16_t *v) -{ - ASSERT(o->type_pos >= 0) - ASSERT(o->type_pos <= o->type_span) - - int left = o->type_span - o->type_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->type_start + o->type_pos, sizeof(header)); - o->type_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->type_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - struct BProto_uint16_s val; - memcpy(&val, o->buf + o->type_start + o->type_pos, sizeof(val)); - o->type_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - if (id == 1) { - *v = ltoh16(val.v); - return 1; - } - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->type_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->type_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->type_start + o->type_pos, sizeof(val)); - o->type_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - o->type_pos += payload_len; - left -= payload_len; - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msgParser_Resettype (msgParser *o) -{ - o->type_pos = 0; -} - -void msgParser_Forwardtype (msgParser *o) -{ - o->type_pos = o->type_span; -} - -int msgParser_Getpayload (msgParser *o, uint8_t **data, int *data_len) -{ - ASSERT(o->payload_pos >= 0) - ASSERT(o->payload_pos <= o->payload_span) - - int left = o->payload_span - o->payload_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->payload_start + o->payload_pos, sizeof(header)); - o->payload_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->payload_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->payload_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->payload_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->payload_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->payload_start + o->payload_pos, sizeof(val)); - o->payload_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->payload_start + o->payload_pos; - o->payload_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_DATA && id == 2) { - *data = payload; - *data_len = payload_len; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msgParser_Resetpayload (msgParser *o) -{ - o->payload_pos = 0; -} - -void msgParser_Forwardpayload (msgParser *o) -{ - o->payload_pos = o->payload_span; -} - -#define msg_youconnect_SIZEaddr(_len) (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (_len)) -#define msg_youconnect_SIZEkey(_len) (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (_len)) -#define msg_youconnect_SIZEpassword (sizeof(struct BProto_header_s) + sizeof(struct BProto_uint64_s)) - -typedef struct { - uint8_t *out; - int used; - int addr_count; - int key_count; - int password_count; -} msg_youconnectWriter; - -static void msg_youconnectWriter_Init (msg_youconnectWriter *o, uint8_t *out); -static int msg_youconnectWriter_Finish (msg_youconnectWriter *o); -static uint8_t * msg_youconnectWriter_Addaddr (msg_youconnectWriter *o, int len); -static uint8_t * msg_youconnectWriter_Addkey (msg_youconnectWriter *o, int len); -static void msg_youconnectWriter_Addpassword (msg_youconnectWriter *o, uint64_t v); - -typedef struct { - uint8_t *buf; - int buf_len; - int addr_start; - int addr_span; - int addr_pos; - int key_start; - int key_span; - int key_pos; - int password_start; - int password_span; - int password_pos; -} msg_youconnectParser; - -static int msg_youconnectParser_Init (msg_youconnectParser *o, uint8_t *buf, int buf_len); -static int msg_youconnectParser_GotEverything (msg_youconnectParser *o); -static int msg_youconnectParser_Getaddr (msg_youconnectParser *o, uint8_t **data, int *data_len); -static void msg_youconnectParser_Resetaddr (msg_youconnectParser *o); -static void msg_youconnectParser_Forwardaddr (msg_youconnectParser *o); -static int msg_youconnectParser_Getkey (msg_youconnectParser *o, uint8_t **data, int *data_len); -static void msg_youconnectParser_Resetkey (msg_youconnectParser *o); -static void msg_youconnectParser_Forwardkey (msg_youconnectParser *o); -static int msg_youconnectParser_Getpassword (msg_youconnectParser *o, uint64_t *v); -static void msg_youconnectParser_Resetpassword (msg_youconnectParser *o); -static void msg_youconnectParser_Forwardpassword (msg_youconnectParser *o); - -void msg_youconnectWriter_Init (msg_youconnectWriter *o, uint8_t *out) -{ - o->out = out; - o->used = 0; - o->addr_count = 0; - o->key_count = 0; - o->password_count = 0; -} - -int msg_youconnectWriter_Finish (msg_youconnectWriter *o) -{ - ASSERT(o->used >= 0) - ASSERT(o->addr_count >= 1) - ASSERT(o->key_count >= 0 && o->key_count <= 1) - ASSERT(o->password_count >= 0 && o->password_count <= 1) - - return o->used; -} - -uint8_t * msg_youconnectWriter_Addaddr (msg_youconnectWriter *o, int len) -{ - ASSERT(o->used >= 0) - - ASSERT(len >= 0 && len <= UINT32_MAX) - - struct BProto_header_s header; - header.id = htol16(1); - header.type = htol16(BPROTO_TYPE_DATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(len); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += len; - - o->addr_count++; - - return dest; -} - -uint8_t * msg_youconnectWriter_Addkey (msg_youconnectWriter *o, int len) -{ - ASSERT(o->used >= 0) - ASSERT(o->key_count == 0) - ASSERT(len >= 0 && len <= UINT32_MAX) - - struct BProto_header_s header; - header.id = htol16(2); - header.type = htol16(BPROTO_TYPE_DATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(len); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += len; - - o->key_count++; - - return dest; -} - -void msg_youconnectWriter_Addpassword (msg_youconnectWriter *o, uint64_t v) -{ - ASSERT(o->used >= 0) - ASSERT(o->password_count == 0) - - - struct BProto_header_s header; - header.id = htol16(3); - header.type = htol16(BPROTO_TYPE_UINT64); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_uint64_s data; - data.v = htol64(v); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_uint64_s); - - o->password_count++; -} - -int msg_youconnectParser_Init (msg_youconnectParser *o, uint8_t *buf, int buf_len) -{ - ASSERT(buf_len >= 0) - - o->buf = buf; - o->buf_len = buf_len; - o->addr_start = o->buf_len; - o->addr_span = 0; - o->addr_pos = 0; - o->key_start = o->buf_len; - o->key_span = 0; - o->key_pos = 0; - o->password_start = o->buf_len; - o->password_span = 0; - o->password_pos = 0; - - int addr_count = 0; - int key_count = 0; - int password_count = 0; - - int pos = 0; - int left = o->buf_len; - - while (left > 0) { - int entry_pos = pos; - - if (!(left >= sizeof(struct BProto_header_s))) { - return 0; - } - struct BProto_header_s header; - memcpy(&header, o->buf + pos, sizeof(header)); - pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - if (!(left >= sizeof(struct BProto_uint8_s))) { - return 0; - } - pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT16: { - if (!(left >= sizeof(struct BProto_uint16_s))) { - return 0; - } - pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT32: { - if (!(left >= sizeof(struct BProto_uint32_s))) { - return 0; - } - pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT64: { - if (!(left >= sizeof(struct BProto_uint64_s))) { - return 0; - } - pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - - switch (id) { - case 3: - if (o->password_start == o->buf_len) { - o->password_start = entry_pos; - } - o->password_span = pos - o->password_start; - password_count++; - break; - default: - return 0; - } - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - if (!(left >= sizeof(struct BProto_data_header_s))) { - return 0; - } - struct BProto_data_header_s val; - memcpy(&val, o->buf + pos, sizeof(val)); - pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - if (!(left >= payload_len)) { - return 0; - } - pos += payload_len; - left -= payload_len; - - switch (id) { - case 1: - if (!(type == BPROTO_TYPE_DATA)) { - return 0; - } - if (o->addr_start == o->buf_len) { - o->addr_start = entry_pos; - } - o->addr_span = pos - o->addr_start; - addr_count++; - break; - case 2: - if (!(type == BPROTO_TYPE_DATA)) { - return 0; - } - if (o->key_start == o->buf_len) { - o->key_start = entry_pos; - } - o->key_span = pos - o->key_start; - key_count++; - break; - default: - return 0; - } - } break; - default: - return 0; - } - } - - if (!(addr_count >= 1)) { - return 0; - } - if (!(key_count <= 1)) { - return 0; - } - if (!(password_count <= 1)) { - return 0; - } - - return 1; -} - -int msg_youconnectParser_GotEverything (msg_youconnectParser *o) -{ - return ( - o->addr_pos == o->addr_span - && - o->key_pos == o->key_span - && - o->password_pos == o->password_span - ); -} - -int msg_youconnectParser_Getaddr (msg_youconnectParser *o, uint8_t **data, int *data_len) -{ - ASSERT(o->addr_pos >= 0) - ASSERT(o->addr_pos <= o->addr_span) - - int left = o->addr_span - o->addr_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->addr_start + o->addr_pos, sizeof(header)); - o->addr_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->addr_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->addr_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->addr_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->addr_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->addr_start + o->addr_pos, sizeof(val)); - o->addr_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->addr_start + o->addr_pos; - o->addr_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_DATA && id == 1) { - *data = payload; - *data_len = payload_len; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg_youconnectParser_Resetaddr (msg_youconnectParser *o) -{ - o->addr_pos = 0; -} - -void msg_youconnectParser_Forwardaddr (msg_youconnectParser *o) -{ - o->addr_pos = o->addr_span; -} - -int msg_youconnectParser_Getkey (msg_youconnectParser *o, uint8_t **data, int *data_len) -{ - ASSERT(o->key_pos >= 0) - ASSERT(o->key_pos <= o->key_span) - - int left = o->key_span - o->key_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->key_start + o->key_pos, sizeof(header)); - o->key_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->key_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->key_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->key_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->key_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->key_start + o->key_pos, sizeof(val)); - o->key_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->key_start + o->key_pos; - o->key_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_DATA && id == 2) { - *data = payload; - *data_len = payload_len; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg_youconnectParser_Resetkey (msg_youconnectParser *o) -{ - o->key_pos = 0; -} - -void msg_youconnectParser_Forwardkey (msg_youconnectParser *o) -{ - o->key_pos = o->key_span; -} - -int msg_youconnectParser_Getpassword (msg_youconnectParser *o, uint64_t *v) -{ - ASSERT(o->password_pos >= 0) - ASSERT(o->password_pos <= o->password_span) - - int left = o->password_span - o->password_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->password_start + o->password_pos, sizeof(header)); - o->password_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->password_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->password_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->password_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - struct BProto_uint64_s val; - memcpy(&val, o->buf + o->password_start + o->password_pos, sizeof(val)); - o->password_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - - if (id == 3) { - *v = ltoh64(val.v); - return 1; - } - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->password_start + o->password_pos, sizeof(val)); - o->password_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - o->password_pos += payload_len; - left -= payload_len; - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg_youconnectParser_Resetpassword (msg_youconnectParser *o) -{ - o->password_pos = 0; -} - -void msg_youconnectParser_Forwardpassword (msg_youconnectParser *o) -{ - o->password_pos = o->password_span; -} - -#define msg_youconnect_addr_SIZEname(_len) (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (_len)) -#define msg_youconnect_addr_SIZEaddr(_len) (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (_len)) - -typedef struct { - uint8_t *out; - int used; - int name_count; - int addr_count; -} msg_youconnect_addrWriter; - -static void msg_youconnect_addrWriter_Init (msg_youconnect_addrWriter *o, uint8_t *out); -static int msg_youconnect_addrWriter_Finish (msg_youconnect_addrWriter *o); -static uint8_t * msg_youconnect_addrWriter_Addname (msg_youconnect_addrWriter *o, int len); -static uint8_t * msg_youconnect_addrWriter_Addaddr (msg_youconnect_addrWriter *o, int len); - -typedef struct { - uint8_t *buf; - int buf_len; - int name_start; - int name_span; - int name_pos; - int addr_start; - int addr_span; - int addr_pos; -} msg_youconnect_addrParser; - -static int msg_youconnect_addrParser_Init (msg_youconnect_addrParser *o, uint8_t *buf, int buf_len); -static int msg_youconnect_addrParser_GotEverything (msg_youconnect_addrParser *o); -static int msg_youconnect_addrParser_Getname (msg_youconnect_addrParser *o, uint8_t **data, int *data_len); -static void msg_youconnect_addrParser_Resetname (msg_youconnect_addrParser *o); -static void msg_youconnect_addrParser_Forwardname (msg_youconnect_addrParser *o); -static int msg_youconnect_addrParser_Getaddr (msg_youconnect_addrParser *o, uint8_t **data, int *data_len); -static void msg_youconnect_addrParser_Resetaddr (msg_youconnect_addrParser *o); -static void msg_youconnect_addrParser_Forwardaddr (msg_youconnect_addrParser *o); - -void msg_youconnect_addrWriter_Init (msg_youconnect_addrWriter *o, uint8_t *out) -{ - o->out = out; - o->used = 0; - o->name_count = 0; - o->addr_count = 0; -} - -int msg_youconnect_addrWriter_Finish (msg_youconnect_addrWriter *o) -{ - ASSERT(o->used >= 0) - ASSERT(o->name_count == 1) - ASSERT(o->addr_count == 1) - - return o->used; -} - -uint8_t * msg_youconnect_addrWriter_Addname (msg_youconnect_addrWriter *o, int len) -{ - ASSERT(o->used >= 0) - ASSERT(o->name_count == 0) - ASSERT(len >= 0 && len <= UINT32_MAX) - - struct BProto_header_s header; - header.id = htol16(1); - header.type = htol16(BPROTO_TYPE_DATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(len); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += len; - - o->name_count++; - - return dest; -} - -uint8_t * msg_youconnect_addrWriter_Addaddr (msg_youconnect_addrWriter *o, int len) -{ - ASSERT(o->used >= 0) - ASSERT(o->addr_count == 0) - ASSERT(len >= 0 && len <= UINT32_MAX) - - struct BProto_header_s header; - header.id = htol16(2); - header.type = htol16(BPROTO_TYPE_DATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(len); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += len; - - o->addr_count++; - - return dest; -} - -int msg_youconnect_addrParser_Init (msg_youconnect_addrParser *o, uint8_t *buf, int buf_len) -{ - ASSERT(buf_len >= 0) - - o->buf = buf; - o->buf_len = buf_len; - o->name_start = o->buf_len; - o->name_span = 0; - o->name_pos = 0; - o->addr_start = o->buf_len; - o->addr_span = 0; - o->addr_pos = 0; - - int name_count = 0; - int addr_count = 0; - - int pos = 0; - int left = o->buf_len; - - while (left > 0) { - int entry_pos = pos; - - if (!(left >= sizeof(struct BProto_header_s))) { - return 0; - } - struct BProto_header_s header; - memcpy(&header, o->buf + pos, sizeof(header)); - pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - if (!(left >= sizeof(struct BProto_uint8_s))) { - return 0; - } - pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT16: { - if (!(left >= sizeof(struct BProto_uint16_s))) { - return 0; - } - pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT32: { - if (!(left >= sizeof(struct BProto_uint32_s))) { - return 0; - } - pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT64: { - if (!(left >= sizeof(struct BProto_uint64_s))) { - return 0; - } - pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - if (!(left >= sizeof(struct BProto_data_header_s))) { - return 0; - } - struct BProto_data_header_s val; - memcpy(&val, o->buf + pos, sizeof(val)); - pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - if (!(left >= payload_len)) { - return 0; - } - pos += payload_len; - left -= payload_len; - - switch (id) { - case 1: - if (!(type == BPROTO_TYPE_DATA)) { - return 0; - } - if (o->name_start == o->buf_len) { - o->name_start = entry_pos; - } - o->name_span = pos - o->name_start; - name_count++; - break; - case 2: - if (!(type == BPROTO_TYPE_DATA)) { - return 0; - } - if (o->addr_start == o->buf_len) { - o->addr_start = entry_pos; - } - o->addr_span = pos - o->addr_start; - addr_count++; - break; - default: - return 0; - } - } break; - default: - return 0; - } - } - - if (!(name_count == 1)) { - return 0; - } - if (!(addr_count == 1)) { - return 0; - } - - return 1; -} - -int msg_youconnect_addrParser_GotEverything (msg_youconnect_addrParser *o) -{ - return ( - o->name_pos == o->name_span - && - o->addr_pos == o->addr_span - ); -} - -int msg_youconnect_addrParser_Getname (msg_youconnect_addrParser *o, uint8_t **data, int *data_len) -{ - ASSERT(o->name_pos >= 0) - ASSERT(o->name_pos <= o->name_span) - - int left = o->name_span - o->name_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->name_start + o->name_pos, sizeof(header)); - o->name_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->name_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->name_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->name_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->name_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->name_start + o->name_pos, sizeof(val)); - o->name_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->name_start + o->name_pos; - o->name_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_DATA && id == 1) { - *data = payload; - *data_len = payload_len; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg_youconnect_addrParser_Resetname (msg_youconnect_addrParser *o) -{ - o->name_pos = 0; -} - -void msg_youconnect_addrParser_Forwardname (msg_youconnect_addrParser *o) -{ - o->name_pos = o->name_span; -} - -int msg_youconnect_addrParser_Getaddr (msg_youconnect_addrParser *o, uint8_t **data, int *data_len) -{ - ASSERT(o->addr_pos >= 0) - ASSERT(o->addr_pos <= o->addr_span) - - int left = o->addr_span - o->addr_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->addr_start + o->addr_pos, sizeof(header)); - o->addr_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->addr_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->addr_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->addr_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->addr_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->addr_start + o->addr_pos, sizeof(val)); - o->addr_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->addr_start + o->addr_pos; - o->addr_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_DATA && id == 2) { - *data = payload; - *data_len = payload_len; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg_youconnect_addrParser_Resetaddr (msg_youconnect_addrParser *o) -{ - o->addr_pos = 0; -} - -void msg_youconnect_addrParser_Forwardaddr (msg_youconnect_addrParser *o) -{ - o->addr_pos = o->addr_span; -} - -#define msg_seed_SIZEseed_id (sizeof(struct BProto_header_s) + sizeof(struct BProto_uint16_s)) -#define msg_seed_SIZEkey(_len) (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (_len)) -#define msg_seed_SIZEiv(_len) (sizeof(struct BProto_header_s) + sizeof(struct BProto_data_header_s) + (_len)) - -typedef struct { - uint8_t *out; - int used; - int seed_id_count; - int key_count; - int iv_count; -} msg_seedWriter; - -static void msg_seedWriter_Init (msg_seedWriter *o, uint8_t *out); -static int msg_seedWriter_Finish (msg_seedWriter *o); -static void msg_seedWriter_Addseed_id (msg_seedWriter *o, uint16_t v); -static uint8_t * msg_seedWriter_Addkey (msg_seedWriter *o, int len); -static uint8_t * msg_seedWriter_Addiv (msg_seedWriter *o, int len); - -typedef struct { - uint8_t *buf; - int buf_len; - int seed_id_start; - int seed_id_span; - int seed_id_pos; - int key_start; - int key_span; - int key_pos; - int iv_start; - int iv_span; - int iv_pos; -} msg_seedParser; - -static int msg_seedParser_Init (msg_seedParser *o, uint8_t *buf, int buf_len); -static int msg_seedParser_GotEverything (msg_seedParser *o); -static int msg_seedParser_Getseed_id (msg_seedParser *o, uint16_t *v); -static void msg_seedParser_Resetseed_id (msg_seedParser *o); -static void msg_seedParser_Forwardseed_id (msg_seedParser *o); -static int msg_seedParser_Getkey (msg_seedParser *o, uint8_t **data, int *data_len); -static void msg_seedParser_Resetkey (msg_seedParser *o); -static void msg_seedParser_Forwardkey (msg_seedParser *o); -static int msg_seedParser_Getiv (msg_seedParser *o, uint8_t **data, int *data_len); -static void msg_seedParser_Resetiv (msg_seedParser *o); -static void msg_seedParser_Forwardiv (msg_seedParser *o); - -void msg_seedWriter_Init (msg_seedWriter *o, uint8_t *out) -{ - o->out = out; - o->used = 0; - o->seed_id_count = 0; - o->key_count = 0; - o->iv_count = 0; -} - -int msg_seedWriter_Finish (msg_seedWriter *o) -{ - ASSERT(o->used >= 0) - ASSERT(o->seed_id_count == 1) - ASSERT(o->key_count == 1) - ASSERT(o->iv_count == 1) - - return o->used; -} - -void msg_seedWriter_Addseed_id (msg_seedWriter *o, uint16_t v) -{ - ASSERT(o->used >= 0) - ASSERT(o->seed_id_count == 0) - - - struct BProto_header_s header; - header.id = htol16(1); - header.type = htol16(BPROTO_TYPE_UINT16); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_uint16_s data; - data.v = htol16(v); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_uint16_s); - - o->seed_id_count++; -} - -uint8_t * msg_seedWriter_Addkey (msg_seedWriter *o, int len) -{ - ASSERT(o->used >= 0) - ASSERT(o->key_count == 0) - ASSERT(len >= 0 && len <= UINT32_MAX) - - struct BProto_header_s header; - header.id = htol16(2); - header.type = htol16(BPROTO_TYPE_DATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(len); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += len; - - o->key_count++; - - return dest; -} - -uint8_t * msg_seedWriter_Addiv (msg_seedWriter *o, int len) -{ - ASSERT(o->used >= 0) - ASSERT(o->iv_count == 0) - ASSERT(len >= 0 && len <= UINT32_MAX) - - struct BProto_header_s header; - header.id = htol16(3); - header.type = htol16(BPROTO_TYPE_DATA); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_data_header_s data; - data.len = htol32(len); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_data_header_s); - - uint8_t *dest = (o->out + o->used); - o->used += len; - - o->iv_count++; - - return dest; -} - -int msg_seedParser_Init (msg_seedParser *o, uint8_t *buf, int buf_len) -{ - ASSERT(buf_len >= 0) - - o->buf = buf; - o->buf_len = buf_len; - o->seed_id_start = o->buf_len; - o->seed_id_span = 0; - o->seed_id_pos = 0; - o->key_start = o->buf_len; - o->key_span = 0; - o->key_pos = 0; - o->iv_start = o->buf_len; - o->iv_span = 0; - o->iv_pos = 0; - - int seed_id_count = 0; - int key_count = 0; - int iv_count = 0; - - int pos = 0; - int left = o->buf_len; - - while (left > 0) { - int entry_pos = pos; - - if (!(left >= sizeof(struct BProto_header_s))) { - return 0; - } - struct BProto_header_s header; - memcpy(&header, o->buf + pos, sizeof(header)); - pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - if (!(left >= sizeof(struct BProto_uint8_s))) { - return 0; - } - pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT16: { - if (!(left >= sizeof(struct BProto_uint16_s))) { - return 0; - } - pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - switch (id) { - case 1: - if (o->seed_id_start == o->buf_len) { - o->seed_id_start = entry_pos; - } - o->seed_id_span = pos - o->seed_id_start; - seed_id_count++; - break; - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT32: { - if (!(left >= sizeof(struct BProto_uint32_s))) { - return 0; - } - pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT64: { - if (!(left >= sizeof(struct BProto_uint64_s))) { - return 0; - } - pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - if (!(left >= sizeof(struct BProto_data_header_s))) { - return 0; - } - struct BProto_data_header_s val; - memcpy(&val, o->buf + pos, sizeof(val)); - pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - if (!(left >= payload_len)) { - return 0; - } - pos += payload_len; - left -= payload_len; - - switch (id) { - case 2: - if (!(type == BPROTO_TYPE_DATA)) { - return 0; - } - if (o->key_start == o->buf_len) { - o->key_start = entry_pos; - } - o->key_span = pos - o->key_start; - key_count++; - break; - case 3: - if (!(type == BPROTO_TYPE_DATA)) { - return 0; - } - if (o->iv_start == o->buf_len) { - o->iv_start = entry_pos; - } - o->iv_span = pos - o->iv_start; - iv_count++; - break; - default: - return 0; - } - } break; - default: - return 0; - } - } - - if (!(seed_id_count == 1)) { - return 0; - } - if (!(key_count == 1)) { - return 0; - } - if (!(iv_count == 1)) { - return 0; - } - - return 1; -} - -int msg_seedParser_GotEverything (msg_seedParser *o) -{ - return ( - o->seed_id_pos == o->seed_id_span - && - o->key_pos == o->key_span - && - o->iv_pos == o->iv_span - ); -} - -int msg_seedParser_Getseed_id (msg_seedParser *o, uint16_t *v) -{ - ASSERT(o->seed_id_pos >= 0) - ASSERT(o->seed_id_pos <= o->seed_id_span) - - int left = o->seed_id_span - o->seed_id_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->seed_id_start + o->seed_id_pos, sizeof(header)); - o->seed_id_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->seed_id_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - struct BProto_uint16_s val; - memcpy(&val, o->buf + o->seed_id_start + o->seed_id_pos, sizeof(val)); - o->seed_id_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - if (id == 1) { - *v = ltoh16(val.v); - return 1; - } - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->seed_id_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->seed_id_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->seed_id_start + o->seed_id_pos, sizeof(val)); - o->seed_id_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - o->seed_id_pos += payload_len; - left -= payload_len; - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg_seedParser_Resetseed_id (msg_seedParser *o) -{ - o->seed_id_pos = 0; -} - -void msg_seedParser_Forwardseed_id (msg_seedParser *o) -{ - o->seed_id_pos = o->seed_id_span; -} - -int msg_seedParser_Getkey (msg_seedParser *o, uint8_t **data, int *data_len) -{ - ASSERT(o->key_pos >= 0) - ASSERT(o->key_pos <= o->key_span) - - int left = o->key_span - o->key_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->key_start + o->key_pos, sizeof(header)); - o->key_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->key_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->key_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->key_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->key_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->key_start + o->key_pos, sizeof(val)); - o->key_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->key_start + o->key_pos; - o->key_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_DATA && id == 2) { - *data = payload; - *data_len = payload_len; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg_seedParser_Resetkey (msg_seedParser *o) -{ - o->key_pos = 0; -} - -void msg_seedParser_Forwardkey (msg_seedParser *o) -{ - o->key_pos = o->key_span; -} - -int msg_seedParser_Getiv (msg_seedParser *o, uint8_t **data, int *data_len) -{ - ASSERT(o->iv_pos >= 0) - ASSERT(o->iv_pos <= o->iv_span) - - int left = o->iv_span - o->iv_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->iv_start + o->iv_pos, sizeof(header)); - o->iv_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->iv_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - o->iv_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->iv_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->iv_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->iv_start + o->iv_pos, sizeof(val)); - o->iv_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - uint8_t *payload = o->buf + o->iv_start + o->iv_pos; - o->iv_pos += payload_len; - left -= payload_len; - - if (type == BPROTO_TYPE_DATA && id == 3) { - *data = payload; - *data_len = payload_len; - return 1; - } - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg_seedParser_Resetiv (msg_seedParser *o) -{ - o->iv_pos = 0; -} - -void msg_seedParser_Forwardiv (msg_seedParser *o) -{ - o->iv_pos = o->iv_span; -} - -#define msg_confirmseed_SIZEseed_id (sizeof(struct BProto_header_s) + sizeof(struct BProto_uint16_s)) - -typedef struct { - uint8_t *out; - int used; - int seed_id_count; -} msg_confirmseedWriter; - -static void msg_confirmseedWriter_Init (msg_confirmseedWriter *o, uint8_t *out); -static int msg_confirmseedWriter_Finish (msg_confirmseedWriter *o); -static void msg_confirmseedWriter_Addseed_id (msg_confirmseedWriter *o, uint16_t v); - -typedef struct { - uint8_t *buf; - int buf_len; - int seed_id_start; - int seed_id_span; - int seed_id_pos; -} msg_confirmseedParser; - -static int msg_confirmseedParser_Init (msg_confirmseedParser *o, uint8_t *buf, int buf_len); -static int msg_confirmseedParser_GotEverything (msg_confirmseedParser *o); -static int msg_confirmseedParser_Getseed_id (msg_confirmseedParser *o, uint16_t *v); -static void msg_confirmseedParser_Resetseed_id (msg_confirmseedParser *o); -static void msg_confirmseedParser_Forwardseed_id (msg_confirmseedParser *o); - -void msg_confirmseedWriter_Init (msg_confirmseedWriter *o, uint8_t *out) -{ - o->out = out; - o->used = 0; - o->seed_id_count = 0; -} - -int msg_confirmseedWriter_Finish (msg_confirmseedWriter *o) -{ - ASSERT(o->used >= 0) - ASSERT(o->seed_id_count == 1) - - return o->used; -} - -void msg_confirmseedWriter_Addseed_id (msg_confirmseedWriter *o, uint16_t v) -{ - ASSERT(o->used >= 0) - ASSERT(o->seed_id_count == 0) - - - struct BProto_header_s header; - header.id = htol16(1); - header.type = htol16(BPROTO_TYPE_UINT16); - memcpy(o->out + o->used, &header, sizeof(header)); - o->used += sizeof(struct BProto_header_s); - - struct BProto_uint16_s data; - data.v = htol16(v); - memcpy(o->out + o->used, &data, sizeof(data)); - o->used += sizeof(struct BProto_uint16_s); - - o->seed_id_count++; -} - -int msg_confirmseedParser_Init (msg_confirmseedParser *o, uint8_t *buf, int buf_len) -{ - ASSERT(buf_len >= 0) - - o->buf = buf; - o->buf_len = buf_len; - o->seed_id_start = o->buf_len; - o->seed_id_span = 0; - o->seed_id_pos = 0; - - int seed_id_count = 0; - - int pos = 0; - int left = o->buf_len; - - while (left > 0) { - int entry_pos = pos; - - if (!(left >= sizeof(struct BProto_header_s))) { - return 0; - } - struct BProto_header_s header; - memcpy(&header, o->buf + pos, sizeof(header)); - pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - if (!(left >= sizeof(struct BProto_uint8_s))) { - return 0; - } - pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT16: { - if (!(left >= sizeof(struct BProto_uint16_s))) { - return 0; - } - pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - switch (id) { - case 1: - if (o->seed_id_start == o->buf_len) { - o->seed_id_start = entry_pos; - } - o->seed_id_span = pos - o->seed_id_start; - seed_id_count++; - break; - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT32: { - if (!(left >= sizeof(struct BProto_uint32_s))) { - return 0; - } - pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_UINT64: { - if (!(left >= sizeof(struct BProto_uint64_s))) { - return 0; - } - pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - - switch (id) { - default: - return 0; - } - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - if (!(left >= sizeof(struct BProto_data_header_s))) { - return 0; - } - struct BProto_data_header_s val; - memcpy(&val, o->buf + pos, sizeof(val)); - pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - if (!(left >= payload_len)) { - return 0; - } - pos += payload_len; - left -= payload_len; - - switch (id) { - default: - return 0; - } - } break; - default: - return 0; - } - } - - if (!(seed_id_count == 1)) { - return 0; - } - - return 1; -} - -int msg_confirmseedParser_GotEverything (msg_confirmseedParser *o) -{ - return ( - o->seed_id_pos == o->seed_id_span - ); -} - -int msg_confirmseedParser_Getseed_id (msg_confirmseedParser *o, uint16_t *v) -{ - ASSERT(o->seed_id_pos >= 0) - ASSERT(o->seed_id_pos <= o->seed_id_span) - - int left = o->seed_id_span - o->seed_id_pos; - - while (left > 0) { - ASSERT(left >= sizeof(struct BProto_header_s)) - struct BProto_header_s header; - memcpy(&header, o->buf + o->seed_id_start + o->seed_id_pos, sizeof(header)); - o->seed_id_pos += sizeof(struct BProto_header_s); - left -= sizeof(struct BProto_header_s); - uint16_t type = ltoh16(header.type); - uint16_t id = ltoh16(header.id); - - switch (type) { - case BPROTO_TYPE_UINT8: { - ASSERT(left >= sizeof(struct BProto_uint8_s)) - o->seed_id_pos += sizeof(struct BProto_uint8_s); - left -= sizeof(struct BProto_uint8_s); - } break; - case BPROTO_TYPE_UINT16: { - ASSERT(left >= sizeof(struct BProto_uint16_s)) - struct BProto_uint16_s val; - memcpy(&val, o->buf + o->seed_id_start + o->seed_id_pos, sizeof(val)); - o->seed_id_pos += sizeof(struct BProto_uint16_s); - left -= sizeof(struct BProto_uint16_s); - - if (id == 1) { - *v = ltoh16(val.v); - return 1; - } - } break; - case BPROTO_TYPE_UINT32: { - ASSERT(left >= sizeof(struct BProto_uint32_s)) - o->seed_id_pos += sizeof(struct BProto_uint32_s); - left -= sizeof(struct BProto_uint32_s); - } break; - case BPROTO_TYPE_UINT64: { - ASSERT(left >= sizeof(struct BProto_uint64_s)) - o->seed_id_pos += sizeof(struct BProto_uint64_s); - left -= sizeof(struct BProto_uint64_s); - } break; - case BPROTO_TYPE_DATA: - case BPROTO_TYPE_CONSTDATA: - { - ASSERT(left >= sizeof(struct BProto_data_header_s)) - struct BProto_data_header_s val; - memcpy(&val, o->buf + o->seed_id_start + o->seed_id_pos, sizeof(val)); - o->seed_id_pos += sizeof(struct BProto_data_header_s); - left -= sizeof(struct BProto_data_header_s); - - uint32_t payload_len = ltoh32(val.len); - ASSERT(left >= payload_len) - o->seed_id_pos += payload_len; - left -= payload_len; - } break; - default: - ASSERT(0); - } - } - - return 0; -} - -void msg_confirmseedParser_Resetseed_id (msg_confirmseedParser *o) -{ - o->seed_id_pos = 0; -} - -void msg_confirmseedParser_Forwardseed_id (msg_confirmseedParser *o) -{ - o->seed_id_pos = o->seed_id_span; -} - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/arch/cc.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/arch/cc.h deleted file mode 100644 index a917779a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/arch/cc.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @file cc.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef LWIP_CUSTOM_CC_H -#define LWIP_CUSTOM_CC_H - -#include -#include -#include -#include - -#include "misc/debug.h" -#include "misc/byteorder.h" -#include "misc/packed.h" -#include "misc/print_macros.h" -#include "misc/byteorder.h" -#include "base/BLog.h" - -#define u8_t uint8_t -#define s8_t int8_t -#define u16_t uint16_t -#define s16_t int16_t -#define u32_t uint32_t -#define s32_t int32_t -#define mem_ptr_t uintptr_t - -#define PACK_STRUCT_BEGIN B_START_PACKED -#define PACK_STRUCT_END B_END_PACKED -#define PACK_STRUCT_STRUCT B_PACKED - -#define LWIP_PLATFORM_DIAG(x) { if (BLog_WouldLog(BLOG_CHANNEL_lwip, BLOG_INFO)) { BLog_Begin(); BLog_Append x; BLog_Finish(BLOG_CHANNEL_lwip, BLOG_INFO); } } -#define LWIP_PLATFORM_ASSERT(x) { fprintf(stderr, "%s: lwip assertion failure: %s\n", __FUNCTION__, (x)); abort(); } - -#define U16_F PRIu16 -#define S16_F PRId16 -#define X16_F PRIx16 -#define U32_F PRIu32 -#define S32_F PRId32 -#define X32_F PRIx32 -#define SZT_F "zu" - -#define LWIP_PLATFORM_BYTESWAP 1 -#define LWIP_PLATFORM_HTONS(x) hton16(x) -#define LWIP_PLATFORM_HTONL(x) hton32(x) - -#define LWIP_RAND() ( \ - (((uint32_t)(rand() & 0xFF)) << 24) | \ - (((uint32_t)(rand() & 0xFF)) << 16) | \ - (((uint32_t)(rand() & 0xFF)) << 8) | \ - (((uint32_t)(rand() & 0xFF)) << 0) \ -) - -// for BYTE_ORDER -#if defined(BADVPN_FREEBSD) - #include -#else - #define LITTLE_ENDIAN 1234 - #define BIG_ENDIAN 4321 - #if defined(BADVPN_LITTLE_ENDIAN) - #define BYTE_ORDER LITTLE_ENDIAN - #else - #define BYTE_ORDER BIG_ENDIAN - #endif -#endif - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/arch/perf.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/arch/perf.h deleted file mode 100644 index 09c9d47d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/arch/perf.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file perf.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef LWIP_CUSTOM_PERF_H -#define LWIP_CUSTOM_PERF_H - -#define PERF_START -#define PERF_STOP(x) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/lwipopts.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/lwipopts.h deleted file mode 100644 index 69c27fb2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/lwipopts.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @file lwipopts.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef LWIP_CUSTOM_LWIPOPTS_H -#define LWIP_CUSTOM_LWIPOPTS_H - -#define NO_SYS 1 -#define MEM_ALIGNMENT 4 - -#define LWIP_ARP 0 -#define ARP_QUEUEING 0 -#define IP_FORWARD 0 -#define LWIP_ICMP 1 -#define LWIP_RAW 0 -#define LWIP_DHCP 0 -#define LWIP_AUTOIP 0 -#define LWIP_SNMP 0 -#define LWIP_IGMP 0 -#define LWIP_DNS 0 -#define LWIP_UDP 1 -#define LWIP_UDPLITE 0 -#define LWIP_TCP 1 -#define LWIP_CALLBACK_API 1 -#define LWIP_NETIF_API 0 -#define LWIP_NETIF_LOOPBACK 0 -#define LWIP_HAVE_LOOPIF 0 -#define LWIP_HAVE_SLIPIF 0 -#define LWIP_NETCONN 0 -#define LWIP_SOCKET 0 -#define PPP_SUPPORT 0 -#define LWIP_IPV6 0 -#define LWIP_IPV6_MLD 0 -#define LWIP_IPV6_AUTOCONFIG 0 - -#define LWIP_CHECKSUM_ON_COPY 1 - -// MEM -#define MEM_SIZE (1024 * 1024 * 2) /* 1MiB */ -#define MEMP_NUM_PBUF 256 -#define MEMP_NUM_TCP_PCB 256 -#define MEMP_NUM_TCP_PCB_LISTEN 256 -#define MEMP_NUM_TCP_SEG 256 -#define MEMP_NUM_REASSDATA 256 -#define MEMP_NUM_FRAG_PBUF 256 -#define PBUF_POOL_SIZE 256 - -//#define MEMP_NUM_TCP_PCB_LISTEN 16 -//#define MEMP_NUM_TCP_PCB 1024 -//#define TCP_SND_BUF 32469 -//#define TCP_SND_QUEUELEN (4 * (TCP_SND_BUF)/(TCP_MSS)) - -#define MEM_LIBC_MALLOC 1 -#define MEMP_MEM_MALLOC 1 - -//#define TCP_MSS 8117 - -#define TCP_MSS 2048 -#define TCP_WND (2*TCP_MSS) -#define TCP_SND_BUF 2 * TCP_WND -#define TCP_OVERSIZE TCP_MSS -#define TCP_SND_QUEUELEN TCP_SNDQUEUELEN_OVERFLOW - - -//#define LWIP_DEBUG -#define TCP_DEBUG LWIP_DBG_ON -#define IP_DEBUG LWIP_DBG_ON -#define TCP_INPUT_DEBUG LWIP_DBG_ON -#define TCP_WND_DEBUG LWIP_DBG_ON -#define TCP_OUTPUT_DEBUG LWIP_DBG_ON -#define TCP_RST_DEBUG LWIP_DBG_ON -#define TCP_QLEN_DEBUG LWIP_DBG_ON -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/sys.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/sys.c deleted file mode 100644 index 6f5ce627..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/custom/sys.c +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @file sys.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "system/BTime.h" - -#include "lwip/sys.h" - -u32_t sys_now (void) -{ - return btime_gettime(); -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/def.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/def.c deleted file mode 100644 index 352b5524..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/def.c +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @file - * Common functions used throughout the stack. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Simon Goldschmidt - * - */ - -#include "lwip/opt.h" -#include "lwip/def.h" - -/** - * These are reference implementations of the byte swapping functions. - * Again with the aim of being simple, correct and fully portable. - * Byte swapping is the second thing you would want to optimize. You will - * need to port it to your architecture and in your cc.h: - * - * #define LWIP_PLATFORM_BYTESWAP 1 - * #define LWIP_PLATFORM_HTONS(x) - * #define LWIP_PLATFORM_HTONL(x) - * - * Note ntohs() and ntohl() are merely references to the htonx counterparts. - */ - -#if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) - -/** - * Convert an u16_t from host- to network byte order. - * - * @param n u16_t in host byte order - * @return n in network byte order - */ -u16_t -lwip_htons(u16_t n) -{ - return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); -} - -/** - * Convert an u16_t from network- to host byte order. - * - * @param n u16_t in network byte order - * @return n in host byte order - */ -u16_t -lwip_ntohs(u16_t n) -{ - return lwip_htons(n); -} - -/** - * Convert an u32_t from host- to network byte order. - * - * @param n u32_t in host byte order - * @return n in network byte order - */ -u32_t -lwip_htonl(u32_t n) -{ - return ((n & 0xff) << 24) | - ((n & 0xff00) << 8) | - ((n & 0xff0000UL) >> 8) | - ((n & 0xff000000UL) >> 24); -} - -/** - * Convert an u32_t from network- to host byte order. - * - * @param n u32_t in network byte order - * @return n in host byte order - */ -u32_t -lwip_ntohl(u32_t n) -{ - return lwip_htonl(n); -} - -#endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/inet_chksum.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/inet_chksum.c deleted file mode 100644 index 8bc42c14..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/inet_chksum.c +++ /dev/null @@ -1,545 +0,0 @@ -/** - * @file - * Incluse internet checksum functions. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/inet_chksum.h" -#include "lwip/def.h" - -#include -#include - -/* These are some reference implementations of the checksum algorithm, with the - * aim of being simple, correct and fully portable. Checksumming is the - * first thing you would want to optimize for your platform. If you create - * your own version, link it in and in your cc.h put: - * - * #define LWIP_CHKSUM - * - * Or you can select from the implementations below by defining - * LWIP_CHKSUM_ALGORITHM to 1, 2 or 3. - */ - -#ifndef LWIP_CHKSUM -# define LWIP_CHKSUM lwip_standard_chksum -# ifndef LWIP_CHKSUM_ALGORITHM -# define LWIP_CHKSUM_ALGORITHM 2 -# endif -u16_t lwip_standard_chksum(void *dataptr, int len); -#endif -/* If none set: */ -#ifndef LWIP_CHKSUM_ALGORITHM -# define LWIP_CHKSUM_ALGORITHM 0 -#endif - -#if (LWIP_CHKSUM_ALGORITHM == 1) /* Version #1 */ -/** - * lwip checksum - * - * @param dataptr points to start of data to be summed at any boundary - * @param len length of data to be summed - * @return host order (!) lwip checksum (non-inverted Internet sum) - * - * @note accumulator size limits summable length to 64k - * @note host endianess is irrelevant (p3 RFC1071) - */ -u16_t -lwip_standard_chksum(void *dataptr, u16_t len) -{ - u32_t acc; - u16_t src; - u8_t *octetptr; - - acc = 0; - /* dataptr may be at odd or even addresses */ - octetptr = (u8_t*)dataptr; - while (len > 1) { - /* declare first octet as most significant - thus assume network order, ignoring host order */ - src = (*octetptr) << 8; - octetptr++; - /* declare second octet as least significant */ - src |= (*octetptr); - octetptr++; - acc += src; - len -= 2; - } - if (len > 0) { - /* accumulate remaining octet */ - src = (*octetptr) << 8; - acc += src; - } - /* add deferred carry bits */ - acc = (acc >> 16) + (acc & 0x0000ffffUL); - if ((acc & 0xffff0000UL) != 0) { - acc = (acc >> 16) + (acc & 0x0000ffffUL); - } - /* This maybe a little confusing: reorder sum using htons() - instead of ntohs() since it has a little less call overhead. - The caller must invert bits for Internet sum ! */ - return htons((u16_t)acc); -} -#endif - -#if (LWIP_CHKSUM_ALGORITHM == 2) /* Alternative version #2 */ -/* - * Curt McDowell - * Broadcom Corp. - * csm@broadcom.com - * - * IP checksum two bytes at a time with support for - * unaligned buffer. - * Works for len up to and including 0x20000. - * by Curt McDowell, Broadcom Corp. 12/08/2005 - * - * @param dataptr points to start of data to be summed at any boundary - * @param len length of data to be summed - * @return host order (!) lwip checksum (non-inverted Internet sum) - */ - -u16_t -lwip_standard_chksum(void *dataptr, int len) -{ - u8_t *pb = (u8_t *)dataptr; - u16_t *ps, t = 0; - u32_t sum = 0; - int odd = ((mem_ptr_t)pb & 1); - - /* Get aligned to u16_t */ - if (odd && len > 0) { - ((u8_t *)&t)[1] = *pb++; - len--; - } - - /* Add the bulk of the data */ - ps = (u16_t *)(void *)pb; - while (len > 1) { - sum += *ps++; - len -= 2; - } - - /* Consume left-over byte, if any */ - if (len > 0) { - ((u8_t *)&t)[0] = *(u8_t *)ps; - } - - /* Add end bytes */ - sum += t; - - /* Fold 32-bit sum to 16 bits - calling this twice is propably faster than if statements... */ - sum = FOLD_U32T(sum); - sum = FOLD_U32T(sum); - - /* Swap if alignment was odd */ - if (odd) { - sum = SWAP_BYTES_IN_WORD(sum); - } - - return (u16_t)sum; -} -#endif - -#if (LWIP_CHKSUM_ALGORITHM == 3) /* Alternative version #3 */ -/** - * An optimized checksum routine. Basically, it uses loop-unrolling on - * the checksum loop, treating the head and tail bytes specially, whereas - * the inner loop acts on 8 bytes at a time. - * - * @arg start of buffer to be checksummed. May be an odd byte address. - * @len number of bytes in the buffer to be checksummed. - * @return host order (!) lwip checksum (non-inverted Internet sum) - * - * by Curt McDowell, Broadcom Corp. December 8th, 2005 - */ - -u16_t -lwip_standard_chksum(void *dataptr, int len) -{ - u8_t *pb = (u8_t *)dataptr; - u16_t *ps, t = 0; - u32_t *pl; - u32_t sum = 0, tmp; - /* starts at odd byte address? */ - int odd = ((mem_ptr_t)pb & 1); - - if (odd && len > 0) { - ((u8_t *)&t)[1] = *pb++; - len--; - } - - ps = (u16_t *)pb; - - if (((mem_ptr_t)ps & 3) && len > 1) { - sum += *ps++; - len -= 2; - } - - pl = (u32_t *)ps; - - while (len > 7) { - tmp = sum + *pl++; /* ping */ - if (tmp < sum) { - tmp++; /* add back carry */ - } - - sum = tmp + *pl++; /* pong */ - if (sum < tmp) { - sum++; /* add back carry */ - } - - len -= 8; - } - - /* make room in upper bits */ - sum = FOLD_U32T(sum); - - ps = (u16_t *)pl; - - /* 16-bit aligned word remaining? */ - while (len > 1) { - sum += *ps++; - len -= 2; - } - - /* dangling tail byte remaining? */ - if (len > 0) { /* include odd byte */ - ((u8_t *)&t)[0] = *(u8_t *)ps; - } - - sum += t; /* add end bytes */ - - /* Fold 32-bit sum to 16 bits - calling this twice is propably faster than if statements... */ - sum = FOLD_U32T(sum); - sum = FOLD_U32T(sum); - - if (odd) { - sum = SWAP_BYTES_IN_WORD(sum); - } - - return (u16_t)sum; -} -#endif - -/** Parts of the pseudo checksum which are common to IPv4 and IPv6 */ -static u16_t -inet_cksum_pseudo_base(struct pbuf *p, u8_t proto, u16_t proto_len, u32_t acc) -{ - struct pbuf *q; - u8_t swapped = 0; - - /* iterate through all pbuf in chain */ - for(q = p; q != NULL; q = q->next) { - LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n", - (void *)q, (void *)q->next)); - acc += LWIP_CHKSUM(q->payload, q->len); - /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/ - /* just executing this next line is probably faster that the if statement needed - to check whether we really need to execute it, and does no harm */ - acc = FOLD_U32T(acc); - if (q->len % 2 != 0) { - swapped = 1 - swapped; - acc = SWAP_BYTES_IN_WORD(acc); - } - /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%"X32_F" \n", acc));*/ - } - - if (swapped) { - acc = SWAP_BYTES_IN_WORD(acc); - } - - acc += (u32_t)htons((u16_t)proto); - acc += (u32_t)htons(proto_len); - - /* Fold 32-bit sum to 16 bits - calling this twice is propably faster than if statements... */ - acc = FOLD_U32T(acc); - acc = FOLD_U32T(acc); - LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%"X32_F"\n", acc)); - return (u16_t)~(acc & 0xffffUL); -} - -/* inet_chksum_pseudo: - * - * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. - * IP addresses are expected to be in network byte order. - * - * @param p chain of pbufs over that a checksum should be calculated (ip data part) - * @param src source ip address (used for checksum of pseudo header) - * @param dst destination ip address (used for checksum of pseudo header) - * @param proto ip protocol (used for checksum of pseudo header) - * @param proto_len length of the ip data part (used for checksum of pseudo header) - * @return checksum (as u16_t) to be saved directly in the protocol header - */ -u16_t -inet_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, - ip_addr_t *src, ip_addr_t *dest) -{ - u32_t acc; - u32_t addr; - - addr = ip4_addr_get_u32(src); - acc = (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - addr = ip4_addr_get_u32(dest); - acc += (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - /* fold down to 16 bits */ - acc = FOLD_U32T(acc); - acc = FOLD_U32T(acc); - - return inet_cksum_pseudo_base(p, proto, proto_len, acc); -} -#if LWIP_IPV6 -/** - * Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. - * IPv6 addresses are expected to be in network byte order. - * - * @param p chain of pbufs over that a checksum should be calculated (ip data part) - * @param src source ipv6 address (used for checksum of pseudo header) - * @param dst destination ipv6 address (used for checksum of pseudo header) - * @param proto ipv6 protocol/next header (used for checksum of pseudo header) - * @param proto_len length of the ipv6 payload (used for checksum of pseudo header) - * @return checksum (as u16_t) to be saved directly in the protocol header - */ -u16_t -ip6_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, - ip6_addr_t *src, ip6_addr_t *dest) -{ - u32_t acc = 0; - u32_t addr; - u8_t addr_part; - - for (addr_part = 0; addr_part < 4; addr_part++) { - addr = src->addr[addr_part]; - acc += (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - addr = dest->addr[addr_part]; - acc += (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - } - /* fold down to 16 bits */ - acc = FOLD_U32T(acc); - acc = FOLD_U32T(acc); - - return inet_cksum_pseudo_base(p, proto, proto_len, acc); -} -#endif /* LWIP_IPV6 */ - -/** Parts of the pseudo checksum which are common to IPv4 and IPv6 */ -static u16_t -inet_cksum_pseudo_partial_base(struct pbuf *p, u8_t proto, u16_t proto_len, - u16_t chksum_len, u32_t acc) -{ - struct pbuf *q; - u8_t swapped = 0; - u16_t chklen; - - /* iterate through all pbuf in chain */ - for(q = p; (q != NULL) && (chksum_len > 0); q = q->next) { - LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n", - (void *)q, (void *)q->next)); - chklen = q->len; - if (chklen > chksum_len) { - chklen = chksum_len; - } - acc += LWIP_CHKSUM(q->payload, chklen); - chksum_len -= chklen; - LWIP_ASSERT("delete me", chksum_len < 0x7fff); - /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/ - /* fold the upper bit down */ - acc = FOLD_U32T(acc); - if (q->len % 2 != 0) { - swapped = 1 - swapped; - acc = SWAP_BYTES_IN_WORD(acc); - } - /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%"X32_F" \n", acc));*/ - } - - if (swapped) { - acc = SWAP_BYTES_IN_WORD(acc); - } - - acc += (u32_t)htons((u16_t)proto); - acc += (u32_t)htons(proto_len); - - /* Fold 32-bit sum to 16 bits - calling this twice is propably faster than if statements... */ - acc = FOLD_U32T(acc); - acc = FOLD_U32T(acc); - LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%"X32_F"\n", acc)); - return (u16_t)~(acc & 0xffffUL); -} - -/* inet_chksum_pseudo_partial: - * - * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. - * IP addresses are expected to be in network byte order. - * - * @param p chain of pbufs over that a checksum should be calculated (ip data part) - * @param src source ip address (used for checksum of pseudo header) - * @param dst destination ip address (used for checksum of pseudo header) - * @param proto ip protocol (used for checksum of pseudo header) - * @param proto_len length of the ip data part (used for checksum of pseudo header) - * @return checksum (as u16_t) to be saved directly in the protocol header - */ -u16_t -inet_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, - u16_t chksum_len, ip_addr_t *src, ip_addr_t *dest) -{ - u32_t acc; - u32_t addr; - - addr = ip4_addr_get_u32(src); - acc = (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - addr = ip4_addr_get_u32(dest); - acc += (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - /* fold down to 16 bits */ - acc = FOLD_U32T(acc); - acc = FOLD_U32T(acc); - - return inet_cksum_pseudo_partial_base(p, proto, proto_len, chksum_len, acc); -} - -#if LWIP_IPV6 -/** - * Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. - * IPv6 addresses are expected to be in network byte order. Will only compute for a - * portion of the payload. - * - * @param p chain of pbufs over that a checksum should be calculated (ip data part) - * @param src source ipv6 address (used for checksum of pseudo header) - * @param dst destination ipv6 address (used for checksum of pseudo header) - * @param proto ipv6 protocol/next header (used for checksum of pseudo header) - * @param proto_len length of the ipv6 payload (used for checksum of pseudo header) - * @param chksum_len number of payload bytes used to compute chksum - * @return checksum (as u16_t) to be saved directly in the protocol header - */ -u16_t -ip6_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, - u16_t chksum_len, ip6_addr_t *src, ip6_addr_t *dest) -{ - u32_t acc = 0; - u32_t addr; - u8_t addr_part; - - for (addr_part = 0; addr_part < 4; addr_part++) { - addr = src->addr[addr_part]; - acc += (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - addr = dest->addr[addr_part]; - acc += (addr & 0xffffUL); - acc += ((addr >> 16) & 0xffffUL); - } - /* fold down to 16 bits */ - acc = FOLD_U32T(acc); - acc = FOLD_U32T(acc); - - return inet_cksum_pseudo_partial_base(p, proto, proto_len, chksum_len, acc); -} -#endif /* LWIP_IPV6 */ - -/* inet_chksum: - * - * Calculates the Internet checksum over a portion of memory. Used primarily for IP - * and ICMP. - * - * @param dataptr start of the buffer to calculate the checksum (no alignment needed) - * @param len length of the buffer to calculate the checksum - * @return checksum (as u16_t) to be saved directly in the protocol header - */ - -u16_t -inet_chksum(void *dataptr, u16_t len) -{ - return ~LWIP_CHKSUM(dataptr, len); -} - -/** - * Calculate a checksum over a chain of pbufs (without pseudo-header, much like - * inet_chksum only pbufs are used). - * - * @param p pbuf chain over that the checksum should be calculated - * @return checksum (as u16_t) to be saved directly in the protocol header - */ -u16_t -inet_chksum_pbuf(struct pbuf *p) -{ - u32_t acc; - struct pbuf *q; - u8_t swapped; - - acc = 0; - swapped = 0; - for(q = p; q != NULL; q = q->next) { - acc += LWIP_CHKSUM(q->payload, q->len); - acc = FOLD_U32T(acc); - if (q->len % 2 != 0) { - swapped = 1 - swapped; - acc = SWAP_BYTES_IN_WORD(acc); - } - } - - if (swapped) { - acc = SWAP_BYTES_IN_WORD(acc); - } - return (u16_t)~(acc & 0xffffUL); -} - -/* These are some implementations for LWIP_CHKSUM_COPY, which copies data - * like MEMCPY but generates a checksum at the same time. Since this is a - * performance-sensitive function, you might want to create your own version - * in assembly targeted at your hardware by defining it in lwipopts.h: - * #define LWIP_CHKSUM_COPY(dst, src, len) your_chksum_copy(dst, src, len) - */ - -#if (LWIP_CHKSUM_COPY_ALGORITHM == 1) /* Version #1 */ -/** Safe but slow: first call MEMCPY, then call LWIP_CHKSUM. - * For architectures with big caches, data might still be in cache when - * generating the checksum after copying. - */ -u16_t -lwip_chksum_copy(void *dst, const void *src, u16_t len) -{ - MEMCPY(dst, src, len); - return LWIP_CHKSUM(dst, len); -} -#endif /* (LWIP_CHKSUM_COPY_ALGORITHM == 1) */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/init.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/init.c deleted file mode 100644 index c24c0274..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/init.c +++ /dev/null @@ -1,345 +0,0 @@ -/** - * @file - * Modules initialization - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/init.h" -#include "lwip/stats.h" -#include "lwip/sys.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/pbuf.h" -#include "lwip/netif.h" -#include "lwip/sockets.h" -#include "lwip/ip.h" -#include "lwip/raw.h" -#include "lwip/udp.h" -#include "lwip/tcp_impl.h" -#include "lwip/snmp_msg.h" -#include "lwip/autoip.h" -#include "lwip/igmp.h" -#include "lwip/dns.h" -#include "lwip/timers.h" -#include "netif/etharp.h" -#include "lwip/ip6.h" -#include "lwip/nd6.h" -#include "lwip/mld6.h" -#include "lwip/api.h" - -/* Compile-time sanity checks for configuration errors. - * These can be done independently of LWIP_DEBUG, without penalty. - */ -#ifndef BYTE_ORDER - #error "BYTE_ORDER is not defined, you have to define it in your cc.h" -#endif -#if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV) - #error "If you want to use broadcast filter per pcb on recv operations, you have to define IP_SOF_BROADCAST=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_UDPLITE) - #error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_SNMP) - #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_DHCP) - #error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_IGMP) - #error "If you want to use IGMP, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_SNMP) - #error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if (!LWIP_UDP && LWIP_DNS) - #error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h" -#endif -#if !MEMP_MEM_MALLOC /* MEMP_NUM_* checks are disabled when not using the pool allocator */ -#if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0)) - #error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h" -#endif -#if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0)) - #error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h" -#endif -#if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0)) - #error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h" -#endif -#if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0)) - #error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h" -#endif -#if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1)) - #error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h" -#endif -#if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0)) - #error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h" -#endif -/* There must be sufficient timeouts, taking into account requirements of the subsystems. */ -#if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0))) - #error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts" -#endif -#if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS)) - #error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!" -#endif -#endif /* !MEMP_MEM_MALLOC */ -#if (LWIP_TCP && (TCP_WND > 0xffff)) - #error "If you want to use TCP, TCP_WND must fit in an u16_t, so, you have to reduce it in your lwipopts.h" -#endif -#if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff)) - #error "If you want to use TCP, TCP_SND_QUEUELEN must fit in an u16_t, so, you have to reduce it in your lwipopts.h" -#endif -#if (LWIP_TCP && (TCP_SND_QUEUELEN < 2)) - #error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work" -#endif -#if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12))) - #error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h" -#endif -#if (LWIP_TCP && TCP_LISTEN_BACKLOG && (TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff)) - #error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t" -#endif -#if (LWIP_NETIF_API && (NO_SYS==1)) - #error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h" -#endif -#if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1)) - #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h" -#endif -#if (!LWIP_NETCONN && LWIP_SOCKET) - #error "If you want to use Socket API, you have to define LWIP_NETCONN=1 in your lwipopts.h" -#endif -#if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP) - #error "If you want to use DHCP/AUTOIP cooperation mode, you have to define LWIP_DHCP=1 and LWIP_AUTOIP=1 in your lwipopts.h" -#endif -#if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK) - #error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h" -#endif -#if (!LWIP_ARP && LWIP_AUTOIP) - #error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h" -#endif -#if (LWIP_SNMP && (SNMP_CONCURRENT_REQUESTS<=0)) - #error "If you want to use SNMP, you have to define SNMP_CONCURRENT_REQUESTS>=1 in your lwipopts.h" -#endif -#if (LWIP_SNMP && (SNMP_TRAP_DESTINATIONS<=0)) - #error "If you want to use SNMP, you have to define SNMP_TRAP_DESTINATIONS>=1 in your lwipopts.h" -#endif -#if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API))) - #error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h" -#endif -#if (MEM_LIBC_MALLOC && MEM_USE_POOLS) - #error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h" -#endif -#if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS) - #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h" -#endif -#if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT) - #error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf" -#endif -#if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT))) - #error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST" -#endif -#if PPP_SUPPORT && !PPPOS_SUPPORT & !PPPOE_SUPPORT - #error "PPP_SUPPORT needs either PPPOS_SUPPORT or PPPOE_SUPPORT turned on" -#endif -#if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT) - #error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT" -#endif -#if (LWIP_IGMP || LWIP_IPV6) && !defined(LWIP_RAND) - #error "When using IGMP or IPv6, LWIP_RAND() needs to be defined to a random-function returning an u32_t random value" -#endif -#if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING - #error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too" -#endif -#if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE - #error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets" -#endif -#if IP_FRAG && IP_FRAG_USES_STATIC_BUF && LWIP_NETIF_TX_SINGLE_PBUF - #error "LWIP_NETIF_TX_SINGLE_PBUF does not work with IP_FRAG_USES_STATIC_BUF==1 as that creates pbuf queues" -#endif -#if LWIP_NETCONN && LWIP_TCP -#if NETCONN_COPY != TCP_WRITE_FLAG_COPY - #error "NETCONN_COPY != TCP_WRITE_FLAG_COPY" -#endif -#if NETCONN_MORE != TCP_WRITE_FLAG_MORE - #error "NETCONN_MORE != TCP_WRITE_FLAG_MORE" -#endif -#endif /* LWIP_NETCONN && LWIP_TCP */ -#if LWIP_SOCKET -/* Check that the SO_* socket options and SOF_* lwIP-internal flags match */ -#if SO_ACCEPTCONN != SOF_ACCEPTCONN - #error "SO_ACCEPTCONN != SOF_ACCEPTCONN" -#endif -#if SO_REUSEADDR != SOF_REUSEADDR - #error "WARNING: SO_REUSEADDR != SOF_REUSEADDR" -#endif -#if SO_KEEPALIVE != SOF_KEEPALIVE - #error "WARNING: SO_KEEPALIVE != SOF_KEEPALIVE" -#endif -#if SO_BROADCAST != SOF_BROADCAST - #error "WARNING: SO_BROADCAST != SOF_BROADCAST" -#endif -#if SO_LINGER != SOF_LINGER - #error "WARNING: SO_LINGER != SOF_LINGER" -#endif -#endif /* LWIP_SOCKET */ - - -/* Compile-time checks for deprecated options. - */ -#ifdef MEMP_NUM_TCPIP_MSG - #error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h." -#endif -#ifdef MEMP_NUM_API_MSG - #error "MEMP_NUM_API_MSG option is deprecated. Remove it from your lwipopts.h." -#endif -#ifdef TCP_REXMIT_DEBUG - #error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h." -#endif -#ifdef RAW_STATS - #error "RAW_STATS option is deprecated. Remove it from your lwipopts.h." -#endif -#ifdef ETHARP_QUEUE_FIRST - #error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h." -#endif -#ifdef ETHARP_ALWAYS_INSERT - #error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h." -#endif - -#ifndef LWIP_DISABLE_TCP_SANITY_CHECKS -#define LWIP_DISABLE_TCP_SANITY_CHECKS 0 -#endif -#ifndef LWIP_DISABLE_MEMP_SANITY_CHECKS -#define LWIP_DISABLE_MEMP_SANITY_CHECKS 0 -#endif - -/* MEMP sanity checks */ -#if !LWIP_DISABLE_MEMP_SANITY_CHECKS -#if LWIP_NETCONN -#if MEMP_MEM_MALLOC -#if !MEMP_NUM_NETCONN && LWIP_SOCKET -#error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN cannot be 0 when using sockets!" -#endif -#else /* MEMP_MEM_MALLOC */ -#if MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB) -#error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN should be less than the sum of MEMP_NUM_{TCP,RAW,UDP}_PCB+MEMP_NUM_TCP_PCB_LISTEN. If you know what you are doing, define LWIP_DISABLE_MEMP_SANITY_CHECKS to 1 to disable this error." -#endif -#endif /* MEMP_MEM_MALLOC */ -#endif /* LWIP_NETCONN */ -#endif /* !LWIP_DISABLE_MEMP_SANITY_CHECKS */ - -/* TCP sanity checks */ -#if !LWIP_DISABLE_TCP_SANITY_CHECKS -#if LWIP_TCP -#if !MEMP_MEM_MALLOC && (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN) - #error "lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if TCP_SND_BUF < (2 * TCP_MSS) - #error "lwip_sanity_check: WARNING: TCP_SND_BUF must be at least as much as (2 * TCP_MSS) for things to work smoothly. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF / TCP_MSS)) - #error "lwip_sanity_check: WARNING: TCP_SND_QUEUELEN must be at least as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if TCP_SNDLOWAT >= TCP_SND_BUF - #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than TCP_SND_BUF. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN - #error "lwip_sanity_check: WARNING: TCP_SNDQUEUELOWAT must be less than TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if !MEMP_MEM_MALLOC && (PBUF_POOL_BUFSIZE <= (PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) - #error "lwip_sanity_check: WARNING: PBUF_POOL_BUFSIZE does not provide enough space for protocol headers. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if !MEMP_MEM_MALLOC && (TCP_WND > (PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - (PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)))) - #error "lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - protocol headers). If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#if TCP_WND < TCP_MSS - #error "lwip_sanity_check: WARNING: TCP_WND is smaller than MSS. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." -#endif -#endif /* LWIP_TCP */ -#endif /* !LWIP_DISABLE_TCP_SANITY_CHECKS */ - -/** - * Perform Sanity check of user-configurable values, and initialize all modules. - */ -void -lwip_init(void) -{ - /* Modules initialization */ - stats_init(); -#if !NO_SYS - sys_init(); -#endif /* !NO_SYS */ - mem_init(); - memp_init(); - pbuf_init(); - netif_init(); -#if LWIP_SOCKET - lwip_socket_init(); -#endif /* LWIP_SOCKET */ - ip_init(); -#if LWIP_ARP - etharp_init(); -#endif /* LWIP_ARP */ -#if LWIP_RAW - raw_init(); -#endif /* LWIP_RAW */ -#if LWIP_UDP - udp_init(); -#endif /* LWIP_UDP */ -#if LWIP_TCP - tcp_init(); -#endif /* LWIP_TCP */ -#if LWIP_SNMP - snmp_init(); -#endif /* LWIP_SNMP */ -#if LWIP_AUTOIP - autoip_init(); -#endif /* LWIP_AUTOIP */ -#if LWIP_IGMP - igmp_init(); -#endif /* LWIP_IGMP */ -#if LWIP_DNS - dns_init(); -#endif /* LWIP_DNS */ -#if LWIP_IPV6 - ip6_init(); - nd6_init(); -#if LWIP_IPV6_MLD - mld6_init(); -#endif /* LWIP_IPV6_MLD */ -#endif /* LWIP_IPV6 */ - -#if LWIP_TIMERS - sys_timeouts_init(); -#endif /* LWIP_TIMERS */ -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/icmp.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/icmp.c deleted file mode 100644 index af471533..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/icmp.c +++ /dev/null @@ -1,338 +0,0 @@ -/** - * @file - * ICMP - Internet Control Message Protocol - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -/* Some ICMP messages should be passed to the transport protocols. This - is not implemented. */ - -#include "lwip/opt.h" - -#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/icmp.h" -#include "lwip/inet_chksum.h" -#include "lwip/ip.h" -#include "lwip/def.h" -#include "lwip/stats.h" -#include "lwip/snmp.h" - -#include - -/** Small optimization: set to 0 if incoming PBUF_POOL pbuf always can be - * used to modify and send a response packet (and to 1 if this is not the case, - * e.g. when link header is stripped of when receiving) */ -#ifndef LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN -#define LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN 1 -#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */ - -/* The amount of data from the original packet to return in a dest-unreachable */ -#define ICMP_DEST_UNREACH_DATASIZE 8 - -static void icmp_send_response(struct pbuf *p, u8_t type, u8_t code); - -/** - * Processes ICMP input packets, called from ip_input(). - * - * Currently only processes icmp echo requests and sends - * out the echo response. - * - * @param p the icmp echo request packet, p->payload pointing to the icmp header - * @param inp the netif on which this packet was received - */ -void -icmp_input(struct pbuf *p, struct netif *inp) -{ - u8_t type; -#ifdef LWIP_DEBUG - u8_t code; -#endif /* LWIP_DEBUG */ - struct icmp_echo_hdr *iecho; - struct ip_hdr *iphdr; - s16_t hlen; - - ICMP_STATS_INC(icmp.recv); - snmp_inc_icmpinmsgs(); - - iphdr = (struct ip_hdr *)ip_current_header(); - hlen = IPH_HL(iphdr) * 4; - if (p->len < sizeof(u16_t)*2) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%"U16_F" bytes) received\n", p->tot_len)); - goto lenerr; - } - - type = *((u8_t *)p->payload); -#ifdef LWIP_DEBUG - code = *(((u8_t *)p->payload)+1); -#endif /* LWIP_DEBUG */ - switch (type) { - case ICMP_ER: - /* This is OK, echo reply might have been parsed by a raw PCB - (as obviously, an echo request has been sent, too). */ - break; - case ICMP_ECHO: -#if !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING - { - int accepted = 1; -#if !LWIP_MULTICAST_PING - /* multicast destination address? */ - if (ip_addr_ismulticast(ip_current_dest_addr())) { - accepted = 0; - } -#endif /* LWIP_MULTICAST_PING */ -#if !LWIP_BROADCAST_PING - /* broadcast destination address? */ - if (ip_addr_isbroadcast(ip_current_dest_addr(), inp)) { - accepted = 0; - } -#endif /* LWIP_BROADCAST_PING */ - /* broadcast or multicast destination address not acceptd? */ - if (!accepted) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: Not echoing to multicast or broadcast pings\n")); - ICMP_STATS_INC(icmp.err); - pbuf_free(p); - return; - } - } -#endif /* !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING */ - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n")); - if (p->tot_len < sizeof(struct icmp_echo_hdr)) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); - goto lenerr; - } - if (inet_chksum_pbuf(p) != 0) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n")); - pbuf_free(p); - ICMP_STATS_INC(icmp.chkerr); - snmp_inc_icmpinerrors(); - return; - } -#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN - if (pbuf_header(p, (PBUF_IP_HLEN + PBUF_LINK_HLEN))) { - /* p is not big enough to contain link headers - * allocate a new one and copy p into it - */ - struct pbuf *r; - /* switch p->payload to ip header */ - if (pbuf_header(p, hlen)) { - LWIP_ASSERT("icmp_input: moving p->payload to ip header failed\n", 0); - goto memerr; - } - /* allocate new packet buffer with space for link headers */ - r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM); - if (r == NULL) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: allocating new pbuf failed\n")); - goto memerr; - } - LWIP_ASSERT("check that first pbuf can hold struct the ICMP header", - (r->len >= hlen + sizeof(struct icmp_echo_hdr))); - /* copy the whole packet including ip header */ - if (pbuf_copy(r, p) != ERR_OK) { - LWIP_ASSERT("icmp_input: copying to new pbuf failed\n", 0); - goto memerr; - } - iphdr = (struct ip_hdr *)r->payload; - /* switch r->payload back to icmp header */ - if (pbuf_header(r, -hlen)) { - LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0); - goto memerr; - } - /* free the original p */ - pbuf_free(p); - /* we now have an identical copy of p that has room for link headers */ - p = r; - } else { - /* restore p->payload to point to icmp header */ - if (pbuf_header(p, -(s16_t)(PBUF_IP_HLEN + PBUF_LINK_HLEN))) { - LWIP_ASSERT("icmp_input: restoring original p->payload failed\n", 0); - goto memerr; - } - } -#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */ - /* At this point, all checks are OK. */ - /* We generate an answer by switching the dest and src ip addresses, - * setting the icmp type to ECHO_RESPONSE and updating the checksum. */ - iecho = (struct icmp_echo_hdr *)p->payload; - ip_addr_copy(iphdr->src, *ip_current_dest_addr()); - ip_addr_copy(iphdr->dest, *ip_current_src_addr()); - ICMPH_TYPE_SET(iecho, ICMP_ER); -#if CHECKSUM_GEN_ICMP - /* adjust the checksum */ - if (iecho->chksum >= PP_HTONS(0xffffU - (ICMP_ECHO << 8))) { - iecho->chksum += PP_HTONS(ICMP_ECHO << 8) + 1; - } else { - iecho->chksum += PP_HTONS(ICMP_ECHO << 8); - } -#else /* CHECKSUM_GEN_ICMP */ - iecho->chksum = 0; -#endif /* CHECKSUM_GEN_ICMP */ - - /* Set the correct TTL and recalculate the header checksum. */ - IPH_TTL_SET(iphdr, ICMP_TTL); - IPH_CHKSUM_SET(iphdr, 0); -#if CHECKSUM_GEN_IP - IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); -#endif /* CHECKSUM_GEN_IP */ - - ICMP_STATS_INC(icmp.xmit); - /* increase number of messages attempted to send */ - snmp_inc_icmpoutmsgs(); - /* increase number of echo replies attempted to send */ - snmp_inc_icmpoutechoreps(); - - if(pbuf_header(p, hlen)) { - LWIP_ASSERT("Can't move over header in packet", 0); - } else { - err_t ret; - /* send an ICMP packet, src addr is the dest addr of the curren packet */ - ret = ip_output_if(p, ip_current_dest_addr(), IP_HDRINCL, - ICMP_TTL, 0, IP_PROTO_ICMP, inp); - if (ret != ERR_OK) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ip_output_if returned an error: %c.\n", ret)); - } - } - break; - default: - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n", - (s16_t)type, (s16_t)code)); - ICMP_STATS_INC(icmp.proterr); - ICMP_STATS_INC(icmp.drop); - } - pbuf_free(p); - return; -lenerr: - pbuf_free(p); - ICMP_STATS_INC(icmp.lenerr); - snmp_inc_icmpinerrors(); - return; -#if LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN -memerr: - pbuf_free(p); - ICMP_STATS_INC(icmp.err); - snmp_inc_icmpinerrors(); - return; -#endif /* LWIP_ICMP_ECHO_CHECK_INPUT_PBUF_LEN */ -} - -/** - * Send an icmp 'destination unreachable' packet, called from ip_input() if - * the transport layer protocol is unknown and from udp_input() if the local - * port is not bound. - * - * @param p the input packet for which the 'unreachable' should be sent, - * p->payload pointing to the IP header - * @param t type of the 'unreachable' packet - */ -void -icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t) -{ - icmp_send_response(p, ICMP_DUR, t); -} - -#if IP_FORWARD || IP_REASSEMBLY -/** - * Send a 'time exceeded' packet, called from ip_forward() if TTL is 0. - * - * @param p the input packet for which the 'time exceeded' should be sent, - * p->payload pointing to the IP header - * @param t type of the 'time exceeded' packet - */ -void -icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t) -{ - icmp_send_response(p, ICMP_TE, t); -} - -#endif /* IP_FORWARD || IP_REASSEMBLY */ - -/** - * Send an icmp packet in response to an incoming packet. - * - * @param p the input packet for which the 'unreachable' should be sent, - * p->payload pointing to the IP header - * @param type Type of the ICMP header - * @param code Code of the ICMP header - */ -static void -icmp_send_response(struct pbuf *p, u8_t type, u8_t code) -{ - struct pbuf *q; - struct ip_hdr *iphdr; - /* we can use the echo header here */ - struct icmp_echo_hdr *icmphdr; - ip_addr_t iphdr_src; - - /* ICMP header + IP header + 8 bytes of data */ - q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE, - PBUF_RAM); - if (q == NULL) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded: failed to allocate pbuf for ICMP packet.\n")); - return; - } - LWIP_ASSERT("check that first pbuf can hold icmp message", - (q->len >= (sizeof(struct icmp_echo_hdr) + IP_HLEN + ICMP_DEST_UNREACH_DATASIZE))); - - iphdr = (struct ip_hdr *)p->payload; - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from ")); - ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src)); - LWIP_DEBUGF(ICMP_DEBUG, (" to ")); - ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest)); - LWIP_DEBUGF(ICMP_DEBUG, ("\n")); - - icmphdr = (struct icmp_echo_hdr *)q->payload; - icmphdr->type = type; - icmphdr->code = code; - icmphdr->id = 0; - icmphdr->seqno = 0; - - /* copy fields from original packet */ - SMEMCPY((u8_t *)q->payload + sizeof(struct icmp_echo_hdr), (u8_t *)p->payload, - IP_HLEN + ICMP_DEST_UNREACH_DATASIZE); - - /* calculate checksum */ - icmphdr->chksum = 0; - icmphdr->chksum = inet_chksum(icmphdr, q->len); - ICMP_STATS_INC(icmp.xmit); - /* increase number of messages attempted to send */ - snmp_inc_icmpoutmsgs(); - /* increase number of destination unreachable messages attempted to send */ - snmp_inc_icmpouttimeexcds(); - ip_addr_copy(iphdr_src, iphdr->src); - ip_output(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP); - pbuf_free(q); -} - -#endif /* LWIP_ICMP */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/ip4.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/ip4.c deleted file mode 100644 index 2f76bdb5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/ip4.c +++ /dev/null @@ -1,924 +0,0 @@ -/** - * @file - * This is the IPv4 layer implementation for incoming and outgoing IP traffic. - * - * @see ip_frag.c - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" -#include "lwip/ip.h" -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/ip_frag.h" -#include "lwip/inet_chksum.h" -#include "lwip/netif.h" -#include "lwip/icmp.h" -#include "lwip/igmp.h" -#include "lwip/raw.h" -#include "lwip/udp.h" -#include "lwip/tcp_impl.h" -#include "lwip/snmp.h" -#include "lwip/dhcp.h" -#include "lwip/autoip.h" -#include "lwip/stats.h" -#include "arch/perf.h" - -#include - -/** Set this to 0 in the rare case of wanting to call an extra function to - * generate the IP checksum (in contrast to calculating it on-the-fly). */ -#ifndef LWIP_INLINE_IP_CHKSUM -#define LWIP_INLINE_IP_CHKSUM 1 -#endif -#if LWIP_INLINE_IP_CHKSUM && CHECKSUM_GEN_IP -#define CHECKSUM_GEN_IP_INLINE 1 -#else -#define CHECKSUM_GEN_IP_INLINE 0 -#endif - -#if LWIP_DHCP || defined(LWIP_IP_ACCEPT_UDP_PORT) -#define IP_ACCEPT_LINK_LAYER_ADDRESSING 1 - -/** Some defines for DHCP to let link-layer-addressed packets through while the - * netif is down. - * To use this in your own application/protocol, define LWIP_IP_ACCEPT_UDP_PORT - * to return 1 if the port is accepted and 0 if the port is not accepted. - */ -#if LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) -/* accept DHCP client port and custom port */ -#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (((port) == PP_NTOHS(DHCP_CLIENT_PORT)) \ - || (LWIP_IP_ACCEPT_UDP_PORT(port))) -#elif defined(LWIP_IP_ACCEPT_UDP_PORT) /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */ -/* accept custom port only */ -#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) (LWIP_IP_ACCEPT_UDP_PORT(port)) -#else /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */ -/* accept DHCP client port only */ -#define IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(port) ((port) == PP_NTOHS(DHCP_CLIENT_PORT)) -#endif /* LWIP_DHCP && defined(LWIP_IP_ACCEPT_UDP_PORT) */ - -#else /* LWIP_DHCP */ -#define IP_ACCEPT_LINK_LAYER_ADDRESSING 0 -#endif /* LWIP_DHCP */ - -/** Global data for both IPv4 and IPv6 */ -struct ip_globals ip_data; - -/** The IP header ID of the next outgoing IP packet */ -static u16_t ip_id; - -/** - * Finds the appropriate network interface for a given IP address. It - * searches the list of network interfaces linearly. A match is found - * if the masked IP address of the network interface equals the masked - * IP address given to the function. - * - * @param dest the destination IP address for which to find the route - * @return the netif on which to send to reach dest - */ -struct netif * -ip_route(ip_addr_t *dest) -{ - struct netif *netif; - -#ifdef LWIP_HOOK_IP4_ROUTE - netif = LWIP_HOOK_IP4_ROUTE(dest); - if (netif != NULL) { - return netif; - } -#endif - - /* iterate through netifs */ - for (netif = netif_list; netif != NULL; netif = netif->next) { - /* network mask matches? */ - if (netif_is_up(netif)) { - if (ip_addr_netcmp(dest, &(netif->ip_addr), &(netif->netmask))) { - /* return netif on which to forward IP packet */ - return netif; - } - } - } - if ((netif_default == NULL) || (!netif_is_up(netif_default))) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_route: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest))); - IP_STATS_INC(ip.rterr); - snmp_inc_ipoutnoroutes(); - return NULL; - } - /* no matching netif found, use default netif */ - return netif_default; -} - -#if IP_FORWARD -/** - * Determine whether an IP address is in a reserved set of addresses - * that may not be forwarded, or whether datagrams to that destination - * may be forwarded. - * @param p the packet to forward - * @param dest the destination IP address - * @return 1: can forward 0: discard - */ -static int -ip_canforward(struct pbuf *p) -{ - u32_t addr = htonl(ip4_addr_get_u32(ip_current_dest_addr())); - - if (p->flags & PBUF_FLAG_LLBCAST) { - /* don't route link-layer broadcasts */ - return 0; - } - if ((p->flags & PBUF_FLAG_LLMCAST) && !IP_MULTICAST(addr)) { - /* don't route link-layer multicasts unless the destination address is an IP - multicast address */ - return 0; - } - if (IP_EXPERIMENTAL(addr)) { - return 0; - } - if (IP_CLASSA(addr)) { - u32_t net = addr & IP_CLASSA_NET; - if ((net == 0) || (net == ((u32_t)IP_LOOPBACKNET << IP_CLASSA_NSHIFT))) { - /* don't route loopback packets */ - return 0; - } - } - return 1; -} - -/** - * Forwards an IP packet. It finds an appropriate route for the - * packet, decrements the TTL value of the packet, adjusts the - * checksum and outputs the packet on the appropriate interface. - * - * @param p the packet to forward (p->payload points to IP header) - * @param iphdr the IP header of the input packet - * @param inp the netif on which this packet was received - */ -static void -ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) -{ - struct netif *netif; - - PERF_START; - - if (!ip_canforward(p)) { - goto return_noroute; - } - - /* RFC3927 2.7: do not forward link-local addresses */ - if (ip_addr_islinklocal(ip_current_dest_addr())) { - LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not forwarding LLA %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(ip_current_dest_addr()), ip4_addr2_16(ip_current_dest_addr()), - ip4_addr3_16(ip_current_dest_addr()), ip4_addr4_16(ip_current_dest_addr()))); - goto return_noroute; - } - - /* Find network interface where to forward this IP packet to. */ - netif = ip_route(ip_current_dest_addr()); - if (netif == NULL) { - LWIP_DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for %"U16_F".%"U16_F".%"U16_F".%"U16_F" found\n", - ip4_addr1_16(ip_current_dest_addr()), ip4_addr2_16(ip_current_dest_addr()), - ip4_addr3_16(ip_current_dest_addr()), ip4_addr4_16(ip_current_dest_addr()))); - /* @todo: send ICMP_DUR_NET? */ - goto return_noroute; - } -#if !IP_FORWARD_ALLOW_TX_ON_RX_NETIF - /* Do not forward packets onto the same network interface on which - * they arrived. */ - if (netif == inp) { - LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n")); - goto return_noroute; - } -#endif /* IP_FORWARD_ALLOW_TX_ON_RX_NETIF */ - - /* decrement TTL */ - IPH_TTL_SET(iphdr, IPH_TTL(iphdr) - 1); - /* send ICMP if TTL == 0 */ - if (IPH_TTL(iphdr) == 0) { - snmp_inc_ipinhdrerrors(); -#if LWIP_ICMP - /* Don't send ICMP messages in response to ICMP messages */ - if (IPH_PROTO(iphdr) != IP_PROTO_ICMP) { - icmp_time_exceeded(p, ICMP_TE_TTL); - } -#endif /* LWIP_ICMP */ - return; - } - - /* Incrementally update the IP checksum. */ - if (IPH_CHKSUM(iphdr) >= PP_HTONS(0xffffU - 0x100)) { - IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + PP_HTONS(0x100) + 1); - } else { - IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + PP_HTONS(0x100)); - } - - LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(ip_current_dest_addr()), ip4_addr2_16(ip_current_dest_addr()), - ip4_addr3_16(ip_current_dest_addr()), ip4_addr4_16(ip_current_dest_addr()))); - - IP_STATS_INC(ip.fw); - IP_STATS_INC(ip.xmit); - snmp_inc_ipforwdatagrams(); - - PERF_STOP("ip_forward"); - /* don't fragment if interface has mtu set to 0 [loopif] */ - if (netif->mtu && (p->tot_len > netif->mtu)) { - if ((IPH_OFFSET(iphdr) & PP_NTOHS(IP_DF)) == 0) { -#if IP_FRAG - ip_frag(p, netif, ip_current_dest_addr()); -#else /* IP_FRAG */ - /* @todo: send ICMP Destination Unreacheable code 13 "Communication administratively prohibited"? */ -#endif /* IP_FRAG */ - } else { - /* send ICMP Destination Unreacheable code 4: "Fragmentation Needed and DF Set" */ - icmp_dest_unreach(p, ICMP_DUR_FRAG); - } - return; - } - /* transmit pbuf on chosen interface */ - netif->output(netif, p, ip_current_dest_addr()); - return; -return_noroute: - snmp_inc_ipoutnoroutes(); -} -#endif /* IP_FORWARD */ - -/** - * This function is called by the network interface device driver when - * an IP packet is received. The function does the basic checks of the - * IP header such as packet size being at least larger than the header - * size etc. If the packet was not destined for us, the packet is - * forwarded (using ip_forward). The IP checksum is always checked. - * - * Finally, the packet is sent to the upper layer protocol input function. - * - * @param p the received IP packet (p->payload points to IP header) - * @param inp the netif on which this packet was received - * @return ERR_OK if the packet was processed (could return ERR_* if it wasn't - * processed, but currently always returns ERR_OK) - */ -err_t -ip_input(struct pbuf *p, struct netif *inp) -{ - struct ip_hdr *iphdr; - struct netif *netif; - u16_t iphdr_hlen; - u16_t iphdr_len; -#if IP_ACCEPT_LINK_LAYER_ADDRESSING - int check_ip_src=1; -#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ - - IP_STATS_INC(ip.recv); - snmp_inc_ipinreceives(); - - /* identify the IP header */ - iphdr = (struct ip_hdr *)p->payload; - if (IPH_V(iphdr) != 4) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_WARNING, ("IP packet dropped due to bad version number %"U16_F"\n", IPH_V(iphdr))); - ip_debug_print(p); - pbuf_free(p); - IP_STATS_INC(ip.err); - IP_STATS_INC(ip.drop); - snmp_inc_ipinhdrerrors(); - return ERR_OK; - } - -#ifdef LWIP_HOOK_IP4_INPUT - if (LWIP_HOOK_IP4_INPUT(p, inp)) { - /* the packet has been eaten */ - return ERR_OK; - } -#endif - - /* obtain IP header length in number of 32-bit words */ - iphdr_hlen = IPH_HL(iphdr); - /* calculate IP header length in bytes */ - iphdr_hlen *= 4; - /* obtain ip length in bytes */ - iphdr_len = ntohs(IPH_LEN(iphdr)); - - /* header length exceeds first pbuf length, or ip length exceeds total pbuf length? */ - if ((iphdr_hlen > p->len) || (iphdr_len > p->tot_len)) { - if (iphdr_hlen > p->len) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("IP header (len %"U16_F") does not fit in first pbuf (len %"U16_F"), IP packet dropped.\n", - iphdr_hlen, p->len)); - } - if (iphdr_len > p->tot_len) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("IP (len %"U16_F") is longer than pbuf (len %"U16_F"), IP packet dropped.\n", - iphdr_len, p->tot_len)); - } - /* free (drop) packet pbufs */ - pbuf_free(p); - IP_STATS_INC(ip.lenerr); - IP_STATS_INC(ip.drop); - snmp_inc_ipindiscards(); - return ERR_OK; - } - - /* verify checksum */ -#if CHECKSUM_CHECK_IP - if (inet_chksum(iphdr, iphdr_hlen) != 0) { - - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("Checksum (0x%"X16_F") failed, IP packet dropped.\n", inet_chksum(iphdr, iphdr_hlen))); - ip_debug_print(p); - pbuf_free(p); - IP_STATS_INC(ip.chkerr); - IP_STATS_INC(ip.drop); - snmp_inc_ipinhdrerrors(); - return ERR_OK; - } -#endif - - /* Trim pbuf. This should have been done at the netif layer, - * but we'll do it anyway just to be sure that its done. */ - pbuf_realloc(p, iphdr_len); - - /* copy IP addresses to aligned ip_addr_t */ - ip_addr_copy(*ipX_2_ip(&ip_data.current_iphdr_dest), iphdr->dest); - ip_addr_copy(*ipX_2_ip(&ip_data.current_iphdr_src), iphdr->src); - - /* match packet against an interface, i.e. is this packet for us? */ -#if LWIP_IGMP - if (ip_addr_ismulticast(ip_current_dest_addr())) { - if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group(inp, ip_current_dest_addr()))) { - netif = inp; - } else { - netif = NULL; - } - } else -#endif /* LWIP_IGMP */ - { - /* start trying with inp. if that's not acceptable, start walking the - list of configured netifs. - 'first' is used as a boolean to mark whether we started walking the list */ - int first = 1; - netif = inp; - do { - LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%"X32_F" netif->ip_addr 0x%"X32_F" (0x%"X32_F", 0x%"X32_F", 0x%"X32_F")\n", - ip4_addr_get_u32(&iphdr->dest), ip4_addr_get_u32(&netif->ip_addr), - ip4_addr_get_u32(&iphdr->dest) & ip4_addr_get_u32(&netif->netmask), - ip4_addr_get_u32(&netif->ip_addr) & ip4_addr_get_u32(&netif->netmask), - ip4_addr_get_u32(&iphdr->dest) & ~ip4_addr_get_u32(&netif->netmask))); - - /* interface is up and configured? */ - if ((netif_is_up(netif)) && (!ip_addr_isany(&(netif->ip_addr)))) { - /* unicast to this interface address? */ - if (ip_addr_cmp(ip_current_dest_addr(), &(netif->ip_addr)) || - /* or broadcast on this interface network address? */ - ip_addr_isbroadcast(ip_current_dest_addr(), netif)) { - LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n", - netif->name[0], netif->name[1])); - /* break out of for loop */ - break; - } -#if LWIP_AUTOIP - /* connections to link-local addresses must persist after changing - the netif's address (RFC3927 ch. 1.9) */ - if ((netif->autoip != NULL) && - ip_addr_cmp(ip_current_dest_addr(), &(netif->autoip->llipaddr))) { - LWIP_DEBUGF(IP_DEBUG, ("ip_input: LLA packet accepted on interface %c%c\n", - netif->name[0], netif->name[1])); - /* break out of for loop */ - break; - } -#endif /* LWIP_AUTOIP */ - } - if (first) { - first = 0; - netif = netif_list; - } else { - netif = netif->next; - } - if (netif == inp) { - netif = netif->next; - } - } while(netif != NULL); - } - -#if IP_ACCEPT_LINK_LAYER_ADDRESSING - /* Pass DHCP messages regardless of destination address. DHCP traffic is addressed - * using link layer addressing (such as Ethernet MAC) so we must not filter on IP. - * According to RFC 1542 section 3.1.1, referred by RFC 2131). - * - * If you want to accept private broadcast communication while a netif is down, - * define LWIP_IP_ACCEPT_UDP_PORT(dst_port), e.g.: - * - * #define LWIP_IP_ACCEPT_UDP_PORT(dst_port) ((dst_port) == PP_NTOHS(12345)) - */ - if (netif == NULL) { - /* remote port is DHCP server? */ - if (IPH_PROTO(iphdr) == IP_PROTO_UDP) { - struct udp_hdr *udphdr = (struct udp_hdr *)((u8_t *)iphdr + iphdr_hlen); - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: UDP packet to DHCP client port %"U16_F"\n", - ntohs(udphdr->dest))); - if (IP_ACCEPT_LINK_LAYER_ADDRESSED_PORT(udphdr->dest)) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: DHCP packet accepted.\n")); - netif = inp; - check_ip_src = 0; - } - } - } -#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ - - /* broadcast or multicast packet source address? Compliant with RFC 1122: 3.2.1.3 */ -#if IP_ACCEPT_LINK_LAYER_ADDRESSING - /* DHCP servers need 0.0.0.0 to be allowed as source address (RFC 1.1.2.2: 3.2.1.3/a) */ - if (check_ip_src && !ip_addr_isany(ip_current_src_addr())) -#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ - { if ((ip_addr_isbroadcast(ip_current_src_addr(), inp)) || - (ip_addr_ismulticast(ip_current_src_addr()))) { - /* packet source is not valid */ - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("ip_input: packet source is not valid.\n")); - /* free (drop) packet pbufs */ - pbuf_free(p); - IP_STATS_INC(ip.drop); - snmp_inc_ipinaddrerrors(); - snmp_inc_ipindiscards(); - return ERR_OK; - } - } - - /* if we're pretending we are everyone for TCP, assume the packet is for source interface if it - isn't for a local address */ - if (netif == NULL && (inp->flags & NETIF_FLAG_PRETEND_TCP) && IPH_PROTO(iphdr) == IP_PROTO_TCP) { - netif = inp; - } - - /* packet not for us? */ - if (netif == NULL) { - /* packet not for us, route or discard */ - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip_input: packet not for us.\n")); -#if IP_FORWARD - /* non-broadcast packet? */ - if (!ip_addr_isbroadcast(ip_current_dest_addr(), inp)) { - /* try to forward IP packet on (other) interfaces */ - ip_forward(p, iphdr, inp); - } else -#endif /* IP_FORWARD */ - { - snmp_inc_ipinaddrerrors(); - snmp_inc_ipindiscards(); - } - pbuf_free(p); - return ERR_OK; - } - /* packet consists of multiple fragments? */ - if ((IPH_OFFSET(iphdr) & PP_HTONS(IP_OFFMASK | IP_MF)) != 0) { -#if IP_REASSEMBLY /* packet fragment reassembly code present? */ - LWIP_DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04"X16_F" tot_len=%"U16_F" len=%"U16_F" MF=%"U16_F" offset=%"U16_F"), calling ip_reass()\n", - ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), !!(IPH_OFFSET(iphdr) & PP_HTONS(IP_MF)), (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8)); - /* reassemble the packet*/ - p = ip_reass(p); - /* packet not fully reassembled yet? */ - if (p == NULL) { - return ERR_OK; - } - iphdr = (struct ip_hdr *)p->payload; -#else /* IP_REASSEMBLY == 0, no packet fragment reassembly code present */ - pbuf_free(p); - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("IP packet dropped since it was fragmented (0x%"X16_F") (while IP_REASSEMBLY == 0).\n", - ntohs(IPH_OFFSET(iphdr)))); - IP_STATS_INC(ip.opterr); - IP_STATS_INC(ip.drop); - /* unsupported protocol feature */ - snmp_inc_ipinunknownprotos(); - return ERR_OK; -#endif /* IP_REASSEMBLY */ - } - -#if IP_OPTIONS_ALLOWED == 0 /* no support for IP options in the IP header? */ - -#if LWIP_IGMP - /* there is an extra "router alert" option in IGMP messages which we allow for but do not police */ - if((iphdr_hlen > IP_HLEN) && (IPH_PROTO(iphdr) != IP_PROTO_IGMP)) { -#else - if (iphdr_hlen > IP_HLEN) { -#endif /* LWIP_IGMP */ - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("IP packet dropped since there were IP options (while IP_OPTIONS_ALLOWED == 0).\n")); - pbuf_free(p); - IP_STATS_INC(ip.opterr); - IP_STATS_INC(ip.drop); - /* unsupported protocol feature */ - snmp_inc_ipinunknownprotos(); - return ERR_OK; - } -#endif /* IP_OPTIONS_ALLOWED == 0 */ - - /* send to upper layers */ - LWIP_DEBUGF(IP_DEBUG, ("ip_input: \n")); - ip_debug_print(p); - LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len)); - - ip_data.current_netif = inp; - ip_data.current_ip4_header = iphdr; - ip_data.current_ip_header_tot_len = IPH_HL(iphdr) * 4; - -#if LWIP_RAW - /* raw input did not eat the packet? */ - if (raw_input(p, inp) == 0) -#endif /* LWIP_RAW */ - { - pbuf_header(p, -iphdr_hlen); /* Move to payload, no check necessary. */ - - switch (IPH_PROTO(iphdr)) { -#if LWIP_UDP - case IP_PROTO_UDP: -#if LWIP_UDPLITE - case IP_PROTO_UDPLITE: -#endif /* LWIP_UDPLITE */ - snmp_inc_ipindelivers(); - udp_input(p, inp); - break; -#endif /* LWIP_UDP */ -#if LWIP_TCP - case IP_PROTO_TCP: - snmp_inc_ipindelivers(); - tcp_input(p, inp); - break; -#endif /* LWIP_TCP */ -#if LWIP_ICMP - case IP_PROTO_ICMP: - snmp_inc_ipindelivers(); - icmp_input(p, inp); - break; -#endif /* LWIP_ICMP */ -#if LWIP_IGMP - case IP_PROTO_IGMP: - igmp_input(p, inp, ip_current_dest_addr()); - break; -#endif /* LWIP_IGMP */ - default: -#if LWIP_ICMP - /* send ICMP destination protocol unreachable unless is was a broadcast */ - if (!ip_addr_isbroadcast(ip_current_dest_addr(), inp) && - !ip_addr_ismulticast(ip_current_dest_addr())) { - pbuf_header(p, iphdr_hlen); /* Move to ip header, no check necessary. */ - p->payload = iphdr; - icmp_dest_unreach(p, ICMP_DUR_PROTO); - } -#endif /* LWIP_ICMP */ - pbuf_free(p); - - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("Unsupported transport protocol %"U16_F"\n", IPH_PROTO(iphdr))); - - IP_STATS_INC(ip.proterr); - IP_STATS_INC(ip.drop); - snmp_inc_ipinunknownprotos(); - } - } - - /* @todo: this is not really necessary... */ - ip_data.current_netif = NULL; - ip_data.current_ip4_header = NULL; - ip_data.current_ip_header_tot_len = 0; - ip_addr_set_any(ip_current_src_addr()); - ip_addr_set_any(ip_current_dest_addr()); - - return ERR_OK; -} - -/** - * Sends an IP packet on a network interface. This function constructs - * the IP header and calculates the IP header checksum. If the source - * IP address is NULL, the IP address of the outgoing network - * interface is filled in as source address. - * If the destination IP address is IP_HDRINCL, p is assumed to already - * include an IP header and p->payload points to it instead of the data. - * - * @param p the packet to send (p->payload points to the data, e.g. next - protocol header; if dest == IP_HDRINCL, p already includes an IP - header and p->payload points to that IP header) - * @param src the source IP address to send from (if src == IP_ADDR_ANY, the - * IP address of the netif used to send is used as source address) - * @param dest the destination IP address to send the packet to - * @param ttl the TTL value to be set in the IP header - * @param tos the TOS value to be set in the IP header - * @param proto the PROTOCOL to be set in the IP header - * @param netif the netif on which to send this packet - * @return ERR_OK if the packet was sent OK - * ERR_BUF if p doesn't have enough space for IP/LINK headers - * returns errors returned by netif->output - * - * @note ip_id: RFC791 "some host may be able to simply use - * unique identifiers independent of destination" - */ -err_t -ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, - u8_t proto, struct netif *netif) -{ -#if IP_OPTIONS_SEND - return ip_output_if_opt(p, src, dest, ttl, tos, proto, netif, NULL, 0); -} - -/** - * Same as ip_output_if() but with the possibility to include IP options: - * - * @ param ip_options pointer to the IP options, copied into the IP header - * @ param optlen length of ip_options - */ -err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options, - u16_t optlen) -{ -#endif /* IP_OPTIONS_SEND */ - struct ip_hdr *iphdr; - ip_addr_t dest_addr; -#if CHECKSUM_GEN_IP_INLINE - u32_t chk_sum = 0; -#endif /* CHECKSUM_GEN_IP_INLINE */ - - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); - - snmp_inc_ipoutrequests(); - - /* Should the IP header be generated or is it already included in p? */ - if (dest != IP_HDRINCL) { - u16_t ip_hlen = IP_HLEN; -#if IP_OPTIONS_SEND - u16_t optlen_aligned = 0; - if (optlen != 0) { -#if CHECKSUM_GEN_IP_INLINE - int i; -#endif /* CHECKSUM_GEN_IP_INLINE */ - /* round up to a multiple of 4 */ - optlen_aligned = ((optlen + 3) & ~3); - ip_hlen += optlen_aligned; - /* First write in the IP options */ - if (pbuf_header(p, optlen_aligned)) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_output_if_opt: not enough room for IP options in pbuf\n")); - IP_STATS_INC(ip.err); - snmp_inc_ipoutdiscards(); - return ERR_BUF; - } - MEMCPY(p->payload, ip_options, optlen); - if (optlen < optlen_aligned) { - /* zero the remaining bytes */ - memset(((char*)p->payload) + optlen, 0, optlen_aligned - optlen); - } -#if CHECKSUM_GEN_IP_INLINE - for (i = 0; i < optlen_aligned/2; i++) { - chk_sum += ((u16_t*)p->payload)[i]; - } -#endif /* CHECKSUM_GEN_IP_INLINE */ - } -#endif /* IP_OPTIONS_SEND */ - /* generate IP header */ - if (pbuf_header(p, IP_HLEN)) { - LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip_output: not enough room for IP header in pbuf\n")); - - IP_STATS_INC(ip.err); - snmp_inc_ipoutdiscards(); - return ERR_BUF; - } - - iphdr = (struct ip_hdr *)p->payload; - LWIP_ASSERT("check that first pbuf can hold struct ip_hdr", - (p->len >= sizeof(struct ip_hdr))); - - IPH_TTL_SET(iphdr, ttl); - IPH_PROTO_SET(iphdr, proto); -#if CHECKSUM_GEN_IP_INLINE - chk_sum += LWIP_MAKE_U16(proto, ttl); -#endif /* CHECKSUM_GEN_IP_INLINE */ - - /* dest cannot be NULL here */ - ip_addr_copy(iphdr->dest, *dest); -#if CHECKSUM_GEN_IP_INLINE - chk_sum += ip4_addr_get_u32(&iphdr->dest) & 0xFFFF; - chk_sum += ip4_addr_get_u32(&iphdr->dest) >> 16; -#endif /* CHECKSUM_GEN_IP_INLINE */ - - IPH_VHL_SET(iphdr, 4, ip_hlen / 4); - IPH_TOS_SET(iphdr, tos); -#if CHECKSUM_GEN_IP_INLINE - chk_sum += LWIP_MAKE_U16(tos, iphdr->_v_hl); -#endif /* CHECKSUM_GEN_IP_INLINE */ - IPH_LEN_SET(iphdr, htons(p->tot_len)); -#if CHECKSUM_GEN_IP_INLINE - chk_sum += iphdr->_len; -#endif /* CHECKSUM_GEN_IP_INLINE */ - IPH_OFFSET_SET(iphdr, (u16_t)(0 | (IP_DF << 4))); - IPH_ID_SET(iphdr, htons(ip_id)); -#if CHECKSUM_GEN_IP_INLINE - chk_sum += iphdr->_id; -#endif /* CHECKSUM_GEN_IP_INLINE */ - ++ip_id; - - if (ip_addr_isany(src)) { - ip_addr_copy(iphdr->src, netif->ip_addr); - } else { - /* src cannot be NULL here */ - ip_addr_copy(iphdr->src, *src); - } - -#if CHECKSUM_GEN_IP_INLINE - chk_sum += ip4_addr_get_u32(&iphdr->src) & 0xFFFF; - chk_sum += ip4_addr_get_u32(&iphdr->src) >> 16; - chk_sum = (chk_sum >> 16) + (chk_sum & 0xFFFF); - chk_sum = (chk_sum >> 16) + chk_sum; - chk_sum = ~chk_sum; - iphdr->_chksum = chk_sum; /* network order */ -#else /* CHECKSUM_GEN_IP_INLINE */ - IPH_CHKSUM_SET(iphdr, 0); -#if CHECKSUM_GEN_IP - IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, ip_hlen)); -#endif -#endif /* CHECKSUM_GEN_IP_INLINE */ - } else { - /* IP header already included in p */ - iphdr = (struct ip_hdr *)p->payload; - ip_addr_copy(dest_addr, iphdr->dest); - dest = &dest_addr; - } - - IP_STATS_INC(ip.xmit); - - LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%"U16_F"\n", netif->name[0], netif->name[1], netif->num)); - ip_debug_print(p); - -#if ENABLE_LOOPBACK - if (ip_addr_cmp(dest, &netif->ip_addr)) { - /* Packet to self, enqueue it for loopback */ - LWIP_DEBUGF(IP_DEBUG, ("netif_loop_output()")); - return netif_loop_output(netif, p, dest); - } -#if LWIP_IGMP - if ((p->flags & PBUF_FLAG_MCASTLOOP) != 0) { - netif_loop_output(netif, p, dest); - } -#endif /* LWIP_IGMP */ -#endif /* ENABLE_LOOPBACK */ -#if IP_FRAG - /* don't fragment if interface has mtu set to 0 [loopif] */ - if (netif->mtu && (p->tot_len > netif->mtu)) { - return ip_frag(p, netif, dest); - } -#endif /* IP_FRAG */ - - LWIP_DEBUGF(IP_DEBUG, ("netif->output()")); - return netif->output(netif, p, dest); -} - -/** - * Simple interface to ip_output_if. It finds the outgoing network - * interface and calls upon ip_output_if to do the actual work. - * - * @param p the packet to send (p->payload points to the data, e.g. next - protocol header; if dest == IP_HDRINCL, p already includes an IP - header and p->payload points to that IP header) - * @param src the source IP address to send from (if src == IP_ADDR_ANY, the - * IP address of the netif used to send is used as source address) - * @param dest the destination IP address to send the packet to - * @param ttl the TTL value to be set in the IP header - * @param tos the TOS value to be set in the IP header - * @param proto the PROTOCOL to be set in the IP header - * - * @return ERR_RTE if no route is found - * see ip_output_if() for more return values - */ -err_t -ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto) -{ - struct netif *netif; - - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); - - if ((netif = ip_route(dest)) == NULL) { - LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest))); - IP_STATS_INC(ip.rterr); - return ERR_RTE; - } - - return ip_output_if(p, src, dest, ttl, tos, proto, netif); -} - -#if LWIP_NETIF_HWADDRHINT -/** Like ip_output, but takes and addr_hint pointer that is passed on to netif->addr_hint - * before calling ip_output_if. - * - * @param p the packet to send (p->payload points to the data, e.g. next - protocol header; if dest == IP_HDRINCL, p already includes an IP - header and p->payload points to that IP header) - * @param src the source IP address to send from (if src == IP_ADDR_ANY, the - * IP address of the netif used to send is used as source address) - * @param dest the destination IP address to send the packet to - * @param ttl the TTL value to be set in the IP header - * @param tos the TOS value to be set in the IP header - * @param proto the PROTOCOL to be set in the IP header - * @param addr_hint address hint pointer set to netif->addr_hint before - * calling ip_output_if() - * - * @return ERR_RTE if no route is found - * see ip_output_if() for more return values - */ -err_t -ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint) -{ - struct netif *netif; - err_t err; - - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); - - if ((netif = ip_route(dest)) == NULL) { - LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest))); - IP_STATS_INC(ip.rterr); - return ERR_RTE; - } - - NETIF_SET_HWADDRHINT(netif, addr_hint); - err = ip_output_if(p, src, dest, ttl, tos, proto, netif); - NETIF_SET_HWADDRHINT(netif, NULL); - - return err; -} -#endif /* LWIP_NETIF_HWADDRHINT*/ - -#if IP_DEBUG -/* Print an IP header by using LWIP_DEBUGF - * @param p an IP packet, p->payload pointing to the IP header - */ -void -ip_debug_print(struct pbuf *p) -{ - struct ip_hdr *iphdr = (struct ip_hdr *)p->payload; - - LWIP_DEBUGF(IP_DEBUG, ("IP header:\n")); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("|%2"S16_F" |%2"S16_F" | 0x%02"X16_F" | %5"U16_F" | (v, hl, tos, len)\n", - IPH_V(iphdr), - IPH_HL(iphdr), - IPH_TOS(iphdr), - ntohs(IPH_LEN(iphdr)))); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %5"U16_F" |%"U16_F"%"U16_F"%"U16_F"| %4"U16_F" | (id, flags, offset)\n", - ntohs(IPH_ID(iphdr)), - ntohs(IPH_OFFSET(iphdr)) >> 15 & 1, - ntohs(IPH_OFFSET(iphdr)) >> 14 & 1, - ntohs(IPH_OFFSET(iphdr)) >> 13 & 1, - ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | 0x%04"X16_F" | (ttl, proto, chksum)\n", - IPH_TTL(iphdr), - IPH_PROTO(iphdr), - ntohs(IPH_CHKSUM(iphdr)))); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | %3"U16_F" | %3"U16_F" | (src)\n", - ip4_addr1_16(&iphdr->src), - ip4_addr2_16(&iphdr->src), - ip4_addr3_16(&iphdr->src), - ip4_addr4_16(&iphdr->src))); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP_DEBUG, ("| %3"U16_F" | %3"U16_F" | %3"U16_F" | %3"U16_F" | (dest)\n", - ip4_addr1_16(&iphdr->dest), - ip4_addr2_16(&iphdr->dest), - ip4_addr3_16(&iphdr->dest), - ip4_addr4_16(&iphdr->dest))); - LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); -} -#endif /* IP_DEBUG */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/ip4_addr.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/ip4_addr.c deleted file mode 100644 index 8f633ff2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/ip4_addr.c +++ /dev/null @@ -1,312 +0,0 @@ -/** - * @file - * This is the IPv4 address tools implementation. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" - -/* used by IP_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */ -const ip_addr_t ip_addr_any = { IPADDR_ANY }; -const ip_addr_t ip_addr_broadcast = { IPADDR_BROADCAST }; - -/** - * Determine if an address is a broadcast address on a network interface - * - * @param addr address to be checked - * @param netif the network interface against which the address is checked - * @return returns non-zero if the address is a broadcast address - */ -u8_t -ip4_addr_isbroadcast(u32_t addr, const struct netif *netif) -{ - ip_addr_t ipaddr; - ip4_addr_set_u32(&ipaddr, addr); - - /* all ones (broadcast) or all zeroes (old skool broadcast) */ - if ((~addr == IPADDR_ANY) || - (addr == IPADDR_ANY)) { - return 1; - /* no broadcast support on this network interface? */ - } else if ((netif->flags & NETIF_FLAG_BROADCAST) == 0) { - /* the given address cannot be a broadcast address - * nor can we check against any broadcast addresses */ - return 0; - /* address matches network interface address exactly? => no broadcast */ - } else if (addr == ip4_addr_get_u32(&netif->ip_addr)) { - return 0; - /* on the same (sub) network... */ - } else if (ip_addr_netcmp(&ipaddr, &(netif->ip_addr), &(netif->netmask)) - /* ...and host identifier bits are all ones? =>... */ - && ((addr & ~ip4_addr_get_u32(&netif->netmask)) == - (IPADDR_BROADCAST & ~ip4_addr_get_u32(&netif->netmask)))) { - /* => network broadcast address */ - return 1; - } else { - return 0; - } -} - -/** Checks if a netmask is valid (starting with ones, then only zeros) - * - * @param netmask the IPv4 netmask to check (in network byte order!) - * @return 1 if the netmask is valid, 0 if it is not - */ -u8_t -ip4_addr_netmask_valid(u32_t netmask) -{ - u32_t mask; - u32_t nm_hostorder = lwip_htonl(netmask); - - /* first, check for the first zero */ - for (mask = 1UL << 31 ; mask != 0; mask >>= 1) { - if ((nm_hostorder & mask) == 0) { - break; - } - } - /* then check that there is no one */ - for (; mask != 0; mask >>= 1) { - if ((nm_hostorder & mask) != 0) { - /* there is a one after the first zero -> invalid */ - return 0; - } - } - /* no one after the first zero -> valid */ - return 1; -} - -/* Here for now until needed in other places in lwIP */ -#ifndef isprint -#define in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up) -#define isprint(c) in_range(c, 0x20, 0x7f) -#define isdigit(c) in_range(c, '0', '9') -#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F')) -#define islower(c) in_range(c, 'a', 'z') -#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v') -#endif - -/** - * Ascii internet address interpretation routine. - * The value returned is in network order. - * - * @param cp IP address in ascii represenation (e.g. "127.0.0.1") - * @return ip address in network order - */ -u32_t -ipaddr_addr(const char *cp) -{ - ip_addr_t val; - - if (ipaddr_aton(cp, &val)) { - return ip4_addr_get_u32(&val); - } - return (IPADDR_NONE); -} - -/** - * Check whether "cp" is a valid ascii representation - * of an Internet address and convert to a binary address. - * Returns 1 if the address is valid, 0 if not. - * This replaces inet_addr, the return value from which - * cannot distinguish between failure and a local broadcast address. - * - * @param cp IP address in ascii represenation (e.g. "127.0.0.1") - * @param addr pointer to which to save the ip address in network order - * @return 1 if cp could be converted to addr, 0 on failure - */ -int -ipaddr_aton(const char *cp, ip_addr_t *addr) -{ - u32_t val; - u8_t base; - char c; - u32_t parts[4]; - u32_t *pp = parts; - - c = *cp; - for (;;) { - /* - * Collect number up to ``.''. - * Values are specified as for C: - * 0x=hex, 0=octal, 1-9=decimal. - */ - if (!isdigit(c)) - return (0); - val = 0; - base = 10; - if (c == '0') { - c = *++cp; - if (c == 'x' || c == 'X') { - base = 16; - c = *++cp; - } else - base = 8; - } - for (;;) { - if (isdigit(c)) { - val = (val * base) + (int)(c - '0'); - c = *++cp; - } else if (base == 16 && isxdigit(c)) { - val = (val << 4) | (int)(c + 10 - (islower(c) ? 'a' : 'A')); - c = *++cp; - } else - break; - } - if (c == '.') { - /* - * Internet format: - * a.b.c.d - * a.b.c (with c treated as 16 bits) - * a.b (with b treated as 24 bits) - */ - if (pp >= parts + 3) { - return (0); - } - *pp++ = val; - c = *++cp; - } else - break; - } - /* - * Check for trailing characters. - */ - if (c != '\0' && !isspace(c)) { - return (0); - } - /* - * Concoct the address according to - * the number of parts specified. - */ - switch (pp - parts + 1) { - - case 0: - return (0); /* initial nondigit */ - - case 1: /* a -- 32 bits */ - break; - - case 2: /* a.b -- 8.24 bits */ - if (val > 0xffffffUL) { - return (0); - } - val |= parts[0] << 24; - break; - - case 3: /* a.b.c -- 8.8.16 bits */ - if (val > 0xffff) { - return (0); - } - val |= (parts[0] << 24) | (parts[1] << 16); - break; - - case 4: /* a.b.c.d -- 8.8.8.8 bits */ - if (val > 0xff) { - return (0); - } - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); - break; - default: - LWIP_ASSERT("unhandled", 0); - break; - } - if (addr) { - ip4_addr_set_u32(addr, htonl(val)); - } - return (1); -} - -/** - * Convert numeric IP address into decimal dotted ASCII representation. - * returns ptr to static buffer; not reentrant! - * - * @param addr ip address in network order to convert - * @return pointer to a global static (!) buffer that holds the ASCII - * represenation of addr - */ -char * -ipaddr_ntoa(const ip_addr_t *addr) -{ - static char str[16]; - return ipaddr_ntoa_r(addr, str, 16); -} - -/** - * Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used. - * - * @param addr ip address in network order to convert - * @param buf target buffer where the string is stored - * @param buflen length of buf - * @return either pointer to buf which now holds the ASCII - * representation of addr or NULL if buf was too small - */ -char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen) -{ - u32_t s_addr; - char inv[3]; - char *rp; - u8_t *ap; - u8_t rem; - u8_t n; - u8_t i; - int len = 0; - - s_addr = ip4_addr_get_u32(addr); - - rp = buf; - ap = (u8_t *)&s_addr; - for(n = 0; n < 4; n++) { - i = 0; - do { - rem = *ap % (u8_t)10; - *ap /= (u8_t)10; - inv[i++] = '0' + rem; - } while(*ap); - while(i--) { - if (len++ >= buflen) { - return NULL; - } - *rp++ = inv[i]; - } - if (len++ >= buflen) { - return NULL; - } - *rp++ = '.'; - ap++; - } - *--rp = 0; - return buf; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/ip_frag.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/ip_frag.c deleted file mode 100644 index 8d184345..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv4/ip_frag.c +++ /dev/null @@ -1,863 +0,0 @@ -/** - * @file - * This is the IPv4 packet segmentation and reassembly implementation. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Jani Monoses - * Simon Goldschmidt - * original reassembly code by Adam Dunkels - * - */ - -#include "lwip/opt.h" -#include "lwip/ip_frag.h" -#include "lwip/def.h" -#include "lwip/inet_chksum.h" -#include "lwip/netif.h" -#include "lwip/snmp.h" -#include "lwip/stats.h" -#include "lwip/icmp.h" - -#include - -#if IP_REASSEMBLY -/** - * The IP reassembly code currently has the following limitations: - * - IP header options are not supported - * - fragments must not overlap (e.g. due to different routes), - * currently, overlapping or duplicate fragments are thrown away - * if IP_REASS_CHECK_OVERLAP=1 (the default)! - * - * @todo: work with IP header options - */ - -/** Setting this to 0, you can turn off checking the fragments for overlapping - * regions. The code gets a little smaller. Only use this if you know that - * overlapping won't occur on your network! */ -#ifndef IP_REASS_CHECK_OVERLAP -#define IP_REASS_CHECK_OVERLAP 1 -#endif /* IP_REASS_CHECK_OVERLAP */ - -/** Set to 0 to prevent freeing the oldest datagram when the reassembly buffer is - * full (IP_REASS_MAX_PBUFS pbufs are enqueued). The code gets a little smaller. - * Datagrams will be freed by timeout only. Especially useful when MEMP_NUM_REASSDATA - * is set to 1, so one datagram can be reassembled at a time, only. */ -#ifndef IP_REASS_FREE_OLDEST -#define IP_REASS_FREE_OLDEST 1 -#endif /* IP_REASS_FREE_OLDEST */ - -#define IP_REASS_FLAG_LASTFRAG 0x01 - -/** This is a helper struct which holds the starting - * offset and the ending offset of this fragment to - * easily chain the fragments. - * It has the same packing requirements as the IP header, since it replaces - * the IP header in memory in incoming fragments (after copying it) to keep - * track of the various fragments. (-> If the IP header doesn't need packing, - * this struct doesn't need packing, too.) - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip_reass_helper { - PACK_STRUCT_FIELD(struct pbuf *next_pbuf); - PACK_STRUCT_FIELD(u16_t start); - PACK_STRUCT_FIELD(u16_t end); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define IP_ADDRESSES_AND_ID_MATCH(iphdrA, iphdrB) \ - (ip_addr_cmp(&(iphdrA)->src, &(iphdrB)->src) && \ - ip_addr_cmp(&(iphdrA)->dest, &(iphdrB)->dest) && \ - IPH_ID(iphdrA) == IPH_ID(iphdrB)) ? 1 : 0 - -/* global variables */ -static struct ip_reassdata *reassdatagrams; -static u16_t ip_reass_pbufcount; - -/* function prototypes */ -static void ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev); -static int ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev); - -/** - * Reassembly timer base function - * for both NO_SYS == 0 and 1 (!). - * - * Should be called every 1000 msec (defined by IP_TMR_INTERVAL). - */ -void -ip_reass_tmr(void) -{ - struct ip_reassdata *r, *prev = NULL; - - r = reassdatagrams; - while (r != NULL) { - /* Decrement the timer. Once it reaches 0, - * clean up the incomplete fragment assembly */ - if (r->timer > 0) { - r->timer--; - LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_tmr: timer dec %"U16_F"\n",(u16_t)r->timer)); - prev = r; - r = r->next; - } else { - /* reassembly timed out */ - struct ip_reassdata *tmp; - LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_tmr: timer timed out\n")); - tmp = r; - /* get the next pointer before freeing */ - r = r->next; - /* free the helper struct and all enqueued pbufs */ - ip_reass_free_complete_datagram(tmp, prev); - } - } -} - -/** - * Free a datagram (struct ip_reassdata) and all its pbufs. - * Updates the total count of enqueued pbufs (ip_reass_pbufcount), - * SNMP counters and sends an ICMP time exceeded packet. - * - * @param ipr datagram to free - * @param prev the previous datagram in the linked list - * @return the number of pbufs freed - */ -static int -ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev) -{ - u16_t pbufs_freed = 0; - u8_t clen; - struct pbuf *p; - struct ip_reass_helper *iprh; - - LWIP_ASSERT("prev != ipr", prev != ipr); - if (prev != NULL) { - LWIP_ASSERT("prev->next == ipr", prev->next == ipr); - } - - snmp_inc_ipreasmfails(); -#if LWIP_ICMP - iprh = (struct ip_reass_helper *)ipr->p->payload; - if (iprh->start == 0) { - /* The first fragment was received, send ICMP time exceeded. */ - /* First, de-queue the first pbuf from r->p. */ - p = ipr->p; - ipr->p = iprh->next_pbuf; - /* Then, copy the original header into it. */ - SMEMCPY(p->payload, &ipr->iphdr, IP_HLEN); - icmp_time_exceeded(p, ICMP_TE_FRAG); - clen = pbuf_clen(p); - LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff); - pbufs_freed += clen; - pbuf_free(p); - } -#endif /* LWIP_ICMP */ - - /* First, free all received pbufs. The individual pbufs need to be released - separately as they have not yet been chained */ - p = ipr->p; - while (p != NULL) { - struct pbuf *pcur; - iprh = (struct ip_reass_helper *)p->payload; - pcur = p; - /* get the next pointer before freeing */ - p = iprh->next_pbuf; - clen = pbuf_clen(pcur); - LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff); - pbufs_freed += clen; - pbuf_free(pcur); - } - /* Then, unchain the struct ip_reassdata from the list and free it. */ - ip_reass_dequeue_datagram(ipr, prev); - LWIP_ASSERT("ip_reass_pbufcount >= clen", ip_reass_pbufcount >= pbufs_freed); - ip_reass_pbufcount -= pbufs_freed; - - return pbufs_freed; -} - -#if IP_REASS_FREE_OLDEST -/** - * Free the oldest datagram to make room for enqueueing new fragments. - * The datagram 'fraghdr' belongs to is not freed! - * - * @param fraghdr IP header of the current fragment - * @param pbufs_needed number of pbufs needed to enqueue - * (used for freeing other datagrams if not enough space) - * @return the number of pbufs freed - */ -static int -ip_reass_remove_oldest_datagram(struct ip_hdr *fraghdr, int pbufs_needed) -{ - /* @todo Can't we simply remove the last datagram in the - * linked list behind reassdatagrams? - */ - struct ip_reassdata *r, *oldest, *prev; - int pbufs_freed = 0, pbufs_freed_current; - int other_datagrams; - - /* Free datagrams until being allowed to enqueue 'pbufs_needed' pbufs, - * but don't free the datagram that 'fraghdr' belongs to! */ - do { - oldest = NULL; - prev = NULL; - other_datagrams = 0; - r = reassdatagrams; - while (r != NULL) { - if (!IP_ADDRESSES_AND_ID_MATCH(&r->iphdr, fraghdr)) { - /* Not the same datagram as fraghdr */ - other_datagrams++; - if (oldest == NULL) { - oldest = r; - } else if (r->timer <= oldest->timer) { - /* older than the previous oldest */ - oldest = r; - } - } - if (r->next != NULL) { - prev = r; - } - r = r->next; - } - if (oldest != NULL) { - pbufs_freed_current = ip_reass_free_complete_datagram(oldest, prev); - pbufs_freed += pbufs_freed_current; - } - } while ((pbufs_freed < pbufs_needed) && (other_datagrams > 1)); - return pbufs_freed; -} -#endif /* IP_REASS_FREE_OLDEST */ - -/** - * Enqueues a new fragment into the fragment queue - * @param fraghdr points to the new fragments IP hdr - * @param clen number of pbufs needed to enqueue (used for freeing other datagrams if not enough space) - * @return A pointer to the queue location into which the fragment was enqueued - */ -static struct ip_reassdata* -ip_reass_enqueue_new_datagram(struct ip_hdr *fraghdr, int clen) -{ - struct ip_reassdata* ipr; - /* No matching previous fragment found, allocate a new reassdata struct */ - ipr = (struct ip_reassdata *)memp_malloc(MEMP_REASSDATA); - if (ipr == NULL) { -#if IP_REASS_FREE_OLDEST - if (ip_reass_remove_oldest_datagram(fraghdr, clen) >= clen) { - ipr = (struct ip_reassdata *)memp_malloc(MEMP_REASSDATA); - } - if (ipr == NULL) -#endif /* IP_REASS_FREE_OLDEST */ - { - IPFRAG_STATS_INC(ip_frag.memerr); - LWIP_DEBUGF(IP_REASS_DEBUG,("Failed to alloc reassdata struct\n")); - return NULL; - } - } - memset(ipr, 0, sizeof(struct ip_reassdata)); - ipr->timer = IP_REASS_MAXAGE; - - /* enqueue the new structure to the front of the list */ - ipr->next = reassdatagrams; - reassdatagrams = ipr; - /* copy the ip header for later tests and input */ - /* @todo: no ip options supported? */ - SMEMCPY(&(ipr->iphdr), fraghdr, IP_HLEN); - return ipr; -} - -/** - * Dequeues a datagram from the datagram queue. Doesn't deallocate the pbufs. - * @param ipr points to the queue entry to dequeue - */ -static void -ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev) -{ - - /* dequeue the reass struct */ - if (reassdatagrams == ipr) { - /* it was the first in the list */ - reassdatagrams = ipr->next; - } else { - /* it wasn't the first, so it must have a valid 'prev' */ - LWIP_ASSERT("sanity check linked list", prev != NULL); - prev->next = ipr->next; - } - - /* now we can free the ip_reass struct */ - memp_free(MEMP_REASSDATA, ipr); -} - -/** - * Chain a new pbuf into the pbuf list that composes the datagram. The pbuf list - * will grow over time as new pbufs are rx. - * Also checks that the datagram passes basic continuity checks (if the last - * fragment was received at least once). - * @param root_p points to the 'root' pbuf for the current datagram being assembled. - * @param new_p points to the pbuf for the current fragment - * @return 0 if invalid, >0 otherwise - */ -static int -ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct pbuf *new_p) -{ - struct ip_reass_helper *iprh, *iprh_tmp, *iprh_prev=NULL; - struct pbuf *q; - u16_t offset,len; - struct ip_hdr *fraghdr; - int valid = 1; - - /* Extract length and fragment offset from current fragment */ - fraghdr = (struct ip_hdr*)new_p->payload; - len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; - offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; - - /* overwrite the fragment's ip header from the pbuf with our helper struct, - * and setup the embedded helper structure. */ - /* make sure the struct ip_reass_helper fits into the IP header */ - LWIP_ASSERT("sizeof(struct ip_reass_helper) <= IP_HLEN", - sizeof(struct ip_reass_helper) <= IP_HLEN); - iprh = (struct ip_reass_helper*)new_p->payload; - iprh->next_pbuf = NULL; - iprh->start = offset; - iprh->end = offset + len; - - /* Iterate through until we either get to the end of the list (append), - * or we find on with a larger offset (insert). */ - for (q = ipr->p; q != NULL;) { - iprh_tmp = (struct ip_reass_helper*)q->payload; - if (iprh->start < iprh_tmp->start) { - /* the new pbuf should be inserted before this */ - iprh->next_pbuf = q; - if (iprh_prev != NULL) { - /* not the fragment with the lowest offset */ -#if IP_REASS_CHECK_OVERLAP - if ((iprh->start < iprh_prev->end) || (iprh->end > iprh_tmp->start)) { - /* fragment overlaps with previous or following, throw away */ - goto freepbuf; - } -#endif /* IP_REASS_CHECK_OVERLAP */ - iprh_prev->next_pbuf = new_p; - } else { - /* fragment with the lowest offset */ - ipr->p = new_p; - } - break; - } else if(iprh->start == iprh_tmp->start) { - /* received the same datagram twice: no need to keep the datagram */ - goto freepbuf; -#if IP_REASS_CHECK_OVERLAP - } else if(iprh->start < iprh_tmp->end) { - /* overlap: no need to keep the new datagram */ - goto freepbuf; -#endif /* IP_REASS_CHECK_OVERLAP */ - } else { - /* Check if the fragments received so far have no wholes. */ - if (iprh_prev != NULL) { - if (iprh_prev->end != iprh_tmp->start) { - /* There is a fragment missing between the current - * and the previous fragment */ - valid = 0; - } - } - } - q = iprh_tmp->next_pbuf; - iprh_prev = iprh_tmp; - } - - /* If q is NULL, then we made it to the end of the list. Determine what to do now */ - if (q == NULL) { - if (iprh_prev != NULL) { - /* this is (for now), the fragment with the highest offset: - * chain it to the last fragment */ -#if IP_REASS_CHECK_OVERLAP - LWIP_ASSERT("check fragments don't overlap", iprh_prev->end <= iprh->start); -#endif /* IP_REASS_CHECK_OVERLAP */ - iprh_prev->next_pbuf = new_p; - if (iprh_prev->end != iprh->start) { - valid = 0; - } - } else { -#if IP_REASS_CHECK_OVERLAP - LWIP_ASSERT("no previous fragment, this must be the first fragment!", - ipr->p == NULL); -#endif /* IP_REASS_CHECK_OVERLAP */ - /* this is the first fragment we ever received for this ip datagram */ - ipr->p = new_p; - } - } - - /* At this point, the validation part begins: */ - /* If we already received the last fragment */ - if ((ipr->flags & IP_REASS_FLAG_LASTFRAG) != 0) { - /* and had no wholes so far */ - if (valid) { - /* then check if the rest of the fragments is here */ - /* Check if the queue starts with the first datagram */ - if (((struct ip_reass_helper*)ipr->p->payload)->start != 0) { - valid = 0; - } else { - /* and check that there are no wholes after this datagram */ - iprh_prev = iprh; - q = iprh->next_pbuf; - while (q != NULL) { - iprh = (struct ip_reass_helper*)q->payload; - if (iprh_prev->end != iprh->start) { - valid = 0; - break; - } - iprh_prev = iprh; - q = iprh->next_pbuf; - } - /* if still valid, all fragments are received - * (because to the MF==0 already arrived */ - if (valid) { - LWIP_ASSERT("sanity check", ipr->p != NULL); - LWIP_ASSERT("sanity check", - ((struct ip_reass_helper*)ipr->p->payload) != iprh); - LWIP_ASSERT("validate_datagram:next_pbuf!=NULL", - iprh->next_pbuf == NULL); - LWIP_ASSERT("validate_datagram:datagram end!=datagram len", - iprh->end == ipr->datagram_len); - } - } - } - /* If valid is 0 here, there are some fragments missing in the middle - * (since MF == 0 has already arrived). Such datagrams simply time out if - * no more fragments are received... */ - return valid; - } - /* If we come here, not all fragments were received, yet! */ - return 0; /* not yet valid! */ -#if IP_REASS_CHECK_OVERLAP -freepbuf: - ip_reass_pbufcount -= pbuf_clen(new_p); - pbuf_free(new_p); - return 0; -#endif /* IP_REASS_CHECK_OVERLAP */ -} - -/** - * Reassembles incoming IP fragments into an IP datagram. - * - * @param p points to a pbuf chain of the fragment - * @return NULL if reassembly is incomplete, ? otherwise - */ -struct pbuf * -ip_reass(struct pbuf *p) -{ - struct pbuf *r; - struct ip_hdr *fraghdr; - struct ip_reassdata *ipr; - struct ip_reass_helper *iprh; - u16_t offset, len; - u8_t clen; - struct ip_reassdata *ipr_prev = NULL; - - IPFRAG_STATS_INC(ip_frag.recv); - snmp_inc_ipreasmreqds(); - - fraghdr = (struct ip_hdr*)p->payload; - - if ((IPH_HL(fraghdr) * 4) != IP_HLEN) { - LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass: IP options currently not supported!\n")); - IPFRAG_STATS_INC(ip_frag.err); - goto nullreturn; - } - - offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; - len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; - - /* Check if we are allowed to enqueue more datagrams. */ - clen = pbuf_clen(p); - if ((ip_reass_pbufcount + clen) > IP_REASS_MAX_PBUFS) { -#if IP_REASS_FREE_OLDEST - if (!ip_reass_remove_oldest_datagram(fraghdr, clen) || - ((ip_reass_pbufcount + clen) > IP_REASS_MAX_PBUFS)) -#endif /* IP_REASS_FREE_OLDEST */ - { - /* No datagram could be freed and still too many pbufs enqueued */ - LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass: Overflow condition: pbufct=%d, clen=%d, MAX=%d\n", - ip_reass_pbufcount, clen, IP_REASS_MAX_PBUFS)); - IPFRAG_STATS_INC(ip_frag.memerr); - /* @todo: send ICMP time exceeded here? */ - /* drop this pbuf */ - goto nullreturn; - } - } - - /* Look for the datagram the fragment belongs to in the current datagram queue, - * remembering the previous in the queue for later dequeueing. */ - for (ipr = reassdatagrams; ipr != NULL; ipr = ipr->next) { - /* Check if the incoming fragment matches the one currently present - in the reassembly buffer. If so, we proceed with copying the - fragment into the buffer. */ - if (IP_ADDRESSES_AND_ID_MATCH(&ipr->iphdr, fraghdr)) { - LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: matching previous fragment ID=%"X16_F"\n", - ntohs(IPH_ID(fraghdr)))); - IPFRAG_STATS_INC(ip_frag.cachehit); - break; - } - ipr_prev = ipr; - } - - if (ipr == NULL) { - /* Enqueue a new datagram into the datagram queue */ - ipr = ip_reass_enqueue_new_datagram(fraghdr, clen); - /* Bail if unable to enqueue */ - if(ipr == NULL) { - goto nullreturn; - } - } else { - if (((ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) == 0) && - ((ntohs(IPH_OFFSET(&ipr->iphdr)) & IP_OFFMASK) != 0)) { - /* ipr->iphdr is not the header from the first fragment, but fraghdr is - * -> copy fraghdr into ipr->iphdr since we want to have the header - * of the first fragment (for ICMP time exceeded and later, for copying - * all options, if supported)*/ - SMEMCPY(&ipr->iphdr, fraghdr, IP_HLEN); - } - } - /* Track the current number of pbufs current 'in-flight', in order to limit - the number of fragments that may be enqueued at any one time */ - ip_reass_pbufcount += clen; - - /* At this point, we have either created a new entry or pointing - * to an existing one */ - - /* check for 'no more fragments', and update queue entry*/ - if ((IPH_OFFSET(fraghdr) & PP_NTOHS(IP_MF)) == 0) { - ipr->flags |= IP_REASS_FLAG_LASTFRAG; - ipr->datagram_len = offset + len; - LWIP_DEBUGF(IP_REASS_DEBUG, - ("ip_reass: last fragment seen, total len %"S16_F"\n", - ipr->datagram_len)); - } - /* find the right place to insert this pbuf */ - /* @todo: trim pbufs if fragments are overlapping */ - if (ip_reass_chain_frag_into_datagram_and_validate(ipr, p)) { - /* the totally last fragment (flag more fragments = 0) was received at least - * once AND all fragments are received */ - ipr->datagram_len += IP_HLEN; - - /* save the second pbuf before copying the header over the pointer */ - r = ((struct ip_reass_helper*)ipr->p->payload)->next_pbuf; - - /* copy the original ip header back to the first pbuf */ - fraghdr = (struct ip_hdr*)(ipr->p->payload); - SMEMCPY(fraghdr, &ipr->iphdr, IP_HLEN); - IPH_LEN_SET(fraghdr, htons(ipr->datagram_len)); - IPH_OFFSET_SET(fraghdr, 0); - IPH_CHKSUM_SET(fraghdr, 0); - /* @todo: do we need to set calculate the correct checksum? */ - IPH_CHKSUM_SET(fraghdr, inet_chksum(fraghdr, IP_HLEN)); - - p = ipr->p; - - /* chain together the pbufs contained within the reass_data list. */ - while(r != NULL) { - iprh = (struct ip_reass_helper*)r->payload; - - /* hide the ip header for every succeding fragment */ - pbuf_header(r, -IP_HLEN); - pbuf_cat(p, r); - r = iprh->next_pbuf; - } - /* release the sources allocate for the fragment queue entry */ - ip_reass_dequeue_datagram(ipr, ipr_prev); - - /* and adjust the number of pbufs currently queued for reassembly. */ - ip_reass_pbufcount -= pbuf_clen(p); - - /* Return the pbuf chain */ - return p; - } - /* the datagram is not (yet?) reassembled completely */ - LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass_pbufcount: %d out\n", ip_reass_pbufcount)); - return NULL; - -nullreturn: - LWIP_DEBUGF(IP_REASS_DEBUG,("ip_reass: nullreturn\n")); - IPFRAG_STATS_INC(ip_frag.drop); - pbuf_free(p); - return NULL; -} -#endif /* IP_REASSEMBLY */ - -#if IP_FRAG -#if IP_FRAG_USES_STATIC_BUF -static u8_t buf[LWIP_MEM_ALIGN_SIZE(IP_FRAG_MAX_MTU + MEM_ALIGNMENT - 1)]; -#else /* IP_FRAG_USES_STATIC_BUF */ - -#if !LWIP_NETIF_TX_SINGLE_PBUF -/** Allocate a new struct pbuf_custom_ref */ -static struct pbuf_custom_ref* -ip_frag_alloc_pbuf_custom_ref(void) -{ - return (struct pbuf_custom_ref*)memp_malloc(MEMP_FRAG_PBUF); -} - -/** Free a struct pbuf_custom_ref */ -static void -ip_frag_free_pbuf_custom_ref(struct pbuf_custom_ref* p) -{ - LWIP_ASSERT("p != NULL", p != NULL); - memp_free(MEMP_FRAG_PBUF, p); -} - -/** Free-callback function to free a 'struct pbuf_custom_ref', called by - * pbuf_free. */ -static void -ipfrag_free_pbuf_custom(struct pbuf *p) -{ - struct pbuf_custom_ref *pcr = (struct pbuf_custom_ref*)p; - LWIP_ASSERT("pcr != NULL", pcr != NULL); - LWIP_ASSERT("pcr == p", (void*)pcr == (void*)p); - if (pcr->original != NULL) { - pbuf_free(pcr->original); - } - ip_frag_free_pbuf_custom_ref(pcr); -} -#endif /* !LWIP_NETIF_TX_SINGLE_PBUF */ -#endif /* IP_FRAG_USES_STATIC_BUF */ - -/** - * Fragment an IP datagram if too large for the netif. - * - * Chop the datagram in MTU sized chunks and send them in order - * by using a fixed size static memory buffer (PBUF_REF) or - * point PBUF_REFs into p (depending on IP_FRAG_USES_STATIC_BUF). - * - * @param p ip packet to send - * @param netif the netif on which to send - * @param dest destination ip address to which to send - * - * @return ERR_OK if sent successfully, err_t otherwise - */ -err_t -ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest) -{ - struct pbuf *rambuf; -#if IP_FRAG_USES_STATIC_BUF - struct pbuf *header; -#else -#if !LWIP_NETIF_TX_SINGLE_PBUF - struct pbuf *newpbuf; -#endif - struct ip_hdr *original_iphdr; -#endif - struct ip_hdr *iphdr; - u16_t nfb; - u16_t left, cop; - u16_t mtu = netif->mtu; - u16_t ofo, omf; - u16_t last; - u16_t poff = IP_HLEN; - u16_t tmp; -#if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF - u16_t newpbuflen = 0; - u16_t left_to_copy; -#endif - - /* Get a RAM based MTU sized pbuf */ -#if IP_FRAG_USES_STATIC_BUF - /* When using a static buffer, we use a PBUF_REF, which we will - * use to reference the packet (without link header). - * Layer and length is irrelevant. - */ - rambuf = pbuf_alloc(PBUF_LINK, 0, PBUF_REF); - if (rambuf == NULL) { - LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_frag: pbuf_alloc(PBUF_LINK, 0, PBUF_REF) failed\n")); - return ERR_MEM; - } - rambuf->tot_len = rambuf->len = mtu; - rambuf->payload = LWIP_MEM_ALIGN((void *)buf); - - /* Copy the IP header in it */ - iphdr = (struct ip_hdr *)rambuf->payload; - SMEMCPY(iphdr, p->payload, IP_HLEN); -#else /* IP_FRAG_USES_STATIC_BUF */ - original_iphdr = (struct ip_hdr *)p->payload; - iphdr = original_iphdr; -#endif /* IP_FRAG_USES_STATIC_BUF */ - - /* Save original offset */ - tmp = ntohs(IPH_OFFSET(iphdr)); - ofo = tmp & IP_OFFMASK; - omf = tmp & IP_MF; - - left = p->tot_len - IP_HLEN; - - nfb = (mtu - IP_HLEN) / 8; - - while (left) { - last = (left <= mtu - IP_HLEN); - - /* Set new offset and MF flag */ - tmp = omf | (IP_OFFMASK & (ofo)); - if (!last) { - tmp = tmp | IP_MF; - } - - /* Fill this fragment */ - cop = last ? left : nfb * 8; - -#if IP_FRAG_USES_STATIC_BUF - poff += pbuf_copy_partial(p, (u8_t*)iphdr + IP_HLEN, cop, poff); -#else /* IP_FRAG_USES_STATIC_BUF */ -#if LWIP_NETIF_TX_SINGLE_PBUF - rambuf = pbuf_alloc(PBUF_IP, cop, PBUF_RAM); - if (rambuf == NULL) { - return ERR_MEM; - } - LWIP_ASSERT("this needs a pbuf in one piece!", - (rambuf->len == rambuf->tot_len) && (rambuf->next == NULL)); - poff += pbuf_copy_partial(p, rambuf->payload, cop, poff); - /* make room for the IP header */ - if(pbuf_header(rambuf, IP_HLEN)) { - pbuf_free(rambuf); - return ERR_MEM; - } - /* fill in the IP header */ - SMEMCPY(rambuf->payload, original_iphdr, IP_HLEN); - iphdr = rambuf->payload; -#else /* LWIP_NETIF_TX_SINGLE_PBUF */ - /* When not using a static buffer, create a chain of pbufs. - * The first will be a PBUF_RAM holding the link and IP header. - * The rest will be PBUF_REFs mirroring the pbuf chain to be fragged, - * but limited to the size of an mtu. - */ - rambuf = pbuf_alloc(PBUF_LINK, IP_HLEN, PBUF_RAM); - if (rambuf == NULL) { - return ERR_MEM; - } - LWIP_ASSERT("this needs a pbuf in one piece!", - (p->len >= (IP_HLEN))); - SMEMCPY(rambuf->payload, original_iphdr, IP_HLEN); - iphdr = (struct ip_hdr *)rambuf->payload; - - /* Can just adjust p directly for needed offset. */ - p->payload = (u8_t *)p->payload + poff; - p->len -= poff; - - left_to_copy = cop; - while (left_to_copy) { - struct pbuf_custom_ref *pcr; - newpbuflen = (left_to_copy < p->len) ? left_to_copy : p->len; - /* Is this pbuf already empty? */ - if (!newpbuflen) { - p = p->next; - continue; - } - pcr = ip_frag_alloc_pbuf_custom_ref(); - if (pcr == NULL) { - pbuf_free(rambuf); - return ERR_MEM; - } - /* Mirror this pbuf, although we might not need all of it. */ - newpbuf = pbuf_alloced_custom(PBUF_RAW, newpbuflen, PBUF_REF, &pcr->pc, p->payload, newpbuflen); - if (newpbuf == NULL) { - ip_frag_free_pbuf_custom_ref(pcr); - pbuf_free(rambuf); - return ERR_MEM; - } - pbuf_ref(p); - pcr->original = p; - pcr->pc.custom_free_function = ipfrag_free_pbuf_custom; - - /* Add it to end of rambuf's chain, but using pbuf_cat, not pbuf_chain - * so that it is removed when pbuf_dechain is later called on rambuf. - */ - pbuf_cat(rambuf, newpbuf); - left_to_copy -= newpbuflen; - if (left_to_copy) { - p = p->next; - } - } - poff = newpbuflen; -#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ -#endif /* IP_FRAG_USES_STATIC_BUF */ - - /* Correct header */ - IPH_OFFSET_SET(iphdr, htons(tmp)); - IPH_LEN_SET(iphdr, htons(cop + IP_HLEN)); - IPH_CHKSUM_SET(iphdr, 0); - IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP_HLEN)); - -#if IP_FRAG_USES_STATIC_BUF - if (last) { - pbuf_realloc(rambuf, left + IP_HLEN); - } - - /* This part is ugly: we alloc a RAM based pbuf for - * the link level header for each chunk and then - * free it.A PBUF_ROM style pbuf for which pbuf_header - * worked would make things simpler. - */ - header = pbuf_alloc(PBUF_LINK, 0, PBUF_RAM); - if (header != NULL) { - pbuf_chain(header, rambuf); - netif->output(netif, header, dest); - IPFRAG_STATS_INC(ip_frag.xmit); - snmp_inc_ipfragcreates(); - pbuf_free(header); - } else { - LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_frag: pbuf_alloc() for header failed\n")); - pbuf_free(rambuf); - return ERR_MEM; - } -#else /* IP_FRAG_USES_STATIC_BUF */ - /* No need for separate header pbuf - we allowed room for it in rambuf - * when allocated. - */ - netif->output(netif, rambuf, dest); - IPFRAG_STATS_INC(ip_frag.xmit); - - /* Unfortunately we can't reuse rambuf - the hardware may still be - * using the buffer. Instead we free it (and the ensuing chain) and - * recreate it next time round the loop. If we're lucky the hardware - * will have already sent the packet, the free will really free, and - * there will be zero memory penalty. - */ - - pbuf_free(rambuf); -#endif /* IP_FRAG_USES_STATIC_BUF */ - left -= cop; - ofo += nfb; - } -#if IP_FRAG_USES_STATIC_BUF - pbuf_free(rambuf); -#endif /* IP_FRAG_USES_STATIC_BUF */ - snmp_inc_ipfragoks(); - return ERR_OK; -} -#endif /* IP_FRAG */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/icmp6.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/icmp6.c deleted file mode 100644 index fd17f393..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/icmp6.c +++ /dev/null @@ -1,337 +0,0 @@ -/** - * @file - * - * IPv6 version of ICMP, as per RFC 4443. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#include "lwip/opt.h" - -#if LWIP_ICMP6 && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/icmp6.h" -#include "lwip/ip6.h" -#include "lwip/ip6_addr.h" -#include "lwip/inet_chksum.h" -#include "lwip/pbuf.h" -#include "lwip/netif.h" -#include "lwip/nd6.h" -#include "lwip/mld6.h" -#include "lwip/stats.h" - -#include - -#ifndef LWIP_ICMP6_DATASIZE -#define LWIP_ICMP6_DATASIZE 8 -#endif -#if LWIP_ICMP6_DATASIZE == 0 -#define LWIP_ICMP6_DATASIZE 8 -#endif - -/* Forward declarations */ -static void icmp6_send_response(struct pbuf *p, u8_t code, u32_t data, u8_t type); - - -/** - * Process an input ICMPv6 message. Called by ip6_input. - * - * Will generate a reply for echo requests. Other messages are forwarded - * to nd6_input, or mld6_input. - * - * @param p the mld packet, p->payload pointing to the icmpv6 header - * @param inp the netif on which this packet was received - */ -void -icmp6_input(struct pbuf *p, struct netif *inp) -{ - struct pp_icmp6_hdr *icmp6hdr; - struct pbuf * r; - ip6_addr_t * reply_src; - - ICMP6_STATS_INC(icmp6.recv); - - /* Check that ICMPv6 header fits in payload */ - if (p->len < sizeof(struct pp_icmp6_hdr)) { - /* drop short packets */ - pbuf_free(p); - ICMP6_STATS_INC(icmp6.lenerr); - ICMP6_STATS_INC(icmp6.drop); - return; - } - - icmp6hdr = (struct pp_icmp6_hdr *)p->payload; - -#if LWIP_ICMP6_CHECKSUM_CHECK - if (ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->tot_len, ip6_current_src_addr(), - ip6_current_dest_addr()) != 0) { - /* Checksum failed */ - pbuf_free(p); - ICMP6_STATS_INC(icmp6.chkerr); - ICMP6_STATS_INC(icmp6.drop); - return; - } -#endif /* LWIP_ICMP6_CHECKSUM_CHECK */ - - switch (icmp6hdr->type) { - case ICMP6_TYPE_NA: /* Neighbor advertisement */ - case ICMP6_TYPE_NS: /* Neighbor solicitation */ - case ICMP6_TYPE_RA: /* Router advertisement */ - case ICMP6_TYPE_RD: /* Redirect */ - case ICMP6_TYPE_PTB: /* Packet too big */ - nd6_input(p, inp); - return; - break; - case ICMP6_TYPE_RS: -#if LWIP_IPV6_FORWARD - /* TODO implement router functionality */ -#endif - break; -#if LWIP_IPV6_MLD - case ICMP6_TYPE_MLQ: - case ICMP6_TYPE_MLR: - case ICMP6_TYPE_MLD: - mld6_input(p, inp); - return; - break; -#endif - case ICMP6_TYPE_EREQ: -#if !LWIP_MULTICAST_PING - /* multicast destination address? */ - if (ip6_addr_ismulticast(ip6_current_dest_addr())) { - /* drop */ - pbuf_free(p); - ICMP6_STATS_INC(icmp6.drop); - return; - } -#endif /* LWIP_MULTICAST_PING */ - - /* Allocate reply. */ - r = pbuf_alloc(PBUF_IP, p->tot_len, PBUF_RAM); - if (r == NULL) { - /* drop */ - pbuf_free(p); - ICMP6_STATS_INC(icmp6.memerr); - return; - } - - /* Copy echo request. */ - if (pbuf_copy(r, p) != ERR_OK) { - /* drop */ - pbuf_free(p); - pbuf_free(r); - ICMP6_STATS_INC(icmp6.err); - return; - } - - /* Determine reply source IPv6 address. */ -#if LWIP_MULTICAST_PING - if (ip6_addr_ismulticast(ip6_current_dest_addr())) { - reply_src = ip6_select_source_address(inp, ip6_current_src_addr()); - if (reply_src == NULL) { - /* drop */ - pbuf_free(p); - pbuf_free(r); - ICMP6_STATS_INC(icmp6.rterr); - return; - } - } - else -#endif /* LWIP_MULTICAST_PING */ - { - reply_src = ip6_current_dest_addr(); - } - - /* Set fields in reply. */ - ((struct icmp6_echo_hdr *)(r->payload))->type = ICMP6_TYPE_EREP; - ((struct icmp6_echo_hdr *)(r->payload))->chksum = 0; - ((struct icmp6_echo_hdr *)(r->payload))->chksum = ip6_chksum_pseudo(r, - IP6_NEXTH_ICMP6, r->tot_len, reply_src, ip6_current_src_addr()); - - /* Send reply. */ - ICMP6_STATS_INC(icmp6.xmit); - ip6_output_if(r, reply_src, ip6_current_src_addr(), - LWIP_ICMP6_HL, 0, IP6_NEXTH_ICMP6, inp); - pbuf_free(r); - - break; - default: - ICMP6_STATS_INC(icmp6.proterr); - ICMP6_STATS_INC(icmp6.drop); - break; - } - - pbuf_free(p); -} - - -/** - * Send an icmpv6 'destination unreachable' packet. - * - * @param p the input packet for which the 'unreachable' should be sent, - * p->payload pointing to the IPv6 header - * @param c ICMPv6 code for the unreachable type - */ -void -icmp6_dest_unreach(struct pbuf *p, enum icmp6_dur_code c) -{ - icmp6_send_response(p, c, 0, ICMP6_TYPE_DUR); -} - -/** - * Send an icmpv6 'packet too big' packet. - * - * @param p the input packet for which the 'packet too big' should be sent, - * p->payload pointing to the IPv6 header - * @param mtu the maximum mtu that we can accept - */ -void -icmp6_packet_too_big(struct pbuf *p, u32_t mtu) -{ - icmp6_send_response(p, 0, mtu, ICMP6_TYPE_PTB); -} - -/** - * Send an icmpv6 'time exceeded' packet. - * - * @param p the input packet for which the 'unreachable' should be sent, - * p->payload pointing to the IPv6 header - * @param c ICMPv6 code for the time exceeded type - */ -void -icmp6_time_exceeded(struct pbuf *p, enum icmp6_te_code c) -{ - icmp6_send_response(p, c, 0, ICMP6_TYPE_TE); -} - -/** - * Send an icmpv6 'parameter problem' packet. - * - * @param p the input packet for which the 'param problem' should be sent, - * p->payload pointing to the IP header - * @param c ICMPv6 code for the param problem type - * @param pointer the pointer to the byte where the parameter is found - */ -void -icmp6_param_problem(struct pbuf *p, enum icmp6_pp_code c, u32_t pointer) -{ - icmp6_send_response(p, c, pointer, ICMP6_TYPE_PP); -} - -/** - * Send an ICMPv6 packet in response to an incoming packet. - * - * @param p the input packet for which the response should be sent, - * p->payload pointing to the IPv6 header - * @param code Code of the ICMPv6 header - * @param data Additional 32-bit parameter in the ICMPv6 header - * @param type Type of the ICMPv6 header - */ -static void -icmp6_send_response(struct pbuf *p, u8_t code, u32_t data, u8_t type) -{ - struct pbuf *q; - struct pp_icmp6_hdr *icmp6hdr; - ip6_addr_t *reply_src, *reply_dest; - ip6_addr_t reply_src_local, reply_dest_local; - struct ip6_hdr *ip6hdr; - struct netif *netif; - - /* ICMPv6 header + IPv6 header + data */ - q = pbuf_alloc(PBUF_IP, sizeof(struct pp_icmp6_hdr) + IP6_HLEN + LWIP_ICMP6_DATASIZE, - PBUF_RAM); - if (q == NULL) { - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded: failed to allocate pbuf for ICMPv6 packet.\n")); - ICMP6_STATS_INC(icmp6.memerr); - return; - } - LWIP_ASSERT("check that first pbuf can hold icmp 6message", - (q->len >= (sizeof(struct pp_icmp6_hdr) + IP6_HLEN + LWIP_ICMP6_DATASIZE))); - - icmp6hdr = (struct pp_icmp6_hdr *)q->payload; - icmp6hdr->type = type; - icmp6hdr->code = code; - icmp6hdr->data = data; - - /* copy fields from original packet */ - SMEMCPY((u8_t *)q->payload + sizeof(struct pp_icmp6_hdr), (u8_t *)p->payload, - IP6_HLEN + LWIP_ICMP6_DATASIZE); - - /* Get the destination address and netif for this ICMP message. */ - if ((ip_current_netif() == NULL) || - ((code == ICMP6_TE_FRAG) && (type == ICMP6_TYPE_TE))) { - /* Special case, as ip6_current_xxx is either NULL, or points - * to a different packet than the one that expired. - * We must use the addresses that are stored in the expired packet. */ - ip6hdr = (struct ip6_hdr *)p->payload; - /* copy from packed address to aligned address */ - ip6_addr_copy(reply_dest_local, ip6hdr->src); - ip6_addr_copy(reply_src_local, ip6hdr->dest); - reply_dest = &reply_dest_local; - reply_src = &reply_src_local; - netif = ip6_route(reply_src, reply_dest); - if (netif == NULL) { - /* drop */ - pbuf_free(q); - ICMP6_STATS_INC(icmp6.rterr); - return; - } - } - else { - netif = ip_current_netif(); - reply_dest = ip6_current_src_addr(); - - /* Select an address to use as source. */ - reply_src = ip6_select_source_address(netif, reply_dest); - if (reply_src == NULL) { - /* drop */ - pbuf_free(q); - ICMP6_STATS_INC(icmp6.rterr); - return; - } - } - - /* calculate checksum */ - icmp6hdr->chksum = 0; - icmp6hdr->chksum = ip6_chksum_pseudo(q, IP6_NEXTH_ICMP6, q->tot_len, - reply_src, reply_dest); - - ICMP6_STATS_INC(icmp6.xmit); - ip6_output_if(q, reply_src, reply_dest, LWIP_ICMP6_HL, 0, IP6_NEXTH_ICMP6, netif); - pbuf_free(q); -} - -#endif /* LWIP_ICMP6 && LWIP_IPV6 */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/ip6.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/ip6.c deleted file mode 100644 index 1eb91f96..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/ip6.c +++ /dev/null @@ -1,1034 +0,0 @@ -/** - * @file - * - * IPv6 layer. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - - -#include "lwip/opt.h" - -#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/netif.h" -#include "lwip/ip6.h" -#include "lwip/ip6_addr.h" -#include "lwip/ip6_frag.h" -#include "lwip/icmp6.h" -#include "lwip/raw.h" -#include "lwip/udp.h" -#include "lwip/tcp_impl.h" -#include "lwip/dhcp6.h" -#include "lwip/nd6.h" -#include "lwip/mld6.h" -#include "lwip/debug.h" -#include "lwip/stats.h" - - -/** - * Finds the appropriate network interface for a given IPv6 address. It tries to select - * a netif following a sequence of heuristics: - * 1) if there is only 1 netif, return it - * 2) if the destination is a link-local address, try to match the src address to a netif. - * this is a tricky case because with multiple netifs, link-local addresses only have - * meaning within a particular subnet/link. - * 3) tries to match the destination subnet to a configured address - * 4) tries to find a router - * 5) tries to match the source address to the netif - * 6) returns the default netif, if configured - * - * @param src the source IPv6 address, if known - * @param dest the destination IPv6 address for which to find the route - * @return the netif on which to send to reach dest - */ -struct netif * -ip6_route(struct ip6_addr *src, struct ip6_addr *dest) -{ - struct netif *netif; - s8_t i; - - /* If single netif configuration, fast return. */ - if ((netif_list != NULL) && (netif_list->next == NULL)) { - return netif_list; - } - - /* Special processing for link-local addresses. */ - if (ip6_addr_islinklocal(dest)) { - if (ip6_addr_isany(src)) { - /* Use default netif. */ - return netif_default; - } - - /* Try to find the netif for the source address. */ - for(netif = netif_list; netif != NULL; netif = netif->next) { - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && - ip6_addr_cmp(src, netif_ip6_addr(netif, i))) { - return netif; - } - } - } - - /* netif not found, use default netif */ - return netif_default; - } - - /* See if the destination subnet matches a configured address. */ - for(netif = netif_list; netif != NULL; netif = netif->next) { - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && - ip6_addr_netcmp(dest, netif_ip6_addr(netif, i))) { - return netif; - } - } - } - - /* Get the netif for a suitable router. */ - i = nd6_select_router(dest, NULL); - if (i >= 0) { - if (default_router_list[i].neighbor_entry != NULL) { - if (default_router_list[i].neighbor_entry->netif != NULL) { - return default_router_list[i].neighbor_entry->netif; - } - } - } - - /* try with the netif that matches the source address. */ - if (!ip6_addr_isany(src)) { - for(netif = netif_list; netif != NULL; netif = netif->next) { - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && - ip6_addr_cmp(src, netif_ip6_addr(netif, i))) { - return netif; - } - } - } - } - - /* no matching netif found, use default netif */ - return netif_default; -} - -/** - * Select the best IPv6 source address for a given destination - * IPv6 address. Loosely follows RFC 3484. "Strong host" behavior - * is assumed. - * - * @param netif the netif on which to send a packet - * @param dest the destination we are trying to reach - * @return the most suitable source address to use, or NULL if no suitable - * source address is found - */ -ip6_addr_t * -ip6_select_source_address(struct netif *netif, ip6_addr_t * dest) -{ - ip6_addr_t * src = NULL; - u8_t i; - - /* If dest is link-local, choose a link-local source. */ - if (ip6_addr_islinklocal(dest) || ip6_addr_ismulticast_linklocal(dest) || ip6_addr_ismulticast_iflocal(dest)) { - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && - ip6_addr_islinklocal(netif_ip6_addr(netif, i))) { - return netif_ip6_addr(netif, i); - } - } - } - - /* Choose a site-local with matching prefix. */ - if (ip6_addr_issitelocal(dest) || ip6_addr_ismulticast_sitelocal(dest)) { - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && - ip6_addr_issitelocal(netif_ip6_addr(netif, i)) && - ip6_addr_netcmp(dest, netif_ip6_addr(netif, i))) { - return netif_ip6_addr(netif, i); - } - } - } - - /* Choose a unique-local with matching prefix. */ - if (ip6_addr_isuniquelocal(dest) || ip6_addr_ismulticast_orglocal(dest)) { - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && - ip6_addr_isuniquelocal(netif_ip6_addr(netif, i)) && - ip6_addr_netcmp(dest, netif_ip6_addr(netif, i))) { - return netif_ip6_addr(netif, i); - } - } - } - - /* Choose a global with best matching prefix. */ - if (ip6_addr_isglobal(dest) || ip6_addr_ismulticast_global(dest)) { - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && - ip6_addr_isglobal(netif_ip6_addr(netif, i))) { - if (src == NULL) { - src = netif_ip6_addr(netif, i); - } - else { - /* Replace src only if we find a prefix match. */ - /* TODO find longest matching prefix. */ - if ((!(ip6_addr_netcmp(src, dest))) && - ip6_addr_netcmp(netif_ip6_addr(netif, i), dest)) { - src = netif_ip6_addr(netif, i); - } - } - } - } - if (src != NULL) { - return src; - } - } - - /* Last resort: see if arbitrary prefix matches. */ - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && - ip6_addr_netcmp(dest, netif_ip6_addr(netif, i))) { - return netif_ip6_addr(netif, i); - } - } - - return NULL; -} - -#if LWIP_IPV6_FORWARD -/** - * Forwards an IPv6 packet. It finds an appropriate route for the - * packet, decrements the HL value of the packet, and outputs - * the packet on the appropriate interface. - * - * @param p the packet to forward (p->payload points to IP header) - * @param iphdr the IPv6 header of the input packet - * @param inp the netif on which this packet was received - */ -static void -ip6_forward(struct pbuf *p, struct ip6_hdr *iphdr, struct netif *inp) -{ - struct netif *netif; - - /* do not forward link-local addresses */ - if (ip6_addr_islinklocal(ip6_current_dest_addr())) { - LWIP_DEBUGF(IP6_DEBUG, ("ip6_forward: not forwarding link-local address.\n")); - IP6_STATS_INC(ip6.rterr); - IP6_STATS_INC(ip6.drop); - return; - } - - /* Find network interface where to forward this IP packet to. */ - netif = ip6_route(IP6_ADDR_ANY, ip6_current_dest_addr()); - if (netif == NULL) { - LWIP_DEBUGF(IP6_DEBUG, ("ip6_forward: no route for %"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F"\n", - IP6_ADDR_BLOCK1(ip6_current_dest_addr()), - IP6_ADDR_BLOCK2(ip6_current_dest_addr()), - IP6_ADDR_BLOCK3(ip6_current_dest_addr()), - IP6_ADDR_BLOCK4(ip6_current_dest_addr()), - IP6_ADDR_BLOCK5(ip6_current_dest_addr()), - IP6_ADDR_BLOCK6(ip6_current_dest_addr()), - IP6_ADDR_BLOCK7(ip6_current_dest_addr()), - IP6_ADDR_BLOCK8(ip6_current_dest_addr()))); -#if LWIP_ICMP6 - /* Don't send ICMP messages in response to ICMP messages */ - if (IP6H_NEXTH(iphdr) != IP6_NEXTH_ICMP6) { - icmp6_dest_unreach(p, ICMP6_DUR_NO_ROUTE); - } -#endif /* LWIP_ICMP6 */ - IP6_STATS_INC(ip6.rterr); - IP6_STATS_INC(ip6.drop); - return; - } - /* Do not forward packets onto the same network interface on which - * they arrived. */ - if (netif == inp) { - LWIP_DEBUGF(IP6_DEBUG, ("ip6_forward: not bouncing packets back on incoming interface.\n")); - IP6_STATS_INC(ip6.rterr); - IP6_STATS_INC(ip6.drop); - return; - } - - /* decrement HL */ - IP6H_HOPLIM_SET(iphdr, IP6H_HOPLIM(iphdr) - 1); - /* send ICMP6 if HL == 0 */ - if (IP6H_HOPLIM(iphdr) == 0) { -#if LWIP_ICMP6 - /* Don't send ICMP messages in response to ICMP messages */ - if (IP6H_NEXTH(iphdr) != IP6_NEXTH_ICMP6) { - icmp6_time_exceeded(p, ICMP6_TE_HL); - } -#endif /* LWIP_ICMP6 */ - IP6_STATS_INC(ip6.drop); - return; - } - - if (netif->mtu && (p->tot_len > netif->mtu)) { -#if LWIP_ICMP6 - /* Don't send ICMP messages in response to ICMP messages */ - if (IP6H_NEXTH(iphdr) != IP6_NEXTH_ICMP6) { - icmp6_packet_too_big(p, netif->mtu); - } -#endif /* LWIP_ICMP6 */ - IP6_STATS_INC(ip6.drop); - return; - } - - LWIP_DEBUGF(IP6_DEBUG, ("ip6_forward: forwarding packet to %"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F"\n", - IP6_ADDR_BLOCK1(ip6_current_dest_addr()), - IP6_ADDR_BLOCK2(ip6_current_dest_addr()), - IP6_ADDR_BLOCK3(ip6_current_dest_addr()), - IP6_ADDR_BLOCK4(ip6_current_dest_addr()), - IP6_ADDR_BLOCK5(ip6_current_dest_addr()), - IP6_ADDR_BLOCK6(ip6_current_dest_addr()), - IP6_ADDR_BLOCK7(ip6_current_dest_addr()), - IP6_ADDR_BLOCK8(ip6_current_dest_addr()))); - - /* transmit pbuf on chosen interface */ - netif->output_ip6(netif, p, ip6_current_dest_addr()); - IP6_STATS_INC(ip6.fw); - IP6_STATS_INC(ip6.xmit); - return; -} -#endif /* LWIP_IPV6_FORWARD */ - - -/** - * This function is called by the network interface device driver when - * an IPv6 packet is received. The function does the basic checks of the - * IP header such as packet size being at least larger than the header - * size etc. If the packet was not destined for us, the packet is - * forwarded (using ip6_forward). - * - * Finally, the packet is sent to the upper layer protocol input function. - * - * @param p the received IPv6 packet (p->payload points to IPv6 header) - * @param inp the netif on which this packet was received - * @return ERR_OK if the packet was processed (could return ERR_* if it wasn't - * processed, but currently always returns ERR_OK) - */ -err_t -ip6_input(struct pbuf *p, struct netif *inp) -{ - struct ip6_hdr *ip6hdr; - struct netif *netif; - u8_t nexth; - u16_t hlen; /* the current header length */ - u8_t i; -#if 0 /*IP_ACCEPT_LINK_LAYER_ADDRESSING*/ - @todo - int check_ip_src=1; -#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ - - IP6_STATS_INC(ip6.recv); - - /* identify the IP header */ - ip6hdr = (struct ip6_hdr *)p->payload; - if (IP6H_V(ip6hdr) != 6) { - LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_WARNING, ("IPv6 packet dropped due to bad version number %"U32_F"\n", - IP6H_V(ip6hdr))); - pbuf_free(p); - IP6_STATS_INC(ip6.err); - IP6_STATS_INC(ip6.drop); - return ERR_OK; - } - - /* header length exceeds first pbuf length, or ip length exceeds total pbuf length? */ - if ((IP6_HLEN > p->len) || ((IP6H_PLEN(ip6hdr) + IP6_HLEN) > p->tot_len)) { - if (IP6_HLEN > p->len) { - LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("IPv6 header (len %"U16_F") does not fit in first pbuf (len %"U16_F"), IP packet dropped.\n", - IP6_HLEN, p->len)); - } - if ((IP6H_PLEN(ip6hdr) + IP6_HLEN) > p->tot_len) { - LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("IPv6 (plen %"U16_F") is longer than pbuf (len %"U16_F"), IP packet dropped.\n", - IP6H_PLEN(ip6hdr) + IP6_HLEN, p->tot_len)); - } - /* free (drop) packet pbufs */ - pbuf_free(p); - IP6_STATS_INC(ip6.lenerr); - IP6_STATS_INC(ip6.drop); - return ERR_OK; - } - - /* Trim pbuf. This should have been done at the netif layer, - * but we'll do it anyway just to be sure that its done. */ - pbuf_realloc(p, IP6_HLEN + IP6H_PLEN(ip6hdr)); - - /* copy IP addresses to aligned ip6_addr_t */ - ip6_addr_copy(ip_data.current_iphdr_dest.ip6, ip6hdr->dest); - ip6_addr_copy(ip_data.current_iphdr_src.ip6, ip6hdr->src); - - /* current header pointer. */ - ip_data.current_ip6_header = ip6hdr; - - /* In netif, used in case we need to send ICMPv6 packets back. */ - ip_data.current_netif = inp; - - /* match packet against an interface, i.e. is this packet for us? */ - if (ip6_addr_ismulticast(ip6_current_dest_addr())) { - /* Always joined to multicast if-local and link-local all-nodes group. */ - if (ip6_addr_isallnodes_iflocal(ip6_current_dest_addr()) || - ip6_addr_isallnodes_linklocal(ip6_current_dest_addr())) { - netif = inp; - } -#if LWIP_IPV6_MLD - else if (mld6_lookfor_group(inp, ip6_current_dest_addr())) { - netif = inp; - } -#else /* LWIP_IPV6_MLD */ - else if (ip6_addr_issolicitednode(ip6_current_dest_addr())) { - /* Filter solicited node packets when MLD is not enabled - * (for Neighbor discovery). */ - netif = NULL; - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_isvalid(netif_ip6_addr_state(inp, i)) && - ip6_addr_cmp_solicitednode(ip6_current_dest_addr(), netif_ip6_addr(inp, i))) { - netif = inp; - LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: solicited node packet accepted on interface %c%c\n", - netif->name[0], netif->name[1])); - break; - } - } - } -#endif /* LWIP_IPV6_MLD */ - else { - netif = NULL; - } - } - else { - /* start trying with inp. if that's not acceptable, start walking the - list of configured netifs. - 'first' is used as a boolean to mark whether we started walking the list */ - int first = 1; - netif = inp; - do { - /* interface is up? */ - if (netif_is_up(netif)) { - /* unicast to this interface address? address configured? */ - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && - ip6_addr_cmp(ip6_current_dest_addr(), netif_ip6_addr(netif, i))) { - /* exit outer loop */ - goto netif_found; - } - } - } - if (ip6_addr_islinklocal(ip6_current_dest_addr())) { - /* Do not match link-local addresses to other netifs. */ - netif = NULL; - break; - } - if (first) { - first = 0; - netif = netif_list; - } else { - netif = netif->next; - } - if (netif == inp) { - netif = netif->next; - } - } while(netif != NULL); -netif_found: - LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: packet accepted on interface %c%c\n", - netif ? netif->name[0] : 'X', netif? netif->name[1] : 'X')); - } - - /* "::" packet source address? (used in duplicate address detection) */ - if (ip6_addr_isany(ip6_current_src_addr()) && - (!ip6_addr_issolicitednode(ip6_current_dest_addr()))) { - /* packet source is not valid */ - /* free (drop) packet pbufs */ - LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: packet with src ANY_ADDRESS dropped\n")); - pbuf_free(p); - IP6_STATS_INC(ip6.drop); - goto ip6_input_cleanup; - } - - /* if we're pretending we are everyone for TCP, assume the packet is for source interface if it - isn't for a local address */ - if (netif == NULL && (inp->flags & NETIF_FLAG_PRETEND_TCP) && IP6H_NEXTH(ip6hdr) == IP6_NEXTH_TCP) { - netif = inp; - } - - /* packet not for us? */ - if (netif == NULL) { - /* packet not for us, route or discard */ - LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_TRACE, ("ip6_input: packet not for us.\n")); -#if LWIP_IPV6_FORWARD - /* non-multicast packet? */ - if (!ip6_addr_ismulticast(ip6_current_dest_addr())) { - /* try to forward IP packet on (other) interfaces */ - ip6_forward(p, ip6hdr, inp); - } -#endif /* LWIP_IPV6_FORWARD */ - pbuf_free(p); - goto ip6_input_cleanup; - } - - /* current netif pointer. */ - ip_data.current_netif = netif; - - /* Save next header type. */ - nexth = IP6H_NEXTH(ip6hdr); - - /* Init header length. */ - hlen = ip_data.current_ip_header_tot_len = IP6_HLEN; - - /* Move to payload. */ - pbuf_header(p, -IP6_HLEN); - - /* Process known option extension headers, if present. */ - while (nexth != IP6_NEXTH_NONE) - { - switch (nexth) { - case IP6_NEXTH_HOPBYHOP: - LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: packet with Hop-by-Hop options header\n")); - /* Get next header type. */ - nexth = *((u8_t *)p->payload); - - /* Get the header length. */ - hlen = 8 * (1 + *((u8_t *)p->payload + 1)); - ip_data.current_ip_header_tot_len += hlen; - - /* Skip over this header. */ - if (hlen > p->len) { - LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n", - hlen, p->len)); - /* free (drop) packet pbufs */ - pbuf_free(p); - IP6_STATS_INC(ip6.lenerr); - IP6_STATS_INC(ip6.drop); - goto ip6_input_cleanup; - } - - pbuf_header(p, -hlen); - break; - case IP6_NEXTH_DESTOPTS: - LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: packet with Destination options header\n")); - /* Get next header type. */ - nexth = *((u8_t *)p->payload); - - /* Get the header length. */ - hlen = 8 * (1 + *((u8_t *)p->payload + 1)); - ip_data.current_ip_header_tot_len += hlen; - - /* Skip over this header. */ - if (hlen > p->len) { - LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n", - hlen, p->len)); - /* free (drop) packet pbufs */ - pbuf_free(p); - IP6_STATS_INC(ip6.lenerr); - IP6_STATS_INC(ip6.drop); - goto ip6_input_cleanup; - } - - pbuf_header(p, -hlen); - break; - case IP6_NEXTH_ROUTING: - LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: packet with Routing header\n")); - /* Get next header type. */ - nexth = *((u8_t *)p->payload); - - /* Get the header length. */ - hlen = 8 * (1 + *((u8_t *)p->payload + 1)); - ip_data.current_ip_header_tot_len += hlen; - - /* Skip over this header. */ - if (hlen > p->len) { - LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n", - hlen, p->len)); - /* free (drop) packet pbufs */ - pbuf_free(p); - IP6_STATS_INC(ip6.lenerr); - IP6_STATS_INC(ip6.drop); - goto ip6_input_cleanup; - } - - pbuf_header(p, -hlen); - break; - - case IP6_NEXTH_FRAGMENT: - { - struct ip6_frag_hdr * frag_hdr; - LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: packet with Fragment header\n")); - - frag_hdr = (struct ip6_frag_hdr *)p->payload; - - /* Get next header type. */ - nexth = frag_hdr->_nexth; - - /* Fragment Header length. */ - hlen = 8; - ip_data.current_ip_header_tot_len += hlen; - - /* Make sure this header fits in current pbuf. */ - if (hlen > p->len) { - LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("IPv6 options header (hlen %"U16_F") does not fit in first pbuf (len %"U16_F"), IPv6 packet dropped.\n", - hlen, p->len)); - /* free (drop) packet pbufs */ - pbuf_free(p); - IP6_FRAG_STATS_INC(ip6_frag.lenerr); - IP6_FRAG_STATS_INC(ip6_frag.drop); - goto ip6_input_cleanup; - } - - /* Offset == 0 and more_fragments == 0? */ - if (((frag_hdr->_fragment_offset & IP6_FRAG_OFFSET_MASK) == 0) && - ((frag_hdr->_fragment_offset & IP6_FRAG_MORE_FLAG) == 0)) { - - /* This is a 1-fragment packet, usually a packet that we have - * already reassembled. Skip this header anc continue. */ - pbuf_header(p, -hlen); - } - else { -#if LWIP_IPV6_REASS - - /* reassemble the packet */ - p = ip6_reass(p); - /* packet not fully reassembled yet? */ - if (p == NULL) { - goto ip6_input_cleanup; - } - - /* Returned p point to IPv6 header. - * Update all our variables and pointers and continue. */ - ip6hdr = (struct ip6_hdr *)p->payload; - nexth = IP6H_NEXTH(ip6hdr); - hlen = ip_data.current_ip_header_tot_len = IP6_HLEN; - pbuf_header(p, -IP6_HLEN); - -#else /* LWIP_IPV6_REASS */ - /* free (drop) packet pbufs */ - LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: packet with Fragment header dropped (with LWIP_IPV6_REASS==0)\n")); - pbuf_free(p); - IP6_STATS_INC(ip6.opterr); - IP6_STATS_INC(ip6.drop); - goto ip6_input_cleanup; -#endif /* LWIP_IPV6_REASS */ - } - break; - } - default: - goto options_done; - break; - } - } -options_done: - - /* p points to IPv6 header again. */ - pbuf_header(p, ip_data.current_ip_header_tot_len); - - /* send to upper layers */ - LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: \n")); - ip6_debug_print(p); - LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len)); - -#if LWIP_RAW - /* raw input did not eat the packet? */ - if (raw_input(p, inp) == 0) -#endif /* LWIP_RAW */ - { - switch (nexth) { - case IP6_NEXTH_NONE: - pbuf_free(p); - break; -#if LWIP_UDP - case IP6_NEXTH_UDP: -#if LWIP_UDPLITE - case IP6_NEXTH_UDPLITE: -#endif /* LWIP_UDPLITE */ - /* Point to payload. */ - pbuf_header(p, -ip_data.current_ip_header_tot_len); - udp_input(p, inp); - break; -#endif /* LWIP_UDP */ -#if LWIP_TCP - case IP6_NEXTH_TCP: - /* Point to payload. */ - pbuf_header(p, -ip_data.current_ip_header_tot_len); - tcp_input(p, inp); - break; -#endif /* LWIP_TCP */ -#if LWIP_ICMP6 - case IP6_NEXTH_ICMP6: - /* Point to payload. */ - pbuf_header(p, -ip_data.current_ip_header_tot_len); - icmp6_input(p, inp); - break; -#endif /* LWIP_ICMP */ - default: -#if LWIP_ICMP6 - /* send ICMP parameter problem unless it was a multicast or ICMPv6 */ - if ((!ip6_addr_ismulticast(ip6_current_dest_addr())) && - (IP6H_NEXTH(ip6hdr) != IP6_NEXTH_ICMP6)) { - icmp6_param_problem(p, ICMP6_PP_HEADER, ip_data.current_ip_header_tot_len - hlen); - } -#endif /* LWIP_ICMP */ - LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip6_input: Unsupported transport protocol %"U16_F"\n", IP6H_NEXTH(ip6hdr))); - pbuf_free(p); - IP6_STATS_INC(ip6.proterr); - IP6_STATS_INC(ip6.drop); - break; - } - } - -ip6_input_cleanup: - ip_data.current_netif = NULL; - ip_data.current_ip6_header = NULL; - ip_data.current_ip_header_tot_len = 0; - ip6_addr_set_any(&ip_data.current_iphdr_src.ip6); - ip6_addr_set_any(&ip_data.current_iphdr_dest.ip6); - - return ERR_OK; -} - - -/** - * Sends an IPv6 packet on a network interface. This function constructs - * the IPv6 header. If the source IPv6 address is NULL, the IPv6 "ANY" address is - * used as source (usually during network startup). If the source IPv6 address it - * IP6_ADDR_ANY, the most appropriate IPv6 address of the outgoing network - * interface is filled in as source address. If the destination IPv6 address is - * IP_HDRINCL, p is assumed to already include an IPv6 header and p->payload points - * to it instead of the data. - * - * @param p the packet to send (p->payload points to the data, e.g. next - protocol header; if dest == IP_HDRINCL, p already includes an - IPv6 header and p->payload points to that IPv6 header) - * @param src the source IPv6 address to send from (if src == IP6_ADDR_ANY, an - * IP address of the netif is selected and used as source address. - * if src == NULL, IP6_ADDR_ANY is used as source) - * @param dest the destination IPv6 address to send the packet to - * @param hl the Hop Limit value to be set in the IPv6 header - * @param tc the Traffic Class value to be set in the IPv6 header - * @param nexth the Next Header to be set in the IPv6 header - * @param netif the netif on which to send this packet - * @return ERR_OK if the packet was sent OK - * ERR_BUF if p doesn't have enough space for IPv6/LINK headers - * returns errors returned by netif->output - */ -err_t -ip6_output_if(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest, - u8_t hl, u8_t tc, - u8_t nexth, struct netif *netif) -{ - struct ip6_hdr *ip6hdr; - ip6_addr_t dest_addr; - - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); - - /* Should the IPv6 header be generated or is it already included in p? */ - if (dest != IP_HDRINCL) { - /* generate IPv6 header */ - if (pbuf_header(p, IP6_HLEN)) { - LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip6_output: not enough room for IPv6 header in pbuf\n")); - IP6_STATS_INC(ip6.err); - return ERR_BUF; - } - - ip6hdr = (struct ip6_hdr *)p->payload; - LWIP_ASSERT("check that first pbuf can hold struct ip6_hdr", - (p->len >= sizeof(struct ip6_hdr))); - - IP6H_HOPLIM_SET(ip6hdr, hl); - IP6H_NEXTH_SET(ip6hdr, nexth); - - /* dest cannot be NULL here */ - ip6_addr_copy(ip6hdr->dest, *dest); - - IP6H_VTCFL_SET(ip6hdr, 6, tc, 0); - IP6H_PLEN_SET(ip6hdr, p->tot_len - IP6_HLEN); - - if (src == NULL) { - src = IP6_ADDR_ANY; - } - else if (ip6_addr_isany(src)) { - src = ip6_select_source_address(netif, dest); - if ((src == NULL) || ip6_addr_isany(src)) { - /* No appropriate source address was found for this packet. */ - LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip6_output: No suitable source address for packet.\n")); - IP6_STATS_INC(ip6.rterr); - return ERR_RTE; - } - } - /* src cannot be NULL here */ - ip6_addr_copy(ip6hdr->src, *src); - - } else { - /* IP header already included in p */ - ip6hdr = (struct ip6_hdr *)p->payload; - ip6_addr_copy(dest_addr, ip6hdr->dest); - dest = &dest_addr; - } - - IP6_STATS_INC(ip6.xmit); - - LWIP_DEBUGF(IP6_DEBUG, ("ip6_output_if: %c%c%"U16_F"\n", netif->name[0], netif->name[1], netif->num)); - ip6_debug_print(p); - -#if ENABLE_LOOPBACK - /* TODO implement loopback for v6 - if (ip6_addr_cmp(dest, netif_ip6_addr(0))) { - return netif_loop_output(netif, p, dest); - }*/ -#endif /* ENABLE_LOOPBACK */ -#if LWIP_IPV6_FRAG - /* don't fragment if interface has mtu set to 0 [loopif] */ - if (netif->mtu && (p->tot_len > nd6_get_destination_mtu(dest, netif))) { - return ip6_frag(p, netif, dest); - } -#endif /* LWIP_IPV6_FRAG */ - - LWIP_DEBUGF(IP6_DEBUG, ("netif->output_ip6()")); - return netif->output_ip6(netif, p, dest); -} - -/** - * Simple interface to ip6_output_if. It finds the outgoing network - * interface and calls upon ip6_output_if to do the actual work. - * - * @param p the packet to send (p->payload points to the data, e.g. next - protocol header; if dest == IP_HDRINCL, p already includes an - IPv6 header and p->payload points to that IPv6 header) - * @param src the source IPv6 address to send from (if src == IP6_ADDR_ANY, an - * IP address of the netif is selected and used as source address. - * if src == NULL, IP6_ADDR_ANY is used as source) - * @param dest the destination IPv6 address to send the packet to - * @param hl the Hop Limit value to be set in the IPv6 header - * @param tc the Traffic Class value to be set in the IPv6 header - * @param nexth the Next Header to be set in the IPv6 header - * - * @return ERR_RTE if no route is found - * see ip_output_if() for more return values - */ -err_t -ip6_output(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest, - u8_t hl, u8_t tc, u8_t nexth) -{ - struct netif *netif; - struct ip6_hdr *ip6hdr; - ip6_addr_t src_addr, dest_addr; - - /* pbufs passed to IPv6 must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); - - if (dest != IP_HDRINCL) { - netif = ip6_route(src, dest); - } else { - /* IP header included in p, read addresses. */ - ip6hdr = (struct ip6_hdr *)p->payload; - ip6_addr_copy(src_addr, ip6hdr->src); - ip6_addr_copy(dest_addr, ip6hdr->dest); - netif = ip6_route(&src_addr, &dest_addr); - } - - if (netif == NULL) { - LWIP_DEBUGF(IP6_DEBUG, ("ip6_output: no route for %"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F"\n", - IP6_ADDR_BLOCK1(dest), - IP6_ADDR_BLOCK2(dest), - IP6_ADDR_BLOCK3(dest), - IP6_ADDR_BLOCK4(dest), - IP6_ADDR_BLOCK5(dest), - IP6_ADDR_BLOCK6(dest), - IP6_ADDR_BLOCK7(dest), - IP6_ADDR_BLOCK8(dest))); - IP6_STATS_INC(ip6.rterr); - return ERR_RTE; - } - - return ip6_output_if(p, src, dest, hl, tc, nexth, netif); -} - - -#if LWIP_NETIF_HWADDRHINT -/** Like ip6_output, but takes and addr_hint pointer that is passed on to netif->addr_hint - * before calling ip6_output_if. - * - * @param p the packet to send (p->payload points to the data, e.g. next - protocol header; if dest == IP_HDRINCL, p already includes an - IPv6 header and p->payload points to that IPv6 header) - * @param src the source IPv6 address to send from (if src == IP6_ADDR_ANY, an - * IP address of the netif is selected and used as source address. - * if src == NULL, IP6_ADDR_ANY is used as source) - * @param dest the destination IPv6 address to send the packet to - * @param hl the Hop Limit value to be set in the IPv6 header - * @param tc the Traffic Class value to be set in the IPv6 header - * @param nexth the Next Header to be set in the IPv6 header - * @param addr_hint address hint pointer set to netif->addr_hint before - * calling ip_output_if() - * - * @return ERR_RTE if no route is found - * see ip_output_if() for more return values - */ -err_t -ip6_output_hinted(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest, - u8_t hl, u8_t tc, u8_t nexth, u8_t *addr_hint) -{ - struct netif *netif; - struct ip6_hdr *ip6hdr; - ip6_addr_t src_addr, dest_addr; - err_t err; - - /* pbufs passed to IP must have a ref-count of 1 as their payload pointer - gets altered as the packet is passed down the stack */ - LWIP_ASSERT("p->ref == 1", p->ref == 1); - - if (dest != IP_HDRINCL) { - netif = ip6_route(src, dest); - } else { - /* IP header included in p, read addresses. */ - ip6hdr = (struct ip6_hdr *)p->payload; - ip6_addr_copy(src_addr, ip6hdr->src); - ip6_addr_copy(dest_addr, ip6hdr->dest); - netif = ip6_route(&src_addr, &dest_addr); - } - - if (netif == NULL) { - LWIP_DEBUGF(IP6_DEBUG, ("ip6_output: no route for %"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F"\n", - IP6_ADDR_BLOCK1(dest), - IP6_ADDR_BLOCK2(dest), - IP6_ADDR_BLOCK3(dest), - IP6_ADDR_BLOCK4(dest), - IP6_ADDR_BLOCK5(dest), - IP6_ADDR_BLOCK6(dest), - IP6_ADDR_BLOCK7(dest), - IP6_ADDR_BLOCK8(dest))); - IP6_STATS_INC(ip6.rterr); - return ERR_RTE; - } - - NETIF_SET_HWADDRHINT(netif, addr_hint); - err = ip6_output_if(p, src, dest, hl, tc, nexth, netif); - NETIF_SET_HWADDRHINT(netif, NULL); - - return err; -} -#endif /* LWIP_NETIF_HWADDRHINT*/ - -#if LWIP_IPV6_MLD -/** - * Add a hop-by-hop options header with a router alert option and padding. - * - * Used by MLD when sending a Multicast listener report/done message. - * - * @param p the packet to which we will prepend the options header - * @param nexth the next header protocol number (e.g. IP6_NEXTH_ICMP6) - * @param value the value of the router alert option data (e.g. IP6_ROUTER_ALERT_VALUE_MLD) - * @return ERR_OK if hop-by-hop header was added, ERR_* otherwise - */ -err_t -ip6_options_add_hbh_ra(struct pbuf * p, u8_t nexth, u8_t value) -{ - struct ip6_hbh_hdr * hbh_hdr; - - /* Move pointer to make room for hop-by-hop options header. */ - if (pbuf_header(p, sizeof(struct ip6_hbh_hdr))) { - LWIP_DEBUGF(IP6_DEBUG, ("ip6_options: no space for options header\n")); - IP6_STATS_INC(ip6.err); - return ERR_BUF; - } - - hbh_hdr = (struct ip6_hbh_hdr *)p->payload; - - /* Set fields. */ - hbh_hdr->_nexth = nexth; - hbh_hdr->_hlen = 0; - hbh_hdr->_ra_opt_type = IP6_ROUTER_ALERT_OPTION; - hbh_hdr->_ra_opt_dlen = 2; - hbh_hdr->_ra_opt_data = value; - hbh_hdr->_padn_opt_type = IP6_PADN_ALERT_OPTION; - hbh_hdr->_padn_opt_dlen = 0; - - return ERR_OK; -} -#endif /* LWIP_IPV6_MLD */ - -#if IP6_DEBUG -/* Print an IPv6 header by using LWIP_DEBUGF - * @param p an IPv6 packet, p->payload pointing to the IPv6 header - */ -void -ip6_debug_print(struct pbuf *p) -{ - struct ip6_hdr *ip6hdr = (struct ip6_hdr *)p->payload; - - LWIP_DEBUGF(IP6_DEBUG, ("IPv6 header:\n")); - LWIP_DEBUGF(IP6_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP6_DEBUG, ("| %2"U16_F" | %3"U16_F" | %7"U32_F" | (ver, class, flow)\n", - IP6H_V(ip6hdr), - IP6H_TC(ip6hdr), - IP6H_FL(ip6hdr))); - LWIP_DEBUGF(IP6_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP6_DEBUG, ("| %5"U16_F" | %3"U16_F" | %3"U16_F" | (plen, nexth, hopl)\n", - IP6H_PLEN(ip6hdr), - IP6H_NEXTH(ip6hdr), - IP6H_HOPLIM(ip6hdr))); - LWIP_DEBUGF(IP6_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP6_DEBUG, ("| %4"X32_F" | %4"X32_F" | %4"X32_F" | %4"X32_F" | (src)\n", - IP6_ADDR_BLOCK1(&(ip6hdr->src)), - IP6_ADDR_BLOCK2(&(ip6hdr->src)), - IP6_ADDR_BLOCK3(&(ip6hdr->src)), - IP6_ADDR_BLOCK4(&(ip6hdr->src)))); - LWIP_DEBUGF(IP6_DEBUG, ("| %4"X32_F" | %4"X32_F" | %4"X32_F" | %4"X32_F" |\n", - IP6_ADDR_BLOCK5(&(ip6hdr->src)), - IP6_ADDR_BLOCK6(&(ip6hdr->src)), - IP6_ADDR_BLOCK7(&(ip6hdr->src)), - IP6_ADDR_BLOCK8(&(ip6hdr->src)))); - LWIP_DEBUGF(IP6_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(IP6_DEBUG, ("| %4"X32_F" | %4"X32_F" | %4"X32_F" | %4"X32_F" | (dest)\n", - IP6_ADDR_BLOCK1(&(ip6hdr->dest)), - IP6_ADDR_BLOCK2(&(ip6hdr->dest)), - IP6_ADDR_BLOCK3(&(ip6hdr->dest)), - IP6_ADDR_BLOCK4(&(ip6hdr->dest)))); - LWIP_DEBUGF(IP6_DEBUG, ("| %4"X32_F" | %4"X32_F" | %4"X32_F" | %4"X32_F" |\n", - IP6_ADDR_BLOCK5(&(ip6hdr->dest)), - IP6_ADDR_BLOCK6(&(ip6hdr->dest)), - IP6_ADDR_BLOCK7(&(ip6hdr->dest)), - IP6_ADDR_BLOCK8(&(ip6hdr->dest)))); - LWIP_DEBUGF(IP6_DEBUG, ("+-------------------------------+\n")); -} -#endif /* IP6_DEBUG */ - -#endif /* LWIP_IPV6 */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/ip6_addr.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/ip6_addr.c deleted file mode 100644 index 65d27980..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/ip6_addr.c +++ /dev/null @@ -1,251 +0,0 @@ -/** - * @file - * - * IPv6 addresses. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * Functions for handling IPv6 addresses. - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#include "lwip/opt.h" - -#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/ip6_addr.h" -#include "lwip/def.h" - -/* used by IP6_ADDR_ANY in ip6_addr.h */ -const ip6_addr_t ip6_addr_any = { { 0ul, 0ul, 0ul, 0ul } }; - -#ifndef isprint -#define in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up) -#define isprint(c) in_range(c, 0x20, 0x7f) -#define isdigit(c) in_range(c, '0', '9') -#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F')) -#define islower(c) in_range(c, 'a', 'z') -#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v') -#define xchar(i) ((i) < 10 ? '0' + (i) : 'A' + (i) - 10) -#endif - -/** - * Check whether "cp" is a valid ascii representation - * of an IPv6 address and convert to a binary address. - * Returns 1 if the address is valid, 0 if not. - * - * @param cp IPv6 address in ascii represenation (e.g. "FF01::1") - * @param addr pointer to which to save the ip address in network order - * @return 1 if cp could be converted to addr, 0 on failure - */ -int -ip6addr_aton(const char *cp, ip6_addr_t *addr) -{ - u32_t addr_index, zero_blocks, current_block_index, current_block_value; - const char * s; - - /* Count the number of colons, to count the number of blocks in a "::" sequence - zero_blocks may be 1 even if there are no :: sequences */ - zero_blocks = 8; - for (s = cp; *s != 0; s++) { - if (*s == ':') - zero_blocks--; - else if (!isxdigit(*s)) - break; - } - - /* parse each block */ - addr_index = 0; - current_block_index = 0; - current_block_value = 0; - for (s = cp; *s != 0; s++) { - if (*s == ':') { - if (addr) { - if (current_block_index & 0x1) { - addr->addr[addr_index++] |= current_block_value; - } - else { - addr->addr[addr_index] = current_block_value << 16; - } - } - current_block_index++; - current_block_value = 0; - if (current_block_index > 7) { - /* address too long! */ - return 0; - } if (s[1] == ':') { - s++; - /* "::" found, set zeros */ - while (zero_blocks-- > 0) { - if (current_block_index & 0x1) { - addr_index++; - } - else { - if (addr) { - addr->addr[addr_index] = 0; - } - } - current_block_index++; - } - } - } else if (isxdigit(*s)) { - /* add current digit */ - current_block_value = (current_block_value << 4) + - (isdigit(*s) ? *s - '0' : - 10 + (islower(*s) ? *s - 'a' : *s - 'A')); - } else { - /* unexpected digit, space? CRLF? */ - break; - } - } - - if (addr) { - if (current_block_index & 0x1) { - addr->addr[addr_index++] |= current_block_value; - } - else { - addr->addr[addr_index] = current_block_value << 16; - } - } - - /* convert to network byte order. */ - if (addr) { - for (addr_index = 0; addr_index < 4; addr_index++) { - addr->addr[addr_index] = htonl(addr->addr[addr_index]); - } - } - - if (current_block_index != 7) { - return 0; - } - - return 1; -} - -/** - * Convert numeric IPv6 address into ASCII representation. - * returns ptr to static buffer; not reentrant! - * - * @param addr ip6 address in network order to convert - * @return pointer to a global static (!) buffer that holds the ASCII - * represenation of addr - */ -char * -ip6addr_ntoa(const ip6_addr_t *addr) -{ - static char str[40]; - return ip6addr_ntoa_r(addr, str, 40); -} - -/** - * Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used. - * - * @param addr ip6 address in network order to convert - * @param buf target buffer where the string is stored - * @param buflen length of buf - * @return either pointer to buf which now holds the ASCII - * representation of addr or NULL if buf was too small - */ -char * -ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen) -{ - u32_t current_block_index, current_block_value; - s32_t zero_flag, i; - - i = 0; - zero_flag = 0; /* used to indicate a zero chain for "::' */ - - for (current_block_index = 0; current_block_index < 8; current_block_index++) { - /* get the current 16-bit block */ - current_block_value = htonl(addr->addr[current_block_index >> 1]); - if ((current_block_index & 0x1) == 0) { - current_block_value = current_block_value >> 16; - } - current_block_value &= 0xffff; - - if (current_block_value == 0) { - /* generate empty block "::" */ - if (!zero_flag) { - if (current_block_index > 0) { - zero_flag = 1; - buf[i++] = ':'; - if (i >= buflen) return NULL; - } - } - } - else { - if (current_block_index > 0) { - buf[i++] = ':'; - if (i >= buflen) return NULL; - } - - if ((current_block_value & 0xf000) == 0) { - zero_flag = 1; - } - else { - buf[i++] = xchar(((current_block_value & 0xf000) >> 12)); - zero_flag = 0; - if (i >= buflen) return NULL; - } - - if (((current_block_value & 0xf00) == 0) && (zero_flag)) { - /* do nothing */ - } - else { - buf[i++] = xchar(((current_block_value & 0xf00) >> 8)); - zero_flag = 0; - if (i >= buflen) return NULL; - } - - if (((current_block_value & 0xf0) == 0) && (zero_flag)) { - /* do nothing */ - } - else { - buf[i++] = xchar(((current_block_value & 0xf0) >> 4)); - zero_flag = 0; - if (i >= buflen) return NULL; - } - - buf[i++] = xchar((current_block_value & 0xf)); - if (i >= buflen) return NULL; - - zero_flag = 0; - } - } - - buf[i] = 0; - - return buf; -} -#endif /* LWIP_IPV6 */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/ip6_frag.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/ip6_frag.c deleted file mode 100644 index a43fd614..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/ip6_frag.c +++ /dev/null @@ -1,697 +0,0 @@ -/** - * @file - * - * IPv6 fragmentation and reassembly. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#include "lwip/opt.h" -#include "lwip/ip6_frag.h" -#include "lwip/ip6.h" -#include "lwip/icmp6.h" -#include "lwip/nd6.h" - -#include "lwip/pbuf.h" -#include "lwip/memp.h" -#include "lwip/stats.h" - -#include - -#if LWIP_IPV6 && LWIP_IPV6_REASS /* don't build if not configured for use in lwipopts.h */ - - -/** Setting this to 0, you can turn off checking the fragments for overlapping - * regions. The code gets a little smaller. Only use this if you know that - * overlapping won't occur on your network! */ -#ifndef IP_REASS_CHECK_OVERLAP -#define IP_REASS_CHECK_OVERLAP 1 -#endif /* IP_REASS_CHECK_OVERLAP */ - -/** Set to 0 to prevent freeing the oldest datagram when the reassembly buffer is - * full (IP_REASS_MAX_PBUFS pbufs are enqueued). The code gets a little smaller. - * Datagrams will be freed by timeout only. Especially useful when MEMP_NUM_REASSDATA - * is set to 1, so one datagram can be reassembled at a time, only. */ -#ifndef IP_REASS_FREE_OLDEST -#define IP_REASS_FREE_OLDEST 1 -#endif /* IP_REASS_FREE_OLDEST */ - -#define IP_REASS_FLAG_LASTFRAG 0x01 - -/** This is a helper struct which holds the starting - * offset and the ending offset of this fragment to - * easily chain the fragments. - * It has the same packing requirements as the IPv6 header, since it replaces - * the Fragment Header in memory in incoming fragments to keep - * track of the various fragments. - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip6_reass_helper { - PACK_STRUCT_FIELD(struct pbuf *next_pbuf); - PACK_STRUCT_FIELD(u16_t start); - PACK_STRUCT_FIELD(u16_t end); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* static variables */ -static struct ip6_reassdata *reassdatagrams; -static u16_t ip6_reass_pbufcount; - -/* Forward declarations. */ -static void ip6_reass_free_complete_datagram(struct ip6_reassdata *ipr); -#if IP_REASS_FREE_OLDEST -static void ip6_reass_remove_oldest_datagram(struct ip6_reassdata *ipr, int pbufs_needed); -#endif /* IP_REASS_FREE_OLDEST */ - -void -ip6_reass_tmr(void) -{ - struct ip6_reassdata *r, *tmp; - - r = reassdatagrams; - while (r != NULL) { - /* Decrement the timer. Once it reaches 0, - * clean up the incomplete fragment assembly */ - if (r->timer > 0) { - r->timer--; - r = r->next; - } else { - /* reassembly timed out */ - tmp = r; - /* get the next pointer before freeing */ - r = r->next; - /* free the helper struct and all enqueued pbufs */ - ip6_reass_free_complete_datagram(tmp); - } - } -} - -/** - * Free a datagram (struct ip6_reassdata) and all its pbufs. - * Updates the total count of enqueued pbufs (ip6_reass_pbufcount), - * sends an ICMP time exceeded packet. - * - * @param ipr datagram to free - */ -static void -ip6_reass_free_complete_datagram(struct ip6_reassdata *ipr) -{ - struct ip6_reassdata *prev; - u16_t pbufs_freed = 0; - u8_t clen; - struct pbuf *p; - struct ip6_reass_helper *iprh; - -#if LWIP_ICMP6 - iprh = (struct ip6_reass_helper *)ipr->p->payload; - if (iprh->start == 0) { - /* The first fragment was received, send ICMP time exceeded. */ - /* First, de-queue the first pbuf from r->p. */ - p = ipr->p; - ipr->p = iprh->next_pbuf; - /* Then, move back to the original header (we are now pointing to Fragment header). */ - if (pbuf_header(p, (u8_t*)p->payload - (u8_t*)ipr->iphdr)) { - LWIP_ASSERT("ip6_reass_free: moving p->payload to ip6 header failed\n", 0); - } - else { - icmp6_time_exceeded(p, ICMP6_TE_FRAG); - } - clen = pbuf_clen(p); - LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff); - pbufs_freed += clen; - pbuf_free(p); - } -#endif /* LWIP_ICMP6 */ - - /* First, free all received pbufs. The individual pbufs need to be released - separately as they have not yet been chained */ - p = ipr->p; - while (p != NULL) { - struct pbuf *pcur; - iprh = (struct ip6_reass_helper *)p->payload; - pcur = p; - /* get the next pointer before freeing */ - p = iprh->next_pbuf; - clen = pbuf_clen(pcur); - LWIP_ASSERT("pbufs_freed + clen <= 0xffff", pbufs_freed + clen <= 0xffff); - pbufs_freed += clen; - pbuf_free(pcur); - } - - /* Then, unchain the struct ip6_reassdata from the list and free it. */ - if (ipr == reassdatagrams) { - reassdatagrams = ipr->next; - } else { - prev = reassdatagrams; - while (prev != NULL) { - if (prev->next == ipr) { - break; - } - prev = prev->next; - } - if (prev != NULL) { - prev->next = ipr->next; - } - } - memp_free(MEMP_IP6_REASSDATA, ipr); - - /* Finally, update number of pbufs in reassembly queue */ - LWIP_ASSERT("ip_reass_pbufcount >= clen", ip6_reass_pbufcount >= pbufs_freed); - ip6_reass_pbufcount -= pbufs_freed; -} - -#if IP_REASS_FREE_OLDEST -/** - * Free the oldest datagram to make room for enqueueing new fragments. - * The datagram ipr is not freed! - * - * @param ipr ip6_reassdata for the current fragment - * @param pbufs_needed number of pbufs needed to enqueue - * (used for freeing other datagrams if not enough space) - */ -static void -ip6_reass_remove_oldest_datagram(struct ip6_reassdata *ipr, int pbufs_needed) -{ - struct ip6_reassdata *r, *oldest; - - /* Free datagrams until being allowed to enqueue 'pbufs_needed' pbufs, - * but don't free the current datagram! */ - do { - r = oldest = reassdatagrams; - while (r != NULL) { - if (r != ipr) { - if (r->timer <= oldest->timer) { - /* older than the previous oldest */ - oldest = r; - } - } - r = r->next; - } - if (oldest != NULL) { - ip6_reass_free_complete_datagram(oldest); - } - } while (((ip6_reass_pbufcount + pbufs_needed) > IP_REASS_MAX_PBUFS) && (reassdatagrams != NULL)); -} -#endif /* IP_REASS_FREE_OLDEST */ - -/** - * Reassembles incoming IPv6 fragments into an IPv6 datagram. - * - * @param p points to the IPv6 Fragment Header - * @param len the length of the payload (after Fragment Header) - * @return NULL if reassembly is incomplete, pbuf pointing to - * IPv6 Header if reassembly is complete - */ -struct pbuf * -ip6_reass(struct pbuf *p) -{ - struct ip6_reassdata *ipr, *ipr_prev; - struct ip6_reass_helper *iprh, *iprh_tmp, *iprh_prev=NULL; - struct ip6_frag_hdr * frag_hdr; - u16_t offset, len; - u8_t clen, valid = 1; - struct pbuf *q; - - IP6_FRAG_STATS_INC(ip6_frag.recv); - - frag_hdr = (struct ip6_frag_hdr *) p->payload; - - clen = pbuf_clen(p); - - offset = ntohs(frag_hdr->_fragment_offset); - - /* Calculate fragment length from IPv6 payload length. - * Adjust for headers before Fragment Header. - * And finally adjust by Fragment Header length. */ - len = ntohs(ip6_current_header()->_plen); - len -= ((u8_t*)p->payload - (u8_t*)ip6_current_header()) - IP6_HLEN; - len -= IP6_FRAG_HLEN; - - /* Look for the datagram the fragment belongs to in the current datagram queue, - * remembering the previous in the queue for later dequeueing. */ - for (ipr = reassdatagrams, ipr_prev = NULL; ipr != NULL; ipr = ipr->next) { - /* Check if the incoming fragment matches the one currently present - in the reassembly buffer. If so, we proceed with copying the - fragment into the buffer. */ - if ((frag_hdr->_identification == ipr->identification) && - ip6_addr_cmp(ip6_current_src_addr(), &(ipr->iphdr->src)) && - ip6_addr_cmp(ip6_current_dest_addr(), &(ipr->iphdr->dest))) { - IP6_FRAG_STATS_INC(ip6_frag.cachehit); - break; - } - ipr_prev = ipr; - } - - if (ipr == NULL) { - /* Enqueue a new datagram into the datagram queue */ - ipr = (struct ip6_reassdata *)memp_malloc(MEMP_IP6_REASSDATA); - if (ipr == NULL) { -#if IP_REASS_FREE_OLDEST - /* Make room and try again. */ - ip6_reass_remove_oldest_datagram(ipr, clen); - ipr = (struct ip6_reassdata *)memp_malloc(MEMP_IP6_REASSDATA); - if (ipr == NULL) -#endif /* IP_REASS_FREE_OLDEST */ - { - IP6_FRAG_STATS_INC(ip6_frag.memerr); - IP6_FRAG_STATS_INC(ip6_frag.drop); - goto nullreturn; - } - } - - memset(ipr, 0, sizeof(struct ip6_reassdata)); - ipr->timer = IP_REASS_MAXAGE; - - /* enqueue the new structure to the front of the list */ - ipr->next = reassdatagrams; - reassdatagrams = ipr; - - /* Use the current IPv6 header for src/dest address reference. - * Eventually, we will replace it when we get the first fragment - * (it might be this one, in any case, it is done later). */ - ipr->iphdr = (struct ip6_hdr *)ip6_current_header(); - - /* copy the fragmented packet id. */ - ipr->identification = frag_hdr->_identification; - - /* copy the nexth field */ - ipr->nexth = frag_hdr->_nexth; - } - - /* Check if we are allowed to enqueue more datagrams. */ - if ((ip6_reass_pbufcount + clen) > IP_REASS_MAX_PBUFS) { -#if IP_REASS_FREE_OLDEST - ip6_reass_remove_oldest_datagram(ipr, clen); - if ((ip6_reass_pbufcount + clen) > IP_REASS_MAX_PBUFS) -#endif /* IP_REASS_FREE_OLDEST */ - { - /* @todo: send ICMPv6 time exceeded here? */ - /* drop this pbuf */ - IP6_FRAG_STATS_INC(ip6_frag.memerr); - IP6_FRAG_STATS_INC(ip6_frag.drop); - goto nullreturn; - } - } - - /* Overwrite Fragment Header with our own helper struct. */ - iprh = (struct ip6_reass_helper *)p->payload; - iprh->next_pbuf = NULL; - iprh->start = (offset & IP6_FRAG_OFFSET_MASK); - iprh->end = (offset & IP6_FRAG_OFFSET_MASK) + len; - - /* find the right place to insert this pbuf */ - /* Iterate through until we either get to the end of the list (append), - * or we find on with a larger offset (insert). */ - for (q = ipr->p; q != NULL;) { - iprh_tmp = (struct ip6_reass_helper*)q->payload; - if (iprh->start < iprh_tmp->start) { -#if IP_REASS_CHECK_OVERLAP - if (iprh->end > iprh_tmp->start) { - /* fragment overlaps with following, throw away */ - IP6_FRAG_STATS_INC(ip6_frag.proterr); - IP6_FRAG_STATS_INC(ip6_frag.drop); - goto nullreturn; - } - if (iprh_prev != NULL) { - if (iprh->start < iprh_prev->end) { - /* fragment overlaps with previous, throw away */ - IP6_FRAG_STATS_INC(ip6_frag.proterr); - IP6_FRAG_STATS_INC(ip6_frag.drop); - goto nullreturn; - } - } -#endif /* IP_REASS_CHECK_OVERLAP */ - /* the new pbuf should be inserted before this */ - iprh->next_pbuf = q; - if (iprh_prev != NULL) { - /* not the fragment with the lowest offset */ - iprh_prev->next_pbuf = p; - } else { - /* fragment with the lowest offset */ - ipr->p = p; - } - break; - } else if(iprh->start == iprh_tmp->start) { - /* received the same datagram twice: no need to keep the datagram */ - IP6_FRAG_STATS_INC(ip6_frag.drop); - goto nullreturn; -#if IP_REASS_CHECK_OVERLAP - } else if(iprh->start < iprh_tmp->end) { - /* overlap: no need to keep the new datagram */ - IP6_FRAG_STATS_INC(ip6_frag.proterr); - IP6_FRAG_STATS_INC(ip6_frag.drop); - goto nullreturn; -#endif /* IP_REASS_CHECK_OVERLAP */ - } else { - /* Check if the fragments received so far have no gaps. */ - if (iprh_prev != NULL) { - if (iprh_prev->end != iprh_tmp->start) { - /* There is a fragment missing between the current - * and the previous fragment */ - valid = 0; - } - } - } - q = iprh_tmp->next_pbuf; - iprh_prev = iprh_tmp; - } - - /* If q is NULL, then we made it to the end of the list. Determine what to do now */ - if (q == NULL) { - if (iprh_prev != NULL) { - /* this is (for now), the fragment with the highest offset: - * chain it to the last fragment */ -#if IP_REASS_CHECK_OVERLAP - LWIP_ASSERT("check fragments don't overlap", iprh_prev->end <= iprh->start); -#endif /* IP_REASS_CHECK_OVERLAP */ - iprh_prev->next_pbuf = p; - if (iprh_prev->end != iprh->start) { - valid = 0; - } - } else { -#if IP_REASS_CHECK_OVERLAP - LWIP_ASSERT("no previous fragment, this must be the first fragment!", - ipr->p == NULL); -#endif /* IP_REASS_CHECK_OVERLAP */ - /* this is the first fragment we ever received for this ip datagram */ - ipr->p = p; - } - } - - /* Track the current number of pbufs current 'in-flight', in order to limit - the number of fragments that may be enqueued at any one time */ - ip6_reass_pbufcount += clen; - - /* Remember IPv6 header if this is the first fragment. */ - if (iprh->start == 0) { - ipr->iphdr = (struct ip6_hdr *)ip6_current_header(); - } - - /* If this is the last fragment, calculate total packet length. */ - if ((offset & IP6_FRAG_MORE_FLAG) == 0) { - ipr->datagram_len = iprh->end; - } - - /* Additional validity tests: we have received first and last fragment. */ - iprh_tmp = (struct ip6_reass_helper*)ipr->p->payload; - if (iprh_tmp->start != 0) { - valid = 0; - } - if (ipr->datagram_len == 0) { - valid = 0; - } - - /* Final validity test: no gaps between current and last fragment. */ - iprh_prev = iprh; - q = iprh->next_pbuf; - while ((q != NULL) && valid) { - iprh = (struct ip6_reass_helper*)q->payload; - if (iprh_prev->end != iprh->start) { - valid = 0; - break; - } - iprh_prev = iprh; - q = iprh->next_pbuf; - } - - if (valid) { - /* All fragments have been received */ - - /* chain together the pbufs contained within the ip6_reassdata list. */ - iprh = (struct ip6_reass_helper*) ipr->p->payload; - while(iprh != NULL) { - - if (iprh->next_pbuf != NULL) { - /* Save next helper struct (will be hidden in next step). */ - iprh_tmp = (struct ip6_reass_helper*) iprh->next_pbuf->payload; - - /* hide the fragment header for every succeding fragment */ - pbuf_header(iprh->next_pbuf, -IP6_FRAG_HLEN); - pbuf_cat(ipr->p, iprh->next_pbuf); - } - else { - iprh_tmp = NULL; - } - - iprh = iprh_tmp; - } - - /* Adjust datagram length by adding header lengths. */ - ipr->datagram_len += ((u8_t*)ipr->p->payload - (u8_t*)ipr->iphdr) - + IP6_FRAG_HLEN - - IP6_HLEN ; - - /* Set payload length in ip header. */ - ipr->iphdr->_plen = htons(ipr->datagram_len); - - /* Get the furst pbuf. */ - p = ipr->p; - - /* Restore Fragment Header in first pbuf. Mark as "single fragment" - * packet. Restore nexth. */ - frag_hdr = (struct ip6_frag_hdr *) p->payload; - frag_hdr->_nexth = ipr->nexth; - frag_hdr->reserved = 0; - frag_hdr->_fragment_offset = 0; - frag_hdr->_identification = 0; - - /* release the sources allocate for the fragment queue entry */ - if (reassdatagrams == ipr) { - /* it was the first in the list */ - reassdatagrams = ipr->next; - } else { - /* it wasn't the first, so it must have a valid 'prev' */ - LWIP_ASSERT("sanity check linked list", ipr_prev != NULL); - ipr_prev->next = ipr->next; - } - memp_free(MEMP_IP6_REASSDATA, ipr); - - /* adjust the number of pbufs currently queued for reassembly. */ - ip6_reass_pbufcount -= pbuf_clen(p); - - /* Move pbuf back to IPv6 header. */ - if (pbuf_header(p, (u8_t*)p->payload - (u8_t*)ipr->iphdr)) { - LWIP_ASSERT("ip6_reass: moving p->payload to ip6 header failed\n", 0); - pbuf_free(p); - return NULL; - } - - /* Return the pbuf chain */ - return p; - } - /* the datagram is not (yet?) reassembled completely */ - return NULL; - -nullreturn: - pbuf_free(p); - return NULL; -} - -#endif /* LWIP_IPV6 ^^ LWIP_IPV6_REASS */ - -#if LWIP_IPV6 && LWIP_IPV6_FRAG - -/** Allocate a new struct pbuf_custom_ref */ -static struct pbuf_custom_ref* -ip6_frag_alloc_pbuf_custom_ref(void) -{ - return (struct pbuf_custom_ref*)memp_malloc(MEMP_FRAG_PBUF); -} - -/** Free a struct pbuf_custom_ref */ -static void -ip6_frag_free_pbuf_custom_ref(struct pbuf_custom_ref* p) -{ - LWIP_ASSERT("p != NULL", p != NULL); - memp_free(MEMP_FRAG_PBUF, p); -} - -/** Free-callback function to free a 'struct pbuf_custom_ref', called by - * pbuf_free. */ -static void -ip6_frag_free_pbuf_custom(struct pbuf *p) -{ - struct pbuf_custom_ref *pcr = (struct pbuf_custom_ref*)p; - LWIP_ASSERT("pcr != NULL", pcr != NULL); - LWIP_ASSERT("pcr == p", (void*)pcr == (void*)p); - if (pcr->original != NULL) { - pbuf_free(pcr->original); - } - ip6_frag_free_pbuf_custom_ref(pcr); -} - -/** - * Fragment an IPv6 datagram if too large for the netif or path MTU. - * - * Chop the datagram in MTU sized chunks and send them in order - * by pointing PBUF_REFs into p - * - * @param p ipv6 packet to send - * @param netif the netif on which to send - * @param dest destination ipv6 address to which to send - * - * @return ERR_OK if sent successfully, err_t otherwise - */ -err_t -ip6_frag(struct pbuf *p, struct netif *netif, ip6_addr_t *dest) -{ - struct ip6_hdr *original_ip6hdr; - struct ip6_hdr *ip6hdr; - struct ip6_frag_hdr * frag_hdr; - struct pbuf *rambuf; - struct pbuf *newpbuf; - static u32_t identification; - u16_t nfb; - u16_t left, cop; - u16_t mtu; - u16_t fragment_offset = 0; - u16_t last; - u16_t poff = IP6_HLEN; - u16_t newpbuflen = 0; - u16_t left_to_copy; - - identification++; - - original_ip6hdr = (struct ip6_hdr *)p->payload; - - mtu = nd6_get_destination_mtu(dest, netif); - - /* TODO we assume there are no options in the unfragmentable part (IPv6 header). */ - left = p->tot_len - IP6_HLEN; - - nfb = (mtu - (IP6_HLEN + IP6_FRAG_HLEN)) & IP6_FRAG_OFFSET_MASK; - - while (left) { - last = (left <= nfb); - - /* Fill this fragment */ - cop = last ? left : nfb; - - /* When not using a static buffer, create a chain of pbufs. - * The first will be a PBUF_RAM holding the link, IPv6, and Fragment header. - * The rest will be PBUF_REFs mirroring the pbuf chain to be fragged, - * but limited to the size of an mtu. - */ - rambuf = pbuf_alloc(PBUF_LINK, IP6_HLEN + IP6_FRAG_HLEN, PBUF_RAM); - if (rambuf == NULL) { - IP6_FRAG_STATS_INC(ip6_frag.memerr); - return ERR_MEM; - } - LWIP_ASSERT("this needs a pbuf in one piece!", - (p->len >= (IP6_HLEN + IP6_FRAG_HLEN))); - SMEMCPY(rambuf->payload, original_ip6hdr, IP6_HLEN); - ip6hdr = (struct ip6_hdr *)rambuf->payload; - frag_hdr = (struct ip6_frag_hdr *)((u8_t*)rambuf->payload + IP6_HLEN); - - /* Can just adjust p directly for needed offset. */ - p->payload = (u8_t *)p->payload + poff; - p->len -= poff; - p->tot_len -= poff; - - left_to_copy = cop; - while (left_to_copy) { - struct pbuf_custom_ref *pcr; - newpbuflen = (left_to_copy < p->len) ? left_to_copy : p->len; - /* Is this pbuf already empty? */ - if (!newpbuflen) { - p = p->next; - continue; - } - pcr = ip6_frag_alloc_pbuf_custom_ref(); - if (pcr == NULL) { - pbuf_free(rambuf); - IP6_FRAG_STATS_INC(ip6_frag.memerr); - return ERR_MEM; - } - /* Mirror this pbuf, although we might not need all of it. */ - newpbuf = pbuf_alloced_custom(PBUF_RAW, newpbuflen, PBUF_REF, &pcr->pc, p->payload, newpbuflen); - if (newpbuf == NULL) { - ip6_frag_free_pbuf_custom_ref(pcr); - pbuf_free(rambuf); - IP6_FRAG_STATS_INC(ip6_frag.memerr); - return ERR_MEM; - } - pbuf_ref(p); - pcr->original = p; - pcr->pc.custom_free_function = ip6_frag_free_pbuf_custom; - - /* Add it to end of rambuf's chain, but using pbuf_cat, not pbuf_chain - * so that it is removed when pbuf_dechain is later called on rambuf. - */ - pbuf_cat(rambuf, newpbuf); - left_to_copy -= newpbuflen; - if (left_to_copy) { - p = p->next; - } - } - poff = newpbuflen; - - /* Set headers */ - frag_hdr->_nexth = original_ip6hdr->_nexth; - frag_hdr->reserved = 0; - frag_hdr->_fragment_offset = htons((fragment_offset & IP6_FRAG_OFFSET_MASK) | (last ? 0 : IP6_FRAG_MORE_FLAG)); - frag_hdr->_identification = htonl(identification); - - IP6H_NEXTH_SET(ip6hdr, IP6_NEXTH_FRAGMENT); - IP6H_PLEN_SET(ip6hdr, cop + IP6_FRAG_HLEN); - - /* No need for separate header pbuf - we allowed room for it in rambuf - * when allocated. - */ - IP6_FRAG_STATS_INC(ip6_frag.xmit); - netif->output_ip6(netif, rambuf, dest); - - /* Unfortunately we can't reuse rambuf - the hardware may still be - * using the buffer. Instead we free it (and the ensuing chain) and - * recreate it next time round the loop. If we're lucky the hardware - * will have already sent the packet, the free will really free, and - * there will be zero memory penalty. - */ - - pbuf_free(rambuf); - left -= cop; - fragment_offset += cop; - } - return ERR_OK; -} - -#endif /* LWIP_IPV6 && LWIP_IPV6_FRAG */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/nd6.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/nd6.c deleted file mode 100644 index 43eb5318..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/ipv6/nd6.c +++ /dev/null @@ -1,1790 +0,0 @@ -/** - * @file - * - * Neighbor discovery and stateless address autoconfiguration for IPv6. - * Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 - * (Address autoconfiguration). - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#include "lwip/opt.h" - -#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/nd6.h" -#include "lwip/pbuf.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/ip6.h" -#include "lwip/ip6_addr.h" -#include "lwip/inet_chksum.h" -#include "lwip/netif.h" -#include "lwip/icmp6.h" -#include "lwip/mld6.h" -#include "lwip/stats.h" - -#include - - -/* Router tables. */ -struct nd6_neighbor_cache_entry neighbor_cache[LWIP_ND6_NUM_NEIGHBORS]; -struct nd6_destination_cache_entry destination_cache[LWIP_ND6_NUM_DESTINATIONS]; -struct nd6_prefix_list_entry prefix_list[LWIP_ND6_NUM_PREFIXES]; -struct nd6_router_list_entry default_router_list[LWIP_ND6_NUM_ROUTERS]; - -/* Default values, can be updated by a RA message. */ -u32_t reachable_time = LWIP_ND6_REACHABLE_TIME; -u32_t retrans_timer = LWIP_ND6_RETRANS_TIMER; /* TODO implement this value in timer */ - -/* Index for cache entries. */ -static u8_t nd6_cached_neighbor_index; -static u8_t nd6_cached_destination_index; - -/* Multicast address holder. */ -static ip6_addr_t multicast_address; - -/* Static buffer to parse RA packet options (size of a prefix option, biggest option) */ -static u8_t nd6_ra_buffer[sizeof(struct prefix_option)]; - -/* Forward declarations. */ -static s8_t nd6_find_neighbor_cache_entry(ip6_addr_t * ip6addr); -static s8_t nd6_new_neighbor_cache_entry(void); -static void nd6_free_neighbor_cache_entry(s8_t i); -static s8_t nd6_find_destination_cache_entry(ip6_addr_t * ip6addr); -static s8_t nd6_new_destination_cache_entry(void); -static s8_t nd6_is_prefix_in_netif(ip6_addr_t * ip6addr, struct netif * netif); -static s8_t nd6_get_router(ip6_addr_t * router_addr, struct netif * netif); -static s8_t nd6_new_router(ip6_addr_t * router_addr, struct netif * netif); -static s8_t nd6_get_onlink_prefix(ip6_addr_t * prefix, struct netif * netif); -static s8_t nd6_new_onlink_prefix(ip6_addr_t * prefix, struct netif * netif); - -#define ND6_SEND_FLAG_MULTICAST_DEST 0x01 -#define ND6_SEND_FLAG_ALLNODES_DEST 0x02 -static void nd6_send_ns(struct netif * netif, ip6_addr_t * target_addr, u8_t flags); -static void nd6_send_na(struct netif * netif, ip6_addr_t * target_addr, u8_t flags); -#if LWIP_IPV6_SEND_ROUTER_SOLICIT -static void nd6_send_rs(struct netif * netif); -#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ - -#if LWIP_ND6_QUEUEING -static void nd6_free_q(struct nd6_q_entry *q); -#else /* LWIP_ND6_QUEUEING */ -#define nd6_free_q(q) pbuf_free(q) -#endif /* LWIP_ND6_QUEUEING */ -static void nd6_send_q(s8_t i); - - -/** - * Process an incoming neighbor discovery message - * - * @param p the nd packet, p->payload pointing to the icmpv6 header - * @param inp the netif on which this packet was received - */ -void -nd6_input(struct pbuf *p, struct netif *inp) -{ - u8_t msg_type; - s8_t i; - - ND6_STATS_INC(nd6.recv); - - msg_type = *((u8_t *)p->payload); - switch (msg_type) { - case ICMP6_TYPE_NA: /* Neighbor Advertisement. */ - { - struct na_header * na_hdr; - struct lladdr_option * lladdr_opt; - - /* Check that na header fits in packet. */ - if (p->len < (sizeof(struct na_header))) { - /* TODO debug message */ - pbuf_free(p); - ND6_STATS_INC(nd6.lenerr); - ND6_STATS_INC(nd6.drop); - return; - } - - na_hdr = (struct na_header *)p->payload; - - /* Unsolicited NA?*/ - if (ip6_addr_ismulticast(ip6_current_dest_addr())) { - /* This is an unsolicited NA. - * link-layer changed? - * part of DAD mechanism? */ - - /* Check that link-layer address option also fits in packet. */ - if (p->len < (sizeof(struct na_header) + sizeof(struct lladdr_option))) { - /* TODO debug message */ - pbuf_free(p); - ND6_STATS_INC(nd6.lenerr); - ND6_STATS_INC(nd6.drop); - return; - } - - lladdr_opt = (struct lladdr_option *)((u8_t*)p->payload + sizeof(struct na_header)); - - /* Override ip6_current_dest_addr() so that we have an aligned copy. */ - ip6_addr_set(ip6_current_dest_addr(), &(na_hdr->target_address)); - -#if LWIP_IPV6_DUP_DETECT_ATTEMPTS - /* If the target address matches this netif, it is a DAD response. */ - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_cmp(ip6_current_dest_addr(), netif_ip6_addr(inp, i))) { - /* We are using a duplicate address. */ - netif_ip6_addr_set_state(inp, i, IP6_ADDR_INVALID); - -#if LWIP_IPV6_MLD - /* Leave solicited node multicast group. */ - ip6_addr_set_solicitednode(&multicast_address, netif_ip6_addr(inp, i)->addr[3]); - mld6_leavegroup(netif_ip6_addr(inp, i), &multicast_address); -#endif /* LWIP_IPV6_MLD */ - - - - -#if LWIP_IPV6_AUTOCONFIG - /* Check to see if this address was autoconfigured. */ - if (!ip6_addr_islinklocal(ip6_current_dest_addr())) { - i = nd6_get_onlink_prefix(ip6_current_dest_addr(), inp); - if (i >= 0) { - /* Mark this prefix as duplicate, so that we don't use it - * to generate this address again. */ - prefix_list[i].flags |= ND6_PREFIX_AUTOCONFIG_ADDRESS_DUPLICATE; - } - } -#endif /* LWIP_IPV6_AUTOCONFIG */ - - pbuf_free(p); - return; - } - } -#endif /* LWIP_IPV6_DUP_DETECT_ATTEMPTS */ - - /* This is an unsolicited NA, most likely there was a LLADDR change. */ - i = nd6_find_neighbor_cache_entry(ip6_current_dest_addr()); - if (i >= 0) { - if (na_hdr->flags & ND6_FLAG_OVERRIDE) { - MEMCPY(neighbor_cache[i].lladdr, lladdr_opt->addr, inp->hwaddr_len); - } - } - } - else { - /* This is a solicited NA. - * neighbor address resolution response? - * neighbor unreachability detection response? */ - - /* Override ip6_current_dest_addr() so that we have an aligned copy. */ - ip6_addr_set(ip6_current_dest_addr(), &(na_hdr->target_address)); - - /* Find the cache entry corresponding to this na. */ - i = nd6_find_neighbor_cache_entry(ip6_current_dest_addr()); - if (i < 0) { - /* We no longer care about this target address. drop it. */ - pbuf_free(p); - return; - } - - /* Update cache entry. */ - neighbor_cache[i].netif = inp; - neighbor_cache[i].counter.reachable_time = reachable_time; - if ((na_hdr->flags & ND6_FLAG_OVERRIDE) || - (neighbor_cache[i].state == ND6_INCOMPLETE)) { - /* Check that link-layer address option also fits in packet. */ - if (p->len < (sizeof(struct na_header) + sizeof(struct lladdr_option))) { - /* TODO debug message */ - pbuf_free(p); - ND6_STATS_INC(nd6.lenerr); - ND6_STATS_INC(nd6.drop); - return; - } - - lladdr_opt = (struct lladdr_option *)((u8_t*)p->payload + sizeof(struct na_header)); - - MEMCPY(neighbor_cache[i].lladdr, lladdr_opt->addr, inp->hwaddr_len); - } - neighbor_cache[i].state = ND6_REACHABLE; - - /* Send queued packets, if any. */ - if (neighbor_cache[i].q != NULL) { - nd6_send_q(i); - } - } - - break; /* ICMP6_TYPE_NA */ - } - case ICMP6_TYPE_NS: /* Neighbor solicitation. */ - { - struct ns_header * ns_hdr; - struct lladdr_option * lladdr_opt; - u8_t accepted; - - /* Check that ns header fits in packet. */ - if (p->len < sizeof(struct ns_header)) { - /* TODO debug message */ - pbuf_free(p); - ND6_STATS_INC(nd6.lenerr); - ND6_STATS_INC(nd6.drop); - return; - } - - ns_hdr = (struct ns_header *)p->payload; - - /* Check if there is a link-layer address provided. Only point to it if in this buffer. */ - lladdr_opt = NULL; - if (p->len >= (sizeof(struct ns_header) + sizeof(struct lladdr_option))) { - lladdr_opt = (struct lladdr_option *)((u8_t*)p->payload + sizeof(struct ns_header)); - } - - /* Check if the target address is configured on the receiving netif. */ - accepted = 0; - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; ++i) { - if ((ip6_addr_isvalid(netif_ip6_addr_state(inp, i)) || - (ip6_addr_istentative(netif_ip6_addr_state(inp, i)) && - ip6_addr_isany(ip6_current_src_addr()))) && - ip6_addr_cmp(&(ns_hdr->target_address), netif_ip6_addr(inp, i))) { - accepted = 1; - break; - } - } - - /* NS not for us? */ - if (!accepted) { - pbuf_free(p); - return; - } - - /* Check for ANY address in src (DAD algorithm). */ - if (ip6_addr_isany(ip6_current_src_addr())) { - /* Sender is validating this address. */ - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; ++i) { - if (ip6_addr_cmp(&(ns_hdr->target_address), netif_ip6_addr(inp, i))) { - /* Send a NA back so that the sender does not use this address. */ - nd6_send_na(inp, netif_ip6_addr(inp, i), ND6_FLAG_OVERRIDE | ND6_SEND_FLAG_ALLNODES_DEST); - if (ip6_addr_istentative(netif_ip6_addr_state(inp, i))) { - /* We shouldn't use this address either. */ - netif_ip6_addr_set_state(inp, i, IP6_ADDR_INVALID); - } - } - } - } - else { - /* Sender is trying to resolve our address. */ - /* Verify that they included their own link-layer address. */ - if (lladdr_opt == NULL) { - /* Not a valid message. */ - pbuf_free(p); - ND6_STATS_INC(nd6.proterr); - ND6_STATS_INC(nd6.drop); - return; - } - - i = nd6_find_neighbor_cache_entry(ip6_current_src_addr()); - if ( i>= 0) { - /* We already have a record for the solicitor. */ - if (neighbor_cache[i].state == ND6_INCOMPLETE) { - neighbor_cache[i].netif = inp; - MEMCPY(neighbor_cache[i].lladdr, lladdr_opt->addr, inp->hwaddr_len); - - /* Delay probe in case we get confirmation of reachability from upper layer (TCP). */ - neighbor_cache[i].state = ND6_DELAY; - neighbor_cache[i].counter.delay_time = LWIP_ND6_DELAY_FIRST_PROBE_TIME; - } - } - else - { - /* Add their IPv6 address and link-layer address to neighbor cache. - * We will need it at least to send a unicast NA message, but most - * likely we will also be communicating with this node soon. */ - i = nd6_new_neighbor_cache_entry(); - if (i < 0) { - /* We couldn't assign a cache entry for this neighbor. - * we won't be able to reply. drop it. */ - pbuf_free(p); - ND6_STATS_INC(nd6.memerr); - return; - } - neighbor_cache[i].netif = inp; - MEMCPY(neighbor_cache[i].lladdr, lladdr_opt->addr, inp->hwaddr_len); - ip6_addr_set(&(neighbor_cache[i].next_hop_address), ip6_current_src_addr()); - - /* Receiving a message does not prove reachability: only in one direction. - * Delay probe in case we get confirmation of reachability from upper layer (TCP). */ - neighbor_cache[i].state = ND6_DELAY; - neighbor_cache[i].counter.delay_time = LWIP_ND6_DELAY_FIRST_PROBE_TIME; - } - - /* Override ip6_current_dest_addr() so that we have an aligned copy. */ - ip6_addr_set(ip6_current_dest_addr(), &(ns_hdr->target_address)); - - /* Send back a NA for us. Allocate the reply pbuf. */ - nd6_send_na(inp, ip6_current_dest_addr(), ND6_FLAG_SOLICITED | ND6_FLAG_OVERRIDE); - } - - break; /* ICMP6_TYPE_NS */ - } - case ICMP6_TYPE_RA: /* Router Advertisement. */ - { - struct ra_header * ra_hdr; - u8_t * buffer; /* Used to copy options. */ - u16_t offset; - - /* Check that RA header fits in packet. */ - if (p->len < sizeof(struct ra_header)) { - /* TODO debug message */ - pbuf_free(p); - ND6_STATS_INC(nd6.lenerr); - ND6_STATS_INC(nd6.drop); - return; - } - - ra_hdr = (struct ra_header *)p->payload; - - /* If we are sending RS messages, stop. */ -#if LWIP_IPV6_SEND_ROUTER_SOLICIT - inp->rs_count = 0; -#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ - - /* Get the matching default router entry. */ - i = nd6_get_router(ip6_current_src_addr(), inp); - if (i < 0) { - /* Create a new router entry. */ - i = nd6_new_router(ip6_current_src_addr(), inp); - } - - if (i < 0) { - /* Could not create a new router entry. */ - pbuf_free(p); - ND6_STATS_INC(nd6.memerr); - return; - } - - /* Re-set invalidation timer. */ - default_router_list[i].invalidation_timer = ra_hdr->router_lifetime; - - /* Re-set default timer values. */ -#if LWIP_ND6_ALLOW_RA_UPDATES - if (ra_hdr->retrans_timer > 0) { - retrans_timer = ra_hdr->retrans_timer; - } - if (ra_hdr->reachable_time > 0) { - reachable_time = ra_hdr->reachable_time; - } -#endif /* LWIP_ND6_ALLOW_RA_UPDATES */ - - /* TODO set default hop limit... */ - /* ra_hdr->current_hop_limit;*/ - - /* Update flags in local entry (incl. preference). */ - default_router_list[i].flags = ra_hdr->flags; - - /* Offset to options. */ - offset = sizeof(struct ra_header); - - /* Process each option. */ - while ((p->tot_len - offset) > 0) { - if (p->len == p->tot_len) { - /* no need to copy from contiguous pbuf */ - buffer = &((u8_t*)p->payload)[offset]; - } else { - buffer = nd6_ra_buffer; - pbuf_copy_partial(p, buffer, sizeof(struct prefix_option), offset); - } - switch (buffer[0]) { - case ND6_OPTION_TYPE_SOURCE_LLADDR: - { - struct lladdr_option * lladdr_opt; - lladdr_opt = (struct lladdr_option *)buffer; - if ((default_router_list[i].neighbor_entry != NULL) && - (default_router_list[i].neighbor_entry->state == ND6_INCOMPLETE)) { - SMEMCPY(default_router_list[i].neighbor_entry->lladdr, lladdr_opt->addr, inp->hwaddr_len); - default_router_list[i].neighbor_entry->state = ND6_REACHABLE; - default_router_list[i].neighbor_entry->counter.reachable_time = reachable_time; - } - break; - } - case ND6_OPTION_TYPE_MTU: - { - struct mtu_option * mtu_opt; - mtu_opt = (struct mtu_option *)buffer; - if (mtu_opt->mtu >= 1280) { -#if LWIP_ND6_ALLOW_RA_UPDATES - inp->mtu = mtu_opt->mtu; -#endif /* LWIP_ND6_ALLOW_RA_UPDATES */ - } - break; - } - case ND6_OPTION_TYPE_PREFIX_INFO: - { - struct prefix_option * prefix_opt; - prefix_opt = (struct prefix_option *)buffer; - - if (prefix_opt->flags & ND6_PREFIX_FLAG_ON_LINK) { - /* Add to on-link prefix list. */ - - /* Get a memory-aligned copy of the prefix. */ - ip6_addr_set(ip6_current_dest_addr(), &(prefix_opt->prefix)); - - /* find cache entry for this prefix. */ - i = nd6_get_onlink_prefix(ip6_current_dest_addr(), inp); - if (i < 0) { - /* Create a new cache entry. */ - i = nd6_new_onlink_prefix(ip6_current_dest_addr(), inp); - } - if (i >= 0) { - prefix_list[i].invalidation_timer = prefix_opt->valid_lifetime; - -#if LWIP_IPV6_AUTOCONFIG - if (prefix_opt->flags & ND6_PREFIX_FLAG_AUTONOMOUS) { - /* Mark prefix as autonomous, so that address autoconfiguration can take place. - * Only OR flag, so that we don't over-write other flags (such as ADDRESS_DUPLICATE)*/ - prefix_list[i].flags |= ND6_PREFIX_AUTOCONFIG_AUTONOMOUS; - } -#endif /* LWIP_IPV6_AUTOCONFIG */ - } - } - - break; - } - case ND6_OPTION_TYPE_ROUTE_INFO: - { - /* TODO implement preferred routes. - struct route_option * route_opt; - route_opt = (struct route_option *)buffer;*/ - - break; - } - default: - /* Unrecognized option, abort. */ - ND6_STATS_INC(nd6.proterr); - break; - } - offset += 8 * ((u16_t)buffer[1]); - } - - break; /* ICMP6_TYPE_RA */ - } - case ICMP6_TYPE_RD: /* Redirect */ - { - struct redirect_header * redir_hdr; - struct lladdr_option * lladdr_opt; - - /* Check that Redir header fits in packet. */ - if (p->len < sizeof(struct redirect_header)) { - /* TODO debug message */ - pbuf_free(p); - ND6_STATS_INC(nd6.lenerr); - ND6_STATS_INC(nd6.drop); - return; - } - - redir_hdr = (struct redirect_header *)p->payload; - - lladdr_opt = NULL; - if (p->len >= (sizeof(struct redirect_header) + sizeof(struct lladdr_option))) { - lladdr_opt = (struct lladdr_option *)((u8_t*)p->payload + sizeof(struct redirect_header)); - } - - /* Copy original destination address to current source address, to have an aligned copy. */ - ip6_addr_set(ip6_current_src_addr(), &(redir_hdr->destination_address)); - - /* Find dest address in cache */ - i = nd6_find_destination_cache_entry(ip6_current_src_addr()); - if (i < 0) { - /* Destination not in cache, drop packet. */ - pbuf_free(p); - return; - } - - /* Set the new target address. */ - ip6_addr_set(&(destination_cache[i].next_hop_addr), &(redir_hdr->target_address)); - - /* If Link-layer address of other router is given, try to add to neighbor cache. */ - if (lladdr_opt != NULL) { - if (lladdr_opt->type == ND6_OPTION_TYPE_TARGET_LLADDR) { - /* Copy target address to current source address, to have an aligned copy. */ - ip6_addr_set(ip6_current_src_addr(), &(redir_hdr->target_address)); - - i = nd6_find_neighbor_cache_entry(ip6_current_src_addr()); - if (i < 0) { - i = nd6_new_neighbor_cache_entry(); - if (i >= 0) { - neighbor_cache[i].netif = inp; - MEMCPY(neighbor_cache[i].lladdr, lladdr_opt->addr, inp->hwaddr_len); - ip6_addr_set(&(neighbor_cache[i].next_hop_address), ip6_current_src_addr()); - - /* Receiving a message does not prove reachability: only in one direction. - * Delay probe in case we get confirmation of reachability from upper layer (TCP). */ - neighbor_cache[i].state = ND6_DELAY; - neighbor_cache[i].counter.delay_time = LWIP_ND6_DELAY_FIRST_PROBE_TIME; - } - } - if (i >= 0) { - if (neighbor_cache[i].state == ND6_INCOMPLETE) { - MEMCPY(neighbor_cache[i].lladdr, lladdr_opt->addr, inp->hwaddr_len); - /* Receiving a message does not prove reachability: only in one direction. - * Delay probe in case we get confirmation of reachability from upper layer (TCP). */ - neighbor_cache[i].state = ND6_DELAY; - neighbor_cache[i].counter.delay_time = LWIP_ND6_DELAY_FIRST_PROBE_TIME; - } - } - } - } - break; /* ICMP6_TYPE_RD */ - } - case ICMP6_TYPE_PTB: /* Packet too big */ - { - struct pp_icmp6_hdr *icmp6hdr; /* Packet too big message */ - struct ip6_hdr * ip6hdr; /* IPv6 header of the packet which caused the error */ - - /* Check that ICMPv6 header + IPv6 header fit in payload */ - if (p->len < (sizeof(struct pp_icmp6_hdr) + IP6_HLEN)) { - /* drop short packets */ - pbuf_free(p); - ND6_STATS_INC(nd6.lenerr); - ND6_STATS_INC(nd6.drop); - return; - } - - icmp6hdr = (struct pp_icmp6_hdr *)p->payload; - ip6hdr = (struct ip6_hdr *)((u8_t*)p->payload + sizeof(struct icmp6_hdr)); - - /* Copy original destination address to current source address, to have an aligned copy. */ - ip6_addr_set(ip6_current_src_addr(), &(ip6hdr->dest)); - - /* Look for entry in destination cache. */ - i = nd6_find_destination_cache_entry(ip6_current_src_addr()); - if (i < 0) { - /* Destination not in cache, drop packet. */ - pbuf_free(p); - return; - } - - /* Change the Path MTU. */ - destination_cache[i].pmtu = icmp6hdr->data; - - break; /* ICMP6_TYPE_PTB */ - } - - default: - ND6_STATS_INC(nd6.proterr); - ND6_STATS_INC(nd6.drop); - break; /* default */ - } - - pbuf_free(p); -} - - -/** - * Periodic timer for Neighbor discovery functions: - * - * - Update neighbor reachability states - * - Update destination cache entries age - * - Update invalidation timers of default routers and on-link prefixes - * - Perform duplicate address detection (DAD) for our addresses - * - Send router solicitations - */ -void -nd6_tmr(void) -{ - s8_t i; -#if LWIP_IPV6_AUTOCONFIG - s8_t j; -#endif - struct netif * netif; - - /* Process neighbor entries. */ - for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { - switch (neighbor_cache[i].state) { - case ND6_INCOMPLETE: - if (neighbor_cache[i].counter.probes_sent >= LWIP_ND6_MAX_MULTICAST_SOLICIT) { - /* Retries exceeded. */ - nd6_free_neighbor_cache_entry(i); - } - else { - /* Send a NS for this entry. */ - neighbor_cache[i].counter.probes_sent++; - nd6_send_ns(neighbor_cache[i].netif, &(neighbor_cache[i].next_hop_address), ND6_SEND_FLAG_MULTICAST_DEST); - } - break; - case ND6_REACHABLE: - /* Send queued packets, if any are left. Should have been sent already. */ - if (neighbor_cache[i].q != NULL) { - nd6_send_q(i); - } - if (neighbor_cache[i].counter.reachable_time <= ND6_TMR_INTERVAL) { - /* Change to stale state. */ - neighbor_cache[i].state = ND6_STALE; - neighbor_cache[i].counter.stale_time = 0; - } - else { - neighbor_cache[i].counter.reachable_time -= ND6_TMR_INTERVAL; - } - break; - case ND6_STALE: - neighbor_cache[i].counter.stale_time += ND6_TMR_INTERVAL; - break; - case ND6_DELAY: - if (neighbor_cache[i].counter.delay_time <= ND6_TMR_INTERVAL) { - /* Change to PROBE state. */ - neighbor_cache[i].state = ND6_PROBE; - neighbor_cache[i].counter.probes_sent = 0; - } - else { - neighbor_cache[i].counter.delay_time -= ND6_TMR_INTERVAL; - } - break; - case ND6_PROBE: - if (neighbor_cache[i].counter.probes_sent >= LWIP_ND6_MAX_MULTICAST_SOLICIT) { - /* Retries exceeded. */ - nd6_free_neighbor_cache_entry(i); - } - else { - /* Send a NS for this entry. */ - neighbor_cache[i].counter.probes_sent++; - nd6_send_ns(neighbor_cache[i].netif, &(neighbor_cache[i].next_hop_address), 0); - } - break; - case ND6_NO_ENTRY: - default: - /* Do nothing. */ - break; - } - } - - /* Process destination entries. */ - for (i = 0; i < LWIP_ND6_NUM_DESTINATIONS; i++) { - destination_cache[i].age++; - } - - /* Process router entries. */ - for (i = 0; i < LWIP_ND6_NUM_ROUTERS; i++) { - if (default_router_list[i].neighbor_entry != NULL) { - /* Active entry. */ - if (default_router_list[i].invalidation_timer > 0) { - default_router_list[i].invalidation_timer -= ND6_TMR_INTERVAL / 1000; - } - if (default_router_list[i].invalidation_timer < ND6_TMR_INTERVAL / 1000) { - /* Less than 1 second remainig. Clear this entry. */ - default_router_list[i].neighbor_entry->isrouter = 0; - default_router_list[i].neighbor_entry = NULL; - default_router_list[i].invalidation_timer = 0; - default_router_list[i].flags = 0; - } - } - } - - /* Process prefix entries. */ - for (i = 0; i < LWIP_ND6_NUM_PREFIXES; i++) { - if (prefix_list[i].invalidation_timer < ND6_TMR_INTERVAL / 1000) { - prefix_list[i].invalidation_timer = 0; - } - if ((prefix_list[i].invalidation_timer > 0) && - (prefix_list[i].netif != NULL)) { - prefix_list[i].invalidation_timer -= ND6_TMR_INTERVAL / 1000; - -#if LWIP_IPV6_AUTOCONFIG - /* Initiate address autoconfiguration for this prefix, if conditions are met. */ - if (prefix_list[i].netif->ip6_autoconfig_enabled && - (prefix_list[i].flags & ND6_PREFIX_AUTOCONFIG_AUTONOMOUS) && - !(prefix_list[i].flags & ND6_PREFIX_AUTOCONFIG_ADDRESS_GENERATED)) { - /* Try to get an address on this netif that is invalid. - * Skip 0 index (link-local address) */ - for (j = 1; j < LWIP_IPV6_NUM_ADDRESSES; j++) { - if (netif_ip6_addr_state(prefix_list[i].netif, j) == IP6_ADDRESS_STATE_INVALID) { - /* Generate an address using this prefix and interface ID from link-local address. */ - prefix_list[i].netif->ip6_addr[j].addr[0] = prefix_list[i].prefix.addr[0]; - prefix_list[i].netif->ip6_addr[j].addr[1] = prefix_list[i].prefix.addr[1]; - prefix_list[i].netif->ip6_addr[j].addr[2] = prefix_list[i].netif->ip6_addr[0].addr[2]; - prefix_list[i].netif->ip6_addr[j].addr[3] = prefix_list[i].netif->ip6_addr[0].addr[3]; - - /* Mark it as tentative (DAD will be performed if configured). */ - netif_ip6_addr_set_state(prefix_list[i].netif, j, IP6_ADDR_TENTATIVE); - - /* Mark this prefix with ADDRESS_GENERATED, so that we don't try again. */ - prefix_list[i].flags |= ND6_PREFIX_AUTOCONFIG_ADDRESS_GENERATED; - - /* Exit loop. */ - break; - } - } - } -#endif /* LWIP_IPV6_AUTOCONFIG */ - } - } - - - /* Process our own addresses, if DAD configured. */ - for (netif = netif_list; netif != NULL; netif = netif->next) { - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; ++i) { - if (ip6_addr_istentative(netif->ip6_addr_state[i])) { - if ((netif->ip6_addr_state[i] & 0x07) >= LWIP_IPV6_DUP_DETECT_ATTEMPTS) { - /* No NA received in response. Mark address as valid. */ - netif->ip6_addr_state[i] = IP6_ADDR_PREFERRED; - /* TODO implement preferred and valid lifetimes. */ - } - else if (netif->flags & NETIF_FLAG_UP) { -#if LWIP_IPV6_MLD - if ((netif->ip6_addr_state[i] & 0x07) == 0) { - /* Join solicited node multicast group. */ - ip6_addr_set_solicitednode(&multicast_address, netif_ip6_addr(netif, i)->addr[3]); - mld6_joingroup(netif_ip6_addr(netif, i), &multicast_address); - } -#endif /* LWIP_IPV6_MLD */ - /* Send a NS for this address. */ - nd6_send_ns(netif, netif_ip6_addr(netif, i), ND6_SEND_FLAG_MULTICAST_DEST); - (netif->ip6_addr_state[i])++; - /* TODO send max 1 NS per tmr call? enable return*/ - /*return;*/ - } - } - } - } - -#if LWIP_IPV6_SEND_ROUTER_SOLICIT - /* Send router solicitation messages, if necessary. */ - for (netif = netif_list; netif != NULL; netif = netif->next) { - if ((netif->rs_count > 0) && (netif->flags & NETIF_FLAG_UP)) { - nd6_send_rs(netif); - netif->rs_count--; - } - } -#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ - -} - -/** - * Send a neighbor solicitation message - * - * @param netif the netif on which to send the message - * @param target_addr the IPv6 target address for the ND message - * @param flags one of ND6_SEND_FLAG_* - */ -static void -nd6_send_ns(struct netif * netif, ip6_addr_t * target_addr, u8_t flags) -{ - struct ns_header * ns_hdr; - struct lladdr_option * lladdr_opt; - struct pbuf * p; - ip6_addr_t * src_addr; - - if (ip6_addr_isvalid(netif_ip6_addr_state(netif,0))) { - /* Use link-local address as source address. */ - src_addr = netif_ip6_addr(netif, 0); - } else { - src_addr = IP6_ADDR_ANY; - } - - /* Allocate a packet. */ - p = pbuf_alloc(PBUF_IP, sizeof(struct ns_header) + sizeof(struct lladdr_option), PBUF_RAM); - if ((p == NULL) || (p->len < (sizeof(struct ns_header) + sizeof(struct lladdr_option)))) { - /* We couldn't allocate a suitable pbuf for the ns. drop it. */ - if (p != NULL) { - pbuf_free(p); - } - ND6_STATS_INC(nd6.memerr); - return; - } - - /* Set fields. */ - ns_hdr = (struct ns_header *)p->payload; - lladdr_opt = (struct lladdr_option *)((u8_t*)p->payload + sizeof(struct ns_header)); - - ns_hdr->type = ICMP6_TYPE_NS; - ns_hdr->code = 0; - ns_hdr->chksum = 0; - ns_hdr->reserved = 0; - ip6_addr_set(&(ns_hdr->target_address), target_addr); - - lladdr_opt->type = ND6_OPTION_TYPE_SOURCE_LLADDR; - lladdr_opt->length = ((netif->hwaddr_len + 2) >> 3) + (((netif->hwaddr_len + 2) & 0x07) ? 1 : 0); - SMEMCPY(lladdr_opt->addr, netif->hwaddr, netif->hwaddr_len); - - /* Generate the solicited node address for the target address. */ - if (flags & ND6_SEND_FLAG_MULTICAST_DEST) { - ip6_addr_set_solicitednode(&multicast_address, target_addr->addr[3]); - target_addr = &multicast_address; - } - - ns_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr, - target_addr); - - /* Send the packet out. */ - ND6_STATS_INC(nd6.xmit); - ip6_output_if(p, (src_addr == IP6_ADDR_ANY) ? NULL : src_addr, target_addr, - LWIP_ICMP6_HL, 0, IP6_NEXTH_ICMP6, netif); - pbuf_free(p); -} - -/** - * Send a neighbor advertisement message - * - * @param netif the netif on which to send the message - * @param target_addr the IPv6 target address for the ND message - * @param flags one of ND6_SEND_FLAG_* - */ -static void -nd6_send_na(struct netif * netif, ip6_addr_t * target_addr, u8_t flags) -{ - struct na_header * na_hdr; - struct lladdr_option * lladdr_opt; - struct pbuf * p; - ip6_addr_t * src_addr; - ip6_addr_t * dest_addr; - - /* Use link-local address as source address. */ - /* src_addr = &(netif->ip6_addr[0]); */ - /* Use target address as source address. */ - src_addr = target_addr; - - /* Allocate a packet. */ - p = pbuf_alloc(PBUF_IP, sizeof(struct na_header) + sizeof(struct lladdr_option), PBUF_RAM); - if ((p == NULL) || (p->len < (sizeof(struct na_header) + sizeof(struct lladdr_option)))) { - /* We couldn't allocate a suitable pbuf for the ns. drop it. */ - if (p != NULL) { - pbuf_free(p); - } - ND6_STATS_INC(nd6.memerr); - return; - } - - /* Set fields. */ - na_hdr = (struct na_header *)p->payload; - lladdr_opt = (struct lladdr_option *)((u8_t*)p->payload + sizeof(struct na_header)); - - na_hdr->type = ICMP6_TYPE_NA; - na_hdr->code = 0; - na_hdr->chksum = 0; - na_hdr->flags = flags & 0xf0; - na_hdr->reserved[0] = 0; - na_hdr->reserved[1] = 0; - na_hdr->reserved[2] = 0; - ip6_addr_set(&(na_hdr->target_address), target_addr); - - lladdr_opt->type = ND6_OPTION_TYPE_TARGET_LLADDR; - lladdr_opt->length = ((netif->hwaddr_len + 2) >> 3) + (((netif->hwaddr_len + 2) & 0x07) ? 1 : 0); - SMEMCPY(lladdr_opt->addr, netif->hwaddr, netif->hwaddr_len); - - /* Generate the solicited node address for the target address. */ - if (flags & ND6_SEND_FLAG_MULTICAST_DEST) { - ip6_addr_set_solicitednode(&multicast_address, target_addr->addr[3]); - dest_addr = &multicast_address; - } - else if (flags & ND6_SEND_FLAG_ALLNODES_DEST) { - ip6_addr_set_allnodes_linklocal(&multicast_address); - dest_addr = &multicast_address; - } - else { - dest_addr = ip6_current_src_addr(); - } - - na_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr, - dest_addr); - - /* Send the packet out. */ - ND6_STATS_INC(nd6.xmit); - ip6_output_if(p, src_addr, dest_addr, - LWIP_ICMP6_HL, 0, IP6_NEXTH_ICMP6, netif); - pbuf_free(p); -} - -#if LWIP_IPV6_SEND_ROUTER_SOLICIT -/** - * Send a router solicitation message - * - * @param netif the netif on which to send the message - */ -static void -nd6_send_rs(struct netif * netif) -{ - struct rs_header * rs_hdr; - struct lladdr_option * lladdr_opt; - struct pbuf * p; - ip6_addr_t * src_addr; - u16_t packet_len; - - /* Link-local source address, or unspecified address? */ - if (ip6_addr_isvalid(netif_ip6_addr_state(netif, 0))) { - src_addr = netif_ip6_addr(netif, 0); - } - else { - src_addr = IP6_ADDR_ANY; - } - - /* Generate the all routers target address. */ - ip6_addr_set_allrouters_linklocal(&multicast_address); - - /* Allocate a packet. */ - packet_len = sizeof(struct rs_header); - if (src_addr != IP6_ADDR_ANY) { - packet_len += sizeof(struct lladdr_option); - } - p = pbuf_alloc(PBUF_IP, packet_len, PBUF_RAM); - if ((p == NULL) || (p->len < packet_len)) { - /* We couldn't allocate a suitable pbuf for the ns. drop it. */ - if (p != NULL) { - pbuf_free(p); - } - ND6_STATS_INC(nd6.memerr); - return; - } - - /* Set fields. */ - rs_hdr = (struct rs_header *)p->payload; - - rs_hdr->type = ICMP6_TYPE_RS; - rs_hdr->code = 0; - rs_hdr->chksum = 0; - rs_hdr->reserved = 0; - - if (src_addr != IP6_ADDR_ANY) { - /* Include our hw address. */ - lladdr_opt = (struct lladdr_option *)((u8_t*)p->payload + sizeof(struct rs_header)); - lladdr_opt->type = ND6_OPTION_TYPE_SOURCE_LLADDR; - lladdr_opt->length = ((netif->hwaddr_len + 2) >> 3) + (((netif->hwaddr_len + 2) & 0x07) ? 1 : 0); - SMEMCPY(lladdr_opt->addr, netif->hwaddr, netif->hwaddr_len); - } - - rs_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr, - &multicast_address); - - /* Send the packet out. */ - ND6_STATS_INC(nd6.xmit); - ip6_output_if(p, src_addr, &multicast_address, - LWIP_ICMP6_HL, 0, IP6_NEXTH_ICMP6, netif); - pbuf_free(p); -} -#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ - -/** - * Search for a neighbor cache entry - * - * @param ip6addr the IPv6 address of the neighbor - * @return The neighbor cache entry index that matched, -1 if no - * entry is found - */ -static s8_t -nd6_find_neighbor_cache_entry(ip6_addr_t * ip6addr) -{ - s8_t i; - for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { - if (ip6_addr_cmp(ip6addr, &(neighbor_cache[i].next_hop_address))) { - return i; - } - } - return -1; -} - -/** - * Create a new neighbor cache entry. - * - * If no unused entry is found, will try to recycle an old entry - * according to ad-hoc "age" heuristic. - * - * @return The neighbor cache entry index that was created, -1 if no - * entry could be created - */ -static s8_t -nd6_new_neighbor_cache_entry(void) -{ - s8_t i; - s8_t j; - u32_t time; - - - /* First, try to find an empty entry. */ - for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { - if (neighbor_cache[i].state == ND6_NO_ENTRY) { - return i; - } - } - - /* We need to recycle an entry. in general, do not recycle if it is a router. */ - - /* Next, try to find a Stale entry. */ - for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { - if ((neighbor_cache[i].state == ND6_STALE) && - (!neighbor_cache[i].isrouter)) { - nd6_free_neighbor_cache_entry(i); - return i; - } - } - - /* Next, try to find a Probe entry. */ - for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { - if ((neighbor_cache[i].state == ND6_PROBE) && - (!neighbor_cache[i].isrouter)) { - nd6_free_neighbor_cache_entry(i); - return i; - } - } - - /* Next, try to find a Delayed entry. */ - for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { - if ((neighbor_cache[i].state == ND6_DELAY) && - (!neighbor_cache[i].isrouter)) { - nd6_free_neighbor_cache_entry(i); - return i; - } - } - - /* Next, try to find the oldest reachable entry. */ - time = 0xfffffffful; - j = -1; - for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { - if ((neighbor_cache[i].state == ND6_REACHABLE) && - (!neighbor_cache[i].isrouter)) { - if (neighbor_cache[i].counter.reachable_time < time) { - j = i; - time = neighbor_cache[i].counter.reachable_time; - } - } - } - if (j >= 0) { - nd6_free_neighbor_cache_entry(j); - return j; - } - - /* Next, find oldest incomplete entry without queued packets. */ - time = 0; - j = -1; - for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { - if ( - (neighbor_cache[i].q == NULL) && - (neighbor_cache[i].state == ND6_INCOMPLETE) && - (!neighbor_cache[i].isrouter)) { - if (neighbor_cache[i].counter.probes_sent >= time) { - j = i; - time = neighbor_cache[i].counter.probes_sent; - } - } - } - if (j >= 0) { - nd6_free_neighbor_cache_entry(j); - return j; - } - - /* Next, find oldest incomplete entry with queued packets. */ - time = 0; - j = -1; - for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) { - if ((neighbor_cache[i].state == ND6_INCOMPLETE) && - (!neighbor_cache[i].isrouter)) { - if (neighbor_cache[i].counter.probes_sent >= time) { - j = i; - time = neighbor_cache[i].counter.probes_sent; - } - } - } - if (j >= 0) { - nd6_free_neighbor_cache_entry(j); - return j; - } - - /* No more entries to try. */ - return -1; -} - -/** - * Will free any resources associated with a neighbor cache - * entry, and will mark it as unused. - * - * @param i the neighbor cache entry index to free - */ -static void -nd6_free_neighbor_cache_entry(s8_t i) -{ - if ((i < 0) || (i >= LWIP_ND6_NUM_NEIGHBORS)) { - return; - } - - /* Free any queued packets. */ - if (neighbor_cache[i].q != NULL) { - nd6_free_q(neighbor_cache[i].q); - neighbor_cache[i].q = NULL; - } - - neighbor_cache[i].state = ND6_NO_ENTRY; - neighbor_cache[i].isrouter = 0; - neighbor_cache[i].netif = NULL; - neighbor_cache[i].counter.reachable_time = 0; - ip6_addr_set_zero(&(neighbor_cache[i].next_hop_address)); -} - -/** - * Search for a destination cache entry - * - * @param ip6addr the IPv6 address of the destination - * @return The destination cache entry index that matched, -1 if no - * entry is found - */ -static s8_t -nd6_find_destination_cache_entry(ip6_addr_t * ip6addr) -{ - s8_t i; - for (i = 0; i < LWIP_ND6_NUM_DESTINATIONS; i++) { - if (ip6_addr_cmp(ip6addr, &(destination_cache[i].destination_addr))) { - return i; - } - } - return -1; -} - -/** - * Create a new destination cache entry. If no unused entry is found, - * will recycle oldest entry. - * - * @return The destination cache entry index that was created, -1 if no - * entry was created - */ -static s8_t -nd6_new_destination_cache_entry(void) -{ - s8_t i, j; - u32_t age; - - /* Find an empty entry. */ - for (i = 0; i < LWIP_ND6_NUM_DESTINATIONS; i++) { - if (ip6_addr_isany(&(destination_cache[i].destination_addr))) { - return i; - } - } - - /* Find oldest entry. */ - age = 0; - j = LWIP_ND6_NUM_DESTINATIONS - 1; - for (i = 0; i < LWIP_ND6_NUM_DESTINATIONS; i++) { - if (destination_cache[i].age > age) { - j = i; - } - } - - return j; -} - -/** - * Determine whether an address matches an on-link prefix. - * - * @param ip6addr the IPv6 address to match - * @return 1 if the address is on-link, 0 otherwise - */ -static s8_t -nd6_is_prefix_in_netif(ip6_addr_t * ip6addr, struct netif * netif) -{ - s8_t i; - for (i = 0; i < LWIP_ND6_NUM_PREFIXES; i++) { - if ((prefix_list[i].netif == netif) && - (prefix_list[i].invalidation_timer > 0) && - ip6_addr_netcmp(ip6addr, &(prefix_list[i].prefix))) { - return 1; - } - } - /* Check to see if address prefix matches a (manually?) configured address. */ - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && - ip6_addr_netcmp(ip6addr, netif_ip6_addr(netif, i))) { - return 1; - } - } - return 0; -} - -/** - * Select a default router for a destination. - * - * @param ip6addr the destination address - * @param netif the netif for the outgoing packet, if known - * @return the default router entry index, or -1 if no suitable - * router is found - */ -s8_t -nd6_select_router(ip6_addr_t * ip6addr, struct netif * netif) -{ - s8_t i; - /* last_router is used for round-robin router selection (as recommended - * in RFC). This is more robust in case one router is not reachable, - * we are not stuck trying to resolve it. */ - static s8_t last_router; - (void)ip6addr; /* TODO match preferred routes!! (must implement ND6_OPTION_TYPE_ROUTE_INFO) */ - - /* TODO: implement default router preference */ - - /* Look for reachable routers. */ - for (i = 0; i < LWIP_ND6_NUM_ROUTERS; i++) { - if (++last_router >= LWIP_ND6_NUM_ROUTERS) { - last_router = 0; - } - if ((default_router_list[i].neighbor_entry != NULL) && - (netif != NULL ? netif == default_router_list[i].neighbor_entry->netif : 1) && - (default_router_list[i].invalidation_timer > 0) && - (default_router_list[i].neighbor_entry->state == ND6_REACHABLE)) { - return i; - } - } - - /* Look for router in other reachability states, but still valid according to timer. */ - for (i = 0; i < LWIP_ND6_NUM_ROUTERS; i++) { - if (++last_router >= LWIP_ND6_NUM_ROUTERS) { - last_router = 0; - } - if ((default_router_list[i].neighbor_entry != NULL) && - (netif != NULL ? netif == default_router_list[i].neighbor_entry->netif : 1) && - (default_router_list[i].invalidation_timer > 0)) { - return i; - } - } - - /* Look for any router for which we have any information at all. */ - for (i = 0; i < LWIP_ND6_NUM_ROUTERS; i++) { - if (++last_router >= LWIP_ND6_NUM_ROUTERS) { - last_router = 0; - } - if (default_router_list[i].neighbor_entry != NULL && - (netif != NULL ? netif == default_router_list[i].neighbor_entry->netif : 1)) { - return i; - } - } - - /* no suitable router found. */ - return -1; -} - -/** - * Find an entry for a default router. - * - * @param router_addr the IPv6 address of the router - * @param netif the netif on which the router is found, if known - * @return the index of the router entry, or -1 if not found - */ -static s8_t -nd6_get_router(ip6_addr_t * router_addr, struct netif * netif) -{ - s8_t i; - - /* Look for router. */ - for (i = 0; i < LWIP_ND6_NUM_ROUTERS; i++) { - if ((default_router_list[i].neighbor_entry != NULL) && - ((netif != NULL) ? netif == default_router_list[i].neighbor_entry->netif : 1) && - ip6_addr_cmp(router_addr, &(default_router_list[i].neighbor_entry->next_hop_address))) { - return i; - } - } - - /* router not found. */ - return -1; -} - -/** - * Create a new entry for a default router. - * - * @param router_addr the IPv6 address of the router - * @param netif the netif on which the router is connected, if known - * @return the index on the router table, or -1 if could not be created - */ -static s8_t -nd6_new_router(ip6_addr_t * router_addr, struct netif * netif) -{ - s8_t router_index; - s8_t neighbor_index; - - /* Do we have a neighbor entry for this router? */ - neighbor_index = nd6_find_neighbor_cache_entry(router_addr); - if (neighbor_index < 0) { - /* Create a neighbor entry for this router. */ - neighbor_index = nd6_new_neighbor_cache_entry(); - if (neighbor_index < 0) { - /* Could not create neighbor entry for this router. */ - return -1; - } - ip6_addr_set(&(neighbor_cache[neighbor_index].next_hop_address), router_addr); - neighbor_cache[neighbor_index].netif = netif; - neighbor_cache[neighbor_index].q = NULL; - neighbor_cache[neighbor_index].state = ND6_INCOMPLETE; - neighbor_cache[neighbor_index].counter.probes_sent = 0; - } - - /* Mark neighbor as router. */ - neighbor_cache[neighbor_index].isrouter = 1; - - /* Look for empty entry. */ - for (router_index = 0; router_index < LWIP_ND6_NUM_ROUTERS; router_index++) { - if (default_router_list[router_index].neighbor_entry == NULL) { - default_router_list[router_index].neighbor_entry = &(neighbor_cache[neighbor_index]); - return router_index; - } - } - - /* Could not create a router entry. */ - - /* Mark neighbor entry as not-router. Entry might be useful as neighbor still. */ - neighbor_cache[neighbor_index].isrouter = 0; - - /* router not found. */ - return -1; -} - -/** - * Find the cached entry for an on-link prefix. - * - * @param prefix the IPv6 prefix that is on-link - * @param netif the netif on which the prefix is on-link - * @return the index on the prefix table, or -1 if not found - */ -static s8_t -nd6_get_onlink_prefix(ip6_addr_t * prefix, struct netif * netif) -{ - s8_t i; - - /* Look for prefix in list. */ - for (i = 0; i < LWIP_ND6_NUM_PREFIXES; ++i) { - if ((ip6_addr_netcmp(&(prefix_list[i].prefix), prefix)) && - (prefix_list[i].netif == netif)) { - return i; - } - } - - /* Entry not available. */ - return -1; -} - -/** - * Creates a new entry for an on-link prefix. - * - * @param prefix the IPv6 prefix that is on-link - * @param netif the netif on which the prefix is on-link - * @return the index on the prefix table, or -1 if not created - */ -static s8_t -nd6_new_onlink_prefix(ip6_addr_t * prefix, struct netif * netif) -{ - s8_t i; - - /* Create new entry. */ - for (i = 0; i < LWIP_ND6_NUM_PREFIXES; ++i) { - if ((prefix_list[i].netif == NULL) || - (prefix_list[i].invalidation_timer == 0)) { - /* Found empty prefix entry. */ - prefix_list[i].netif = netif; - ip6_addr_set(&(prefix_list[i].prefix), prefix); -#if LWIP_IPV6_AUTOCONFIG - prefix_list[i].flags = 0; -#endif - return i; - } - } - - /* Entry not available. */ - return -1; -} - -/** - * Determine the next hop for a destination. Will determine if the - * destination is on-link, else a suitable on-link router is selected. - * - * The last entry index is cached for fast entry search. - * - * @param ip6addr the destination address - * @param netif the netif on which the packet will be sent - * @return the neighbor cache entry for the next hop, ERR_RTE if no - * suitable next hop was found, ERR_MEM if no cache entry - * could be created - */ -s8_t -nd6_get_next_hop_entry(ip6_addr_t * ip6addr, struct netif * netif) -{ - s8_t i; - -#if LWIP_NETIF_HWADDRHINT - if (netif->addr_hint != NULL) { - /* per-pcb cached entry was given */ - u8_t addr_hint = *(netif->addr_hint); - if (addr_hint < LWIP_ND6_NUM_DESTINATIONS) { - nd6_cached_destination_index = addr_hint; - } - } -#endif /* LWIP_NETIF_HWADDRHINT */ - - /* Look for ip6addr in destination cache. */ - if (ip6_addr_cmp(ip6addr, &(destination_cache[nd6_cached_destination_index].destination_addr))) { - /* the cached entry index is the right one! */ - /* do nothing. */ - ND6_STATS_INC(nd6.cachehit); - } else { - /* Search destination cache. */ - i = nd6_find_destination_cache_entry(ip6addr); - if (i >= 0) { - /* found destination entry. make it our new cached index. */ - nd6_cached_destination_index = i; - } - else { - /* Not found. Create a new destination entry. */ - i = nd6_new_destination_cache_entry(); - if (i >= 0) { - /* got new destination entry. make it our new cached index. */ - nd6_cached_destination_index = i; - } else { - /* Could not create a destination cache entry. */ - return ERR_MEM; - } - - /* Copy dest address to destination cache. */ - ip6_addr_set(&(destination_cache[nd6_cached_destination_index].destination_addr), ip6addr); - - /* Now find the next hop. is it a neighbor? */ - if (ip6_addr_islinklocal(ip6addr) || - nd6_is_prefix_in_netif(ip6addr, netif)) { - /* Destination in local link. */ - destination_cache[nd6_cached_destination_index].pmtu = netif->mtu; - ip6_addr_copy(destination_cache[nd6_cached_destination_index].next_hop_addr, destination_cache[nd6_cached_destination_index].destination_addr); - } - else { - /* We need to select a router. */ - i = nd6_select_router(ip6addr, netif); - if (i < 0) { - /* No router found. */ - ip6_addr_set_any(&(destination_cache[nd6_cached_destination_index].destination_addr)); - return ERR_RTE; - } - destination_cache[nd6_cached_destination_index].pmtu = netif->mtu; /* Start with netif mtu, correct through ICMPv6 if necessary */ - ip6_addr_copy(destination_cache[nd6_cached_destination_index].next_hop_addr, default_router_list[i].neighbor_entry->next_hop_address); - } - } - } - -#if LWIP_NETIF_HWADDRHINT - if (netif->addr_hint != NULL) { - /* per-pcb cached entry was given */ - *(netif->addr_hint) = nd6_cached_destination_index; - } -#endif /* LWIP_NETIF_HWADDRHINT */ - - /* Look in neighbor cache for the next-hop address. */ - if (ip6_addr_cmp(&(destination_cache[nd6_cached_destination_index].next_hop_addr), - &(neighbor_cache[nd6_cached_neighbor_index].next_hop_address))) { - /* Cache hit. */ - /* Do nothing. */ - ND6_STATS_INC(nd6.cachehit); - } else { - i = nd6_find_neighbor_cache_entry(&(destination_cache[nd6_cached_destination_index].next_hop_addr)); - if (i >= 0) { - /* Found a matching record, make it new cached entry. */ - nd6_cached_neighbor_index = i; - } - else { - /* Neighbor not in cache. Make a new entry. */ - i = nd6_new_neighbor_cache_entry(); - if (i >= 0) { - /* got new neighbor entry. make it our new cached index. */ - nd6_cached_neighbor_index = i; - } else { - /* Could not create a neighbor cache entry. */ - return ERR_MEM; - } - - /* Initialize fields. */ - ip6_addr_copy(neighbor_cache[i].next_hop_address, - destination_cache[nd6_cached_destination_index].next_hop_addr); - neighbor_cache[i].isrouter = 0; - neighbor_cache[i].netif = netif; - neighbor_cache[i].state = ND6_INCOMPLETE; - neighbor_cache[i].counter.probes_sent = 0; - } - } - - /* Reset this destination's age. */ - destination_cache[nd6_cached_destination_index].age = 0; - - return nd6_cached_neighbor_index; -} - -/** - * Queue a packet for a neighbor. - * - * @param neighbor_index the index in the neighbor cache table - * @param q packet to be queued - * @return ERR_OK if succeeded, ERR_MEM if out of memory - */ -err_t -nd6_queue_packet(s8_t neighbor_index, struct pbuf * q) -{ - err_t result = ERR_MEM; - struct pbuf *p; - int copy_needed = 0; -#if LWIP_ND6_QUEUEING - struct nd6_q_entry *new_entry, *r; -#endif /* LWIP_ND6_QUEUEING */ - - if ((neighbor_index < 0) || (neighbor_index >= LWIP_ND6_NUM_NEIGHBORS)) { - return ERR_ARG; - } - - /* IF q includes a PBUF_REF, PBUF_POOL or PBUF_RAM, we have no choice but - * to copy the whole queue into a new PBUF_RAM (see bug #11400) - * PBUF_ROMs can be left as they are, since ROM must not get changed. */ - p = q; - while (p) { - if(p->type != PBUF_ROM) { - copy_needed = 1; - break; - } - p = p->next; - } - if(copy_needed) { - /* copy the whole packet into new pbufs */ - p = pbuf_alloc(PBUF_LINK, q->tot_len, PBUF_RAM); - while ((p == NULL) && (neighbor_cache[neighbor_index].q != NULL)) { - /* Free oldest packet (as per RFC recommendation) */ -#if LWIP_ND6_QUEUEING - r = neighbor_cache[neighbor_index].q; - neighbor_cache[neighbor_index].q = r->next; - r->next = NULL; - nd6_free_q(r); -#else /* LWIP_ND6_QUEUEING */ - pbuf_free(neighbor_cache[neighbor_index].q); - neighbor_cache[neighbor_index].q = NULL; -#endif /* LWIP_ND6_QUEUEING */ - p = pbuf_alloc(PBUF_LINK, q->tot_len, PBUF_RAM); - } - if(p != NULL) { - if (pbuf_copy(p, q) != ERR_OK) { - pbuf_free(p); - p = NULL; - } - } - } else { - /* referencing the old pbuf is enough */ - p = q; - pbuf_ref(p); - } - /* packet was copied/ref'd? */ - if (p != NULL) { - /* queue packet ... */ -#if LWIP_ND6_QUEUEING - /* allocate a new nd6 queue entry */ - new_entry = (struct nd6_q_entry *)memp_malloc(MEMP_ND6_QUEUE); - if ((new_entry == NULL) && (neighbor_cache[neighbor_index].q != NULL)) { - /* Free oldest packet (as per RFC recommendation) */ - r = neighbor_cache[neighbor_index].q; - neighbor_cache[neighbor_index].q = r->next; - r->next = NULL; - nd6_free_q(r); - new_entry = (struct nd6_q_entry *)memp_malloc(MEMP_ND6_QUEUE); - } - if (new_entry != NULL) { - new_entry->next = NULL; - new_entry->p = p; - if(neighbor_cache[neighbor_index].q != NULL) { - /* queue was already existent, append the new entry to the end */ - r = neighbor_cache[neighbor_index].q; - while (r->next != NULL) { - r = r->next; - } - r->next = new_entry; - } else { - /* queue did not exist, first item in queue */ - neighbor_cache[neighbor_index].q = new_entry; - } - LWIP_DEBUGF(LWIP_DBG_TRACE, ("ipv6: queued packet %p on neighbor entry %"S16_F"\n", (void *)p, (s16_t)neighbor_index)); - result = ERR_OK; - } else { - /* the pool MEMP_ND6_QUEUE is empty */ - pbuf_free(p); - LWIP_DEBUGF(LWIP_DBG_TRACE, ("ipv6: could not queue a copy of packet %p (out of memory)\n", (void *)p)); - /* { result == ERR_MEM } through initialization */ - } -#else /* LWIP_ND6_QUEUEING */ - /* Queue a single packet. If an older packet is already queued, free it as per RFC. */ - if (neighbor_cache[neighbor_index].q != NULL) { - pbuf_free(neighbor_cache[neighbor_index].q); - } - neighbor_cache[neighbor_index].q = p; - LWIP_DEBUGF(LWIP_DBG_TRACE, ("ipv6: queued packet %p on neighbor entry %"S16_F"\n", (void *)p, (s16_t)neighbor_index)); - result = ERR_OK; -#endif /* LWIP_ND6_QUEUEING */ - } else { - LWIP_DEBUGF(LWIP_DBG_TRACE, ("ipv6: could not queue a copy of packet %p (out of memory)\n", (void *)q)); - /* { result == ERR_MEM } through initialization */ - } - - return result; -} - -#if LWIP_ND6_QUEUEING -/** - * Free a complete queue of nd6 q entries - * - * @param q a queue of nd6_q_entry to free - */ -static void -nd6_free_q(struct nd6_q_entry *q) -{ - struct nd6_q_entry *r; - LWIP_ASSERT("q != NULL", q != NULL); - LWIP_ASSERT("q->p != NULL", q->p != NULL); - while (q) { - r = q; - q = q->next; - LWIP_ASSERT("r->p != NULL", (r->p != NULL)); - pbuf_free(r->p); - memp_free(MEMP_ND6_QUEUE, r); - } -} -#endif /* LWIP_ND6_QUEUEING */ - -/** - * Send queued packets for a neighbor - * - * @param i the neighbor to send packets to - */ -static void -nd6_send_q(s8_t i) -{ - struct ip6_hdr *ip6hdr; -#if LWIP_ND6_QUEUEING - struct nd6_q_entry *q; -#endif /* LWIP_ND6_QUEUEING */ - - if ((i < 0) || (i >= LWIP_ND6_NUM_NEIGHBORS)) { - return; - } - -#if LWIP_ND6_QUEUEING - while (neighbor_cache[i].q != NULL) { - /* remember first in queue */ - q = neighbor_cache[i].q; - /* pop first item off the queue */ - neighbor_cache[i].q = q->next; - /* Get ipv6 header. */ - ip6hdr = (struct ip6_hdr *)(q->p->payload); - /* Override ip6_current_dest_addr() so that we have an aligned copy. */ - ip6_addr_set(ip6_current_dest_addr(), &(ip6hdr->dest)); - /* send the queued IPv6 packet */ - (neighbor_cache[i].netif)->output_ip6(neighbor_cache[i].netif, q->p, ip6_current_dest_addr()); - /* free the queued IP packet */ - pbuf_free(q->p); - /* now queue entry can be freed */ - memp_free(MEMP_ND6_QUEUE, q); - } -#else /* LWIP_ND6_QUEUEING */ - if (neighbor_cache[i].q != NULL) { - /* Get ipv6 header. */ - ip6hdr = (struct ip6_hdr *)(neighbor_cache[i].q->payload); - /* Override ip6_current_dest_addr() so that we have an aligned copy. */ - ip6_addr_set(ip6_current_dest_addr(), &(ip6hdr->dest)); - /* send the queued IPv6 packet */ - (neighbor_cache[i].netif)->output_ip6(neighbor_cache[i].netif, neighbor_cache[i].q, ip6_current_dest_addr()); - /* free the queued IP packet */ - pbuf_free(neighbor_cache[i].q); - neighbor_cache[i].q = NULL; - } -#endif /* LWIP_ND6_QUEUEING */ -} - - -/** - * Get the Path MTU for a destination. - * - * @param ip6addr the destination address - * @param netif the netif on which the packet will be sent - * @return the Path MTU, if known, or the netif default MTU - */ -u16_t -nd6_get_destination_mtu(ip6_addr_t * ip6addr, struct netif * netif) -{ - s8_t i; - - i = nd6_find_destination_cache_entry(ip6addr); - if (i >= 0) { - if (destination_cache[i].pmtu > 0) { - return destination_cache[i].pmtu; - } - } - - if (netif != NULL) { - return netif->mtu; - } - - return 1280; /* Minimum MTU */ -} - - -#if LWIP_ND6_TCP_REACHABILITY_HINTS -/** - * Provide the Neighbor discovery process with a hint that a - * destination is reachable. Called by tcp_receive when ACKs are - * received or sent (as per RFC). This is useful to avoid sending - * NS messages every 30 seconds. - * - * @param ip6addr the destination address which is know to be reachable - * by an upper layer protocol (TCP) - */ -void -nd6_reachability_hint(ip6_addr_t * ip6addr) -{ - s8_t i; - - /* Find destination in cache. */ - if (ip6_addr_cmp(ip6addr, &(destination_cache[nd6_cached_destination_index].destination_addr))) { - i = nd6_cached_destination_index; - ND6_STATS_INC(nd6.cachehit); - } - else { - i = nd6_find_destination_cache_entry(ip6addr); - } - if (i < 0) { - return; - } - - /* Find next hop neighbor in cache. */ - if (ip6_addr_cmp(&(destination_cache[i].next_hop_addr), &(neighbor_cache[nd6_cached_neighbor_index].next_hop_address))) { - i = nd6_cached_neighbor_index; - ND6_STATS_INC(nd6.cachehit); - } - else { - i = nd6_find_neighbor_cache_entry(&(destination_cache[i].next_hop_addr)); - } - if (i < 0) { - return; - } - - /* Set reachability state. */ - neighbor_cache[i].state = ND6_REACHABLE; - neighbor_cache[i].counter.reachable_time = reachable_time; -} -#endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */ - -#endif /* LWIP_IPV6 */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/mem.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/mem.c deleted file mode 100644 index 1659a2c7..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/mem.c +++ /dev/null @@ -1,659 +0,0 @@ -/** - * @file - * Dynamic memory manager - * - * This is a lightweight replacement for the standard C library malloc(). - * - * If you want to use the standard C library malloc() instead, define - * MEM_LIBC_MALLOC to 1 in your lwipopts.h - * - * To let mem_malloc() use pools (prevents fragmentation and is much faster than - * a heap but might waste some memory), define MEM_USE_POOLS to 1, define - * MEM_USE_CUSTOM_POOLS to 1 and create a file "lwippools.h" that includes a list - * of pools like this (more pools can be added between _START and _END): - * - * Define three pools with sizes 256, 512, and 1512 bytes - * LWIP_MALLOC_MEMPOOL_START - * LWIP_MALLOC_MEMPOOL(20, 256) - * LWIP_MALLOC_MEMPOOL(10, 512) - * LWIP_MALLOC_MEMPOOL(5, 1512) - * LWIP_MALLOC_MEMPOOL_END - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * Simon Goldschmidt - * - */ - -#include "lwip/opt.h" - -#if !MEM_LIBC_MALLOC /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/sys.h" -#include "lwip/stats.h" -#include "lwip/err.h" - -#include - -#if MEM_USE_POOLS -/* lwIP head implemented with different sized pools */ - -/** - * Allocate memory: determine the smallest pool that is big enough - * to contain an element of 'size' and get an element from that pool. - * - * @param size the size in bytes of the memory needed - * @return a pointer to the allocated memory or NULL if the pool is empty - */ -void * -mem_malloc(mem_size_t size) -{ - void *ret; - struct memp_malloc_helper *element; - memp_t poolnr; - mem_size_t required_size = size + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper)); - - for (poolnr = MEMP_POOL_FIRST; poolnr <= MEMP_POOL_LAST; poolnr = (memp_t)(poolnr + 1)) { -#if MEM_USE_POOLS_TRY_BIGGER_POOL -again: -#endif /* MEM_USE_POOLS_TRY_BIGGER_POOL */ - /* is this pool big enough to hold an element of the required size - plus a struct memp_malloc_helper that saves the pool this element came from? */ - if (required_size <= memp_sizes[poolnr]) { - break; - } - } - if (poolnr > MEMP_POOL_LAST) { - LWIP_ASSERT("mem_malloc(): no pool is that big!", 0); - return NULL; - } - element = (struct memp_malloc_helper*)memp_malloc(poolnr); - if (element == NULL) { - /* No need to DEBUGF or ASSERT: This error is already - taken care of in memp.c */ -#if MEM_USE_POOLS_TRY_BIGGER_POOL - /** Try a bigger pool if this one is empty! */ - if (poolnr < MEMP_POOL_LAST) { - poolnr++; - goto again; - } -#endif /* MEM_USE_POOLS_TRY_BIGGER_POOL */ - return NULL; - } - - /* save the pool number this element came from */ - element->poolnr = poolnr; - /* and return a pointer to the memory directly after the struct memp_malloc_helper */ - ret = (u8_t*)element + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper)); - - return ret; -} - -/** - * Free memory previously allocated by mem_malloc. Loads the pool number - * and calls memp_free with that pool number to put the element back into - * its pool - * - * @param rmem the memory element to free - */ -void -mem_free(void *rmem) -{ - struct memp_malloc_helper *hmem; - - LWIP_ASSERT("rmem != NULL", (rmem != NULL)); - LWIP_ASSERT("rmem == MEM_ALIGN(rmem)", (rmem == LWIP_MEM_ALIGN(rmem))); - - /* get the original struct memp_malloc_helper */ - hmem = (struct memp_malloc_helper*)(void*)((u8_t*)rmem - LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))); - - LWIP_ASSERT("hmem != NULL", (hmem != NULL)); - LWIP_ASSERT("hmem == MEM_ALIGN(hmem)", (hmem == LWIP_MEM_ALIGN(hmem))); - LWIP_ASSERT("hmem->poolnr < MEMP_MAX", (hmem->poolnr < MEMP_MAX)); - - /* and put it in the pool we saved earlier */ - memp_free(hmem->poolnr, hmem); -} - -#else /* MEM_USE_POOLS */ -/* lwIP replacement for your libc malloc() */ - -/** - * The heap is made up as a list of structs of this type. - * This does not have to be aligned since for getting its size, - * we only use the macro SIZEOF_STRUCT_MEM, which automatically alignes. - */ -struct mem { - /** index (-> ram[next]) of the next struct */ - mem_size_t next; - /** index (-> ram[prev]) of the previous struct */ - mem_size_t prev; - /** 1: this area is used; 0: this area is unused */ - u8_t used; -}; - -/** All allocated blocks will be MIN_SIZE bytes big, at least! - * MIN_SIZE can be overridden to suit your needs. Smaller values save space, - * larger values could prevent too small blocks to fragment the RAM too much. */ -#ifndef MIN_SIZE -#define MIN_SIZE 12 -#endif /* MIN_SIZE */ -/* some alignment macros: we define them here for better source code layout */ -#define MIN_SIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(MIN_SIZE) -#define SIZEOF_STRUCT_MEM LWIP_MEM_ALIGN_SIZE(sizeof(struct mem)) -#define MEM_SIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(MEM_SIZE) - -/** If you want to relocate the heap to external memory, simply define - * LWIP_RAM_HEAP_POINTER as a void-pointer to that location. - * If so, make sure the memory at that location is big enough (see below on - * how that space is calculated). */ -#ifndef LWIP_RAM_HEAP_POINTER -/** the heap. we need one struct mem at the end and some room for alignment */ -u8_t ram_heap[MEM_SIZE_ALIGNED + (2*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT]; -#define LWIP_RAM_HEAP_POINTER ram_heap -#endif /* LWIP_RAM_HEAP_POINTER */ - -/** pointer to the heap (ram_heap): for alignment, ram is now a pointer instead of an array */ -static u8_t *ram; -/** the last entry, always unused! */ -static struct mem *ram_end; -/** pointer to the lowest free block, this is used for faster search */ -static struct mem *lfree; - -/** concurrent access protection */ -#if !NO_SYS -static sys_mutex_t mem_mutex; -#endif - -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - -static volatile u8_t mem_free_count; - -/* Allow mem_free from other (e.g. interrupt) context */ -#define LWIP_MEM_FREE_DECL_PROTECT() SYS_ARCH_DECL_PROTECT(lev_free) -#define LWIP_MEM_FREE_PROTECT() SYS_ARCH_PROTECT(lev_free) -#define LWIP_MEM_FREE_UNPROTECT() SYS_ARCH_UNPROTECT(lev_free) -#define LWIP_MEM_ALLOC_DECL_PROTECT() SYS_ARCH_DECL_PROTECT(lev_alloc) -#define LWIP_MEM_ALLOC_PROTECT() SYS_ARCH_PROTECT(lev_alloc) -#define LWIP_MEM_ALLOC_UNPROTECT() SYS_ARCH_UNPROTECT(lev_alloc) - -#else /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - -/* Protect the heap only by using a semaphore */ -#define LWIP_MEM_FREE_DECL_PROTECT() -#define LWIP_MEM_FREE_PROTECT() sys_mutex_lock(&mem_mutex) -#define LWIP_MEM_FREE_UNPROTECT() sys_mutex_unlock(&mem_mutex) -/* mem_malloc is protected using semaphore AND LWIP_MEM_ALLOC_PROTECT */ -#define LWIP_MEM_ALLOC_DECL_PROTECT() -#define LWIP_MEM_ALLOC_PROTECT() -#define LWIP_MEM_ALLOC_UNPROTECT() - -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - - -/** - * "Plug holes" by combining adjacent empty struct mems. - * After this function is through, there should not exist - * one empty struct mem pointing to another empty struct mem. - * - * @param mem this points to a struct mem which just has been freed - * @internal this function is only called by mem_free() and mem_trim() - * - * This assumes access to the heap is protected by the calling function - * already. - */ -static void -plug_holes(struct mem *mem) -{ - struct mem *nmem; - struct mem *pmem; - - LWIP_ASSERT("plug_holes: mem >= ram", (u8_t *)mem >= ram); - LWIP_ASSERT("plug_holes: mem < ram_end", (u8_t *)mem < (u8_t *)ram_end); - LWIP_ASSERT("plug_holes: mem->used == 0", mem->used == 0); - - /* plug hole forward */ - LWIP_ASSERT("plug_holes: mem->next <= MEM_SIZE_ALIGNED", mem->next <= MEM_SIZE_ALIGNED); - - nmem = (struct mem *)(void *)&ram[mem->next]; - if (mem != nmem && nmem->used == 0 && (u8_t *)nmem != (u8_t *)ram_end) { - /* if mem->next is unused and not end of ram, combine mem and mem->next */ - if (lfree == nmem) { - lfree = mem; - } - mem->next = nmem->next; - ((struct mem *)(void *)&ram[nmem->next])->prev = (mem_size_t)((u8_t *)mem - ram); - } - - /* plug hole backward */ - pmem = (struct mem *)(void *)&ram[mem->prev]; - if (pmem != mem && pmem->used == 0) { - /* if mem->prev is unused, combine mem and mem->prev */ - if (lfree == mem) { - lfree = pmem; - } - pmem->next = mem->next; - ((struct mem *)(void *)&ram[mem->next])->prev = (mem_size_t)((u8_t *)pmem - ram); - } -} - -/** - * Zero the heap and initialize start, end and lowest-free - */ -void -mem_init(void) -{ - struct mem *mem; - - LWIP_ASSERT("Sanity check alignment", - (SIZEOF_STRUCT_MEM & (MEM_ALIGNMENT-1)) == 0); - - /* align the heap */ - ram = (u8_t *)LWIP_MEM_ALIGN(LWIP_RAM_HEAP_POINTER); - /* initialize the start of the heap */ - mem = (struct mem *)(void *)ram; - mem->next = MEM_SIZE_ALIGNED; - mem->prev = 0; - mem->used = 0; - /* initialize the end of the heap */ - ram_end = (struct mem *)(void *)&ram[MEM_SIZE_ALIGNED]; - ram_end->used = 1; - ram_end->next = MEM_SIZE_ALIGNED; - ram_end->prev = MEM_SIZE_ALIGNED; - - /* initialize the lowest-free pointer to the start of the heap */ - lfree = (struct mem *)(void *)ram; - - MEM_STATS_AVAIL(avail, MEM_SIZE_ALIGNED); - - if(sys_mutex_new(&mem_mutex) != ERR_OK) { - LWIP_ASSERT("failed to create mem_mutex", 0); - } -} - -/** - * Put a struct mem back on the heap - * - * @param rmem is the data portion of a struct mem as returned by a previous - * call to mem_malloc() - */ -void -mem_free(void *rmem) -{ - struct mem *mem; - LWIP_MEM_FREE_DECL_PROTECT(); - - if (rmem == NULL) { - LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("mem_free(p == NULL) was called.\n")); - return; - } - LWIP_ASSERT("mem_free: sanity check alignment", (((mem_ptr_t)rmem) & (MEM_ALIGNMENT-1)) == 0); - - LWIP_ASSERT("mem_free: legal memory", (u8_t *)rmem >= (u8_t *)ram && - (u8_t *)rmem < (u8_t *)ram_end); - - if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { - SYS_ARCH_DECL_PROTECT(lev); - LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("mem_free: illegal memory\n")); - /* protect mem stats from concurrent access */ - SYS_ARCH_PROTECT(lev); - MEM_STATS_INC(illegal); - SYS_ARCH_UNPROTECT(lev); - return; - } - /* protect the heap from concurrent access */ - LWIP_MEM_FREE_PROTECT(); - /* Get the corresponding struct mem ... */ - mem = (struct mem *)(void *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); - /* ... which has to be in a used state ... */ - LWIP_ASSERT("mem_free: mem->used", mem->used); - /* ... and is now unused. */ - mem->used = 0; - - if (mem < lfree) { - /* the newly freed struct is now the lowest */ - lfree = mem; - } - - MEM_STATS_DEC_USED(used, mem->next - (mem_size_t)(((u8_t *)mem - ram))); - - /* finally, see if prev or next are free also */ - plug_holes(mem); -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - mem_free_count = 1; -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - LWIP_MEM_FREE_UNPROTECT(); -} - -/** - * Shrink memory returned by mem_malloc(). - * - * @param rmem pointer to memory allocated by mem_malloc the is to be shrinked - * @param newsize required size after shrinking (needs to be smaller than or - * equal to the previous size) - * @return for compatibility reasons: is always == rmem, at the moment - * or NULL if newsize is > old size, in which case rmem is NOT touched - * or freed! - */ -void * -mem_trim(void *rmem, mem_size_t newsize) -{ - mem_size_t size; - mem_size_t ptr, ptr2; - struct mem *mem, *mem2; - /* use the FREE_PROTECT here: it protects with sem OR SYS_ARCH_PROTECT */ - LWIP_MEM_FREE_DECL_PROTECT(); - - /* Expand the size of the allocated memory region so that we can - adjust for alignment. */ - newsize = LWIP_MEM_ALIGN_SIZE(newsize); - - if(newsize < MIN_SIZE_ALIGNED) { - /* every data block must be at least MIN_SIZE_ALIGNED long */ - newsize = MIN_SIZE_ALIGNED; - } - - if (newsize > MEM_SIZE_ALIGNED) { - return NULL; - } - - LWIP_ASSERT("mem_trim: legal memory", (u8_t *)rmem >= (u8_t *)ram && - (u8_t *)rmem < (u8_t *)ram_end); - - if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { - SYS_ARCH_DECL_PROTECT(lev); - LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("mem_trim: illegal memory\n")); - /* protect mem stats from concurrent access */ - SYS_ARCH_PROTECT(lev); - MEM_STATS_INC(illegal); - SYS_ARCH_UNPROTECT(lev); - return rmem; - } - /* Get the corresponding struct mem ... */ - mem = (struct mem *)(void *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); - /* ... and its offset pointer */ - ptr = (mem_size_t)((u8_t *)mem - ram); - - size = mem->next - ptr - SIZEOF_STRUCT_MEM; - LWIP_ASSERT("mem_trim can only shrink memory", newsize <= size); - if (newsize > size) { - /* not supported */ - return NULL; - } - if (newsize == size) { - /* No change in size, simply return */ - return rmem; - } - - /* protect the heap from concurrent access */ - LWIP_MEM_FREE_PROTECT(); - - mem2 = (struct mem *)(void *)&ram[mem->next]; - if(mem2->used == 0) { - /* The next struct is unused, we can simply move it at little */ - mem_size_t next; - /* remember the old next pointer */ - next = mem2->next; - /* create new struct mem which is moved directly after the shrinked mem */ - ptr2 = ptr + SIZEOF_STRUCT_MEM + newsize; - if (lfree == mem2) { - lfree = (struct mem *)(void *)&ram[ptr2]; - } - mem2 = (struct mem *)(void *)&ram[ptr2]; - mem2->used = 0; - /* restore the next pointer */ - mem2->next = next; - /* link it back to mem */ - mem2->prev = ptr; - /* link mem to it */ - mem->next = ptr2; - /* last thing to restore linked list: as we have moved mem2, - * let 'mem2->next->prev' point to mem2 again. but only if mem2->next is not - * the end of the heap */ - if (mem2->next != MEM_SIZE_ALIGNED) { - ((struct mem *)(void *)&ram[mem2->next])->prev = ptr2; - } - MEM_STATS_DEC_USED(used, (size - newsize)); - /* no need to plug holes, we've already done that */ - } else if (newsize + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED <= size) { - /* Next struct is used but there's room for another struct mem with - * at least MIN_SIZE_ALIGNED of data. - * Old size ('size') must be big enough to contain at least 'newsize' plus a struct mem - * ('SIZEOF_STRUCT_MEM') with some data ('MIN_SIZE_ALIGNED'). - * @todo we could leave out MIN_SIZE_ALIGNED. We would create an empty - * region that couldn't hold data, but when mem->next gets freed, - * the 2 regions would be combined, resulting in more free memory */ - ptr2 = ptr + SIZEOF_STRUCT_MEM + newsize; - mem2 = (struct mem *)(void *)&ram[ptr2]; - if (mem2 < lfree) { - lfree = mem2; - } - mem2->used = 0; - mem2->next = mem->next; - mem2->prev = ptr; - mem->next = ptr2; - if (mem2->next != MEM_SIZE_ALIGNED) { - ((struct mem *)(void *)&ram[mem2->next])->prev = ptr2; - } - MEM_STATS_DEC_USED(used, (size - newsize)); - /* the original mem->next is used, so no need to plug holes! */ - } - /* else { - next struct mem is used but size between mem and mem2 is not big enough - to create another struct mem - -> don't do anyhting. - -> the remaining space stays unused since it is too small - } */ -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - mem_free_count = 1; -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - LWIP_MEM_FREE_UNPROTECT(); - return rmem; -} - -/** - * Adam's mem_malloc() plus solution for bug #17922 - * Allocate a block of memory with a minimum of 'size' bytes. - * - * @param size is the minimum size of the requested block in bytes. - * @return pointer to allocated memory or NULL if no free memory was found. - * - * Note that the returned value will always be aligned (as defined by MEM_ALIGNMENT). - */ -void * -mem_malloc(mem_size_t size) -{ - mem_size_t ptr, ptr2; - struct mem *mem, *mem2; -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - u8_t local_mem_free_count = 0; -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - LWIP_MEM_ALLOC_DECL_PROTECT(); - - if (size == 0) { - return NULL; - } - - /* Expand the size of the allocated memory region so that we can - adjust for alignment. */ - size = LWIP_MEM_ALIGN_SIZE(size); - - if(size < MIN_SIZE_ALIGNED) { - /* every data block must be at least MIN_SIZE_ALIGNED long */ - size = MIN_SIZE_ALIGNED; - } - - if (size > MEM_SIZE_ALIGNED) { - return NULL; - } - - /* protect the heap from concurrent access */ - sys_mutex_lock(&mem_mutex); - LWIP_MEM_ALLOC_PROTECT(); -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - /* run as long as a mem_free disturbed mem_malloc or mem_trim */ - do { - local_mem_free_count = 0; -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - - /* Scan through the heap searching for a free block that is big enough, - * beginning with the lowest free block. - */ - for (ptr = (mem_size_t)((u8_t *)lfree - ram); ptr < MEM_SIZE_ALIGNED - size; - ptr = ((struct mem *)(void *)&ram[ptr])->next) { - mem = (struct mem *)(void *)&ram[ptr]; -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - mem_free_count = 0; - LWIP_MEM_ALLOC_UNPROTECT(); - /* allow mem_free or mem_trim to run */ - LWIP_MEM_ALLOC_PROTECT(); - if (mem_free_count != 0) { - /* If mem_free or mem_trim have run, we have to restart since they - could have altered our current struct mem. */ - local_mem_free_count = 1; - break; - } -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - - if ((!mem->used) && - (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) { - /* mem is not used and at least perfect fit is possible: - * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size' of mem */ - - if (mem->next - (ptr + SIZEOF_STRUCT_MEM) >= (size + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED)) { - /* (in addition to the above, we test if another struct mem (SIZEOF_STRUCT_MEM) containing - * at least MIN_SIZE_ALIGNED of data also fits in the 'user data space' of 'mem') - * -> split large block, create empty remainder, - * remainder must be large enough to contain MIN_SIZE_ALIGNED data: if - * mem->next - (ptr + (2*SIZEOF_STRUCT_MEM)) == size, - * struct mem would fit in but no data between mem2 and mem2->next - * @todo we could leave out MIN_SIZE_ALIGNED. We would create an empty - * region that couldn't hold data, but when mem->next gets freed, - * the 2 regions would be combined, resulting in more free memory - */ - ptr2 = ptr + SIZEOF_STRUCT_MEM + size; - /* create mem2 struct */ - mem2 = (struct mem *)(void *)&ram[ptr2]; - mem2->used = 0; - mem2->next = mem->next; - mem2->prev = ptr; - /* and insert it between mem and mem->next */ - mem->next = ptr2; - mem->used = 1; - - if (mem2->next != MEM_SIZE_ALIGNED) { - ((struct mem *)(void *)&ram[mem2->next])->prev = ptr2; - } - MEM_STATS_INC_USED(used, (size + SIZEOF_STRUCT_MEM)); - } else { - /* (a mem2 struct does no fit into the user data space of mem and mem->next will always - * be used at this point: if not we have 2 unused structs in a row, plug_holes should have - * take care of this). - * -> near fit or excact fit: do not split, no mem2 creation - * also can't move mem->next directly behind mem, since mem->next - * will always be used at this point! - */ - mem->used = 1; - MEM_STATS_INC_USED(used, mem->next - (mem_size_t)((u8_t *)mem - ram)); - } -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT -mem_malloc_adjust_lfree: -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - if (mem == lfree) { - struct mem *cur = lfree; - /* Find next free block after mem and update lowest free pointer */ - while (cur->used && cur != ram_end) { -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - mem_free_count = 0; - LWIP_MEM_ALLOC_UNPROTECT(); - /* prevent high interrupt latency... */ - LWIP_MEM_ALLOC_PROTECT(); - if (mem_free_count != 0) { - /* If mem_free or mem_trim have run, we have to restart since they - could have altered our current struct mem or lfree. */ - goto mem_malloc_adjust_lfree; - } -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - cur = (struct mem *)(void *)&ram[cur->next]; - } - lfree = cur; - LWIP_ASSERT("mem_malloc: !lfree->used", ((lfree == ram_end) || (!lfree->used))); - } - LWIP_MEM_ALLOC_UNPROTECT(); - sys_mutex_unlock(&mem_mutex); - LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.", - (mem_ptr_t)mem + SIZEOF_STRUCT_MEM + size <= (mem_ptr_t)ram_end); - LWIP_ASSERT("mem_malloc: allocated memory properly aligned.", - ((mem_ptr_t)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0); - LWIP_ASSERT("mem_malloc: sanity check alignment", - (((mem_ptr_t)mem) & (MEM_ALIGNMENT-1)) == 0); - - return (u8_t *)mem + SIZEOF_STRUCT_MEM; - } - } -#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT - /* if we got interrupted by a mem_free, try again */ - } while(local_mem_free_count != 0); -#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ - LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("mem_malloc: could not allocate %"S16_F" bytes\n", (s16_t)size)); - MEM_STATS_INC(err); - LWIP_MEM_ALLOC_UNPROTECT(); - sys_mutex_unlock(&mem_mutex); - return NULL; -} - -#endif /* MEM_USE_POOLS */ -/** - * Contiguously allocates enough space for count objects that are size bytes - * of memory each and returns a pointer to the allocated memory. - * - * The allocated memory is filled with bytes of value zero. - * - * @param count number of objects to allocate - * @param size size of the objects to allocate - * @return pointer to allocated memory / NULL pointer if there is an error - */ -void *mem_calloc(mem_size_t count, mem_size_t size) -{ - void *p; - - /* allocate 'count' objects of size 'size' */ - p = mem_malloc(count * size); - if (p) { - /* zero the memory */ - memset(p, 0, count * size); - } - return p; -} - -#endif /* !MEM_LIBC_MALLOC */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/memp.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/memp.c deleted file mode 100644 index 1323463e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/memp.c +++ /dev/null @@ -1,485 +0,0 @@ -/** - * @file - * Dynamic pool memory manager - * - * lwIP has dedicated pools for many structures (netconn, protocol control blocks, - * packet buffers, ...). All these pools are managed here. - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/memp.h" -#include "lwip/pbuf.h" -#include "lwip/udp.h" -#include "lwip/raw.h" -#include "lwip/tcp_impl.h" -#include "lwip/igmp.h" -#include "lwip/api.h" -#include "lwip/api_msg.h" -#include "lwip/tcpip.h" -#include "lwip/sys.h" -#include "lwip/timers.h" -#include "lwip/stats.h" -#include "netif/etharp.h" -#include "lwip/ip_frag.h" -#include "lwip/snmp_structs.h" -#include "lwip/snmp_msg.h" -#include "lwip/dns.h" -#include "netif/ppp_oe.h" -#include "lwip/nd6.h" -#include "lwip/ip6_frag.h" -#include "lwip/mld6.h" - -#include - -#if !MEMP_MEM_MALLOC /* don't build if not configured for use in lwipopts.h */ - -struct memp { - struct memp *next; -#if MEMP_OVERFLOW_CHECK - const char *file; - int line; -#endif /* MEMP_OVERFLOW_CHECK */ -}; - -#if MEMP_OVERFLOW_CHECK -/* if MEMP_OVERFLOW_CHECK is turned on, we reserve some bytes at the beginning - * and at the end of each element, initialize them as 0xcd and check - * them later. */ -/* If MEMP_OVERFLOW_CHECK is >= 2, on every call to memp_malloc or memp_free, - * every single element in each pool is checked! - * This is VERY SLOW but also very helpful. */ -/* MEMP_SANITY_REGION_BEFORE and MEMP_SANITY_REGION_AFTER can be overridden in - * lwipopts.h to change the amount reserved for checking. */ -#ifndef MEMP_SANITY_REGION_BEFORE -#define MEMP_SANITY_REGION_BEFORE 16 -#endif /* MEMP_SANITY_REGION_BEFORE*/ -#if MEMP_SANITY_REGION_BEFORE > 0 -#define MEMP_SANITY_REGION_BEFORE_ALIGNED LWIP_MEM_ALIGN_SIZE(MEMP_SANITY_REGION_BEFORE) -#else -#define MEMP_SANITY_REGION_BEFORE_ALIGNED 0 -#endif /* MEMP_SANITY_REGION_BEFORE*/ -#ifndef MEMP_SANITY_REGION_AFTER -#define MEMP_SANITY_REGION_AFTER 16 -#endif /* MEMP_SANITY_REGION_AFTER*/ -#if MEMP_SANITY_REGION_AFTER > 0 -#define MEMP_SANITY_REGION_AFTER_ALIGNED LWIP_MEM_ALIGN_SIZE(MEMP_SANITY_REGION_AFTER) -#else -#define MEMP_SANITY_REGION_AFTER_ALIGNED 0 -#endif /* MEMP_SANITY_REGION_AFTER*/ - -/* MEMP_SIZE: save space for struct memp and for sanity check */ -#define MEMP_SIZE (LWIP_MEM_ALIGN_SIZE(sizeof(struct memp)) + MEMP_SANITY_REGION_BEFORE_ALIGNED) -#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x) + MEMP_SANITY_REGION_AFTER_ALIGNED) - -#else /* MEMP_OVERFLOW_CHECK */ - -/* No sanity checks - * We don't need to preserve the struct memp while not allocated, so we - * can save a little space and set MEMP_SIZE to 0. - */ -#define MEMP_SIZE 0 -#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x)) - -#endif /* MEMP_OVERFLOW_CHECK */ - -/** This array holds the first free element of each pool. - * Elements form a linked list. */ -static struct memp *memp_tab[MEMP_MAX]; - -#else /* MEMP_MEM_MALLOC */ - -#define MEMP_ALIGN_SIZE(x) (LWIP_MEM_ALIGN_SIZE(x)) - -#endif /* MEMP_MEM_MALLOC */ - -/** This array holds the element sizes of each pool. */ -#if !MEM_USE_POOLS && !MEMP_MEM_MALLOC -static -#endif -const u16_t memp_sizes[MEMP_MAX] = { -#define LWIP_MEMPOOL(name,num,size,desc) LWIP_MEM_ALIGN_SIZE(size), -#include "lwip/memp_std.h" -}; - -#if !MEMP_MEM_MALLOC /* don't build if not configured for use in lwipopts.h */ - -/** This array holds the number of elements in each pool. */ -static const u16_t memp_num[MEMP_MAX] = { -#define LWIP_MEMPOOL(name,num,size,desc) (num), -#include "lwip/memp_std.h" -}; - -/** This array holds a textual description of each pool. */ -#ifdef LWIP_DEBUG -static const char *memp_desc[MEMP_MAX] = { -#define LWIP_MEMPOOL(name,num,size,desc) (desc), -#include "lwip/memp_std.h" -}; -#endif /* LWIP_DEBUG */ - -#if MEMP_SEPARATE_POOLS - -/** This creates each memory pool. These are named memp_memory_XXX_base (where - * XXX is the name of the pool defined in memp_std.h). - * To relocate a pool, declare it as extern in cc.h. Example for GCC: - * extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB_base[]; - */ -#define LWIP_MEMPOOL(name,num,size,desc) u8_t memp_memory_ ## name ## _base \ - [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; -#include "lwip/memp_std.h" - -/** This array holds the base of each memory pool. */ -static u8_t *const memp_bases[] = { -#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base, -#include "lwip/memp_std.h" -}; - -#else /* MEMP_SEPARATE_POOLS */ - -/** This is the actual memory used by the pools (all pools in one big block). */ -static u8_t memp_memory[MEM_ALIGNMENT - 1 -#define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) ) -#include "lwip/memp_std.h" -]; - -#endif /* MEMP_SEPARATE_POOLS */ - -#if MEMP_SANITY_CHECK -/** - * Check that memp-lists don't form a circle, using "Floyd's cycle-finding algorithm". - */ -static int -memp_sanity(void) -{ - s16_t i; - struct memp *t, *h; - - for (i = 0; i < MEMP_MAX; i++) { - t = memp_tab[i]; - if(t != NULL) { - for (h = t->next; (t != NULL) && (h != NULL); t = t->next, - h = (((h->next != NULL) && (h->next->next != NULL)) ? h->next->next : NULL)) { - if (t == h) { - return 0; - } - } - } - } - return 1; -} -#endif /* MEMP_SANITY_CHECK*/ -#if MEMP_OVERFLOW_CHECK -#if defined(LWIP_DEBUG) && MEMP_STATS -static const char * memp_overflow_names[] = { -#define LWIP_MEMPOOL(name,num,size,desc) "/"desc, -#include "lwip/memp_std.h" - }; -#endif - -/** - * Check if a memp element was victim of an overflow - * (e.g. the restricted area after it has been altered) - * - * @param p the memp element to check - * @param memp_type the pool p comes from - */ -static void -memp_overflow_check_element_overflow(struct memp *p, u16_t memp_type) -{ - u16_t k; - u8_t *m; -#if MEMP_SANITY_REGION_AFTER_ALIGNED > 0 - m = (u8_t*)p + MEMP_SIZE + memp_sizes[memp_type]; - for (k = 0; k < MEMP_SANITY_REGION_AFTER_ALIGNED; k++) { - if (m[k] != 0xcd) { - char errstr[128] = "detected memp overflow in pool "; - char digit[] = "0"; - if(memp_type >= 10) { - digit[0] = '0' + (memp_type/10); - strcat(errstr, digit); - } - digit[0] = '0' + (memp_type%10); - strcat(errstr, digit); -#if defined(LWIP_DEBUG) && MEMP_STATS - strcat(errstr, memp_overflow_names[memp_type]); -#endif - LWIP_ASSERT(errstr, 0); - } - } -#endif -} - -/** - * Check if a memp element was victim of an underflow - * (e.g. the restricted area before it has been altered) - * - * @param p the memp element to check - * @param memp_type the pool p comes from - */ -static void -memp_overflow_check_element_underflow(struct memp *p, u16_t memp_type) -{ - u16_t k; - u8_t *m; -#if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 - m = (u8_t*)p + MEMP_SIZE - MEMP_SANITY_REGION_BEFORE_ALIGNED; - for (k = 0; k < MEMP_SANITY_REGION_BEFORE_ALIGNED; k++) { - if (m[k] != 0xcd) { - char errstr[128] = "detected memp underflow in pool "; - char digit[] = "0"; - if(memp_type >= 10) { - digit[0] = '0' + (memp_type/10); - strcat(errstr, digit); - } - digit[0] = '0' + (memp_type%10); - strcat(errstr, digit); -#if defined(LWIP_DEBUG) && MEMP_STATS - strcat(errstr, memp_overflow_names[memp_type]); -#endif - LWIP_ASSERT(errstr, 0); - } - } -#endif -} - -/** - * Do an overflow check for all elements in every pool. - * - * @see memp_overflow_check_element for a description of the check - */ -static void -memp_overflow_check_all(void) -{ - u16_t i, j; - struct memp *p; - -#if !MEMP_SEPARATE_POOLS - p = (struct memp *)LWIP_MEM_ALIGN(memp_memory); -#endif /* !MEMP_SEPARATE_POOLS */ - for (i = 0; i < MEMP_MAX; ++i) { -#if MEMP_SEPARATE_POOLS - p = (struct memp *)(memp_bases[i]); -#endif /* MEMP_SEPARATE_POOLS */ - for (j = 0; j < memp_num[i]; ++j) { - memp_overflow_check_element_overflow(p, i); - p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED); - } - } -#if !MEMP_SEPARATE_POOLS - p = (struct memp *)LWIP_MEM_ALIGN(memp_memory); -#endif /* !MEMP_SEPARATE_POOLS */ - for (i = 0; i < MEMP_MAX; ++i) { -#if MEMP_SEPARATE_POOLS - p = (struct memp *)(memp_bases[i]); -#endif /* MEMP_SEPARATE_POOLS */ - for (j = 0; j < memp_num[i]; ++j) { - memp_overflow_check_element_underflow(p, i); - p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED); - } - } -} - -/** - * Initialize the restricted areas of all memp elements in every pool. - */ -static void -memp_overflow_init(void) -{ - u16_t i, j; - struct memp *p; - u8_t *m; - -#if !MEMP_SEPARATE_POOLS - p = (struct memp *)LWIP_MEM_ALIGN(memp_memory); -#endif /* !MEMP_SEPARATE_POOLS */ - for (i = 0; i < MEMP_MAX; ++i) { -#if MEMP_SEPARATE_POOLS - p = (struct memp *)(memp_bases[i]); -#endif /* MEMP_SEPARATE_POOLS */ - for (j = 0; j < memp_num[i]; ++j) { -#if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0 - m = (u8_t*)p + MEMP_SIZE - MEMP_SANITY_REGION_BEFORE_ALIGNED; - memset(m, 0xcd, MEMP_SANITY_REGION_BEFORE_ALIGNED); -#endif -#if MEMP_SANITY_REGION_AFTER_ALIGNED > 0 - m = (u8_t*)p + MEMP_SIZE + memp_sizes[i]; - memset(m, 0xcd, MEMP_SANITY_REGION_AFTER_ALIGNED); -#endif - p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED); - } - } -} -#endif /* MEMP_OVERFLOW_CHECK */ - -/** - * Initialize this module. - * - * Carves out memp_memory into linked lists for each pool-type. - */ -void -memp_init(void) -{ - struct memp *memp; - u16_t i, j; - - for (i = 0; i < MEMP_MAX; ++i) { - MEMP_STATS_AVAIL(used, i, 0); - MEMP_STATS_AVAIL(max, i, 0); - MEMP_STATS_AVAIL(err, i, 0); - MEMP_STATS_AVAIL(avail, i, memp_num[i]); - } - -#if !MEMP_SEPARATE_POOLS - memp = (struct memp *)LWIP_MEM_ALIGN(memp_memory); -#endif /* !MEMP_SEPARATE_POOLS */ - /* for every pool: */ - for (i = 0; i < MEMP_MAX; ++i) { - memp_tab[i] = NULL; -#if MEMP_SEPARATE_POOLS - memp = (struct memp*)memp_bases[i]; -#endif /* MEMP_SEPARATE_POOLS */ - /* create a linked list of memp elements */ - for (j = 0; j < memp_num[i]; ++j) { - memp->next = memp_tab[i]; - memp_tab[i] = memp; - memp = (struct memp *)(void *)((u8_t *)memp + MEMP_SIZE + memp_sizes[i] -#if MEMP_OVERFLOW_CHECK - + MEMP_SANITY_REGION_AFTER_ALIGNED -#endif - ); - } - } -#if MEMP_OVERFLOW_CHECK - memp_overflow_init(); - /* check everything a first time to see if it worked */ - memp_overflow_check_all(); -#endif /* MEMP_OVERFLOW_CHECK */ -} - -/** - * Get an element from a specific pool. - * - * @param type the pool to get an element from - * - * the debug version has two more parameters: - * @param file file name calling this function - * @param line number of line where this function is called - * - * @return a pointer to the allocated memory or a NULL pointer on error - */ -void * -#if !MEMP_OVERFLOW_CHECK -memp_malloc(memp_t type) -#else -memp_malloc_fn(memp_t type, const char* file, const int line) -#endif -{ - struct memp *memp; - SYS_ARCH_DECL_PROTECT(old_level); - - LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;); - - SYS_ARCH_PROTECT(old_level); -#if MEMP_OVERFLOW_CHECK >= 2 - memp_overflow_check_all(); -#endif /* MEMP_OVERFLOW_CHECK >= 2 */ - - memp = memp_tab[type]; - - if (memp != NULL) { - memp_tab[type] = memp->next; -#if MEMP_OVERFLOW_CHECK - memp->next = NULL; - memp->file = file; - memp->line = line; -#endif /* MEMP_OVERFLOW_CHECK */ - MEMP_STATS_INC_USED(used, type); - LWIP_ASSERT("memp_malloc: memp properly aligned", - ((mem_ptr_t)memp % MEM_ALIGNMENT) == 0); - memp = (struct memp*)(void *)((u8_t*)memp + MEMP_SIZE); - } else { - LWIP_DEBUGF(MEMP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("memp_malloc: out of memory in pool %s\n", memp_desc[type])); - MEMP_STATS_INC(err, type); - } - - SYS_ARCH_UNPROTECT(old_level); - - return memp; -} - -/** - * Put an element back into its pool. - * - * @param type the pool where to put mem - * @param mem the memp element to free - */ -void -memp_free(memp_t type, void *mem) -{ - struct memp *memp; - SYS_ARCH_DECL_PROTECT(old_level); - - if (mem == NULL) { - return; - } - LWIP_ASSERT("memp_free: mem properly aligned", - ((mem_ptr_t)mem % MEM_ALIGNMENT) == 0); - - memp = (struct memp *)(void *)((u8_t*)mem - MEMP_SIZE); - - SYS_ARCH_PROTECT(old_level); -#if MEMP_OVERFLOW_CHECK -#if MEMP_OVERFLOW_CHECK >= 2 - memp_overflow_check_all(); -#else - memp_overflow_check_element_overflow(memp, type); - memp_overflow_check_element_underflow(memp, type); -#endif /* MEMP_OVERFLOW_CHECK >= 2 */ -#endif /* MEMP_OVERFLOW_CHECK */ - - MEMP_STATS_DEC(used, type); - - memp->next = memp_tab[type]; - memp_tab[type] = memp; - -#if MEMP_SANITY_CHECK - LWIP_ASSERT("memp sanity", memp_sanity()); -#endif /* MEMP_SANITY_CHECK */ - - SYS_ARCH_UNPROTECT(old_level); -} - -#endif /* MEMP_MEM_MALLOC */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/netif.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/netif.c deleted file mode 100644 index dcc87580..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/netif.c +++ /dev/null @@ -1,913 +0,0 @@ -/** - * @file - * lwIP network interface abstraction - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/def.h" -#include "lwip/ip_addr.h" -#include "lwip/ip6_addr.h" -#include "lwip/netif.h" -#include "lwip/tcp_impl.h" -#include "lwip/snmp.h" -#include "lwip/igmp.h" -#include "netif/etharp.h" -#include "lwip/stats.h" -#if ENABLE_LOOPBACK -#include "lwip/sys.h" -#if LWIP_NETIF_LOOPBACK_MULTITHREADING -#include "lwip/tcpip.h" -#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ -#endif /* ENABLE_LOOPBACK */ - -#if LWIP_AUTOIP -#include "lwip/autoip.h" -#endif /* LWIP_AUTOIP */ -#if LWIP_DHCP -#include "lwip/dhcp.h" -#endif /* LWIP_DHCP */ -#if LWIP_IPV6_DHCP6 -#include "lwip/dhcp6.h" -#endif /* LWIP_IPV6_DHCP6 */ -#if LWIP_IPV6_MLD -#include "lwip/mld6.h" -#endif /* LWIP_IPV6_MLD */ - -#if LWIP_NETIF_STATUS_CALLBACK -#define NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0) -#else -#define NETIF_STATUS_CALLBACK(n) -#endif /* LWIP_NETIF_STATUS_CALLBACK */ - -#if LWIP_NETIF_LINK_CALLBACK -#define NETIF_LINK_CALLBACK(n) do{ if (n->link_callback) { (n->link_callback)(n); }}while(0) -#else -#define NETIF_LINK_CALLBACK(n) -#endif /* LWIP_NETIF_LINK_CALLBACK */ - -struct netif *netif_list; -struct netif *netif_default; - -static u8_t netif_num; - -#if LWIP_IPV6 -static err_t netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr); -#endif /* LWIP_IPV6 */ - -#if LWIP_HAVE_LOOPIF -static struct netif loop_netif; - -/** - * Initialize a lwip network interface structure for a loopback interface - * - * @param netif the lwip network interface structure for this loopif - * @return ERR_OK if the loopif is initialized - * ERR_MEM if private data couldn't be allocated - */ -static err_t -netif_loopif_init(struct netif *netif) -{ - /* initialize the snmp variables and counters inside the struct netif - * ifSpeed: no assumption can be made! - */ - NETIF_INIT_SNMP(netif, snmp_ifType_softwareLoopback, 0); - - netif->name[0] = 'l'; - netif->name[1] = 'o'; - netif->output = netif_loop_output; - return ERR_OK; -} -#endif /* LWIP_HAVE_LOOPIF */ - -void -netif_init(void) -{ -#if LWIP_HAVE_LOOPIF - ip_addr_t loop_ipaddr, loop_netmask, loop_gw; - IP4_ADDR(&loop_gw, 127,0,0,1); - IP4_ADDR(&loop_ipaddr, 127,0,0,1); - IP4_ADDR(&loop_netmask, 255,0,0,0); - -#if NO_SYS - netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, ip_input); -#else /* NO_SYS */ - netif_add(&loop_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, netif_loopif_init, tcpip_input); -#endif /* NO_SYS */ - netif_set_up(&loop_netif); - -#endif /* LWIP_HAVE_LOOPIF */ -} - -/** - * Add a network interface to the list of lwIP netifs. - * - * @param netif a pre-allocated netif structure - * @param ipaddr IP address for the new netif - * @param netmask network mask for the new netif - * @param gw default gateway IP address for the new netif - * @param state opaque data passed to the new netif - * @param init callback function that initializes the interface - * @param input callback function that is called to pass - * ingress packets up in the protocol layer stack. - * - * @return netif, or NULL if failed. - */ -struct netif * -netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, - ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input) -{ -#if LWIP_IPV6 - u32_t i; -#endif - - LWIP_ASSERT("No init function given", init != NULL); - - /* reset new interface configuration state */ - ip_addr_set_zero(&netif->ip_addr); - ip_addr_set_zero(&netif->netmask); - ip_addr_set_zero(&netif->gw); -#if LWIP_IPV6 - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - ip6_addr_set_zero(&netif->ip6_addr[i]); - netif_ip6_addr_set_state(netif, i, IP6_ADDR_INVALID); - } - netif->output_ip6 = netif_null_output_ip6; -#endif /* LWIP_IPV6 */ - netif->flags = 0; -#if LWIP_DHCP - /* netif not under DHCP control by default */ - netif->dhcp = NULL; -#endif /* LWIP_DHCP */ -#if LWIP_AUTOIP - /* netif not under AutoIP control by default */ - netif->autoip = NULL; -#endif /* LWIP_AUTOIP */ -#if LWIP_IPV6_AUTOCONFIG - /* IPv6 address autoconfiguration not enabled by default */ - netif->ip6_autoconfig_enabled = 0; -#endif /* LWIP_IPV6_AUTOCONFIG */ -#if LWIP_IPV6_SEND_ROUTER_SOLICIT - netif->rs_count = LWIP_ND6_MAX_MULTICAST_SOLICIT; -#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ -#if LWIP_IPV6_DHCP6 - /* netif not under DHCPv6 control by default */ - netif->dhcp6 = NULL; -#endif /* LWIP_IPV6_DHCP6 */ -#if LWIP_NETIF_STATUS_CALLBACK - netif->status_callback = NULL; -#endif /* LWIP_NETIF_STATUS_CALLBACK */ -#if LWIP_NETIF_LINK_CALLBACK - netif->link_callback = NULL; -#endif /* LWIP_NETIF_LINK_CALLBACK */ -#if LWIP_IGMP - netif->igmp_mac_filter = NULL; -#endif /* LWIP_IGMP */ -#if LWIP_IPV6 && LWIP_IPV6_MLD - netif->mld_mac_filter = NULL; -#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ -#if ENABLE_LOOPBACK - netif->loop_first = NULL; - netif->loop_last = NULL; -#endif /* ENABLE_LOOPBACK */ - - /* remember netif specific state information data */ - netif->state = state; - netif->num = netif_num++; - netif->input = input; - NETIF_SET_HWADDRHINT(netif, NULL); -#if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS - netif->loop_cnt_current = 0; -#endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */ - - netif_set_addr(netif, ipaddr, netmask, gw); - - /* call user specified initialization function for netif */ - if (init(netif) != ERR_OK) { - return NULL; - } - - /* add this netif to the list */ - netif->next = netif_list; - netif_list = netif; - snmp_inc_iflist(); - -#if LWIP_IGMP - /* start IGMP processing */ - if (netif->flags & NETIF_FLAG_IGMP) { - igmp_start(netif); - } -#endif /* LWIP_IGMP */ - - LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ", - netif->name[0], netif->name[1])); - ip_addr_debug_print(NETIF_DEBUG, ipaddr); - LWIP_DEBUGF(NETIF_DEBUG, (" netmask ")); - ip_addr_debug_print(NETIF_DEBUG, netmask); - LWIP_DEBUGF(NETIF_DEBUG, (" gw ")); - ip_addr_debug_print(NETIF_DEBUG, gw); - LWIP_DEBUGF(NETIF_DEBUG, ("\n")); - return netif; -} - -/** - * Change IP address configuration for a network interface (including netmask - * and default gateway). - * - * @param netif the network interface to change - * @param ipaddr the new IP address - * @param netmask the new netmask - * @param gw the new default gateway - */ -void -netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, - ip_addr_t *gw) -{ - netif_set_ipaddr(netif, ipaddr); - netif_set_netmask(netif, netmask); - netif_set_gw(netif, gw); -} - -/** - * Remove a network interface from the list of lwIP netifs. - * - * @param netif the network interface to remove - */ -void -netif_remove(struct netif *netif) -{ - if (netif == NULL) { - return; - } - -#if LWIP_IGMP - /* stop IGMP processing */ - if (netif->flags & NETIF_FLAG_IGMP) { - igmp_stop(netif); - } -#endif /* LWIP_IGMP */ -#if LWIP_IPV6 && LWIP_IPV6_MLD - /* stop MLD processing */ - mld6_stop(netif); -#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ - if (netif_is_up(netif)) { - /* set netif down before removing (call callback function) */ - netif_set_down(netif); - } - - snmp_delete_ipaddridx_tree(netif); - - /* is it the first netif? */ - if (netif_list == netif) { - netif_list = netif->next; - } else { - /* look for netif further down the list */ - struct netif * tmpNetif; - for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) { - if (tmpNetif->next == netif) { - tmpNetif->next = netif->next; - break; - } - } - if (tmpNetif == NULL) - return; /* we didn't find any netif today */ - } - snmp_dec_iflist(); - /* this netif is default? */ - if (netif_default == netif) { - /* reset default netif */ - netif_set_default(NULL); - } -#if LWIP_NETIF_REMOVE_CALLBACK - if (netif->remove_callback) { - netif->remove_callback(netif); - } -#endif /* LWIP_NETIF_REMOVE_CALLBACK */ - LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") ); -} - -/** - * Find a network interface by searching for its name - * - * @param name the name of the netif (like netif->name) plus concatenated number - * in ascii representation (e.g. 'en0') - */ -struct netif * -netif_find(char *name) -{ - struct netif *netif; - u8_t num; - - if (name == NULL) { - return NULL; - } - - num = name[2] - '0'; - - for(netif = netif_list; netif != NULL; netif = netif->next) { - if (num == netif->num && - name[0] == netif->name[0] && - name[1] == netif->name[1]) { - LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1])); - return netif; - } - } - LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1])); - return NULL; -} - -int netif_is_named (struct netif *netif, const char name[3]) -{ - u8_t num = name[2] - '0'; - - return (!memcmp(netif->name, name, 2) && netif->num == num); -} - -/** - * Change the IP address of a network interface - * - * @param netif the network interface to change - * @param ipaddr the new IP address - * - * @note call netif_set_addr() if you also want to change netmask and - * default gateway - */ -void -netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr) -{ - /* TODO: Handling of obsolete pcbs */ - /* See: http://mail.gnu.org/archive/html/lwip-users/2003-03/msg00118.html */ -#if LWIP_TCP - struct tcp_pcb *pcb; - struct tcp_pcb_listen *lpcb; - - /* address is actually being changed? */ - if (ipaddr && (ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0) { - /* extern struct tcp_pcb *tcp_active_pcbs; defined by tcp.h */ - LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n")); - pcb = tcp_active_pcbs; - while (pcb != NULL) { - /* PCB bound to current local interface address? */ - if (ip_addr_cmp(ipX_2_ip(&pcb->local_ip), &(netif->ip_addr)) -#if LWIP_AUTOIP - /* connections to link-local addresses must persist (RFC3927 ch. 1.9) */ - && !ip_addr_islinklocal(ipX_2_ip(&pcb->local_ip)) -#endif /* LWIP_AUTOIP */ - ) { - /* this connection must be aborted */ - struct tcp_pcb *next = pcb->next; - LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: aborting TCP pcb %p\n", (void *)pcb)); - tcp_abort(pcb); - pcb = next; - } else { - pcb = pcb->next; - } - } - for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { - /* PCB bound to current local interface address? */ - if ((!(ip_addr_isany(ipX_2_ip(&lpcb->local_ip)))) && - (ip_addr_cmp(ipX_2_ip(&lpcb->local_ip), &(netif->ip_addr)))) { - /* The PCB is listening to the old ipaddr and - * is set to listen to the new one instead */ - ip_addr_set(ipX_2_ip(&lpcb->local_ip), ipaddr); - } - } - } -#endif - snmp_delete_ipaddridx_tree(netif); - snmp_delete_iprteidx_tree(0,netif); - /* set new IP address to netif */ - ip_addr_set(&(netif->ip_addr), ipaddr); - snmp_insert_ipaddridx_tree(netif); - snmp_insert_iprteidx_tree(0,netif); - - LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: IP address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - netif->name[0], netif->name[1], - ip4_addr1_16(&netif->ip_addr), - ip4_addr2_16(&netif->ip_addr), - ip4_addr3_16(&netif->ip_addr), - ip4_addr4_16(&netif->ip_addr))); -} - -/** - * Change the default gateway for a network interface - * - * @param netif the network interface to change - * @param gw the new default gateway - * - * @note call netif_set_addr() if you also want to change ip address and netmask - */ -void -netif_set_gw(struct netif *netif, ip_addr_t *gw) -{ - ip_addr_set(&(netif->gw), gw); - LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: GW address of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - netif->name[0], netif->name[1], - ip4_addr1_16(&netif->gw), - ip4_addr2_16(&netif->gw), - ip4_addr3_16(&netif->gw), - ip4_addr4_16(&netif->gw))); -} - -void netif_set_pretend_tcp (struct netif *netif, u8_t pretend) -{ - if (pretend) { - netif->flags |= NETIF_FLAG_PRETEND_TCP; - } else { - netif->flags &= ~NETIF_FLAG_PRETEND_TCP; - } -} - -/** - * Change the netmask of a network interface - * - * @param netif the network interface to change - * @param netmask the new netmask - * - * @note call netif_set_addr() if you also want to change ip address and - * default gateway - */ -void -netif_set_netmask(struct netif *netif, ip_addr_t *netmask) -{ - snmp_delete_iprteidx_tree(0, netif); - /* set new netmask to netif */ - ip_addr_set(&(netif->netmask), netmask); - snmp_insert_iprteidx_tree(0, netif); - LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", - netif->name[0], netif->name[1], - ip4_addr1_16(&netif->netmask), - ip4_addr2_16(&netif->netmask), - ip4_addr3_16(&netif->netmask), - ip4_addr4_16(&netif->netmask))); -} - -/** - * Set a network interface as the default network interface - * (used to output all packets for which no specific route is found) - * - * @param netif the default network interface - */ -void -netif_set_default(struct netif *netif) -{ - if (netif == NULL) { - /* remove default route */ - snmp_delete_iprteidx_tree(1, netif); - } else { - /* install default route */ - snmp_insert_iprteidx_tree(1, netif); - } - netif_default = netif; - LWIP_DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n", - netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\'')); -} - -/** - * Bring an interface up, available for processing - * traffic. - * - * @note: Enabling DHCP on a down interface will make it come - * up once configured. - * - * @see dhcp_start() - */ -void netif_set_up(struct netif *netif) -{ - if (!(netif->flags & NETIF_FLAG_UP)) { - netif->flags |= NETIF_FLAG_UP; - -#if LWIP_SNMP - snmp_get_sysuptime(&netif->ts); -#endif /* LWIP_SNMP */ - - NETIF_STATUS_CALLBACK(netif); - - if (netif->flags & NETIF_FLAG_LINK_UP) { -#if LWIP_ARP - /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ - if (netif->flags & (NETIF_FLAG_ETHARP)) { - etharp_gratuitous(netif); - } -#endif /* LWIP_ARP */ - -#if LWIP_IGMP - /* resend IGMP memberships */ - if (netif->flags & NETIF_FLAG_IGMP) { - igmp_report_groups( netif); - } -#endif /* LWIP_IGMP */ -#if LWIP_IPV6 && LWIP_IPV6_MLD - /* send mld memberships */ - mld6_report_groups( netif); -#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ - -#if LWIP_IPV6_SEND_ROUTER_SOLICIT - /* Send Router Solicitation messages. */ - netif->rs_count = LWIP_ND6_MAX_MULTICAST_SOLICIT; -#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ - - } - } -} - -/** - * Bring an interface down, disabling any traffic processing. - * - * @note: Enabling DHCP on a down interface will make it come - * up once configured. - * - * @see dhcp_start() - */ -void netif_set_down(struct netif *netif) -{ - if (netif->flags & NETIF_FLAG_UP) { - netif->flags &= ~NETIF_FLAG_UP; -#if LWIP_SNMP - snmp_get_sysuptime(&netif->ts); -#endif - -#if LWIP_ARP - if (netif->flags & NETIF_FLAG_ETHARP) { - etharp_cleanup_netif(netif); - } -#endif /* LWIP_ARP */ - NETIF_STATUS_CALLBACK(netif); - } -} - -#if LWIP_NETIF_STATUS_CALLBACK -/** - * Set callback to be called when interface is brought up/down - */ -void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback) -{ - if (netif) { - netif->status_callback = status_callback; - } -} -#endif /* LWIP_NETIF_STATUS_CALLBACK */ - -#if LWIP_NETIF_REMOVE_CALLBACK -/** - * Set callback to be called when the interface has been removed - */ -void -netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback) -{ - if (netif) { - netif->remove_callback = remove_callback; - } -} -#endif /* LWIP_NETIF_REMOVE_CALLBACK */ - -/** - * Called by a driver when its link goes up - */ -void netif_set_link_up(struct netif *netif ) -{ - if (!(netif->flags & NETIF_FLAG_LINK_UP)) { - netif->flags |= NETIF_FLAG_LINK_UP; - -#if LWIP_DHCP - if (netif->dhcp) { - dhcp_network_changed(netif); - } -#endif /* LWIP_DHCP */ - -#if LWIP_AUTOIP - if (netif->autoip) { - autoip_network_changed(netif); - } -#endif /* LWIP_AUTOIP */ - - if (netif->flags & NETIF_FLAG_UP) { -#if LWIP_ARP - /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ - if (netif->flags & NETIF_FLAG_ETHARP) { - etharp_gratuitous(netif); - } -#endif /* LWIP_ARP */ - -#if LWIP_IGMP - /* resend IGMP memberships */ - if (netif->flags & NETIF_FLAG_IGMP) { - igmp_report_groups( netif); - } -#endif /* LWIP_IGMP */ -#if LWIP_IPV6 && LWIP_IPV6_MLD - /* send mld memberships */ - mld6_report_groups( netif); -#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ - } - NETIF_LINK_CALLBACK(netif); - } -} - -/** - * Called by a driver when its link goes down - */ -void netif_set_link_down(struct netif *netif ) -{ - if (netif->flags & NETIF_FLAG_LINK_UP) { - netif->flags &= ~NETIF_FLAG_LINK_UP; - NETIF_LINK_CALLBACK(netif); - } -} - -#if LWIP_NETIF_LINK_CALLBACK -/** - * Set callback to be called when link is brought up/down - */ -void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback) -{ - if (netif) { - netif->link_callback = link_callback; - } -} -#endif /* LWIP_NETIF_LINK_CALLBACK */ - -#if ENABLE_LOOPBACK -/** - * Send an IP packet to be received on the same netif (loopif-like). - * The pbuf is simply copied and handed back to netif->input. - * In multithreaded mode, this is done directly since netif->input must put - * the packet on a queue. - * In callback mode, the packet is put on an internal queue and is fed to - * netif->input by netif_poll(). - * - * @param netif the lwip network interface structure - * @param p the (IP) packet to 'send' - * @param ipaddr the ip address to send the packet to (not used) - * @return ERR_OK if the packet has been sent - * ERR_MEM if the pbuf used to copy the packet couldn't be allocated - */ -err_t -netif_loop_output(struct netif *netif, struct pbuf *p, - ip_addr_t *ipaddr) -{ - struct pbuf *r; - err_t err; - struct pbuf *last; -#if LWIP_LOOPBACK_MAX_PBUFS - u8_t clen = 0; -#endif /* LWIP_LOOPBACK_MAX_PBUFS */ - /* If we have a loopif, SNMP counters are adjusted for it, - * if not they are adjusted for 'netif'. */ -#if LWIP_SNMP -#if LWIP_HAVE_LOOPIF - struct netif *stats_if = &loop_netif; -#else /* LWIP_HAVE_LOOPIF */ - struct netif *stats_if = netif; -#endif /* LWIP_HAVE_LOOPIF */ -#endif /* LWIP_SNMP */ - SYS_ARCH_DECL_PROTECT(lev); - LWIP_UNUSED_ARG(ipaddr); - - /* Allocate a new pbuf */ - r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM); - if (r == NULL) { - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.drop); - snmp_inc_ifoutdiscards(stats_if); - return ERR_MEM; - } -#if LWIP_LOOPBACK_MAX_PBUFS - clen = pbuf_clen(r); - /* check for overflow or too many pbuf on queue */ - if(((netif->loop_cnt_current + clen) < netif->loop_cnt_current) || - ((netif->loop_cnt_current + clen) > LWIP_LOOPBACK_MAX_PBUFS)) { - pbuf_free(r); - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.drop); - snmp_inc_ifoutdiscards(stats_if); - return ERR_MEM; - } - netif->loop_cnt_current += clen; -#endif /* LWIP_LOOPBACK_MAX_PBUFS */ - - /* Copy the whole pbuf queue p into the single pbuf r */ - if ((err = pbuf_copy(r, p)) != ERR_OK) { - pbuf_free(r); - LINK_STATS_INC(link.memerr); - LINK_STATS_INC(link.drop); - snmp_inc_ifoutdiscards(stats_if); - return err; - } - - /* Put the packet on a linked list which gets emptied through calling - netif_poll(). */ - - /* let last point to the last pbuf in chain r */ - for (last = r; last->next != NULL; last = last->next); - - SYS_ARCH_PROTECT(lev); - if(netif->loop_first != NULL) { - LWIP_ASSERT("if first != NULL, last must also be != NULL", netif->loop_last != NULL); - netif->loop_last->next = r; - netif->loop_last = last; - } else { - netif->loop_first = r; - netif->loop_last = last; - } - SYS_ARCH_UNPROTECT(lev); - - LINK_STATS_INC(link.xmit); - snmp_add_ifoutoctets(stats_if, p->tot_len); - snmp_inc_ifoutucastpkts(stats_if); - -#if LWIP_NETIF_LOOPBACK_MULTITHREADING - /* For multithreading environment, schedule a call to netif_poll */ - tcpip_callback((tcpip_callback_fn)netif_poll, netif); -#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ - - return ERR_OK; -} - -/** - * Call netif_poll() in the main loop of your application. This is to prevent - * reentering non-reentrant functions like tcp_input(). Packets passed to - * netif_loop_output() are put on a list that is passed to netif->input() by - * netif_poll(). - */ -void -netif_poll(struct netif *netif) -{ - struct pbuf *in; - /* If we have a loopif, SNMP counters are adjusted for it, - * if not they are adjusted for 'netif'. */ -#if LWIP_SNMP -#if LWIP_HAVE_LOOPIF - struct netif *stats_if = &loop_netif; -#else /* LWIP_HAVE_LOOPIF */ - struct netif *stats_if = netif; -#endif /* LWIP_HAVE_LOOPIF */ -#endif /* LWIP_SNMP */ - SYS_ARCH_DECL_PROTECT(lev); - - do { - /* Get a packet from the list. With SYS_LIGHTWEIGHT_PROT=1, this is protected */ - SYS_ARCH_PROTECT(lev); - in = netif->loop_first; - if (in != NULL) { - struct pbuf *in_end = in; -#if LWIP_LOOPBACK_MAX_PBUFS - u8_t clen = pbuf_clen(in); - /* adjust the number of pbufs on queue */ - LWIP_ASSERT("netif->loop_cnt_current underflow", - ((netif->loop_cnt_current - clen) < netif->loop_cnt_current)); - netif->loop_cnt_current -= clen; -#endif /* LWIP_LOOPBACK_MAX_PBUFS */ - while (in_end->len != in_end->tot_len) { - LWIP_ASSERT("bogus pbuf: len != tot_len but next == NULL!", in_end->next != NULL); - in_end = in_end->next; - } - /* 'in_end' now points to the last pbuf from 'in' */ - if (in_end == netif->loop_last) { - /* this was the last pbuf in the list */ - netif->loop_first = netif->loop_last = NULL; - } else { - /* pop the pbuf off the list */ - netif->loop_first = in_end->next; - LWIP_ASSERT("should not be null since first != last!", netif->loop_first != NULL); - } - /* De-queue the pbuf from its successors on the 'loop_' list. */ - in_end->next = NULL; - } - SYS_ARCH_UNPROTECT(lev); - - if (in != NULL) { - LINK_STATS_INC(link.recv); - snmp_add_ifinoctets(stats_if, in->tot_len); - snmp_inc_ifinucastpkts(stats_if); - /* loopback packets are always IP packets! */ - if (ip_input(in, netif) != ERR_OK) { - pbuf_free(in); - } - /* Don't reference the packet any more! */ - in = NULL; - } - /* go on while there is a packet on the list */ - } while (netif->loop_first != NULL); -} - -#if !LWIP_NETIF_LOOPBACK_MULTITHREADING -/** - * Calls netif_poll() for every netif on the netif_list. - */ -void -netif_poll_all(void) -{ - struct netif *netif = netif_list; - /* loop through netifs */ - while (netif != NULL) { - netif_poll(netif); - /* proceed to next network interface */ - netif = netif->next; - } -} -#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ -#endif /* ENABLE_LOOPBACK */ - -#if LWIP_IPV6 -s8_t -netif_matches_ip6_addr(struct netif * netif, ip6_addr_t * ip6addr) -{ - s8_t i; - for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { - if (ip6_addr_cmp(netif_ip6_addr(netif, i), ip6addr)) { - return i; - } - } - return -1; -} - -void -netif_create_ip6_linklocal_address(struct netif * netif, u8_t from_mac_48bit) -{ - u8_t i, addr_index, min_len; - - /* Link-local prefix. */ - netif->ip6_addr[0].addr[0] = PP_HTONL(0xfe800000ul); - netif->ip6_addr[0].addr[1] = 0; - - /* Generate interface ID. */ - if (from_mac_48bit) { - /* Assume hwaddr is a 48-bit IEEE 802 MAC. Convert to EUI-64 address. Complement Group bit. */ - netif->ip6_addr[0].addr[2] = htonl((((u32_t)(netif->hwaddr[0] ^ 0x02)) << 24) | - ((u32_t)(netif->hwaddr[1]) << 16) | - ((u32_t)(netif->hwaddr[2]) << 8) | - (0xff)); - netif->ip6_addr[0].addr[3] = htonl((0xfeul << 24) | - ((u32_t)(netif->hwaddr[3]) << 16) | - ((u32_t)(netif->hwaddr[4]) << 8) | - (netif->hwaddr[5])); - } - else { - /* Use hwaddr directly as interface ID. */ - netif->ip6_addr[0].addr[2] = 0; - netif->ip6_addr[0].addr[3] = 0; - - min_len = netif->hwaddr_len < 8 ? netif->hwaddr_len : 8; - addr_index = 3; - for (i = 0; i < min_len; i++) { - if (i == 4) { - addr_index--; - } - netif->ip6_addr[0].addr[addr_index] |= ((u32_t)(netif->hwaddr[netif->hwaddr_len - i - 1])) << (8 * (i & 0x03)); - } - } - - /* Set address state. */ -#if LWIP_IPV6_DUP_DETECT_ATTEMPTS - /* Will perform duplicate address detection (DAD). */ - netif->ip6_addr_state[0] = IP6_ADDR_TENTATIVE; -#else - /* Consider address valid. */ - netif->ip6_addr_state[0] = IP6_ADDR_PREFERRED; -#endif /* LWIP_IPV6_AUTOCONFIG */ -} - -static err_t -netif_null_output_ip6(struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr) -{ - (void)netif; - (void)p; - (void)ipaddr; - - return ERR_IF; -} -#endif /* LWIP_IPV6 */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/pbuf.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/pbuf.c deleted file mode 100644 index 1e5e53b1..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/pbuf.c +++ /dev/null @@ -1,1179 +0,0 @@ -/** - * @file - * Packet buffer management - * - * Packets are built from the pbuf data structure. It supports dynamic - * memory allocation for packet contents or can reference externally - * managed packet contents both in RAM and ROM. Quick allocation for - * incoming packets is provided through pools with fixed sized pbufs. - * - * A packet may span over multiple pbufs, chained as a singly linked - * list. This is called a "pbuf chain". - * - * Multiple packets may be queued, also using this singly linked list. - * This is called a "packet queue". - * - * So, a packet queue consists of one or more pbuf chains, each of - * which consist of one or more pbufs. CURRENTLY, PACKET QUEUES ARE - * NOT SUPPORTED!!! Use helper structs to queue multiple packets. - * - * The differences between a pbuf chain and a packet queue are very - * precise but subtle. - * - * The last pbuf of a packet has a ->tot_len field that equals the - * ->len field. It can be found by traversing the list. If the last - * pbuf of a packet has a ->next field other than NULL, more packets - * are on the queue. - * - * Therefore, looping through a pbuf of a single packet, has an - * loop end condition (tot_len == p->len), NOT (next == NULL). - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#include "lwip/stats.h" -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/pbuf.h" -#include "lwip/sys.h" -#include "arch/perf.h" -#if LWIP_TCP && TCP_QUEUE_OOSEQ -#include "lwip/tcp_impl.h" -#endif -#if LWIP_CHECKSUM_ON_COPY -#include "lwip/inet_chksum.h" -#endif - -#include - -#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf)) -/* Since the pool is created in memp, PBUF_POOL_BUFSIZE will be automatically - aligned there. Therefore, PBUF_POOL_BUFSIZE_ALIGNED can be used here. */ -#define PBUF_POOL_BUFSIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE) - -#if !LWIP_TCP || !TCP_QUEUE_OOSEQ || !PBUF_POOL_FREE_OOSEQ -#define PBUF_POOL_IS_EMPTY() -#else /* !LWIP_TCP || !TCP_QUEUE_OOSEQ || !PBUF_POOL_FREE_OOSEQ */ - -#if !NO_SYS -#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL -#include "lwip/tcpip.h" -#define PBUF_POOL_FREE_OOSEQ_QUEUE_CALL() do { \ - if(tcpip_callback_with_block(pbuf_free_ooseq_callback, NULL, 0) != ERR_OK) { \ - SYS_ARCH_PROTECT(old_level); \ - pbuf_free_ooseq_pending = 0; \ - SYS_ARCH_UNPROTECT(old_level); \ - } } while(0) -#endif /* PBUF_POOL_FREE_OOSEQ_QUEUE_CALL */ -#endif /* !NO_SYS */ - -volatile u8_t pbuf_free_ooseq_pending; -#define PBUF_POOL_IS_EMPTY() pbuf_pool_is_empty() - -/** - * Attempt to reclaim some memory from queued out-of-sequence TCP segments - * if we run out of pool pbufs. It's better to give priority to new packets - * if we're running out. - * - * This must be done in the correct thread context therefore this function - * can only be used with NO_SYS=0 and through tcpip_callback. - */ -#if !NO_SYS -static -#endif /* !NO_SYS */ -void -pbuf_free_ooseq(void) -{ - struct tcp_pcb* pcb; - SYS_ARCH_DECL_PROTECT(old_level); - - SYS_ARCH_PROTECT(old_level); - pbuf_free_ooseq_pending = 0; - SYS_ARCH_UNPROTECT(old_level); - - for (pcb = tcp_active_pcbs; NULL != pcb; pcb = pcb->next) { - if (NULL != pcb->ooseq) { - /** Free the ooseq pbufs of one PCB only */ - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free_ooseq: freeing out-of-sequence pbufs\n")); - tcp_segs_free(pcb->ooseq); - pcb->ooseq = NULL; - return; - } - } -} - -#if !NO_SYS -/** - * Just a callback function for tcpip_timeout() that calls pbuf_free_ooseq(). - */ -static void -pbuf_free_ooseq_callback(void *arg) -{ - LWIP_UNUSED_ARG(arg); - pbuf_free_ooseq(); -} -#endif /* !NO_SYS */ - -/** Queue a call to pbuf_free_ooseq if not already queued. */ -static void -pbuf_pool_is_empty(void) -{ -#ifndef PBUF_POOL_FREE_OOSEQ_QUEUE_CALL - SYS_ARCH_DECL_PROTECT(old_level); - SYS_ARCH_PROTECT(old_level); - pbuf_free_ooseq_pending = 1; - SYS_ARCH_UNPROTECT(old_level); -#else /* PBUF_POOL_FREE_OOSEQ_QUEUE_CALL */ - u8_t queued; - SYS_ARCH_DECL_PROTECT(old_level); - SYS_ARCH_PROTECT(old_level); - queued = pbuf_free_ooseq_pending; - pbuf_free_ooseq_pending = 1; - SYS_ARCH_UNPROTECT(old_level); - - if(!queued) { - /* queue a call to pbuf_free_ooseq if not already queued */ - PBUF_POOL_FREE_OOSEQ_QUEUE_CALL(); - } -#endif /* PBUF_POOL_FREE_OOSEQ_QUEUE_CALL */ -} -#endif /* !LWIP_TCP || !TCP_QUEUE_OOSEQ || !PBUF_POOL_FREE_OOSEQ */ - -/** - * Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type). - * - * The actual memory allocated for the pbuf is determined by the - * layer at which the pbuf is allocated and the requested size - * (from the size parameter). - * - * @param layer flag to define header size - * @param length size of the pbuf's payload - * @param type this parameter decides how and where the pbuf - * should be allocated as follows: - * - * - PBUF_RAM: buffer memory for pbuf is allocated as one large - * chunk. This includes protocol headers as well. - * - PBUF_ROM: no buffer memory is allocated for the pbuf, even for - * protocol headers. Additional headers must be prepended - * by allocating another pbuf and chain in to the front of - * the ROM pbuf. It is assumed that the memory used is really - * similar to ROM in that it is immutable and will not be - * changed. Memory which is dynamic should generally not - * be attached to PBUF_ROM pbufs. Use PBUF_REF instead. - * - PBUF_REF: no buffer memory is allocated for the pbuf, even for - * protocol headers. It is assumed that the pbuf is only - * being used in a single thread. If the pbuf gets queued, - * then pbuf_take should be called to copy the buffer. - * - PBUF_POOL: the pbuf is allocated as a pbuf chain, with pbufs from - * the pbuf pool that is allocated during pbuf_init(). - * - * @return the allocated pbuf. If multiple pbufs where allocated, this - * is the first pbuf of a pbuf chain. - */ -struct pbuf * -pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type) -{ - struct pbuf *p, *q, *r; - u16_t offset; - s32_t rem_len; /* remaining length */ - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F")\n", length)); - - /* determine header offset */ - switch (layer) { - case PBUF_TRANSPORT: - /* add room for transport (often TCP) layer header */ - offset = PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN; - break; - case PBUF_IP: - /* add room for IP layer header */ - offset = PBUF_LINK_HLEN + PBUF_IP_HLEN; - break; - case PBUF_LINK: - /* add room for link layer header */ - offset = PBUF_LINK_HLEN; - break; - case PBUF_RAW: - offset = 0; - break; - default: - LWIP_ASSERT("pbuf_alloc: bad pbuf layer", 0); - return NULL; - } - - switch (type) { - case PBUF_POOL: - /* allocate head of pbuf chain into p */ - p = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL); - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc: allocated pbuf %p\n", (void *)p)); - if (p == NULL) { - PBUF_POOL_IS_EMPTY(); - return NULL; - } - p->type = type; - p->next = NULL; - - /* make the payload pointer point 'offset' bytes into pbuf data memory */ - p->payload = LWIP_MEM_ALIGN((void *)((u8_t *)p + (SIZEOF_STRUCT_PBUF + offset))); - LWIP_ASSERT("pbuf_alloc: pbuf p->payload properly aligned", - ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); - /* the total length of the pbuf chain is the requested size */ - p->tot_len = length; - /* set the length of the first pbuf in the chain */ - p->len = LWIP_MIN(length, PBUF_POOL_BUFSIZE_ALIGNED - LWIP_MEM_ALIGN_SIZE(offset)); - LWIP_ASSERT("check p->payload + p->len does not overflow pbuf", - ((u8_t*)p->payload + p->len <= - (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); - LWIP_ASSERT("PBUF_POOL_BUFSIZE must be bigger than MEM_ALIGNMENT", - (PBUF_POOL_BUFSIZE_ALIGNED - LWIP_MEM_ALIGN_SIZE(offset)) > 0 ); - /* set reference count (needed here in case we fail) */ - p->ref = 1; - - /* now allocate the tail of the pbuf chain */ - - /* remember first pbuf for linkage in next iteration */ - r = p; - /* remaining length to be allocated */ - rem_len = length - p->len; - /* any remaining pbufs to be allocated? */ - while (rem_len > 0) { - q = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL); - if (q == NULL) { - PBUF_POOL_IS_EMPTY(); - /* free chain so far allocated */ - pbuf_free(p); - /* bail out unsuccesfully */ - return NULL; - } - q->type = type; - q->flags = 0; - q->next = NULL; - /* make previous pbuf point to this pbuf */ - r->next = q; - /* set total length of this pbuf and next in chain */ - LWIP_ASSERT("rem_len < max_u16_t", rem_len < 0xffff); - q->tot_len = (u16_t)rem_len; - /* this pbuf length is pool size, unless smaller sized tail */ - q->len = LWIP_MIN((u16_t)rem_len, PBUF_POOL_BUFSIZE_ALIGNED); - q->payload = (void *)((u8_t *)q + SIZEOF_STRUCT_PBUF); - LWIP_ASSERT("pbuf_alloc: pbuf q->payload properly aligned", - ((mem_ptr_t)q->payload % MEM_ALIGNMENT) == 0); - LWIP_ASSERT("check p->payload + p->len does not overflow pbuf", - ((u8_t*)p->payload + p->len <= - (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); - q->ref = 1; - /* calculate remaining length to be allocated */ - rem_len -= q->len; - /* remember this pbuf for linkage in next iteration */ - r = q; - } - /* end of chain */ - /*r->next = NULL;*/ - - break; - case PBUF_RAM: - /* If pbuf is to be allocated in RAM, allocate memory for it. */ - p = (struct pbuf*)mem_malloc(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZE(length)); - if (p == NULL) { - return NULL; - } - /* Set up internal structure of the pbuf. */ - p->payload = LWIP_MEM_ALIGN((void *)((u8_t *)p + SIZEOF_STRUCT_PBUF + offset)); - p->len = p->tot_len = length; - p->next = NULL; - p->type = type; - - LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned", - ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); - break; - /* pbuf references existing (non-volatile static constant) ROM payload? */ - case PBUF_ROM: - /* pbuf references existing (externally allocated) RAM payload? */ - case PBUF_REF: - /* only allocate memory for the pbuf structure */ - p = (struct pbuf *)memp_malloc(MEMP_PBUF); - if (p == NULL) { - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n", - (type == PBUF_ROM) ? "ROM" : "REF")); - return NULL; - } - /* caller must set this field properly, afterwards */ - p->payload = NULL; - p->len = p->tot_len = length; - p->next = NULL; - p->type = type; - break; - default: - LWIP_ASSERT("pbuf_alloc: erroneous type", 0); - return NULL; - } - /* set reference count */ - p->ref = 1; - /* set flags */ - p->flags = 0; - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p)); - return p; -} - -#if LWIP_SUPPORT_CUSTOM_PBUF -/** Initialize a custom pbuf (already allocated). - * - * @param layer flag to define header size - * @param length size of the pbuf's payload - * @param type type of the pbuf (only used to treat the pbuf accordingly, as - * this function allocates no memory) - * @param p pointer to the custom pbuf to initialize (already allocated) - * @param payload_mem pointer to the buffer that is used for payload and headers, - * must be at least big enough to hold 'length' plus the header size, - * may be NULL if set later. - * ATTENTION: The caller is responsible for correct alignment of this buffer!! - * @param payload_mem_len the size of the 'payload_mem' buffer, must be at least - * big enough to hold 'length' plus the header size - */ -struct pbuf* -pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, struct pbuf_custom *p, - void *payload_mem, u16_t payload_mem_len) -{ - u16_t offset; - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloced_custom(length=%"U16_F")\n", length)); - - /* determine header offset */ - switch (l) { - case PBUF_TRANSPORT: - /* add room for transport (often TCP) layer header */ - offset = PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN; - break; - case PBUF_IP: - /* add room for IP layer header */ - offset = PBUF_LINK_HLEN + PBUF_IP_HLEN; - break; - case PBUF_LINK: - /* add room for link layer header */ - offset = PBUF_LINK_HLEN; - break; - case PBUF_RAW: - offset = 0; - break; - default: - LWIP_ASSERT("pbuf_alloced_custom: bad pbuf layer", 0); - return NULL; - } - - if (LWIP_MEM_ALIGN_SIZE(offset) + length > payload_mem_len) { - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_WARNING, ("pbuf_alloced_custom(length=%"U16_F") buffer too short\n", length)); - return NULL; - } - - p->pbuf.next = NULL; - if (payload_mem != NULL) { - p->pbuf.payload = (u8_t *)payload_mem + LWIP_MEM_ALIGN_SIZE(offset); - } else { - p->pbuf.payload = NULL; - } - p->pbuf.flags = PBUF_FLAG_IS_CUSTOM; - p->pbuf.len = p->pbuf.tot_len = length; - p->pbuf.type = type; - p->pbuf.ref = 1; - return &p->pbuf; -} -#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ - -/** - * Shrink a pbuf chain to a desired length. - * - * @param p pbuf to shrink. - * @param new_len desired new length of pbuf chain - * - * Depending on the desired length, the first few pbufs in a chain might - * be skipped and left unchanged. The new last pbuf in the chain will be - * resized, and any remaining pbufs will be freed. - * - * @note If the pbuf is ROM/REF, only the ->tot_len and ->len fields are adjusted. - * @note May not be called on a packet queue. - * - * @note Despite its name, pbuf_realloc cannot grow the size of a pbuf (chain). - */ -void -pbuf_realloc(struct pbuf *p, u16_t new_len) -{ - struct pbuf *q; - u16_t rem_len; /* remaining length */ - s32_t grow; - - LWIP_ASSERT("pbuf_realloc: p != NULL", p != NULL); - LWIP_ASSERT("pbuf_realloc: sane p->type", p->type == PBUF_POOL || - p->type == PBUF_ROM || - p->type == PBUF_RAM || - p->type == PBUF_REF); - - /* desired length larger than current length? */ - if (new_len >= p->tot_len) { - /* enlarging not yet supported */ - return; - } - - /* the pbuf chain grows by (new_len - p->tot_len) bytes - * (which may be negative in case of shrinking) */ - grow = new_len - p->tot_len; - - /* first, step over any pbufs that should remain in the chain */ - rem_len = new_len; - q = p; - /* should this pbuf be kept? */ - while (rem_len > q->len) { - /* decrease remaining length by pbuf length */ - rem_len -= q->len; - /* decrease total length indicator */ - LWIP_ASSERT("grow < max_u16_t", grow < 0xffff); - q->tot_len += (u16_t)grow; - /* proceed to next pbuf in chain */ - q = q->next; - LWIP_ASSERT("pbuf_realloc: q != NULL", q != NULL); - } - /* we have now reached the new last pbuf (in q) */ - /* rem_len == desired length for pbuf q */ - - /* shrink allocated memory for PBUF_RAM */ - /* (other types merely adjust their length fields */ - if ((q->type == PBUF_RAM) && (rem_len != q->len)) { - /* reallocate and adjust the length of the pbuf that will be split */ - q = (struct pbuf *)mem_trim(q, (u16_t)((u8_t *)q->payload - (u8_t *)q) + rem_len); - LWIP_ASSERT("mem_trim returned q == NULL", q != NULL); - } - /* adjust length fields for new last pbuf */ - q->len = rem_len; - q->tot_len = q->len; - - /* any remaining pbufs in chain? */ - if (q->next != NULL) { - /* free remaining pbufs in chain */ - pbuf_free(q->next); - } - /* q is last packet in chain */ - q->next = NULL; - -} - -/** - * Adjusts the payload pointer to hide or reveal headers in the payload. - * - * Adjusts the ->payload pointer so that space for a header - * (dis)appears in the pbuf payload. - * - * The ->payload, ->tot_len and ->len fields are adjusted. - * - * @param p pbuf to change the header size. - * @param header_size_increment Number of bytes to increment header size which - * increases the size of the pbuf. New space is on the front. - * (Using a negative value decreases the header size.) - * If hdr_size_inc is 0, this function does nothing and returns succesful. - * - * PBUF_ROM and PBUF_REF type buffers cannot have their sizes increased, so - * the call will fail. A check is made that the increase in header size does - * not move the payload pointer in front of the start of the buffer. - * @return non-zero on failure, zero on success. - * - */ -u8_t -pbuf_header(struct pbuf *p, s16_t header_size_increment) -{ - u16_t type; - void *payload; - u16_t increment_magnitude; - - LWIP_ASSERT("p != NULL", p != NULL); - if ((header_size_increment == 0) || (p == NULL)) { - return 0; - } - - if (header_size_increment < 0){ - increment_magnitude = -header_size_increment; - /* Check that we aren't going to move off the end of the pbuf */ - LWIP_ERROR("increment_magnitude <= p->len", (increment_magnitude <= p->len), return 1;); - } else { - increment_magnitude = header_size_increment; -#if 0 - /* Can't assert these as some callers speculatively call - pbuf_header() to see if it's OK. Will return 1 below instead. */ - /* Check that we've got the correct type of pbuf to work with */ - LWIP_ASSERT("p->type == PBUF_RAM || p->type == PBUF_POOL", - p->type == PBUF_RAM || p->type == PBUF_POOL); - /* Check that we aren't going to move off the beginning of the pbuf */ - LWIP_ASSERT("p->payload - increment_magnitude >= p + SIZEOF_STRUCT_PBUF", - (u8_t *)p->payload - increment_magnitude >= (u8_t *)p + SIZEOF_STRUCT_PBUF); -#endif - } - - type = p->type; - /* remember current payload pointer */ - payload = p->payload; - - /* pbuf types containing payloads? */ - if (type == PBUF_RAM || type == PBUF_POOL) { - /* set new payload pointer */ - p->payload = (u8_t *)p->payload - header_size_increment; - /* boundary check fails? */ - if ((u8_t *)p->payload < (u8_t *)p + SIZEOF_STRUCT_PBUF) { - LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("pbuf_header: failed as %p < %p (not enough space for new header size)\n", - (void *)p->payload, (void *)(p + 1))); - /* restore old payload pointer */ - p->payload = payload; - /* bail out unsuccesfully */ - return 1; - } - /* pbuf types refering to external payloads? */ - } else if (type == PBUF_REF || type == PBUF_ROM) { - /* hide a header in the payload? */ - if ((header_size_increment < 0) && (increment_magnitude <= p->len)) { - /* increase payload pointer */ - p->payload = (u8_t *)p->payload - header_size_increment; - } else { - /* cannot expand payload to front (yet!) - * bail out unsuccesfully */ - return 1; - } - } else { - /* Unknown type */ - LWIP_ASSERT("bad pbuf type", 0); - return 1; - } - /* modify pbuf length fields */ - p->len += header_size_increment; - p->tot_len += header_size_increment; - - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_header: old %p new %p (%"S16_F")\n", - (void *)payload, (void *)p->payload, header_size_increment)); - - return 0; -} - -/** - * Dereference a pbuf chain or queue and deallocate any no-longer-used - * pbufs at the head of this chain or queue. - * - * Decrements the pbuf reference count. If it reaches zero, the pbuf is - * deallocated. - * - * For a pbuf chain, this is repeated for each pbuf in the chain, - * up to the first pbuf which has a non-zero reference count after - * decrementing. So, when all reference counts are one, the whole - * chain is free'd. - * - * @param p The pbuf (chain) to be dereferenced. - * - * @return the number of pbufs that were de-allocated - * from the head of the chain. - * - * @note MUST NOT be called on a packet queue (Not verified to work yet). - * @note the reference counter of a pbuf equals the number of pointers - * that refer to the pbuf (or into the pbuf). - * - * @internal examples: - * - * Assuming existing chains a->b->c with the following reference - * counts, calling pbuf_free(a) results in: - * - * 1->2->3 becomes ...1->3 - * 3->3->3 becomes 2->3->3 - * 1->1->2 becomes ......1 - * 2->1->1 becomes 1->1->1 - * 1->1->1 becomes ....... - * - */ -u8_t -pbuf_free(struct pbuf *p) -{ - u16_t type; - struct pbuf *q; - u8_t count; - - if (p == NULL) { - LWIP_ASSERT("p != NULL", p != NULL); - /* if assertions are disabled, proceed with debug output */ - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("pbuf_free(p == NULL) was called.\n")); - return 0; - } - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free(%p)\n", (void *)p)); - - PERF_START; - - LWIP_ASSERT("pbuf_free: sane type", - p->type == PBUF_RAM || p->type == PBUF_ROM || - p->type == PBUF_REF || p->type == PBUF_POOL); - - count = 0; - /* de-allocate all consecutive pbufs from the head of the chain that - * obtain a zero reference count after decrementing*/ - while (p != NULL) { - u16_t ref; - SYS_ARCH_DECL_PROTECT(old_level); - /* Since decrementing ref cannot be guaranteed to be a single machine operation - * we must protect it. We put the new ref into a local variable to prevent - * further protection. */ - SYS_ARCH_PROTECT(old_level); - /* all pbufs in a chain are referenced at least once */ - LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0); - /* decrease reference count (number of pointers to pbuf) */ - ref = --(p->ref); - SYS_ARCH_UNPROTECT(old_level); - /* this pbuf is no longer referenced to? */ - if (ref == 0) { - /* remember next pbuf in chain for next iteration */ - q = p->next; - LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: deallocating %p\n", (void *)p)); - type = p->type; -#if LWIP_SUPPORT_CUSTOM_PBUF - /* is this a custom pbuf? */ - if ((p->flags & PBUF_FLAG_IS_CUSTOM) != 0) { - struct pbuf_custom *pc = (struct pbuf_custom*)p; - LWIP_ASSERT("pc->custom_free_function != NULL", pc->custom_free_function != NULL); - pc->custom_free_function(p); - } else -#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ - { - /* is this a pbuf from the pool? */ - if (type == PBUF_POOL) { - memp_free(MEMP_PBUF_POOL, p); - /* is this a ROM or RAM referencing pbuf? */ - } else if (type == PBUF_ROM || type == PBUF_REF) { - memp_free(MEMP_PBUF, p); - /* type == PBUF_RAM */ - } else { - mem_free(p); - } - } - count++; - /* proceed to next pbuf */ - p = q; - /* p->ref > 0, this pbuf is still referenced to */ - /* (and so the remaining pbufs in chain as well) */ - } else { - LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: %p has ref %"U16_F", ending here.\n", (void *)p, ref)); - /* stop walking through the chain */ - p = NULL; - } - } - PERF_STOP("pbuf_free"); - /* return number of de-allocated pbufs */ - return count; -} - -/** - * Count number of pbufs in a chain - * - * @param p first pbuf of chain - * @return the number of pbufs in a chain - */ - -u8_t -pbuf_clen(struct pbuf *p) -{ - u8_t len; - - len = 0; - while (p != NULL) { - ++len; - p = p->next; - } - return len; -} - -/** - * Increment the reference count of the pbuf. - * - * @param p pbuf to increase reference counter of - * - */ -void -pbuf_ref(struct pbuf *p) -{ - SYS_ARCH_DECL_PROTECT(old_level); - /* pbuf given? */ - if (p != NULL) { - SYS_ARCH_PROTECT(old_level); - ++(p->ref); - SYS_ARCH_UNPROTECT(old_level); - } -} - -/** - * Concatenate two pbufs (each may be a pbuf chain) and take over - * the caller's reference of the tail pbuf. - * - * @note The caller MAY NOT reference the tail pbuf afterwards. - * Use pbuf_chain() for that purpose. - * - * @see pbuf_chain() - */ - -void -pbuf_cat(struct pbuf *h, struct pbuf *t) -{ - struct pbuf *p; - - LWIP_ERROR("(h != NULL) && (t != NULL) (programmer violates API)", - ((h != NULL) && (t != NULL)), return;); - - /* proceed to last pbuf of chain */ - for (p = h; p->next != NULL; p = p->next) { - /* add total length of second chain to all totals of first chain */ - p->tot_len += t->tot_len; - } - /* { p is last pbuf of first h chain, p->next == NULL } */ - LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); - LWIP_ASSERT("p->next == NULL", p->next == NULL); - /* add total length of second chain to last pbuf total of first chain */ - p->tot_len += t->tot_len; - /* chain last pbuf of head (p) with first of tail (t) */ - p->next = t; - /* p->next now references t, but the caller will drop its reference to t, - * so netto there is no change to the reference count of t. - */ -} - -/** - * Chain two pbufs (or pbuf chains) together. - * - * The caller MUST call pbuf_free(t) once it has stopped - * using it. Use pbuf_cat() instead if you no longer use t. - * - * @param h head pbuf (chain) - * @param t tail pbuf (chain) - * @note The pbufs MUST belong to the same packet. - * @note MAY NOT be called on a packet queue. - * - * The ->tot_len fields of all pbufs of the head chain are adjusted. - * The ->next field of the last pbuf of the head chain is adjusted. - * The ->ref field of the first pbuf of the tail chain is adjusted. - * - */ -void -pbuf_chain(struct pbuf *h, struct pbuf *t) -{ - pbuf_cat(h, t); - /* t is now referenced by h */ - pbuf_ref(t); - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_chain: %p references %p\n", (void *)h, (void *)t)); -} - -/** - * Dechains the first pbuf from its succeeding pbufs in the chain. - * - * Makes p->tot_len field equal to p->len. - * @param p pbuf to dechain - * @return remainder of the pbuf chain, or NULL if it was de-allocated. - * @note May not be called on a packet queue. - */ -struct pbuf * -pbuf_dechain(struct pbuf *p) -{ - struct pbuf *q; - u8_t tail_gone = 1; - /* tail */ - q = p->next; - /* pbuf has successor in chain? */ - if (q != NULL) { - /* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ - LWIP_ASSERT("p->tot_len == p->len + q->tot_len", q->tot_len == p->tot_len - p->len); - /* enforce invariant if assertion is disabled */ - q->tot_len = p->tot_len - p->len; - /* decouple pbuf from remainder */ - p->next = NULL; - /* total length of pbuf p is its own length only */ - p->tot_len = p->len; - /* q is no longer referenced by p, free it */ - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_dechain: unreferencing %p\n", (void *)q)); - tail_gone = pbuf_free(q); - if (tail_gone > 0) { - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, - ("pbuf_dechain: deallocated %p (as it is no longer referenced)\n", (void *)q)); - } - /* return remaining tail or NULL if deallocated */ - } - /* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ - LWIP_ASSERT("p->tot_len == p->len", p->tot_len == p->len); - return ((tail_gone > 0) ? NULL : q); -} - -/** - * - * Create PBUF_RAM copies of pbufs. - * - * Used to queue packets on behalf of the lwIP stack, such as - * ARP based queueing. - * - * @note You MUST explicitly use p = pbuf_take(p); - * - * @note Only one packet is copied, no packet queue! - * - * @param p_to pbuf destination of the copy - * @param p_from pbuf source of the copy - * - * @return ERR_OK if pbuf was copied - * ERR_ARG if one of the pbufs is NULL or p_to is not big - * enough to hold p_from - */ -err_t -pbuf_copy(struct pbuf *p_to, struct pbuf *p_from) -{ - u16_t offset_to=0, offset_from=0, len; - - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy(%p, %p)\n", - (void*)p_to, (void*)p_from)); - - /* is the target big enough to hold the source? */ - LWIP_ERROR("pbuf_copy: target not big enough to hold source", ((p_to != NULL) && - (p_from != NULL) && (p_to->tot_len >= p_from->tot_len)), return ERR_ARG;); - - /* iterate through pbuf chain */ - do - { - /* copy one part of the original chain */ - if ((p_to->len - offset_to) >= (p_from->len - offset_from)) { - /* complete current p_from fits into current p_to */ - len = p_from->len - offset_from; - } else { - /* current p_from does not fit into current p_to */ - len = p_to->len - offset_to; - } - MEMCPY((u8_t*)p_to->payload + offset_to, (u8_t*)p_from->payload + offset_from, len); - offset_to += len; - offset_from += len; - LWIP_ASSERT("offset_to <= p_to->len", offset_to <= p_to->len); - LWIP_ASSERT("offset_from <= p_from->len", offset_from <= p_from->len); - if (offset_from >= p_from->len) { - /* on to next p_from (if any) */ - offset_from = 0; - p_from = p_from->next; - } - if (offset_to == p_to->len) { - /* on to next p_to (if any) */ - offset_to = 0; - p_to = p_to->next; - LWIP_ERROR("p_to != NULL", (p_to != NULL) || (p_from == NULL) , return ERR_ARG;); - } - - if((p_from != NULL) && (p_from->len == p_from->tot_len)) { - /* don't copy more than one packet! */ - LWIP_ERROR("pbuf_copy() does not allow packet queues!\n", - (p_from->next == NULL), return ERR_VAL;); - } - if((p_to != NULL) && (p_to->len == p_to->tot_len)) { - /* don't copy more than one packet! */ - LWIP_ERROR("pbuf_copy() does not allow packet queues!\n", - (p_to->next == NULL), return ERR_VAL;); - } - } while (p_from); - LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_copy: end of chain reached.\n")); - return ERR_OK; -} - -/** - * Copy (part of) the contents of a packet buffer - * to an application supplied buffer. - * - * @param buf the pbuf from which to copy data - * @param dataptr the application supplied buffer - * @param len length of data to copy (dataptr must be big enough). No more - * than buf->tot_len will be copied, irrespective of len - * @param offset offset into the packet buffer from where to begin copying len bytes - * @return the number of bytes copied, or 0 on failure - */ -u16_t -pbuf_copy_partial(struct pbuf *buf, void *dataptr, u16_t len, u16_t offset) -{ - struct pbuf *p; - u16_t left; - u16_t buf_copy_len; - u16_t copied_total = 0; - - LWIP_ERROR("pbuf_copy_partial: invalid buf", (buf != NULL), return 0;); - LWIP_ERROR("pbuf_copy_partial: invalid dataptr", (dataptr != NULL), return 0;); - - left = 0; - - if((buf == NULL) || (dataptr == NULL)) { - return 0; - } - - /* Note some systems use byte copy if dataptr or one of the pbuf payload pointers are unaligned. */ - for(p = buf; len != 0 && p != NULL; p = p->next) { - if ((offset != 0) && (offset >= p->len)) { - /* don't copy from this buffer -> on to the next */ - offset -= p->len; - } else { - /* copy from this buffer. maybe only partially. */ - buf_copy_len = p->len - offset; - if (buf_copy_len > len) - buf_copy_len = len; - /* copy the necessary parts of the buffer */ - MEMCPY(&((char*)dataptr)[left], &((char*)p->payload)[offset], buf_copy_len); - copied_total += buf_copy_len; - left += buf_copy_len; - len -= buf_copy_len; - offset = 0; - } - } - return copied_total; -} - -/** - * Copy application supplied data into a pbuf. - * This function can only be used to copy the equivalent of buf->tot_len data. - * - * @param buf pbuf to fill with data - * @param dataptr application supplied data buffer - * @param len length of the application supplied data buffer - * - * @return ERR_OK if successful, ERR_MEM if the pbuf is not big enough - */ -err_t -pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len) -{ - struct pbuf *p; - u16_t buf_copy_len; - u16_t total_copy_len = len; - u16_t copied_total = 0; - - LWIP_ERROR("pbuf_take: invalid buf", (buf != NULL), return 0;); - LWIP_ERROR("pbuf_take: invalid dataptr", (dataptr != NULL), return 0;); - - if ((buf == NULL) || (dataptr == NULL) || (buf->tot_len < len)) { - return ERR_ARG; - } - - /* Note some systems use byte copy if dataptr or one of the pbuf payload pointers are unaligned. */ - for(p = buf; total_copy_len != 0; p = p->next) { - LWIP_ASSERT("pbuf_take: invalid pbuf", p != NULL); - buf_copy_len = total_copy_len; - if (buf_copy_len > p->len) { - /* this pbuf cannot hold all remaining data */ - buf_copy_len = p->len; - } - /* copy the necessary parts of the buffer */ - MEMCPY(p->payload, &((char*)dataptr)[copied_total], buf_copy_len); - total_copy_len -= buf_copy_len; - copied_total += buf_copy_len; - } - LWIP_ASSERT("did not copy all data", total_copy_len == 0 && copied_total == len); - return ERR_OK; -} - -/** - * Creates a single pbuf out of a queue of pbufs. - * - * @remark: Either the source pbuf 'p' is freed by this function or the original - * pbuf 'p' is returned, therefore the caller has to check the result! - * - * @param p the source pbuf - * @param layer pbuf_layer of the new pbuf - * - * @return a new, single pbuf (p->next is NULL) - * or the old pbuf if allocation fails - */ -struct pbuf* -pbuf_coalesce(struct pbuf *p, pbuf_layer layer) -{ - struct pbuf *q; - err_t err; - if (p->next == NULL) { - return p; - } - q = pbuf_alloc(layer, p->tot_len, PBUF_RAM); - if (q == NULL) { - /* @todo: what do we do now? */ - return p; - } - err = pbuf_copy(q, p); - LWIP_ASSERT("pbuf_copy failed", err == ERR_OK); - pbuf_free(p); - return q; -} - -#if LWIP_CHECKSUM_ON_COPY -/** - * Copies data into a single pbuf (*not* into a pbuf queue!) and updates - * the checksum while copying - * - * @param p the pbuf to copy data into - * @param start_offset offset of p->payload where to copy the data to - * @param dataptr data to copy into the pbuf - * @param len length of data to copy into the pbuf - * @param chksum pointer to the checksum which is updated - * @return ERR_OK if successful, another error if the data does not fit - * within the (first) pbuf (no pbuf queues!) - */ -err_t -pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, - u16_t len, u16_t *chksum) -{ - u32_t acc; - u16_t copy_chksum; - char *dst_ptr; - LWIP_ASSERT("p != NULL", p != NULL); - LWIP_ASSERT("dataptr != NULL", dataptr != NULL); - LWIP_ASSERT("chksum != NULL", chksum != NULL); - LWIP_ASSERT("len != 0", len != 0); - - if ((start_offset >= p->len) || (start_offset + len > p->len)) { - return ERR_ARG; - } - - dst_ptr = ((char*)p->payload) + start_offset; - copy_chksum = LWIP_CHKSUM_COPY(dst_ptr, dataptr, len); - if ((start_offset & 1) != 0) { - copy_chksum = SWAP_BYTES_IN_WORD(copy_chksum); - } - acc = *chksum; - acc += copy_chksum; - *chksum = FOLD_U32T(acc); - return ERR_OK; -} -#endif /* LWIP_CHECKSUM_ON_COPY */ - - /** Get one byte from the specified position in a pbuf - * WARNING: returns zero for offset >= p->tot_len - * - * @param p pbuf to parse - * @param offset offset into p of the byte to return - * @return byte at an offset into p OR ZERO IF 'offset' >= p->tot_len - */ -u8_t -pbuf_get_at(struct pbuf* p, u16_t offset) -{ - u16_t copy_from = offset; - struct pbuf* q = p; - - /* get the correct pbuf */ - while ((q != NULL) && (q->len <= copy_from)) { - copy_from -= q->len; - q = q->next; - } - /* return requested data if pbuf is OK */ - if ((q != NULL) && (q->len > copy_from)) { - return ((u8_t*)q->payload)[copy_from]; - } - return 0; -} - -/** Compare pbuf contents at specified offset with memory s2, both of length n - * - * @param p pbuf to compare - * @param offset offset into p at wich to start comparing - * @param s2 buffer to compare - * @param n length of buffer to compare - * @return zero if equal, nonzero otherwise - * (0xffff if p is too short, diffoffset+1 otherwise) - */ -u16_t -pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n) -{ - u16_t start = offset; - struct pbuf* q = p; - - /* get the correct pbuf */ - while ((q != NULL) && (q->len <= start)) { - start -= q->len; - q = q->next; - } - /* return requested data if pbuf is OK */ - if ((q != NULL) && (q->len > start)) { - u16_t i; - for(i = 0; i < n; i++) { - u8_t a = pbuf_get_at(q, start + i); - u8_t b = ((u8_t*)s2)[i]; - if (a != b) { - return i+1; - } - } - return 0; - } - return 0xffff; -} - -/** Find occurrence of mem (with length mem_len) in pbuf p, starting at offset - * start_offset. - * - * @param p pbuf to search, maximum length is 0xFFFE since 0xFFFF is used as - * return value 'not found' - * @param mem search for the contents of this buffer - * @param mem_len length of 'mem' - * @param start_offset offset into p at which to start searching - * @return 0xFFFF if substr was not found in p or the index where it was found - */ -u16_t -pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset) -{ - u16_t i; - u16_t max = p->tot_len - mem_len; - if (p->tot_len >= mem_len + start_offset) { - for(i = start_offset; i <= max; ) { - u16_t plus = pbuf_memcmp(p, i, mem, mem_len); - if (plus == 0) { - return i; - } else { - i += plus; - } - } - } - return 0xFFFF; -} - -/** Find occurrence of substr with length substr_len in pbuf p, start at offset - * start_offset - * WARNING: in contrast to strstr(), this one does not stop at the first \0 in - * the pbuf/source string! - * - * @param p pbuf to search, maximum length is 0xFFFE since 0xFFFF is used as - * return value 'not found' - * @param substr string to search for in p, maximum length is 0xFFFE - * @return 0xFFFF if substr was not found in p or the index where it was found - */ -u16_t -pbuf_strstr(struct pbuf* p, const char* substr) -{ - size_t substr_len; - if ((substr == NULL) || (substr[0] == 0) || (p->tot_len == 0xFFFF)) { - return 0xFFFF; - } - substr_len = strlen(substr); - if (substr_len >= 0xFFFF) { - return 0xFFFF; - } - return pbuf_memfind(p, substr, (u16_t)substr_len, 0); -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/stats.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/stats.c deleted file mode 100644 index 06fbe0f2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/stats.c +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @file - * Statistics module - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if LWIP_STATS /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/def.h" -#include "lwip/stats.h" -#include "lwip/mem.h" - -#include - -struct stats_ lwip_stats; - -void stats_init(void) -{ -#ifdef LWIP_DEBUG -#if MEMP_STATS - const char * memp_names[] = { -#define LWIP_MEMPOOL(name,num,size,desc) desc, -#include "lwip/memp_std.h" - }; - int i; - for (i = 0; i < MEMP_MAX; i++) { - lwip_stats.memp[i].name = memp_names[i]; - } -#endif /* MEMP_STATS */ -#if MEM_STATS - lwip_stats.mem.name = "MEM"; -#endif /* MEM_STATS */ -#endif /* LWIP_DEBUG */ -} - -#if LWIP_STATS_DISPLAY -void -stats_display_proto(struct stats_proto *proto, const char *name) -{ - LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); - LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); - LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); - LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); - LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); - LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr)); - LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr)); - LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr)); - LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr)); - LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr)); - LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr)); - LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err)); - LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); -} - -#if IGMP_STATS -void -stats_display_igmp(struct stats_igmp *igmp, const char *name) -{ - LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); - LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit)); - LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv)); - LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop)); - LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr)); - LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr)); - LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr)); - LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr)); - LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1)); - LWIP_PLATFORM_DIAG(("rx_group: %"STAT_COUNTER_F"\n\t", igmp->rx_group)); - LWIP_PLATFORM_DIAG(("rx_general: %"STAT_COUNTER_F"\n\t", igmp->rx_general)); - LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report)); - LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join)); - LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave)); - LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report)); -} -#endif /* IGMP_STATS */ - -#if MEM_STATS || MEMP_STATS -void -stats_display_mem(struct stats_mem *mem, const char *name) -{ - LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name)); - LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail)); - LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used)); - LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max)); - LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err)); -} - -#if MEMP_STATS -void -stats_display_memp(struct stats_mem *mem, int index) -{ - char * memp_names[] = { -#define LWIP_MEMPOOL(name,num,size,desc) desc, -#include "lwip/memp_std.h" - }; - if(index < MEMP_MAX) { - stats_display_mem(mem, memp_names[index]); - } -} -#endif /* MEMP_STATS */ -#endif /* MEM_STATS || MEMP_STATS */ - -#if SYS_STATS -void -stats_display_sys(struct stats_sys *sys) -{ - LWIP_PLATFORM_DIAG(("\nSYS\n\t")); - LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used)); - LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max)); - LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err)); - LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used)); - LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max)); - LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err)); - LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used)); - LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max)); - LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err)); -} -#endif /* SYS_STATS */ - -void -stats_display(void) -{ - s16_t i; - - LINK_STATS_DISPLAY(); - ETHARP_STATS_DISPLAY(); - IPFRAG_STATS_DISPLAY(); - IP6_FRAG_STATS_DISPLAY(); - IP_STATS_DISPLAY(); - ND6_STATS_DISPLAY(); - IP6_STATS_DISPLAY(); - IGMP_STATS_DISPLAY(); - MLD6_STATS_DISPLAY(); - ICMP_STATS_DISPLAY(); - ICMP6_STATS_DISPLAY(); - UDP_STATS_DISPLAY(); - TCP_STATS_DISPLAY(); - MEM_STATS_DISPLAY(); - for (i = 0; i < MEMP_MAX; i++) { - MEMP_STATS_DISPLAY(i); - } - SYS_STATS_DISPLAY(); -} -#endif /* LWIP_STATS_DISPLAY */ - -#endif /* LWIP_STATS */ - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/tcp.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/tcp.c deleted file mode 100644 index 55496d05..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/tcp.c +++ /dev/null @@ -1,1852 +0,0 @@ -/** - * @file - * Transmission Control Protocol for IP - * - * This file contains common functions for the TCP implementation, such as functinos - * for manipulating the data structures and the TCP timer functions. TCP functions - * related to input and output is found in tcp_in.c and tcp_out.c respectively. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/snmp.h" -#include "lwip/tcp.h" -#include "lwip/tcp_impl.h" -#include "lwip/debug.h" -#include "lwip/stats.h" -#include "lwip/ip6.h" -#include "lwip/ip6_addr.h" -#include "lwip/nd6.h" - -#include - -#ifndef TCP_LOCAL_PORT_RANGE_START -/* From http://www.iana.org/assignments/port-numbers: - "The Dynamic and/or Private Ports are those from 49152 through 65535" */ -#define TCP_LOCAL_PORT_RANGE_START 0xc000 -#define TCP_LOCAL_PORT_RANGE_END 0xffff -#define TCP_ENSURE_LOCAL_PORT_RANGE(port) (((port) & ~TCP_LOCAL_PORT_RANGE_START) + TCP_LOCAL_PORT_RANGE_START) -#endif - -#if LWIP_TCP_KEEPALIVE -#define TCP_KEEP_DUR(pcb) ((pcb)->keep_cnt * (pcb)->keep_intvl) -#define TCP_KEEP_INTVL(pcb) ((pcb)->keep_intvl) -#else /* LWIP_TCP_KEEPALIVE */ -#define TCP_KEEP_DUR(pcb) TCP_MAXIDLE -#define TCP_KEEP_INTVL(pcb) TCP_KEEPINTVL_DEFAULT -#endif /* LWIP_TCP_KEEPALIVE */ - -const char * const tcp_state_str[] = { - "CLOSED", - "LISTEN", - "SYN_SENT", - "SYN_RCVD", - "ESTABLISHED", - "FIN_WAIT_1", - "FIN_WAIT_2", - "CLOSE_WAIT", - "CLOSING", - "LAST_ACK", - "TIME_WAIT" -}; - -/* last local TCP port */ -static u16_t tcp_port = TCP_LOCAL_PORT_RANGE_START; - -/* Incremented every coarse grained timer shot (typically every 500 ms). */ -u32_t tcp_ticks; -const u8_t tcp_backoff[13] = - { 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7}; - /* Times per slowtmr hits */ -const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 }; - -/* The TCP PCB lists. */ - -/** List of all TCP PCBs bound but not yet (connected || listening) */ -struct tcp_pcb *tcp_bound_pcbs; -/** List of all TCP PCBs in LISTEN state */ -union tcp_listen_pcbs_t tcp_listen_pcbs; -/** List of all TCP PCBs that are in a state in which - * they accept or send data. */ -struct tcp_pcb *tcp_active_pcbs; -/** List of all TCP PCBs in TIME-WAIT state */ -struct tcp_pcb *tcp_tw_pcbs; - -#define NUM_TCP_PCB_LISTS 4 -#define NUM_TCP_PCB_LISTS_NO_TIME_WAIT 3 -/** An array with all (non-temporary) PCB lists, mainly used for smaller code size */ -struct tcp_pcb ** const tcp_pcb_lists[] = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcbs, - &tcp_active_pcbs, &tcp_tw_pcbs}; - -/** Only used for temporary storage. */ -struct tcp_pcb *tcp_tmp_pcb; - -u8_t tcp_active_pcbs_changed; - -/** Timer counter to handle calling slow-timer from tcp_tmr() */ -static u8_t tcp_timer; -static u8_t tcp_timer_ctr; -static u16_t tcp_new_port(void); - -/** - * Initialize this module. - */ -void -tcp_init(void) -{ -#if LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) - tcp_port = TCP_ENSURE_LOCAL_PORT_RANGE(LWIP_RAND()); -#endif /* LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) */ -} - -/** - * Called periodically to dispatch TCP timers. - */ -void -tcp_tmr(void) -{ - /* Call tcp_fasttmr() every 250 ms */ - tcp_fasttmr(); - - if (++tcp_timer & 1) { - /* Call tcp_tmr() every 500 ms, i.e., every other timer - tcp_tmr() is called. */ - tcp_slowtmr(); - } -} - -/** - * Closes the TX side of a connection held by the PCB. - * For tcp_close(), a RST is sent if the application didn't receive all data - * (tcp_recved() not called for all data passed to recv callback). - * - * Listening pcbs are freed and may not be referenced any more. - * Connection pcbs are freed if not yet connected and may not be referenced - * any more. If a connection is established (at least SYN received or in - * a closing state), the connection is closed, and put in a closing state. - * The pcb is then automatically freed in tcp_slowtmr(). It is therefore - * unsafe to reference it. - * - * @param pcb the tcp_pcb to close - * @return ERR_OK if connection has been closed - * another err_t if closing failed and pcb is not freed - */ -static err_t -tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data) -{ - err_t err; - - if (rst_on_unacked_data && ((pcb->state == ESTABLISHED) || (pcb->state == CLOSE_WAIT))) { - if ((pcb->refused_data != NULL) || (pcb->rcv_wnd != TCP_WND)) { - /* Not all data received by application, send RST to tell the remote - side about this. */ - LWIP_ASSERT("pcb->flags & TF_RXCLOSED", pcb->flags & TF_RXCLOSED); - - /* don't call tcp_abort here: we must not deallocate the pcb since - that might not be expected when calling tcp_close */ - tcp_rst(pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip, - pcb->local_port, pcb->remote_port, PCB_ISIPV6(pcb)); - - tcp_pcb_purge(pcb); - TCP_RMV_ACTIVE(pcb); - if (pcb->state == ESTABLISHED) { - /* move to TIME_WAIT since we close actively */ - pcb->state = TIME_WAIT; - TCP_REG(&tcp_tw_pcbs, pcb); - } else { - /* CLOSE_WAIT: deallocate the pcb since we already sent a RST for it */ - memp_free(MEMP_TCP_PCB, pcb); - } - return ERR_OK; - } - } - - switch (pcb->state) { - case CLOSED: - /* Closing a pcb in the CLOSED state might seem erroneous, - * however, it is in this state once allocated and as yet unused - * and the user needs some way to free it should the need arise. - * Calling tcp_close() with a pcb that has already been closed, (i.e. twice) - * or for a pcb that has been used and then entered the CLOSED state - * is erroneous, but this should never happen as the pcb has in those cases - * been freed, and so any remaining handles are bogus. */ - err = ERR_OK; - if (pcb->local_port != 0 || pcb->bound_to_netif) { - TCP_RMV(&tcp_bound_pcbs, pcb); - } - memp_free(MEMP_TCP_PCB, pcb); - pcb = NULL; - break; - case LISTEN: - err = ERR_OK; - tcp_pcb_remove(&tcp_listen_pcbs.pcbs, pcb); - memp_free(MEMP_TCP_PCB_LISTEN, pcb); - pcb = NULL; - break; - case SYN_SENT: - err = ERR_OK; - TCP_PCB_REMOVE_ACTIVE(pcb); - memp_free(MEMP_TCP_PCB, pcb); - pcb = NULL; - snmp_inc_tcpattemptfails(); - break; - case SYN_RCVD: - err = tcp_send_fin(pcb); - if (err == ERR_OK) { - snmp_inc_tcpattemptfails(); - pcb->state = FIN_WAIT_1; - } - break; - case ESTABLISHED: - err = tcp_send_fin(pcb); - if (err == ERR_OK) { - snmp_inc_tcpestabresets(); - pcb->state = FIN_WAIT_1; - } - break; - case CLOSE_WAIT: - err = tcp_send_fin(pcb); - if (err == ERR_OK) { - snmp_inc_tcpestabresets(); - pcb->state = LAST_ACK; - } - break; - default: - /* Has already been closed, do nothing. */ - err = ERR_OK; - pcb = NULL; - break; - } - - if (pcb != NULL && err == ERR_OK) { - /* To ensure all data has been sent when tcp_close returns, we have - to make sure tcp_output doesn't fail. - Since we don't really have to ensure all data has been sent when tcp_close - returns (unsent data is sent from tcp timer functions, also), we don't care - for the return value of tcp_output for now. */ - /* @todo: When implementing SO_LINGER, this must be changed somehow: - If SOF_LINGER is set, the data should be sent and acked before close returns. - This can only be valid for sequential APIs, not for the raw API. */ - tcp_output(pcb); - } - return err; -} - -/** - * Closes the connection held by the PCB. - * - * Listening pcbs are freed and may not be referenced any more. - * Connection pcbs are freed if not yet connected and may not be referenced - * any more. If a connection is established (at least SYN received or in - * a closing state), the connection is closed, and put in a closing state. - * The pcb is then automatically freed in tcp_slowtmr(). It is therefore - * unsafe to reference it (unless an error is returned). - * - * @param pcb the tcp_pcb to close - * @return ERR_OK if connection has been closed - * another err_t if closing failed and pcb is not freed - */ -err_t -tcp_close(struct tcp_pcb *pcb) -{ -#if TCP_DEBUG - LWIP_DEBUGF(TCP_DEBUG, ("tcp_close: closing in ")); - tcp_debug_print_state(pcb->state); -#endif /* TCP_DEBUG */ - - if (pcb->state != LISTEN) { - /* Set a flag not to receive any more data... */ - pcb->flags |= TF_RXCLOSED; - } - /* ... and close */ - return tcp_close_shutdown(pcb, 1); -} - -/** - * Causes all or part of a full-duplex connection of this PCB to be shut down. - * This doesn't deallocate the PCB unless shutting down both sides! - * Shutting down both sides is the same as calling tcp_close, so if it succeds, - * the PCB should not be referenced any more. - * - * @param pcb PCB to shutdown - * @param shut_rx shut down receive side if this is != 0 - * @param shut_tx shut down send side if this is != 0 - * @return ERR_OK if shutdown succeeded (or the PCB has already been shut down) - * another err_t on error. - */ -err_t -tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx) -{ - if (pcb->state == LISTEN) { - return ERR_CONN; - } - if (shut_rx) { - /* shut down the receive side: set a flag not to receive any more data... */ - pcb->flags |= TF_RXCLOSED; - if (shut_tx) { - /* shutting down the tx AND rx side is the same as closing for the raw API */ - return tcp_close_shutdown(pcb, 1); - } - /* ... and free buffered data */ - if (pcb->refused_data != NULL) { - pbuf_free(pcb->refused_data); - pcb->refused_data = NULL; - } - } - if (shut_tx) { - /* This can't happen twice since if it succeeds, the pcb's state is changed. - Only close in these states as the others directly deallocate the PCB */ - switch (pcb->state) { - case SYN_RCVD: - case ESTABLISHED: - case CLOSE_WAIT: - return tcp_close_shutdown(pcb, shut_rx); - default: - /* Not (yet?) connected, cannot shutdown the TX side as that would bring us - into CLOSED state, where the PCB is deallocated. */ - return ERR_CONN; - } - } - return ERR_OK; -} - -/** - * Abandons a connection and optionally sends a RST to the remote - * host. Deletes the local protocol control block. This is done when - * a connection is killed because of shortage of memory. - * - * @param pcb the tcp_pcb to abort - * @param reset boolean to indicate whether a reset should be sent - */ -void -tcp_abandon(struct tcp_pcb *pcb, int reset) -{ - u32_t seqno, ackno; -#if LWIP_CALLBACK_API - tcp_err_fn errf; -#endif /* LWIP_CALLBACK_API */ - void *errf_arg; - - /* pcb->state LISTEN not allowed here */ - LWIP_ASSERT("don't call tcp_abort/tcp_abandon for listen-pcbs", - pcb->state != LISTEN); - /* Figure out on which TCP PCB list we are, and remove us. If we - are in an active state, call the receive function associated with - the PCB with a NULL argument, and send an RST to the remote end. */ - if (pcb->state == TIME_WAIT) { - tcp_pcb_remove(&tcp_tw_pcbs, pcb); - memp_free(MEMP_TCP_PCB, pcb); - } else { - int send_rst = reset && (pcb->state != CLOSED); - seqno = pcb->snd_nxt; - ackno = pcb->rcv_nxt; -#if LWIP_CALLBACK_API - errf = pcb->errf; -#endif /* LWIP_CALLBACK_API */ - errf_arg = pcb->callback_arg; - TCP_PCB_REMOVE_ACTIVE(pcb); - if (pcb->unacked != NULL) { - tcp_segs_free(pcb->unacked); - } - if (pcb->unsent != NULL) { - tcp_segs_free(pcb->unsent); - } -#if TCP_QUEUE_OOSEQ - if (pcb->ooseq != NULL) { - tcp_segs_free(pcb->ooseq); - } -#endif /* TCP_QUEUE_OOSEQ */ - if (send_rst) { - LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abandon: sending RST\n")); - tcp_rst(seqno, ackno, &pcb->local_ip, &pcb->remote_ip, pcb->local_port, pcb->remote_port, PCB_ISIPV6(pcb)); - } - memp_free(MEMP_TCP_PCB, pcb); - TCP_EVENT_ERR(errf, errf_arg, ERR_ABRT); - } -} - -/** - * Aborts the connection by sending a RST (reset) segment to the remote - * host. The pcb is deallocated. This function never fails. - * - * ATTENTION: When calling this from one of the TCP callbacks, make - * sure you always return ERR_ABRT (and never return ERR_ABRT otherwise - * or you will risk accessing deallocated memory or memory leaks! - * - * @param pcb the tcp pcb to abort - */ -void -tcp_abort(struct tcp_pcb *pcb) -{ - tcp_abandon(pcb, 1); -} - -/** - * Binds the connection to a local portnumber and IP address. If the - * IP address is not given (i.e., ipaddr == NULL), the IP address of - * the outgoing network interface is used instead. - * - * @param pcb the tcp_pcb to bind (no check is done whether this pcb is - * already bound!) - * @param ipaddr the local ip address to bind to (use IP_ADDR_ANY to bind - * to any local address - * @param port the local port to bind to - * @return ERR_USE if the port is already in use - * ERR_VAL if bind failed because the PCB is not in a valid state - * ERR_OK if bound - */ -err_t -tcp_bind(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port) -{ - int i; - int max_pcb_list = NUM_TCP_PCB_LISTS; - struct tcp_pcb *cpcb; - - LWIP_ERROR("tcp_bind: can only bind in state CLOSED", pcb->state == CLOSED, return ERR_VAL); - -#if SO_REUSE - /* Unless the REUSEADDR flag is set, - we have to check the pcbs in TIME-WAIT state, also. - We do not dump TIME_WAIT pcb's; they can still be matched by incoming - packets using both local and remote IP addresses and ports to distinguish. - */ - if (ip_get_option(pcb, SOF_REUSEADDR)) { - max_pcb_list = NUM_TCP_PCB_LISTS_NO_TIME_WAIT; - } -#endif /* SO_REUSE */ - - if (port == 0) { - port = tcp_new_port(); - if (port == 0) { - return ERR_BUF; - } - } - - /* Check if the address already is in use (on all lists) */ - for (i = 0; i < max_pcb_list; i++) { - for(cpcb = *tcp_pcb_lists[i]; cpcb != NULL; cpcb = cpcb->next) { - if (cpcb->local_port == port) { -#if SO_REUSE - /* Omit checking for the same port if both pcbs have REUSEADDR set. - For SO_REUSEADDR, the duplicate-check for a 5-tuple is done in - tcp_connect. */ - if (!ip_get_option(pcb, SOF_REUSEADDR) || - !ip_get_option(cpcb, SOF_REUSEADDR)) -#endif /* SO_REUSE */ - { - /* @todo: check accept_any_ip_version */ - if (IP_PCB_IPVER_EQ(pcb, cpcb) && - (ipX_addr_isany(PCB_ISIPV6(pcb), &cpcb->local_ip) || - ipX_addr_isany(PCB_ISIPV6(pcb), ip_2_ipX(ipaddr)) || - ipX_addr_cmp(PCB_ISIPV6(pcb), &cpcb->local_ip, ip_2_ipX(ipaddr)))) { - return ERR_USE; - } - } - } - } - } - - pcb->bound_to_netif = 0; - if (!ipX_addr_isany(PCB_ISIPV6(pcb), ip_2_ipX(ipaddr))) { - ipX_addr_set(PCB_ISIPV6(pcb), &pcb->local_ip, ip_2_ipX(ipaddr)); - } - pcb->local_port = port; - TCP_REG(&tcp_bound_pcbs, pcb); - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: bind to port %"U16_F"\n", port)); - return ERR_OK; -} - -err_t -tcp_bind_to_netif(struct tcp_pcb *pcb, const char ifname[3]) -{ - LWIP_ERROR("tcp_bind_if: can only bind in state CLOSED", pcb->state == CLOSED, return ERR_ISCONN); - - /* Check if the interface is already in use */ - for (int i = 0; i < NUM_TCP_PCB_LISTS; i++) { - for(struct tcp_pcb *cpcb = *tcp_pcb_lists[i]; cpcb != NULL; cpcb = cpcb->next) { - if (IP_PCB_IPVER_EQ(pcb, cpcb) && - cpcb->bound_to_netif && - !memcmp(cpcb->local_netif, ifname, sizeof(cpcb->local_netif))) { - return ERR_USE; - } - } - } - - pcb->bound_to_netif = 1; - ipX_addr_set_any(PCB_ISIPV6(pcb), &pcb->local_ip); - pcb->local_port = 0; - memcpy(pcb->local_netif, ifname, sizeof(pcb->local_netif)); - TCP_REG(&tcp_bound_pcbs, pcb); - LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind_to_netif: bind to interface %c%c%c\n", ifname[0], ifname[1], ifname[2])); - return ERR_OK; -} - -#if LWIP_CALLBACK_API -/** - * Default accept callback if no accept callback is specified by the user. - */ -static err_t -tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err) -{ - LWIP_UNUSED_ARG(arg); - LWIP_UNUSED_ARG(pcb); - LWIP_UNUSED_ARG(err); - - return ERR_ABRT; -} -#endif /* LWIP_CALLBACK_API */ - -/** - * Set the state of the connection to be LISTEN, which means that it - * is able to accept incoming connections. The protocol control block - * is reallocated in order to consume less memory. Setting the - * connection to LISTEN is an irreversible process. - * - * @param pcb the original tcp_pcb - * @param backlog the incoming connections queue limit - * @return tcp_pcb used for listening, consumes less memory. - * - * @note The original tcp_pcb is freed. This function therefore has to be - * called like this: - * tpcb = tcp_listen(tpcb); - */ -struct tcp_pcb * -tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog) -{ - struct tcp_pcb_listen *lpcb; - - LWIP_UNUSED_ARG(backlog); - LWIP_ERROR("tcp_listen: pcb already connected", pcb->state == CLOSED, return NULL); - - /* already listening? */ - if (pcb->state == LISTEN) { - return pcb; - } -#if SO_REUSE - if (ip_get_option(pcb, SOF_REUSEADDR) && !pcb->have_local_netif) { - /* Since SOF_REUSEADDR allows reusing a local address before the pcb's usage - is declared (listen-/connection-pcb), we have to make sure now that - this port is only used once for every local IP. */ - for(lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { - if ((lpcb->local_port == pcb->local_port) && - IP_PCB_IPVER_EQ(pcb, lpcb)) { - if (ipX_addr_cmp(PCB_ISIPV6(pcb), &lpcb->local_ip, &pcb->local_ip)) { - /* this address/port is already used */ - return NULL; - } - } - } - } -#endif /* SO_REUSE */ - lpcb = (struct tcp_pcb_listen *)memp_malloc(MEMP_TCP_PCB_LISTEN); - if (lpcb == NULL) { - return NULL; - } - lpcb->callback_arg = pcb->callback_arg; - lpcb->bound_to_netif = pcb->bound_to_netif; - lpcb->local_port = pcb->local_port; - memcpy(lpcb->local_netif, pcb->local_netif, sizeof(pcb->local_netif)); - lpcb->state = LISTEN; - lpcb->prio = pcb->prio; - lpcb->so_options = pcb->so_options; - ip_set_option(lpcb, SOF_ACCEPTCONN); - lpcb->ttl = pcb->ttl; - lpcb->tos = pcb->tos; -#if LWIP_IPV6 - PCB_ISIPV6(lpcb) = PCB_ISIPV6(pcb); - lpcb->accept_any_ip_version = 0; -#endif /* LWIP_IPV6 */ - ipX_addr_copy(PCB_ISIPV6(pcb), lpcb->local_ip, pcb->local_ip); - if (pcb->local_port != 0 || pcb->bound_to_netif) { - TCP_RMV(&tcp_bound_pcbs, pcb); - } - memp_free(MEMP_TCP_PCB, pcb); -#if LWIP_CALLBACK_API - lpcb->accept = tcp_accept_null; -#endif /* LWIP_CALLBACK_API */ -#if TCP_LISTEN_BACKLOG - lpcb->accepts_pending = 0; - lpcb->backlog = (backlog ? backlog : 1); -#endif /* TCP_LISTEN_BACKLOG */ - TCP_REG(&tcp_listen_pcbs.pcbs, (struct tcp_pcb *)lpcb); - return (struct tcp_pcb *)lpcb; -} - -#if LWIP_IPV6 -/** - * Same as tcp_listen_with_backlog, but allows to accept IPv4 and IPv6 - * connections, if the pcb's local address is set to ANY. - */ -struct tcp_pcb * -tcp_listen_dual_with_backlog(struct tcp_pcb *pcb, u8_t backlog) -{ - struct tcp_pcb *lpcb; - - lpcb = tcp_listen_with_backlog(pcb, backlog); - if ((lpcb != NULL) && - ipX_addr_isany(PCB_ISIPV6(pcb), &pcb->local_ip)) { - /* The default behavior is to accept connections on either - * IPv4 or IPv6, if not bound. */ - /* @see NETCONN_FLAG_IPV6_V6ONLY for changing this behavior */ - ((struct tcp_pcb_listen*)lpcb)->accept_any_ip_version = 1; - } - return lpcb; -} -#endif /* LWIP_IPV6 */ - -/** - * Update the state that tracks the available window space to advertise. - * - * Returns how much extra window would be advertised if we sent an - * update now. - */ -u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb) -{ - u32_t new_right_edge = pcb->rcv_nxt + pcb->rcv_wnd; - - if (TCP_SEQ_GEQ(new_right_edge, pcb->rcv_ann_right_edge + LWIP_MIN((TCP_WND / 2), pcb->mss))) { - /* we can advertise more window */ - pcb->rcv_ann_wnd = pcb->rcv_wnd; - return new_right_edge - pcb->rcv_ann_right_edge; - } else { - if (TCP_SEQ_GT(pcb->rcv_nxt, pcb->rcv_ann_right_edge)) { - /* Can happen due to other end sending out of advertised window, - * but within actual available (but not yet advertised) window */ - pcb->rcv_ann_wnd = 0; - } else { - /* keep the right edge of window constant */ - u32_t new_rcv_ann_wnd = pcb->rcv_ann_right_edge - pcb->rcv_nxt; - LWIP_ASSERT("new_rcv_ann_wnd <= 0xffff", new_rcv_ann_wnd <= 0xffff); - pcb->rcv_ann_wnd = (u16_t)new_rcv_ann_wnd; - } - return 0; - } -} - -/** - * This function should be called by the application when it has - * processed the data. The purpose is to advertise a larger window - * when the data has been processed. - * - * @param pcb the tcp_pcb for which data is read - * @param len the amount of bytes that have been read by the application - */ -void -tcp_recved(struct tcp_pcb *pcb, u16_t len) -{ - int wnd_inflation; - - /* pcb->state LISTEN not allowed here */ - LWIP_ASSERT("don't call tcp_recved for listen-pcbs", - pcb->state != LISTEN); - LWIP_ASSERT("tcp_recved: len would wrap rcv_wnd\n", - len <= 0xffff - pcb->rcv_wnd ); - - pcb->rcv_wnd += len; - if (pcb->rcv_wnd > TCP_WND) { - pcb->rcv_wnd = TCP_WND; - } - - wnd_inflation = tcp_update_rcv_ann_wnd(pcb); - - /* If the change in the right edge of window is significant (default - * watermark is TCP_WND/4), then send an explicit update now. - * Otherwise wait for a packet to be sent in the normal course of - * events (or more window to be available later) */ - if (wnd_inflation >= TCP_WND_UPDATE_THRESHOLD) { - tcp_ack_now(pcb); - tcp_output(pcb); - } - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_recved: recveived %"U16_F" bytes, wnd %"U16_F" (%"U16_F").\n", - len, pcb->rcv_wnd, TCP_WND - pcb->rcv_wnd)); -} - -/** - * Allocate a new local TCP port. - * - * @return a new (free) local TCP port number - */ -static u16_t -tcp_new_port(void) -{ - u8_t i; - u16_t n = 0; - struct tcp_pcb *pcb; - -again: - if (tcp_port++ == TCP_LOCAL_PORT_RANGE_END) { - tcp_port = TCP_LOCAL_PORT_RANGE_START; - } - /* Check all PCB lists. */ - for (i = 0; i < NUM_TCP_PCB_LISTS; i++) { - for(pcb = *tcp_pcb_lists[i]; pcb != NULL; pcb = pcb->next) { - if (pcb->local_port == tcp_port) { - if (++n > (TCP_LOCAL_PORT_RANGE_END - TCP_LOCAL_PORT_RANGE_START)) { - return 0; - } - goto again; - } - } - } - return tcp_port; -} - -/** - * Connects to another host. The function given as the "connected" - * argument will be called when the connection has been established. - * - * @param pcb the tcp_pcb used to establish the connection - * @param ipaddr the remote ip address to connect to - * @param port the remote tcp port to connect to - * @param connected callback function to call when connected (or on error) - * @return ERR_VAL if invalid arguments are given - * ERR_OK if connect request has been sent - * other err_t values if connect request couldn't be sent - */ -err_t -tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port, - tcp_connected_fn connected) -{ - err_t ret; - u32_t iss; - u16_t old_local_port; - - LWIP_ERROR("tcp_connect: can only connect from state CLOSED", pcb->state == CLOSED, return ERR_ISCONN); - LWIP_ERROR("tcp_connect: cannot connect pcb bound to netif", !pcb->bound_to_netif, return ERR_VAL); - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %"U16_F"\n", port)); - if (ipaddr != NULL) { - ipX_addr_set(PCB_ISIPV6(pcb), &pcb->remote_ip, ip_2_ipX(ipaddr)); - } else { - return ERR_VAL; - } - pcb->remote_port = port; - - /* check if we have a route to the remote host */ - if (ipX_addr_isany(PCB_ISIPV6(pcb), &pcb->local_ip)) { - /* no local IP address set, yet. */ - struct netif *netif; - ipX_addr_t *local_ip; - ipX_route_get_local_ipX(PCB_ISIPV6(pcb), &pcb->local_ip, &pcb->remote_ip, netif, local_ip); - if ((netif == NULL) || (local_ip == NULL)) { - /* Don't even try to send a SYN packet if we have no route - since that will fail. */ - return ERR_RTE; - } - /* Use the address as local address of the pcb. */ - ipX_addr_copy(PCB_ISIPV6(pcb), pcb->local_ip, *local_ip); - } - - old_local_port = pcb->local_port; - if (pcb->local_port == 0) { - pcb->local_port = tcp_new_port(); - if (pcb->local_port == 0) { - return ERR_BUF; - } - } -#if SO_REUSE - if (ip_get_option(pcb, SOF_REUSEADDR)) { - /* Since SOF_REUSEADDR allows reusing a local address, we have to make sure - now that the 5-tuple is unique. */ - struct tcp_pcb *cpcb; - int i; - /* Don't check listen- and bound-PCBs, check active- and TIME-WAIT PCBs. */ - for (i = 2; i < NUM_TCP_PCB_LISTS; i++) { - for(cpcb = *tcp_pcb_lists[i]; cpcb != NULL; cpcb = cpcb->next) { - if ((cpcb->local_port == pcb->local_port) && - (cpcb->remote_port == port) && - IP_PCB_IPVER_EQ(cpcb, pcb) && - ipX_addr_cmp(PCB_ISIPV6(pcb), &cpcb->local_ip, &pcb->local_ip) && - ipX_addr_cmp(PCB_ISIPV6(pcb), &cpcb->remote_ip, ip_2_ipX(ipaddr))) { - /* linux returns EISCONN here, but ERR_USE should be OK for us */ - return ERR_USE; - } - } - } - } -#endif /* SO_REUSE */ - iss = tcp_next_iss(); - pcb->rcv_nxt = 0; - pcb->snd_nxt = iss; - pcb->lastack = iss - 1; - pcb->snd_lbb = iss - 1; - pcb->rcv_wnd = TCP_WND; - pcb->rcv_ann_wnd = TCP_WND; - pcb->rcv_ann_right_edge = pcb->rcv_nxt; - pcb->snd_wnd = TCP_WND; - /* As initial send MSS, we use TCP_MSS but limit it to 536. - The send MSS is updated when an MSS option is received. */ - pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS; -#if TCP_CALCULATE_EFF_SEND_MSS - pcb->mss = tcp_eff_send_mss(pcb->mss, &pcb->local_ip, &pcb->remote_ip, PCB_ISIPV6(pcb)); -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - pcb->cwnd = 1; - pcb->ssthresh = pcb->mss * 10; -#if LWIP_CALLBACK_API - pcb->connected = connected; -#else /* LWIP_CALLBACK_API */ - LWIP_UNUSED_ARG(connected); -#endif /* LWIP_CALLBACK_API */ - - /* Send a SYN together with the MSS option. */ - ret = tcp_enqueue_flags(pcb, TCP_SYN); - if (ret == ERR_OK) { - /* SYN segment was enqueued, changed the pcbs state now */ - pcb->state = SYN_SENT; - if (old_local_port != 0) { - TCP_RMV(&tcp_bound_pcbs, pcb); - } - TCP_REG_ACTIVE(pcb); - snmp_inc_tcpactiveopens(); - - tcp_output(pcb); - } - return ret; -} - -/** - * Called every 500 ms and implements the retransmission timer and the timer that - * removes PCBs that have been in TIME-WAIT for enough time. It also increments - * various timers such as the inactivity timer in each PCB. - * - * Automatically called from tcp_tmr(). - */ -void -tcp_slowtmr(void) -{ - struct tcp_pcb *pcb, *prev; - u16_t eff_wnd; - u8_t pcb_remove; /* flag if a PCB should be removed */ - u8_t pcb_reset; /* flag if a RST should be sent when removing */ - err_t err; - - err = ERR_OK; - - ++tcp_ticks; - ++tcp_timer_ctr; - -tcp_slowtmr_start: - /* Steps through all of the active PCBs. */ - prev = NULL; - pcb = tcp_active_pcbs; - if (pcb == NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: no active pcbs\n")); - } - while (pcb != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: processing active pcb\n")); - LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED\n", pcb->state != CLOSED); - LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN\n", pcb->state != LISTEN); - LWIP_ASSERT("tcp_slowtmr: active pcb->state != TIME-WAIT\n", pcb->state != TIME_WAIT); - if (pcb->last_timer == tcp_timer_ctr) { - /* skip this pcb, we have already processed it */ - pcb = pcb->next; - continue; - } - pcb->last_timer = tcp_timer_ctr; - - pcb_remove = 0; - pcb_reset = 0; - - if (pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) { - ++pcb_remove; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n")); - } - else if (pcb->nrtx == TCP_MAXRTX) { - ++pcb_remove; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n")); - } else { - if (pcb->persist_backoff > 0) { - /* If snd_wnd is zero, use persist timer to send 1 byte probes - * instead of using the standard retransmission mechanism. */ - pcb->persist_cnt++; - if (pcb->persist_cnt >= tcp_persist_backoff[pcb->persist_backoff-1]) { - pcb->persist_cnt = 0; - if (pcb->persist_backoff < sizeof(tcp_persist_backoff)) { - pcb->persist_backoff++; - } - tcp_zero_window_probe(pcb); - } - } else { - /* Increase the retransmission timer if it is running */ - if(pcb->rtime >= 0) { - ++pcb->rtime; - } - - if (pcb->unacked != NULL && pcb->rtime >= pcb->rto) { - /* Time for a retransmission. */ - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %"S16_F - " pcb->rto %"S16_F"\n", - pcb->rtime, pcb->rto)); - - /* Double retransmission time-out unless we are trying to - * connect to somebody (i.e., we are in SYN_SENT). */ - if (pcb->state != SYN_SENT) { - pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx]; - } - - /* Reset the retransmission timer. */ - pcb->rtime = 0; - - /* Reduce congestion window and ssthresh. */ - eff_wnd = LWIP_MIN(pcb->cwnd, pcb->snd_wnd); - pcb->ssthresh = eff_wnd >> 1; - if (pcb->ssthresh < (pcb->mss << 1)) { - pcb->ssthresh = (pcb->mss << 1); - } - pcb->cwnd = pcb->mss; - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %"U16_F - " ssthresh %"U16_F"\n", - pcb->cwnd, pcb->ssthresh)); - - /* The following needs to be called AFTER cwnd is set to one - mss - STJ */ - tcp_rexmit_rto(pcb); - } - } - } - /* Check if this PCB has stayed too long in FIN-WAIT-2 */ - if (pcb->state == FIN_WAIT_2) { - /* If this PCB is in FIN_WAIT_2 because of SHUT_WR don't let it time out. */ - if (pcb->flags & TF_RXCLOSED) { - /* PCB was fully closed (either through close() or SHUT_RDWR): - normal FIN-WAIT timeout handling. */ - if ((u32_t)(tcp_ticks - pcb->tmr) > - TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) { - ++pcb_remove; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n")); - } - } - } - - /* Check if KEEPALIVE should be sent */ - if(ip_get_option(pcb, SOF_KEEPALIVE) && - ((pcb->state == ESTABLISHED) || - (pcb->state == CLOSE_WAIT))) { - if((u32_t)(tcp_ticks - pcb->tmr) > - (pcb->keep_idle + TCP_KEEP_DUR(pcb)) / TCP_SLOW_INTERVAL) - { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to ")); - ipX_addr_debug_print(PCB_ISIPV6(pcb), TCP_DEBUG, &pcb->remote_ip); - LWIP_DEBUGF(TCP_DEBUG, ("\n")); - - ++pcb_remove; - ++pcb_reset; - } - else if((u32_t)(tcp_ticks - pcb->tmr) > - (pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEP_INTVL(pcb)) - / TCP_SLOW_INTERVAL) - { - tcp_keepalive(pcb); - pcb->keep_cnt_sent++; - } - } - - /* If this PCB has queued out of sequence data, but has been - inactive for too long, will drop the data (it will eventually - be retransmitted). */ -#if TCP_QUEUE_OOSEQ - if (pcb->ooseq != NULL && - (u32_t)tcp_ticks - pcb->tmr >= pcb->rto * TCP_OOSEQ_TIMEOUT) { - tcp_segs_free(pcb->ooseq); - pcb->ooseq = NULL; - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: dropping OOSEQ queued data\n")); - } -#endif /* TCP_QUEUE_OOSEQ */ - - /* Check if this PCB has stayed too long in SYN-RCVD */ - if (pcb->state == SYN_RCVD) { - if ((u32_t)(tcp_ticks - pcb->tmr) > - TCP_SYN_RCVD_TIMEOUT / TCP_SLOW_INTERVAL) { - ++pcb_remove; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD\n")); - } - } - - /* Check if this PCB has stayed too long in LAST-ACK */ - if (pcb->state == LAST_ACK) { - if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { - ++pcb_remove; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in LAST-ACK\n")); - } - } - - /* If the PCB should be removed, do it. */ - if (pcb_remove) { - struct tcp_pcb *pcb2; - tcp_err_fn err_fn; - void *err_arg; - tcp_pcb_purge(pcb); - /* Remove PCB from tcp_active_pcbs list. */ - if (prev != NULL) { - LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_active_pcbs", pcb != tcp_active_pcbs); - prev->next = pcb->next; - } else { - /* This PCB was the first. */ - LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_active_pcbs", tcp_active_pcbs == pcb); - tcp_active_pcbs = pcb->next; - } - - if (pcb_reset) { - tcp_rst(pcb->snd_nxt, pcb->rcv_nxt, &pcb->local_ip, &pcb->remote_ip, - pcb->local_port, pcb->remote_port, PCB_ISIPV6(pcb)); - } - - err_fn = pcb->errf; - err_arg = pcb->callback_arg; - pcb2 = pcb; - pcb = pcb->next; - memp_free(MEMP_TCP_PCB, pcb2); - - tcp_active_pcbs_changed = 0; - TCP_EVENT_ERR(err_fn, err_arg, ERR_ABRT); - if (tcp_active_pcbs_changed) { - goto tcp_slowtmr_start; - } - } else { - /* get the 'next' element now and work with 'prev' below (in case of abort) */ - prev = pcb; - pcb = pcb->next; - - /* We check if we should poll the connection. */ - ++prev->polltmr; - if (prev->polltmr >= prev->pollinterval) { - prev->polltmr = 0; - LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: polling application\n")); - tcp_active_pcbs_changed = 0; - TCP_EVENT_POLL(prev, err); - if (tcp_active_pcbs_changed) { - goto tcp_slowtmr_start; - } - /* if err == ERR_ABRT, 'prev' is already deallocated */ - if (err == ERR_OK) { - tcp_output(prev); - } - } - } - } - - - /* Steps through all of the TIME-WAIT PCBs. */ - prev = NULL; - pcb = tcp_tw_pcbs; - while (pcb != NULL) { - LWIP_ASSERT("tcp_slowtmr: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); - pcb_remove = 0; - - /* Check if this PCB has stayed long enough in TIME-WAIT */ - if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { - ++pcb_remove; - } - - - - /* If the PCB should be removed, do it. */ - if (pcb_remove) { - struct tcp_pcb *pcb2; - tcp_pcb_purge(pcb); - /* Remove PCB from tcp_tw_pcbs list. */ - if (prev != NULL) { - LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != tcp_tw_pcbs); - prev->next = pcb->next; - } else { - /* This PCB was the first. */ - LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_tw_pcbs", tcp_tw_pcbs == pcb); - tcp_tw_pcbs = pcb->next; - } - pcb2 = pcb; - pcb = pcb->next; - memp_free(MEMP_TCP_PCB, pcb2); - } else { - prev = pcb; - pcb = pcb->next; - } - } -} - -/** - * Is called every TCP_FAST_INTERVAL (250 ms) and process data previously - * "refused" by upper layer (application) and sends delayed ACKs. - * - * Automatically called from tcp_tmr(). - */ -void -tcp_fasttmr(void) -{ - struct tcp_pcb *pcb; - - ++tcp_timer_ctr; - -tcp_fasttmr_start: - pcb = tcp_active_pcbs; - - while(pcb != NULL) { - if (pcb->last_timer != tcp_timer_ctr) { - struct tcp_pcb *next; - pcb->last_timer = tcp_timer_ctr; - /* send delayed ACKs */ - if (pcb->flags & TF_ACK_DELAY) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_fasttmr: delayed ACK\n")); - tcp_ack_now(pcb); - tcp_output(pcb); - pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); - } - - next = pcb->next; - - /* If there is data which was previously "refused" by upper layer */ - if (pcb->refused_data != NULL) { - tcp_active_pcbs_changed = 0; - tcp_process_refused_data(pcb); - if (tcp_active_pcbs_changed) { - /* application callback has changed the pcb list: restart the loop */ - goto tcp_fasttmr_start; - } - } - pcb = next; - } - } -} - -/** Pass pcb->refused_data to the recv callback */ -err_t -tcp_process_refused_data(struct tcp_pcb *pcb) -{ - err_t err; - u8_t refused_flags = pcb->refused_data->flags; - /* set pcb->refused_data to NULL in case the callback frees it and then - closes the pcb */ - struct pbuf *refused_data = pcb->refused_data; - pcb->refused_data = NULL; - /* Notify again application with data previously received. */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: notify kept packet\n")); - TCP_EVENT_RECV(pcb, refused_data, ERR_OK, err); - if (err == ERR_OK) { - /* did refused_data include a FIN? */ - if (refused_flags & PBUF_FLAG_TCP_FIN) { - /* correct rcv_wnd as the application won't call tcp_recved() - for the FIN's seqno */ - if (pcb->rcv_wnd != TCP_WND) { - pcb->rcv_wnd++; - } - TCP_EVENT_CLOSED(pcb, err); - if (err == ERR_ABRT) { - return ERR_ABRT; - } - } - } else if (err == ERR_ABRT) { - /* if err == ERR_ABRT, 'pcb' is already deallocated */ - /* Drop incoming packets because pcb is "full" (only if the incoming - segment contains data). */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: drop incoming packets, because pcb is \"full\"\n")); - return ERR_ABRT; - } else { - /* data is still refused, pbuf is still valid (go on for ACK-only packets) */ - pcb->refused_data = refused_data; - } - return ERR_OK; -} - -/** - * Deallocates a list of TCP segments (tcp_seg structures). - * - * @param seg tcp_seg list of TCP segments to free - */ -void -tcp_segs_free(struct tcp_seg *seg) -{ - while (seg != NULL) { - struct tcp_seg *next = seg->next; - tcp_seg_free(seg); - seg = next; - } -} - -/** - * Frees a TCP segment (tcp_seg structure). - * - * @param seg single tcp_seg to free - */ -void -tcp_seg_free(struct tcp_seg *seg) -{ - if (seg != NULL) { - if (seg->p != NULL) { - pbuf_free(seg->p); -#if TCP_DEBUG - seg->p = NULL; -#endif /* TCP_DEBUG */ - } - memp_free(MEMP_TCP_SEG, seg); - } -} - -/** - * Sets the priority of a connection. - * - * @param pcb the tcp_pcb to manipulate - * @param prio new priority - */ -void -tcp_setprio(struct tcp_pcb *pcb, u8_t prio) -{ - pcb->prio = prio; -} - -#if TCP_QUEUE_OOSEQ -/** - * Returns a copy of the given TCP segment. - * The pbuf and data are not copied, only the pointers - * - * @param seg the old tcp_seg - * @return a copy of seg - */ -struct tcp_seg * -tcp_seg_copy(struct tcp_seg *seg) -{ - struct tcp_seg *cseg; - - cseg = (struct tcp_seg *)memp_malloc(MEMP_TCP_SEG); - if (cseg == NULL) { - return NULL; - } - SMEMCPY((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg)); - pbuf_ref(cseg->p); - return cseg; -} -#endif /* TCP_QUEUE_OOSEQ */ - -#if LWIP_CALLBACK_API -/** - * Default receive callback that is called if the user didn't register - * a recv callback for the pcb. - */ -err_t -tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) -{ - LWIP_UNUSED_ARG(arg); - if (p != NULL) { - tcp_recved(pcb, p->tot_len); - pbuf_free(p); - } else if (err == ERR_OK) { - return tcp_close(pcb); - } - return ERR_OK; -} -#endif /* LWIP_CALLBACK_API */ - -/** - * Kills the oldest active connection that has the same or lower priority than - * 'prio'. - * - * @param prio minimum priority - */ -static void -tcp_kill_prio(u8_t prio) -{ - struct tcp_pcb *pcb, *inactive; - u32_t inactivity; - u8_t mprio; - - - mprio = TCP_PRIO_MAX; - - /* We kill the oldest active connection that has lower priority than prio. */ - inactivity = 0; - inactive = NULL; - for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { - if (pcb->prio <= prio && - pcb->prio <= mprio && - (u32_t)(tcp_ticks - pcb->tmr) >= inactivity) { - inactivity = tcp_ticks - pcb->tmr; - inactive = pcb; - mprio = pcb->prio; - } - } - if (inactive != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_prio: killing oldest PCB %p (%"S32_F")\n", - (void *)inactive, inactivity)); - tcp_abort(inactive); - } -} - -/** - * Kills the oldest connection that is in TIME_WAIT state. - * Called from tcp_alloc() if no more connections are available. - */ -static void -tcp_kill_timewait(void) -{ - struct tcp_pcb *pcb, *inactive; - u32_t inactivity; - - inactivity = 0; - inactive = NULL; - /* Go through the list of TIME_WAIT pcbs and get the oldest pcb. */ - for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { - if ((u32_t)(tcp_ticks - pcb->tmr) >= inactivity) { - inactivity = tcp_ticks - pcb->tmr; - inactive = pcb; - } - } - if (inactive != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_timewait: killing oldest TIME-WAIT PCB %p (%"S32_F")\n", - (void *)inactive, inactivity)); - tcp_abort(inactive); - } -} - -/** - * Allocate a new tcp_pcb structure. - * - * @param prio priority for the new pcb - * @return a new tcp_pcb that initially is in state CLOSED - */ -struct tcp_pcb * -tcp_alloc(u8_t prio) -{ - struct tcp_pcb *pcb; - u32_t iss; - - pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); - if (pcb == NULL) { - /* Try killing oldest connection in TIME-WAIT. */ - LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest TIME-WAIT connection\n")); - tcp_kill_timewait(); - /* Try to allocate a tcp_pcb again. */ - pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); - if (pcb == NULL) { - /* Try killing active connections with lower priority than the new one. */ - LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing connection with prio lower than %d\n", prio)); - tcp_kill_prio(prio); - /* Try to allocate a tcp_pcb again. */ - pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); - if (pcb != NULL) { - /* adjust err stats: memp_malloc failed twice before */ - MEMP_STATS_DEC(err, MEMP_TCP_PCB); - } - } - if (pcb != NULL) { - /* adjust err stats: timewait PCB was freed above */ - MEMP_STATS_DEC(err, MEMP_TCP_PCB); - } - } - if (pcb != NULL) { - memset(pcb, 0, sizeof(struct tcp_pcb)); - pcb->prio = prio; - pcb->snd_buf = TCP_SND_BUF; - pcb->snd_queuelen = 0; - pcb->rcv_wnd = TCP_WND; - pcb->rcv_ann_wnd = TCP_WND; - pcb->tos = 0; - pcb->ttl = TCP_TTL; - /* As initial send MSS, we use TCP_MSS but limit it to 536. - The send MSS is updated when an MSS option is received. */ - pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS; - pcb->rto = 3000 / TCP_SLOW_INTERVAL; - pcb->sa = 0; - pcb->sv = 3000 / TCP_SLOW_INTERVAL; - pcb->rtime = -1; - pcb->cwnd = 1; - iss = tcp_next_iss(); - pcb->snd_wl2 = iss; - pcb->snd_nxt = iss; - pcb->lastack = iss; - pcb->snd_lbb = iss; - pcb->tmr = tcp_ticks; - pcb->last_timer = tcp_timer_ctr; - - pcb->polltmr = 0; - -#if LWIP_CALLBACK_API - pcb->recv = tcp_recv_null; -#endif /* LWIP_CALLBACK_API */ - - /* Init KEEPALIVE timer */ - pcb->keep_idle = TCP_KEEPIDLE_DEFAULT; - -#if LWIP_TCP_KEEPALIVE - pcb->keep_intvl = TCP_KEEPINTVL_DEFAULT; - pcb->keep_cnt = TCP_KEEPCNT_DEFAULT; -#endif /* LWIP_TCP_KEEPALIVE */ - - pcb->keep_cnt_sent = 0; - } - return pcb; -} - -/** - * Creates a new TCP protocol control block but doesn't place it on - * any of the TCP PCB lists. - * The pcb is not put on any list until binding using tcp_bind(). - * - * @internal: Maybe there should be a idle TCP PCB list where these - * PCBs are put on. Port reservation using tcp_bind() is implemented but - * allocated pcbs that are not bound can't be killed automatically if wanting - * to allocate a pcb with higher prio (@see tcp_kill_prio()) - * - * @return a new tcp_pcb that initially is in state CLOSED - */ -struct tcp_pcb * -tcp_new(void) -{ - return tcp_alloc(TCP_PRIO_NORMAL); -} - -#if LWIP_IPV6 -/** - * Creates a new TCP-over-IPv6 protocol control block but doesn't - * place it on any of the TCP PCB lists. - * The pcb is not put on any list until binding using tcp_bind(). - * - * @return a new tcp_pcb that initially is in state CLOSED - */ -struct tcp_pcb * -tcp_new_ip6(void) -{ - struct tcp_pcb * pcb; - pcb = tcp_alloc(TCP_PRIO_NORMAL); - ip_set_v6(pcb, 1); - return pcb; -} -#endif /* LWIP_IPV6 */ - -/** - * Used to specify the argument that should be passed callback - * functions. - * - * @param pcb tcp_pcb to set the callback argument - * @param arg void pointer argument to pass to callback functions - */ -void -tcp_arg(struct tcp_pcb *pcb, void *arg) -{ - /* This function is allowed to be called for both listen pcbs and - connection pcbs. */ - pcb->callback_arg = arg; -} -#if LWIP_CALLBACK_API - -/** - * Used to specify the function that should be called when a TCP - * connection receives data. - * - * @param pcb tcp_pcb to set the recv callback - * @param recv callback function to call for this pcb when data is received - */ -void -tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv) -{ - LWIP_ASSERT("invalid socket state for recv callback", pcb->state != LISTEN); - pcb->recv = recv; -} - -/** - * Used to specify the function that should be called when TCP data - * has been successfully delivered to the remote host. - * - * @param pcb tcp_pcb to set the sent callback - * @param sent callback function to call for this pcb when data is successfully sent - */ -void -tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent) -{ - LWIP_ASSERT("invalid socket state for sent callback", pcb->state != LISTEN); - pcb->sent = sent; -} - -/** - * Used to specify the function that should be called when a fatal error - * has occured on the connection. - * - * @param pcb tcp_pcb to set the err callback - * @param err callback function to call for this pcb when a fatal error - * has occured on the connection - */ -void -tcp_err(struct tcp_pcb *pcb, tcp_err_fn err) -{ - LWIP_ASSERT("invalid socket state for err callback", pcb->state != LISTEN); - pcb->errf = err; -} - -/** - * Used for specifying the function that should be called when a - * LISTENing connection has been connected to another host. - * - * @param pcb tcp_pcb to set the accept callback - * @param accept callback function to call for this pcb when LISTENing - * connection has been connected to another host - */ -void -tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept) -{ - /* This function is allowed to be called for both listen pcbs and - connection pcbs. */ - pcb->accept = accept; -} -#endif /* LWIP_CALLBACK_API */ - - -/** - * Used to specify the function that should be called periodically - * from TCP. The interval is specified in terms of the TCP coarse - * timer interval, which is called twice a second. - * - */ -void -tcp_poll(struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval) -{ - LWIP_ASSERT("invalid socket state for poll", pcb->state != LISTEN); -#if LWIP_CALLBACK_API - pcb->poll = poll; -#else /* LWIP_CALLBACK_API */ - LWIP_UNUSED_ARG(poll); -#endif /* LWIP_CALLBACK_API */ - pcb->pollinterval = interval; -} - -/** - * Purges a TCP PCB. Removes any buffered data and frees the buffer memory - * (pcb->ooseq, pcb->unsent and pcb->unacked are freed). - * - * @param pcb tcp_pcb to purge. The pcb itself is not deallocated! - */ -void -tcp_pcb_purge(struct tcp_pcb *pcb) -{ - if (pcb->state != CLOSED && - pcb->state != TIME_WAIT && - pcb->state != LISTEN) { - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge\n")); - -#if TCP_LISTEN_BACKLOG - if (pcb->state == SYN_RCVD) { - /* Need to find the corresponding listen_pcb and decrease its accepts_pending */ - struct tcp_pcb_listen *lpcb; - LWIP_ASSERT("tcp_pcb_purge: pcb->state == SYN_RCVD but tcp_listen_pcbs is NULL", - tcp_listen_pcbs.listen_pcbs != NULL); - for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { - if ((!lpcb->bound_to_netif && !pcb->bound_to_netif && - (lpcb->local_port == pcb->local_port) && - IP_PCB_IPVER_EQ(pcb, lpcb) && - (ipX_addr_isany(PCB_ISIPV6(lpcb), &lpcb->local_ip) || - ipX_addr_cmp(PCB_ISIPV6(lpcb), &pcb->local_ip, &lpcb->local_ip))) || - (lpcb->bound_to_netif && pcb->bound_to_netif && - !memcmp(lpcb->local_netif, pcb->local_netif, sizeof(pcb->local_netif)))) { - /* port and address of the listen pcb match the timed-out pcb */ - LWIP_ASSERT("tcp_pcb_purge: listen pcb does not have accepts pending", - lpcb->accepts_pending > 0); - lpcb->accepts_pending--; - break; - } - } - } -#endif /* TCP_LISTEN_BACKLOG */ - - - if (pcb->refused_data != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->refused_data\n")); - pbuf_free(pcb->refused_data); - pcb->refused_data = NULL; - } - if (pcb->unsent != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: not all data sent\n")); - } - if (pcb->unacked != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->unacked\n")); - } -#if TCP_QUEUE_OOSEQ - if (pcb->ooseq != NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->ooseq\n")); - } - tcp_segs_free(pcb->ooseq); - pcb->ooseq = NULL; -#endif /* TCP_QUEUE_OOSEQ */ - - /* Stop the retransmission timer as it will expect data on unacked - queue if it fires */ - pcb->rtime = -1; - - tcp_segs_free(pcb->unsent); - tcp_segs_free(pcb->unacked); - pcb->unacked = pcb->unsent = NULL; -#if TCP_OVERSIZE - pcb->unsent_oversize = 0; -#endif /* TCP_OVERSIZE */ - } -} - -/** - * Purges the PCB and removes it from a PCB list. Any delayed ACKs are sent first. - * - * @param pcblist PCB list to purge. - * @param pcb tcp_pcb to purge. The pcb itself is NOT deallocated! - */ -void -tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb) -{ - TCP_RMV(pcblist, pcb); - - tcp_pcb_purge(pcb); - - /* if there is an outstanding delayed ACKs, send it */ - if (pcb->state != TIME_WAIT && - pcb->state != LISTEN && - pcb->flags & TF_ACK_DELAY) { - pcb->flags |= TF_ACK_NOW; - tcp_output(pcb); - } - - if (pcb->state != LISTEN) { - LWIP_ASSERT("unsent segments leaking", pcb->unsent == NULL); - LWIP_ASSERT("unacked segments leaking", pcb->unacked == NULL); -#if TCP_QUEUE_OOSEQ - LWIP_ASSERT("ooseq segments leaking", pcb->ooseq == NULL); -#endif /* TCP_QUEUE_OOSEQ */ - } - - pcb->state = CLOSED; - - LWIP_ASSERT("tcp_pcb_remove: tcp_pcbs_sane()", tcp_pcbs_sane()); -} - -/** - * Calculates a new initial sequence number for new connections. - * - * @return u32_t pseudo random sequence number - */ -u32_t -tcp_next_iss(void) -{ - static u32_t iss = 6510; - - iss += tcp_ticks; /* XXX */ - return iss; -} - -#if TCP_CALCULATE_EFF_SEND_MSS -/** - * Calcluates the effective send mss that can be used for a specific IP address - * by using ip_route to determin the netif used to send to the address and - * calculating the minimum of TCP_MSS and that netif's mtu (if set). - */ -u16_t -tcp_eff_send_mss_impl(u16_t sendmss, ipX_addr_t *dest -#if LWIP_IPV6 - , ipX_addr_t *src, u8_t isipv6 -#endif /* LWIP_IPV6 */ - ) -{ - u16_t mss_s; - struct netif *outif; - s16_t mtu; - - outif = ipX_route(isipv6, src, dest); -#if LWIP_IPV6 - if (isipv6) { - /* First look in destination cache, to see if there is a Path MTU. */ - mtu = nd6_get_destination_mtu(ipX_2_ip6(dest), outif); - } else -#endif /* LWIP_IPV6 */ - { - if (outif == NULL) { - return sendmss; - } - mtu = outif->mtu; - } - - if (mtu != 0) { - mss_s = mtu - IP_HLEN - TCP_HLEN; -#if LWIP_IPV6 - /* for IPv6, substract the difference in header size */ - mss_s -= (IP6_HLEN - IP_HLEN); -#endif /* LWIP_IPV6 */ - /* RFC 1122, chap 4.2.2.6: - * Eff.snd.MSS = min(SendMSS+20, MMS_S) - TCPhdrsize - IPoptionsize - * We correct for TCP options in tcp_write(), and don't support IP options. - */ - sendmss = LWIP_MIN(sendmss, mss_s); - } - return sendmss; -} -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - -const char* -tcp_debug_state_str(enum tcp_state s) -{ - return tcp_state_str[s]; -} - -#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG -/** - * Print a tcp header for debugging purposes. - * - * @param tcphdr pointer to a struct tcp_hdr - */ -void -tcp_debug_print(struct tcp_hdr *tcphdr) -{ - LWIP_DEBUGF(TCP_DEBUG, ("TCP header:\n")); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n", - ntohs(tcphdr->src), ntohs(tcphdr->dest))); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %010"U32_F" | (seq no)\n", - ntohl(tcphdr->seqno))); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %010"U32_F" | (ack no)\n", - ntohl(tcphdr->ackno))); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| %2"U16_F" | |%"U16_F"%"U16_F"%"U16_F"%"U16_F"%"U16_F"%"U16_F"| %5"U16_F" | (hdrlen, flags (", - TCPH_HDRLEN(tcphdr), - TCPH_FLAGS(tcphdr) >> 5 & 1, - TCPH_FLAGS(tcphdr) >> 4 & 1, - TCPH_FLAGS(tcphdr) >> 3 & 1, - TCPH_FLAGS(tcphdr) >> 2 & 1, - TCPH_FLAGS(tcphdr) >> 1 & 1, - TCPH_FLAGS(tcphdr) & 1, - ntohs(tcphdr->wnd))); - tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); - LWIP_DEBUGF(TCP_DEBUG, ("), win)\n")); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(TCP_DEBUG, ("| 0x%04"X16_F" | %5"U16_F" | (chksum, urgp)\n", - ntohs(tcphdr->chksum), ntohs(tcphdr->urgp))); - LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); -} - -/** - * Print a tcp state for debugging purposes. - * - * @param s enum tcp_state to print - */ -void -tcp_debug_print_state(enum tcp_state s) -{ - LWIP_DEBUGF(TCP_DEBUG, ("State: %s\n", tcp_state_str[s])); -} - -/** - * Print tcp flags for debugging purposes. - * - * @param flags tcp flags, all active flags are printed - */ -void -tcp_debug_print_flags(u8_t flags) -{ - if (flags & TCP_FIN) { - LWIP_DEBUGF(TCP_DEBUG, ("FIN ")); - } - if (flags & TCP_SYN) { - LWIP_DEBUGF(TCP_DEBUG, ("SYN ")); - } - if (flags & TCP_RST) { - LWIP_DEBUGF(TCP_DEBUG, ("RST ")); - } - if (flags & TCP_PSH) { - LWIP_DEBUGF(TCP_DEBUG, ("PSH ")); - } - if (flags & TCP_ACK) { - LWIP_DEBUGF(TCP_DEBUG, ("ACK ")); - } - if (flags & TCP_URG) { - LWIP_DEBUGF(TCP_DEBUG, ("URG ")); - } - if (flags & TCP_ECE) { - LWIP_DEBUGF(TCP_DEBUG, ("ECE ")); - } - if (flags & TCP_CWR) { - LWIP_DEBUGF(TCP_DEBUG, ("CWR ")); - } - LWIP_DEBUGF(TCP_DEBUG, ("\n")); -} - -/** - * Print all tcp_pcbs in every list for debugging purposes. - */ -void -tcp_debug_print_pcbs(void) -{ - struct tcp_pcb *pcb; - LWIP_DEBUGF(TCP_DEBUG, ("Active PCB states:\n")); - for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", - pcb->local_port, pcb->remote_port, - pcb->snd_nxt, pcb->rcv_nxt)); - tcp_debug_print_state(pcb->state); - } - LWIP_DEBUGF(TCP_DEBUG, ("Listen PCB states:\n")); - for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", - pcb->local_port, pcb->remote_port, - pcb->snd_nxt, pcb->rcv_nxt)); - tcp_debug_print_state(pcb->state); - } - LWIP_DEBUGF(TCP_DEBUG, ("TIME-WAIT PCB states:\n")); - for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", - pcb->local_port, pcb->remote_port, - pcb->snd_nxt, pcb->rcv_nxt)); - tcp_debug_print_state(pcb->state); - } -} - -/** - * Check state consistency of the tcp_pcb lists. - */ -s16_t -tcp_pcbs_sane(void) -{ - struct tcp_pcb *pcb; - for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != CLOSED", pcb->state != CLOSED); - LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != LISTEN", pcb->state != LISTEN); - LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT); - } - for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_ASSERT("tcp_pcbs_sane: tw pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); - } - return 1; -} -#endif /* TCP_DEBUG */ - -#endif /* LWIP_TCP */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/tcp_in.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/tcp_in.c deleted file mode 100644 index 6c382d06..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/tcp_in.c +++ /dev/null @@ -1,1666 +0,0 @@ -/** - * @file - * Transmission Control Protocol, incoming traffic - * - * The input processing functions of the TCP layer. - * - * These functions are generally called in the order (ip_input() ->) - * tcp_input() -> * tcp_process() -> tcp_receive() (-> application). - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/tcp_impl.h" -#include "lwip/def.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/inet_chksum.h" -#include "lwip/stats.h" -#include "lwip/snmp.h" -#include "arch/perf.h" -#include "lwip/ip6.h" -#include "lwip/ip6_addr.h" -#include "lwip/inet_chksum.h" -#if LWIP_ND6_TCP_REACHABILITY_HINTS -#include "lwip/nd6.h" -#endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */ - -/* These variables are global to all functions involved in the input - processing of TCP segments. They are set by the tcp_input() - function. */ -static struct tcp_seg inseg; -static struct tcp_hdr *tcphdr; -static u32_t seqno, ackno; -static u8_t flags; -static u16_t tcplen; - -static u8_t recv_flags; -static struct pbuf *recv_data; - -struct tcp_pcb *tcp_input_pcb; - -/* Forward declarations. */ -static err_t tcp_process(struct tcp_pcb *pcb); -static void tcp_receive(struct tcp_pcb *pcb); -static void tcp_parseopt(struct tcp_pcb *pcb); - -static err_t tcp_listen_input(struct tcp_pcb_listen *pcb); -static err_t tcp_timewait_input(struct tcp_pcb *pcb); - -/** - * The initial input processing of TCP. It verifies the TCP header, demultiplexes - * the segment between the PCBs and passes it on to tcp_process(), which implements - * the TCP finite state machine. This function is called by the IP layer (in - * ip_input()). - * - * @param p received TCP segment to process (p->payload pointing to the TCP header) - * @param inp network interface on which this segment was received - */ -void -tcp_input(struct pbuf *p, struct netif *inp) -{ - struct tcp_pcb *pcb, *prev; - struct tcp_pcb_listen *lpcb; -#if SO_REUSE - struct tcp_pcb *lpcb_prev = NULL; - struct tcp_pcb_listen *lpcb_any = NULL; -#endif /* SO_REUSE */ - u8_t hdrlen; - err_t err; -#if CHECKSUM_CHECK_TCP - u16_t chksum; -#endif /* CHECKSUM_CHECK_TCP */ - - PERF_START; - - TCP_STATS_INC(tcp.recv); - snmp_inc_tcpinsegs(); - - tcphdr = (struct tcp_hdr *)p->payload; - -#if TCP_INPUT_DEBUG - tcp_debug_print(tcphdr); -#endif - - /* Check that TCP header fits in payload */ - if (p->len < sizeof(struct tcp_hdr)) { - /* drop short packets */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%"U16_F" bytes) discarded\n", p->tot_len)); - TCP_STATS_INC(tcp.lenerr); - goto dropped; - } - - /* Don't even process incoming broadcasts/multicasts. */ - if ((!ip_current_is_v6() && ip_addr_isbroadcast(ip_current_dest_addr(), inp)) || - ipX_addr_ismulticast(ip_current_is_v6(), ipX_current_dest_addr())) { - TCP_STATS_INC(tcp.proterr); - goto dropped; - } - -#if CHECKSUM_CHECK_TCP - /* Verify TCP checksum. */ - chksum = ipX_chksum_pseudo(ip_current_is_v6(), p, IP_PROTO_TCP, p->tot_len, - ipX_current_src_addr(), ipX_current_dest_addr()); - if (chksum != 0) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04"X16_F"\n", - chksum)); - tcp_debug_print(tcphdr); - TCP_STATS_INC(tcp.chkerr); - goto dropped; - } -#endif /* CHECKSUM_CHECK_TCP */ - - /* Move the payload pointer in the pbuf so that it points to the - TCP data instead of the TCP header. */ - hdrlen = TCPH_HDRLEN(tcphdr); - if(pbuf_header(p, -(hdrlen * 4))){ - /* drop short packets */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet\n")); - TCP_STATS_INC(tcp.lenerr); - goto dropped; - } - - /* Convert fields in TCP header to host byte order. */ - tcphdr->src = ntohs(tcphdr->src); - tcphdr->dest = ntohs(tcphdr->dest); - seqno = tcphdr->seqno = ntohl(tcphdr->seqno); - ackno = tcphdr->ackno = ntohl(tcphdr->ackno); - tcphdr->wnd = ntohs(tcphdr->wnd); - - flags = TCPH_FLAGS(tcphdr); - tcplen = p->tot_len + ((flags & (TCP_FIN | TCP_SYN)) ? 1 : 0); - - /* Demultiplex an incoming segment. First, we check if it is destined - for an active connection. */ - prev = NULL; - - - for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED); - LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT); - LWIP_ASSERT("tcp_input: active pcb->state != LISTEN", pcb->state != LISTEN); - if (pcb->remote_port == tcphdr->src && - pcb->local_port == tcphdr->dest && - IP_PCB_IPVER_INPUT_MATCH(pcb) && - ipX_addr_cmp(ip_current_is_v6(), &pcb->remote_ip, ipX_current_src_addr()) && - ipX_addr_cmp(ip_current_is_v6(),&pcb->local_ip, ipX_current_dest_addr())) { - /* Move this PCB to the front of the list so that subsequent - lookups will be faster (we exploit locality in TCP segment - arrivals). */ - LWIP_ASSERT("tcp_input: pcb->next != pcb (before cache)", pcb->next != pcb); - if (prev != NULL) { - prev->next = pcb->next; - pcb->next = tcp_active_pcbs; - tcp_active_pcbs = pcb; - } - LWIP_ASSERT("tcp_input: pcb->next != pcb (after cache)", pcb->next != pcb); - break; - } - prev = pcb; - } - - if (pcb == NULL) { - /* If it did not go to an active connection, we check the connections - in the TIME-WAIT state. */ - for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { - LWIP_ASSERT("tcp_input: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); - if (pcb->remote_port == tcphdr->src && - pcb->local_port == tcphdr->dest && - IP_PCB_IPVER_INPUT_MATCH(pcb) && - ipX_addr_cmp(ip_current_is_v6(), &pcb->remote_ip, ipX_current_src_addr()) && - ipX_addr_cmp(ip_current_is_v6(),&pcb->local_ip, ipX_current_dest_addr())) { - /* We don't really care enough to move this PCB to the front - of the list since we are not very likely to receive that - many segments for connections in TIME-WAIT. */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for TIME_WAITing connection.\n")); - tcp_timewait_input(pcb); - pbuf_free(p); - return; - } - } - - /* Finally, if we still did not get a match, we check all PCBs that - are LISTENing for incoming connections. */ - prev = NULL; - struct tcp_pcb_listen *netif_pcb = NULL; - struct tcp_pcb *netif_pcb_prev = NULL; - for(lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { - if (lpcb->bound_to_netif) { - if (IP_PCB_IPVER_INPUT_MATCH(lpcb) && netif_is_named(inp, lpcb->local_netif)) { - netif_pcb = lpcb; - netif_pcb_prev = prev; - } - } - else if (lpcb->local_port == tcphdr->dest) { -#if LWIP_IPV6 - if (lpcb->accept_any_ip_version) { - /* found an ANY-match */ -#if SO_REUSE - lpcb_any = lpcb; - lpcb_prev = prev; -#else /* SO_REUSE */ - break; -#endif /* SO_REUSE */ - } else -#endif /* LWIP_IPV6 */ - if (IP_PCB_IPVER_INPUT_MATCH(lpcb)) { - if (ipX_addr_cmp(ip_current_is_v6(), &lpcb->local_ip, ipX_current_dest_addr())) { - /* found an exact match */ - break; - } else if (ipX_addr_isany(ip_current_is_v6(), &lpcb->local_ip)) { - /* found an ANY-match */ -#if SO_REUSE - lpcb_any = lpcb; - lpcb_prev = prev; -#else /* SO_REUSE */ - break; - #endif /* SO_REUSE */ - } - } - } - prev = (struct tcp_pcb *)lpcb; - } -#if SO_REUSE - /* first try specific local IP */ - if (lpcb == NULL) { - /* only pass to ANY if no specific local IP has been found */ - lpcb = lpcb_any; - prev = lpcb_prev; - } -#endif /* SO_REUSE */ - if (lpcb == NULL && netif_pcb) { - lpcb = netif_pcb; - prev = netif_pcb_prev; - } - if (lpcb != NULL) { - /* Move this PCB to the front of the list so that subsequent - lookups will be faster (we exploit locality in TCP segment - arrivals). */ - if (prev != NULL) { - ((struct tcp_pcb_listen *)prev)->next = lpcb->next; - /* our successor is the remainder of the listening list */ - lpcb->next = tcp_listen_pcbs.listen_pcbs; - /* put this listening pcb at the head of the listening list */ - tcp_listen_pcbs.listen_pcbs = lpcb; - } - - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n")); - tcp_listen_input(lpcb); - pbuf_free(p); - return; - } - } - -#if TCP_INPUT_DEBUG - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags ")); - tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n")); -#endif /* TCP_INPUT_DEBUG */ - - - if (pcb != NULL) { - /* The incoming segment belongs to a connection. */ -#if TCP_INPUT_DEBUG -#if TCP_DEBUG - tcp_debug_print_state(pcb->state); -#endif /* TCP_DEBUG */ -#endif /* TCP_INPUT_DEBUG */ - - /* Set up a tcp_seg structure. */ - inseg.next = NULL; - inseg.len = p->tot_len; - inseg.p = p; - inseg.tcphdr = tcphdr; - - recv_data = NULL; - recv_flags = 0; - - if (flags & TCP_PSH) { - p->flags |= PBUF_FLAG_PUSH; - } - - /* If there is data which was previously "refused" by upper layer */ - if (pcb->refused_data != NULL) { - if ((tcp_process_refused_data(pcb) == ERR_ABRT) || - ((pcb->refused_data != NULL) && (tcplen > 0))) { - /* pcb has been aborted or refused data is still refused and the new - segment contains data */ - TCP_STATS_INC(tcp.drop); - snmp_inc_tcpinerrs(); - goto aborted; - } - } - tcp_input_pcb = pcb; - err = tcp_process(pcb); - /* A return value of ERR_ABRT means that tcp_abort() was called - and that the pcb has been freed. If so, we don't do anything. */ - if (err != ERR_ABRT) { - if (recv_flags & TF_RESET) { - /* TF_RESET means that the connection was reset by the other - end. We then call the error callback to inform the - application that the connection is dead before we - deallocate the PCB. */ - TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_RST); - tcp_pcb_remove(&tcp_active_pcbs, pcb); - memp_free(MEMP_TCP_PCB, pcb); - } else if (recv_flags & TF_CLOSED) { - /* The connection has been closed and we will deallocate the - PCB. */ - if (!(pcb->flags & TF_RXCLOSED)) { - /* Connection closed although the application has only shut down the - tx side: call the PCB's err callback and indicate the closure to - ensure the application doesn't continue using the PCB. */ - TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_CLSD); - } - tcp_pcb_remove(&tcp_active_pcbs, pcb); - memp_free(MEMP_TCP_PCB, pcb); - } else { - err = ERR_OK; - /* If the application has registered a "sent" function to be - called when new send buffer space is available, we call it - now. */ - if (pcb->acked > 0) { - TCP_EVENT_SENT(pcb, pcb->acked, err); - if (err == ERR_ABRT) { - goto aborted; - } - } - - if (recv_data != NULL) { - LWIP_ASSERT("pcb->refused_data == NULL", pcb->refused_data == NULL); - if (pcb->flags & TF_RXCLOSED) { - /* received data although already closed -> abort (send RST) to - notify the remote host that not all data has been processed */ - pbuf_free(recv_data); - tcp_abort(pcb); - goto aborted; - } - - /* Notify application that data has been received. */ - TCP_EVENT_RECV(pcb, recv_data, ERR_OK, err); - if (err == ERR_ABRT) { - goto aborted; - } - - /* If the upper layer can't receive this data, store it */ - if (err != ERR_OK) { - pcb->refused_data = recv_data; - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: keep incoming packet, because pcb is \"full\"\n")); - } - } - - /* If a FIN segment was received, we call the callback - function with a NULL buffer to indicate EOF. */ - if (recv_flags & TF_GOT_FIN) { - if (pcb->refused_data != NULL) { - /* Delay this if we have refused data. */ - pcb->refused_data->flags |= PBUF_FLAG_TCP_FIN; - } else { - /* correct rcv_wnd as the application won't call tcp_recved() - for the FIN's seqno */ - if (pcb->rcv_wnd != TCP_WND) { - pcb->rcv_wnd++; - } - TCP_EVENT_CLOSED(pcb, err); - if (err == ERR_ABRT) { - goto aborted; - } - } - } - - tcp_input_pcb = NULL; - /* Try to send something out. */ - tcp_output(pcb); -#if TCP_INPUT_DEBUG -#if TCP_DEBUG - tcp_debug_print_state(pcb->state); -#endif /* TCP_DEBUG */ -#endif /* TCP_INPUT_DEBUG */ - } - } - /* Jump target if pcb has been aborted in a callback (by calling tcp_abort()). - Below this line, 'pcb' may not be dereferenced! */ -aborted: - tcp_input_pcb = NULL; - recv_data = NULL; - - /* give up our reference to inseg.p */ - if (inseg.p != NULL) - { - pbuf_free(inseg.p); - inseg.p = NULL; - } - } else { - - /* If no matching PCB was found, send a TCP RST (reset) to the - sender. */ - LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n")); - if (!(TCPH_FLAGS(tcphdr) & TCP_RST)) { - TCP_STATS_INC(tcp.proterr); - TCP_STATS_INC(tcp.drop); - tcp_rst(ackno, seqno + tcplen, ipX_current_dest_addr(), - ipX_current_src_addr(), tcphdr->dest, tcphdr->src, ip_current_is_v6()); - } - pbuf_free(p); - } - - LWIP_ASSERT("tcp_input: tcp_pcbs_sane()", tcp_pcbs_sane()); - PERF_STOP("tcp_input"); - return; -dropped: - TCP_STATS_INC(tcp.drop); - snmp_inc_tcpinerrs(); - pbuf_free(p); -} - -/** - * Called by tcp_input() when a segment arrives for a listening - * connection (from tcp_input()). - * - * @param pcb the tcp_pcb_listen for which a segment arrived - * @return ERR_OK if the segment was processed - * another err_t on error - * - * @note the return value is not (yet?) used in tcp_input() - * @note the segment which arrived is saved in global variables, therefore only the pcb - * involved is passed as a parameter to this function - */ -static err_t -tcp_listen_input(struct tcp_pcb_listen *pcb) -{ - struct tcp_pcb *npcb; - err_t rc; - - if (flags & TCP_RST) { - /* An incoming RST should be ignored. Return. */ - return ERR_OK; - } - - /* In the LISTEN state, we check for incoming SYN segments, - creates a new PCB, and responds with a SYN|ACK. */ - if (flags & TCP_ACK) { - /* For incoming segments with the ACK flag set, respond with a - RST. */ - LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n")); - tcp_rst(ackno, seqno + tcplen, ipX_current_dest_addr(), - ipX_current_src_addr(), tcphdr->dest, tcphdr->src, ip_current_is_v6()); - } else if (flags & TCP_SYN) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %"U16_F" -> %"U16_F".\n", tcphdr->src, tcphdr->dest)); -#if TCP_LISTEN_BACKLOG - if (pcb->accepts_pending >= pcb->backlog) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: listen backlog exceeded for port %"U16_F"\n", tcphdr->dest)); - return ERR_ABRT; - } -#endif /* TCP_LISTEN_BACKLOG */ - npcb = tcp_alloc(pcb->prio); - /* If a new PCB could not be created (probably due to lack of memory), - we don't do anything, but rely on the sender will retransmit the - SYN at a time when we have more memory available. */ - if (npcb == NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n")); - TCP_STATS_INC(tcp.memerr); - return ERR_MEM; - } -#if TCP_LISTEN_BACKLOG - pcb->accepts_pending++; -#endif /* TCP_LISTEN_BACKLOG */ - /* Set up the new PCB. */ -#if LWIP_IPV6 - PCB_ISIPV6(npcb) = ip_current_is_v6(); -#endif /* LWIP_IPV6 */ - ipX_addr_copy(ip_current_is_v6(), npcb->local_ip, *ipX_current_dest_addr()); - ipX_addr_copy(ip_current_is_v6(), npcb->remote_ip, *ipX_current_src_addr()); - npcb->bound_to_netif = pcb->bound_to_netif; - npcb->local_port = tcphdr->dest; - memcpy(npcb->local_netif, pcb->local_netif, sizeof(pcb->local_netif)); - npcb->remote_port = tcphdr->src; - npcb->state = SYN_RCVD; - npcb->rcv_nxt = seqno + 1; - npcb->rcv_ann_right_edge = npcb->rcv_nxt; - npcb->snd_wnd = tcphdr->wnd; - npcb->snd_wnd_max = tcphdr->wnd; - npcb->ssthresh = npcb->snd_wnd; - npcb->snd_wl1 = seqno - 1;/* initialise to seqno-1 to force window update */ - npcb->callback_arg = pcb->callback_arg; -#if LWIP_CALLBACK_API - npcb->accept = pcb->accept; -#endif /* LWIP_CALLBACK_API */ - /* inherit socket options */ - npcb->so_options = pcb->so_options & SOF_INHERITED; - /* Register the new PCB so that we can begin receiving segments - for it. */ - TCP_REG_ACTIVE(npcb); - - /* Parse any options in the SYN. */ - tcp_parseopt(npcb); -#if TCP_CALCULATE_EFF_SEND_MSS - npcb->mss = tcp_eff_send_mss(npcb->mss, &npcb->local_ip, - &npcb->remote_ip, PCB_ISIPV6(npcb)); -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - - snmp_inc_tcppassiveopens(); - - /* Send a SYN|ACK together with the MSS option. */ - rc = tcp_enqueue_flags(npcb, TCP_SYN | TCP_ACK); - if (rc != ERR_OK) { - tcp_abandon(npcb, 0); - return rc; - } - return tcp_output(npcb); - } - return ERR_OK; -} - -/** - * Called by tcp_input() when a segment arrives for a connection in - * TIME_WAIT. - * - * @param pcb the tcp_pcb for which a segment arrived - * - * @note the segment which arrived is saved in global variables, therefore only the pcb - * involved is passed as a parameter to this function - */ -static err_t -tcp_timewait_input(struct tcp_pcb *pcb) -{ - /* RFC 1337: in TIME_WAIT, ignore RST and ACK FINs + any 'acceptable' segments */ - /* RFC 793 3.9 Event Processing - Segment Arrives: - * - first check sequence number - we skip that one in TIME_WAIT (always - * acceptable since we only send ACKs) - * - second check the RST bit (... return) */ - if (flags & TCP_RST) { - return ERR_OK; - } - /* - fourth, check the SYN bit, */ - if (flags & TCP_SYN) { - /* If an incoming segment is not acceptable, an acknowledgment - should be sent in reply */ - if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt+pcb->rcv_wnd)) { - /* If the SYN is in the window it is an error, send a reset */ - tcp_rst(ackno, seqno + tcplen, ipX_current_dest_addr(), - ipX_current_src_addr(), tcphdr->dest, tcphdr->src, ip_current_is_v6()); - return ERR_OK; - } - } else if (flags & TCP_FIN) { - /* - eighth, check the FIN bit: Remain in the TIME-WAIT state. - Restart the 2 MSL time-wait timeout.*/ - pcb->tmr = tcp_ticks; - } - - if ((tcplen > 0)) { - /* Acknowledge data, FIN or out-of-window SYN */ - pcb->flags |= TF_ACK_NOW; - return tcp_output(pcb); - } - return ERR_OK; -} - -/** - * Implements the TCP state machine. Called by tcp_input. In some - * states tcp_receive() is called to receive data. The tcp_seg - * argument will be freed by the caller (tcp_input()) unless the - * recv_data pointer in the pcb is set. - * - * @param pcb the tcp_pcb for which a segment arrived - * - * @note the segment which arrived is saved in global variables, therefore only the pcb - * involved is passed as a parameter to this function - */ -static err_t -tcp_process(struct tcp_pcb *pcb) -{ - struct tcp_seg *rseg; - u8_t acceptable = 0; - err_t err; - - err = ERR_OK; - - /* Process incoming RST segments. */ - if (flags & TCP_RST) { - /* First, determine if the reset is acceptable. */ - if (pcb->state == SYN_SENT) { - if (ackno == pcb->snd_nxt) { - acceptable = 1; - } - } else { - if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, - pcb->rcv_nxt+pcb->rcv_wnd)) { - acceptable = 1; - } - } - - if (acceptable) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: Connection RESET\n")); - LWIP_ASSERT("tcp_input: pcb->state != CLOSED", pcb->state != CLOSED); - recv_flags |= TF_RESET; - pcb->flags &= ~TF_ACK_DELAY; - return ERR_RST; - } else { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: unacceptable reset seqno %"U32_F" rcv_nxt %"U32_F"\n", - seqno, pcb->rcv_nxt)); - LWIP_DEBUGF(TCP_DEBUG, ("tcp_process: unacceptable reset seqno %"U32_F" rcv_nxt %"U32_F"\n", - seqno, pcb->rcv_nxt)); - return ERR_OK; - } - } - - if ((flags & TCP_SYN) && (pcb->state != SYN_SENT && pcb->state != SYN_RCVD)) { - /* Cope with new connection attempt after remote end crashed */ - tcp_ack_now(pcb); - return ERR_OK; - } - - if ((pcb->flags & TF_RXCLOSED) == 0) { - /* Update the PCB (in)activity timer unless rx is closed (see tcp_shutdown) */ - pcb->tmr = tcp_ticks; - } - pcb->keep_cnt_sent = 0; - - tcp_parseopt(pcb); - - /* Do different things depending on the TCP state. */ - switch (pcb->state) { - case SYN_SENT: - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %"U32_F" pcb->snd_nxt %"U32_F" unacked %"U32_F"\n", ackno, - pcb->snd_nxt, ntohl(pcb->unacked->tcphdr->seqno))); - /* received SYN ACK with expected sequence number? */ - if ((flags & TCP_ACK) && (flags & TCP_SYN) - && ackno == ntohl(pcb->unacked->tcphdr->seqno) + 1) { - pcb->snd_buf++; - pcb->rcv_nxt = seqno + 1; - pcb->rcv_ann_right_edge = pcb->rcv_nxt; - pcb->lastack = ackno; - pcb->snd_wnd = tcphdr->wnd; - pcb->snd_wnd_max = tcphdr->wnd; - pcb->snd_wl1 = seqno - 1; /* initialise to seqno - 1 to force window update */ - pcb->state = ESTABLISHED; - -#if TCP_CALCULATE_EFF_SEND_MSS - pcb->mss = tcp_eff_send_mss(pcb->mss, &pcb->local_ip, &pcb->remote_ip, - PCB_ISIPV6(pcb)); -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - - /* Set ssthresh again after changing pcb->mss (already set in tcp_connect - * but for the default value of pcb->mss) */ - pcb->ssthresh = pcb->mss * 10; - - pcb->cwnd = ((pcb->cwnd == 1) ? (pcb->mss * 2) : pcb->mss); - LWIP_ASSERT("pcb->snd_queuelen > 0", (pcb->snd_queuelen > 0)); - --pcb->snd_queuelen; - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_process: SYN-SENT --queuelen %"U16_F"\n", (u16_t)pcb->snd_queuelen)); - rseg = pcb->unacked; - pcb->unacked = rseg->next; - tcp_seg_free(rseg); - - /* If there's nothing left to acknowledge, stop the retransmit - timer, otherwise reset it to start again */ - if(pcb->unacked == NULL) - pcb->rtime = -1; - else { - pcb->rtime = 0; - pcb->nrtx = 0; - } - - /* Call the user specified function to call when sucessfully - * connected. */ - TCP_EVENT_CONNECTED(pcb, ERR_OK, err); - if (err == ERR_ABRT) { - return ERR_ABRT; - } - tcp_ack_now(pcb); - } - /* received ACK? possibly a half-open connection */ - else if (flags & TCP_ACK) { - /* send a RST to bring the other side in a non-synchronized state. */ - tcp_rst(ackno, seqno + tcplen, ipX_current_dest_addr(), - ipX_current_src_addr(), tcphdr->dest, tcphdr->src, ip_current_is_v6()); - } - break; - case SYN_RCVD: - if (flags & TCP_ACK) { - /* expected ACK number? */ - if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)) { - u16_t old_cwnd; - pcb->state = ESTABLISHED; - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection established %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); -#if LWIP_CALLBACK_API - LWIP_ASSERT("pcb->accept != NULL", pcb->accept != NULL); -#endif - /* Call the accept function. */ - TCP_EVENT_ACCEPT(pcb, ERR_OK, err); - if (err != ERR_OK) { - /* If the accept function returns with an error, we abort - * the connection. */ - /* Already aborted? */ - if (err != ERR_ABRT) { - tcp_abort(pcb); - } - return ERR_ABRT; - } - old_cwnd = pcb->cwnd; - /* If there was any data contained within this ACK, - * we'd better pass it on to the application as well. */ - tcp_receive(pcb); - - /* Prevent ACK for SYN to generate a sent event */ - if (pcb->acked != 0) { - pcb->acked--; - } - - pcb->cwnd = ((old_cwnd == 1) ? (pcb->mss * 2) : pcb->mss); - - if (recv_flags & TF_GOT_FIN) { - tcp_ack_now(pcb); - pcb->state = CLOSE_WAIT; - } - } else { - /* incorrect ACK number, send RST */ - tcp_rst(ackno, seqno + tcplen, ipX_current_dest_addr(), - ipX_current_src_addr(), tcphdr->dest, tcphdr->src, ip_current_is_v6()); - } - } else if ((flags & TCP_SYN) && (seqno == pcb->rcv_nxt - 1)) { - /* Looks like another copy of the SYN - retransmit our SYN-ACK */ - tcp_rexmit(pcb); - } - break; - case CLOSE_WAIT: - /* FALLTHROUGH */ - case ESTABLISHED: - tcp_receive(pcb); - if (recv_flags & TF_GOT_FIN) { /* passive close */ - tcp_ack_now(pcb); - pcb->state = CLOSE_WAIT; - } - break; - case FIN_WAIT_1: - tcp_receive(pcb); - if (recv_flags & TF_GOT_FIN) { - if ((flags & TCP_ACK) && (ackno == pcb->snd_nxt)) { - LWIP_DEBUGF(TCP_DEBUG, - ("TCP connection closed: FIN_WAIT_1 %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); - tcp_ack_now(pcb); - tcp_pcb_purge(pcb); - TCP_RMV_ACTIVE(pcb); - pcb->state = TIME_WAIT; - TCP_REG(&tcp_tw_pcbs, pcb); - } else { - tcp_ack_now(pcb); - pcb->state = CLOSING; - } - } else if ((flags & TCP_ACK) && (ackno == pcb->snd_nxt)) { - pcb->state = FIN_WAIT_2; - } - break; - case FIN_WAIT_2: - tcp_receive(pcb); - if (recv_flags & TF_GOT_FIN) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: FIN_WAIT_2 %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); - tcp_ack_now(pcb); - tcp_pcb_purge(pcb); - TCP_RMV_ACTIVE(pcb); - pcb->state = TIME_WAIT; - TCP_REG(&tcp_tw_pcbs, pcb); - } - break; - case CLOSING: - tcp_receive(pcb); - if (flags & TCP_ACK && ackno == pcb->snd_nxt) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: CLOSING %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); - tcp_pcb_purge(pcb); - TCP_RMV_ACTIVE(pcb); - pcb->state = TIME_WAIT; - TCP_REG(&tcp_tw_pcbs, pcb); - } - break; - case LAST_ACK: - tcp_receive(pcb); - if (flags & TCP_ACK && ackno == pcb->snd_nxt) { - LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: LAST_ACK %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest)); - /* bugfix #21699: don't set pcb->state to CLOSED here or we risk leaking segments */ - recv_flags |= TF_CLOSED; - } - break; - default: - break; - } - return ERR_OK; -} - -#if TCP_QUEUE_OOSEQ -/** - * Insert segment into the list (segments covered with new one will be deleted) - * - * Called from tcp_receive() - */ -static void -tcp_oos_insert_segment(struct tcp_seg *cseg, struct tcp_seg *next) -{ - struct tcp_seg *old_seg; - - if (TCPH_FLAGS(cseg->tcphdr) & TCP_FIN) { - /* received segment overlaps all following segments */ - tcp_segs_free(next); - next = NULL; - } - else { - /* delete some following segments - oos queue may have segments with FIN flag */ - while (next && - TCP_SEQ_GEQ((seqno + cseg->len), - (next->tcphdr->seqno + next->len))) { - /* cseg with FIN already processed */ - if (TCPH_FLAGS(next->tcphdr) & TCP_FIN) { - TCPH_SET_FLAG(cseg->tcphdr, TCP_FIN); - } - old_seg = next; - next = next->next; - tcp_seg_free(old_seg); - } - if (next && - TCP_SEQ_GT(seqno + cseg->len, next->tcphdr->seqno)) { - /* We need to trim the incoming segment. */ - cseg->len = (u16_t)(next->tcphdr->seqno - seqno); - pbuf_realloc(cseg->p, cseg->len); - } - } - cseg->next = next; -} -#endif /* TCP_QUEUE_OOSEQ */ - -/** - * Called by tcp_process. Checks if the given segment is an ACK for outstanding - * data, and if so frees the memory of the buffered data. Next, is places the - * segment on any of the receive queues (pcb->recved or pcb->ooseq). If the segment - * is buffered, the pbuf is referenced by pbuf_ref so that it will not be freed until - * it has been removed from the buffer. - * - * If the incoming segment constitutes an ACK for a segment that was used for RTT - * estimation, the RTT is estimated here as well. - * - * Called from tcp_process(). - */ -static void -tcp_receive(struct tcp_pcb *pcb) -{ - struct tcp_seg *next; -#if TCP_QUEUE_OOSEQ - struct tcp_seg *prev, *cseg; -#endif /* TCP_QUEUE_OOSEQ */ - struct pbuf *p; - s32_t off; - s16_t m; - u32_t right_wnd_edge; - u16_t new_tot_len; - int found_dupack = 0; -#if TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS - u32_t ooseq_blen; - u16_t ooseq_qlen; -#endif /* TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS */ - - LWIP_ASSERT("tcp_receive: wrong state", pcb->state >= ESTABLISHED); - - if (flags & TCP_ACK) { - right_wnd_edge = pcb->snd_wnd + pcb->snd_wl2; - - /* Update window. */ - if (TCP_SEQ_LT(pcb->snd_wl1, seqno) || - (pcb->snd_wl1 == seqno && TCP_SEQ_LT(pcb->snd_wl2, ackno)) || - (pcb->snd_wl2 == ackno && tcphdr->wnd > pcb->snd_wnd)) { - pcb->snd_wnd = tcphdr->wnd; - /* keep track of the biggest window announced by the remote host to calculate - the maximum segment size */ - if (pcb->snd_wnd_max < tcphdr->wnd) { - pcb->snd_wnd_max = tcphdr->wnd; - } - pcb->snd_wl1 = seqno; - pcb->snd_wl2 = ackno; - if (pcb->snd_wnd == 0) { - if (pcb->persist_backoff == 0) { - /* start persist timer */ - pcb->persist_cnt = 0; - pcb->persist_backoff = 1; - } - } else if (pcb->persist_backoff > 0) { - /* stop persist timer */ - pcb->persist_backoff = 0; - } - LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: window update %"U16_F"\n", pcb->snd_wnd)); -#if TCP_WND_DEBUG - } else { - if (pcb->snd_wnd != tcphdr->wnd) { - LWIP_DEBUGF(TCP_WND_DEBUG, - ("tcp_receive: no window update lastack %"U32_F" ackno %" - U32_F" wl1 %"U32_F" seqno %"U32_F" wl2 %"U32_F"\n", - pcb->lastack, ackno, pcb->snd_wl1, seqno, pcb->snd_wl2)); - } -#endif /* TCP_WND_DEBUG */ - } - - /* (From Stevens TCP/IP Illustrated Vol II, p970.) Its only a - * duplicate ack if: - * 1) It doesn't ACK new data - * 2) length of received packet is zero (i.e. no payload) - * 3) the advertised window hasn't changed - * 4) There is outstanding unacknowledged data (retransmission timer running) - * 5) The ACK is == biggest ACK sequence number so far seen (snd_una) - * - * If it passes all five, should process as a dupack: - * a) dupacks < 3: do nothing - * b) dupacks == 3: fast retransmit - * c) dupacks > 3: increase cwnd - * - * If it only passes 1-3, should reset dupack counter (and add to - * stats, which we don't do in lwIP) - * - * If it only passes 1, should reset dupack counter - * - */ - - /* Clause 1 */ - if (TCP_SEQ_LEQ(ackno, pcb->lastack)) { - pcb->acked = 0; - /* Clause 2 */ - if (tcplen == 0) { - /* Clause 3 */ - if (pcb->snd_wl2 + pcb->snd_wnd == right_wnd_edge){ - /* Clause 4 */ - if (pcb->rtime >= 0) { - /* Clause 5 */ - if (pcb->lastack == ackno) { - found_dupack = 1; - if ((u8_t)(pcb->dupacks + 1) > pcb->dupacks) { - ++pcb->dupacks; - } - if (pcb->dupacks > 3) { - /* Inflate the congestion window, but not if it means that - the value overflows. */ - if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) { - pcb->cwnd += pcb->mss; - } - } else if (pcb->dupacks == 3) { - /* Do fast retransmit */ - tcp_rexmit_fast(pcb); - } - } - } - } - } - /* If Clause (1) or more is true, but not a duplicate ack, reset - * count of consecutive duplicate acks */ - if (!found_dupack) { - pcb->dupacks = 0; - } - } else if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)){ - /* We come here when the ACK acknowledges new data. */ - - /* Reset the "IN Fast Retransmit" flag, since we are no longer - in fast retransmit. Also reset the congestion window to the - slow start threshold. */ - if (pcb->flags & TF_INFR) { - pcb->flags &= ~TF_INFR; - pcb->cwnd = pcb->ssthresh; - } - - /* Reset the number of retransmissions. */ - pcb->nrtx = 0; - - /* Reset the retransmission time-out. */ - pcb->rto = (pcb->sa >> 3) + pcb->sv; - - /* Update the send buffer space. Diff between the two can never exceed 64K? */ - pcb->acked = (u16_t)(ackno - pcb->lastack); - - pcb->snd_buf += pcb->acked; - - /* Reset the fast retransmit variables. */ - pcb->dupacks = 0; - pcb->lastack = ackno; - - /* Update the congestion control variables (cwnd and - ssthresh). */ - if (pcb->state >= ESTABLISHED) { - if (pcb->cwnd < pcb->ssthresh) { - if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) { - pcb->cwnd += pcb->mss; - } - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: slow start cwnd %"U16_F"\n", pcb->cwnd)); - } else { - u16_t new_cwnd = (pcb->cwnd + pcb->mss * pcb->mss / pcb->cwnd); - if (new_cwnd > pcb->cwnd) { - pcb->cwnd = new_cwnd; - } - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %"U16_F"\n", pcb->cwnd)); - } - } - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: ACK for %"U32_F", unacked->seqno %"U32_F":%"U32_F"\n", - ackno, - pcb->unacked != NULL? - ntohl(pcb->unacked->tcphdr->seqno): 0, - pcb->unacked != NULL? - ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked): 0)); - - /* Remove segment from the unacknowledged list if the incoming - ACK acknowlegdes them. */ - while (pcb->unacked != NULL && - TCP_SEQ_LEQ(ntohl(pcb->unacked->tcphdr->seqno) + - TCP_TCPLEN(pcb->unacked), ackno)) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unacked\n", - ntohl(pcb->unacked->tcphdr->seqno), - ntohl(pcb->unacked->tcphdr->seqno) + - TCP_TCPLEN(pcb->unacked))); - - next = pcb->unacked; - pcb->unacked = pcb->unacked->next; - - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen)); - LWIP_ASSERT("pcb->snd_queuelen >= pbuf_clen(next->p)", (pcb->snd_queuelen >= pbuf_clen(next->p))); - /* Prevent ACK for FIN to generate a sent event */ - if ((pcb->acked != 0) && ((TCPH_FLAGS(next->tcphdr) & TCP_FIN) != 0)) { - pcb->acked--; - } - - pcb->snd_queuelen -= pbuf_clen(next->p); - tcp_seg_free(next); - - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%"U16_F" (after freeing unacked)\n", (u16_t)pcb->snd_queuelen)); - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL || - pcb->unsent != NULL); - } - } - - /* If there's nothing left to acknowledge, stop the retransmit - timer, otherwise reset it to start again */ - if(pcb->unacked == NULL) - pcb->rtime = -1; - else - pcb->rtime = 0; - - pcb->polltmr = 0; - -#if LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS - if (PCB_ISIPV6(pcb)) { - /* Inform neighbor reachability of forward progress. */ - nd6_reachability_hint(ip6_current_src_addr()); - } -#endif /* LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS*/ - } else { - /* Fix bug bug #21582: out of sequence ACK, didn't really ack anything */ - pcb->acked = 0; - } - - /* We go through the ->unsent list to see if any of the segments - on the list are acknowledged by the ACK. This may seem - strange since an "unsent" segment shouldn't be acked. The - rationale is that lwIP puts all outstanding segments on the - ->unsent list after a retransmission, so these segments may - in fact have been sent once. */ - while (pcb->unsent != NULL && - TCP_SEQ_BETWEEN(ackno, ntohl(pcb->unsent->tcphdr->seqno) + - TCP_TCPLEN(pcb->unsent), pcb->snd_nxt)) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unsent\n", - ntohl(pcb->unsent->tcphdr->seqno), ntohl(pcb->unsent->tcphdr->seqno) + - TCP_TCPLEN(pcb->unsent))); - - next = pcb->unsent; - pcb->unsent = pcb->unsent->next; -#if TCP_OVERSIZE - if (pcb->unsent == NULL) { - pcb->unsent_oversize = 0; - } -#endif /* TCP_OVERSIZE */ - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen)); - LWIP_ASSERT("pcb->snd_queuelen >= pbuf_clen(next->p)", (pcb->snd_queuelen >= pbuf_clen(next->p))); - /* Prevent ACK for FIN to generate a sent event */ - if ((pcb->acked != 0) && ((TCPH_FLAGS(next->tcphdr) & TCP_FIN) != 0)) { - pcb->acked--; - } - pcb->snd_queuelen -= pbuf_clen(next->p); - tcp_seg_free(next); - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%"U16_F" (after freeing unsent)\n", (u16_t)pcb->snd_queuelen)); - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_receive: valid queue length", - pcb->unacked != NULL || pcb->unsent != NULL); - } - } - /* End of ACK for new data processing. */ - - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: pcb->rttest %"U32_F" rtseq %"U32_F" ackno %"U32_F"\n", - pcb->rttest, pcb->rtseq, ackno)); - - /* RTT estimation calculations. This is done by checking if the - incoming segment acknowledges the segment we use to take a - round-trip time measurement. */ - if (pcb->rttest && TCP_SEQ_LT(pcb->rtseq, ackno)) { - /* diff between this shouldn't exceed 32K since this are tcp timer ticks - and a round-trip shouldn't be that long... */ - m = (s16_t)(tcp_ticks - pcb->rttest); - - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: experienced rtt %"U16_F" ticks (%"U16_F" msec).\n", - m, m * TCP_SLOW_INTERVAL)); - - /* This is taken directly from VJs original code in his paper */ - m = m - (pcb->sa >> 3); - pcb->sa += m; - if (m < 0) { - m = -m; - } - m = m - (pcb->sv >> 2); - pcb->sv += m; - pcb->rto = (pcb->sa >> 3) + pcb->sv; - - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: RTO %"U16_F" (%"U16_F" milliseconds)\n", - pcb->rto, pcb->rto * TCP_SLOW_INTERVAL)); - - pcb->rttest = 0; - } - } - - /* If the incoming segment contains data, we must process it - further unless the pcb already received a FIN. - (RFC 793, chapeter 3.9, "SEGMENT ARRIVES" in states CLOSE-WAIT, CLOSING, - LAST-ACK and TIME-WAIT: "Ignore the segment text.") */ - if ((tcplen > 0) && (pcb->state < CLOSE_WAIT)) { - /* This code basically does three things: - - +) If the incoming segment contains data that is the next - in-sequence data, this data is passed to the application. This - might involve trimming the first edge of the data. The rcv_nxt - variable and the advertised window are adjusted. - - +) If the incoming segment has data that is above the next - sequence number expected (->rcv_nxt), the segment is placed on - the ->ooseq queue. This is done by finding the appropriate - place in the ->ooseq queue (which is ordered by sequence - number) and trim the segment in both ends if needed. An - immediate ACK is sent to indicate that we received an - out-of-sequence segment. - - +) Finally, we check if the first segment on the ->ooseq queue - now is in sequence (i.e., if rcv_nxt >= ooseq->seqno). If - rcv_nxt > ooseq->seqno, we must trim the first edge of the - segment on ->ooseq before we adjust rcv_nxt. The data in the - segments that are now on sequence are chained onto the - incoming segment so that we only need to call the application - once. - */ - - /* First, we check if we must trim the first edge. We have to do - this if the sequence number of the incoming segment is less - than rcv_nxt, and the sequence number plus the length of the - segment is larger than rcv_nxt. */ - /* if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)){ - if (TCP_SEQ_LT(pcb->rcv_nxt, seqno + tcplen)) {*/ - if (TCP_SEQ_BETWEEN(pcb->rcv_nxt, seqno + 1, seqno + tcplen - 1)){ - /* Trimming the first edge is done by pushing the payload - pointer in the pbuf downwards. This is somewhat tricky since - we do not want to discard the full contents of the pbuf up to - the new starting point of the data since we have to keep the - TCP header which is present in the first pbuf in the chain. - - What is done is really quite a nasty hack: the first pbuf in - the pbuf chain is pointed to by inseg.p. Since we need to be - able to deallocate the whole pbuf, we cannot change this - inseg.p pointer to point to any of the later pbufs in the - chain. Instead, we point the ->payload pointer in the first - pbuf to data in one of the later pbufs. We also set the - inseg.data pointer to point to the right place. This way, the - ->p pointer will still point to the first pbuf, but the - ->p->payload pointer will point to data in another pbuf. - - After we are done with adjusting the pbuf pointers we must - adjust the ->data pointer in the seg and the segment - length.*/ - - off = pcb->rcv_nxt - seqno; - p = inseg.p; - LWIP_ASSERT("inseg.p != NULL", inseg.p); - LWIP_ASSERT("insane offset!", (off < 0x7fff)); - if (inseg.p->len < off) { - LWIP_ASSERT("pbuf too short!", (((s32_t)inseg.p->tot_len) >= off)); - new_tot_len = (u16_t)(inseg.p->tot_len - off); - while (p->len < off) { - off -= p->len; - /* KJM following line changed (with addition of new_tot_len var) - to fix bug #9076 - inseg.p->tot_len -= p->len; */ - p->tot_len = new_tot_len; - p->len = 0; - p = p->next; - } - if(pbuf_header(p, (s16_t)-off)) { - /* Do we need to cope with this failing? Assert for now */ - LWIP_ASSERT("pbuf_header failed", 0); - } - } else { - if(pbuf_header(inseg.p, (s16_t)-off)) { - /* Do we need to cope with this failing? Assert for now */ - LWIP_ASSERT("pbuf_header failed", 0); - } - } - inseg.len -= (u16_t)(pcb->rcv_nxt - seqno); - inseg.tcphdr->seqno = seqno = pcb->rcv_nxt; - } - else { - if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)){ - /* the whole segment is < rcv_nxt */ - /* must be a duplicate of a packet that has already been correctly handled */ - - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: duplicate seqno %"U32_F"\n", seqno)); - tcp_ack_now(pcb); - } - } - - /* The sequence number must be within the window (above rcv_nxt - and below rcv_nxt + rcv_wnd) in order to be further - processed. */ - if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, - pcb->rcv_nxt + pcb->rcv_wnd - 1)){ - if (pcb->rcv_nxt == seqno) { - /* The incoming segment is the next in sequence. We check if - we have to trim the end of the segment and update rcv_nxt - and pass the data to the application. */ - tcplen = TCP_TCPLEN(&inseg); - - if (tcplen > pcb->rcv_wnd) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, - ("tcp_receive: other end overran receive window" - "seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n", - seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd)); - if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { - /* Must remove the FIN from the header as we're trimming - * that byte of sequence-space from the packet */ - TCPH_FLAGS_SET(inseg.tcphdr, TCPH_FLAGS(inseg.tcphdr) &~ TCP_FIN); - } - /* Adjust length of segment to fit in the window. */ - inseg.len = pcb->rcv_wnd; - if (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) { - inseg.len -= 1; - } - pbuf_realloc(inseg.p, inseg.len); - tcplen = TCP_TCPLEN(&inseg); - LWIP_ASSERT("tcp_receive: segment not trimmed correctly to rcv_wnd\n", - (seqno + tcplen) == (pcb->rcv_nxt + pcb->rcv_wnd)); - } -#if TCP_QUEUE_OOSEQ - /* Received in-sequence data, adjust ooseq data if: - - FIN has been received or - - inseq overlaps with ooseq */ - if (pcb->ooseq != NULL) { - if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, - ("tcp_receive: received in-order FIN, binning ooseq queue\n")); - /* Received in-order FIN means anything that was received - * out of order must now have been received in-order, so - * bin the ooseq queue */ - while (pcb->ooseq != NULL) { - struct tcp_seg *old_ooseq = pcb->ooseq; - pcb->ooseq = pcb->ooseq->next; - tcp_seg_free(old_ooseq); - } - } else { - next = pcb->ooseq; - /* Remove all segments on ooseq that are covered by inseg already. - * FIN is copied from ooseq to inseg if present. */ - while (next && - TCP_SEQ_GEQ(seqno + tcplen, - next->tcphdr->seqno + next->len)) { - /* inseg cannot have FIN here (already processed above) */ - if (TCPH_FLAGS(next->tcphdr) & TCP_FIN && - (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) == 0) { - TCPH_SET_FLAG(inseg.tcphdr, TCP_FIN); - tcplen = TCP_TCPLEN(&inseg); - } - prev = next; - next = next->next; - tcp_seg_free(prev); - } - /* Now trim right side of inseg if it overlaps with the first - * segment on ooseq */ - if (next && - TCP_SEQ_GT(seqno + tcplen, - next->tcphdr->seqno)) { - /* inseg cannot have FIN here (already processed above) */ - inseg.len = (u16_t)(next->tcphdr->seqno - seqno); - if (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) { - inseg.len -= 1; - } - pbuf_realloc(inseg.p, inseg.len); - tcplen = TCP_TCPLEN(&inseg); - LWIP_ASSERT("tcp_receive: segment not trimmed correctly to ooseq queue\n", - (seqno + tcplen) == next->tcphdr->seqno); - } - pcb->ooseq = next; - } - } -#endif /* TCP_QUEUE_OOSEQ */ - - pcb->rcv_nxt = seqno + tcplen; - - /* Update the receiver's (our) window. */ - LWIP_ASSERT("tcp_receive: tcplen > rcv_wnd\n", pcb->rcv_wnd >= tcplen); - pcb->rcv_wnd -= tcplen; - - tcp_update_rcv_ann_wnd(pcb); - - /* If there is data in the segment, we make preparations to - pass this up to the application. The ->recv_data variable - is used for holding the pbuf that goes to the - application. The code for reassembling out-of-sequence data - chains its data on this pbuf as well. - - If the segment was a FIN, we set the TF_GOT_FIN flag that will - be used to indicate to the application that the remote side has - closed its end of the connection. */ - if (inseg.p->tot_len > 0) { - recv_data = inseg.p; - /* Since this pbuf now is the responsibility of the - application, we delete our reference to it so that we won't - (mistakingly) deallocate it. */ - inseg.p = NULL; - } - if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: received FIN.\n")); - recv_flags |= TF_GOT_FIN; - } - -#if TCP_QUEUE_OOSEQ - /* We now check if we have segments on the ->ooseq queue that - are now in sequence. */ - while (pcb->ooseq != NULL && - pcb->ooseq->tcphdr->seqno == pcb->rcv_nxt) { - - cseg = pcb->ooseq; - seqno = pcb->ooseq->tcphdr->seqno; - - pcb->rcv_nxt += TCP_TCPLEN(cseg); - LWIP_ASSERT("tcp_receive: ooseq tcplen > rcv_wnd\n", - pcb->rcv_wnd >= TCP_TCPLEN(cseg)); - pcb->rcv_wnd -= TCP_TCPLEN(cseg); - - tcp_update_rcv_ann_wnd(pcb); - - if (cseg->p->tot_len > 0) { - /* Chain this pbuf onto the pbuf that we will pass to - the application. */ - if (recv_data) { - pbuf_cat(recv_data, cseg->p); - } else { - recv_data = cseg->p; - } - cseg->p = NULL; - } - if (TCPH_FLAGS(cseg->tcphdr) & TCP_FIN) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: dequeued FIN.\n")); - recv_flags |= TF_GOT_FIN; - if (pcb->state == ESTABLISHED) { /* force passive close or we can move to active close */ - pcb->state = CLOSE_WAIT; - } - } - - pcb->ooseq = cseg->next; - tcp_seg_free(cseg); - } -#endif /* TCP_QUEUE_OOSEQ */ - - - /* Acknowledge the segment(s). */ - tcp_ack(pcb); - -#if LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS - if (PCB_ISIPV6(pcb)) { - /* Inform neighbor reachability of forward progress. */ - nd6_reachability_hint(ip6_current_src_addr()); - } -#endif /* LWIP_IPV6 && LWIP_ND6_TCP_REACHABILITY_HINTS*/ - - } else { - /* We get here if the incoming segment is out-of-sequence. */ - tcp_send_empty_ack(pcb); -#if TCP_QUEUE_OOSEQ - /* We queue the segment on the ->ooseq queue. */ - if (pcb->ooseq == NULL) { - pcb->ooseq = tcp_seg_copy(&inseg); - } else { - /* If the queue is not empty, we walk through the queue and - try to find a place where the sequence number of the - incoming segment is between the sequence numbers of the - previous and the next segment on the ->ooseq queue. That is - the place where we put the incoming segment. If needed, we - trim the second edges of the previous and the incoming - segment so that it will fit into the sequence. - - If the incoming segment has the same sequence number as a - segment on the ->ooseq queue, we discard the segment that - contains less data. */ - - prev = NULL; - for(next = pcb->ooseq; next != NULL; next = next->next) { - if (seqno == next->tcphdr->seqno) { - /* The sequence number of the incoming segment is the - same as the sequence number of the segment on - ->ooseq. We check the lengths to see which one to - discard. */ - if (inseg.len > next->len) { - /* The incoming segment is larger than the old - segment. We replace some segments with the new - one. */ - cseg = tcp_seg_copy(&inseg); - if (cseg != NULL) { - if (prev != NULL) { - prev->next = cseg; - } else { - pcb->ooseq = cseg; - } - tcp_oos_insert_segment(cseg, next); - } - break; - } else { - /* Either the lenghts are the same or the incoming - segment was smaller than the old one; in either - case, we ditch the incoming segment. */ - break; - } - } else { - if (prev == NULL) { - if (TCP_SEQ_LT(seqno, next->tcphdr->seqno)) { - /* The sequence number of the incoming segment is lower - than the sequence number of the first segment on the - queue. We put the incoming segment first on the - queue. */ - cseg = tcp_seg_copy(&inseg); - if (cseg != NULL) { - pcb->ooseq = cseg; - tcp_oos_insert_segment(cseg, next); - } - break; - } - } else { - /*if (TCP_SEQ_LT(prev->tcphdr->seqno, seqno) && - TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {*/ - if (TCP_SEQ_BETWEEN(seqno, prev->tcphdr->seqno+1, next->tcphdr->seqno-1)) { - /* The sequence number of the incoming segment is in - between the sequence numbers of the previous and - the next segment on ->ooseq. We trim trim the previous - segment, delete next segments that included in received segment - and trim received, if needed. */ - cseg = tcp_seg_copy(&inseg); - if (cseg != NULL) { - if (TCP_SEQ_GT(prev->tcphdr->seqno + prev->len, seqno)) { - /* We need to trim the prev segment. */ - prev->len = (u16_t)(seqno - prev->tcphdr->seqno); - pbuf_realloc(prev->p, prev->len); - } - prev->next = cseg; - tcp_oos_insert_segment(cseg, next); - } - break; - } - } - /* If the "next" segment is the last segment on the - ooseq queue, we add the incoming segment to the end - of the list. */ - if (next->next == NULL && - TCP_SEQ_GT(seqno, next->tcphdr->seqno)) { - if (TCPH_FLAGS(next->tcphdr) & TCP_FIN) { - /* segment "next" already contains all data */ - break; - } - next->next = tcp_seg_copy(&inseg); - if (next->next != NULL) { - if (TCP_SEQ_GT(next->tcphdr->seqno + next->len, seqno)) { - /* We need to trim the last segment. */ - next->len = (u16_t)(seqno - next->tcphdr->seqno); - pbuf_realloc(next->p, next->len); - } - /* check if the remote side overruns our receive window */ - if ((u32_t)tcplen + seqno > pcb->rcv_nxt + (u32_t)pcb->rcv_wnd) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, - ("tcp_receive: other end overran receive window" - "seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n", - seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd)); - if (TCPH_FLAGS(next->next->tcphdr) & TCP_FIN) { - /* Must remove the FIN from the header as we're trimming - * that byte of sequence-space from the packet */ - TCPH_FLAGS_SET(next->next->tcphdr, TCPH_FLAGS(next->next->tcphdr) &~ TCP_FIN); - } - /* Adjust length of segment to fit in the window. */ - next->next->len = pcb->rcv_nxt + pcb->rcv_wnd - seqno; - pbuf_realloc(next->next->p, next->next->len); - tcplen = TCP_TCPLEN(next->next); - LWIP_ASSERT("tcp_receive: segment not trimmed correctly to rcv_wnd\n", - (seqno + tcplen) == (pcb->rcv_nxt + pcb->rcv_wnd)); - } - } - break; - } - } - prev = next; - } - } -#if TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS - /* Check that the data on ooseq doesn't exceed one of the limits - and throw away everything above that limit. */ - ooseq_blen = 0; - ooseq_qlen = 0; - prev = NULL; - for(next = pcb->ooseq; next != NULL; prev = next, next = next->next) { - struct pbuf *p = next->p; - ooseq_blen += p->tot_len; - ooseq_qlen += pbuf_clen(p); - if ((ooseq_blen > TCP_OOSEQ_MAX_BYTES) || - (ooseq_qlen > TCP_OOSEQ_MAX_PBUFS)) { - /* too much ooseq data, dump this and everything after it */ - tcp_segs_free(next); - if (prev == NULL) { - /* first ooseq segment is too much, dump the whole queue */ - pcb->ooseq = NULL; - } else { - /* just dump 'next' and everything after it */ - prev->next = NULL; - } - break; - } - } -#endif /* TCP_OOSEQ_MAX_BYTES || TCP_OOSEQ_MAX_PBUFS */ -#endif /* TCP_QUEUE_OOSEQ */ - } - } else { - /* The incoming segment is not withing the window. */ - tcp_send_empty_ack(pcb); - } - } else { - /* Segments with length 0 is taken care of here. Segments that - fall out of the window are ACKed. */ - /*if (TCP_SEQ_GT(pcb->rcv_nxt, seqno) || - TCP_SEQ_GEQ(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) {*/ - if(!TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd-1)){ - tcp_ack_now(pcb); - } - } -} - -/** - * Parses the options contained in the incoming segment. - * - * Called from tcp_listen_input() and tcp_process(). - * Currently, only the MSS option is supported! - * - * @param pcb the tcp_pcb for which a segment arrived - */ -static void -tcp_parseopt(struct tcp_pcb *pcb) -{ - u16_t c, max_c; - u16_t mss; - u8_t *opts, opt; -#if LWIP_TCP_TIMESTAMPS - u32_t tsval; -#endif - - opts = (u8_t *)tcphdr + TCP_HLEN; - - /* Parse the TCP MSS option, if present. */ - if(TCPH_HDRLEN(tcphdr) > 0x5) { - max_c = (TCPH_HDRLEN(tcphdr) - 5) << 2; - for (c = 0; c < max_c; ) { - opt = opts[c]; - switch (opt) { - case 0x00: - /* End of options. */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: EOL\n")); - return; - case 0x01: - /* NOP option. */ - ++c; - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: NOP\n")); - break; - case 0x02: - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: MSS\n")); - if (opts[c + 1] != 0x04 || c + 0x04 > max_c) { - /* Bad length */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n")); - return; - } - /* An MSS option with the right option length. */ - mss = (opts[c + 2] << 8) | opts[c + 3]; - /* Limit the mss to the configured TCP_MSS and prevent division by zero */ - pcb->mss = ((mss > TCP_MSS) || (mss == 0)) ? TCP_MSS : mss; - /* Advance to next option */ - c += 0x04; - break; -#if LWIP_TCP_TIMESTAMPS - case 0x08: - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: TS\n")); - if (opts[c + 1] != 0x0A || c + 0x0A > max_c) { - /* Bad length */ - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n")); - return; - } - /* TCP timestamp option with valid length */ - tsval = (opts[c+2]) | (opts[c+3] << 8) | - (opts[c+4] << 16) | (opts[c+5] << 24); - if (flags & TCP_SYN) { - pcb->ts_recent = ntohl(tsval); - pcb->flags |= TF_TIMESTAMP; - } else if (TCP_SEQ_BETWEEN(pcb->ts_lastacksent, seqno, seqno+tcplen)) { - pcb->ts_recent = ntohl(tsval); - } - /* Advance to next option */ - c += 0x0A; - break; -#endif - default: - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: other\n")); - if (opts[c + 1] == 0) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_parseopt: bad length\n")); - /* If the length field is zero, the options are malformed - and we don't process them further. */ - return; - } - /* All other options have a length field, so that we easily - can skip past them. */ - c += opts[c + 1]; - } - } - } -} - -#endif /* LWIP_TCP */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/tcp_out.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/tcp_out.c deleted file mode 100644 index d6622178..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/tcp_out.c +++ /dev/null @@ -1,1499 +0,0 @@ -/** - * @file - * Transmission Control Protocol, outgoing traffic - * - * The output functions of TCP. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#include "lwip/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/tcp_impl.h" -#include "lwip/def.h" -#include "lwip/mem.h" -#include "lwip/memp.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/inet_chksum.h" -#include "lwip/stats.h" -#include "lwip/snmp.h" -#include "lwip/ip6.h" -#include "lwip/ip6_addr.h" -#include "lwip/inet_chksum.h" -#if LWIP_TCP_TIMESTAMPS -#include "lwip/sys.h" -#endif - -#include - -/* Define some copy-macros for checksum-on-copy so that the code looks - nicer by preventing too many ifdef's. */ -#if TCP_CHECKSUM_ON_COPY -#define TCP_DATA_COPY(dst, src, len, seg) do { \ - tcp_seg_add_chksum(LWIP_CHKSUM_COPY(dst, src, len), \ - len, &seg->chksum, &seg->chksum_swapped); \ - seg->flags |= TF_SEG_DATA_CHECKSUMMED; } while(0) -#define TCP_DATA_COPY2(dst, src, len, chksum, chksum_swapped) \ - tcp_seg_add_chksum(LWIP_CHKSUM_COPY(dst, src, len), len, chksum, chksum_swapped); -#else /* TCP_CHECKSUM_ON_COPY*/ -#define TCP_DATA_COPY(dst, src, len, seg) MEMCPY(dst, src, len) -#define TCP_DATA_COPY2(dst, src, len, chksum, chksum_swapped) MEMCPY(dst, src, len) -#endif /* TCP_CHECKSUM_ON_COPY*/ - -/** Define this to 1 for an extra check that the output checksum is valid - * (usefule when the checksum is generated by the application, not the stack) */ -#ifndef TCP_CHECKSUM_ON_COPY_SANITY_CHECK -#define TCP_CHECKSUM_ON_COPY_SANITY_CHECK 0 -#endif - -/* Forward declarations.*/ -static void tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb); - -/** Allocate a pbuf and create a tcphdr at p->payload, used for output - * functions other than the default tcp_output -> tcp_output_segment - * (e.g. tcp_send_empty_ack, etc.) - * - * @param pcb tcp pcb for which to send a packet (used to initialize tcp_hdr) - * @param optlen length of header-options - * @param datalen length of tcp data to reserve in pbuf - * @param seqno_be seqno in network byte order (big-endian) - * @return pbuf with p->payload being the tcp_hdr - */ -static struct pbuf * -tcp_output_alloc_header(struct tcp_pcb *pcb, u16_t optlen, u16_t datalen, - u32_t seqno_be /* already in network byte order */) -{ - struct tcp_hdr *tcphdr; - struct pbuf *p = pbuf_alloc(PBUF_IP, TCP_HLEN + optlen + datalen, PBUF_RAM); - if (p != NULL) { - LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr", - (p->len >= TCP_HLEN + optlen)); - tcphdr = (struct tcp_hdr *)p->payload; - tcphdr->src = htons(pcb->local_port); - tcphdr->dest = htons(pcb->remote_port); - tcphdr->seqno = seqno_be; - tcphdr->ackno = htonl(pcb->rcv_nxt); - TCPH_HDRLEN_FLAGS_SET(tcphdr, (5 + optlen / 4), TCP_ACK); - tcphdr->wnd = htons(pcb->rcv_ann_wnd); - tcphdr->chksum = 0; - tcphdr->urgp = 0; - - /* If we're sending a packet, update the announced right window edge */ - pcb->rcv_ann_right_edge = pcb->rcv_nxt + pcb->rcv_ann_wnd; - } - return p; -} - -/** - * Called by tcp_close() to send a segment including FIN flag but not data. - * - * @param pcb the tcp_pcb over which to send a segment - * @return ERR_OK if sent, another err_t otherwise - */ -err_t -tcp_send_fin(struct tcp_pcb *pcb) -{ - /* first, try to add the fin to the last unsent segment */ - if (pcb->unsent != NULL) { - struct tcp_seg *last_unsent; - for (last_unsent = pcb->unsent; last_unsent->next != NULL; - last_unsent = last_unsent->next); - - if ((TCPH_FLAGS(last_unsent->tcphdr) & (TCP_SYN | TCP_FIN | TCP_RST)) == 0) { - /* no SYN/FIN/RST flag in the header, we can add the FIN flag */ - TCPH_SET_FLAG(last_unsent->tcphdr, TCP_FIN); - pcb->flags |= TF_FIN; - return ERR_OK; - } - } - /* no data, no length, flags, copy=1, no optdata */ - return tcp_enqueue_flags(pcb, TCP_FIN); -} - -/** - * Create a TCP segment with prefilled header. - * - * Called by tcp_write and tcp_enqueue_flags. - * - * @param pcb Protocol control block for the TCP connection. - * @param p pbuf that is used to hold the TCP header. - * @param flags TCP flags for header. - * @param seqno TCP sequence number of this packet - * @param optflags options to include in TCP header - * @return a new tcp_seg pointing to p, or NULL. - * The TCP header is filled in except ackno and wnd. - * p is freed on failure. - */ -static struct tcp_seg * -tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno, u8_t optflags) -{ - struct tcp_seg *seg; - u8_t optlen = LWIP_TCP_OPT_LENGTH(optflags); - - if ((seg = (struct tcp_seg *)memp_malloc(MEMP_TCP_SEG)) == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_create_segment: no memory.\n")); - pbuf_free(p); - return NULL; - } - seg->flags = optflags; - seg->next = NULL; - seg->p = p; - seg->len = p->tot_len - optlen; -#if TCP_OVERSIZE_DBGCHECK - seg->oversize_left = 0; -#endif /* TCP_OVERSIZE_DBGCHECK */ -#if TCP_CHECKSUM_ON_COPY - seg->chksum = 0; - seg->chksum_swapped = 0; - /* check optflags */ - LWIP_ASSERT("invalid optflags passed: TF_SEG_DATA_CHECKSUMMED", - (optflags & TF_SEG_DATA_CHECKSUMMED) == 0); -#endif /* TCP_CHECKSUM_ON_COPY */ - - /* build TCP header */ - if (pbuf_header(p, TCP_HLEN)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_create_segment: no room for TCP header in pbuf.\n")); - TCP_STATS_INC(tcp.err); - tcp_seg_free(seg); - return NULL; - } - seg->tcphdr = (struct tcp_hdr *)seg->p->payload; - seg->tcphdr->src = htons(pcb->local_port); - seg->tcphdr->dest = htons(pcb->remote_port); - seg->tcphdr->seqno = htonl(seqno); - /* ackno is set in tcp_output */ - TCPH_HDRLEN_FLAGS_SET(seg->tcphdr, (5 + optlen / 4), flags); - /* wnd and chksum are set in tcp_output */ - seg->tcphdr->urgp = 0; - return seg; -} - -/** - * Allocate a PBUF_RAM pbuf, perhaps with extra space at the end. - * - * This function is like pbuf_alloc(layer, length, PBUF_RAM) except - * there may be extra bytes available at the end. - * - * @param layer flag to define header size. - * @param length size of the pbuf's payload. - * @param max_length maximum usable size of payload+oversize. - * @param oversize pointer to a u16_t that will receive the number of usable tail bytes. - * @param pcb The TCP connection that willo enqueue the pbuf. - * @param apiflags API flags given to tcp_write. - * @param first_seg true when this pbuf will be used in the first enqueued segment. - * @param - */ -#if TCP_OVERSIZE -static struct pbuf * -tcp_pbuf_prealloc(pbuf_layer layer, u16_t length, u16_t max_length, - u16_t *oversize, struct tcp_pcb *pcb, u8_t apiflags, - u8_t first_seg) -{ - struct pbuf *p; - u16_t alloc = length; - -#if LWIP_NETIF_TX_SINGLE_PBUF - LWIP_UNUSED_ARG(max_length); - LWIP_UNUSED_ARG(pcb); - LWIP_UNUSED_ARG(apiflags); - LWIP_UNUSED_ARG(first_seg); - /* always create MSS-sized pbufs */ - alloc = max_length; -#else /* LWIP_NETIF_TX_SINGLE_PBUF */ - if (length < max_length) { - /* Should we allocate an oversized pbuf, or just the minimum - * length required? If tcp_write is going to be called again - * before this segment is transmitted, we want the oversized - * buffer. If the segment will be transmitted immediately, we can - * save memory by allocating only length. We use a simple - * heuristic based on the following information: - * - * Did the user set TCP_WRITE_FLAG_MORE? - * - * Will the Nagle algorithm defer transmission of this segment? - */ - if ((apiflags & TCP_WRITE_FLAG_MORE) || - (!(pcb->flags & TF_NODELAY) && - (!first_seg || - pcb->unsent != NULL || - pcb->unacked != NULL))) { - alloc = LWIP_MIN(max_length, LWIP_MEM_ALIGN_SIZE(length + TCP_OVERSIZE)); - } - } -#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ - p = pbuf_alloc(layer, alloc, PBUF_RAM); - if (p == NULL) { - return NULL; - } - LWIP_ASSERT("need unchained pbuf", p->next == NULL); - *oversize = p->len - length; - /* trim p->len to the currently used size */ - p->len = p->tot_len = length; - return p; -} -#else /* TCP_OVERSIZE */ -#define tcp_pbuf_prealloc(layer, length, mx, os, pcb, api, fst) pbuf_alloc((layer), (length), PBUF_RAM) -#endif /* TCP_OVERSIZE */ - -#if TCP_CHECKSUM_ON_COPY -/** Add a checksum of newly added data to the segment */ -static void -tcp_seg_add_chksum(u16_t chksum, u16_t len, u16_t *seg_chksum, - u8_t *seg_chksum_swapped) -{ - u32_t helper; - /* add chksum to old chksum and fold to u16_t */ - helper = chksum + *seg_chksum; - chksum = FOLD_U32T(helper); - if ((len & 1) != 0) { - *seg_chksum_swapped = 1 - *seg_chksum_swapped; - chksum = SWAP_BYTES_IN_WORD(chksum); - } - *seg_chksum = chksum; -} -#endif /* TCP_CHECKSUM_ON_COPY */ - -/** Checks if tcp_write is allowed or not (checks state, snd_buf and snd_queuelen). - * - * @param pcb the tcp pcb to check for - * @param len length of data to send (checked agains snd_buf) - * @return ERR_OK if tcp_write is allowed to proceed, another err_t otherwise - */ -static err_t -tcp_write_checks(struct tcp_pcb *pcb, u16_t len) -{ - /* connection is in invalid state for data transmission? */ - if ((pcb->state != ESTABLISHED) && - (pcb->state != CLOSE_WAIT) && - (pcb->state != SYN_SENT) && - (pcb->state != SYN_RCVD)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_STATE | LWIP_DBG_LEVEL_SEVERE, ("tcp_write() called in invalid state\n")); - return ERR_CONN; - } else if (len == 0) { - return ERR_OK; - } - - /* fail on too much data */ - if (len > pcb->snd_buf) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_write: too much data (len=%"U16_F" > snd_buf=%"U16_F")\n", - len, pcb->snd_buf)); - pcb->flags |= TF_NAGLEMEMERR; - return ERR_MEM; - } - - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_write: queuelen: %"U16_F"\n", (u16_t)pcb->snd_queuelen)); - - /* If total number of pbufs on the unsent/unacked queues exceeds the - * configured maximum, return an error */ - /* check for configured max queuelen and possible overflow */ - if ((pcb->snd_queuelen >= TCP_SND_QUEUELEN) || (pcb->snd_queuelen > TCP_SNDQUEUELEN_OVERFLOW)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_write: too long queue %"U16_F" (max %"U16_F")\n", - pcb->snd_queuelen, TCP_SND_QUEUELEN)); - TCP_STATS_INC(tcp.memerr); - pcb->flags |= TF_NAGLEMEMERR; - return ERR_MEM; - } - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_write: pbufs on queue => at least one queue non-empty", - pcb->unacked != NULL || pcb->unsent != NULL); - } else { - LWIP_ASSERT("tcp_write: no pbufs on queue => both queues empty", - pcb->unacked == NULL && pcb->unsent == NULL); - } - return ERR_OK; -} - -/** - * Write data for sending (but does not send it immediately). - * - * It waits in the expectation of more data being sent soon (as - * it can send them more efficiently by combining them together). - * To prompt the system to send data now, call tcp_output() after - * calling tcp_write(). - * - * @param pcb Protocol control block for the TCP connection to enqueue data for. - * @param arg Pointer to the data to be enqueued for sending. - * @param len Data length in bytes - * @param apiflags combination of following flags : - * - TCP_WRITE_FLAG_COPY (0x01) data will be copied into memory belonging to the stack - * - TCP_WRITE_FLAG_MORE (0x02) for TCP connection, PSH flag will be set on last segment sent, - * @return ERR_OK if enqueued, another err_t on error - */ -err_t -tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) -{ - struct pbuf *concat_p = NULL; - struct tcp_seg *last_unsent = NULL, *seg = NULL, *prev_seg = NULL, *queue = NULL; - u16_t pos = 0; /* position in 'arg' data */ - u16_t queuelen; - u8_t optlen = 0; - u8_t optflags = 0; -#if TCP_OVERSIZE - u16_t oversize = 0; - u16_t oversize_used = 0; -#endif /* TCP_OVERSIZE */ -#if TCP_CHECKSUM_ON_COPY - u16_t concat_chksum = 0; - u8_t concat_chksum_swapped = 0; - u16_t concat_chksummed = 0; -#endif /* TCP_CHECKSUM_ON_COPY */ - err_t err; - /* don't allocate segments bigger than half the maximum window we ever received */ - u16_t mss_local = LWIP_MIN(pcb->mss, pcb->snd_wnd_max/2); - -#if LWIP_NETIF_TX_SINGLE_PBUF - /* Always copy to try to create single pbufs for TX */ - apiflags |= TCP_WRITE_FLAG_COPY; -#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ - - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, data=%p, len=%"U16_F", apiflags=%"U16_F")\n", - (void *)pcb, arg, len, (u16_t)apiflags)); - LWIP_ERROR("tcp_write: arg == NULL (programmer violates API)", - arg != NULL, return ERR_ARG;); - - err = tcp_write_checks(pcb, len); - if (err != ERR_OK) { - return err; - } - queuelen = pcb->snd_queuelen; - -#if LWIP_TCP_TIMESTAMPS - if ((pcb->flags & TF_TIMESTAMP)) { - optflags = TF_SEG_OPTS_TS; - optlen = LWIP_TCP_OPT_LENGTH(TF_SEG_OPTS_TS); - } -#endif /* LWIP_TCP_TIMESTAMPS */ - - - /* - * TCP segmentation is done in three phases with increasing complexity: - * - * 1. Copy data directly into an oversized pbuf. - * 2. Chain a new pbuf to the end of pcb->unsent. - * 3. Create new segments. - * - * We may run out of memory at any point. In that case we must - * return ERR_MEM and not change anything in pcb. Therefore, all - * changes are recorded in local variables and committed at the end - * of the function. Some pcb fields are maintained in local copies: - * - * queuelen = pcb->snd_queuelen - * oversize = pcb->unsent_oversize - * - * These variables are set consistently by the phases: - * - * seg points to the last segment tampered with. - * - * pos records progress as data is segmented. - */ - - /* Find the tail of the unsent queue. */ - if (pcb->unsent != NULL) { - u16_t space; - u16_t unsent_optlen; - - /* @todo: this could be sped up by keeping last_unsent in the pcb */ - for (last_unsent = pcb->unsent; last_unsent->next != NULL; - last_unsent = last_unsent->next); - - /* Usable space at the end of the last unsent segment */ - unsent_optlen = LWIP_TCP_OPT_LENGTH(last_unsent->flags); - space = mss_local - (last_unsent->len + unsent_optlen); - - /* - * Phase 1: Copy data directly into an oversized pbuf. - * - * The number of bytes copied is recorded in the oversize_used - * variable. The actual copying is done at the bottom of the - * function. - */ -#if TCP_OVERSIZE -#if TCP_OVERSIZE_DBGCHECK - /* check that pcb->unsent_oversize matches last_unsent->unsent_oversize */ - LWIP_ASSERT("unsent_oversize mismatch (pcb vs. last_unsent)", - pcb->unsent_oversize == last_unsent->oversize_left); -#endif /* TCP_OVERSIZE_DBGCHECK */ - oversize = pcb->unsent_oversize; - if (oversize > 0) { - LWIP_ASSERT("inconsistent oversize vs. space", oversize_used <= space); - seg = last_unsent; - oversize_used = oversize < len ? oversize : len; - pos += oversize_used; - oversize -= oversize_used; - space -= oversize_used; - } - /* now we are either finished or oversize is zero */ - LWIP_ASSERT("inconsistend oversize vs. len", (oversize == 0) || (pos == len)); -#endif /* TCP_OVERSIZE */ - - /* - * Phase 2: Chain a new pbuf to the end of pcb->unsent. - * - * We don't extend segments containing SYN/FIN flags or options - * (len==0). The new pbuf is kept in concat_p and pbuf_cat'ed at - * the end. - */ - if ((pos < len) && (space > 0) && (last_unsent->len > 0)) { - u16_t seglen = space < len - pos ? space : len - pos; - seg = last_unsent; - - /* Create a pbuf with a copy or reference to seglen bytes. We - * can use PBUF_RAW here since the data appears in the middle of - * a segment. A header will never be prepended. */ - if (apiflags & TCP_WRITE_FLAG_COPY) { - /* Data is copied */ - if ((concat_p = tcp_pbuf_prealloc(PBUF_RAW, seglen, space, &oversize, pcb, apiflags, 1)) == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, - ("tcp_write : could not allocate memory for pbuf copy size %"U16_F"\n", - seglen)); - goto memerr; - } -#if TCP_OVERSIZE_DBGCHECK - last_unsent->oversize_left += oversize; -#endif /* TCP_OVERSIZE_DBGCHECK */ - TCP_DATA_COPY2(concat_p->payload, (u8_t*)arg + pos, seglen, &concat_chksum, &concat_chksum_swapped); -#if TCP_CHECKSUM_ON_COPY - concat_chksummed += seglen; -#endif /* TCP_CHECKSUM_ON_COPY */ - } else { - /* Data is not copied */ - if ((concat_p = pbuf_alloc(PBUF_RAW, seglen, PBUF_ROM)) == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, - ("tcp_write: could not allocate memory for zero-copy pbuf\n")); - goto memerr; - } -#if TCP_CHECKSUM_ON_COPY - /* calculate the checksum of nocopy-data */ - tcp_seg_add_chksum(~inet_chksum((u8_t*)arg + pos, seglen), seglen, - &concat_chksum, &concat_chksum_swapped); - concat_chksummed += seglen; -#endif /* TCP_CHECKSUM_ON_COPY */ - /* reference the non-volatile payload data */ - concat_p->payload = (u8_t*)arg + pos; - } - - pos += seglen; - queuelen += pbuf_clen(concat_p); - } - } else { -#if TCP_OVERSIZE - LWIP_ASSERT("unsent_oversize mismatch (pcb->unsent is NULL)", - pcb->unsent_oversize == 0); -#endif /* TCP_OVERSIZE */ - } - - /* - * Phase 3: Create new segments. - * - * The new segments are chained together in the local 'queue' - * variable, ready to be appended to pcb->unsent. - */ - while (pos < len) { - struct pbuf *p; - u16_t left = len - pos; - u16_t max_len = mss_local - optlen; - u16_t seglen = left > max_len ? max_len : left; -#if TCP_CHECKSUM_ON_COPY - u16_t chksum = 0; - u8_t chksum_swapped = 0; -#endif /* TCP_CHECKSUM_ON_COPY */ - - if (apiflags & TCP_WRITE_FLAG_COPY) { - /* If copy is set, memory should be allocated and data copied - * into pbuf */ - if ((p = tcp_pbuf_prealloc(PBUF_TRANSPORT, seglen + optlen, mss_local, &oversize, pcb, apiflags, queue == NULL)) == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write : could not allocate memory for pbuf copy size %"U16_F"\n", seglen)); - goto memerr; - } - LWIP_ASSERT("tcp_write: check that first pbuf can hold the complete seglen", - (p->len >= seglen)); - TCP_DATA_COPY2((char *)p->payload + optlen, (u8_t*)arg + pos, seglen, &chksum, &chksum_swapped); - } else { - /* Copy is not set: First allocate a pbuf for holding the data. - * Since the referenced data is available at least until it is - * sent out on the link (as it has to be ACKed by the remote - * party) we can safely use PBUF_ROM instead of PBUF_REF here. - */ - struct pbuf *p2; -#if TCP_OVERSIZE - LWIP_ASSERT("oversize == 0", oversize == 0); -#endif /* TCP_OVERSIZE */ - if ((p2 = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_ROM)) == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write: could not allocate memory for zero-copy pbuf\n")); - goto memerr; - } -#if TCP_CHECKSUM_ON_COPY - /* calculate the checksum of nocopy-data */ - chksum = ~inet_chksum((u8_t*)arg + pos, seglen); -#endif /* TCP_CHECKSUM_ON_COPY */ - /* reference the non-volatile payload data */ - p2->payload = (u8_t*)arg + pos; - - /* Second, allocate a pbuf for the headers. */ - if ((p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) { - /* If allocation fails, we have to deallocate the data pbuf as - * well. */ - pbuf_free(p2); - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write: could not allocate memory for header pbuf\n")); - goto memerr; - } - /* Concatenate the headers and data pbufs together. */ - pbuf_cat(p/*header*/, p2/*data*/); - } - - queuelen += pbuf_clen(p); - - /* Now that there are more segments queued, we check again if the - * length of the queue exceeds the configured maximum or - * overflows. */ - if ((queuelen > TCP_SND_QUEUELEN) || (queuelen > TCP_SNDQUEUELEN_OVERFLOW)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_write: queue too long %"U16_F" (%"U16_F")\n", queuelen, TCP_SND_QUEUELEN)); - pbuf_free(p); - goto memerr; - } - - if ((seg = tcp_create_segment(pcb, p, 0, pcb->snd_lbb + pos, optflags)) == NULL) { - goto memerr; - } -#if TCP_OVERSIZE_DBGCHECK - seg->oversize_left = oversize; -#endif /* TCP_OVERSIZE_DBGCHECK */ -#if TCP_CHECKSUM_ON_COPY - seg->chksum = chksum; - seg->chksum_swapped = chksum_swapped; - seg->flags |= TF_SEG_DATA_CHECKSUMMED; -#endif /* TCP_CHECKSUM_ON_COPY */ - - /* first segment of to-be-queued data? */ - if (queue == NULL) { - queue = seg; - } else { - /* Attach the segment to the end of the queued segments */ - LWIP_ASSERT("prev_seg != NULL", prev_seg != NULL); - prev_seg->next = seg; - } - /* remember last segment of to-be-queued data for next iteration */ - prev_seg = seg; - - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE, ("tcp_write: queueing %"U32_F":%"U32_F"\n", - ntohl(seg->tcphdr->seqno), - ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg))); - - pos += seglen; - } - - /* - * All three segmentation phases were successful. We can commit the - * transaction. - */ - - /* - * Phase 1: If data has been added to the preallocated tail of - * last_unsent, we update the length fields of the pbuf chain. - */ -#if TCP_OVERSIZE - if (oversize_used > 0) { - struct pbuf *p; - /* Bump tot_len of whole chain, len of tail */ - for (p = last_unsent->p; p; p = p->next) { - p->tot_len += oversize_used; - if (p->next == NULL) { - TCP_DATA_COPY((char *)p->payload + p->len, arg, oversize_used, last_unsent); - p->len += oversize_used; - } - } - last_unsent->len += oversize_used; -#if TCP_OVERSIZE_DBGCHECK - LWIP_ASSERT("last_unsent->oversize_left >= oversize_used", - last_unsent->oversize_left >= oversize_used); - last_unsent->oversize_left -= oversize_used; -#endif /* TCP_OVERSIZE_DBGCHECK */ - } - pcb->unsent_oversize = oversize; -#endif /* TCP_OVERSIZE */ - - /* - * Phase 2: concat_p can be concatenated onto last_unsent->p - */ - if (concat_p != NULL) { - LWIP_ASSERT("tcp_write: cannot concatenate when pcb->unsent is empty", - (last_unsent != NULL)); - pbuf_cat(last_unsent->p, concat_p); - last_unsent->len += concat_p->tot_len; -#if TCP_CHECKSUM_ON_COPY - if (concat_chksummed) { - tcp_seg_add_chksum(concat_chksum, concat_chksummed, &last_unsent->chksum, - &last_unsent->chksum_swapped); - last_unsent->flags |= TF_SEG_DATA_CHECKSUMMED; - } -#endif /* TCP_CHECKSUM_ON_COPY */ - } - - /* - * Phase 3: Append queue to pcb->unsent. Queue may be NULL, but that - * is harmless - */ - if (last_unsent == NULL) { - pcb->unsent = queue; - } else { - last_unsent->next = queue; - } - - /* - * Finally update the pcb state. - */ - pcb->snd_lbb += len; - pcb->snd_buf -= len; - pcb->snd_queuelen = queuelen; - - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_write: %"S16_F" (after enqueued)\n", - pcb->snd_queuelen)); - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_write: valid queue length", - pcb->unacked != NULL || pcb->unsent != NULL); - } - - /* Set the PSH flag in the last segment that we enqueued. */ - if (seg != NULL && seg->tcphdr != NULL && ((apiflags & TCP_WRITE_FLAG_MORE)==0)) { - TCPH_SET_FLAG(seg->tcphdr, TCP_PSH); - } - - return ERR_OK; -memerr: - pcb->flags |= TF_NAGLEMEMERR; - TCP_STATS_INC(tcp.memerr); - - if (concat_p != NULL) { - pbuf_free(concat_p); - } - if (queue != NULL) { - tcp_segs_free(queue); - } - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_write: valid queue length", pcb->unacked != NULL || - pcb->unsent != NULL); - } - LWIP_DEBUGF(TCP_QLEN_DEBUG | LWIP_DBG_STATE, ("tcp_write: %"S16_F" (with mem err)\n", pcb->snd_queuelen)); - return ERR_MEM; -} - -/** - * Enqueue TCP options for transmission. - * - * Called by tcp_connect(), tcp_listen_input(), and tcp_send_ctrl(). - * - * @param pcb Protocol control block for the TCP connection. - * @param flags TCP header flags to set in the outgoing segment. - * @param optdata pointer to TCP options, or NULL. - * @param optlen length of TCP options in bytes. - */ -err_t -tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags) -{ - struct pbuf *p; - struct tcp_seg *seg; - u8_t optflags = 0; - u8_t optlen = 0; - - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue_flags: queuelen: %"U16_F"\n", (u16_t)pcb->snd_queuelen)); - - LWIP_ASSERT("tcp_enqueue_flags: need either TCP_SYN or TCP_FIN in flags (programmer violates API)", - (flags & (TCP_SYN | TCP_FIN)) != 0); - - /* check for configured max queuelen and possible overflow */ - if ((pcb->snd_queuelen >= TCP_SND_QUEUELEN) || (pcb->snd_queuelen > TCP_SNDQUEUELEN_OVERFLOW)) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue_flags: too long queue %"U16_F" (max %"U16_F")\n", - pcb->snd_queuelen, TCP_SND_QUEUELEN)); - TCP_STATS_INC(tcp.memerr); - pcb->flags |= TF_NAGLEMEMERR; - return ERR_MEM; - } - - if (flags & TCP_SYN) { - optflags = TF_SEG_OPTS_MSS; - } -#if LWIP_TCP_TIMESTAMPS - if ((pcb->flags & TF_TIMESTAMP)) { - optflags |= TF_SEG_OPTS_TS; - } -#endif /* LWIP_TCP_TIMESTAMPS */ - optlen = LWIP_TCP_OPT_LENGTH(optflags); - - /* tcp_enqueue_flags is always called with either SYN or FIN in flags. - * We need one available snd_buf byte to do that. - * This means we can't send FIN while snd_buf==0. A better fix would be to - * not include SYN and FIN sequence numbers in the snd_buf count. */ - if (pcb->snd_buf == 0) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue_flags: no send buffer available\n")); - TCP_STATS_INC(tcp.memerr); - return ERR_MEM; - } - - /* Allocate pbuf with room for TCP header + options */ - if ((p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) { - pcb->flags |= TF_NAGLEMEMERR; - TCP_STATS_INC(tcp.memerr); - return ERR_MEM; - } - LWIP_ASSERT("tcp_enqueue_flags: check that first pbuf can hold optlen", - (p->len >= optlen)); - - /* Allocate memory for tcp_seg, and fill in fields. */ - if ((seg = tcp_create_segment(pcb, p, flags, pcb->snd_lbb, optflags)) == NULL) { - pcb->flags |= TF_NAGLEMEMERR; - TCP_STATS_INC(tcp.memerr); - return ERR_MEM; - } - LWIP_ASSERT("seg->tcphdr not aligned", ((mem_ptr_t)seg->tcphdr % MEM_ALIGNMENT) == 0); - LWIP_ASSERT("tcp_enqueue_flags: invalid segment length", seg->len == 0); - - LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_TRACE, - ("tcp_enqueue_flags: queueing %"U32_F":%"U32_F" (0x%"X16_F")\n", - ntohl(seg->tcphdr->seqno), - ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg), - (u16_t)flags)); - - /* Now append seg to pcb->unsent queue */ - if (pcb->unsent == NULL) { - pcb->unsent = seg; - } else { - struct tcp_seg *useg; - for (useg = pcb->unsent; useg->next != NULL; useg = useg->next); - useg->next = seg; - } -#if TCP_OVERSIZE - /* The new unsent tail has no space */ - pcb->unsent_oversize = 0; -#endif /* TCP_OVERSIZE */ - - /* SYN and FIN bump the sequence number */ - if ((flags & TCP_SYN) || (flags & TCP_FIN)) { - pcb->snd_lbb++; - /* optlen does not influence snd_buf */ - pcb->snd_buf--; - } - if (flags & TCP_FIN) { - pcb->flags |= TF_FIN; - } - - /* update number of segments on the queues */ - pcb->snd_queuelen += pbuf_clen(seg->p); - LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue_flags: %"S16_F" (after enqueued)\n", pcb->snd_queuelen)); - if (pcb->snd_queuelen != 0) { - LWIP_ASSERT("tcp_enqueue_flags: invalid queue length", - pcb->unacked != NULL || pcb->unsent != NULL); - } - - return ERR_OK; -} - -#if LWIP_TCP_TIMESTAMPS -/* Build a timestamp option (12 bytes long) at the specified options pointer) - * - * @param pcb tcp_pcb - * @param opts option pointer where to store the timestamp option - */ -static void -tcp_build_timestamp_option(struct tcp_pcb *pcb, u32_t *opts) -{ - /* Pad with two NOP options to make everything nicely aligned */ - opts[0] = PP_HTONL(0x0101080A); - opts[1] = htonl(sys_now()); - opts[2] = htonl(pcb->ts_recent); -} -#endif - -/** Send an ACK without data. - * - * @param pcb Protocol control block for the TCP connection to send the ACK - */ -err_t -tcp_send_empty_ack(struct tcp_pcb *pcb) -{ - struct pbuf *p; - u8_t optlen = 0; -#if LWIP_TCP_TIMESTAMPS || CHECKSUM_GEN_TCP - struct tcp_hdr *tcphdr; -#endif /* LWIP_TCP_TIMESTAMPS || CHECKSUM_GEN_TCP */ - -#if LWIP_TCP_TIMESTAMPS - if (pcb->flags & TF_TIMESTAMP) { - optlen = LWIP_TCP_OPT_LENGTH(TF_SEG_OPTS_TS); - } -#endif - - p = tcp_output_alloc_header(pcb, optlen, 0, htonl(pcb->snd_nxt)); - if (p == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: (ACK) could not allocate pbuf\n")); - return ERR_BUF; - } -#if LWIP_TCP_TIMESTAMPS || CHECKSUM_GEN_TCP - tcphdr = (struct tcp_hdr *)p->payload; -#endif /* LWIP_TCP_TIMESTAMPS || CHECKSUM_GEN_TCP */ - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, - ("tcp_output: sending ACK for %"U32_F"\n", pcb->rcv_nxt)); - /* remove ACK flags from the PCB, as we send an empty ACK now */ - pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); - - /* NB. MSS option is only sent on SYNs, so ignore it here */ -#if LWIP_TCP_TIMESTAMPS - pcb->ts_lastacksent = pcb->rcv_nxt; - - if (pcb->flags & TF_TIMESTAMP) { - tcp_build_timestamp_option(pcb, (u32_t *)(tcphdr + 1)); - } -#endif - -#if CHECKSUM_GEN_TCP - tcphdr->chksum = ipX_chksum_pseudo(PCB_ISIPV6(pcb), p, IP_PROTO_TCP, p->tot_len, - &pcb->local_ip, &pcb->remote_ip); -#endif -#if LWIP_NETIF_HWADDRHINT - ipX_output_hinted(PCB_ISIPV6(pcb), p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, - IP_PROTO_TCP, &pcb->addr_hint); -#else /* LWIP_NETIF_HWADDRHINT*/ - ipX_output(PCB_ISIPV6(pcb), p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, - IP_PROTO_TCP); -#endif /* LWIP_NETIF_HWADDRHINT*/ - pbuf_free(p); - - return ERR_OK; -} - -/** - * Find out what we can send and send it - * - * @param pcb Protocol control block for the TCP connection to send data - * @return ERR_OK if data has been sent or nothing to send - * another err_t on error - */ -err_t -tcp_output(struct tcp_pcb *pcb) -{ - struct tcp_seg *seg, *useg; - u32_t wnd, snd_nxt; -#if TCP_CWND_DEBUG - s16_t i = 0; -#endif /* TCP_CWND_DEBUG */ - - /* pcb->state LISTEN not allowed here */ - LWIP_ASSERT("don't call tcp_output for listen-pcbs", - pcb->state != LISTEN); - - /* First, check if we are invoked by the TCP input processing - code. If so, we do not output anything. Instead, we rely on the - input processing code to call us when input processing is done - with. */ - if (tcp_input_pcb == pcb) { - return ERR_OK; - } - - wnd = LWIP_MIN(pcb->snd_wnd, pcb->cwnd); - - seg = pcb->unsent; - - /* If the TF_ACK_NOW flag is set and no data will be sent (either - * because the ->unsent queue is empty or because the window does - * not allow it), construct an empty ACK segment and send it. - * - * If data is to be sent, we will just piggyback the ACK (see below). - */ - if (pcb->flags & TF_ACK_NOW && - (seg == NULL || - ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd)) { - return tcp_send_empty_ack(pcb); - } - - /* useg should point to last segment on unacked queue */ - useg = pcb->unacked; - if (useg != NULL) { - for (; useg->next != NULL; useg = useg->next); - } - -#if TCP_OUTPUT_DEBUG - if (seg == NULL) { - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n", - (void*)pcb->unsent)); - } -#endif /* TCP_OUTPUT_DEBUG */ -#if TCP_CWND_DEBUG - if (seg == NULL) { - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"U16_F - ", cwnd %"U16_F", wnd %"U32_F - ", seg == NULL, ack %"U32_F"\n", - pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack)); - } else { - LWIP_DEBUGF(TCP_CWND_DEBUG, - ("tcp_output: snd_wnd %"U16_F", cwnd %"U16_F", wnd %"U32_F - ", effwnd %"U32_F", seq %"U32_F", ack %"U32_F"\n", - pcb->snd_wnd, pcb->cwnd, wnd, - ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len, - ntohl(seg->tcphdr->seqno), pcb->lastack)); - } -#endif /* TCP_CWND_DEBUG */ - /* data available and window allows it to be sent? */ - while (seg != NULL && - ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) { - LWIP_ASSERT("RST not expected here!", - (TCPH_FLAGS(seg->tcphdr) & TCP_RST) == 0); - /* Stop sending if the nagle algorithm would prevent it - * Don't stop: - * - if tcp_write had a memory error before (prevent delayed ACK timeout) or - * - if FIN was already enqueued for this PCB (SYN is always alone in a segment - - * either seg->next != NULL or pcb->unacked == NULL; - * RST is no sent using tcp_write/tcp_output. - */ - if((tcp_do_output_nagle(pcb) == 0) && - ((pcb->flags & (TF_NAGLEMEMERR | TF_FIN)) == 0)){ - break; - } -#if TCP_CWND_DEBUG - LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"U16_F", cwnd %"U16_F", wnd %"U32_F", effwnd %"U32_F", seq %"U32_F", ack %"U32_F", i %"S16_F"\n", - pcb->snd_wnd, pcb->cwnd, wnd, - ntohl(seg->tcphdr->seqno) + seg->len - - pcb->lastack, - ntohl(seg->tcphdr->seqno), pcb->lastack, i)); - ++i; -#endif /* TCP_CWND_DEBUG */ - - pcb->unsent = seg->next; - - if (pcb->state != SYN_SENT) { - TCPH_SET_FLAG(seg->tcphdr, TCP_ACK); - pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); - } - -#if TCP_OVERSIZE_DBGCHECK - seg->oversize_left = 0; -#endif /* TCP_OVERSIZE_DBGCHECK */ - tcp_output_segment(seg, pcb); - snd_nxt = ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg); - if (TCP_SEQ_LT(pcb->snd_nxt, snd_nxt)) { - pcb->snd_nxt = snd_nxt; - } - /* put segment on unacknowledged list if length > 0 */ - if (TCP_TCPLEN(seg) > 0) { - seg->next = NULL; - /* unacked list is empty? */ - if (pcb->unacked == NULL) { - pcb->unacked = seg; - useg = seg; - /* unacked list is not empty? */ - } else { - /* In the case of fast retransmit, the packet should not go to the tail - * of the unacked queue, but rather somewhere before it. We need to check for - * this case. -STJ Jul 27, 2004 */ - if (TCP_SEQ_LT(ntohl(seg->tcphdr->seqno), ntohl(useg->tcphdr->seqno))) { - /* add segment to before tail of unacked list, keeping the list sorted */ - struct tcp_seg **cur_seg = &(pcb->unacked); - while (*cur_seg && - TCP_SEQ_LT(ntohl((*cur_seg)->tcphdr->seqno), ntohl(seg->tcphdr->seqno))) { - cur_seg = &((*cur_seg)->next ); - } - seg->next = (*cur_seg); - (*cur_seg) = seg; - } else { - /* add segment to tail of unacked list */ - useg->next = seg; - useg = useg->next; - } - } - /* do not queue empty segments on the unacked list */ - } else { - tcp_seg_free(seg); - } - seg = pcb->unsent; - } -#if TCP_OVERSIZE - if (pcb->unsent == NULL) { - /* last unsent has been removed, reset unsent_oversize */ - pcb->unsent_oversize = 0; - } -#endif /* TCP_OVERSIZE */ - - pcb->flags &= ~TF_NAGLEMEMERR; - return ERR_OK; -} - -/** - * Called by tcp_output() to actually send a TCP segment over IP. - * - * @param seg the tcp_seg to send - * @param pcb the tcp_pcb for the TCP connection used to send the segment - */ -static void -tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb) -{ - u16_t len; - u32_t *opts; - - /** @bug Exclude retransmitted segments from this count. */ - snmp_inc_tcpoutsegs(); - - /* The TCP header has already been constructed, but the ackno and - wnd fields remain. */ - seg->tcphdr->ackno = htonl(pcb->rcv_nxt); - - /* advertise our receive window size in this TCP segment */ - seg->tcphdr->wnd = htons(pcb->rcv_ann_wnd); - - pcb->rcv_ann_right_edge = pcb->rcv_nxt + pcb->rcv_ann_wnd; - - /* Add any requested options. NB MSS option is only set on SYN - packets, so ignore it here */ - opts = (u32_t *)(void *)(seg->tcphdr + 1); - if (seg->flags & TF_SEG_OPTS_MSS) { - u16_t mss; -#if TCP_CALCULATE_EFF_SEND_MSS - mss = tcp_eff_send_mss(TCP_MSS, &pcb->local_ip, &pcb->remote_ip, PCB_ISIPV6(pcb)); -#else /* TCP_CALCULATE_EFF_SEND_MSS */ - mss = TCP_MSS; -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - *opts = TCP_BUILD_MSS_OPTION(mss); - opts += 1; - } -#if LWIP_TCP_TIMESTAMPS - pcb->ts_lastacksent = pcb->rcv_nxt; - - if (seg->flags & TF_SEG_OPTS_TS) { - tcp_build_timestamp_option(pcb, opts); - opts += 3; - } -#endif - - /* Set retransmission timer running if it is not currently enabled - This must be set before checking the route. */ - if (pcb->rtime == -1) { - pcb->rtime = 0; - } - - /* If we don't have a local IP address, we get one by - calling ip_route(). */ - if (ipX_addr_isany(PCB_ISIPV6(pcb), &pcb->local_ip)) { - struct netif *netif; - ipX_addr_t *local_ip; - ipX_route_get_local_ipX(PCB_ISIPV6(pcb), &pcb->local_ip, &pcb->remote_ip, netif, local_ip); - if ((netif == NULL) || (local_ip == NULL)) { - return; - } - ipX_addr_copy(PCB_ISIPV6(pcb), pcb->local_ip, *local_ip); - } - - if (pcb->rttest == 0) { - pcb->rttest = tcp_ticks; - pcb->rtseq = ntohl(seg->tcphdr->seqno); - - LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_output_segment: rtseq %"U32_F"\n", pcb->rtseq)); - } - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output_segment: %"U32_F":%"U32_F"\n", - htonl(seg->tcphdr->seqno), htonl(seg->tcphdr->seqno) + - seg->len)); - - len = (u16_t)((u8_t *)seg->tcphdr - (u8_t *)seg->p->payload); - - seg->p->len -= len; - seg->p->tot_len -= len; - - seg->p->payload = seg->tcphdr; - - seg->tcphdr->chksum = 0; -#if TCP_CHECKSUM_ON_COPY - { - u32_t acc; -#if TCP_CHECKSUM_ON_COPY_SANITY_CHECK - u16_t chksum_slow = ipX_chksum_pseudo(PCB_ISIPV6(pcb), seg->p, IP_PROTO_TCP, - seg->p->tot_len, &pcb->local_ip, &pcb->remote_ip); -#endif /* TCP_CHECKSUM_ON_COPY_SANITY_CHECK */ - if ((seg->flags & TF_SEG_DATA_CHECKSUMMED) == 0) { - LWIP_ASSERT("data included but not checksummed", - seg->p->tot_len == (TCPH_HDRLEN(seg->tcphdr) * 4)); - } - - /* rebuild TCP header checksum (TCP header changes for retransmissions!) */ - acc = ipX_chksum_pseudo_partial(PCB_ISIPV6(pcb), seg->p, IP_PROTO_TCP, - seg->p->tot_len, TCPH_HDRLEN(seg->tcphdr) * 4, &pcb->local_ip, &pcb->remote_ip); - /* add payload checksum */ - if (seg->chksum_swapped) { - seg->chksum = SWAP_BYTES_IN_WORD(seg->chksum); - seg->chksum_swapped = 0; - } - acc += (u16_t)~(seg->chksum); - seg->tcphdr->chksum = FOLD_U32T(acc); -#if TCP_CHECKSUM_ON_COPY_SANITY_CHECK - if (chksum_slow != seg->tcphdr->chksum) { - LWIP_DEBUGF(TCP_DEBUG | LWIP_DBG_LEVEL_WARNING, - ("tcp_output_segment: calculated checksum is %"X16_F" instead of %"X16_F"\n", - seg->tcphdr->chksum, chksum_slow)); - seg->tcphdr->chksum = chksum_slow; - } -#endif /* TCP_CHECKSUM_ON_COPY_SANITY_CHECK */ - } -#else /* TCP_CHECKSUM_ON_COPY */ -#if CHECKSUM_GEN_TCP - seg->tcphdr->chksum = ipX_chksum_pseudo(PCB_ISIPV6(pcb), seg->p, IP_PROTO_TCP, - seg->p->tot_len, &pcb->local_ip, &pcb->remote_ip); -#endif /* CHECKSUM_GEN_TCP */ -#endif /* TCP_CHECKSUM_ON_COPY */ - TCP_STATS_INC(tcp.xmit); - -#if LWIP_NETIF_HWADDRHINT - ipX_output_hinted(PCB_ISIPV6(pcb), seg->p, &pcb->local_ip, &pcb->remote_ip, - pcb->ttl, pcb->tos, IP_PROTO_TCP, &pcb->addr_hint); -#else /* LWIP_NETIF_HWADDRHINT*/ - ipX_output(PCB_ISIPV6(pcb), seg->p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, - pcb->tos, IP_PROTO_TCP); -#endif /* LWIP_NETIF_HWADDRHINT*/ -} - -/** - * Send a TCP RESET packet (empty segment with RST flag set) either to - * abort a connection or to show that there is no matching local connection - * for a received segment. - * - * Called by tcp_abort() (to abort a local connection), tcp_input() (if no - * matching local pcb was found), tcp_listen_input() (if incoming segment - * has ACK flag set) and tcp_process() (received segment in the wrong state) - * - * Since a RST segment is in most cases not sent for an active connection, - * tcp_rst() has a number of arguments that are taken from a tcp_pcb for - * most other segment output functions. - * - * @param seqno the sequence number to use for the outgoing segment - * @param ackno the acknowledge number to use for the outgoing segment - * @param local_ip the local IP address to send the segment from - * @param remote_ip the remote IP address to send the segment to - * @param local_port the local TCP port to send the segment from - * @param remote_port the remote TCP port to send the segment to - */ -void -tcp_rst_impl(u32_t seqno, u32_t ackno, - ipX_addr_t *local_ip, ipX_addr_t *remote_ip, - u16_t local_port, u16_t remote_port -#if LWIP_IPV6 - , u8_t isipv6 -#endif /* LWIP_IPV6 */ - ) -{ - struct pbuf *p; - struct tcp_hdr *tcphdr; - p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM); - if (p == NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_rst: could not allocate memory for pbuf\n")); - return; - } - LWIP_ASSERT("check that first pbuf can hold struct tcp_hdr", - (p->len >= sizeof(struct tcp_hdr))); - - tcphdr = (struct tcp_hdr *)p->payload; - tcphdr->src = htons(local_port); - tcphdr->dest = htons(remote_port); - tcphdr->seqno = htonl(seqno); - tcphdr->ackno = htonl(ackno); - TCPH_HDRLEN_FLAGS_SET(tcphdr, TCP_HLEN/4, TCP_RST | TCP_ACK); - tcphdr->wnd = PP_HTONS(TCP_WND); - tcphdr->chksum = 0; - tcphdr->urgp = 0; - - TCP_STATS_INC(tcp.xmit); - snmp_inc_tcpoutrsts(); - -#if CHECKSUM_GEN_TCP - tcphdr->chksum = ipX_chksum_pseudo(isipv6, p, IP_PROTO_TCP, p->tot_len, - local_ip, remote_ip); -#endif - /* Send output with hardcoded TTL/HL since we have no access to the pcb */ - ipX_output(isipv6, p, local_ip, remote_ip, TCP_TTL, 0, IP_PROTO_TCP); - pbuf_free(p); - LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_rst: seqno %"U32_F" ackno %"U32_F".\n", seqno, ackno)); -} - -/** - * Requeue all unacked segments for retransmission - * - * Called by tcp_slowtmr() for slow retransmission. - * - * @param pcb the tcp_pcb for which to re-enqueue all unacked segments - */ -void -tcp_rexmit_rto(struct tcp_pcb *pcb) -{ - struct tcp_seg *seg; - - if (pcb->unacked == NULL) { - return; - } - - /* Move all unacked segments to the head of the unsent queue */ - for (seg = pcb->unacked; seg->next != NULL; seg = seg->next); - /* concatenate unsent queue after unacked queue */ - seg->next = pcb->unsent; - /* unsent queue is the concatenated queue (of unacked, unsent) */ - pcb->unsent = pcb->unacked; - /* unacked queue is now empty */ - pcb->unacked = NULL; - /* last unsent hasn't changed, no need to reset unsent_oversize */ - - /* increment number of retransmissions */ - ++pcb->nrtx; - - /* Don't take any RTT measurements after retransmitting. */ - pcb->rttest = 0; - - /* Do the actual retransmission */ - tcp_output(pcb); -} - -/** - * Requeue the first unacked segment for retransmission - * - * Called by tcp_receive() for fast retramsmit. - * - * @param pcb the tcp_pcb for which to retransmit the first unacked segment - */ -void -tcp_rexmit(struct tcp_pcb *pcb) -{ - struct tcp_seg *seg; - struct tcp_seg **cur_seg; - - if (pcb->unacked == NULL) { - return; - } - - /* Move the first unacked segment to the unsent queue */ - /* Keep the unsent queue sorted. */ - seg = pcb->unacked; - pcb->unacked = seg->next; - - cur_seg = &(pcb->unsent); - while (*cur_seg && - TCP_SEQ_LT(ntohl((*cur_seg)->tcphdr->seqno), ntohl(seg->tcphdr->seqno))) { - cur_seg = &((*cur_seg)->next ); - } - seg->next = *cur_seg; - *cur_seg = seg; -#if TCP_OVERSIZE - if (seg->next == NULL) { - /* the retransmitted segment is last in unsent, so reset unsent_oversize */ - pcb->unsent_oversize = 0; - } -#endif /* TCP_OVERSIZE */ - - ++pcb->nrtx; - - /* Don't take any rtt measurements after retransmitting. */ - pcb->rttest = 0; - - /* Do the actual retransmission. */ - snmp_inc_tcpretranssegs(); - /* No need to call tcp_output: we are always called from tcp_input() - and thus tcp_output directly returns. */ -} - - -/** - * Handle retransmission after three dupacks received - * - * @param pcb the tcp_pcb for which to retransmit the first unacked segment - */ -void -tcp_rexmit_fast(struct tcp_pcb *pcb) -{ - if (pcb->unacked != NULL && !(pcb->flags & TF_INFR)) { - /* This is fast retransmit. Retransmit the first unacked segment. */ - LWIP_DEBUGF(TCP_FR_DEBUG, - ("tcp_receive: dupacks %"U16_F" (%"U32_F - "), fast retransmit %"U32_F"\n", - (u16_t)pcb->dupacks, pcb->lastack, - ntohl(pcb->unacked->tcphdr->seqno))); - tcp_rexmit(pcb); - - /* Set ssthresh to half of the minimum of the current - * cwnd and the advertised window */ - if (pcb->cwnd > pcb->snd_wnd) { - pcb->ssthresh = pcb->snd_wnd / 2; - } else { - pcb->ssthresh = pcb->cwnd / 2; - } - - /* The minimum value for ssthresh should be 2 MSS */ - if (pcb->ssthresh < 2*pcb->mss) { - LWIP_DEBUGF(TCP_FR_DEBUG, - ("tcp_receive: The minimum value for ssthresh %"U16_F - " should be min 2 mss %"U16_F"...\n", - pcb->ssthresh, 2*pcb->mss)); - pcb->ssthresh = 2*pcb->mss; - } - - pcb->cwnd = pcb->ssthresh + 3 * pcb->mss; - pcb->flags |= TF_INFR; - } -} - - -/** - * Send keepalive packets to keep a connection active although - * no data is sent over it. - * - * Called by tcp_slowtmr() - * - * @param pcb the tcp_pcb for which to send a keepalive packet - */ -void -tcp_keepalive(struct tcp_pcb *pcb) -{ - struct pbuf *p; -#if CHECKSUM_GEN_TCP - struct tcp_hdr *tcphdr; -#endif /* CHECKSUM_GEN_TCP */ - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: sending KEEPALIVE probe to ")); - ipX_addr_debug_print(PCB_ISIPV6(pcb), TCP_DEBUG, &pcb->remote_ip); - LWIP_DEBUGF(TCP_DEBUG, ("\n")); - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %"U32_F" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", - tcp_ticks, pcb->tmr, pcb->keep_cnt_sent)); - - p = tcp_output_alloc_header(pcb, 0, 0, htonl(pcb->snd_nxt - 1)); - if(p == NULL) { - LWIP_DEBUGF(TCP_DEBUG, - ("tcp_keepalive: could not allocate memory for pbuf\n")); - return; - } -#if CHECKSUM_GEN_TCP - tcphdr = (struct tcp_hdr *)p->payload; - - tcphdr->chksum = ipX_chksum_pseudo(PCB_ISIPV6(pcb), p, IP_PROTO_TCP, p->tot_len, - &pcb->local_ip, &pcb->remote_ip); -#endif /* CHECKSUM_GEN_TCP */ - TCP_STATS_INC(tcp.xmit); - - /* Send output to IP */ -#if LWIP_NETIF_HWADDRHINT - ipX_output_hinted(PCB_ISIPV6(pcb), p, &pcb->local_ip, &pcb->remote_ip, - pcb->ttl, 0, IP_PROTO_TCP, &pcb->addr_hint); -#else /* LWIP_NETIF_HWADDRHINT*/ - ipX_output(PCB_ISIPV6(pcb), p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, - 0, IP_PROTO_TCP); -#endif /* LWIP_NETIF_HWADDRHINT*/ - - pbuf_free(p); - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: seqno %"U32_F" ackno %"U32_F".\n", - pcb->snd_nxt - 1, pcb->rcv_nxt)); -} - - -/** - * Send persist timer zero-window probes to keep a connection active - * when a window update is lost. - * - * Called by tcp_slowtmr() - * - * @param pcb the tcp_pcb for which to send a zero-window probe packet - */ -void -tcp_zero_window_probe(struct tcp_pcb *pcb) -{ - struct pbuf *p; - struct tcp_hdr *tcphdr; - struct tcp_seg *seg; - u16_t len; - u8_t is_fin; - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: sending ZERO WINDOW probe to ")); - ipX_addr_debug_print(PCB_ISIPV6(pcb), TCP_DEBUG, &pcb->remote_ip); - LWIP_DEBUGF(TCP_DEBUG, ("\n")); - - LWIP_DEBUGF(TCP_DEBUG, - ("tcp_zero_window_probe: tcp_ticks %"U32_F - " pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", - tcp_ticks, pcb->tmr, pcb->keep_cnt_sent)); - - seg = pcb->unacked; - - if(seg == NULL) { - seg = pcb->unsent; - } - if(seg == NULL) { - return; - } - - is_fin = ((TCPH_FLAGS(seg->tcphdr) & TCP_FIN) != 0) && (seg->len == 0); - /* we want to send one seqno: either FIN or data (no options) */ - len = is_fin ? 0 : 1; - - p = tcp_output_alloc_header(pcb, 0, len, seg->tcphdr->seqno); - if(p == NULL) { - LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: no memory for pbuf\n")); - return; - } - tcphdr = (struct tcp_hdr *)p->payload; - - if (is_fin) { - /* FIN segment, no data */ - TCPH_FLAGS_SET(tcphdr, TCP_ACK | TCP_FIN); - } else { - /* Data segment, copy in one byte from the head of the unacked queue */ - char *d = ((char *)p->payload + TCP_HLEN); - /* Depending on whether the segment has already been sent (unacked) or not - (unsent), seg->p->payload points to the IP header or TCP header. - Ensure we copy the first TCP data byte: */ - pbuf_copy_partial(seg->p, d, 1, seg->p->tot_len - seg->len); - } - -#if CHECKSUM_GEN_TCP - tcphdr->chksum = ipX_chksum_pseudo(PCB_ISIPV6(pcb), p, IP_PROTO_TCP, p->tot_len, - &pcb->local_ip, &pcb->remote_ip); -#endif - TCP_STATS_INC(tcp.xmit); - - /* Send output to IP */ -#if LWIP_NETIF_HWADDRHINT - ipX_output_hinted(PCB_ISIPV6(pcb), p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, - 0, IP_PROTO_TCP, &pcb->addr_hint); -#else /* LWIP_NETIF_HWADDRHINT*/ - ipX_output(PCB_ISIPV6(pcb), p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP); -#endif /* LWIP_NETIF_HWADDRHINT*/ - - pbuf_free(p); - - LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: seqno %"U32_F - " ackno %"U32_F".\n", - pcb->snd_nxt - 1, pcb->rcv_nxt)); -} -#endif /* LWIP_TCP */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/timers.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/timers.c deleted file mode 100644 index 167f2351..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/timers.c +++ /dev/null @@ -1,545 +0,0 @@ -/** - * @file - * Stack-internal timers implementation. - * This file includes timer callbacks for stack-internal timers as well as - * functions to set up or stop timers and check for expired timers. - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * Simon Goldschmidt - * - */ - -#include "lwip/opt.h" - -#include "lwip/timers.h" -#include "lwip/tcp_impl.h" - -#if LWIP_TIMERS - -#include "lwip/def.h" -#include "lwip/memp.h" -#include "lwip/tcpip.h" - -#include "lwip/ip_frag.h" -#include "netif/etharp.h" -#include "lwip/dhcp.h" -#include "lwip/autoip.h" -#include "lwip/igmp.h" -#include "lwip/dns.h" -#include "lwip/nd6.h" -#include "lwip/ip6_frag.h" -#include "lwip/mld6.h" -#include "lwip/sys.h" -#include "lwip/pbuf.h" - -/** The one and only timeout list */ -static struct sys_timeo *next_timeout; -#if NO_SYS -static u32_t timeouts_last_time; -#endif /* NO_SYS */ - -#if LWIP_TCP -/** global variable that shows if the tcp timer is currently scheduled or not */ -static int tcpip_tcp_timer_active; - -/** - * Timer callback function that calls tcp_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -tcpip_tcp_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - - /* call TCP timer handler */ - tcp_tmr(); - /* timer still needed? */ - if (tcp_active_pcbs || tcp_tw_pcbs) { - /* restart timer */ - sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL); - } else { - /* disable timer */ - tcpip_tcp_timer_active = 0; - } -} - -/** - * Called from TCP_REG when registering a new PCB: - * the reason is to have the TCP timer only running when - * there are active (or time-wait) PCBs. - */ -void -tcp_timer_needed(void) -{ - /* timer is off but needed again? */ - if (!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs)) { - /* enable and start timer */ - tcpip_tcp_timer_active = 1; - sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL); - } -} -#endif /* LWIP_TCP */ - -#if IP_REASSEMBLY -/** - * Timer callback function that calls ip_reass_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -ip_reass_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: ip_reass_tmr()\n")); - ip_reass_tmr(); - sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL); -} -#endif /* IP_REASSEMBLY */ - -#if LWIP_ARP -/** - * Timer callback function that calls etharp_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -arp_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: etharp_tmr()\n")); - etharp_tmr(); - sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); -} -#endif /* LWIP_ARP */ - -#if LWIP_DHCP -/** - * Timer callback function that calls dhcp_coarse_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -dhcp_timer_coarse(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dhcp_coarse_tmr()\n")); - dhcp_coarse_tmr(); - sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL); -} - -/** - * Timer callback function that calls dhcp_fine_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -dhcp_timer_fine(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dhcp_fine_tmr()\n")); - dhcp_fine_tmr(); - sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); -} -#endif /* LWIP_DHCP */ - -#if LWIP_AUTOIP -/** - * Timer callback function that calls autoip_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -autoip_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: autoip_tmr()\n")); - autoip_tmr(); - sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL); -} -#endif /* LWIP_AUTOIP */ - -#if LWIP_IGMP -/** - * Timer callback function that calls igmp_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -igmp_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: igmp_tmr()\n")); - igmp_tmr(); - sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL); -} -#endif /* LWIP_IGMP */ - -#if LWIP_DNS -/** - * Timer callback function that calls dns_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -dns_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dns_tmr()\n")); - dns_tmr(); - sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL); -} -#endif /* LWIP_DNS */ - -#if LWIP_IPV6 -/** - * Timer callback function that calls nd6_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -nd6_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: nd6_tmr()\n")); - nd6_tmr(); - sys_timeout(ND6_TMR_INTERVAL, nd6_timer, NULL); -} - -#if LWIP_IPV6_REASS -/** - * Timer callback function that calls ip6_reass_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -ip6_reass_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: ip6_reass_tmr()\n")); - ip6_reass_tmr(); - sys_timeout(IP6_REASS_TMR_INTERVAL, ip6_reass_timer, NULL); -} -#endif /* LWIP_IPV6_REASS */ - -#if LWIP_IPV6_MLD -/** - * Timer callback function that calls mld6_tmr() and reschedules itself. - * - * @param arg unused argument - */ -static void -mld6_timer(void *arg) -{ - LWIP_UNUSED_ARG(arg); - LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: mld6_tmr()\n")); - mld6_tmr(); - sys_timeout(MLD6_TMR_INTERVAL, mld6_timer, NULL); -} -#endif /* LWIP_IPV6_MLD */ -#endif /* LWIP_IPV6 */ - -/** Initialize this module */ -void sys_timeouts_init(void) -{ -#if IP_REASSEMBLY - sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL); -#endif /* IP_REASSEMBLY */ -#if LWIP_ARP - sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); -#endif /* LWIP_ARP */ -#if LWIP_DHCP - sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL); - sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); -#endif /* LWIP_DHCP */ -#if LWIP_AUTOIP - sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL); -#endif /* LWIP_AUTOIP */ -#if LWIP_IGMP - sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL); -#endif /* LWIP_IGMP */ -#if LWIP_DNS - sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL); -#endif /* LWIP_DNS */ -#if LWIP_IPV6 - sys_timeout(ND6_TMR_INTERVAL, nd6_timer, NULL); -#if LWIP_IPV6_REASS - sys_timeout(IP6_REASS_TMR_INTERVAL, ip6_reass_timer, NULL); -#endif /* LWIP_IPV6_REASS */ -#if LWIP_IPV6_MLD - sys_timeout(MLD6_TMR_INTERVAL, mld6_timer, NULL); -#endif /* LWIP_IPV6_MLD */ -#endif /* LWIP_IPV6 */ - -#if NO_SYS - /* Initialise timestamp for sys_check_timeouts */ - timeouts_last_time = sys_now(); -#endif -} - -/** - * Create a one-shot timer (aka timeout). Timeouts are processed in the - * following cases: - * - while waiting for a message using sys_timeouts_mbox_fetch() - * - by calling sys_check_timeouts() (NO_SYS==1 only) - * - * @param msecs time in milliseconds after that the timer should expire - * @param handler callback function to call when msecs have elapsed - * @param arg argument to pass to the callback function - */ -#if LWIP_DEBUG_TIMERNAMES -void -sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name) -#else /* LWIP_DEBUG_TIMERNAMES */ -void -sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg) -#endif /* LWIP_DEBUG_TIMERNAMES */ -{ - struct sys_timeo *timeout, *t; - timeout = (struct sys_timeo *)memp_malloc(MEMP_SYS_TIMEOUT); - if (timeout == NULL) { - LWIP_ASSERT("sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty", timeout != NULL); - return; - } - timeout->next = NULL; - timeout->h = handler; - timeout->arg = arg; - timeout->time = msecs; -#if LWIP_DEBUG_TIMERNAMES - timeout->handler_name = handler_name; - LWIP_DEBUGF(TIMERS_DEBUG, ("sys_timeout: %p msecs=%"U32_F" handler=%s arg=%p\n", - (void *)timeout, msecs, handler_name, (void *)arg)); -#endif /* LWIP_DEBUG_TIMERNAMES */ - - if (next_timeout == NULL) { - next_timeout = timeout; - return; - } - - if (next_timeout->time > msecs) { - next_timeout->time -= msecs; - timeout->next = next_timeout; - next_timeout = timeout; - } else { - for(t = next_timeout; t != NULL; t = t->next) { - timeout->time -= t->time; - if (t->next == NULL || t->next->time > timeout->time) { - if (t->next != NULL) { - t->next->time -= timeout->time; - } - timeout->next = t->next; - t->next = timeout; - break; - } - } - } -} - -/** - * Go through timeout list (for this task only) and remove the first matching - * entry, even though the timeout has not triggered yet. - * - * @note This function only works as expected if there is only one timeout - * calling 'handler' in the list of timeouts. - * - * @param handler callback function that would be called by the timeout - * @param arg callback argument that would be passed to handler -*/ -void -sys_untimeout(sys_timeout_handler handler, void *arg) -{ - struct sys_timeo *prev_t, *t; - - if (next_timeout == NULL) { - return; - } - - for (t = next_timeout, prev_t = NULL; t != NULL; prev_t = t, t = t->next) { - if ((t->h == handler) && (t->arg == arg)) { - /* We have a match */ - /* Unlink from previous in list */ - if (prev_t == NULL) { - next_timeout = t->next; - } else { - prev_t->next = t->next; - } - /* If not the last one, add time of this one back to next */ - if (t->next != NULL) { - t->next->time += t->time; - } - memp_free(MEMP_SYS_TIMEOUT, t); - return; - } - } - return; -} - -#if NO_SYS - -/** Handle timeouts for NO_SYS==1 (i.e. without using - * tcpip_thread/sys_timeouts_mbox_fetch(). Uses sys_now() to call timeout - * handler functions when timeouts expire. - * - * Must be called periodically from your main loop. - */ -void -sys_check_timeouts(void) -{ - if (next_timeout) { - struct sys_timeo *tmptimeout; - u32_t diff; - sys_timeout_handler handler; - void *arg; - u8_t had_one; - u32_t now; - - now = sys_now(); - /* this cares for wraparounds */ - diff = now - timeouts_last_time; - do - { -#if PBUF_POOL_FREE_OOSEQ - PBUF_CHECK_FREE_OOSEQ(); -#endif /* PBUF_POOL_FREE_OOSEQ */ - had_one = 0; - tmptimeout = next_timeout; - if (tmptimeout && (tmptimeout->time <= diff)) { - /* timeout has expired */ - had_one = 1; - timeouts_last_time = now; - diff -= tmptimeout->time; - next_timeout = tmptimeout->next; - handler = tmptimeout->h; - arg = tmptimeout->arg; -#if LWIP_DEBUG_TIMERNAMES - if (handler != NULL) { - LWIP_DEBUGF(TIMERS_DEBUG, ("sct calling h=%s arg=%p\n", - tmptimeout->handler_name, arg)); - } -#endif /* LWIP_DEBUG_TIMERNAMES */ - memp_free(MEMP_SYS_TIMEOUT, tmptimeout); - if (handler != NULL) { - handler(arg); - } - } - /* repeat until all expired timers have been called */ - }while(had_one); - } -} - -/** Set back the timestamp of the last call to sys_check_timeouts() - * This is necessary if sys_check_timeouts() hasn't been called for a long - * time (e.g. while saving energy) to prevent all timer functions of that - * period being called. - */ -void -sys_restart_timeouts(void) -{ - timeouts_last_time = sys_now(); -} - -#else /* NO_SYS */ - -/** - * Wait (forever) for a message to arrive in an mbox. - * While waiting, timeouts are processed. - * - * @param mbox the mbox to fetch the message from - * @param msg the place to store the message - */ -void -sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg) -{ - u32_t time_needed; - struct sys_timeo *tmptimeout; - sys_timeout_handler handler; - void *arg; - - again: - if (!next_timeout) { - time_needed = sys_arch_mbox_fetch(mbox, msg, 0); - } else { - if (next_timeout->time > 0) { - time_needed = sys_arch_mbox_fetch(mbox, msg, next_timeout->time); - } else { - time_needed = SYS_ARCH_TIMEOUT; - } - - if (time_needed == SYS_ARCH_TIMEOUT) { - /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message - could be fetched. We should now call the timeout handler and - deallocate the memory allocated for the timeout. */ - tmptimeout = next_timeout; - next_timeout = tmptimeout->next; - handler = tmptimeout->h; - arg = tmptimeout->arg; -#if LWIP_DEBUG_TIMERNAMES - if (handler != NULL) { - LWIP_DEBUGF(TIMERS_DEBUG, ("stmf calling h=%s arg=%p\n", - tmptimeout->handler_name, arg)); - } -#endif /* LWIP_DEBUG_TIMERNAMES */ - memp_free(MEMP_SYS_TIMEOUT, tmptimeout); - if (handler != NULL) { - /* For LWIP_TCPIP_CORE_LOCKING, lock the core before calling the - timeout handler function. */ - LOCK_TCPIP_CORE(); - handler(arg); - UNLOCK_TCPIP_CORE(); - } - LWIP_TCPIP_THREAD_ALIVE(); - - /* We try again to fetch a message from the mbox. */ - goto again; - } else { - /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout - occured. The time variable is set to the number of - milliseconds we waited for the message. */ - if (time_needed < next_timeout->time) { - next_timeout->time -= time_needed; - } else { - next_timeout->time = 0; - } - } - } -} - -#endif /* NO_SYS */ - -#else /* LWIP_TIMERS */ -/* Satisfy the TCP code which calls this function */ -void -tcp_timer_needed(void) -{ -} -#endif /* LWIP_TIMERS */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/udp.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/udp.c deleted file mode 100644 index ac0e56d1..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/core/udp.c +++ /dev/null @@ -1,1151 +0,0 @@ -/** - * @file - * User Datagram Protocol module - * - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - - -/* udp.c - * - * The code for the User Datagram Protocol UDP & UDPLite (RFC 3828). - * - */ - -/* @todo Check the use of '(struct udp_pcb).chksum_len_rx'! - */ - -#include "lwip/opt.h" - -#if LWIP_UDP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/udp.h" -#include "lwip/def.h" -#include "lwip/memp.h" -#include "lwip/inet_chksum.h" -#include "lwip/ip_addr.h" -#include "lwip/ip6.h" -#include "lwip/ip6_addr.h" -#include "lwip/inet_chksum.h" -#include "lwip/netif.h" -#include "lwip/icmp.h" -#include "lwip/icmp6.h" -#include "lwip/stats.h" -#include "lwip/snmp.h" -#include "arch/perf.h" -#include "lwip/dhcp.h" - -#include - -#ifndef UDP_LOCAL_PORT_RANGE_START -/* From http://www.iana.org/assignments/port-numbers: - "The Dynamic and/or Private Ports are those from 49152 through 65535" */ -#define UDP_LOCAL_PORT_RANGE_START 0xc000 -#define UDP_LOCAL_PORT_RANGE_END 0xffff -#define UDP_ENSURE_LOCAL_PORT_RANGE(port) (((port) & ~UDP_LOCAL_PORT_RANGE_START) + UDP_LOCAL_PORT_RANGE_START) -#endif - -/* last local UDP port */ -static u16_t udp_port = UDP_LOCAL_PORT_RANGE_START; - -/* The list of UDP PCBs */ -/* exported in udp.h (was static) */ -struct udp_pcb *udp_pcbs; - -/** - * Initialize this module. - */ -void -udp_init(void) -{ -#if LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) - udp_port = UDP_ENSURE_LOCAL_PORT_RANGE(LWIP_RAND()); -#endif /* LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS && defined(LWIP_RAND) */ -} - -/** - * Allocate a new local UDP port. - * - * @return a new (free) local UDP port number - */ -static u16_t -udp_new_port(void) -{ - u16_t n = 0; - struct udp_pcb *pcb; - -again: - if (udp_port++ == UDP_LOCAL_PORT_RANGE_END) { - udp_port = UDP_LOCAL_PORT_RANGE_START; - } - /* Check all PCBs. */ - for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { - if (pcb->local_port == udp_port) { - if (++n > (UDP_LOCAL_PORT_RANGE_END - UDP_LOCAL_PORT_RANGE_START)) { - return 0; - } - goto again; - } - } - return udp_port; -#if 0 - struct udp_pcb *ipcb = udp_pcbs; - while ((ipcb != NULL) && (udp_port != UDP_LOCAL_PORT_RANGE_END)) { - if (ipcb->local_port == udp_port) { - /* port is already used by another udp_pcb */ - udp_port++; - /* restart scanning all udp pcbs */ - ipcb = udp_pcbs; - } else { - /* go on with next udp pcb */ - ipcb = ipcb->next; - } - } - if (ipcb != NULL) { - return 0; - } - return udp_port; -#endif -} - -/** - * Process an incoming UDP datagram. - * - * Given an incoming UDP datagram (as a chain of pbufs) this function - * finds a corresponding UDP PCB and hands over the pbuf to the pcbs - * recv function. If no pcb is found or the datagram is incorrect, the - * pbuf is freed. - * - * @param p pbuf to be demultiplexed to a UDP PCB (p->payload pointing to the UDP header) - * @param inp network interface on which the datagram was received. - * - */ -void -udp_input(struct pbuf *p, struct netif *inp) -{ - struct udp_hdr *udphdr; - struct udp_pcb *pcb, *prev; - struct udp_pcb *uncon_pcb; - u16_t src, dest; - u8_t local_match; - u8_t broadcast; - u8_t for_us; - - PERF_START; - - UDP_STATS_INC(udp.recv); - - /* Check minimum length (UDP header) */ - if (p->len < UDP_HLEN) { - /* drop short packets */ - LWIP_DEBUGF(UDP_DEBUG, - ("udp_input: short UDP datagram (%"U16_F" bytes) discarded\n", p->tot_len)); - UDP_STATS_INC(udp.lenerr); - UDP_STATS_INC(udp.drop); - snmp_inc_udpinerrors(); - pbuf_free(p); - goto end; - } - - udphdr = (struct udp_hdr *)p->payload; - - /* is broadcast packet ? */ -#if LWIP_IPV6 - broadcast = !ip_current_is_v6() && ip_addr_isbroadcast(ip_current_dest_addr(), inp); -#else /* LWIP_IPV6 */ - broadcast = ip_addr_isbroadcast(ip_current_dest_addr(), inp); -#endif /* LWIP_IPV6 */ - - LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %"U16_F"\n", p->tot_len)); - - /* convert src and dest ports to host byte order */ - src = ntohs(udphdr->src); - dest = ntohs(udphdr->dest); - - udp_debug_print(udphdr); - - /* print the UDP source and destination */ - LWIP_DEBUGF(UDP_DEBUG, ("udp (")); - ipX_addr_debug_print(ip_current_is_v6(), UDP_DEBUG, ipX_current_dest_addr()); - LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F") <-- (", ntohs(udphdr->dest))); - ipX_addr_debug_print(ip_current_is_v6(), UDP_DEBUG, ipX_current_src_addr()); - LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F")\n", ntohs(udphdr->src))); - -#if LWIP_DHCP - pcb = NULL; - /* when LWIP_DHCP is active, packets to DHCP_CLIENT_PORT may only be processed by - the dhcp module, no other UDP pcb may use the local UDP port DHCP_CLIENT_PORT */ - if (dest == DHCP_CLIENT_PORT) { - /* all packets for DHCP_CLIENT_PORT not coming from DHCP_SERVER_PORT are dropped! */ - if (src == DHCP_SERVER_PORT) { - if ((inp->dhcp != NULL) && (inp->dhcp->pcb != NULL)) { - /* accept the packe if - (- broadcast or directed to us) -> DHCP is link-layer-addressed, local ip is always ANY! - - inp->dhcp->pcb->remote == ANY or iphdr->src - (no need to check for IPv6 since the dhcp struct always uses IPv4) */ - if (ipX_addr_isany(0, &inp->dhcp->pcb->remote_ip) || - ip_addr_cmp(ipX_2_ip(&(inp->dhcp->pcb->remote_ip)), ip_current_src_addr())) { - pcb = inp->dhcp->pcb; - } - } - } - } else -#endif /* LWIP_DHCP */ - { - prev = NULL; - local_match = 0; - uncon_pcb = NULL; - /* Iterate through the UDP pcb list for a matching pcb. - * 'Perfect match' pcbs (connected to the remote port & ip address) are - * preferred. If no perfect match is found, the first unconnected pcb that - * matches the local port and ip address gets the datagram. */ - for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { - local_match = 0; - /* print the PCB local and remote address */ - LWIP_DEBUGF(UDP_DEBUG, ("pcb (")); - ipX_addr_debug_print(PCB_ISIPV6(pcb), UDP_DEBUG, &pcb->local_ip); - LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F") <-- (", pcb->local_port)); - ipX_addr_debug_print(PCB_ISIPV6(pcb), UDP_DEBUG, &pcb->remote_ip); - LWIP_DEBUGF(UDP_DEBUG, (", %"U16_F")\n", pcb->remote_port)); - - /* compare PCB local addr+port to UDP destination addr+port */ - if (pcb->local_port == dest) { - if ( -#if LWIP_IPV6 - ((PCB_ISIPV6(pcb) && (ip_current_is_v6()) && - (ip6_addr_isany(ipX_2_ip6(&pcb->local_ip)) || -#if LWIP_IPV6_MLD - ip6_addr_ismulticast(ip6_current_dest_addr()) || -#endif /* LWIP_IPV6_MLD */ - ip6_addr_cmp(ipX_2_ip6(&pcb->local_ip), ip6_current_dest_addr()))) || - (!PCB_ISIPV6(pcb) && - (ip_current_header() != NULL) && -#else /* LWIP_IPV6 */ - (( -#endif /* LWIP_IPV6 */ - ((!broadcast && ipX_addr_isany(0, &pcb->local_ip)) || - ip_addr_cmp(ipX_2_ip(&pcb->local_ip), ip_current_dest_addr()) || -#if LWIP_IGMP - ip_addr_ismulticast(ip_current_dest_addr()) || -#endif /* LWIP_IGMP */ -#if IP_SOF_BROADCAST_RECV - (broadcast && ip_get_option(pcb, SOF_BROADCAST) && - (ipX_addr_isany(0, &pcb->local_ip) || - ip_addr_netcmp(ipX_2_ip(&pcb->local_ip), ip_current_dest_addr(), &inp->netmask))))))) { -#else /* IP_SOF_BROADCAST_RECV */ - (broadcast && - (ipX_addr_isany(0, &pcb->local_ip) || - ip_addr_netcmp(ipX_2_ip(&pcb->local_ip), ip_current_dest_addr(), &inp->netmask))))))) { -#endif /* IP_SOF_BROADCAST_RECV */ - local_match = 1; - if ((uncon_pcb == NULL) && - ((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) { - /* the first unconnected matching PCB */ - uncon_pcb = pcb; - } - } - } - /* compare PCB remote addr+port to UDP source addr+port */ - if ((local_match != 0) && - (pcb->remote_port == src) && IP_PCB_IPVER_INPUT_MATCH(pcb) && - (ipX_addr_isany(PCB_ISIPV6(pcb), &pcb->remote_ip) || - ipX_addr_cmp(PCB_ISIPV6(pcb), &pcb->remote_ip, ipX_current_src_addr()))) { - /* the first fully matching PCB */ - if (prev != NULL) { - /* move the pcb to the front of udp_pcbs so that is - found faster next time */ - prev->next = pcb->next; - pcb->next = udp_pcbs; - udp_pcbs = pcb; - } else { - UDP_STATS_INC(udp.cachehit); - } - break; - } - prev = pcb; - } - /* no fully matching pcb found? then look for an unconnected pcb */ - if (pcb == NULL) { - pcb = uncon_pcb; - } - } - - /* Check checksum if this is a match or if it was directed at us. */ - if (pcb != NULL) { - for_us = 1; - } else { -#if LWIP_IPV6 - if (ip_current_is_v6()) { - for_us = netif_matches_ip6_addr(inp, ip6_current_dest_addr()); - } else -#endif /* LWIP_IPV6 */ - { - for_us = ip_addr_cmp(&inp->ip_addr, ip_current_dest_addr()); - } - } - if (for_us) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: calculating checksum\n")); -#if CHECKSUM_CHECK_UDP -#if LWIP_UDPLITE - if (ip_current_header_proto() == IP_PROTO_UDPLITE) { - /* Do the UDP Lite checksum */ - u16_t chklen = ntohs(udphdr->len); - if (chklen < sizeof(struct udp_hdr)) { - if (chklen == 0) { - /* For UDP-Lite, checksum length of 0 means checksum - over the complete packet (See RFC 3828 chap. 3.1) */ - chklen = p->tot_len; - } else { - /* At least the UDP-Lite header must be covered by the - checksum! (Again, see RFC 3828 chap. 3.1) */ - goto chkerr; - } - } - if (ipX_chksum_pseudo_partial(ip_current_is_v6(), p, IP_PROTO_UDPLITE, - p->tot_len, chklen, - ipX_current_src_addr(), ipX_current_dest_addr()) != 0) { - goto chkerr; - } - } else -#endif /* LWIP_UDPLITE */ - { - if (udphdr->chksum != 0) { - if (ipX_chksum_pseudo(ip_current_is_v6(), p, IP_PROTO_UDP, p->tot_len, - ipX_current_src_addr(), - ipX_current_dest_addr()) != 0) { - goto chkerr; - } - } - } -#endif /* CHECKSUM_CHECK_UDP */ - if(pbuf_header(p, -UDP_HLEN)) { - /* Can we cope with this failing? Just assert for now */ - LWIP_ASSERT("pbuf_header failed\n", 0); - UDP_STATS_INC(udp.drop); - snmp_inc_udpinerrors(); - pbuf_free(p); - goto end; - } - if (pcb != NULL) { - snmp_inc_udpindatagrams(); -#if SO_REUSE && SO_REUSE_RXTOALL - if ((broadcast || -#if LWIP_IPV6 - ip6_addr_ismulticast(ip6_current_dest_addr()) || -#endif /* LWIP_IPV6 */ - ip_addr_ismulticast(ip_current_dest_addr())) && - ip_get_option(pcb, SOF_REUSEADDR)) { - /* pass broadcast- or multicast packets to all multicast pcbs - if SOF_REUSEADDR is set on the first match */ - struct udp_pcb *mpcb; - u8_t p_header_changed = 0; - s16_t hdrs_len = (s16_t)(ip_current_header_tot_len() + UDP_HLEN); - for (mpcb = udp_pcbs; mpcb != NULL; mpcb = mpcb->next) { - if (mpcb != pcb) { - /* compare PCB local addr+port to UDP destination addr+port */ - if ((mpcb->local_port == dest) && -#if LWIP_IPV6 - ((PCB_ISIPV6(mpcb) && - (ip6_addr_ismulticast(ip6_current_dest_addr()) || - ip6_addr_cmp(ipX_2_ip6(&mpcb->local_ip), ip6_current_dest_addr()))) || - (!PCB_ISIPV6(mpcb) && -#else /* LWIP_IPV6 */ - (( -#endif /* LWIP_IPV6 */ - ((!broadcast && ipX_addr_isany(0, &mpcb->local_ip)) || - ip_addr_cmp(ipX_2_ip(&mpcb->local_ip), ip_current_dest_addr()) || -#if LWIP_IGMP - ip_addr_ismulticast(ip_current_dest_addr()) || -#endif /* LWIP_IGMP */ -#if IP_SOF_BROADCAST_RECV - (broadcast && ip_get_option(mpcb, SOF_BROADCAST)))))) { -#else /* IP_SOF_BROADCAST_RECV */ - (broadcast))))) { -#endif /* IP_SOF_BROADCAST_RECV */ - /* pass a copy of the packet to all local matches */ - if (mpcb->recv.ip4 != NULL) { - struct pbuf *q; - /* for that, move payload to IP header again */ - if (p_header_changed == 0) { - pbuf_header(p, hdrs_len); - p_header_changed = 1; - } - q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); - if (q != NULL) { - err_t err = pbuf_copy(q, p); - if (err == ERR_OK) { - /* move payload to UDP data */ - pbuf_header(q, -hdrs_len); -#if LWIP_IPV6 - if (PCB_ISIPV6(mpcb)) { - mpcb->recv.ip6(mpcb->recv_arg, mpcb, q, ip6_current_src_addr(), src); - } - else -#endif /* LWIP_IPV6 */ - { - mpcb->recv.ip4(mpcb->recv_arg, mpcb, q, ip_current_src_addr(), src); - } - } - } - } - } - } - } - if (p_header_changed) { - /* and move payload to UDP data again */ - pbuf_header(p, -hdrs_len); - } - } -#endif /* SO_REUSE && SO_REUSE_RXTOALL */ - /* callback */ - if (pcb->recv.ip4 != NULL) { - /* now the recv function is responsible for freeing p */ -#if LWIP_IPV6 - if (PCB_ISIPV6(pcb)) { - pcb->recv.ip6(pcb->recv_arg, pcb, p, ip6_current_src_addr(), src); - } - else -#endif /* LWIP_IPV6 */ - { - pcb->recv.ip4(pcb->recv_arg, pcb, p, ip_current_src_addr(), src); - } - } else { - /* no recv function registered? then we have to free the pbuf! */ - pbuf_free(p); - goto end; - } - } else { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_input: not for us.\n")); - -#if LWIP_ICMP || LWIP_ICMP6 - /* No match was found, send ICMP destination port unreachable unless - destination address was broadcast/multicast. */ - if (!broadcast && -#if LWIP_IPV6 - !ip6_addr_ismulticast(ip6_current_dest_addr()) && -#endif /* LWIP_IPV6 */ - !ip_addr_ismulticast(ip_current_dest_addr())) { - /* move payload pointer back to ip header */ - pbuf_header(p, ip_current_header_tot_len() + UDP_HLEN); - icmp_port_unreach(ip_current_is_v6(), p); - } -#endif /* LWIP_ICMP || LWIP_ICMP6 */ - UDP_STATS_INC(udp.proterr); - UDP_STATS_INC(udp.drop); - snmp_inc_udpnoports(); - pbuf_free(p); - } - } else { - pbuf_free(p); - } -end: - PERF_STOP("udp_input"); - return; -#if CHECKSUM_CHECK_UDP -chkerr: - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("udp_input: UDP (or UDP Lite) datagram discarded due to failing checksum\n")); - UDP_STATS_INC(udp.chkerr); - UDP_STATS_INC(udp.drop); - snmp_inc_udpinerrors(); - pbuf_free(p); - PERF_STOP("udp_input"); -#endif /* CHECKSUM_CHECK_UDP */ -} - -/** - * Send data using UDP. - * - * @param pcb UDP PCB used to send the data. - * @param p chain of pbuf's to be sent. - * - * The datagram will be sent to the current remote_ip & remote_port - * stored in pcb. If the pcb is not bound to a port, it will - * automatically be bound to a random port. - * - * @return lwIP error code. - * - ERR_OK. Successful. No error occured. - * - ERR_MEM. Out of memory. - * - ERR_RTE. Could not find route to destination address. - * - More errors could be returned by lower protocol layers. - * - * @see udp_disconnect() udp_sendto() - */ -err_t -udp_send(struct udp_pcb *pcb, struct pbuf *p) -{ - /* send to the packet using remote ip and port stored in the pcb */ - return udp_sendto(pcb, p, ipX_2_ip(&pcb->remote_ip), pcb->remote_port); -} - -#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP -/** Same as udp_send() but with checksum - */ -err_t -udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, - u8_t have_chksum, u16_t chksum) -{ - /* send to the packet using remote ip and port stored in the pcb */ - return udp_sendto_chksum(pcb, p, ipX_2_ip(&pcb->remote_ip), pcb->remote_port, - have_chksum, chksum); -} -#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ - -/** - * Send data to a specified address using UDP. - * - * @param pcb UDP PCB used to send the data. - * @param p chain of pbuf's to be sent. - * @param dst_ip Destination IP address. - * @param dst_port Destination UDP port. - * - * dst_ip & dst_port are expected to be in the same byte order as in the pcb. - * - * If the PCB already has a remote address association, it will - * be restored after the data is sent. - * - * @return lwIP error code (@see udp_send for possible error codes) - * - * @see udp_disconnect() udp_send() - */ -err_t -udp_sendto(struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port) -{ -#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP - return udp_sendto_chksum(pcb, p, dst_ip, dst_port, 0, 0); -} - -/** Same as udp_sendto(), but with checksum */ -err_t -udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip, - u16_t dst_port, u8_t have_chksum, u16_t chksum) -{ -#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ - struct netif *netif; - ipX_addr_t *dst_ip_route = ip_2_ipX(dst_ip); - - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_send\n")); - -#if LWIP_IPV6 || LWIP_IGMP - if (ipX_addr_ismulticast(PCB_ISIPV6(pcb), dst_ip_route)) { - /* For multicast, find a netif based on source address. */ -#if LWIP_IPV6 - if (PCB_ISIPV6(pcb)) { - dst_ip_route = &pcb->local_ip; - } else -#endif /* LWIP_IPV6 */ - { -#if LWIP_IGMP - dst_ip_route = ip_2_ipX(&pcb->multicast_ip); -#endif /* LWIP_IGMP */ - } - } -#endif /* LWIP_IPV6 || LWIP_IGMP */ - - /* find the outgoing network interface for this packet */ - netif = ipX_route(PCB_ISIPV6(pcb), &pcb->local_ip, dst_ip_route); - - /* no outgoing network interface could be found? */ - if (netif == NULL) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("udp_send: No route to ")); - ipX_addr_debug_print(PCB_ISIPV6(pcb), UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ip_2_ipX(dst_ip)); - LWIP_DEBUGF(UDP_DEBUG, ("\n")); - UDP_STATS_INC(udp.rterr); - return ERR_RTE; - } -#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP - return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port, netif, have_chksum, chksum); -#else /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ - return udp_sendto_if(pcb, p, dst_ip, dst_port, netif); -#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ -} - -/** - * Send data to a specified address using UDP. - * The netif used for sending can be specified. - * - * This function exists mainly for DHCP, to be able to send UDP packets - * on a netif that is still down. - * - * @param pcb UDP PCB used to send the data. - * @param p chain of pbuf's to be sent. - * @param dst_ip Destination IP address. - * @param dst_port Destination UDP port. - * @param netif the netif used for sending. - * - * dst_ip & dst_port are expected to be in the same byte order as in the pcb. - * - * @return lwIP error code (@see udp_send for possible error codes) - * - * @see udp_disconnect() udp_send() - */ -err_t -udp_sendto_if(struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port, struct netif *netif) -{ -#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP - return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port, netif, 0, 0); -} - -/** Same as udp_sendto_if(), but with checksum */ -err_t -udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip, - u16_t dst_port, struct netif *netif, u8_t have_chksum, - u16_t chksum) -{ -#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ - struct udp_hdr *udphdr; - ip_addr_t *src_ip; - err_t err; - struct pbuf *q; /* q will be sent down the stack */ - u8_t ip_proto; - -#if IP_SOF_BROADCAST - /* broadcast filter? */ - if (!ip_get_option(pcb, SOF_BROADCAST) && -#if LWIP_IPV6 - !PCB_ISIPV6(pcb) && -#endif /* LWIP_IPV6 */ - ip_addr_isbroadcast(dst_ip, netif) ) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, - ("udp_sendto_if: SOF_BROADCAST not enabled on pcb %p\n", (void *)pcb)); - return ERR_VAL; - } -#endif /* IP_SOF_BROADCAST */ - - /* if the PCB is not yet bound to a port, bind it here */ - if (pcb->local_port == 0) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_send: not yet bound to a port, binding now\n")); - err = udp_bind(pcb, ipX_2_ip(&pcb->local_ip), pcb->local_port); - if (err != ERR_OK) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("udp_send: forced port bind failed\n")); - return err; - } - } - - /* not enough space to add an UDP header to first pbuf in given p chain? */ - if (pbuf_header(p, UDP_HLEN)) { - /* allocate header in a separate new pbuf */ - q = pbuf_alloc(PBUF_IP, UDP_HLEN, PBUF_RAM); - /* new header pbuf could not be allocated? */ - if (q == NULL) { - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_SERIOUS, ("udp_send: could not allocate header\n")); - return ERR_MEM; - } - if (p->tot_len != 0) { - /* chain header q in front of given pbuf p (only if p contains data) */ - pbuf_chain(q, p); - } - /* first pbuf q points to header pbuf */ - LWIP_DEBUGF(UDP_DEBUG, - ("udp_send: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p)); - } else { - /* adding space for header within p succeeded */ - /* first pbuf q equals given pbuf */ - q = p; - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: added header in given pbuf %p\n", (void *)p)); - } - LWIP_ASSERT("check that first pbuf can hold struct udp_hdr", - (q->len >= sizeof(struct udp_hdr))); - /* q now represents the packet to be sent */ - udphdr = (struct udp_hdr *)q->payload; - udphdr->src = htons(pcb->local_port); - udphdr->dest = htons(dst_port); - /* in UDP, 0 checksum means 'no checksum' */ - udphdr->chksum = 0x0000; - - /* Multicast Loop? */ -#if LWIP_IGMP - if (((pcb->flags & UDP_FLAGS_MULTICAST_LOOP) != 0) && -#if LWIP_IPV6 - ( -#if LWIP_IPV6_MLD - (PCB_ISIPV6(pcb) && - ip6_addr_ismulticast(ip_2_ip6(dst_ip))) || -#endif /* LWIP_IPV6_MLD */ - (!PCB_ISIPV6(pcb) && -#else /* LWIP_IPV6 */ - (( -#endif /* LWIP_IPV6 */ - ip_addr_ismulticast(dst_ip)))) { - q->flags |= PBUF_FLAG_MCASTLOOP; - } -#endif /* LWIP_IGMP */ - - - /* PCB local address is IP_ANY_ADDR? */ -#if LWIP_IPV6 - if (PCB_ISIPV6(pcb)) { - if (ip6_addr_isany(ipX_2_ip6(&pcb->local_ip))) { - src_ip = ip6_2_ip(ip6_select_source_address(netif, ip_2_ip6(dst_ip))); - if (src_ip == NULL) { - /* No suitable source address was found. */ - if (q != p) { - /* free the header pbuf */ - pbuf_free(q); - /* p is still referenced by the caller, and will live on */ - } - return ERR_RTE; - } - } else { - /* use UDP PCB local IPv6 address as source address, if still valid. */ - if (netif_matches_ip6_addr(netif, ipX_2_ip6(&pcb->local_ip)) < 0) { - /* Address isn't valid anymore. */ - if (q != p) { - /* free the header pbuf */ - pbuf_free(q); - /* p is still referenced by the caller, and will live on */ - } - return ERR_RTE; - } - src_ip = ipX_2_ip(&pcb->local_ip); - } - } - else -#endif /* LWIP_IPV6 */ - if (ip_addr_isany(ipX_2_ip(&pcb->local_ip))) { - /* use outgoing network interface IP address as source address */ - src_ip = &(netif->ip_addr); - } else { - /* check if UDP PCB local IP address is correct - * this could be an old address if netif->ip_addr has changed */ - if (!ip_addr_cmp(ipX_2_ip(&(pcb->local_ip)), &(netif->ip_addr))) { - /* local_ip doesn't match, drop the packet */ - if (q != p) { - /* free the header pbuf */ - pbuf_free(q); - q = NULL; - /* p is still referenced by the caller, and will live on */ - } - return ERR_VAL; - } - /* use UDP PCB local IP address as source address */ - src_ip = ipX_2_ip(&(pcb->local_ip)); - } - - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %"U16_F"\n", q->tot_len)); - -#if LWIP_UDPLITE - /* UDP Lite protocol? */ - if (pcb->flags & UDP_FLAGS_UDPLITE) { - u16_t chklen, chklen_hdr; - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %"U16_F"\n", q->tot_len)); - /* set UDP message length in UDP header */ - chklen_hdr = chklen = pcb->chksum_len_tx; - if ((chklen < sizeof(struct udp_hdr)) || (chklen > q->tot_len)) { - if (chklen != 0) { - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE pcb->chksum_len is illegal: %"U16_F"\n", chklen)); - } - /* For UDP-Lite, checksum length of 0 means checksum - over the complete packet. (See RFC 3828 chap. 3.1) - At least the UDP-Lite header must be covered by the - checksum, therefore, if chksum_len has an illegal - value, we generate the checksum over the complete - packet to be safe. */ - chklen_hdr = 0; - chklen = q->tot_len; - } - udphdr->len = htons(chklen_hdr); - /* calculate checksum */ -#if CHECKSUM_GEN_UDP -#if LWIP_CHECKSUM_ON_COPY - if (have_chksum) { - chklen = UDP_HLEN; - } -#endif /* LWIP_CHECKSUM_ON_COPY */ - udphdr->chksum = ipX_chksum_pseudo_partial(PCB_ISIPV6(pcb), q, IP_PROTO_UDPLITE, - q->tot_len, chklen, ip_2_ipX(src_ip), ip_2_ipX(dst_ip)); -#if LWIP_CHECKSUM_ON_COPY - if (have_chksum) { - u32_t acc; - acc = udphdr->chksum + (u16_t)~(chksum); - udphdr->chksum = FOLD_U32T(acc); - } -#endif /* LWIP_CHECKSUM_ON_COPY */ - - /* chksum zero must become 0xffff, as zero means 'no checksum' */ - if (udphdr->chksum == 0x0000) { - udphdr->chksum = 0xffff; - } -#endif /* CHECKSUM_GEN_UDP */ - - ip_proto = IP_PROTO_UDPLITE; - } else -#endif /* LWIP_UDPLITE */ - { /* UDP */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %"U16_F"\n", q->tot_len)); - udphdr->len = htons(q->tot_len); - /* calculate checksum */ -#if CHECKSUM_GEN_UDP - /* Checksum is mandatory over IPv6. */ - if (PCB_ISIPV6(pcb) || (pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) { - u16_t udpchksum; -#if LWIP_CHECKSUM_ON_COPY - if (have_chksum) { - u32_t acc; - udpchksum = ipX_chksum_pseudo_partial(PCB_ISIPV6(pcb), q, IP_PROTO_UDP, - q->tot_len, UDP_HLEN, ip_2_ipX(src_ip), ip_2_ipX(dst_ip)); - acc = udpchksum + (u16_t)~(chksum); - udpchksum = FOLD_U32T(acc); - } else -#endif /* LWIP_CHECKSUM_ON_COPY */ - { - udpchksum = ipX_chksum_pseudo(PCB_ISIPV6(pcb), q, IP_PROTO_UDP, q->tot_len, - ip_2_ipX(src_ip), ip_2_ipX(dst_ip)); - } - - /* chksum zero must become 0xffff, as zero means 'no checksum' */ - if (udpchksum == 0x0000) { - udpchksum = 0xffff; - } - udphdr->chksum = udpchksum; - } -#endif /* CHECKSUM_GEN_UDP */ - ip_proto = IP_PROTO_UDP; - } - - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04"X16_F"\n", udphdr->chksum)); - LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,0x%02"X16_F",)\n", (u16_t)ip_proto)); - /* output to IP */ - NETIF_SET_HWADDRHINT(netif, &(pcb->addr_hint)); - err = ipX_output_if(PCB_ISIPV6(pcb), q, src_ip, dst_ip, pcb->ttl, pcb->tos, ip_proto, netif); - NETIF_SET_HWADDRHINT(netif, NULL); - - /* TODO: must this be increased even if error occured? */ - snmp_inc_udpoutdatagrams(); - - /* did we chain a separate header pbuf earlier? */ - if (q != p) { - /* free the header pbuf */ - pbuf_free(q); - q = NULL; - /* p is still referenced by the caller, and will live on */ - } - - UDP_STATS_INC(udp.xmit); - return err; -} - -/** - * Bind an UDP PCB. - * - * @param pcb UDP PCB to be bound with a local address ipaddr and port. - * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to - * bind to all local interfaces. - * @param port local UDP port to bind with. Use 0 to automatically bind - * to a random port between UDP_LOCAL_PORT_RANGE_START and - * UDP_LOCAL_PORT_RANGE_END. - * - * ipaddr & port are expected to be in the same byte order as in the pcb. - * - * @return lwIP error code. - * - ERR_OK. Successful. No error occured. - * - ERR_USE. The specified ipaddr and port are already bound to by - * another UDP PCB. - * - * @see udp_disconnect() - */ -err_t -udp_bind(struct udp_pcb *pcb, ip_addr_t *ipaddr, u16_t port) -{ - struct udp_pcb *ipcb; - u8_t rebind; - - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_bind(ipaddr = ")); - ipX_addr_debug_print(PCB_ISIPV6(pcb), UDP_DEBUG | LWIP_DBG_TRACE, ip_2_ipX(ipaddr)); - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, (", port = %"U16_F")\n", port)); - - rebind = 0; - /* Check for double bind and rebind of the same pcb */ - for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { - /* is this UDP PCB already on active list? */ - if (pcb == ipcb) { - /* pcb may occur at most once in active list */ - LWIP_ASSERT("rebind == 0", rebind == 0); - /* pcb already in list, just rebind */ - rebind = 1; - } - - /* By default, we don't allow to bind to a port that any other udp - PCB is alread bound to, unless *all* PCBs with that port have tha - REUSEADDR flag set. */ -#if SO_REUSE - else if (!ip_get_option(pcb, SOF_REUSEADDR) && - !ip_get_option(ipcb, SOF_REUSEADDR)) { -#else /* SO_REUSE */ - /* port matches that of PCB in list and REUSEADDR not set -> reject */ - else { -#endif /* SO_REUSE */ - if ((ipcb->local_port == port) && IP_PCB_IPVER_EQ(pcb, ipcb) && - /* IP address matches, or one is IP_ADDR_ANY? */ - (ipX_addr_isany(PCB_ISIPV6(ipcb), &(ipcb->local_ip)) || - ipX_addr_isany(PCB_ISIPV6(ipcb), ip_2_ipX(ipaddr)) || - ipX_addr_cmp(PCB_ISIPV6(ipcb), &(ipcb->local_ip), ip_2_ipX(ipaddr)))) { - /* other PCB already binds to this local IP and port */ - LWIP_DEBUGF(UDP_DEBUG, - ("udp_bind: local port %"U16_F" already bound by another pcb\n", port)); - return ERR_USE; - } - } - } - - ipX_addr_set_ipaddr(PCB_ISIPV6(pcb), &pcb->local_ip, ipaddr); - - /* no port specified? */ - if (port == 0) { - port = udp_new_port(); - if (port == 0) { - /* no more ports available in local range */ - LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: out of free UDP ports\n")); - return ERR_USE; - } - } - pcb->local_port = port; - snmp_insert_udpidx_tree(pcb); - /* pcb not active yet? */ - if (rebind == 0) { - /* place the PCB on the active list if not already there */ - pcb->next = udp_pcbs; - udp_pcbs = pcb; - } - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("udp_bind: bound to ")); - ipX_addr_debug_print(PCB_ISIPV6(pcb), UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, &pcb->local_ip); - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, (", port %"U16_F")\n", pcb->local_port)); - return ERR_OK; -} - -/** - * Connect an UDP PCB. - * - * This will associate the UDP PCB with the remote address. - * - * @param pcb UDP PCB to be connected with remote address ipaddr and port. - * @param ipaddr remote IP address to connect with. - * @param port remote UDP port to connect with. - * - * @return lwIP error code - * - * ipaddr & port are expected to be in the same byte order as in the pcb. - * - * The udp pcb is bound to a random local port if not already bound. - * - * @see udp_disconnect() - */ -err_t -udp_connect(struct udp_pcb *pcb, ip_addr_t *ipaddr, u16_t port) -{ - struct udp_pcb *ipcb; - - if (pcb->local_port == 0) { - err_t err = udp_bind(pcb, ipX_2_ip(&pcb->local_ip), pcb->local_port); - if (err != ERR_OK) { - return err; - } - } - - ipX_addr_set_ipaddr(PCB_ISIPV6(pcb), &pcb->remote_ip, ipaddr); - pcb->remote_port = port; - pcb->flags |= UDP_FLAGS_CONNECTED; -/** TODO: this functionality belongs in upper layers */ -#ifdef LWIP_UDP_TODO -#if LWIP_IPV6 - if (!PCB_ISIPV6(pcb)) -#endif /* LWIP_IPV6 */ - { - /* Nail down local IP for netconn_addr()/getsockname() */ - if (ip_addr_isany(ipX_2_ip(&pcb->local_ip)) && !ip_addr_isany(ipX_2_ip(&pcb->remote_ip))) { - struct netif *netif; - - if ((netif = ip_route(ipX_2_ip(&pcb->remote_ip))) == NULL) { - LWIP_DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", - ip4_addr_get_u32(ipX_2_ip(&pcb->remote_ip)))); - UDP_STATS_INC(udp.rterr); - return ERR_RTE; - } - /** TODO: this will bind the udp pcb locally, to the interface which - is used to route output packets to the remote address. However, we - might want to accept incoming packets on any interface! */ - ipX_addr_copy(0, pcb->local_ip, netif->ip_addr); - } else if (ip_addr_isany(ipX_2_ip(&pcb->remote_ip))) { - ipX_addr_set_any(0, &pcb->local_ip); - } - } -#endif - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("udp_connect: connected to ")); - ipX_addr_debug_print(PCB_ISIPV6(pcb), UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, - &pcb->remote_ip); - LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, (", port %"U16_F")\n", pcb->remote_port)); - - /* Insert UDP PCB into the list of active UDP PCBs. */ - for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { - if (pcb == ipcb) { - /* already on the list, just return */ - return ERR_OK; - } - } - /* PCB not yet on the list, add PCB now */ - pcb->next = udp_pcbs; - udp_pcbs = pcb; - return ERR_OK; -} - -/** - * Disconnect a UDP PCB - * - * @param pcb the udp pcb to disconnect. - */ -void -udp_disconnect(struct udp_pcb *pcb) -{ - /* reset remote address association */ - ipX_addr_set_any(PCB_ISIPV6(pcb), &pcb->remote_ip); - pcb->remote_port = 0; - /* mark PCB as unconnected */ - pcb->flags &= ~UDP_FLAGS_CONNECTED; -} - -/** - * Set a receive callback for a UDP PCB - * - * This callback will be called when receiving a datagram for the pcb. - * - * @param pcb the pcb for wich to set the recv callback - * @param recv function pointer of the callback function - * @param recv_arg additional argument to pass to the callback function - */ -void -udp_recv(struct udp_pcb *pcb, udp_recv_fn recv, void *recv_arg) -{ - /* remember recv() callback and user data */ - pcb->recv.ip4 = recv; - pcb->recv_arg = recv_arg; -} - -/** - * Remove an UDP PCB. - * - * @param pcb UDP PCB to be removed. The PCB is removed from the list of - * UDP PCB's and the data structure is freed from memory. - * - * @see udp_new() - */ -void -udp_remove(struct udp_pcb *pcb) -{ - struct udp_pcb *pcb2; - - snmp_delete_udpidx_tree(pcb); - /* pcb to be removed is first in list? */ - if (udp_pcbs == pcb) { - /* make list start at 2nd pcb */ - udp_pcbs = udp_pcbs->next; - /* pcb not 1st in list */ - } else { - for (pcb2 = udp_pcbs; pcb2 != NULL; pcb2 = pcb2->next) { - /* find pcb in udp_pcbs list */ - if (pcb2->next != NULL && pcb2->next == pcb) { - /* remove pcb from list */ - pcb2->next = pcb->next; - } - } - } - memp_free(MEMP_UDP_PCB, pcb); -} - -/** - * Create a UDP PCB. - * - * @return The UDP PCB which was created. NULL if the PCB data structure - * could not be allocated. - * - * @see udp_remove() - */ -struct udp_pcb * -udp_new(void) -{ - struct udp_pcb *pcb; - pcb = (struct udp_pcb *)memp_malloc(MEMP_UDP_PCB); - /* could allocate UDP PCB? */ - if (pcb != NULL) { - /* UDP Lite: by initializing to all zeroes, chksum_len is set to 0 - * which means checksum is generated over the whole datagram per default - * (recommended as default by RFC 3828). */ - /* initialize PCB to all zeroes */ - memset(pcb, 0, sizeof(struct udp_pcb)); - pcb->ttl = UDP_TTL; - } - return pcb; -} - -#if LWIP_IPV6 -/** - * Create a UDP PCB for IPv6. - * - * @return The UDP PCB which was created. NULL if the PCB data structure - * could not be allocated. - * - * @see udp_remove() - */ -struct udp_pcb * -udp_new_ip6(void) -{ - struct udp_pcb *pcb; - pcb = udp_new(); - ip_set_v6(pcb, 1); - return pcb; -} -#endif /* LWIP_IPV6 */ - -#if UDP_DEBUG -/** - * Print UDP header information for debug purposes. - * - * @param udphdr pointer to the udp header in memory. - */ -void -udp_debug_print(struct udp_hdr *udphdr) -{ - LWIP_DEBUGF(UDP_DEBUG, ("UDP header:\n")); - LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | %5"U16_F" | (src port, dest port)\n", - ntohs(udphdr->src), ntohs(udphdr->dest))); - LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); - LWIP_DEBUGF(UDP_DEBUG, ("| %5"U16_F" | 0x%04"X16_F" | (len, chksum)\n", - ntohs(udphdr->len), ntohs(udphdr->chksum))); - LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); -} -#endif /* UDP_DEBUG */ - -#endif /* LWIP_UDP */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/autoip.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/autoip.h deleted file mode 100644 index e62b72e8..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/autoip.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @file - * - * AutoIP Automatic LinkLocal IP Configuration - */ - -/* - * - * Copyright (c) 2007 Dominik Spies - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Dominik Spies - * - * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform - * with RFC 3927. - * - * - * Please coordinate changes and requests with Dominik Spies - * - */ - -#ifndef __LWIP_AUTOIP_H__ -#define __LWIP_AUTOIP_H__ - -#include "lwip/opt.h" - -#if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/netif.h" -#include "lwip/udp.h" -#include "netif/etharp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* AutoIP Timing */ -#define AUTOIP_TMR_INTERVAL 100 -#define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL) - -/* RFC 3927 Constants */ -#define PROBE_WAIT 1 /* second (initial random delay) */ -#define PROBE_MIN 1 /* second (minimum delay till repeated probe) */ -#define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */ -#define PROBE_NUM 3 /* (number of probe packets) */ -#define ANNOUNCE_NUM 2 /* (number of announcement packets) */ -#define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */ -#define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */ -#define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */ -#define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */ -#define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */ - -/* AutoIP client states */ -#define AUTOIP_STATE_OFF 0 -#define AUTOIP_STATE_PROBING 1 -#define AUTOIP_STATE_ANNOUNCING 2 -#define AUTOIP_STATE_BOUND 3 - -struct autoip -{ - ip_addr_t llipaddr; /* the currently selected, probed, announced or used LL IP-Address */ - u8_t state; /* current AutoIP state machine state */ - u8_t sent_num; /* sent number of probes or announces, dependent on state */ - u16_t ttw; /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */ - u8_t lastconflict; /* ticks until a conflict can be solved by defending */ - u8_t tried_llipaddr; /* total number of probed/used Link Local IP-Addresses */ -}; - - -#define autoip_init() /* Compatibility define, no init needed. */ - -/** Set a struct autoip allocated by the application to work with */ -void autoip_set_struct(struct netif *netif, struct autoip *autoip); - -/** Start AutoIP client */ -err_t autoip_start(struct netif *netif); - -/** Stop AutoIP client */ -err_t autoip_stop(struct netif *netif); - -/** Handles every incoming ARP Packet, called by etharp_arp_input */ -void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr); - -/** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */ -void autoip_tmr(void); - -/** Handle a possible change in the network configuration */ -void autoip_network_changed(struct netif *netif); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_AUTOIP */ - -#endif /* __LWIP_AUTOIP_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/icmp.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/icmp.h deleted file mode 100644 index fa893b6b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/icmp.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_ICMP_H__ -#define __LWIP_ICMP_H__ - -#include "lwip/opt.h" -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" - -#if LWIP_IPV6 && LWIP_ICMP6 -#include "lwip/icmp6.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define ICMP_ER 0 /* echo reply */ -#define ICMP_DUR 3 /* destination unreachable */ -#define ICMP_SQ 4 /* source quench */ -#define ICMP_RD 5 /* redirect */ -#define ICMP_ECHO 8 /* echo */ -#define ICMP_TE 11 /* time exceeded */ -#define ICMP_PP 12 /* parameter problem */ -#define ICMP_TS 13 /* timestamp */ -#define ICMP_TSR 14 /* timestamp reply */ -#define ICMP_IRQ 15 /* information request */ -#define ICMP_IR 16 /* information reply */ - -enum icmp_dur_type { - ICMP_DUR_NET = 0, /* net unreachable */ - ICMP_DUR_HOST = 1, /* host unreachable */ - ICMP_DUR_PROTO = 2, /* protocol unreachable */ - ICMP_DUR_PORT = 3, /* port unreachable */ - ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ - ICMP_DUR_SR = 5 /* source route failed */ -}; - -enum icmp_te_type { - ICMP_TE_TTL = 0, /* time to live exceeded in transit */ - ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ -}; - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -/** This is the standard ICMP header only that the u32_t data - * is splitted to two u16_t like ICMP echo needs it. - * This header is also used for other ICMP types that do not - * use the data part. - */ -PACK_STRUCT_BEGIN -struct icmp_echo_hdr { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u16_t id); - PACK_STRUCT_FIELD(u16_t seqno); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define ICMPH_TYPE(hdr) ((hdr)->type) -#define ICMPH_CODE(hdr) ((hdr)->code) - -/** Combines type and code to an u16_t */ -#define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t)) -#define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c)) - - -#if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */ - -void icmp_input(struct pbuf *p, struct netif *inp); -void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t); -void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t); - -#endif /* LWIP_ICMP */ - -#if (LWIP_IPV6 && LWIP_ICMP6) -#define icmp_port_unreach(isipv6, pbuf) ((isipv6) ? \ - icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT) : \ - icmp_dest_unreach(pbuf, ICMP_DUR_PORT)) -#elif LWIP_ICMP -#define icmp_port_unreach(isipv6, pbuf) icmp_dest_unreach(pbuf, ICMP_DUR_PORT) -#else /* (LWIP_IPV6 && LWIP_ICMP6) || LWIP_ICMP*/ -#define icmp_port_unreach(isipv6, pbuf) -#endif /* (LWIP_IPV6 && LWIP_ICMP6) || LWIP_ICMP*/ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_ICMP_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/igmp.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/igmp.h deleted file mode 100644 index 8aabac24..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/igmp.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2002 CITEL Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is a contribution to the lwIP TCP/IP stack. - * The Swedish Institute of Computer Science and Adam Dunkels - * are specifically granted permission to redistribute this - * source code. -*/ - -#ifndef __LWIP_IGMP_H__ -#define __LWIP_IGMP_H__ - -#include "lwip/opt.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/pbuf.h" - -#if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */ - -#ifdef __cplusplus -extern "C" { -#endif - - -/* IGMP timer */ -#define IGMP_TMR_INTERVAL 100 /* Milliseconds */ -#define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL) -#define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL) - -/* MAC Filter Actions, these are passed to a netif's - * igmp_mac_filter callback function. */ -#define IGMP_DEL_MAC_FILTER 0 -#define IGMP_ADD_MAC_FILTER 1 - - -/** - * igmp group structure - there is - * a list of groups for each interface - * these should really be linked from the interface, but - * if we keep them separate we will not affect the lwip original code - * too much - * - * There will be a group for the all systems group address but this - * will not run the state machine as it is used to kick off reports - * from all the other groups - */ -struct igmp_group { - /** next link */ - struct igmp_group *next; - /** interface on which the group is active */ - struct netif *netif; - /** multicast address */ - ip_addr_t group_address; - /** signifies we were the last person to report */ - u8_t last_reporter_flag; - /** current state of the group */ - u8_t group_state; - /** timer for reporting, negative is OFF */ - u16_t timer; - /** counter of simultaneous uses */ - u8_t use; -}; - -/* Prototypes */ -void igmp_init(void); -err_t igmp_start(struct netif *netif); -err_t igmp_stop(struct netif *netif); -void igmp_report_groups(struct netif *netif); -struct igmp_group *igmp_lookfor_group(struct netif *ifp, ip_addr_t *addr); -void igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest); -err_t igmp_joingroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); -err_t igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr); -void igmp_tmr(void); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IGMP */ - -#endif /* __LWIP_IGMP_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/inet.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/inet.h deleted file mode 100644 index 7bff49b5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/inet.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_INET_H__ -#define __LWIP_INET_H__ - -#include "lwip/opt.h" -#include "lwip/def.h" -#include "lwip/ip_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** For compatibility with BSD code */ -struct in_addr { - u32_t s_addr; -}; - -/** 255.255.255.255 */ -#define INADDR_NONE IPADDR_NONE -/** 127.0.0.1 */ -#define INADDR_LOOPBACK IPADDR_LOOPBACK -/** 0.0.0.0 */ -#define INADDR_ANY IPADDR_ANY -/** 255.255.255.255 */ -#define INADDR_BROADCAST IPADDR_BROADCAST - -/* Definitions of the bits in an Internet address integer. - - On subnets, host and network parts are found according to - the subnet mask, not these masks. */ -#define IN_CLASSA(a) IP_CLASSA(a) -#define IN_CLASSA_NET IP_CLASSA_NET -#define IN_CLASSA_NSHIFT IP_CLASSA_NSHIFT -#define IN_CLASSA_HOST IP_CLASSA_HOST -#define IN_CLASSA_MAX IP_CLASSA_MAX - -#define IN_CLASSB(b) IP_CLASSB(b) -#define IN_CLASSB_NET IP_CLASSB_NET -#define IN_CLASSB_NSHIFT IP_CLASSB_NSHIFT -#define IN_CLASSB_HOST IP_CLASSB_HOST -#define IN_CLASSB_MAX IP_CLASSB_MAX - -#define IN_CLASSC(c) IP_CLASSC(c) -#define IN_CLASSC_NET IP_CLASSC_NET -#define IN_CLASSC_NSHIFT IP_CLASSC_NSHIFT -#define IN_CLASSC_HOST IP_CLASSC_HOST -#define IN_CLASSC_MAX IP_CLASSC_MAX - -#define IN_CLASSD(d) IP_CLASSD(d) -#define IN_CLASSD_NET IP_CLASSD_NET /* These ones aren't really */ -#define IN_CLASSD_NSHIFT IP_CLASSD_NSHIFT /* net and host fields, but */ -#define IN_CLASSD_HOST IP_CLASSD_HOST /* routing needn't know. */ -#define IN_CLASSD_MAX IP_CLASSD_MAX - -#define IN_MULTICAST(a) IP_MULTICAST(a) - -#define IN_EXPERIMENTAL(a) IP_EXPERIMENTAL(a) -#define IN_BADCLASS(a) IP_BADCLASS(a) - -#define IN_LOOPBACKNET IP_LOOPBACKNET - -#define inet_addr_from_ipaddr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr)) -#define inet_addr_to_ipaddr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr)) -/* ATTENTION: the next define only works because both s_addr and ip_addr_t are an u32_t effectively! */ -#define inet_addr_to_ipaddr_p(target_ipaddr_p, source_inaddr) ((target_ipaddr_p) = (ip_addr_t*)&((source_inaddr)->s_addr)) - -/* directly map this to the lwip internal functions */ -#define inet_addr(cp) ipaddr_addr(cp) -#define inet_aton(cp, addr) ipaddr_aton(cp, (ip_addr_t*)addr) -#define inet_ntoa(addr) ipaddr_ntoa((ip_addr_t*)&(addr)) -#define inet_ntoa_r(addr, buf, buflen) ipaddr_ntoa_r((ip_addr_t*)&(addr), buf, buflen) - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_INET_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/ip4.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/ip4.h deleted file mode 100644 index 04b5b8a6..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/ip4.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_IP4_H__ -#define __LWIP_IP4_H__ - -#include "lwip/opt.h" - -#include "lwip/def.h" -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" -#include "lwip/ip6_addr.h" -#include "lwip/err.h" -#include "lwip/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Currently, the function ip_output_if_opt() is only used with IGMP */ -#define IP_OPTIONS_SEND LWIP_IGMP - -#define IP_HLEN 20 - -#define IP_PROTO_ICMP 1 -#define IP_PROTO_IGMP 2 -#define IP_PROTO_UDP 17 -#define IP_PROTO_UDPLITE 136 -#define IP_PROTO_TCP 6 - - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip_hdr { - /* version / header length */ - PACK_STRUCT_FIELD(u8_t _v_hl); - /* type of service */ - PACK_STRUCT_FIELD(u8_t _tos); - /* total length */ - PACK_STRUCT_FIELD(u16_t _len); - /* identification */ - PACK_STRUCT_FIELD(u16_t _id); - /* fragment offset field */ - PACK_STRUCT_FIELD(u16_t _offset); -#define IP_RF 0x8000U /* reserved fragment flag */ -#define IP_DF 0x4000U /* dont fragment flag */ -#define IP_MF 0x2000U /* more fragments flag */ -#define IP_OFFMASK 0x1fffU /* mask for fragmenting bits */ - /* time to live */ - PACK_STRUCT_FIELD(u8_t _ttl); - /* protocol*/ - PACK_STRUCT_FIELD(u8_t _proto); - /* checksum */ - PACK_STRUCT_FIELD(u16_t _chksum); - /* source and destination IP addresses */ - PACK_STRUCT_FIELD(ip_addr_p_t src); - PACK_STRUCT_FIELD(ip_addr_p_t dest); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define IPH_V(hdr) ((hdr)->_v_hl >> 4) -#define IPH_HL(hdr) ((hdr)->_v_hl & 0x0f) -#define IPH_TOS(hdr) ((hdr)->_tos) -#define IPH_LEN(hdr) ((hdr)->_len) -#define IPH_ID(hdr) ((hdr)->_id) -#define IPH_OFFSET(hdr) ((hdr)->_offset) -#define IPH_TTL(hdr) ((hdr)->_ttl) -#define IPH_PROTO(hdr) ((hdr)->_proto) -#define IPH_CHKSUM(hdr) ((hdr)->_chksum) - -#define IPH_VHL_SET(hdr, v, hl) (hdr)->_v_hl = (((v) << 4) | (hl)) -#define IPH_TOS_SET(hdr, tos) (hdr)->_tos = (tos) -#define IPH_LEN_SET(hdr, len) (hdr)->_len = (len) -#define IPH_ID_SET(hdr, id) (hdr)->_id = (id) -#define IPH_OFFSET_SET(hdr, off) (hdr)->_offset = (off) -#define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl) -#define IPH_PROTO_SET(hdr, proto) (hdr)->_proto = (u8_t)(proto) -#define IPH_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum) - - -#define ip_init() /* Compatibility define, no init needed. */ -struct netif *ip_route(ip_addr_t *dest); -err_t ip_input(struct pbuf *p, struct netif *inp); -err_t ip_output(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto); -err_t ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, - struct netif *netif); -#if LWIP_NETIF_HWADDRHINT -err_t ip_output_hinted(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, u8_t *addr_hint); -#endif /* LWIP_NETIF_HWADDRHINT */ -#if IP_OPTIONS_SEND -err_t ip_output_if_opt(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest, - u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, void *ip_options, - u16_t optlen); -#endif /* IP_OPTIONS_SEND */ - -#define ip_netif_get_local_ipX(netif) (((netif) != NULL) ? ip_2_ipX(&((netif)->ip_addr)) : NULL) - -#if IP_DEBUG -void ip_debug_print(struct pbuf *p); -#else -#define ip_debug_print(p) -#endif /* IP_DEBUG */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_IP_H__ */ - - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/ip4_addr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/ip4_addr.h deleted file mode 100644 index b05ae537..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/ip4_addr.h +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_IP4_ADDR_H__ -#define __LWIP_IP4_ADDR_H__ - -#include "lwip/opt.h" -#include "lwip/def.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* This is the aligned version of ip_addr_t, - used as local variable, on the stack, etc. */ -struct ip_addr { - u32_t addr; -}; - -/* This is the packed version of ip_addr_t, - used in network headers that are itself packed */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip_addr_packed { - PACK_STRUCT_FIELD(u32_t addr); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** ip_addr_t uses a struct for convenience only, so that the same defines can - * operate both on ip_addr_t as well as on ip_addr_p_t. */ -typedef struct ip_addr ip_addr_t; -typedef struct ip_addr_packed ip_addr_p_t; - -/* - * struct ipaddr2 is used in the definition of the ARP packet format in - * order to support compilers that don't have structure packing. - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip_addr2 { - PACK_STRUCT_FIELD(u16_t addrw[2]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* Forward declaration to not include netif.h */ -struct netif; - -extern const ip_addr_t ip_addr_any; -extern const ip_addr_t ip_addr_broadcast; - -/** IP_ADDR_ can be used as a fixed IP address - * for the wildcard and the broadcast address - */ -#define IP_ADDR_ANY ((ip_addr_t *)&ip_addr_any) -#define IP_ADDR_BROADCAST ((ip_addr_t *)&ip_addr_broadcast) - -/** 255.255.255.255 */ -#define IPADDR_NONE ((u32_t)0xffffffffUL) -/** 127.0.0.1 */ -#define IPADDR_LOOPBACK ((u32_t)0x7f000001UL) -/** 0.0.0.0 */ -#define IPADDR_ANY ((u32_t)0x00000000UL) -/** 255.255.255.255 */ -#define IPADDR_BROADCAST ((u32_t)0xffffffffUL) - -/* Definitions of the bits in an Internet address integer. - - On subnets, host and network parts are found according to - the subnet mask, not these masks. */ -#define IP_CLASSA(a) ((((u32_t)(a)) & 0x80000000UL) == 0) -#define IP_CLASSA_NET 0xff000000 -#define IP_CLASSA_NSHIFT 24 -#define IP_CLASSA_HOST (0xffffffff & ~IP_CLASSA_NET) -#define IP_CLASSA_MAX 128 - -#define IP_CLASSB(a) ((((u32_t)(a)) & 0xc0000000UL) == 0x80000000UL) -#define IP_CLASSB_NET 0xffff0000 -#define IP_CLASSB_NSHIFT 16 -#define IP_CLASSB_HOST (0xffffffff & ~IP_CLASSB_NET) -#define IP_CLASSB_MAX 65536 - -#define IP_CLASSC(a) ((((u32_t)(a)) & 0xe0000000UL) == 0xc0000000UL) -#define IP_CLASSC_NET 0xffffff00 -#define IP_CLASSC_NSHIFT 8 -#define IP_CLASSC_HOST (0xffffffff & ~IP_CLASSC_NET) - -#define IP_CLASSD(a) (((u32_t)(a) & 0xf0000000UL) == 0xe0000000UL) -#define IP_CLASSD_NET 0xf0000000 /* These ones aren't really */ -#define IP_CLASSD_NSHIFT 28 /* net and host fields, but */ -#define IP_CLASSD_HOST 0x0fffffff /* routing needn't know. */ -#define IP_MULTICAST(a) IP_CLASSD(a) - -#define IP_EXPERIMENTAL(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) -#define IP_BADCLASS(a) (((u32_t)(a) & 0xf0000000UL) == 0xf0000000UL) - -#define IP_LOOPBACKNET 127 /* official! */ - - -#if BYTE_ORDER == BIG_ENDIAN -/** Set an IP address given by the four byte-parts */ -#define IP4_ADDR(ipaddr, a,b,c,d) \ - (ipaddr)->addr = ((u32_t)((a) & 0xff) << 24) | \ - ((u32_t)((b) & 0xff) << 16) | \ - ((u32_t)((c) & 0xff) << 8) | \ - (u32_t)((d) & 0xff) -#else -/** Set an IP address given by the four byte-parts. - Little-endian version that prevents the use of htonl. */ -#define IP4_ADDR(ipaddr, a,b,c,d) \ - (ipaddr)->addr = ((u32_t)((d) & 0xff) << 24) | \ - ((u32_t)((c) & 0xff) << 16) | \ - ((u32_t)((b) & 0xff) << 8) | \ - (u32_t)((a) & 0xff) -#endif - -/** MEMCPY-like copying of IP addresses where addresses are known to be - * 16-bit-aligned if the port is correctly configured (so a port could define - * this to copying 2 u16_t's) - no NULL-pointer-checking needed. */ -#ifndef IPADDR2_COPY -#define IPADDR2_COPY(dest, src) SMEMCPY(dest, src, sizeof(ip_addr_t)) -#endif - -/** Copy IP address - faster than ip_addr_set: no NULL check */ -#define ip_addr_copy(dest, src) ((dest).addr = (src).addr) -/** Safely copy one IP address to another (src may be NULL) */ -#define ip_addr_set(dest, src) ((dest)->addr = \ - ((src) == NULL ? 0 : \ - (src)->addr)) -/** Set complete address to zero */ -#define ip_addr_set_zero(ipaddr) ((ipaddr)->addr = 0) -/** Set address to IPADDR_ANY (no need for htonl()) */ -#define ip_addr_set_any(ipaddr) ((ipaddr)->addr = IPADDR_ANY) -/** Set address to loopback address */ -#define ip_addr_set_loopback(ipaddr) ((ipaddr)->addr = PP_HTONL(IPADDR_LOOPBACK)) -/** Safely copy one IP address to another and change byte order - * from host- to network-order. */ -#define ip_addr_set_hton(dest, src) ((dest)->addr = \ - ((src) == NULL ? 0:\ - htonl((src)->addr))) -/** IPv4 only: set the IP address given as an u32_t */ -#define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32)) -/** IPv4 only: get the IP address as an u32_t */ -#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr) - -/** Get the network address by combining host address with netmask */ -#define ip_addr_get_network(target, host, netmask) ((target)->addr = ((host)->addr) & ((netmask)->addr)) - -/** - * Determine if two address are on the same network. - * - * @arg addr1 IP address 1 - * @arg addr2 IP address 2 - * @arg mask network identifier mask - * @return !0 if the network identifiers of both address match - */ -#define ip_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \ - (mask)->addr) == \ - ((addr2)->addr & \ - (mask)->addr)) -#define ip_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr) - -#define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == IPADDR_ANY) - -#define ip_addr_isbroadcast(ipaddr, netif) ip4_addr_isbroadcast((ipaddr)->addr, (netif)) -u8_t ip4_addr_isbroadcast(u32_t addr, const struct netif *netif); - -#define ip_addr_netmask_valid(netmask) ip4_addr_netmask_valid((netmask)->addr) -u8_t ip4_addr_netmask_valid(u32_t netmask); - -#define ip_addr_ismulticast(addr1) (((addr1)->addr & PP_HTONL(0xf0000000UL)) == PP_HTONL(0xe0000000UL)) - -#define ip_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL)) - -#define ip_addr_debug_print(debug, ipaddr) \ - LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \ - ipaddr != NULL ? ip4_addr1_16(ipaddr) : 0, \ - ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \ - ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \ - ipaddr != NULL ? ip4_addr4_16(ipaddr) : 0)) - -/* Get one byte from the 4-byte address */ -#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0]) -#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1]) -#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2]) -#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3]) -/* These are cast to u16_t, with the intent that they are often arguments - * to printf using the U16_F format from cc.h. */ -#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr)) -#define ip4_addr2_16(ipaddr) ((u16_t)ip4_addr2(ipaddr)) -#define ip4_addr3_16(ipaddr) ((u16_t)ip4_addr3(ipaddr)) -#define ip4_addr4_16(ipaddr) ((u16_t)ip4_addr4(ipaddr)) - -/** For backwards compatibility */ -#define ip_ntoa(ipaddr) ipaddr_ntoa(ipaddr) - -u32_t ipaddr_addr(const char *cp); -int ipaddr_aton(const char *cp, ip_addr_t *addr); -/** returns ptr to static buffer; not reentrant! */ -char *ipaddr_ntoa(const ip_addr_t *addr); -char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen); - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_IP_ADDR_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/ip_frag.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/ip_frag.h deleted file mode 100644 index 47eca9f4..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv4/lwip/ip_frag.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Jani Monoses - * - */ - -#ifndef __LWIP_IP_FRAG_H__ -#define __LWIP_IP_FRAG_H__ - -#include "lwip/opt.h" -#include "lwip/err.h" -#include "lwip/pbuf.h" -#include "lwip/netif.h" -#include "lwip/ip_addr.h" -#include "lwip/ip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if IP_REASSEMBLY -/* The IP reassembly timer interval in milliseconds. */ -#define IP_TMR_INTERVAL 1000 - -/* IP reassembly helper struct. - * This is exported because memp needs to know the size. - */ -struct ip_reassdata { - struct ip_reassdata *next; - struct pbuf *p; - struct ip_hdr iphdr; - u16_t datagram_len; - u8_t flags; - u8_t timer; -}; - -void ip_reass_init(void); -void ip_reass_tmr(void); -struct pbuf * ip_reass(struct pbuf *p); -#endif /* IP_REASSEMBLY */ - -#if IP_FRAG -#if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF -/** A custom pbuf that holds a reference to another pbuf, which is freed - * when this custom pbuf is freed. This is used to create a custom PBUF_REF - * that points into the original pbuf. */ -#ifndef __LWIP_PBUF_CUSTOM_REF__ -#define __LWIP_PBUF_CUSTOM_REF__ -struct pbuf_custom_ref { - /** 'base class' */ - struct pbuf_custom pc; - /** pointer to the original pbuf that is referenced */ - struct pbuf *original; -}; -#endif /* __LWIP_PBUF_CUSTOM_REF__ */ -#endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ - -err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest); -#endif /* IP_FRAG */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_IP_FRAG_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/dhcp6.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/dhcp6.h deleted file mode 100644 index 4b905c54..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/dhcp6.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file - * - * IPv6 address autoconfiguration as per RFC 4862. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * IPv6 address autoconfiguration as per RFC 4862. - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#ifndef __LWIP_IP6_DHCP6_H__ -#define __LWIP_IP6_DHCP6_H__ - -#include "lwip/opt.h" - -#if LWIP_IPV6_DHCP6 /* don't build if not configured for use in lwipopts.h */ - - -struct dhcp6 -{ - /*TODO: implement DHCP6*/ -}; - -#endif /* LWIP_IPV6_DHCP6 */ - -#endif /* __LWIP_IP6_DHCP6_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ethip6.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ethip6.h deleted file mode 100644 index e7f412b4..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ethip6.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file - * - * Ethernet output for IPv6. Uses ND tables for link-layer addressing. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#ifndef __LWIP_ETHIP6_H__ -#define __LWIP_ETHIP6_H__ - -#include "lwip/opt.h" - -#if LWIP_IPV6 && LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/pbuf.h" -#include "lwip/ip6.h" -#include "lwip/ip6_addr.h" -#include "lwip/netif.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -err_t ethip6_output(struct netif *netif, struct pbuf *q, ip6_addr_t *ip6addr); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6 && LWIP_ETHERNET */ - -#endif /* __LWIP_ETHIP6_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/icmp6.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/icmp6.h deleted file mode 100644 index 428f1a4d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/icmp6.h +++ /dev/null @@ -1,152 +0,0 @@ -/** - * @file - * - * IPv6 version of ICMP, as per RFC 4443. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ -#ifndef __LWIP_ICMP6_H__ -#define __LWIP_ICMP6_H__ - -#include "lwip/opt.h" -#include "lwip/pbuf.h" -#include "lwip/ip6_addr.h" -#include "lwip/netif.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -enum icmp6_type { - ICMP6_TYPE_DUR = 1, /* Destination unreachable */ - ICMP6_TYPE_PTB = 2, /* Packet too big */ - ICMP6_TYPE_TE = 3, /* Time exceeded */ - ICMP6_TYPE_PP = 4, /* Parameter problem */ - ICMP6_TYPE_PE1 = 100, /* Private experimentation */ - ICMP6_TYPE_PE2 = 101, /* Private experimentation */ - ICMP6_TYPE_RSV_ERR = 127, /* Reserved for expansion of error messages */ - - ICMP6_TYPE_EREQ = 128, /* Echo request */ - ICMP6_TYPE_EREP = 129, /* Echo reply */ - ICMP6_TYPE_MLQ = 130, /* Multicast listener query */ - ICMP6_TYPE_MLR = 131, /* Multicast listener report */ - ICMP6_TYPE_MLD = 132, /* Multicast listener done */ - ICMP6_TYPE_RS = 133, /* Router solicitation */ - ICMP6_TYPE_RA = 134, /* Router advertisement */ - ICMP6_TYPE_NS = 135, /* Neighbor solicitation */ - ICMP6_TYPE_NA = 136, /* Neighbor advertisement */ - ICMP6_TYPE_RD = 137, /* Redirect */ - ICMP6_TYPE_MRA = 151, /* Multicast router advertisement */ - ICMP6_TYPE_MRS = 152, /* Multicast router solicitation */ - ICMP6_TYPE_MRT = 153, /* Multicast router termination */ - ICMP6_TYPE_PE3 = 200, /* Private experimentation */ - ICMP6_TYPE_PE4 = 201, /* Private experimentation */ - ICMP6_TYPE_RSV_INF = 255 /* Reserved for expansion of informational messages */ -}; - -enum icmp6_dur_code { - ICMP6_DUR_NO_ROUTE = 0, /* No route to destination */ - ICMP6_DUR_PROHIBITED = 1, /* Communication with destination administratively prohibited */ - ICMP6_DUR_SCOPE = 2, /* Beyond scope of source address */ - ICMP6_DUR_ADDRESS = 3, /* Address unreachable */ - ICMP6_DUR_PORT = 4, /* Port unreachable */ - ICMP6_DUR_POLICY = 5, /* Source address failed ingress/egress policy */ - ICMP6_DUR_REJECT_ROUTE = 6 /* Reject route to destination */ -}; - -enum icmp6_te_code { - ICMP6_TE_HL = 0, /* Hop limit exceeded in transit */ - ICMP6_TE_FRAG = 1 /* Fragment reassembly time exceeded */ -}; - -enum icmp6_pp_code { - ICMP6_PP_FIELD = 0, /* Erroneous header field encountered */ - ICMP6_PP_HEADER = 1, /* Unrecognized next header type encountered */ - ICMP6_PP_OPTION = 2 /* Unrecognized IPv6 option encountered */ -}; - -/** This is the standard ICMP6 header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct pp_icmp6_hdr { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u32_t data); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** This is the ICMP6 header adapted for echo req/resp. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct icmp6_echo_hdr { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u16_t id); - PACK_STRUCT_FIELD(u16_t seqno); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - - -#if LWIP_ICMP6 && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -void icmp6_input(struct pbuf *p, struct netif *inp); -void icmp6_dest_unreach(struct pbuf *p, enum icmp6_dur_code c); -void icmp6_packet_too_big(struct pbuf *p, u32_t mtu); -void icmp6_time_exceeded(struct pbuf *p, enum icmp6_te_code c); -void icmp6_param_problem(struct pbuf *p, enum icmp6_pp_code c, u32_t pointer); - -#endif /* LWIP_ICMP6 && LWIP_IPV6 */ - - -#ifdef __cplusplus -} -#endif - - -#endif /* __LWIP_ICMP6_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/inet6.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/inet6.h deleted file mode 100644 index dbf98df0..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/inet6.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @file - * - * INET v6 addresses. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ -#ifndef __LWIP_INET6_H__ -#define __LWIP_INET6_H__ - -#include "lwip/opt.h" - -#if LWIP_IPV6 && LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/ip6_addr.h" -#include "lwip/def.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** For compatibility with BSD code */ -struct in6_addr { - union { - u8_t u8_addr[16]; - u32_t u32_addr[4]; - } un; -#define s6_addr un.u32_addr -}; - -#define IN6ADDR_ANY_INIT {0,0,0,0} -#define IN6ADDR_LOOPBACK_INIT {0,0,0,PP_HTONL(1)} - - -#define inet6_addr_from_ip6addr(target_in6addr, source_ip6addr) {(target_in6addr)->un.u32_addr[0] = (source_ip6addr)->addr[0]; \ - (target_in6addr)->un.u32_addr[1] = (source_ip6addr)->addr[1]; \ - (target_in6addr)->un.u32_addr[2] = (source_ip6addr)->addr[2]; \ - (target_in6addr)->un.u32_addr[3] = (source_ip6addr)->addr[3];} -#define inet6_addr_to_ip6addr(target_ip6addr, source_in6addr) {(target_ip6addr)->addr[0] = (source_in6addr)->un.u32_addr[0]; \ - (target_ip6addr)->addr[1] = (source_in6addr)->un.u32_addr[1]; \ - (target_ip6addr)->addr[2] = (source_in6addr)->un.u32_addr[2]; \ - (target_ip6addr)->addr[3] = (source_in6addr)->un.u32_addr[3];} -/* ATTENTION: the next define only works because both in6_addr and ip6_addr_t are an u32_t[4] effectively! */ -#define inet6_addr_to_ip6addr_p(target_ip6addr_p, source_in6addr) ((target_ip6addr_p) = (ip6_addr_t*)(source_in6addr)) - -/* directly map this to the lwip internal functions */ -#define inet6_aton(cp, addr) ip6addr_aton(cp, (ip6_addr_t*)addr) -#define inet6_ntoa(addr) ip6addr_ntoa((ip6_addr_t*)&(addr)) -#define inet6_ntoa_r(addr, buf, buflen) ip6addr_ntoa_r((ip6_addr_t*)&(addr), buf, buflen) - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6 */ - -#endif /* __LWIP_INET6_H__ */ - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ip6.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ip6.h deleted file mode 100644 index b199c95a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ip6.h +++ /dev/null @@ -1,197 +0,0 @@ -/** - * @file - * - * IPv6 layer. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ -#ifndef __LWIP_IP6_H__ -#define __LWIP_IP6_H__ - -#include "lwip/opt.h" - -#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/ip.h" -#include "lwip/ip6_addr.h" -#include "lwip/def.h" -#include "lwip/pbuf.h" -#include "lwip/netif.h" - -#include "lwip/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define IP6_HLEN 40 - -#define IP6_NEXTH_HOPBYHOP 0 -#define IP6_NEXTH_TCP 6 -#define IP6_NEXTH_UDP 17 -#define IP6_NEXTH_ENCAPS 41 -#define IP6_NEXTH_ROUTING 43 -#define IP6_NEXTH_FRAGMENT 44 -#define IP6_NEXTH_ICMP6 58 -#define IP6_NEXTH_NONE 59 -#define IP6_NEXTH_DESTOPTS 60 -#define IP6_NEXTH_UDPLITE 136 - - -/* The IPv6 header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip6_hdr { - /* version / traffic class / flow label */ - PACK_STRUCT_FIELD(u32_t _v_tc_fl); - /* payload length */ - PACK_STRUCT_FIELD(u16_t _plen); - /* next header */ - PACK_STRUCT_FIELD(u8_t _nexth); - /* hop limit */ - PACK_STRUCT_FIELD(u8_t _hoplim); - /* source and destination IP addresses */ - PACK_STRUCT_FIELD(ip6_addr_p_t src); - PACK_STRUCT_FIELD(ip6_addr_p_t dest); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* Hop-by-hop router alert option. */ -#define IP6_HBH_HLEN 8 -#define IP6_PAD1_OPTION 0 -#define IP6_PADN_ALERT_OPTION 1 -#define IP6_ROUTER_ALERT_OPTION 5 -#define IP6_ROUTER_ALERT_VALUE_MLD 0 -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip6_hbh_hdr { - /* next header */ - PACK_STRUCT_FIELD(u8_t _nexth); - /* header length */ - PACK_STRUCT_FIELD(u8_t _hlen); - /* router alert option type */ - PACK_STRUCT_FIELD(u8_t _ra_opt_type); - /* router alert option data len */ - PACK_STRUCT_FIELD(u8_t _ra_opt_dlen); - /* router alert option data */ - PACK_STRUCT_FIELD(u16_t _ra_opt_data); - /* PadN option type */ - PACK_STRUCT_FIELD(u8_t _padn_opt_type); - /* PadN option data len */ - PACK_STRUCT_FIELD(u8_t _padn_opt_dlen); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* Fragment header. */ -#define IP6_FRAG_HLEN 8 -#define IP6_FRAG_OFFSET_MASK 0xfff8 -#define IP6_FRAG_MORE_FLAG 0x0001 -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip6_frag_hdr { - /* next header */ - PACK_STRUCT_FIELD(u8_t _nexth); - /* reserved */ - PACK_STRUCT_FIELD(u8_t reserved); - /* fragment offset */ - PACK_STRUCT_FIELD(u16_t _fragment_offset); - /* fragmented packet identification */ - PACK_STRUCT_FIELD(u32_t _identification); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define IP6H_V(hdr) ((ntohl((hdr)->_v_tc_fl) >> 28) & 0x0f) -#define IP6H_TC(hdr) ((ntohl((hdr)->_v_tc_fl) >> 20) & 0xff) -#define IP6H_FL(hdr) (ntohl((hdr)->_v_tc_fl) & 0x000fffff) -#define IP6H_PLEN(hdr) (ntohs((hdr)->_plen)) -#define IP6H_NEXTH(hdr) ((hdr)->_nexth) -#define IP6H_NEXTH_P(hdr) ((u8_t *)(hdr) + 6) -#define IP6H_HOPLIM(hdr) ((hdr)->_hoplim) - -#define IP6H_VTCFL_SET(hdr, v, tc, fl) (hdr)->_v_tc_fl = (htonl(((v) << 28) | ((tc) << 20) | (fl))) -#define IP6H_PLEN_SET(hdr, plen) (hdr)->_plen = htons(plen) -#define IP6H_NEXTH_SET(hdr, nexth) (hdr)->_nexth = (nexth) -#define IP6H_HOPLIM_SET(hdr, hl) (hdr)->_hoplim = (u8_t)(hl) - - -#define ip6_init() /* TODO should we init current addresses and header pointer? */ -struct netif *ip6_route(struct ip6_addr *src, struct ip6_addr *dest); -ip6_addr_t *ip6_select_source_address(struct netif *netif, ip6_addr_t * dest); -err_t ip6_input(struct pbuf *p, struct netif *inp); -err_t ip6_output(struct pbuf *p, struct ip6_addr *src, struct ip6_addr *dest, - u8_t hl, u8_t tc, u8_t nexth); -err_t ip6_output_if(struct pbuf *p, struct ip6_addr *src, struct ip6_addr *dest, - u8_t hl, u8_t tc, u8_t nexth, struct netif *netif); -#if LWIP_NETIF_HWADDRHINT -err_t ip6_output_hinted(struct pbuf *p, ip6_addr_t *src, ip6_addr_t *dest, - u8_t hl, u8_t tc, u8_t nexth, u8_t *addr_hint); -#endif /* LWIP_NETIF_HWADDRHINT */ -#if LWIP_IPV6_MLD -err_t ip6_options_add_hbh_ra(struct pbuf * p, u8_t nexth, u8_t value); -#endif /* LWIP_IPV6_MLD */ - -#define ip6_netif_get_local_ipX(netif, dest) (((netif) != NULL) ? \ - ip6_2_ipX(ip6_select_source_address(netif, dest)) : NULL) - -#if IP6_DEBUG -void ip6_debug_print(struct pbuf *p); -#else -#define ip6_debug_print(p) -#endif /* IP6_DEBUG */ - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6 */ - -#endif /* __LWIP_IP6_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ip6_addr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ip6_addr.h deleted file mode 100644 index 89b5b811..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ip6_addr.h +++ /dev/null @@ -1,286 +0,0 @@ -/** - * @file - * - * IPv6 addresses. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * Structs and macros for handling IPv6 addresses. - * - * Please coordinate changes and requests with Ivan Delamer - * - */ -#ifndef __LWIP_IP6_ADDR_H__ -#define __LWIP_IP6_ADDR_H__ - -#include "lwip/opt.h" - -#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* This is the aligned version of ip6_addr_t, - used as local variable, on the stack, etc. */ -struct ip6_addr { - u32_t addr[4]; -}; - -/* This is the packed version of ip6_addr_t, - used in network headers that are itself packed */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ip6_addr_packed { - PACK_STRUCT_FIELD(u32_t addr[4]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** ip6_addr_t uses a struct for convenience only, so that the same defines can - * operate both on ip6_addr_t as well as on ip6_addr_p_t. */ -typedef struct ip6_addr ip6_addr_t; -typedef struct ip6_addr_packed ip6_addr_p_t; - - -/** IP6_ADDR_ANY can be used as a fixed IPv6 address - * for the wildcard - */ -extern const ip6_addr_t ip6_addr_any; -#define IP6_ADDR_ANY ((ip6_addr_t *)&ip6_addr_any) - - - - -#if BYTE_ORDER == BIG_ENDIAN -/** Set an IPv6 partial address given by byte-parts. */ -#define IP6_ADDR(ip6addr, index, a,b,c,d) \ - (ip6addr)->addr[index] = ((u32_t)((a) & 0xff) << 24) | \ - ((u32_t)((b) & 0xff) << 16) | \ - ((u32_t)((c) & 0xff) << 8) | \ - (u32_t)((d) & 0xff) -#else -/** Set an IPv6 partial address given by byte-parts. -Little-endian version, stored in network order (no htonl). */ -#define IP6_ADDR(ip6addr, index, a,b,c,d) \ - (ip6addr)->addr[index] = ((u32_t)((d) & 0xff) << 24) | \ - ((u32_t)((c) & 0xff) << 16) | \ - ((u32_t)((b) & 0xff) << 8) | \ - (u32_t)((a) & 0xff) -#endif - -/** Access address in 16-bit block */ -#define IP6_ADDR_BLOCK1(ip6addr) ((u16_t)(htonl((ip6addr)->addr[0]) >> 16) & 0xffff) -#define IP6_ADDR_BLOCK2(ip6addr) ((u16_t)(htonl((ip6addr)->addr[0])) & 0xffff) -#define IP6_ADDR_BLOCK3(ip6addr) ((u16_t)(htonl((ip6addr)->addr[1]) >> 16) & 0xffff) -#define IP6_ADDR_BLOCK4(ip6addr) ((u16_t)(htonl((ip6addr)->addr[1])) & 0xffff) -#define IP6_ADDR_BLOCK5(ip6addr) ((u16_t)(htonl((ip6addr)->addr[2]) >> 16) & 0xffff) -#define IP6_ADDR_BLOCK6(ip6addr) ((u16_t)(htonl((ip6addr)->addr[2])) & 0xffff) -#define IP6_ADDR_BLOCK7(ip6addr) ((u16_t)(htonl((ip6addr)->addr[3]) >> 16) & 0xffff) -#define IP6_ADDR_BLOCK8(ip6addr) ((u16_t)(htonl((ip6addr)->addr[3])) & 0xffff) - -/** Copy IPv6 address - faster than ip6_addr_set: no NULL check */ -#define ip6_addr_copy(dest, src) do{(dest).addr[0] = (src).addr[0]; \ - (dest).addr[1] = (src).addr[1]; \ - (dest).addr[2] = (src).addr[2]; \ - (dest).addr[3] = (src).addr[3];}while(0) -/** Safely copy one IPv6 address to another (src may be NULL) */ -#define ip6_addr_set(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : (src)->addr[0]; \ - (dest)->addr[1] = (src) == NULL ? 0 : (src)->addr[1]; \ - (dest)->addr[2] = (src) == NULL ? 0 : (src)->addr[2]; \ - (dest)->addr[3] = (src) == NULL ? 0 : (src)->addr[3];}while(0) - -/** Set complete address to zero */ -#define ip6_addr_set_zero(ip6addr) do{(ip6addr)->addr[0] = 0; \ - (ip6addr)->addr[1] = 0; \ - (ip6addr)->addr[2] = 0; \ - (ip6addr)->addr[3] = 0;}while(0) - -/** Set address to ipv6 'any' (no need for htonl()) */ -#define ip6_addr_set_any(ip6addr) ip6_addr_set_zero(ip6addr) -/** Set address to ipv6 loopback address */ -#define ip6_addr_set_loopback(ip6addr) do{(ip6addr)->addr[0] = 0; \ - (ip6addr)->addr[1] = 0; \ - (ip6addr)->addr[2] = 0; \ - (ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0) -/** Safely copy one IPv6 address to another and change byte order - * from host- to network-order. */ -#define ip6_addr_set_hton(dest, src) do{(dest)->addr[0] = (src) == NULL ? 0 : htonl((src)->addr[0]); \ - (dest)->addr[1] = (src) == NULL ? 0 : htonl((src)->addr[1]); \ - (dest)->addr[2] = (src) == NULL ? 0 : htonl((src)->addr[2]); \ - (dest)->addr[3] = (src) == NULL ? 0 : htonl((src)->addr[3]);}while(0) - - - -/** - * Determine if two IPv6 address are on the same network. - * - * @arg addr1 IPv6 address 1 - * @arg addr2 IPv6 address 2 - * @return !0 if the network identifiers of both address match - */ -#define ip6_addr_netcmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \ - ((addr1)->addr[1] == (addr2)->addr[1])) - -#define ip6_addr_cmp(addr1, addr2) (((addr1)->addr[0] == (addr2)->addr[0]) && \ - ((addr1)->addr[1] == (addr2)->addr[1]) && \ - ((addr1)->addr[2] == (addr2)->addr[2]) && \ - ((addr1)->addr[3] == (addr2)->addr[3])) - -#define ip6_get_subnet_id(ip6addr) (htonl((ip6addr)->addr[2]) & 0x0000ffffUL) - -#define ip6_addr_isany(ip6addr) (((ip6addr) == NULL) || \ - (((ip6addr)->addr[0] == 0) && \ - ((ip6addr)->addr[1] == 0) && \ - ((ip6addr)->addr[2] == 0) && \ - ((ip6addr)->addr[3] == 0))) - - -#define ip6_addr_isglobal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xe0000000UL)) == PP_HTONL(0x20000000UL)) - -#define ip6_addr_islinklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffc00000UL)) == PP_HTONL(0xfe800000UL)) - -#define ip6_addr_issitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffc00000UL)) == PP_HTONL(0xfec00000UL)) - -#define ip6_addr_isuniquelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xfe000000UL)) == PP_HTONL(0xfc000000UL)) - -#define ip6_addr_ismulticast(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)) -#define ip6_addr_multicast_transient_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00100000UL)) -#define ip6_addr_multicast_prefix_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00200000UL)) -#define ip6_addr_multicast_rendezvous_flag(ip6addr) ((ip6addr)->addr[0] & PP_HTONL(0x00400000UL)) -#define ip6_addr_multicast_scope(ip6addr) ((htonl((ip6addr)->addr[0]) >> 16) & 0xf) -#define IP6_MULTICAST_SCOPE_RESERVED 0x0 -#define IP6_MULTICAST_SCOPE_RESERVED0 0x0 -#define IP6_MULTICAST_SCOPE_INTERFACE_LOCAL 0x1 -#define IP6_MULTICAST_SCOPE_LINK_LOCAL 0x2 -#define IP6_MULTICAST_SCOPE_RESERVED3 0x3 -#define IP6_MULTICAST_SCOPE_ADMIN_LOCAL 0x4 -#define IP6_MULTICAST_SCOPE_SITE_LOCAL 0x5 -#define IP6_MULTICAST_SCOPE_ORGANIZATION_LOCAL 0x8 -#define IP6_MULTICAST_SCOPE_GLOBAL 0xe -#define IP6_MULTICAST_SCOPE_RESERVEDF 0xf -#define ip6_addr_ismulticast_iflocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff010000UL)) -#define ip6_addr_ismulticast_linklocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff020000UL)) -#define ip6_addr_ismulticast_adminlocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff040000UL)) -#define ip6_addr_ismulticast_sitelocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff050000UL)) -#define ip6_addr_ismulticast_orglocal(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff080000UL)) -#define ip6_addr_ismulticast_global(ip6addr) (((ip6addr)->addr[0] & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xff0e0000UL)) - -/* TODO define get/set for well-know multicast addresses, e.g. ff02::1 */ -#define ip6_addr_isallnodes_iflocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff010000UL)) && \ - ((ip6addr)->addr[1] == 0UL) && \ - ((ip6addr)->addr[2] == 0UL) && \ - ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) - -#define ip6_addr_isallnodes_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ - ((ip6addr)->addr[1] == 0UL) && \ - ((ip6addr)->addr[2] == 0UL) && \ - ((ip6addr)->addr[3] == PP_HTONL(0x00000001UL))) -#define ip6_addr_set_allnodes_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ - (ip6addr)->addr[1] = 0; \ - (ip6addr)->addr[2] = 0; \ - (ip6addr)->addr[3] = PP_HTONL(0x00000001UL);}while(0) - -#define ip6_addr_isallrouters_linklocal(ip6addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ - ((ip6addr)->addr[1] == 0UL) && \ - ((ip6addr)->addr[2] == 0UL) && \ - ((ip6addr)->addr[3] == PP_HTONL(0x00000002UL))) -#define ip6_addr_set_allrouters_linklocal(ip6addr) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ - (ip6addr)->addr[1] = 0; \ - (ip6addr)->addr[2] = 0; \ - (ip6addr)->addr[3] = PP_HTONL(0x00000002UL);}while(0) - -#define ip6_addr_issolicitednode(ip6addr) ( ((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ - ((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \ - (((ip6addr)->addr[3] & PP_HTONL(0xff000000UL)) == PP_HTONL(0xff000000UL)) ) - -#define ip6_addr_set_solicitednode(ip6addr, if_id) do{(ip6addr)->addr[0] = PP_HTONL(0xff020000UL); \ - (ip6addr)->addr[1] = 0; \ - (ip6addr)->addr[2] = PP_HTONL(0x00000001UL); \ - (ip6addr)->addr[3] = htonl(0xff000000UL | (htonl(if_id) & 0x00ffffffUL));}while(0) - -#define ip6_addr_cmp_solicitednode(ip6addr, sn_addr) (((ip6addr)->addr[0] == PP_HTONL(0xff020000UL)) && \ - ((ip6addr)->addr[1] == 0) && \ - ((ip6addr)->addr[2] == PP_HTONL(0x00000001UL)) && \ - ((ip6addr)->addr[3] == htonl(0xff000000UL | (htonl((sn_addr)->addr[3]) & 0x00ffffffUL)))) - -/* IPv6 address states. */ -#define IP6_ADDR_INVALID 0x00 -#define IP6_ADDR_TENTATIVE 0x08 -#define IP6_ADDR_TENTATIVE_1 0x09 /* 1 probe sent */ -#define IP6_ADDR_TENTATIVE_2 0x0a /* 2 probes sent */ -#define IP6_ADDR_TENTATIVE_3 0x0b /* 3 probes sent */ -#define IP6_ADDR_TENTATIVE_4 0x0c /* 4 probes sent */ -#define IP6_ADDR_TENTATIVE_5 0x0d /* 5 probes sent */ -#define IP6_ADDR_TENTATIVE_6 0x0e /* 6 probes sent */ -#define IP6_ADDR_TENTATIVE_7 0x0f /* 7 probes sent */ -#define IP6_ADDR_VALID 0x10 -#define IP6_ADDR_PREFERRED 0x30 -#define IP6_ADDR_DEPRECATED 0x50 - -#define ip6_addr_isinvalid(addr_state) (addr_state == IP6_ADDR_INVALID) -#define ip6_addr_istentative(addr_state) (addr_state & IP6_ADDR_TENTATIVE) -#define ip6_addr_isvalid(addr_state) (addr_state & IP6_ADDR_VALID) /* Include valid, preferred, and deprecated. */ -#define ip6_addr_ispreferred(addr_state) (addr_state == IP6_ADDR_PREFERRED) -#define ip6_addr_isdeprecated(addr_state) (addr_state == IP6_ADDR_DEPRECATED) - -#define ip6_addr_debug_print(debug, ipaddr) \ - LWIP_DEBUGF(debug, ("%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F":%"X16_F, \ - ipaddr != NULL ? IP6_ADDR_BLOCK1(ipaddr) : 0, \ - ipaddr != NULL ? IP6_ADDR_BLOCK2(ipaddr) : 0, \ - ipaddr != NULL ? IP6_ADDR_BLOCK3(ipaddr) : 0, \ - ipaddr != NULL ? IP6_ADDR_BLOCK4(ipaddr) : 0, \ - ipaddr != NULL ? IP6_ADDR_BLOCK5(ipaddr) : 0, \ - ipaddr != NULL ? IP6_ADDR_BLOCK6(ipaddr) : 0, \ - ipaddr != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0, \ - ipaddr != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0)) - -int ip6addr_aton(const char *cp, ip6_addr_t *addr); -/** returns ptr to static buffer; not reentrant! */ -char *ip6addr_ntoa(const ip6_addr_t *addr); -char *ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen); - - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6 */ - -#endif /* __LWIP_IP6_ADDR_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ip6_frag.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ip6_frag.h deleted file mode 100644 index 75898b8f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/ip6_frag.h +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @file - * - * IPv6 fragmentation and reassembly. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ -#ifndef __LWIP_IP6_FRAG_H__ -#define __LWIP_IP6_FRAG_H__ - -#include "lwip/opt.h" -#include "lwip/pbuf.h" -#include "lwip/ip6_addr.h" -#include "lwip/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#if LWIP_IPV6 && LWIP_IPV6_REASS /* don't build if not configured for use in lwipopts.h */ - -/* The IPv6 reassembly timer interval in milliseconds. */ -#define IP6_REASS_TMR_INTERVAL 1000 - -/* IPv6 reassembly helper struct. - * This is exported because memp needs to know the size. - */ -struct ip6_reassdata { - struct ip6_reassdata *next; - struct pbuf *p; - struct ip6_hdr * iphdr; - u32_t identification; - u16_t datagram_len; - u8_t nexth; - u8_t timer; -}; - -#define ip6_reass_init() /* Compatibility define */ -void ip6_reass_tmr(void); -struct pbuf * ip6_reass(struct pbuf *p); - -#endif /* LWIP_IPV6 && LWIP_IPV6_REASS */ - -#if LWIP_IPV6 && LWIP_IPV6_FRAG /* don't build if not configured for use in lwipopts.h */ - -/** A custom pbuf that holds a reference to another pbuf, which is freed - * when this custom pbuf is freed. This is used to create a custom PBUF_REF - * that points into the original pbuf. */ -#ifndef __LWIP_PBUF_CUSTOM_REF__ -#define __LWIP_PBUF_CUSTOM_REF__ -struct pbuf_custom_ref { - /** 'base class' */ - struct pbuf_custom pc; - /** pointer to the original pbuf that is referenced */ - struct pbuf *original; -}; -#endif /* __LWIP_PBUF_CUSTOM_REF__ */ - -err_t ip6_frag(struct pbuf *p, struct netif *netif, ip6_addr_t *dest); - -#endif /* LWIP_IPV6 && LWIP_IPV6_FRAG */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_IP6_FRAG_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/mld6.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/mld6.h deleted file mode 100644 index abd86e55..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/mld6.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @file - * - * Multicast listener discovery for IPv6. Aims to be compliant with RFC 2710. - * No support for MLDv2. - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#ifndef __LWIP_MLD6_H__ -#define __LWIP_MLD6_H__ - -#include "lwip/opt.h" - -#if LWIP_IPV6_MLD && LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/pbuf.h" -#include "lwip/netif.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -struct mld_group { - /** next link */ - struct mld_group *next; - /** interface on which the group is active */ - struct netif *netif; - /** multicast address */ - ip6_addr_t group_address; - /** signifies we were the last person to report */ - u8_t last_reporter_flag; - /** current state of the group */ - u8_t group_state; - /** timer for reporting */ - u16_t timer; - /** counter of simultaneous uses */ - u8_t use; -}; - -/** Multicast listener report/query/done message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct mld_header { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u16_t max_resp_delay); - PACK_STRUCT_FIELD(u16_t reserved); - PACK_STRUCT_FIELD(ip6_addr_p_t multicast_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define MLD6_TMR_INTERVAL 100 /* Milliseconds */ - -/* MAC Filter Actions, these are passed to a netif's - * mld_mac_filter callback function. */ -#define MLD6_DEL_MAC_FILTER 0 -#define MLD6_ADD_MAC_FILTER 1 - - -#define mld6_init() /* TODO should we init tables? */ -err_t mld6_stop(struct netif *netif); -void mld6_report_groups(struct netif *netif); -void mld6_tmr(void); -struct mld_group *mld6_lookfor_group(struct netif *ifp, ip6_addr_t *addr); -void mld6_input(struct pbuf *p, struct netif *inp); -err_t mld6_joingroup(ip6_addr_t *srcaddr, ip6_addr_t *groupaddr); -err_t mld6_leavegroup(ip6_addr_t *srcaddr, ip6_addr_t *groupaddr); - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6_MLD && LWIP_IPV6 */ - -#endif /* __LWIP_MLD6_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/nd6.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/nd6.h deleted file mode 100644 index 28636e89..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/ipv6/lwip/nd6.h +++ /dev/null @@ -1,369 +0,0 @@ -/** - * @file - * - * Neighbor discovery and stateless address autoconfiguration for IPv6. - * Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 - * (Address autoconfiguration). - */ - -/* - * Copyright (c) 2010 Inico Technologies Ltd. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Ivan Delamer - * - * - * Please coordinate changes and requests with Ivan Delamer - * - */ - -#ifndef __LWIP_ND6_H__ -#define __LWIP_ND6_H__ - -#include "lwip/opt.h" - -#if LWIP_IPV6 /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/pbuf.h" -#include "lwip/ip6.h" -#include "lwip/ip6_addr.h" -#include "lwip/netif.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/* Struct for tables. */ -struct nd6_neighbor_cache_entry { - ip6_addr_t next_hop_address; - struct netif * netif; - u8_t lladdr[NETIF_MAX_HWADDR_LEN]; - /*u32_t pmtu;*/ -#if LWIP_ND6_QUEUEING - /** Pointer to queue of pending outgoing packets on this entry. */ - struct nd6_q_entry *q; -#else /* LWIP_ND6_QUEUEING */ - /** Pointer to a single pending outgoing packet on this entry. */ - struct pbuf *q; -#endif /* LWIP_ND6_QUEUEING */ - u8_t state; - u8_t isrouter; - union { - u32_t reachable_time; - u32_t delay_time; - u32_t probes_sent; - u32_t stale_time; - } counter; -}; - -struct nd6_destination_cache_entry { - ip6_addr_t destination_addr; - ip6_addr_t next_hop_addr; - u32_t pmtu; - u32_t age; -}; - -struct nd6_prefix_list_entry { - ip6_addr_t prefix; - struct netif * netif; - u32_t invalidation_timer; -#if LWIP_IPV6_AUTOCONFIG - u8_t flags; -#define ND6_PREFIX_AUTOCONFIG_AUTONOMOUS 0x01 -#define ND6_PREFIX_AUTOCONFIG_ADDRESS_GENERATED 0x02 -#define ND6_PREFIX_AUTOCONFIG_ADDRESS_DUPLICATE 0x04 -#endif /* LWIP_IPV6_AUTOCONFIG */ -}; - -struct nd6_router_list_entry { - struct nd6_neighbor_cache_entry * neighbor_entry; - u32_t invalidation_timer; - u8_t flags; -}; - - -enum nd6_neighbor_cache_entry_state { - ND6_NO_ENTRY = 0, - ND6_INCOMPLETE, - ND6_REACHABLE, - ND6_STALE, - ND6_DELAY, - ND6_PROBE -}; - -#if LWIP_ND6_QUEUEING -/** struct for queueing outgoing packets for unknown address - * defined here to be accessed by memp.h - */ -struct nd6_q_entry { - struct nd6_q_entry *next; - struct pbuf *p; -}; -#endif /* LWIP_ND6_QUEUEING */ - -/** Neighbor solicitation message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ns_header { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u32_t reserved); - PACK_STRUCT_FIELD(ip6_addr_p_t target_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Neighbor advertisement message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct na_header { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u8_t flags); - PACK_STRUCT_FIELD(u8_t reserved[3]); - PACK_STRUCT_FIELD(ip6_addr_p_t target_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif -#define ND6_FLAG_ROUTER (0x80) -#define ND6_FLAG_SOLICITED (0x40) -#define ND6_FLAG_OVERRIDE (0x20) - -/** Router solicitation message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct rs_header { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u32_t reserved); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Router advertisement message header. */ -#define ND6_RA_FLAG_MANAGED_ADDR_CONFIG (0x80) -#define ND6_RA_FLAG_OTHER_STATEFUL_CONFIG (0x40) -#define ND6_RA_FLAG_HOME_AGENT (0x20) -#define ND6_RA_PREFERENCE_MASK (0x18) -#define ND6_RA_PREFERENCE_HIGH (0x08) -#define ND6_RA_PREFERENCE_MEDIUM (0x00) -#define ND6_RA_PREFERENCE_LOW (0x18) -#define ND6_RA_PREFERENCE_DISABLED (0x10) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct ra_header { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u8_t current_hop_limit); - PACK_STRUCT_FIELD(u8_t flags); - PACK_STRUCT_FIELD(u16_t router_lifetime); - PACK_STRUCT_FIELD(u32_t reachable_time); - PACK_STRUCT_FIELD(u32_t retrans_timer); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Redirect message header. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct redirect_header { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u32_t reserved); - PACK_STRUCT_FIELD(ip6_addr_p_t target_address); - PACK_STRUCT_FIELD(ip6_addr_p_t destination_address); - /* Options follow. */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Link-layer address option. */ -#define ND6_OPTION_TYPE_SOURCE_LLADDR (0x01) -#define ND6_OPTION_TYPE_TARGET_LLADDR (0x02) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct lladdr_option { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t length); - PACK_STRUCT_FIELD(u8_t addr[NETIF_MAX_HWADDR_LEN]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Prefix information option. */ -#define ND6_OPTION_TYPE_PREFIX_INFO (0x03) -#define ND6_PREFIX_FLAG_ON_LINK (0x80) -#define ND6_PREFIX_FLAG_AUTONOMOUS (0x40) -#define ND6_PREFIX_FLAG_ROUTER_ADDRESS (0x20) -#define ND6_PREFIX_FLAG_SITE_PREFIX (0x10) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct prefix_option { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t length); - PACK_STRUCT_FIELD(u8_t prefix_length); - PACK_STRUCT_FIELD(u8_t flags); - PACK_STRUCT_FIELD(u32_t valid_lifetime); - PACK_STRUCT_FIELD(u32_t preferred_lifetime); - PACK_STRUCT_FIELD(u8_t reserved2[3]); - PACK_STRUCT_FIELD(u8_t site_prefix_length); - PACK_STRUCT_FIELD(ip6_addr_p_t prefix); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Redirected header option. */ -#define ND6_OPTION_TYPE_REDIR_HDR (0x04) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct redirected_header_option { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t length); - PACK_STRUCT_FIELD(u8_t reserved[6]); - /* Portion of redirected packet follows. */ - /* PACK_STRUCT_FIELD(u8_t redirected[8]); */ -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** MTU option. */ -#define ND6_OPTION_TYPE_MTU (0x05) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct mtu_option { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t length); - PACK_STRUCT_FIELD(u16_t reserved); - PACK_STRUCT_FIELD(u32_t mtu); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/** Route information option. */ -#define ND6_OPTION_TYPE_ROUTE_INFO (24) -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct route_option { - PACK_STRUCT_FIELD(u8_t type); - PACK_STRUCT_FIELD(u8_t length); - PACK_STRUCT_FIELD(u8_t prefix_length); - PACK_STRUCT_FIELD(u8_t preference); - PACK_STRUCT_FIELD(u32_t route_lifetime); - PACK_STRUCT_FIELD(ip6_addr_p_t prefix); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -/* the possible states of an IP address */ -#define IP6_ADDRESS_STATE_INVALID (0) -#define IP6_ADDRESS_STATE_VALID (0x4) -#define IP6_ADDRESS_STATE_PREFERRED (0x5) /* includes valid */ -#define IP6_ADDRESS_STATE_DEPRECATED (0x6) /* includes valid */ -#define IP6_ADDRESS_STATE_TENTATIV (0x8) - -/** 1 second period */ -#define ND6_TMR_INTERVAL 1000 - -/* Router tables. */ -/* TODO make these static? and entries accessible through API? */ -extern struct nd6_neighbor_cache_entry neighbor_cache[]; -extern struct nd6_destination_cache_entry destination_cache[]; -extern struct nd6_prefix_list_entry prefix_list[]; -extern struct nd6_router_list_entry default_router_list[]; - -/* Default values, can be updated by a RA message. */ -extern u32_t reachable_time; -extern u32_t retrans_timer; - -#define nd6_init() /* TODO should we init tables? */ -void nd6_tmr(void); -void nd6_input(struct pbuf *p, struct netif *inp); -s8_t nd6_get_next_hop_entry(ip6_addr_t * ip6addr, struct netif * netif); -s8_t nd6_select_router(ip6_addr_t * ip6addr, struct netif * netif); -u16_t nd6_get_destination_mtu(ip6_addr_t * ip6addr, struct netif * netif); -err_t nd6_queue_packet(s8_t neighbor_index, struct pbuf * p); -#if LWIP_ND6_TCP_REACHABILITY_HINTS -void nd6_reachability_hint(ip6_addr_t * ip6addr); -#endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_IPV6 */ - -#endif /* __LWIP_ND6_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/api.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/api.h deleted file mode 100644 index ac58eebb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/api.h +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_API_H__ -#define __LWIP_API_H__ - -#include "lwip/opt.h" - -#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ - -#include /* for size_t */ - -#include "lwip/netbuf.h" -#include "lwip/sys.h" -#include "lwip/ip_addr.h" -#include "lwip/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Throughout this file, IP addresses and port numbers are expected to be in - * the same byte order as in the corresponding pcb. - */ - -/* Flags for netconn_write (u8_t) */ -#define NETCONN_NOFLAG 0x00 -#define NETCONN_NOCOPY 0x00 /* Only for source code compatibility */ -#define NETCONN_COPY 0x01 -#define NETCONN_MORE 0x02 -#define NETCONN_DONTBLOCK 0x04 - -/* Flags for struct netconn.flags (u8_t) */ -/** TCP: when data passed to netconn_write doesn't fit into the send buffer, - this temporarily stores whether to wake up the original application task - if data couldn't be sent in the first try. */ -#define NETCONN_FLAG_WRITE_DELAYED 0x01 -/** Should this netconn avoid blocking? */ -#define NETCONN_FLAG_NON_BLOCKING 0x02 -/** Was the last connect action a non-blocking one? */ -#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04 -/** If this is set, a TCP netconn must call netconn_recved() to update - the TCP receive window (done automatically if not set). */ -#define NETCONN_FLAG_NO_AUTO_RECVED 0x08 -/** If a nonblocking write has been rejected before, poll_tcp needs to - check if the netconn is writable again */ -#define NETCONN_FLAG_CHECK_WRITESPACE 0x10 -#if LWIP_IPV6 -/** If this flag is set then only IPv6 communication is allowed on the - netconn. As per RFC#3493 this features defaults to OFF allowing - dual-stack usage by default. */ -#define NETCONN_FLAG_IPV6_V6ONLY 0x20 -#endif /* LWIP_IPV6 */ - - -/* Helpers to process several netconn_types by the same code */ -#define NETCONNTYPE_GROUP(t) ((t)&0xF0) -#define NETCONNTYPE_DATAGRAM(t) ((t)&0xE0) -#if LWIP_IPV6 -#define NETCONN_TYPE_IPV6 0x08 -#define NETCONNTYPE_ISIPV6(t) ((t)&0x08) -#define NETCONNTYPE_ISUDPLITE(t) (((t)&0xF7) == NETCONN_UDPLITE) -#define NETCONNTYPE_ISUDPNOCHKSUM(t) (((t)&0xF7) == NETCONN_UDPNOCHKSUM) -#else /* LWIP_IPV6 */ -#define NETCONNTYPE_ISUDPLITE(t) ((t) == NETCONN_UDPLITE) -#define NETCONNTYPE_ISUDPNOCHKSUM(t) ((t) == NETCONN_UDPNOCHKSUM) -#endif /* LWIP_IPV6 */ - -/** Protocol family and type of the netconn */ -enum netconn_type { - NETCONN_INVALID = 0, - /* NETCONN_TCP Group */ - NETCONN_TCP = 0x10, -#if LWIP_IPV6 - NETCONN_TCP_IPV6 = NETCONN_TCP | NETCONN_TYPE_IPV6 /* 0x18 */, -#endif /* LWIP_IPV6 */ - /* NETCONN_UDP Group */ - NETCONN_UDP = 0x20, - NETCONN_UDPLITE = 0x21, - NETCONN_UDPNOCHKSUM = 0x22, -#if LWIP_IPV6 - NETCONN_UDP_IPV6 = NETCONN_UDP | NETCONN_TYPE_IPV6 /* 0x28 */, - NETCONN_UDPLITE_IPV6 = NETCONN_UDPLITE | NETCONN_TYPE_IPV6 /* 0x29 */, - NETCONN_UDPNOCHKSUM_IPV6 = NETCONN_UDPNOCHKSUM | NETCONN_TYPE_IPV6 /* 0x2a */, -#endif /* LWIP_IPV6 */ - /* NETCONN_RAW Group */ - NETCONN_RAW = 0x40 -#if LWIP_IPV6 - , - NETCONN_RAW_IPV6 = NETCONN_RAW | NETCONN_TYPE_IPV6 /* 0x48 */ -#endif /* LWIP_IPV6 */ -}; - -/** Current state of the netconn. Non-TCP netconns are always - * in state NETCONN_NONE! */ -enum netconn_state { - NETCONN_NONE, - NETCONN_WRITE, - NETCONN_LISTEN, - NETCONN_CONNECT, - NETCONN_CLOSE -}; - -/** Use to inform the callback function about changes */ -enum netconn_evt { - NETCONN_EVT_RCVPLUS, - NETCONN_EVT_RCVMINUS, - NETCONN_EVT_SENDPLUS, - NETCONN_EVT_SENDMINUS, - NETCONN_EVT_ERROR -}; - -#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) -/** Used for netconn_join_leave_group() */ -enum netconn_igmp { - NETCONN_JOIN, - NETCONN_LEAVE -}; -#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ - -/* forward-declare some structs to avoid to include their headers */ -struct ip_pcb; -struct tcp_pcb; -struct udp_pcb; -struct raw_pcb; -struct netconn; -struct api_msg_msg; - -/** A callback prototype to inform about events for a netconn */ -typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len); - -/** A netconn descriptor */ -struct netconn { - /** type of the netconn (TCP, UDP or RAW) */ - enum netconn_type type; - /** current state of the netconn */ - enum netconn_state state; - /** the lwIP internal protocol control block */ - union { - struct ip_pcb *ip; - struct tcp_pcb *tcp; - struct udp_pcb *udp; - struct raw_pcb *raw; - } pcb; - /** the last error this netconn had */ - err_t last_err; - /** sem that is used to synchroneously execute functions in the core context */ - sys_sem_t op_completed; - /** mbox where received packets are stored until they are fetched - by the netconn application thread (can grow quite big) */ - sys_mbox_t recvmbox; -#if LWIP_TCP - /** mbox where new connections are stored until processed - by the application thread */ - sys_mbox_t acceptmbox; -#endif /* LWIP_TCP */ - /** only used for socket layer */ -#if LWIP_SOCKET - int socket; -#endif /* LWIP_SOCKET */ -#if LWIP_SO_SNDTIMEO - /** timeout to wait for sending data (which means enqueueing data for sending - in internal buffers) */ - s32_t send_timeout; -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVTIMEO - /** timeout to wait for new data to be received - (or connections to arrive for listening netconns) */ - int recv_timeout; -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVBUF - /** maximum amount of bytes queued in recvmbox - not used for TCP: adjust TCP_WND instead! */ - int recv_bufsize; - /** number of bytes currently in recvmbox to be received, - tested against recv_bufsize to limit bytes on recvmbox - for UDP and RAW, used for FIONREAD */ - s16_t recv_avail; -#endif /* LWIP_SO_RCVBUF */ - /** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */ - u8_t flags; -#if LWIP_TCP - /** TCP: when data passed to netconn_write doesn't fit into the send buffer, - this temporarily stores how much is already sent. */ - size_t write_offset; - /** TCP: when data passed to netconn_write doesn't fit into the send buffer, - this temporarily stores the message. - Also used during connect and close. */ - struct api_msg_msg *current_msg; -#endif /* LWIP_TCP */ - /** A callback function that is informed about events for this netconn */ - netconn_callback callback; -}; - -/** Register an Network connection event */ -#define API_EVENT(c,e,l) if (c->callback) { \ - (*c->callback)(c, e, l); \ - } - -/** Set conn->last_err to err but don't overwrite fatal errors */ -#define NETCONN_SET_SAFE_ERR(conn, err) do { \ - SYS_ARCH_DECL_PROTECT(lev); \ - SYS_ARCH_PROTECT(lev); \ - if (!ERR_IS_FATAL((conn)->last_err)) { \ - (conn)->last_err = err; \ - } \ - SYS_ARCH_UNPROTECT(lev); \ -} while(0); - -/* Network connection functions: */ -#define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL) -#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c) -struct -netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto, - netconn_callback callback); -err_t netconn_delete(struct netconn *conn); -/** Get the type of a netconn (as enum netconn_type). */ -#define netconn_type(conn) (conn->type) - -err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr, - u16_t *port, u8_t local); -#define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0) -#define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1) - -err_t netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port); -err_t netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port); -err_t netconn_disconnect (struct netconn *conn); -err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog); -#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG) -err_t netconn_accept(struct netconn *conn, struct netconn **new_conn); -err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf); -err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf); -void netconn_recved(struct netconn *conn, u32_t length); -err_t netconn_sendto(struct netconn *conn, struct netbuf *buf, - ip_addr_t *addr, u16_t port); -err_t netconn_send(struct netconn *conn, struct netbuf *buf); -err_t netconn_write_partly(struct netconn *conn, const void *dataptr, size_t size, - u8_t apiflags, size_t *bytes_written); -#define netconn_write(conn, dataptr, size, apiflags) \ - netconn_write_partly(conn, dataptr, size, apiflags, NULL) -err_t netconn_close(struct netconn *conn); -err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx); - -#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) -err_t netconn_join_leave_group(struct netconn *conn, ip_addr_t *multiaddr, - ip_addr_t *netif_addr, enum netconn_igmp join_or_leave); -#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ -#if LWIP_DNS -err_t netconn_gethostbyname(const char *name, ip_addr_t *addr); -#endif /* LWIP_DNS */ -#if LWIP_IPV6 - -#define netconn_bind_ip6(conn, ip6addr, port) (NETCONNTYPE_ISIPV6((conn)->type) ? \ - netconn_bind(conn, ip6_2_ip(ip6addr), port) : ERR_VAL) -#define netconn_connect_ip6(conn, ip6addr, port) (NETCONNTYPE_ISIPV6((conn)->type) ? \ - netconn_connect(conn, ip6_2_ip(ip6addr), port) : ERR_VAL) -#define netconn_sendto_ip6(conn, buf, ip6addr, port) (NETCONNTYPE_ISIPV6((conn)->type) ? \ - netconn_sendto(conn, buf, ip6_2_ip(ip6addr), port) : ERR_VAL) -#if LWIP_IPV6_MLD -#define netconn_join_leave_group_ip6(conn, multiaddr, srcaddr, join_or_leave) (NETCONNTYPE_ISIPV6((conn)->type) ? \ - netconn_join_leave_group(conn, ip6_2_ip(multiaddr), ip6_2_ip(srcaddr), join_or_leave) :\ - ERR_VAL) -#endif /* LWIP_IPV6_MLD*/ -#endif /* LWIP_IPV6 */ - -#define netconn_err(conn) ((conn)->last_err) -#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize) - -/** Set the blocking status of netconn calls (@todo: write/send is missing) */ -#define netconn_set_nonblocking(conn, val) do { if(val) { \ - (conn)->flags |= NETCONN_FLAG_NON_BLOCKING; \ -} else { \ - (conn)->flags &= ~ NETCONN_FLAG_NON_BLOCKING; }} while(0) -/** Get the blocking status of netconn calls (@todo: write/send is missing) */ -#define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0) - -/** TCP: Set the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */ -#define netconn_set_noautorecved(conn, val) do { if(val) { \ - (conn)->flags |= NETCONN_FLAG_NO_AUTO_RECVED; \ -} else { \ - (conn)->flags &= ~ NETCONN_FLAG_NO_AUTO_RECVED; }} while(0) -/** TCP: Get the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */ -#define netconn_get_noautorecved(conn) (((conn)->flags & NETCONN_FLAG_NO_AUTO_RECVED) != 0) - -#if LWIP_SO_SNDTIMEO -/** Set the send timeout in milliseconds */ -#define netconn_set_sendtimeout(conn, timeout) ((conn)->send_timeout = (timeout)) -/** Get the send timeout in milliseconds */ -#define netconn_get_sendtimeout(conn) ((conn)->send_timeout) -#endif /* LWIP_SO_SNDTIMEO */ -#if LWIP_SO_RCVTIMEO -/** Set the receive timeout in milliseconds */ -#define netconn_set_recvtimeout(conn, timeout) ((conn)->recv_timeout = (timeout)) -/** Get the receive timeout in milliseconds */ -#define netconn_get_recvtimeout(conn) ((conn)->recv_timeout) -#endif /* LWIP_SO_RCVTIMEO */ -#if LWIP_SO_RCVBUF -/** Set the receive buffer in bytes */ -#define netconn_set_recvbufsize(conn, recvbufsize) ((conn)->recv_bufsize = (recvbufsize)) -/** Get the receive buffer in bytes */ -#define netconn_get_recvbufsize(conn) ((conn)->recv_bufsize) -#endif /* LWIP_SO_RCVBUF*/ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_NETCONN */ - -#endif /* __LWIP_API_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/api_msg.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/api_msg.h deleted file mode 100644 index 8268036a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/api_msg.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_API_MSG_H__ -#define __LWIP_API_MSG_H__ - -#include "lwip/opt.h" - -#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ - -#include /* for size_t */ - -#include "lwip/ip_addr.h" -#include "lwip/err.h" -#include "lwip/sys.h" -#include "lwip/igmp.h" -#include "lwip/api.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* For the netconn API, these values are use as a bitmask! */ -#define NETCONN_SHUT_RD 1 -#define NETCONN_SHUT_WR 2 -#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR) - -/* IP addresses and port numbers are expected to be in - * the same byte order as in the corresponding pcb. - */ -/** This struct includes everything that is necessary to execute a function - for a netconn in another thread context (mainly used to process netconns - in the tcpip_thread context to be thread safe). */ -struct api_msg_msg { - /** The netconn which to process - always needed: it includes the semaphore - which is used to block the application thread until the function finished. */ - struct netconn *conn; - /** The return value of the function executed in tcpip_thread. */ - err_t err; - /** Depending on the executed function, one of these union members is used */ - union { - /** used for lwip_netconn_do_send */ - struct netbuf *b; - /** used for lwip_netconn_do_newconn */ - struct { - u8_t proto; - } n; - /** used for lwip_netconn_do_bind and lwip_netconn_do_connect */ - struct { - ip_addr_t *ipaddr; - u16_t port; - } bc; - /** used for lwip_netconn_do_getaddr */ - struct { - ipX_addr_t *ipaddr; - u16_t *port; - u8_t local; - } ad; - /** used for lwip_netconn_do_write */ - struct { - const void *dataptr; - size_t len; - u8_t apiflags; -#if LWIP_SO_SNDTIMEO - u32_t time_started; -#endif /* LWIP_SO_SNDTIMEO */ - } w; - /** used for lwip_netconn_do_recv */ - struct { - u32_t len; - } r; - /** used for lwip_netconn_do_close (/shutdown) */ - struct { - u8_t shut; - } sd; -#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) - /** used for lwip_netconn_do_join_leave_group */ - struct { - ipX_addr_t *multiaddr; - ipX_addr_t *netif_addr; - enum netconn_igmp join_or_leave; - } jl; -#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ -#if TCP_LISTEN_BACKLOG - struct { - u8_t backlog; - } lb; -#endif /* TCP_LISTEN_BACKLOG */ - } msg; -}; - -/** This struct contains a function to execute in another thread context and - a struct api_msg_msg that serves as an argument for this function. - This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */ -struct api_msg { - /** function to execute in tcpip_thread context */ - void (* function)(struct api_msg_msg *msg); - /** arguments for this function */ - struct api_msg_msg msg; -}; - -#if LWIP_DNS -/** As lwip_netconn_do_gethostbyname requires more arguments but doesn't require a netconn, - it has its own struct (to avoid struct api_msg getting bigger than necessary). - lwip_netconn_do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg - (see netconn_gethostbyname). */ -struct dns_api_msg { - /** Hostname to query or dotted IP address string */ - const char *name; - /** Rhe resolved address is stored here */ - ip_addr_t *addr; - /** This semaphore is posted when the name is resolved, the application thread - should wait on it. */ - sys_sem_t *sem; - /** Errors are given back here */ - err_t *err; -}; -#endif /* LWIP_DNS */ - -void lwip_netconn_do_newconn ( struct api_msg_msg *msg); -void lwip_netconn_do_delconn ( struct api_msg_msg *msg); -void lwip_netconn_do_bind ( struct api_msg_msg *msg); -void lwip_netconn_do_connect ( struct api_msg_msg *msg); -void lwip_netconn_do_disconnect ( struct api_msg_msg *msg); -void lwip_netconn_do_listen ( struct api_msg_msg *msg); -void lwip_netconn_do_send ( struct api_msg_msg *msg); -void lwip_netconn_do_recv ( struct api_msg_msg *msg); -void lwip_netconn_do_write ( struct api_msg_msg *msg); -void lwip_netconn_do_getaddr ( struct api_msg_msg *msg); -void lwip_netconn_do_close ( struct api_msg_msg *msg); -void lwip_netconn_do_shutdown ( struct api_msg_msg *msg); -#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) -void lwip_netconn_do_join_leave_group( struct api_msg_msg *msg); -#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */ - -#if LWIP_DNS -void lwip_netconn_do_gethostbyname(void *arg); -#endif /* LWIP_DNS */ - -struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback); -void netconn_free(struct netconn *conn); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_NETCONN */ - -#endif /* __LWIP_API_MSG_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/arch.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/arch.h deleted file mode 100644 index 5adae9ef..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/arch.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_ARCH_H__ -#define __LWIP_ARCH_H__ - -#include "arch/cc.h" - -/** Temporary: define format string for size_t if not defined in cc.h */ -#ifndef SZT_F -#define SZT_F U32_F -#endif /* SZT_F */ -/** Temporary upgrade helper: define format string for u8_t as hex if not - defined in cc.h */ -#ifndef X8_F -#define X8_F "02x" -#endif /* X8_F */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef PACK_STRUCT_BEGIN -#define PACK_STRUCT_BEGIN -#endif /* PACK_STRUCT_BEGIN */ - -#ifndef PACK_STRUCT_END -#define PACK_STRUCT_END -#endif /* PACK_STRUCT_END */ - -#ifndef PACK_STRUCT_FIELD -#define PACK_STRUCT_FIELD(x) x -#endif /* PACK_STRUCT_FIELD */ - - -#ifndef LWIP_UNUSED_ARG -#define LWIP_UNUSED_ARG(x) (void)x -#endif /* LWIP_UNUSED_ARG */ - - -#ifdef LWIP_PROVIDE_ERRNO - -#define EPERM 1 /* Operation not permitted */ -#define ENOENT 2 /* No such file or directory */ -#define ESRCH 3 /* No such process */ -#define EINTR 4 /* Interrupted system call */ -#define EIO 5 /* I/O error */ -#define ENXIO 6 /* No such device or address */ -#define E2BIG 7 /* Arg list too long */ -#define ENOEXEC 8 /* Exec format error */ -#define EBADF 9 /* Bad file number */ -#define ECHILD 10 /* No child processes */ -#define EAGAIN 11 /* Try again */ -#define ENOMEM 12 /* Out of memory */ -#define EACCES 13 /* Permission denied */ -#define EFAULT 14 /* Bad address */ -#define ENOTBLK 15 /* Block device required */ -#define EBUSY 16 /* Device or resource busy */ -#define EEXIST 17 /* File exists */ -#define EXDEV 18 /* Cross-device link */ -#define ENODEV 19 /* No such device */ -#define ENOTDIR 20 /* Not a directory */ -#define EISDIR 21 /* Is a directory */ -#define EINVAL 22 /* Invalid argument */ -#define ENFILE 23 /* File table overflow */ -#define EMFILE 24 /* Too many open files */ -#define ENOTTY 25 /* Not a typewriter */ -#define ETXTBSY 26 /* Text file busy */ -#define EFBIG 27 /* File too large */ -#define ENOSPC 28 /* No space left on device */ -#define ESPIPE 29 /* Illegal seek */ -#define EROFS 30 /* Read-only file system */ -#define EMLINK 31 /* Too many links */ -#define EPIPE 32 /* Broken pipe */ -#define EDOM 33 /* Math argument out of domain of func */ -#define ERANGE 34 /* Math result not representable */ -#define EDEADLK 35 /* Resource deadlock would occur */ -#define ENAMETOOLONG 36 /* File name too long */ -#define ENOLCK 37 /* No record locks available */ -#define ENOSYS 38 /* Function not implemented */ -#define ENOTEMPTY 39 /* Directory not empty */ -#define ELOOP 40 /* Too many symbolic links encountered */ -#define EWOULDBLOCK EAGAIN /* Operation would block */ -#define ENOMSG 42 /* No message of desired type */ -#define EIDRM 43 /* Identifier removed */ -#define ECHRNG 44 /* Channel number out of range */ -#define EL2NSYNC 45 /* Level 2 not synchronized */ -#define EL3HLT 46 /* Level 3 halted */ -#define EL3RST 47 /* Level 3 reset */ -#define ELNRNG 48 /* Link number out of range */ -#define EUNATCH 49 /* Protocol driver not attached */ -#define ENOCSI 50 /* No CSI structure available */ -#define EL2HLT 51 /* Level 2 halted */ -#define EBADE 52 /* Invalid exchange */ -#define EBADR 53 /* Invalid request descriptor */ -#define EXFULL 54 /* Exchange full */ -#define ENOANO 55 /* No anode */ -#define EBADRQC 56 /* Invalid request code */ -#define EBADSLT 57 /* Invalid slot */ - -#define EDEADLOCK EDEADLK - -#define EBFONT 59 /* Bad font file format */ -#define ENOSTR 60 /* Device not a stream */ -#define ENODATA 61 /* No data available */ -#define ETIME 62 /* Timer expired */ -#define ENOSR 63 /* Out of streams resources */ -#define ENONET 64 /* Machine is not on the network */ -#define ENOPKG 65 /* Package not installed */ -#define EREMOTE 66 /* Object is remote */ -#define ENOLINK 67 /* Link has been severed */ -#define EADV 68 /* Advertise error */ -#define ESRMNT 69 /* Srmount error */ -#define ECOMM 70 /* Communication error on send */ -#define EPROTO 71 /* Protocol error */ -#define EMULTIHOP 72 /* Multihop attempted */ -#define EDOTDOT 73 /* RFS specific error */ -#define EBADMSG 74 /* Not a data message */ -#define EOVERFLOW 75 /* Value too large for defined data type */ -#define ENOTUNIQ 76 /* Name not unique on network */ -#define EBADFD 77 /* File descriptor in bad state */ -#define EREMCHG 78 /* Remote address changed */ -#define ELIBACC 79 /* Can not access a needed shared library */ -#define ELIBBAD 80 /* Accessing a corrupted shared library */ -#define ELIBSCN 81 /* .lib section in a.out corrupted */ -#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ -#define ELIBEXEC 83 /* Cannot exec a shared library directly */ -#define EILSEQ 84 /* Illegal byte sequence */ -#define ERESTART 85 /* Interrupted system call should be restarted */ -#define ESTRPIPE 86 /* Streams pipe error */ -#define EUSERS 87 /* Too many users */ -#define ENOTSOCK 88 /* Socket operation on non-socket */ -#define EDESTADDRREQ 89 /* Destination address required */ -#define EMSGSIZE 90 /* Message too long */ -#define EPROTOTYPE 91 /* Protocol wrong type for socket */ -#define ENOPROTOOPT 92 /* Protocol not available */ -#define EPROTONOSUPPORT 93 /* Protocol not supported */ -#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ -#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ -#define EPFNOSUPPORT 96 /* Protocol family not supported */ -#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ -#define EADDRINUSE 98 /* Address already in use */ -#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ -#define ENETDOWN 100 /* Network is down */ -#define ENETUNREACH 101 /* Network is unreachable */ -#define ENETRESET 102 /* Network dropped connection because of reset */ -#define ECONNABORTED 103 /* Software caused connection abort */ -#define ECONNRESET 104 /* Connection reset by peer */ -#define ENOBUFS 105 /* No buffer space available */ -#define EISCONN 106 /* Transport endpoint is already connected */ -#define ENOTCONN 107 /* Transport endpoint is not connected */ -#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ -#define ETOOMANYREFS 109 /* Too many references: cannot splice */ -#define ETIMEDOUT 110 /* Connection timed out */ -#define ECONNREFUSED 111 /* Connection refused */ -#define EHOSTDOWN 112 /* Host is down */ -#define EHOSTUNREACH 113 /* No route to host */ -#define EALREADY 114 /* Operation already in progress */ -#define EINPROGRESS 115 /* Operation now in progress */ -#define ESTALE 116 /* Stale NFS file handle */ -#define EUCLEAN 117 /* Structure needs cleaning */ -#define ENOTNAM 118 /* Not a XENIX named type file */ -#define ENAVAIL 119 /* No XENIX semaphores available */ -#define EISNAM 120 /* Is a named type file */ -#define EREMOTEIO 121 /* Remote I/O error */ -#define EDQUOT 122 /* Quota exceeded */ - -#define ENOMEDIUM 123 /* No medium found */ -#define EMEDIUMTYPE 124 /* Wrong medium type */ - -#ifndef errno -extern int errno; -#endif - -#endif /* LWIP_PROVIDE_ERRNO */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_ARCH_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/debug.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/debug.h deleted file mode 100644 index 0fe04139..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/debug.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_DEBUG_H__ -#define __LWIP_DEBUG_H__ - -#include "lwip/arch.h" -#include "lwip/opt.h" - -/** lower two bits indicate debug level - * - 0 all - * - 1 warning - * - 2 serious - * - 3 severe - */ -#define LWIP_DBG_LEVEL_ALL 0x00 -#define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */ -#define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */ -#define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */ -#define LWIP_DBG_LEVEL_SEVERE 0x03 -#define LWIP_DBG_MASK_LEVEL 0x03 - -/** flag for LWIP_DEBUGF to enable that debug message */ -#define LWIP_DBG_ON 0x80U -/** flag for LWIP_DEBUGF to disable that debug message */ -#define LWIP_DBG_OFF 0x00U - -/** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ -#define LWIP_DBG_TRACE 0x40U -/** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ -#define LWIP_DBG_STATE 0x20U -/** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ -#define LWIP_DBG_FRESH 0x10U -/** flag for LWIP_DEBUGF to halt after printing this debug message */ -#define LWIP_DBG_HALT 0x08U - -#ifndef LWIP_NOASSERT -#define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ - LWIP_PLATFORM_ASSERT(message); } while(0) -#else /* LWIP_NOASSERT */ -#define LWIP_ASSERT(message, assertion) -#endif /* LWIP_NOASSERT */ - -/** if "expression" isn't true, then print "message" and execute "handler" expression */ -#ifndef LWIP_ERROR -#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ - LWIP_PLATFORM_ASSERT(message); handler;}} while(0) -#endif /* LWIP_ERROR */ - -#ifdef LWIP_DEBUG -/** print debug message only if debug message type is enabled... - * AND is of correct type AND is at least LWIP_DBG_LEVEL - */ -#define LWIP_DEBUGF(debug, message) do { \ - if ( \ - ((debug) & LWIP_DBG_ON) && \ - ((debug) & LWIP_DBG_TYPES_ON) && \ - ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ - LWIP_PLATFORM_DIAG(message); \ - if ((debug) & LWIP_DBG_HALT) { \ - while(1); \ - } \ - } \ - } while(0) - -#else /* LWIP_DEBUG */ -#define LWIP_DEBUGF(debug, message) -#endif /* LWIP_DEBUG */ - -#endif /* __LWIP_DEBUG_H__ */ - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/def.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/def.h deleted file mode 100644 index 73a1b560..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/def.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_DEF_H__ -#define __LWIP_DEF_H__ - -/* arch.h might define NULL already */ -#include "lwip/arch.h" -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y)) -#define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y)) - -#ifndef NULL -#define NULL ((void *)0) -#endif - -/* Endianess-optimized shifting of two u8_t to create one u16_t */ -#if BYTE_ORDER == LITTLE_ENDIAN -#define LWIP_MAKE_U16(a, b) ((a << 8) | b) -#else -#define LWIP_MAKE_U16(a, b) ((b << 8) | a) -#endif - -#ifndef LWIP_PLATFORM_BYTESWAP -#define LWIP_PLATFORM_BYTESWAP 0 -#endif - -#ifndef LWIP_PREFIX_BYTEORDER_FUNCS -/* workaround for naming collisions on some platforms */ - -#ifdef htons -#undef htons -#endif /* htons */ -#ifdef htonl -#undef htonl -#endif /* htonl */ -#ifdef ntohs -#undef ntohs -#endif /* ntohs */ -#ifdef ntohl -#undef ntohl -#endif /* ntohl */ - -#define htons(x) lwip_htons(x) -#define ntohs(x) lwip_ntohs(x) -#define htonl(x) lwip_htonl(x) -#define ntohl(x) lwip_ntohl(x) -#endif /* LWIP_PREFIX_BYTEORDER_FUNCS */ - -#if BYTE_ORDER == BIG_ENDIAN -#define lwip_htons(x) (x) -#define lwip_ntohs(x) (x) -#define lwip_htonl(x) (x) -#define lwip_ntohl(x) (x) -#define PP_HTONS(x) (x) -#define PP_NTOHS(x) (x) -#define PP_HTONL(x) (x) -#define PP_NTOHL(x) (x) -#else /* BYTE_ORDER != BIG_ENDIAN */ -#if LWIP_PLATFORM_BYTESWAP -#define lwip_htons(x) LWIP_PLATFORM_HTONS(x) -#define lwip_ntohs(x) LWIP_PLATFORM_HTONS(x) -#define lwip_htonl(x) LWIP_PLATFORM_HTONL(x) -#define lwip_ntohl(x) LWIP_PLATFORM_HTONL(x) -#else /* LWIP_PLATFORM_BYTESWAP */ -u16_t lwip_htons(u16_t x); -u16_t lwip_ntohs(u16_t x); -u32_t lwip_htonl(u32_t x); -u32_t lwip_ntohl(u32_t x); -#endif /* LWIP_PLATFORM_BYTESWAP */ - -/* These macros should be calculated by the preprocessor and are used - with compile-time constants only (so that there is no little-endian - overhead at runtime). */ -#define PP_HTONS(x) ((((x) & 0xff) << 8) | (((x) & 0xff00) >> 8)) -#define PP_NTOHS(x) PP_HTONS(x) -#define PP_HTONL(x) ((((x) & 0xff) << 24) | \ - (((x) & 0xff00) << 8) | \ - (((x) & 0xff0000UL) >> 8) | \ - (((x) & 0xff000000UL) >> 24)) -#define PP_NTOHL(x) PP_HTONL(x) - -#endif /* BYTE_ORDER == BIG_ENDIAN */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_DEF_H__ */ - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/dhcp.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/dhcp.h deleted file mode 100644 index 32d93381..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/dhcp.h +++ /dev/null @@ -1,242 +0,0 @@ -/** @file - */ - -#ifndef __LWIP_DHCP_H__ -#define __LWIP_DHCP_H__ - -#include "lwip/opt.h" - -#if LWIP_DHCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/netif.h" -#include "lwip/udp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** period (in seconds) of the application calling dhcp_coarse_tmr() */ -#define DHCP_COARSE_TIMER_SECS 60 -/** period (in milliseconds) of the application calling dhcp_coarse_tmr() */ -#define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL) -/** period (in milliseconds) of the application calling dhcp_fine_tmr() */ -#define DHCP_FINE_TIMER_MSECS 500 - -#define DHCP_CHADDR_LEN 16U -#define DHCP_SNAME_LEN 64U -#define DHCP_FILE_LEN 128U - -struct dhcp -{ - /** transaction identifier of last sent request */ - u32_t xid; - /** our connection to the DHCP server */ - struct udp_pcb *pcb; - /** incoming msg */ - struct dhcp_msg *msg_in; - /** current DHCP state machine state */ - u8_t state; - /** retries of current request */ - u8_t tries; -#if LWIP_DHCP_AUTOIP_COOP - u8_t autoip_coop_state; -#endif - u8_t subnet_mask_given; - - struct pbuf *p_out; /* pbuf of outcoming msg */ - struct dhcp_msg *msg_out; /* outgoing msg */ - u16_t options_out_len; /* outgoing msg options length */ - u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */ - u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */ - u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */ - ip_addr_t server_ip_addr; /* dhcp server address that offered this lease */ - ip_addr_t offered_ip_addr; - ip_addr_t offered_sn_mask; - ip_addr_t offered_gw_addr; - - u32_t offered_t0_lease; /* lease period (in seconds) */ - u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */ - u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period) */ - /* @todo: LWIP_DHCP_BOOTP_FILE configuration option? - integrate with possible TFTP-client for booting? */ -#if LWIP_DHCP_BOOTP_FILE - ip_addr_t offered_si_addr; - char boot_file_name[DHCP_FILE_LEN]; -#endif /* LWIP_DHCP_BOOTPFILE */ -}; - -/* MUST be compiled with "pack structs" or equivalent! */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** minimum set of fields of any DHCP message */ -struct dhcp_msg -{ - PACK_STRUCT_FIELD(u8_t op); - PACK_STRUCT_FIELD(u8_t htype); - PACK_STRUCT_FIELD(u8_t hlen); - PACK_STRUCT_FIELD(u8_t hops); - PACK_STRUCT_FIELD(u32_t xid); - PACK_STRUCT_FIELD(u16_t secs); - PACK_STRUCT_FIELD(u16_t flags); - PACK_STRUCT_FIELD(ip_addr_p_t ciaddr); - PACK_STRUCT_FIELD(ip_addr_p_t yiaddr); - PACK_STRUCT_FIELD(ip_addr_p_t siaddr); - PACK_STRUCT_FIELD(ip_addr_p_t giaddr); - PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]); - PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]); - PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]); - PACK_STRUCT_FIELD(u32_t cookie); -#define DHCP_MIN_OPTIONS_LEN 68U -/** make sure user does not configure this too small */ -#if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN)) -# undef DHCP_OPTIONS_LEN -#endif -/** allow this to be configured in lwipopts.h, but not too small */ -#if (!defined(DHCP_OPTIONS_LEN)) -/** set this to be sufficient for your options in outgoing DHCP msgs */ -# define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN -#endif - PACK_STRUCT_FIELD(u8_t options[DHCP_OPTIONS_LEN]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -void dhcp_set_struct(struct netif *netif, struct dhcp *dhcp); -/** Remove a struct dhcp previously set to the netif using dhcp_set_struct() */ -#define dhcp_remove_struct(netif) do { (netif)->dhcp = NULL; } while(0) -void dhcp_cleanup(struct netif *netif); -/** start DHCP configuration */ -err_t dhcp_start(struct netif *netif); -/** enforce early lease renewal (not needed normally)*/ -err_t dhcp_renew(struct netif *netif); -/** release the DHCP lease, usually called before dhcp_stop()*/ -err_t dhcp_release(struct netif *netif); -/** stop DHCP configuration */ -void dhcp_stop(struct netif *netif); -/** inform server of our manual IP address */ -void dhcp_inform(struct netif *netif); -/** Handle a possible change in the network configuration */ -void dhcp_network_changed(struct netif *netif); - -/** if enabled, check whether the offered IP address is not in use, using ARP */ -#if DHCP_DOES_ARP_CHECK -void dhcp_arp_reply(struct netif *netif, ip_addr_t *addr); -#endif - -/** to be called every minute */ -void dhcp_coarse_tmr(void); -/** to be called every half second */ -void dhcp_fine_tmr(void); - -/** DHCP message item offsets and length */ -#define DHCP_OP_OFS 0 -#define DHCP_HTYPE_OFS 1 -#define DHCP_HLEN_OFS 2 -#define DHCP_HOPS_OFS 3 -#define DHCP_XID_OFS 4 -#define DHCP_SECS_OFS 8 -#define DHCP_FLAGS_OFS 10 -#define DHCP_CIADDR_OFS 12 -#define DHCP_YIADDR_OFS 16 -#define DHCP_SIADDR_OFS 20 -#define DHCP_GIADDR_OFS 24 -#define DHCP_CHADDR_OFS 28 -#define DHCP_SNAME_OFS 44 -#define DHCP_FILE_OFS 108 -#define DHCP_MSG_LEN 236 - -#define DHCP_COOKIE_OFS DHCP_MSG_LEN -#define DHCP_OPTIONS_OFS (DHCP_MSG_LEN + 4) - -#define DHCP_CLIENT_PORT 68 -#define DHCP_SERVER_PORT 67 - -/** DHCP client states */ -#define DHCP_OFF 0 -#define DHCP_REQUESTING 1 -#define DHCP_INIT 2 -#define DHCP_REBOOTING 3 -#define DHCP_REBINDING 4 -#define DHCP_RENEWING 5 -#define DHCP_SELECTING 6 -#define DHCP_INFORMING 7 -#define DHCP_CHECKING 8 -#define DHCP_PERMANENT 9 -#define DHCP_BOUND 10 -/** not yet implemented #define DHCP_RELEASING 11 */ -#define DHCP_BACKING_OFF 12 - -/** AUTOIP cooperatation flags */ -#define DHCP_AUTOIP_COOP_STATE_OFF 0 -#define DHCP_AUTOIP_COOP_STATE_ON 1 - -#define DHCP_BOOTREQUEST 1 -#define DHCP_BOOTREPLY 2 - -/** DHCP message types */ -#define DHCP_DISCOVER 1 -#define DHCP_OFFER 2 -#define DHCP_REQUEST 3 -#define DHCP_DECLINE 4 -#define DHCP_ACK 5 -#define DHCP_NAK 6 -#define DHCP_RELEASE 7 -#define DHCP_INFORM 8 - -/** DHCP hardware type, currently only ethernet is supported */ -#define DHCP_HTYPE_ETH 1 - -#define DHCP_MAGIC_COOKIE 0x63825363UL - -/* This is a list of options for BOOTP and DHCP, see RFC 2132 for descriptions */ - -/** BootP options */ -#define DHCP_OPTION_PAD 0 -#define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */ -#define DHCP_OPTION_ROUTER 3 -#define DHCP_OPTION_DNS_SERVER 6 -#define DHCP_OPTION_HOSTNAME 12 -#define DHCP_OPTION_IP_TTL 23 -#define DHCP_OPTION_MTU 26 -#define DHCP_OPTION_BROADCAST 28 -#define DHCP_OPTION_TCP_TTL 37 -#define DHCP_OPTION_END 255 - -/** DHCP options */ -#define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */ -#define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */ -#define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */ - -#define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */ -#define DHCP_OPTION_MESSAGE_TYPE_LEN 1 - -#define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */ -#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */ - -#define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */ -#define DHCP_OPTION_MAX_MSG_SIZE_LEN 2 - -#define DHCP_OPTION_T1 58 /* T1 renewal time */ -#define DHCP_OPTION_T2 59 /* T2 rebinding time */ -#define DHCP_OPTION_US 60 -#define DHCP_OPTION_CLIENT_ID 61 -#define DHCP_OPTION_TFTP_SERVERNAME 66 -#define DHCP_OPTION_BOOTFILE 67 - -/** possible combinations of overloading the file and sname fields with options */ -#define DHCP_OVERLOAD_NONE 0 -#define DHCP_OVERLOAD_FILE 1 -#define DHCP_OVERLOAD_SNAME 2 -#define DHCP_OVERLOAD_SNAME_FILE 3 - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_DHCP */ - -#endif /*__LWIP_DHCP_H__*/ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/dns.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/dns.h deleted file mode 100644 index 6c7d9b07..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/dns.h +++ /dev/null @@ -1,124 +0,0 @@ -/** - * lwip DNS resolver header file. - - * Author: Jim Pettinato - * April 2007 - - * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __LWIP_DNS_H__ -#define __LWIP_DNS_H__ - -#include "lwip/opt.h" - -#if LWIP_DNS /* don't build if not configured for use in lwipopts.h */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** DNS timer period */ -#define DNS_TMR_INTERVAL 1000 - -/** DNS field TYPE used for "Resource Records" */ -#define DNS_RRTYPE_A 1 /* a host address */ -#define DNS_RRTYPE_NS 2 /* an authoritative name server */ -#define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */ -#define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */ -#define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */ -#define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */ -#define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */ -#define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */ -#define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */ -#define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */ -#define DNS_RRTYPE_WKS 11 /* a well known service description */ -#define DNS_RRTYPE_PTR 12 /* a domain name pointer */ -#define DNS_RRTYPE_HINFO 13 /* host information */ -#define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */ -#define DNS_RRTYPE_MX 15 /* mail exchange */ -#define DNS_RRTYPE_TXT 16 /* text strings */ - -/** DNS field CLASS used for "Resource Records" */ -#define DNS_RRCLASS_IN 1 /* the Internet */ -#define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */ -#define DNS_RRCLASS_CH 3 /* the CHAOS class */ -#define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */ -#define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */ - -/* The size used for the next line is rather a hack, but it prevents including socket.h in all files - that include memp.h, and that would possibly break portability (since socket.h defines some types - and constants possibly already define by the OS). - Calculation rule: - sizeof(struct addrinfo) + sizeof(struct sockaddr_in) + DNS_MAX_NAME_LENGTH + 1 byte zero-termination */ -#define NETDB_ELEM_SIZE (32 + 16 + DNS_MAX_NAME_LENGTH + 1) - -#if DNS_LOCAL_HOSTLIST -/** struct used for local host-list */ -struct local_hostlist_entry { - /** static hostname */ - const char *name; - /** static host address in network byteorder */ - ip_addr_t addr; - struct local_hostlist_entry *next; -}; -#if DNS_LOCAL_HOSTLIST_IS_DYNAMIC -#ifndef DNS_LOCAL_HOSTLIST_MAX_NAMELEN -#define DNS_LOCAL_HOSTLIST_MAX_NAMELEN DNS_MAX_NAME_LENGTH -#endif -#define LOCALHOSTLIST_ELEM_SIZE ((sizeof(struct local_hostlist_entry) + DNS_LOCAL_HOSTLIST_MAX_NAMELEN + 1)) -#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ -#endif /* DNS_LOCAL_HOSTLIST */ - -/** Callback which is invoked when a hostname is found. - * A function of this type must be implemented by the application using the DNS resolver. - * @param name pointer to the name that was looked up. - * @param ipaddr pointer to an ip_addr_t containing the IP address of the hostname, - * or NULL if the name could not be found (or on any other error). - * @param callback_arg a user-specified callback argument passed to dns_gethostbyname -*/ -typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *callback_arg); - -void dns_init(void); -void dns_tmr(void); -void dns_setserver(u8_t numdns, ip_addr_t *dnsserver); -ip_addr_t dns_getserver(u8_t numdns); -err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr, - dns_found_callback found, void *callback_arg); - -#if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC -int dns_local_removehost(const char *hostname, const ip_addr_t *addr); -err_t dns_local_addhost(const char *hostname, const ip_addr_t *addr); -#endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_DNS */ - -#endif /* __LWIP_DNS_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/err.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/err.h deleted file mode 100644 index ac907729..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/err.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_ERR_H__ -#define __LWIP_ERR_H__ - -#include "lwip/opt.h" -#include "lwip/arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Define LWIP_ERR_T in cc.h if you want to use - * a different type for your platform (must be signed). */ -#ifdef LWIP_ERR_T -typedef LWIP_ERR_T err_t; -#else /* LWIP_ERR_T */ -typedef s8_t err_t; -#endif /* LWIP_ERR_T*/ - -/* Definitions for error constants. */ - -#define ERR_OK 0 /* No error, everything OK. */ -#define ERR_MEM -1 /* Out of memory error. */ -#define ERR_BUF -2 /* Buffer error. */ -#define ERR_TIMEOUT -3 /* Timeout. */ -#define ERR_RTE -4 /* Routing problem. */ -#define ERR_INPROGRESS -5 /* Operation in progress */ -#define ERR_VAL -6 /* Illegal value. */ -#define ERR_WOULDBLOCK -7 /* Operation would block. */ -#define ERR_USE -8 /* Address in use. */ -#define ERR_ISCONN -9 /* Already connected. */ - -#define ERR_IS_FATAL(e) ((e) < ERR_ISCONN) - -#define ERR_ABRT -10 /* Connection aborted. */ -#define ERR_RST -11 /* Connection reset. */ -#define ERR_CLSD -12 /* Connection closed. */ -#define ERR_CONN -13 /* Not connected. */ - -#define ERR_ARG -14 /* Illegal argument. */ - -#define ERR_IF -15 /* Low-level netif error */ - - -#ifdef LWIP_DEBUG -extern const char *lwip_strerr(err_t err); -#else -#define lwip_strerr(x) "" -#endif /* LWIP_DEBUG */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_ERR_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/inet_chksum.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/inet_chksum.h deleted file mode 100644 index e1687888..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/inet_chksum.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_INET_CHKSUM_H__ -#define __LWIP_INET_CHKSUM_H__ - -#include "lwip/opt.h" - -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" - -/** Swap the bytes in an u16_t: much like htons() for little-endian */ -#ifndef SWAP_BYTES_IN_WORD -#if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) -/* little endian and PLATFORM_BYTESWAP defined */ -#define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(w) -#else /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) */ -/* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */ -#define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8) -#endif /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)*/ -#endif /* SWAP_BYTES_IN_WORD */ - -/** Split an u32_t in two u16_ts and add them up */ -#ifndef FOLD_U32T -#define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL)) -#endif - -#if LWIP_CHECKSUM_ON_COPY -/** Function-like macro: same as MEMCPY but returns the checksum of copied data - as u16_t */ -#ifndef LWIP_CHKSUM_COPY -#define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len) -#ifndef LWIP_CHKSUM_COPY_ALGORITHM -#define LWIP_CHKSUM_COPY_ALGORITHM 1 -#endif /* LWIP_CHKSUM_COPY_ALGORITHM */ -#endif /* LWIP_CHKSUM_COPY */ -#else /* LWIP_CHECKSUM_ON_COPY */ -#define LWIP_CHKSUM_COPY_ALGORITHM 0 -#endif /* LWIP_CHECKSUM_ON_COPY */ - -#ifdef __cplusplus -extern "C" { -#endif - -u16_t inet_chksum(void *dataptr, u16_t len); -u16_t inet_chksum_pbuf(struct pbuf *p); -u16_t inet_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, - ip_addr_t *src, ip_addr_t *dest); -u16_t inet_chksum_pseudo_partial(struct pbuf *p, u8_t proto, - u16_t proto_len, u16_t chksum_len, ip_addr_t *src, ip_addr_t *dest); -#if LWIP_CHKSUM_COPY_ALGORITHM -u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len); -#endif /* LWIP_CHKSUM_COPY_ALGORITHM */ - -#if LWIP_IPV6 -u16_t ip6_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len, - ip6_addr_t *src, ip6_addr_t *dest); -u16_t ip6_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len, - u16_t chksum_len, ip6_addr_t *src, ip6_addr_t *dest); - -#define ipX_chksum_pseudo(isipv6, p, proto, proto_len, src, dest) \ - ((isipv6) ? \ - ip6_chksum_pseudo(p, proto, proto_len, ipX_2_ip6(src), ipX_2_ip6(dest)) :\ - inet_chksum_pseudo(p, proto, proto_len, ipX_2_ip(src), ipX_2_ip(dest))) -#define ipX_chksum_pseudo_partial(isipv6, p, proto, proto_len, chksum_len, src, dest) \ - ((isipv6) ? \ - ip6_chksum_pseudo_partial(p, proto, proto_len, chksum_len, ipX_2_ip6(src), ipX_2_ip6(dest)) :\ - inet_chksum_pseudo_partial(p, proto, proto_len, chksum_len, ipX_2_ip(src), ipX_2_ip(dest))) - -#else /* LWIP_IPV6 */ - -#define ipX_chksum_pseudo(isipv6, p, proto, proto_len, src, dest) \ - inet_chksum_pseudo(p, proto, proto_len, src, dest) -#define ipX_chksum_pseudo_partial(isipv6, p, proto, proto_len, chksum_len, src, dest) \ - inet_chksum_pseudo_partial(p, proto, proto_len, chksum_len, src, dest) - -#endif /* LWIP_IPV6 */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_INET_H__ */ - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/init.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/init.h deleted file mode 100644 index 4e2e2856..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/init.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_INIT_H__ -#define __LWIP_INIT_H__ - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** X.x.x: Major version of the stack */ -#define LWIP_VERSION_MAJOR 1U -/** x.X.x: Minor version of the stack */ -#define LWIP_VERSION_MINOR 4U -/** x.x.X: Revision of the stack */ -#define LWIP_VERSION_REVISION 1U -/** For release candidates, this is set to 1..254 - * For official releases, this is set to 255 (LWIP_RC_RELEASE) - * For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */ -#define LWIP_VERSION_RC 0U - -/** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ -#define LWIP_RC_RELEASE 255U -/** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for CVS versions */ -#define LWIP_RC_DEVELOPMENT 0U - -#define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) -#define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) -#define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) - -/** Provides the version of the stack */ -#define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \ - LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC) - -/* Modules initialization */ -void lwip_init(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_INIT_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/ip.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/ip.h deleted file mode 100644 index a0cd1d4d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/ip.h +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_IP_H__ -#define __LWIP_IP_H__ - -#include "lwip/opt.h" - -#include "lwip/def.h" -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" -#include "lwip/err.h" -#include "lwip/netif.h" -#include "lwip/ip4.h" -#include "lwip/ip6.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* This is passed as the destination address to ip_output_if (not - to ip_output), meaning that an IP header already is constructed - in the pbuf. This is used when TCP retransmits. */ -#ifdef IP_HDRINCL -#undef IP_HDRINCL -#endif /* IP_HDRINCL */ -#define IP_HDRINCL NULL - -#if LWIP_NETIF_HWADDRHINT -#define IP_PCB_ADDRHINT ;u8_t addr_hint -#else -#define IP_PCB_ADDRHINT -#endif /* LWIP_NETIF_HWADDRHINT */ - -#if LWIP_IPV6 -#define IP_PCB_ISIPV6_MEMBER u8_t isipv6; -#define IP_PCB_IPVER_EQ(pcb1, pcb2) ((pcb1)->isipv6 == (pcb2)->isipv6) -#define IP_PCB_IPVER_INPUT_MATCH(pcb) (ip_current_is_v6() ? \ - ((pcb)->isipv6 != 0) : \ - ((pcb)->isipv6 == 0)) -#define PCB_ISIPV6(pcb) ((pcb)->isipv6) -#else -#define IP_PCB_ISIPV6_MEMBER -#define IP_PCB_IPVER_EQ(pcb1, pcb2) 1 -#define IP_PCB_IPVER_INPUT_MATCH(pcb) 1 -#define PCB_ISIPV6(pcb) 0 -#endif /* LWIP_IPV6 */ - -/* This is the common part of all PCB types. It needs to be at the - beginning of a PCB type definition. It is located here so that - changes to this common part are made in one location instead of - having to change all PCB structs. */ -#define IP_PCB \ - IP_PCB_ISIPV6_MEMBER \ - /* ip addresses in network byte order */ \ - ipX_addr_t local_ip; \ - ipX_addr_t remote_ip; \ - /* Socket options */ \ - u8_t so_options; \ - /* Type Of Service */ \ - u8_t tos; \ - /* Time To Live */ \ - u8_t ttl \ - /* link layer address resolution hint */ \ - IP_PCB_ADDRHINT - -struct ip_pcb { -/* Common members of all PCB types */ - IP_PCB; -}; - -/* - * Option flags per-socket. These are the same like SO_XXX. - */ -/*#define SOF_DEBUG 0x01U Unimplemented: turn on debugging info recording */ -#define SOF_ACCEPTCONN 0x02U /* socket has had listen() */ -#define SOF_REUSEADDR 0x04U /* allow local address reuse */ -#define SOF_KEEPALIVE 0x08U /* keep connections alive */ -/*#define SOF_DONTROUTE 0x10U Unimplemented: just use interface addresses */ -#define SOF_BROADCAST 0x20U /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ -/*#define SOF_USELOOPBACK 0x40U Unimplemented: bypass hardware when possible */ -#define SOF_LINGER 0x80U /* linger on close if data present */ -/*#define SOF_OOBINLINE 0x0100U Unimplemented: leave received OOB data in line */ -/*#define SOF_REUSEPORT 0x0200U Unimplemented: allow local address & port reuse */ - -/* These flags are inherited (e.g. from a listen-pcb to a connection-pcb): */ -#define SOF_INHERITED (SOF_REUSEADDR|SOF_KEEPALIVE|SOF_LINGER/*|SOF_DEBUG|SOF_DONTROUTE|SOF_OOBINLINE*/) - -/* Global variables of this module, kept in a struct for efficient access using base+index. */ -struct ip_globals -{ - /** The interface that provided the packet for the current callback invocation. */ - struct netif *current_netif; - /** Header of the input packet currently being processed. */ - const struct ip_hdr *current_ip4_header; -#if LWIP_IPV6 - /** Header of the input IPv6 packet currently being processed. */ - const struct ip6_hdr *current_ip6_header; -#endif /* LWIP_IPV6 */ - /** Total header length of current_ip4/6_header (i.e. after this, the UDP/TCP header starts) */ - u16_t current_ip_header_tot_len; - /** Source IP address of current_header */ - ipX_addr_t current_iphdr_src; - /** Destination IP address of current_header */ - ipX_addr_t current_iphdr_dest; -}; -extern struct ip_globals ip_data; - - -/** Get the interface that received the current packet. - * This function must only be called from a receive callback (udp_recv, - * raw_recv, tcp_accept). It will return NULL otherwise. */ -#define ip_current_netif() (ip_data.current_netif) -/** Get the IP header of the current packet. - * This function must only be called from a receive callback (udp_recv, - * raw_recv, tcp_accept). It will return NULL otherwise. */ -#define ip_current_header() (ip_data.current_ip4_header) -/** Total header length of ip(6)_current_header() (i.e. after this, the UDP/TCP header starts) */ -#define ip_current_header_tot_len() (ip_data.current_ip_header_tot_len) -/** Source IP address of current_header */ -#define ipX_current_src_addr() (&ip_data.current_iphdr_src) -/** Destination IP address of current_header */ -#define ipX_current_dest_addr() (&ip_data.current_iphdr_dest) - -#if LWIP_IPV6 -/** Get the IPv6 header of the current packet. - * This function must only be called from a receive callback (udp_recv, - * raw_recv, tcp_accept). It will return NULL otherwise. */ -#define ip6_current_header() (ip_data.current_ip6_header) -/** Returns TRUE if the current IP input packet is IPv6, FALSE if it is IPv4 */ -#define ip_current_is_v6() (ip6_current_header() != NULL) -/** Source IPv6 address of current_header */ -#define ip6_current_src_addr() (ipX_2_ip6(&ip_data.current_iphdr_src)) -/** Destination IPv6 address of current_header */ -#define ip6_current_dest_addr() (ipX_2_ip6(&ip_data.current_iphdr_dest)) -/** Get the transport layer protocol */ -#define ip_current_header_proto() (ip_current_is_v6() ? \ - IP6H_NEXTH(ip6_current_header()) :\ - IPH_PROTO(ip_current_header())) -/** Get the transport layer header */ -#define ipX_next_header_ptr() ((void*)((ip_current_is_v6() ? \ - (u8_t*)ip6_current_header() : (u8_t*)ip_current_header()) + ip_current_header_tot_len())) - -/** Set an IP_PCB to IPv6 (IPv4 is the default) */ -#define ip_set_v6(pcb, val) do{if(pcb != NULL) { pcb->isipv6 = val; }}while(0) - -/** Source IP4 address of current_header */ -#define ip_current_src_addr() (ipX_2_ip(&ip_data.current_iphdr_src)) -/** Destination IP4 address of current_header */ -#define ip_current_dest_addr() (ipX_2_ip(&ip_data.current_iphdr_dest)) - -#else /* LWIP_IPV6 */ - -/** Always returns FALSE when only supporting IPv4 */ -#define ip_current_is_v6() 0 -/** Get the transport layer protocol */ -#define ip_current_header_proto() IPH_PROTO(ip_current_header()) -/** Get the transport layer header */ -#define ipX_next_header_ptr() ((void*)((u8_t*)ip_current_header() + ip_current_header_tot_len())) -/** Source IP4 address of current_header */ -#define ip_current_src_addr() (&ip_data.current_iphdr_src) -/** Destination IP4 address of current_header */ -#define ip_current_dest_addr() (&ip_data.current_iphdr_dest) - -#endif /* LWIP_IPV6 */ - -/** Union source address of current_header */ -#define ipX_current_src_addr() (&ip_data.current_iphdr_src) -/** Union destination address of current_header */ -#define ipX_current_dest_addr() (&ip_data.current_iphdr_dest) - -/** Gets an IP pcb option (SOF_* flags) */ -#define ip_get_option(pcb, opt) ((pcb)->so_options & (opt)) -/** Sets an IP pcb option (SOF_* flags) */ -#define ip_set_option(pcb, opt) ((pcb)->so_options |= (opt)) -/** Resets an IP pcb option (SOF_* flags) */ -#define ip_reset_option(pcb, opt) ((pcb)->so_options &= ~(opt)) - -#if LWIP_IPV6 -#define ipX_output(isipv6, p, src, dest, ttl, tos, proto) \ - ((isipv6) ? \ - ip6_output(p, ipX_2_ip6(src), ipX_2_ip6(dest), ttl, tos, proto) : \ - ip_output(p, ipX_2_ip(src), ipX_2_ip(dest), ttl, tos, proto)) -#define ipX_output_if(isipv6, p, src, dest, ttl, tos, proto, netif) \ - ((isipv6) ? \ - ip6_output_if(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, netif) : \ - ip_output_if(p, (src), (dest), ttl, tos, proto, netif)) -#define ipX_output_hinted(isipv6, p, src, dest, ttl, tos, proto, addr_hint) \ - ((isipv6) ? \ - ip6_output_hinted(p, ipX_2_ip6(src), ipX_2_ip6(dest), ttl, tos, proto, addr_hint) : \ - ip_output_hinted(p, ipX_2_ip(src), ipX_2_ip(dest), ttl, tos, proto, addr_hint)) -#define ipX_route(isipv6, src, dest) \ - ((isipv6) ? \ - ip6_route(ipX_2_ip6(src), ipX_2_ip6(dest)) : \ - ip_route(ipX_2_ip(dest))) -#define ipX_netif_get_local_ipX(isipv6, netif, dest) \ - ((isipv6) ? \ - ip6_netif_get_local_ipX(netif, ipX_2_ip6(dest)) : \ - ip_netif_get_local_ipX(netif)) -#define ipX_debug_print(is_ipv6, p) ((is_ipv6) ? ip6_debug_print(p) : ip_debug_print(p)) -#else /* LWIP_IPV6 */ -#define ipX_output(isipv6, p, src, dest, ttl, tos, proto) \ - ip_output(p, src, dest, ttl, tos, proto) -#define ipX_output_if(isipv6, p, src, dest, ttl, tos, proto, netif) \ - ip_output_if(p, src, dest, ttl, tos, proto, netif) -#define ipX_output_hinted(isipv6, p, src, dest, ttl, tos, proto, addr_hint) \ - ip_output_hinted(p, src, dest, ttl, tos, proto, addr_hint) -#define ipX_route(isipv6, src, dest) \ - ip_route(ipX_2_ip(dest)) -#define ipX_netif_get_local_ipX(isipv6, netif, dest) \ - ip_netif_get_local_ipX(netif) -#define ipX_debug_print(is_ipv6, p) ip_debug_print(p) -#endif /* LWIP_IPV6 */ - -#define ipX_route_get_local_ipX(isipv6, src, dest, netif, ipXaddr) do { \ - (netif) = ipX_route(isipv6, src, dest); \ - (ipXaddr) = ipX_netif_get_local_ipX(isipv6, netif, dest); \ -}while(0) - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_IP_H__ */ - - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/ip_addr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/ip_addr.h deleted file mode 100644 index 7bd03cbd..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/ip_addr.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_IP_ADDR_H__ -#define __LWIP_IP_ADDR_H__ - -#include "lwip/opt.h" -#include "lwip/def.h" - -#include "lwip/ip4_addr.h" -#include "lwip/ip6_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_IPV6 -/* A union struct for both IP version's addresses. */ -typedef union { - ip_addr_t ip4; - ip6_addr_t ip6; -} ipX_addr_t; - -/** These functions only exist for type-safe conversion from ip_addr_t to - ip6_addr_t and back */ -#ifdef LWIP_ALLOW_STATIC_FN_IN_HEADER -static ip6_addr_t* ip_2_ip6(ip_addr_t *ipaddr) -{ return (ip6_addr_t*)ipaddr;} -static ip_addr_t* ip6_2_ip(ip6_addr_t *ip6addr) -{ return (ip_addr_t*)ip6addr; } -static ipX_addr_t* ip_2_ipX(ip_addr_t *ipaddr) -{ return (ipX_addr_t*)ipaddr; } -static ipX_addr_t* ip6_2_ipX(ip6_addr_t *ip6addr) -{ return (ipX_addr_t*)ip6addr; } -#else /* LWIP_ALLOW_STATIC_FN_IN_HEADER */ -#define ip_2_ip6(ipaddr) ((ip6_addr_t*)(ipaddr)) -#define ip6_2_ip(ip6addr) ((ip_addr_t*)(ip6addr)) -#define ip_2_ipX(ipaddr) ((ipX_addr_t*)ipaddr) -#define ip6_2_ipX(ip6addr) ((ipX_addr_t*)ip6addr) -#endif /* LWIP_ALLOW_STATIC_FN_IN_HEADER*/ -#define ipX_2_ip6(ip6addr) (&((ip6addr)->ip6)) -#define ipX_2_ip(ipaddr) (&((ipaddr)->ip4)) - -#define ipX_addr_copy(is_ipv6, dest, src) do{if(is_ipv6){ \ - ip6_addr_copy((dest).ip6, (src).ip6); }else{ \ - ip_addr_copy((dest).ip4, (src).ip4); }}while(0) -#define ipX_addr_set(is_ipv6, dest, src) do{if(is_ipv6){ \ - ip6_addr_set(ipX_2_ip6(dest), ipX_2_ip6(src)); }else{ \ - ip_addr_set(ipX_2_ip(dest), ipX_2_ip(src)); }}while(0) -#define ipX_addr_set_ipaddr(is_ipv6, dest, src) do{if(is_ipv6){ \ - ip6_addr_set(ipX_2_ip6(dest), ip_2_ip6(src)); }else{ \ - ip_addr_set(ipX_2_ip(dest), src); }}while(0) -#define ipX_addr_set_zero(is_ipv6, ipaddr) do{if(is_ipv6){ \ - ip6_addr_set_zero(ipX_2_ip6(ipaddr)); }else{ \ - ip_addr_set_zero(ipX_2_ip(ipaddr)); }}while(0) -#define ipX_addr_set_any(is_ipv6, ipaddr) do{if(is_ipv6){ \ - ip6_addr_set_any(ipX_2_ip6(ipaddr)); }else{ \ - ip_addr_set_any(ipX_2_ip(ipaddr)); }}while(0) -#define ipX_addr_set_loopback(is_ipv6, ipaddr) do{if(is_ipv6){ \ - ip6_addr_set_loopback(ipX_2_ip6(ipaddr)); }else{ \ - ip_addr_set_loopback(ipX_2_ip(ipaddr)); }}while(0) -#define ipX_addr_set_hton(is_ipv6, dest, src) do{if(is_ipv6){ \ - ip6_addr_set_hton(ipX_2_ip6(ipaddr), (src)) ;}else{ \ - ip_addr_set_hton(ipX_2_ip(ipaddr), (src));}}while(0) -#define ipX_addr_cmp(is_ipv6, addr1, addr2) ((is_ipv6) ? \ - ip6_addr_cmp(ipX_2_ip6(addr1), ipX_2_ip6(addr2)) : \ - ip_addr_cmp(ipX_2_ip(addr1), ipX_2_ip(addr2))) -#define ipX_addr_isany(is_ipv6, ipaddr) ((is_ipv6) ? \ - ip6_addr_isany(ipX_2_ip6(ipaddr)) : \ - ip_addr_isany(ipX_2_ip(ipaddr))) -#define ipX_addr_ismulticast(is_ipv6, ipaddr) ((is_ipv6) ? \ - ip6_addr_ismulticast(ipX_2_ip6(ipaddr)) : \ - ip_addr_ismulticast(ipX_2_ip(ipaddr))) -#define ipX_addr_debug_print(is_ipv6, debug, ipaddr) do { if(is_ipv6) { \ - ip6_addr_debug_print(debug, ipX_2_ip6(ipaddr)); } else { \ - ip_addr_debug_print(debug, ipX_2_ip(ipaddr)); }}while(0) - -#else /* LWIP_IPV6 */ - -typedef ip_addr_t ipX_addr_t; -#define ipX_2_ip(ipaddr) (ipaddr) -#define ip_2_ipX(ipaddr) (ipaddr) - -#define ipX_addr_copy(is_ipv6, dest, src) ip_addr_copy(dest, src) -#define ipX_addr_set(is_ipv6, dest, src) ip_addr_set(dest, src) -#define ipX_addr_set_ipaddr(is_ipv6, dest, src) ip_addr_set(dest, src) -#define ipX_addr_set_zero(is_ipv6, ipaddr) ip_addr_set_zero(ipaddr) -#define ipX_addr_set_any(is_ipv6, ipaddr) ip_addr_set_any(ipaddr) -#define ipX_addr_set_loopback(is_ipv6, ipaddr) ip_addr_set_loopback(ipaddr) -#define ipX_addr_set_hton(is_ipv6, dest, src) ip_addr_set_hton(dest, src) -#define ipX_addr_cmp(is_ipv6, addr1, addr2) ip_addr_cmp(addr1, addr2) -#define ipX_addr_isany(is_ipv6, ipaddr) ip_addr_isany(ipaddr) -#define ipX_addr_ismulticast(is_ipv6, ipaddr) ip_addr_ismulticast(ipaddr) -#define ipX_addr_debug_print(is_ipv6, debug, ipaddr) ip_addr_debug_print(debug, ipaddr) - -#endif /* LWIP_IPV6 */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_IP_ADDR_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/mem.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/mem.h deleted file mode 100644 index 0ad9db65..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/mem.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_MEM_H__ -#define __LWIP_MEM_H__ - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if MEM_LIBC_MALLOC - -#include /* for size_t */ - -typedef size_t mem_size_t; -#define MEM_SIZE_F SZT_F - -/* aliases for C library malloc() */ -#define mem_init() -/* in case C library malloc() needs extra protection, - * allow these defines to be overridden. - */ -#ifndef mem_free -#define mem_free(mem) do {free(mem); (mem)=NULL;} while (0); -#endif -#ifndef mem_malloc -#define mem_malloc malloc -#endif -#ifndef mem_calloc -#define mem_calloc calloc -#endif -/* Since there is no C library allocation function to shrink memory without - moving it, define this to nothing. */ -#ifndef mem_trim -#define mem_trim(mem, size) (mem) -#endif -#else /* MEM_LIBC_MALLOC */ - -/* MEM_SIZE would have to be aligned, but using 64000 here instead of - * 65535 leaves some room for alignment... - */ -#if MEM_SIZE > 64000L -typedef u32_t mem_size_t; -#define MEM_SIZE_F U32_F -#else -typedef u16_t mem_size_t; -#define MEM_SIZE_F U16_F -#endif /* MEM_SIZE > 64000 */ - -#if MEM_USE_POOLS -/** mem_init is not used when using pools instead of a heap */ -#define mem_init() -/** mem_trim is not used when using pools instead of a heap: - we can't free part of a pool element and don't want to copy the rest */ -#define mem_trim(mem, size) (mem) -#else /* MEM_USE_POOLS */ -/* lwIP alternative malloc */ -void mem_init(void); -void *mem_trim(void *mem, mem_size_t size); -#endif /* MEM_USE_POOLS */ -void *mem_malloc(mem_size_t size); -void *mem_calloc(mem_size_t count, mem_size_t size); -void mem_free(void *mem); -#endif /* MEM_LIBC_MALLOC */ - -/** Calculate memory size for an aligned buffer - returns the next highest - * multiple of MEM_ALIGNMENT (e.g. LWIP_MEM_ALIGN_SIZE(3) and - * LWIP_MEM_ALIGN_SIZE(4) will both yield 4 for MEM_ALIGNMENT == 4). - */ -#ifndef LWIP_MEM_ALIGN_SIZE -#define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1)) -#endif - -/** Calculate safe memory size for an aligned buffer when using an unaligned - * type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the - * start (e.g. if buffer is u8_t[] and actual data will be u32_t*) - */ -#ifndef LWIP_MEM_ALIGN_BUFFER -#define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1)) -#endif - -/** Align a memory pointer to the alignment defined by MEM_ALIGNMENT - * so that ADDR % MEM_ALIGNMENT == 0 - */ -#ifndef LWIP_MEM_ALIGN -#define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1))) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_MEM_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/memp.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/memp.h deleted file mode 100644 index f0d07399..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/memp.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef __LWIP_MEMP_H__ -#define __LWIP_MEMP_H__ - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */ -typedef enum { -#define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name, -#include "lwip/memp_std.h" - MEMP_MAX -} memp_t; - -#if MEM_USE_POOLS -/* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */ -typedef enum { - /* Get the first (via: - MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/ - MEMP_POOL_HELPER_FIRST = ((u8_t) -#define LWIP_MEMPOOL(name,num,size,desc) -#define LWIP_MALLOC_MEMPOOL_START 1 -#define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0 -#define LWIP_MALLOC_MEMPOOL_END -#include "lwip/memp_std.h" - ) , - /* Get the last (via: - MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */ - MEMP_POOL_HELPER_LAST = ((u8_t) -#define LWIP_MEMPOOL(name,num,size,desc) -#define LWIP_MALLOC_MEMPOOL_START -#define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size * -#define LWIP_MALLOC_MEMPOOL_END 1 -#include "lwip/memp_std.h" - ) -} memp_pool_helper_t; - -/* The actual start and stop values are here (cast them over) - We use this helper type and these defines so we can avoid using const memp_t values */ -#define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST) -#define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST) -#endif /* MEM_USE_POOLS */ - -#if MEMP_MEM_MALLOC || MEM_USE_POOLS -extern const u16_t memp_sizes[MEMP_MAX]; -#endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */ - -#if MEMP_MEM_MALLOC - -#include "mem.h" - -#define memp_init() -#define memp_malloc(type) mem_malloc(memp_sizes[type]) -#define memp_free(type, mem) mem_free(mem) - -#else /* MEMP_MEM_MALLOC */ - -#if MEM_USE_POOLS -/** This structure is used to save the pool one element came from. */ -struct memp_malloc_helper -{ - memp_t poolnr; -}; -#endif /* MEM_USE_POOLS */ - -void memp_init(void); - -#if MEMP_OVERFLOW_CHECK -void *memp_malloc_fn(memp_t type, const char* file, const int line); -#define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__) -#else -void *memp_malloc(memp_t type); -#endif -void memp_free(memp_t type, void *mem); - -#endif /* MEMP_MEM_MALLOC */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_MEMP_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/memp_std.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/memp_std.h deleted file mode 100644 index 592a2824..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/memp_std.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * SETUP: Make sure we define everything we will need. - * - * We have create three types of pools: - * 1) MEMPOOL - standard pools - * 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c - * 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct - * - * If the include'r doesn't require any special treatment of each of the types - * above, then will declare #2 & #3 to be just standard mempools. - */ -#ifndef LWIP_MALLOC_MEMPOOL -/* This treats "malloc pools" just like any other pool. - The pools are a little bigger to provide 'size' as the amount of user data. */ -#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + sizeof(struct memp_malloc_helper)), "MALLOC_"#size) -#define LWIP_MALLOC_MEMPOOL_START -#define LWIP_MALLOC_MEMPOOL_END -#endif /* LWIP_MALLOC_MEMPOOL */ - -#ifndef LWIP_PBUF_MEMPOOL -/* This treats "pbuf pools" just like any other pool. - * Allocates buffers for a pbuf struct AND a payload size */ -#define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc) -#endif /* LWIP_PBUF_MEMPOOL */ - - -/* - * A list of internal pools used by LWIP. - * - * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description) - * creates a pool name MEMP_pool_name. description is used in stats.c - */ -#if LWIP_RAW -LWIP_MEMPOOL(RAW_PCB, MEMP_NUM_RAW_PCB, sizeof(struct raw_pcb), "RAW_PCB") -#endif /* LWIP_RAW */ - -#if LWIP_UDP -LWIP_MEMPOOL(UDP_PCB, MEMP_NUM_UDP_PCB, sizeof(struct udp_pcb), "UDP_PCB") -#endif /* LWIP_UDP */ - -#if LWIP_TCP -LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB") -LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN") -LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG") -#endif /* LWIP_TCP */ - -#if IP_REASSEMBLY -LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA") -#endif /* IP_REASSEMBLY */ -#if (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF) || LWIP_IPV6_FRAG -LWIP_MEMPOOL(FRAG_PBUF, MEMP_NUM_FRAG_PBUF, sizeof(struct pbuf_custom_ref),"FRAG_PBUF") -#endif /* IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ - -#if LWIP_NETCONN -LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF") -LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN") -#endif /* LWIP_NETCONN */ - -#if NO_SYS==0 -LWIP_MEMPOOL(TCPIP_MSG_API, MEMP_NUM_TCPIP_MSG_API, sizeof(struct tcpip_msg), "TCPIP_MSG_API") -#if !LWIP_TCPIP_CORE_LOCKING_INPUT -LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg), "TCPIP_MSG_INPKT") -#endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */ -#endif /* NO_SYS==0 */ - -#if LWIP_ARP && ARP_QUEUEING -LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE") -#endif /* LWIP_ARP && ARP_QUEUEING */ - -#if LWIP_IGMP -LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP") -#endif /* LWIP_IGMP */ - -#if (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) /* LWIP_TIMERS */ -LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT") -#endif /* LWIP_TIMERS */ - -#if LWIP_SNMP -LWIP_MEMPOOL(SNMP_ROOTNODE, MEMP_NUM_SNMP_ROOTNODE, sizeof(struct mib_list_rootnode), "SNMP_ROOTNODE") -LWIP_MEMPOOL(SNMP_NODE, MEMP_NUM_SNMP_NODE, sizeof(struct mib_list_node), "SNMP_NODE") -LWIP_MEMPOOL(SNMP_VARBIND, MEMP_NUM_SNMP_VARBIND, sizeof(struct snmp_varbind), "SNMP_VARBIND") -LWIP_MEMPOOL(SNMP_VALUE, MEMP_NUM_SNMP_VALUE, SNMP_MAX_VALUE_SIZE, "SNMP_VALUE") -#endif /* LWIP_SNMP */ -#if LWIP_DNS && LWIP_SOCKET -LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB") -#endif /* LWIP_DNS && LWIP_SOCKET */ -#if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC -LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST") -#endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ -#if PPP_SUPPORT && PPPOE_SUPPORT -LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF") -#endif /* PPP_SUPPORT && PPPOE_SUPPORT */ - -#if LWIP_IPV6 && LWIP_ND6_QUEUEING -LWIP_MEMPOOL(ND6_QUEUE, MEMP_NUM_ND6_QUEUE, sizeof(struct nd6_q_entry), "ND6_QUEUE") -#endif /* LWIP_IPV6 && LWIP_ND6_QUEUEING */ - -#if LWIP_IPV6 && LWIP_IPV6_REASS -LWIP_MEMPOOL(IP6_REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip6_reassdata), "IP6_REASSDATA") -#endif /* LWIP_IPV6 && LWIP_IPV6_REASS */ - -#if LWIP_IPV6 && LWIP_IPV6_MLD -LWIP_MEMPOOL(MLD6_GROUP, MEMP_NUM_MLD6_GROUP, sizeof(struct mld_group), "MLD6_GROUP") -#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ - - -/* - * A list of pools of pbuf's used by LWIP. - * - * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description) - * creates a pool name MEMP_pool_name. description is used in stats.c - * This allocates enough space for the pbuf struct and a payload. - * (Example: pbuf_payload_size=0 allocates only size for the struct) - */ -LWIP_PBUF_MEMPOOL(PBUF, MEMP_NUM_PBUF, 0, "PBUF_REF/ROM") -LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE, PBUF_POOL_BUFSIZE, "PBUF_POOL") - - -/* - * Allow for user-defined pools; this must be explicitly set in lwipopts.h - * since the default is to NOT look for lwippools.h - */ -#if MEMP_USE_CUSTOM_POOLS -#include "lwippools.h" -#endif /* MEMP_USE_CUSTOM_POOLS */ - -/* - * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later - * (#undef is ignored for something that is not defined) - */ -#undef LWIP_MEMPOOL -#undef LWIP_MALLOC_MEMPOOL -#undef LWIP_MALLOC_MEMPOOL_START -#undef LWIP_MALLOC_MEMPOOL_END -#undef LWIP_PBUF_MEMPOOL diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netbuf.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netbuf.h deleted file mode 100644 index d12fe270..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netbuf.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_NETBUF_H__ -#define __LWIP_NETBUF_H__ - -#include "lwip/opt.h" -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" -#include "lwip/ip6_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** This netbuf has dest-addr/port set */ -#define NETBUF_FLAG_DESTADDR 0x01 -/** This netbuf includes a checksum */ -#define NETBUF_FLAG_CHKSUM 0x02 - -struct netbuf { - struct pbuf *p, *ptr; - ipX_addr_t addr; - u16_t port; -#if LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY -#if LWIP_CHECKSUM_ON_COPY - u8_t flags; -#endif /* LWIP_CHECKSUM_ON_COPY */ - u16_t toport_chksum; -#if LWIP_NETBUF_RECVINFO - ipX_addr_t toaddr; -#endif /* LWIP_NETBUF_RECVINFO */ -#endif /* LWIP_NETBUF_RECVINFO || LWIP_CHECKSUM_ON_COPY */ -}; - -/* Network buffer functions: */ -struct netbuf * netbuf_new (void); -void netbuf_delete (struct netbuf *buf); -void * netbuf_alloc (struct netbuf *buf, u16_t size); -void netbuf_free (struct netbuf *buf); -err_t netbuf_ref (struct netbuf *buf, - const void *dataptr, u16_t size); -void netbuf_chain (struct netbuf *head, - struct netbuf *tail); - -err_t netbuf_data (struct netbuf *buf, - void **dataptr, u16_t *len); -s8_t netbuf_next (struct netbuf *buf); -void netbuf_first (struct netbuf *buf); - - -#define netbuf_copy_partial(buf, dataptr, len, offset) \ - pbuf_copy_partial((buf)->p, (dataptr), (len), (offset)) -#define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0) -#define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len) -#define netbuf_len(buf) ((buf)->p->tot_len) -#define netbuf_fromaddr(buf) (ipX_2_ip(&((buf)->addr))) -#define netbuf_set_fromaddr(buf, fromaddr) ip_addr_set(ipX_2_ip(&((buf)->addr)), fromaddr) -#define netbuf_fromport(buf) ((buf)->port) -#if LWIP_NETBUF_RECVINFO -#define netbuf_destaddr(buf) (ipX_2_ip(&((buf)->toaddr))) -#define netbuf_set_destaddr(buf, destaddr) ip_addr_set(ipX_2_ip(&((buf)->toaddr)), destaddr) -#define netbuf_destport(buf) (((buf)->flags & NETBUF_FLAG_DESTADDR) ? (buf)->toport_chksum : 0) -#endif /* LWIP_NETBUF_RECVINFO */ -#if LWIP_CHECKSUM_ON_COPY -#define netbuf_set_chksum(buf, chksum) do { (buf)->flags = NETBUF_FLAG_CHKSUM; \ - (buf)->toport_chksum = chksum; } while(0) -#endif /* LWIP_CHECKSUM_ON_COPY */ - -#if LWIP_IPV6 -#define netbuf_fromaddr_ip6(buf) (ipX_2_ip6(&((buf)->addr))) -#define netbuf_set_fromaddr_ip6(buf, fromaddr) ip6_addr_set(ipX_2_ip6(&((buf)->addr)), fromaddr) -#define netbuf_destaddr_ip6(buf) (ipX_2_ip6(&((buf)->toaddr))) -#define netbuf_set_destaddr_ip6(buf, destaddr) ip6_addr_set(ipX_2_ip6(&((buf)->toaddr)), destaddr) -#endif /* LWIP_IPV6 */ - -#define netbuf_fromaddr_ipX(buf) (&((buf)->addr)) -#define netbuf_destaddr_ipX(buf) (&((buf)->toaddr)) - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_NETBUF_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netdb.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netdb.h deleted file mode 100644 index 7587e2f2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netdb.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Simon Goldschmidt - * - */ -#ifndef __LWIP_NETDB_H__ -#define __LWIP_NETDB_H__ - -#include "lwip/opt.h" - -#if LWIP_DNS && LWIP_SOCKET - -#include /* for size_t */ - -#include "lwip/inet.h" -#include "lwip/sockets.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* some rarely used options */ -#ifndef LWIP_DNS_API_DECLARE_H_ERRNO -#define LWIP_DNS_API_DECLARE_H_ERRNO 1 -#endif - -#ifndef LWIP_DNS_API_DEFINE_ERRORS -#define LWIP_DNS_API_DEFINE_ERRORS 1 -#endif - -#ifndef LWIP_DNS_API_DECLARE_STRUCTS -#define LWIP_DNS_API_DECLARE_STRUCTS 1 -#endif - -#if LWIP_DNS_API_DEFINE_ERRORS -/** Errors used by the DNS API functions, h_errno can be one of them */ -#define EAI_NONAME 200 -#define EAI_SERVICE 201 -#define EAI_FAIL 202 -#define EAI_MEMORY 203 - -#define HOST_NOT_FOUND 210 -#define NO_DATA 211 -#define NO_RECOVERY 212 -#define TRY_AGAIN 213 -#endif /* LWIP_DNS_API_DEFINE_ERRORS */ - -#if LWIP_DNS_API_DECLARE_STRUCTS -struct hostent { - char *h_name; /* Official name of the host. */ - char **h_aliases; /* A pointer to an array of pointers to alternative host names, - terminated by a null pointer. */ - int h_addrtype; /* Address type. */ - int h_length; /* The length, in bytes, of the address. */ - char **h_addr_list; /* A pointer to an array of pointers to network addresses (in - network byte order) for the host, terminated by a null pointer. */ -#define h_addr h_addr_list[0] /* for backward compatibility */ -}; - -struct addrinfo { - int ai_flags; /* Input flags. */ - int ai_family; /* Address family of socket. */ - int ai_socktype; /* Socket type. */ - int ai_protocol; /* Protocol of socket. */ - socklen_t ai_addrlen; /* Length of socket address. */ - struct sockaddr *ai_addr; /* Socket address of socket. */ - char *ai_canonname; /* Canonical name of service location. */ - struct addrinfo *ai_next; /* Pointer to next in list. */ -}; -#endif /* LWIP_DNS_API_DECLARE_STRUCTS */ - -#if LWIP_DNS_API_DECLARE_H_ERRNO -/* application accessable error code set by the DNS API functions */ -extern int h_errno; -#endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/ - -struct hostent *lwip_gethostbyname(const char *name); -int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf, - size_t buflen, struct hostent **result, int *h_errnop); -void lwip_freeaddrinfo(struct addrinfo *ai); -int lwip_getaddrinfo(const char *nodename, - const char *servname, - const struct addrinfo *hints, - struct addrinfo **res); - -#if LWIP_COMPAT_SOCKETS -#define gethostbyname(name) lwip_gethostbyname(name) -#define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \ - lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop) -#define freeaddrinfo(addrinfo) lwip_freeaddrinfo(addrinfo) -#define getaddrinfo(nodname, servname, hints, res) \ - lwip_getaddrinfo(nodname, servname, hints, res) -#endif /* LWIP_COMPAT_SOCKETS */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_DNS && LWIP_SOCKET */ - -#endif /* __LWIP_NETDB_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netif.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netif.h deleted file mode 100644 index f9770324..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netif.h +++ /dev/null @@ -1,393 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_NETIF_H__ -#define __LWIP_NETIF_H__ - -#include "lwip/opt.h" - -#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) - -#include "lwip/err.h" - -#include "lwip/ip_addr.h" -#include "lwip/ip6_addr.h" - -#include "lwip/def.h" -#include "lwip/pbuf.h" -#if LWIP_DHCP -struct dhcp; -#endif -#if LWIP_AUTOIP -struct autoip; -#endif -#if LWIP_IPV6_DHCP6 -#include "lwip/dhcp6.h" -#endif /* LWIP_IPV6_DHCP6 */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Throughout this file, IP addresses are expected to be in - * the same byte order as in IP_PCB. */ - -/** must be the maximum of all used hardware address lengths - across all types of interfaces in use */ -#define NETIF_MAX_HWADDR_LEN 6U - -/** Whether the network interface is 'up'. This is - * a software flag used to control whether this network - * interface is enabled and processes traffic. - * It is set by the startup code (for static IP configuration) or - * by dhcp/autoip when an address has been assigned. - */ -#define NETIF_FLAG_UP 0x01U -/** If set, the netif has broadcast capability. - * Set by the netif driver in its init function. */ -#define NETIF_FLAG_BROADCAST 0x02U -/** If set, the netif is one end of a point-to-point connection. - * Set by the netif driver in its init function. */ -#define NETIF_FLAG_POINTTOPOINT 0x04U -/** If set, the interface is configured using DHCP. - * Set by the DHCP code when starting or stopping DHCP. */ -#define NETIF_FLAG_DHCP 0x08U -/** If set, the interface has an active link - * (set by the network interface driver). - * Either set by the netif driver in its init function (if the link - * is up at that time) or at a later point once the link comes up - * (if link detection is supported by the hardware). */ -#define NETIF_FLAG_LINK_UP 0x10U -/** If set, the netif is an ethernet device using ARP. - * Set by the netif driver in its init function. - * Used to check input packet types and use of DHCP. */ -#define NETIF_FLAG_ETHARP 0x20U -/** If set, the netif is an ethernet device. It might not use - * ARP or TCP/IP if it is used for PPPoE only. - */ -#define NETIF_FLAG_ETHERNET 0x40U -/** If set, the netif has IGMP capability. - * Set by the netif driver in its init function. */ -#define NETIF_FLAG_IGMP 0x80U -/** Whether to pretend that we are every host for TCP packets. - * Set by netif_set_pretend_tcp. */ -#define NETIF_FLAG_PRETEND_TCP 0x100U - -/** Function prototype for netif init functions. Set up flags and output/linkoutput - * callback functions in this function. - * - * @param netif The netif to initialize - */ -typedef err_t (*netif_init_fn)(struct netif *netif); -/** Function prototype for netif->input functions. This function is saved as 'input' - * callback function in the netif struct. Call it when a packet has been received. - * - * @param p The received packet, copied into a pbuf - * @param inp The netif which received the packet - */ -typedef err_t (*netif_input_fn)(struct pbuf *p, struct netif *inp); -/** Function prototype for netif->output functions. Called by lwIP when a packet - * shall be sent. For ethernet netif, set this to 'etharp_output' and set - * 'linkoutput'. - * - * @param netif The netif which shall send a packet - * @param p The packet to send (p->payload points to IP header) - * @param ipaddr The IP address to which the packet shall be sent - */ -typedef err_t (*netif_output_fn)(struct netif *netif, struct pbuf *p, - ip_addr_t *ipaddr); -#if LWIP_IPV6 -/** Function prototype for netif->output_ip6 functions. Called by lwIP when a packet - * shall be sent. For ethernet netif, set this to 'nd_output' and set - * 'linkoutput'. - * - * @param netif The netif which shall send a packet - * @param p The packet to send (p->payload points to IP header) - * @param ipaddr The IPv6 address to which the packet shall be sent - */ -typedef err_t (*netif_output_ip6_fn)(struct netif *netif, struct pbuf *p, - ip6_addr_t *ipaddr); -#endif /* LWIP_IPV6 */ -/** Function prototype for netif->linkoutput functions. Only used for ethernet - * netifs. This function is called by ARP when a packet shall be sent. - * - * @param netif The netif which shall send a packet - * @param p The packet to send (raw ethernet packet) - */ -typedef err_t (*netif_linkoutput_fn)(struct netif *netif, struct pbuf *p); -/** Function prototype for netif status- or link-callback functions. */ -typedef void (*netif_status_callback_fn)(struct netif *netif); -/** Function prototype for netif igmp_mac_filter functions */ -typedef err_t (*netif_igmp_mac_filter_fn)(struct netif *netif, - ip_addr_t *group, u8_t action); -#if LWIP_IPV6 && LWIP_IPV6_MLD -/** Function prototype for netif mld_mac_filter functions */ -typedef err_t (*netif_mld_mac_filter_fn)(struct netif *netif, - ip6_addr_t *group, u8_t action); -#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ - -/** Generic data structure used for all lwIP network interfaces. - * The following fields should be filled in by the initialization - * function for the device driver: hwaddr_len, hwaddr[], mtu, flags */ -struct netif { - /** pointer to next in linked list */ - struct netif *next; - - /** IP address configuration in network byte order */ - ip_addr_t ip_addr; - ip_addr_t netmask; - ip_addr_t gw; - -#if LWIP_IPV6 - /** Array of IPv6 addresses for this netif. */ - ip6_addr_t ip6_addr[LWIP_IPV6_NUM_ADDRESSES]; - /** The state of each IPv6 address (Tentative, Preferred, etc). - * @see ip6_addr.h */ - u8_t ip6_addr_state[LWIP_IPV6_NUM_ADDRESSES]; -#endif /* LWIP_IPV6 */ - /** This function is called by the network device driver - * to pass a packet up the TCP/IP stack. */ - netif_input_fn input; - /** This function is called by the IP module when it wants - * to send a packet on the interface. This function typically - * first resolves the hardware address, then sends the packet. */ - netif_output_fn output; - /** This function is called by the ARP module when it wants - * to send a packet on the interface. This function outputs - * the pbuf as-is on the link medium. */ - netif_linkoutput_fn linkoutput; -#if LWIP_IPV6 - /** This function is called by the IPv6 module when it wants - * to send a packet on the interface. This function typically - * first resolves the hardware address, then sends the packet. */ - netif_output_ip6_fn output_ip6; -#endif /* LWIP_IPV6 */ -#if LWIP_NETIF_STATUS_CALLBACK - /** This function is called when the netif state is set to up or down - */ - netif_status_callback_fn status_callback; -#endif /* LWIP_NETIF_STATUS_CALLBACK */ -#if LWIP_NETIF_LINK_CALLBACK - /** This function is called when the netif link is set to up or down - */ - netif_status_callback_fn link_callback; -#endif /* LWIP_NETIF_LINK_CALLBACK */ -#if LWIP_NETIF_REMOVE_CALLBACK - /** This function is called when the netif has been removed */ - netif_status_callback_fn remove_callback; -#endif /* LWIP_NETIF_REMOVE_CALLBACK */ - /** This field can be set by the device driver and could point - * to state information for the device. */ - void *state; -#if LWIP_DHCP - /** the DHCP client state information for this netif */ - struct dhcp *dhcp; -#endif /* LWIP_DHCP */ -#if LWIP_AUTOIP - /** the AutoIP client state information for this netif */ - struct autoip *autoip; -#endif -#if LWIP_IPV6_AUTOCONFIG - /** is this netif enabled for IPv6 autoconfiguration */ - u8_t ip6_autoconfig_enabled; -#endif /* LWIP_IPV6_AUTOCONFIG */ -#if LWIP_IPV6_SEND_ROUTER_SOLICIT - /** Number of Router Solicitation messages that remain to be sent. */ - u8_t rs_count; -#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ -#if LWIP_IPV6_DHCP6 - /** the DHCPv6 client state information for this netif */ - struct dhcp6 *dhcp6; -#endif /* LWIP_IPV6_DHCP6 */ -#if LWIP_NETIF_HOSTNAME - /* the hostname for this netif, NULL is a valid value */ - char* hostname; -#endif /* LWIP_NETIF_HOSTNAME */ - /** maximum transfer unit (in bytes) */ - u16_t mtu; - /** number of bytes used in hwaddr */ - u8_t hwaddr_len; - /** link level hardware address of this interface */ - u8_t hwaddr[NETIF_MAX_HWADDR_LEN]; - /** flags (see NETIF_FLAG_ above) */ - u16_t flags; - /** descriptive abbreviation */ - char name[2]; - /** number of this interface */ - u8_t num; -#if LWIP_SNMP - /** link type (from "snmp_ifType" enum from snmp.h) */ - u8_t link_type; - /** (estimate) link speed */ - u32_t link_speed; - /** timestamp at last change made (up/down) */ - u32_t ts; - /** counters */ - u32_t ifinoctets; - u32_t ifinucastpkts; - u32_t ifinnucastpkts; - u32_t ifindiscards; - u32_t ifoutoctets; - u32_t ifoutucastpkts; - u32_t ifoutnucastpkts; - u32_t ifoutdiscards; -#endif /* LWIP_SNMP */ -#if LWIP_IGMP - /** This function could be called to add or delete an entry in the multicast - filter table of the ethernet MAC.*/ - netif_igmp_mac_filter_fn igmp_mac_filter; -#endif /* LWIP_IGMP */ -#if LWIP_IPV6 && LWIP_IPV6_MLD - /** This function could be called to add or delete an entry in the IPv6 multicast - filter table of the ethernet MAC. */ - netif_mld_mac_filter_fn mld_mac_filter; -#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */ -#if LWIP_NETIF_HWADDRHINT - u8_t *addr_hint; -#endif /* LWIP_NETIF_HWADDRHINT */ -#if ENABLE_LOOPBACK - /* List of packets to be queued for ourselves. */ - struct pbuf *loop_first; - struct pbuf *loop_last; -#if LWIP_LOOPBACK_MAX_PBUFS - u16_t loop_cnt_current; -#endif /* LWIP_LOOPBACK_MAX_PBUFS */ -#endif /* ENABLE_LOOPBACK */ -}; - -#if LWIP_SNMP -#define NETIF_INIT_SNMP(netif, type, speed) \ - /* use "snmp_ifType" enum from snmp.h for "type", snmp_ifType_ethernet_csmacd by example */ \ - (netif)->link_type = (type); \ - /* your link speed here (units: bits per second) */ \ - (netif)->link_speed = (speed); \ - (netif)->ts = 0; \ - (netif)->ifinoctets = 0; \ - (netif)->ifinucastpkts = 0; \ - (netif)->ifinnucastpkts = 0; \ - (netif)->ifindiscards = 0; \ - (netif)->ifoutoctets = 0; \ - (netif)->ifoutucastpkts = 0; \ - (netif)->ifoutnucastpkts = 0; \ - (netif)->ifoutdiscards = 0 -#else /* LWIP_SNMP */ -#define NETIF_INIT_SNMP(netif, type, speed) -#endif /* LWIP_SNMP */ - - -/** The list of network interfaces. */ -extern struct netif *netif_list; -/** The default network interface. */ -extern struct netif *netif_default; - -void netif_init(void); - -struct netif *netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, - ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input); - -void -netif_set_addr(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, - ip_addr_t *gw); -void netif_remove(struct netif * netif); - -/* Returns a network interface given its name. The name is of the form - "et0", where the first two letters are the "name" field in the - netif structure, and the digit is in the num field in the same - structure. */ -struct netif *netif_find(char *name); - -int netif_is_named (struct netif *netif, const char name[3]); - -void netif_set_default(struct netif *netif); - -void netif_set_ipaddr(struct netif *netif, ip_addr_t *ipaddr); -void netif_set_netmask(struct netif *netif, ip_addr_t *netmask); -void netif_set_gw(struct netif *netif, ip_addr_t *gw); -void netif_set_pretend_tcp(struct netif *netif, u8_t pretend); - -void netif_set_up(struct netif *netif); -void netif_set_down(struct netif *netif); -/** Ask if an interface is up */ -#define netif_is_up(netif) (((netif)->flags & NETIF_FLAG_UP) ? (u8_t)1 : (u8_t)0) - -#if LWIP_NETIF_STATUS_CALLBACK -void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback); -#endif /* LWIP_NETIF_STATUS_CALLBACK */ -#if LWIP_NETIF_REMOVE_CALLBACK -void netif_set_remove_callback(struct netif *netif, netif_status_callback_fn remove_callback); -#endif /* LWIP_NETIF_REMOVE_CALLBACK */ - -void netif_set_link_up(struct netif *netif); -void netif_set_link_down(struct netif *netif); -/** Ask if a link is up */ -#define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) - -#if LWIP_NETIF_LINK_CALLBACK -void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback); -#endif /* LWIP_NETIF_LINK_CALLBACK */ - -#if LWIP_NETIF_HOSTNAME -#define netif_set_hostname(netif, name) do { if((netif) != NULL) { (netif)->hostname = name; }}while(0) -#define netif_get_hostname(netif) (((netif) != NULL) ? ((netif)->hostname) : NULL) -#endif /* LWIP_NETIF_HOSTNAME */ - -#if LWIP_IGMP -#define netif_set_igmp_mac_filter(netif, function) do { if((netif) != NULL) { (netif)->igmp_mac_filter = function; }}while(0) -#define netif_get_igmp_mac_filter(netif) (((netif) != NULL) ? ((netif)->igmp_mac_filter) : NULL) -#endif /* LWIP_IGMP */ - -#if ENABLE_LOOPBACK -err_t netif_loop_output(struct netif *netif, struct pbuf *p, ip_addr_t *dest_ip); -void netif_poll(struct netif *netif); -#if !LWIP_NETIF_LOOPBACK_MULTITHREADING -void netif_poll_all(void); -#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ -#endif /* ENABLE_LOOPBACK */ - -#if LWIP_IPV6 -#define netif_ip6_addr(netif, i) (&((netif)->ip6_addr[(i)])) -#define netif_ip6_addr_state(netif, i) ((netif)->ip6_addr_state[(i)]) -#define netif_ip6_addr_set_state(netif, i, state) ((netif)->ip6_addr_state[(i)] = (state)) -s8_t netif_matches_ip6_addr(struct netif * netif, ip6_addr_t * ip6addr); -void netif_create_ip6_linklocal_address(struct netif * netif, u8_t from_mac_48bit); -#endif /* LWIP_IPV6 */ - -#if LWIP_NETIF_HWADDRHINT -#define NETIF_SET_HWADDRHINT(netif, hint) ((netif)->addr_hint = (hint)) -#else /* LWIP_NETIF_HWADDRHINT */ -#define NETIF_SET_HWADDRHINT(netif, hint) -#endif /* LWIP_NETIF_HWADDRHINT */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_NETIF_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netifapi.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netifapi.h deleted file mode 100644 index 33318efa..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/netifapi.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#ifndef __LWIP_NETIFAPI_H__ -#define __LWIP_NETIFAPI_H__ - -#include "lwip/opt.h" - -#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/sys.h" -#include "lwip/netif.h" -#include "lwip/dhcp.h" -#include "lwip/autoip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*netifapi_void_fn)(struct netif *netif); -typedef err_t (*netifapi_errt_fn)(struct netif *netif); - -struct netifapi_msg_msg { -#if !LWIP_TCPIP_CORE_LOCKING - sys_sem_t sem; -#endif /* !LWIP_TCPIP_CORE_LOCKING */ - err_t err; - struct netif *netif; - union { - struct { - ip_addr_t *ipaddr; - ip_addr_t *netmask; - ip_addr_t *gw; - void *state; - netif_init_fn init; - netif_input_fn input; - } add; - struct { - netifapi_void_fn voidfunc; - netifapi_errt_fn errtfunc; - } common; - } msg; -}; - -struct netifapi_msg { - void (* function)(struct netifapi_msg_msg *msg); - struct netifapi_msg_msg msg; -}; - - -/* API for application */ -err_t netifapi_netif_add ( struct netif *netif, - ip_addr_t *ipaddr, - ip_addr_t *netmask, - ip_addr_t *gw, - void *state, - netif_init_fn init, - netif_input_fn input); - -err_t netifapi_netif_set_addr ( struct netif *netif, - ip_addr_t *ipaddr, - ip_addr_t *netmask, - ip_addr_t *gw ); - -err_t netifapi_netif_common ( struct netif *netif, - netifapi_void_fn voidfunc, - netifapi_errt_fn errtfunc); - -#define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL) -#define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL) -#define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL) -#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL) -#define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start) -#define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) -#define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start) -#define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_NETIF_API */ - -#endif /* __LWIP_NETIFAPI_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/opt.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/opt.h deleted file mode 100644 index e51f8e55..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/opt.h +++ /dev/null @@ -1,2417 +0,0 @@ -/** - * @file - * - * lwIP Options Configuration - */ - -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_OPT_H__ -#define __LWIP_OPT_H__ - -/* - * Include user defined options first. Anything not defined in these files - * will be set to standard values. Override anything you dont like! - */ -#include "lwipopts.h" -#include "lwip/debug.h" - -/* - ----------------------------------------------- - ---------- Platform specific locking ---------- - ----------------------------------------------- -*/ - -/** - * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain - * critical regions during buffer allocation, deallocation and memory - * allocation and deallocation. - */ -#ifndef SYS_LIGHTWEIGHT_PROT -#define SYS_LIGHTWEIGHT_PROT 0 -#endif - -/** - * NO_SYS==1: Provides VERY minimal functionality. Otherwise, - * use lwIP facilities. - */ -#ifndef NO_SYS -#define NO_SYS 0 -#endif - -/** - * NO_SYS_NO_TIMERS==1: Drop support for sys_timeout when NO_SYS==1 - * Mainly for compatibility to old versions. - */ -#ifndef NO_SYS_NO_TIMERS -#define NO_SYS_NO_TIMERS 0 -#endif - -/** - * MEMCPY: override this if you have a faster implementation at hand than the - * one included in your C library - */ -#ifndef MEMCPY -#define MEMCPY(dst,src,len) memcpy(dst,src,len) -#endif - -/** - * SMEMCPY: override this with care! Some compilers (e.g. gcc) can inline a - * call to memcpy() if the length is known at compile time and is small. - */ -#ifndef SMEMCPY -#define SMEMCPY(dst,src,len) memcpy(dst,src,len) -#endif - -/* - ------------------------------------ - ---------- Memory options ---------- - ------------------------------------ -*/ -/** - * MEM_LIBC_MALLOC==1: Use malloc/free/realloc provided by your C-library - * instead of the lwip internal allocator. Can save code size if you - * already use it. - */ -#ifndef MEM_LIBC_MALLOC -#define MEM_LIBC_MALLOC 0 -#endif - -/** -* MEMP_MEM_MALLOC==1: Use mem_malloc/mem_free instead of the lwip pool allocator. -* Especially useful with MEM_LIBC_MALLOC but handle with care regarding execution -* speed and usage from interrupts! -*/ -#ifndef MEMP_MEM_MALLOC -#define MEMP_MEM_MALLOC 0 -#endif - -/** - * MEM_ALIGNMENT: should be set to the alignment of the CPU - * 4 byte alignment -> #define MEM_ALIGNMENT 4 - * 2 byte alignment -> #define MEM_ALIGNMENT 2 - */ -#ifndef MEM_ALIGNMENT -#define MEM_ALIGNMENT 1 -#endif - -/** - * MEM_SIZE: the size of the heap memory. If the application will send - * a lot of data that needs to be copied, this should be set high. - */ -#ifndef MEM_SIZE -#define MEM_SIZE 1600 -#endif - -/** - * MEMP_SEPARATE_POOLS: if defined to 1, each pool is placed in its own array. - * This can be used to individually change the location of each pool. - * Default is one big array for all pools - */ -#ifndef MEMP_SEPARATE_POOLS -#define MEMP_SEPARATE_POOLS 0 -#endif - -/** - * MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable - * amount of bytes before and after each memp element in every pool and fills - * it with a prominent default value. - * MEMP_OVERFLOW_CHECK == 0 no checking - * MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed - * MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool every time - * memp_malloc() or memp_free() is called (useful but slow!) - */ -#ifndef MEMP_OVERFLOW_CHECK -#define MEMP_OVERFLOW_CHECK 0 -#endif - -/** - * MEMP_SANITY_CHECK==1: run a sanity check after each memp_free() to make - * sure that there are no cycles in the linked lists. - */ -#ifndef MEMP_SANITY_CHECK -#define MEMP_SANITY_CHECK 0 -#endif - -/** - * MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set - * of memory pools of various sizes. When mem_malloc is called, an element of - * the smallest pool that can provide the length needed is returned. - * To use this, MEMP_USE_CUSTOM_POOLS also has to be enabled. - */ -#ifndef MEM_USE_POOLS -#define MEM_USE_POOLS 0 -#endif - -/** - * MEM_USE_POOLS_TRY_BIGGER_POOL==1: if one malloc-pool is empty, try the next - * bigger pool - WARNING: THIS MIGHT WASTE MEMORY but it can make a system more - * reliable. */ -#ifndef MEM_USE_POOLS_TRY_BIGGER_POOL -#define MEM_USE_POOLS_TRY_BIGGER_POOL 0 -#endif - -/** - * MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h - * that defines additional pools beyond the "standard" ones required - * by lwIP. If you set this to 1, you must have lwippools.h in your - * inlude path somewhere. - */ -#ifndef MEMP_USE_CUSTOM_POOLS -#define MEMP_USE_CUSTOM_POOLS 0 -#endif - -/** - * Set this to 1 if you want to free PBUF_RAM pbufs (or call mem_free()) from - * interrupt context (or another context that doesn't allow waiting for a - * semaphore). - * If set to 1, mem_malloc will be protected by a semaphore and SYS_ARCH_PROTECT, - * while mem_free will only use SYS_ARCH_PROTECT. mem_malloc SYS_ARCH_UNPROTECTs - * with each loop so that mem_free can run. - * - * ATTENTION: As you can see from the above description, this leads to dis-/ - * enabling interrupts often, which can be slow! Also, on low memory, mem_malloc - * can need longer. - * - * If you don't want that, at least for NO_SYS=0, you can still use the following - * functions to enqueue a deallocation call which then runs in the tcpip_thread - * context: - * - pbuf_free_callback(p); - * - mem_free_callback(m); - */ -#ifndef LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT -#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0 -#endif - -/* - ------------------------------------------------ - ---------- Internal Memory Pool Sizes ---------- - ------------------------------------------------ -*/ -/** - * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF). - * If the application sends a lot of data out of ROM (or other static memory), - * this should be set high. - */ -#ifndef MEMP_NUM_PBUF -#define MEMP_NUM_PBUF 16 -#endif - -/** - * MEMP_NUM_RAW_PCB: Number of raw connection PCBs - * (requires the LWIP_RAW option) - */ -#ifndef MEMP_NUM_RAW_PCB -#define MEMP_NUM_RAW_PCB 4 -#endif - -/** - * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One - * per active UDP "connection". - * (requires the LWIP_UDP option) - */ -#ifndef MEMP_NUM_UDP_PCB -#define MEMP_NUM_UDP_PCB 4 -#endif - -/** - * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. - * (requires the LWIP_TCP option) - */ -#ifndef MEMP_NUM_TCP_PCB -#define MEMP_NUM_TCP_PCB 5 -#endif - -/** - * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. - * (requires the LWIP_TCP option) - */ -#ifndef MEMP_NUM_TCP_PCB_LISTEN -#define MEMP_NUM_TCP_PCB_LISTEN 8 -#endif - -/** - * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. - * (requires the LWIP_TCP option) - */ -#ifndef MEMP_NUM_TCP_SEG -#define MEMP_NUM_TCP_SEG 16 -#endif - -/** - * MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for - * reassembly (whole packets, not fragments!) - */ -#ifndef MEMP_NUM_REASSDATA -#define MEMP_NUM_REASSDATA 5 -#endif - -/** - * MEMP_NUM_FRAG_PBUF: the number of IP fragments simultaneously sent - * (fragments, not whole packets!). - * This is only used with IP_FRAG_USES_STATIC_BUF==0 and - * LWIP_NETIF_TX_SINGLE_PBUF==0 and only has to be > 1 with DMA-enabled MACs - * where the packet is not yet sent when netif->output returns. - */ -#ifndef MEMP_NUM_FRAG_PBUF -#define MEMP_NUM_FRAG_PBUF 15 -#endif - -/** - * MEMP_NUM_ARP_QUEUE: the number of simulateously queued outgoing - * packets (pbufs) that are waiting for an ARP request (to resolve - * their destination address) to finish. - * (requires the ARP_QUEUEING option) - */ -#ifndef MEMP_NUM_ARP_QUEUE -#define MEMP_NUM_ARP_QUEUE 30 -#endif - -/** - * MEMP_NUM_IGMP_GROUP: The number of multicast groups whose network interfaces - * can be members et the same time (one per netif - allsystems group -, plus one - * per netif membership). - * (requires the LWIP_IGMP option) - */ -#ifndef MEMP_NUM_IGMP_GROUP -#define MEMP_NUM_IGMP_GROUP 8 -#endif - -/** - * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. - * (requires NO_SYS==0) - * The default number of timeouts is calculated here for all enabled modules. - * The formula expects settings to be either '0' or '1'. - */ -#ifndef MEMP_NUM_SYS_TIMEOUT -#define MEMP_NUM_SYS_TIMEOUT (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)) -#endif - -/** - * MEMP_NUM_NETBUF: the number of struct netbufs. - * (only needed if you use the sequential API, like api_lib.c) - */ -#ifndef MEMP_NUM_NETBUF -#define MEMP_NUM_NETBUF 2 -#endif - -/** - * MEMP_NUM_NETCONN: the number of struct netconns. - * (only needed if you use the sequential API, like api_lib.c) - */ -#ifndef MEMP_NUM_NETCONN -#define MEMP_NUM_NETCONN 4 -#endif - -/** - * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used - * for callback/timeout API communication. - * (only needed if you use tcpip.c) - */ -#ifndef MEMP_NUM_TCPIP_MSG_API -#define MEMP_NUM_TCPIP_MSG_API 8 -#endif - -/** - * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used - * for incoming packets. - * (only needed if you use tcpip.c) - */ -#ifndef MEMP_NUM_TCPIP_MSG_INPKT -#define MEMP_NUM_TCPIP_MSG_INPKT 8 -#endif - -/** - * MEMP_NUM_SNMP_NODE: the number of leafs in the SNMP tree. - */ -#ifndef MEMP_NUM_SNMP_NODE -#define MEMP_NUM_SNMP_NODE 50 -#endif - -/** - * MEMP_NUM_SNMP_ROOTNODE: the number of branches in the SNMP tree. - * Every branch has one leaf (MEMP_NUM_SNMP_NODE) at least! - */ -#ifndef MEMP_NUM_SNMP_ROOTNODE -#define MEMP_NUM_SNMP_ROOTNODE 30 -#endif - -/** - * MEMP_NUM_SNMP_VARBIND: the number of concurrent requests (does not have to - * be changed normally) - 2 of these are used per request (1 for input, - * 1 for output) - */ -#ifndef MEMP_NUM_SNMP_VARBIND -#define MEMP_NUM_SNMP_VARBIND 2 -#endif - -/** - * MEMP_NUM_SNMP_VALUE: the number of OID or values concurrently used - * (does not have to be changed normally) - 3 of these are used per request - * (1 for the value read and 2 for OIDs - input and output) - */ -#ifndef MEMP_NUM_SNMP_VALUE -#define MEMP_NUM_SNMP_VALUE 3 -#endif - -/** - * MEMP_NUM_NETDB: the number of concurrently running lwip_addrinfo() calls - * (before freeing the corresponding memory using lwip_freeaddrinfo()). - */ -#ifndef MEMP_NUM_NETDB -#define MEMP_NUM_NETDB 1 -#endif - -/** - * MEMP_NUM_LOCALHOSTLIST: the number of host entries in the local host list - * if DNS_LOCAL_HOSTLIST_IS_DYNAMIC==1. - */ -#ifndef MEMP_NUM_LOCALHOSTLIST -#define MEMP_NUM_LOCALHOSTLIST 1 -#endif - -/** - * MEMP_NUM_PPPOE_INTERFACES: the number of concurrently active PPPoE - * interfaces (only used with PPPOE_SUPPORT==1) - */ -#ifndef MEMP_NUM_PPPOE_INTERFACES -#define MEMP_NUM_PPPOE_INTERFACES 1 -#endif - -/** - * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. - */ -#ifndef PBUF_POOL_SIZE -#define PBUF_POOL_SIZE 16 -#endif - -/* - --------------------------------- - ---------- ARP options ---------- - --------------------------------- -*/ -/** - * LWIP_ARP==1: Enable ARP functionality. - */ -#ifndef LWIP_ARP -#define LWIP_ARP 1 -#endif - -/** - * ARP_TABLE_SIZE: Number of active MAC-IP address pairs cached. - */ -#ifndef ARP_TABLE_SIZE -#define ARP_TABLE_SIZE 10 -#endif - -/** - * ARP_QUEUEING==1: Multiple outgoing packets are queued during hardware address - * resolution. By default, only the most recent packet is queued per IP address. - * This is sufficient for most protocols and mainly reduces TCP connection - * startup time. Set this to 1 if you know your application sends more than one - * packet in a row to an IP address that is not in the ARP cache. - */ -#ifndef ARP_QUEUEING -#define ARP_QUEUEING 0 -#endif - -/** - * ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be - * updated with the source MAC and IP addresses supplied in the packet. - * You may want to disable this if you do not trust LAN peers to have the - * correct addresses, or as a limited approach to attempt to handle - * spoofing. If disabled, lwIP will need to make a new ARP request if - * the peer is not already in the ARP table, adding a little latency. - * The peer *is* in the ARP table if it requested our address before. - * Also notice that this slows down input processing of every IP packet! - */ -#ifndef ETHARP_TRUST_IP_MAC -#define ETHARP_TRUST_IP_MAC 0 -#endif - -/** - * ETHARP_SUPPORT_VLAN==1: support receiving ethernet packets with VLAN header. - * Additionally, you can define ETHARP_VLAN_CHECK to an u16_t VLAN ID to check. - * If ETHARP_VLAN_CHECK is defined, only VLAN-traffic for this VLAN is accepted. - * If ETHARP_VLAN_CHECK is not defined, all traffic is accepted. - * Alternatively, define a function/define ETHARP_VLAN_CHECK_FN(eth_hdr, vlan) - * that returns 1 to accept a packet or 0 to drop a packet. - */ -#ifndef ETHARP_SUPPORT_VLAN -#define ETHARP_SUPPORT_VLAN 0 -#endif - -/** LWIP_ETHERNET==1: enable ethernet support for PPPoE even though ARP - * might be disabled - */ -#ifndef LWIP_ETHERNET -#define LWIP_ETHERNET (LWIP_ARP || PPPOE_SUPPORT) -#endif - -/** ETH_PAD_SIZE: number of bytes added before the ethernet header to ensure - * alignment of payload after that header. Since the header is 14 bytes long, - * without this padding e.g. addresses in the IP header will not be aligned - * on a 32-bit boundary, so setting this to 2 can speed up 32-bit-platforms. - */ -#ifndef ETH_PAD_SIZE -#define ETH_PAD_SIZE 0 -#endif - -/** ETHARP_SUPPORT_STATIC_ENTRIES==1: enable code to support static ARP table - * entries (using etharp_add_static_entry/etharp_remove_static_entry). - */ -#ifndef ETHARP_SUPPORT_STATIC_ENTRIES -#define ETHARP_SUPPORT_STATIC_ENTRIES 0 -#endif - - -/* - -------------------------------- - ---------- IP options ---------- - -------------------------------- -*/ -/** - * IP_FORWARD==1: Enables the ability to forward IP packets across network - * interfaces. If you are going to run lwIP on a device with only one network - * interface, define this to 0. - */ -#ifndef IP_FORWARD -#define IP_FORWARD 0 -#endif - -/** - * IP_OPTIONS_ALLOWED: Defines the behavior for IP options. - * IP_OPTIONS_ALLOWED==0: All packets with IP options are dropped. - * IP_OPTIONS_ALLOWED==1: IP options are allowed (but not parsed). - */ -#ifndef IP_OPTIONS_ALLOWED -#define IP_OPTIONS_ALLOWED 1 -#endif - -/** - * IP_REASSEMBLY==1: Reassemble incoming fragmented IP packets. Note that - * this option does not affect outgoing packet sizes, which can be controlled - * via IP_FRAG. - */ -#ifndef IP_REASSEMBLY -#define IP_REASSEMBLY 1 -#endif - -/** - * IP_FRAG==1: Fragment outgoing IP packets if their size exceeds MTU. Note - * that this option does not affect incoming packet sizes, which can be - * controlled via IP_REASSEMBLY. - */ -#ifndef IP_FRAG -#define IP_FRAG 1 -#endif - -/** - * IP_REASS_MAXAGE: Maximum time (in multiples of IP_TMR_INTERVAL - so seconds, normally) - * a fragmented IP packet waits for all fragments to arrive. If not all fragments arrived - * in this time, the whole packet is discarded. - */ -#ifndef IP_REASS_MAXAGE -#define IP_REASS_MAXAGE 3 -#endif - -/** - * IP_REASS_MAX_PBUFS: Total maximum amount of pbufs waiting to be reassembled. - * Since the received pbufs are enqueued, be sure to configure - * PBUF_POOL_SIZE > IP_REASS_MAX_PBUFS so that the stack is still able to receive - * packets even if the maximum amount of fragments is enqueued for reassembly! - */ -#ifndef IP_REASS_MAX_PBUFS -#define IP_REASS_MAX_PBUFS 10 -#endif - -/** - * IP_FRAG_USES_STATIC_BUF==1: Use a static MTU-sized buffer for IP - * fragmentation. Otherwise pbufs are allocated and reference the original - * packet data to be fragmented (or with LWIP_NETIF_TX_SINGLE_PBUF==1, - * new PBUF_RAM pbufs are used for fragments). - * ATTENTION: IP_FRAG_USES_STATIC_BUF==1 may not be used for DMA-enabled MACs! - */ -#ifndef IP_FRAG_USES_STATIC_BUF -#define IP_FRAG_USES_STATIC_BUF 0 -#endif - -/** - * IP_FRAG_MAX_MTU: Assumed max MTU on any interface for IP frag buffer - * (requires IP_FRAG_USES_STATIC_BUF==1) - */ -#if IP_FRAG_USES_STATIC_BUF && !defined(IP_FRAG_MAX_MTU) -#define IP_FRAG_MAX_MTU 1500 -#endif - -/** - * IP_DEFAULT_TTL: Default value for Time-To-Live used by transport layers. - */ -#ifndef IP_DEFAULT_TTL -#define IP_DEFAULT_TTL 255 -#endif - -/** - * IP_SOF_BROADCAST=1: Use the SOF_BROADCAST field to enable broadcast - * filter per pcb on udp and raw send operations. To enable broadcast filter - * on recv operations, you also have to set IP_SOF_BROADCAST_RECV=1. - */ -#ifndef IP_SOF_BROADCAST -#define IP_SOF_BROADCAST 0 -#endif - -/** - * IP_SOF_BROADCAST_RECV (requires IP_SOF_BROADCAST=1) enable the broadcast - * filter on recv operations. - */ -#ifndef IP_SOF_BROADCAST_RECV -#define IP_SOF_BROADCAST_RECV 0 -#endif - -/** - * IP_FORWARD_ALLOW_TX_ON_RX_NETIF==1: allow ip_forward() to send packets back - * out on the netif where it was received. This should only be used for - * wireless networks. - * ATTENTION: When this is 1, make sure your netif driver correctly marks incoming - * link-layer-broadcast/multicast packets as such using the corresponding pbuf flags! - */ -#ifndef IP_FORWARD_ALLOW_TX_ON_RX_NETIF -#define IP_FORWARD_ALLOW_TX_ON_RX_NETIF 0 -#endif - -/** - * LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS==1: randomize the local port for the first - * local TCP/UDP pcb (default==0). This can prevent creating predictable port - * numbers after booting a device. - */ -#ifndef LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS -#define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS 0 -#endif - -/* - ---------------------------------- - ---------- ICMP options ---------- - ---------------------------------- -*/ -/** - * LWIP_ICMP==1: Enable ICMP module inside the IP stack. - * Be careful, disable that make your product non-compliant to RFC1122 - */ -#ifndef LWIP_ICMP -#define LWIP_ICMP 1 -#endif - -/** - * ICMP_TTL: Default value for Time-To-Live used by ICMP packets. - */ -#ifndef ICMP_TTL -#define ICMP_TTL (IP_DEFAULT_TTL) -#endif - -/** - * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) - */ -#ifndef LWIP_BROADCAST_PING -#define LWIP_BROADCAST_PING 0 -#endif - -/** - * LWIP_MULTICAST_PING==1: respond to multicast pings (default is unicast only) - */ -#ifndef LWIP_MULTICAST_PING -#define LWIP_MULTICAST_PING 0 -#endif - -/* - --------------------------------- - ---------- RAW options ---------- - --------------------------------- -*/ -/** - * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. - */ -#ifndef LWIP_RAW -#define LWIP_RAW 1 -#endif - -/** - * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. - */ -#ifndef RAW_TTL -#define RAW_TTL (IP_DEFAULT_TTL) -#endif - -/* - ---------------------------------- - ---------- DHCP options ---------- - ---------------------------------- -*/ -/** - * LWIP_DHCP==1: Enable DHCP module. - */ -#ifndef LWIP_DHCP -#define LWIP_DHCP 0 -#endif - -/** - * DHCP_DOES_ARP_CHECK==1: Do an ARP check on the offered address. - */ -#ifndef DHCP_DOES_ARP_CHECK -#define DHCP_DOES_ARP_CHECK ((LWIP_DHCP) && (LWIP_ARP)) -#endif - -/* - ------------------------------------ - ---------- AUTOIP options ---------- - ------------------------------------ -*/ -/** - * LWIP_AUTOIP==1: Enable AUTOIP module. - */ -#ifndef LWIP_AUTOIP -#define LWIP_AUTOIP 0 -#endif - -/** - * LWIP_DHCP_AUTOIP_COOP==1: Allow DHCP and AUTOIP to be both enabled on - * the same interface at the same time. - */ -#ifndef LWIP_DHCP_AUTOIP_COOP -#define LWIP_DHCP_AUTOIP_COOP 0 -#endif - -/** - * LWIP_DHCP_AUTOIP_COOP_TRIES: Set to the number of DHCP DISCOVER probes - * that should be sent before falling back on AUTOIP. This can be set - * as low as 1 to get an AutoIP address very quickly, but you should - * be prepared to handle a changing IP address when DHCP overrides - * AutoIP. - */ -#ifndef LWIP_DHCP_AUTOIP_COOP_TRIES -#define LWIP_DHCP_AUTOIP_COOP_TRIES 9 -#endif - -/* - ---------------------------------- - ---------- SNMP options ---------- - ---------------------------------- -*/ -/** - * LWIP_SNMP==1: Turn on SNMP module. UDP must be available for SNMP - * transport. - */ -#ifndef LWIP_SNMP -#define LWIP_SNMP 0 -#endif - -/** - * SNMP_CONCURRENT_REQUESTS: Number of concurrent requests the module will - * allow. At least one request buffer is required. - * Does not have to be changed unless external MIBs answer request asynchronously - */ -#ifndef SNMP_CONCURRENT_REQUESTS -#define SNMP_CONCURRENT_REQUESTS 1 -#endif - -/** - * SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap - * destination is required - */ -#ifndef SNMP_TRAP_DESTINATIONS -#define SNMP_TRAP_DESTINATIONS 1 -#endif - -/** - * SNMP_PRIVATE_MIB: - * When using a private MIB, you have to create a file 'private_mib.h' that contains - * a 'struct mib_array_node mib_private' which contains your MIB. - */ -#ifndef SNMP_PRIVATE_MIB -#define SNMP_PRIVATE_MIB 0 -#endif - -/** - * Only allow SNMP write actions that are 'safe' (e.g. disabeling netifs is not - * a safe action and disabled when SNMP_SAFE_REQUESTS = 1). - * Unsafe requests are disabled by default! - */ -#ifndef SNMP_SAFE_REQUESTS -#define SNMP_SAFE_REQUESTS 1 -#endif - -/** - * The maximum length of strings used. This affects the size of - * MEMP_SNMP_VALUE elements. - */ -#ifndef SNMP_MAX_OCTET_STRING_LEN -#define SNMP_MAX_OCTET_STRING_LEN 127 -#endif - -/** - * The maximum depth of the SNMP tree. - * With private MIBs enabled, this depends on your MIB! - * This affects the size of MEMP_SNMP_VALUE elements. - */ -#ifndef SNMP_MAX_TREE_DEPTH -#define SNMP_MAX_TREE_DEPTH 15 -#endif - -/** - * The size of the MEMP_SNMP_VALUE elements, normally calculated from - * SNMP_MAX_OCTET_STRING_LEN and SNMP_MAX_TREE_DEPTH. - */ -#ifndef SNMP_MAX_VALUE_SIZE -#define SNMP_MAX_VALUE_SIZE LWIP_MAX((SNMP_MAX_OCTET_STRING_LEN)+1, sizeof(s32_t)*(SNMP_MAX_TREE_DEPTH)) -#endif - -/* - ---------------------------------- - ---------- IGMP options ---------- - ---------------------------------- -*/ -/** - * LWIP_IGMP==1: Turn on IGMP module. - */ -#ifndef LWIP_IGMP -#define LWIP_IGMP 0 -#endif - -/* - ---------------------------------- - ---------- DNS options ----------- - ---------------------------------- -*/ -/** - * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS - * transport. - */ -#ifndef LWIP_DNS -#define LWIP_DNS 0 -#endif - -/** DNS maximum number of entries to maintain locally. */ -#ifndef DNS_TABLE_SIZE -#define DNS_TABLE_SIZE 4 -#endif - -/** DNS maximum host name length supported in the name table. */ -#ifndef DNS_MAX_NAME_LENGTH -#define DNS_MAX_NAME_LENGTH 256 -#endif - -/** The maximum of DNS servers */ -#ifndef DNS_MAX_SERVERS -#define DNS_MAX_SERVERS 2 -#endif - -/** DNS do a name checking between the query and the response. */ -#ifndef DNS_DOES_NAME_CHECK -#define DNS_DOES_NAME_CHECK 1 -#endif - -/** DNS message max. size. Default value is RFC compliant. */ -#ifndef DNS_MSG_SIZE -#define DNS_MSG_SIZE 512 -#endif - -/** DNS_LOCAL_HOSTLIST: Implements a local host-to-address list. If enabled, - * you have to define - * #define DNS_LOCAL_HOSTLIST_INIT {{"host1", 0x123}, {"host2", 0x234}} - * (an array of structs name/address, where address is an u32_t in network - * byte order). - * - * Instead, you can also use an external function: - * #define DNS_LOOKUP_LOCAL_EXTERN(x) extern u32_t my_lookup_function(const char *name) - * that returns the IP address or INADDR_NONE if not found. - */ -#ifndef DNS_LOCAL_HOSTLIST -#define DNS_LOCAL_HOSTLIST 0 -#endif /* DNS_LOCAL_HOSTLIST */ - -/** If this is turned on, the local host-list can be dynamically changed - * at runtime. */ -#ifndef DNS_LOCAL_HOSTLIST_IS_DYNAMIC -#define DNS_LOCAL_HOSTLIST_IS_DYNAMIC 0 -#endif /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */ - -/* - --------------------------------- - ---------- UDP options ---------- - --------------------------------- -*/ -/** - * LWIP_UDP==1: Turn on UDP. - */ -#ifndef LWIP_UDP -#define LWIP_UDP 1 -#endif - -/** - * LWIP_UDPLITE==1: Turn on UDP-Lite. (Requires LWIP_UDP) - */ -#ifndef LWIP_UDPLITE -#define LWIP_UDPLITE 0 -#endif - -/** - * UDP_TTL: Default Time-To-Live value. - */ -#ifndef UDP_TTL -#define UDP_TTL (IP_DEFAULT_TTL) -#endif - -/** - * LWIP_NETBUF_RECVINFO==1: append destination addr and port to every netbuf. - */ -#ifndef LWIP_NETBUF_RECVINFO -#define LWIP_NETBUF_RECVINFO 0 -#endif - -/* - --------------------------------- - ---------- TCP options ---------- - --------------------------------- -*/ -/** - * LWIP_TCP==1: Turn on TCP. - */ -#ifndef LWIP_TCP -#define LWIP_TCP 1 -#endif - -/** - * TCP_TTL: Default Time-To-Live value. - */ -#ifndef TCP_TTL -#define TCP_TTL (IP_DEFAULT_TTL) -#endif - -/** - * TCP_WND: The size of a TCP window. This must be at least - * (2 * TCP_MSS) for things to work well - */ -#ifndef TCP_WND -#define TCP_WND (4 * TCP_MSS) -#endif - -/** - * TCP_MAXRTX: Maximum number of retransmissions of data segments. - */ -#ifndef TCP_MAXRTX -#define TCP_MAXRTX 12 -#endif - -/** - * TCP_SYNMAXRTX: Maximum number of retransmissions of SYN segments. - */ -#ifndef TCP_SYNMAXRTX -#define TCP_SYNMAXRTX 6 -#endif - -/** - * TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order. - * Define to 0 if your device is low on memory. - */ -#ifndef TCP_QUEUE_OOSEQ -#define TCP_QUEUE_OOSEQ (LWIP_TCP) -#endif - -/** - * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default, - * you might want to increase this.) - * For the receive side, this MSS is advertised to the remote side - * when opening a connection. For the transmit size, this MSS sets - * an upper limit on the MSS advertised by the remote host. - */ -#ifndef TCP_MSS -#define TCP_MSS 536 -#endif - -/** - * TCP_CALCULATE_EFF_SEND_MSS: "The maximum size of a segment that TCP really - * sends, the 'effective send MSS,' MUST be the smaller of the send MSS (which - * reflects the available reassembly buffer size at the remote host) and the - * largest size permitted by the IP layer" (RFC 1122) - * Setting this to 1 enables code that checks TCP_MSS against the MTU of the - * netif used for a connection and limits the MSS if it would be too big otherwise. - */ -#ifndef TCP_CALCULATE_EFF_SEND_MSS -#define TCP_CALCULATE_EFF_SEND_MSS 1 -#endif - - -/** - * TCP_SND_BUF: TCP sender buffer space (bytes). - * To achieve good performance, this should be at least 2 * TCP_MSS. - */ -#ifndef TCP_SND_BUF -#define TCP_SND_BUF (2 * TCP_MSS) -#endif - -/** - * TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least - * as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. - */ -#ifndef TCP_SND_QUEUELEN -#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS)) -#endif - -/** - * TCP_SNDLOWAT: TCP writable space (bytes). This must be less than - * TCP_SND_BUF. It is the amount of space which must be available in the - * TCP snd_buf for select to return writable (combined with TCP_SNDQUEUELOWAT). - */ -#ifndef TCP_SNDLOWAT -#define TCP_SNDLOWAT LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), (2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1) -#endif - -/** - * TCP_SNDQUEUELOWAT: TCP writable bufs (pbuf count). This must be less - * than TCP_SND_QUEUELEN. If the number of pbufs queued on a pcb drops below - * this number, select returns writable (combined with TCP_SNDLOWAT). - */ -#ifndef TCP_SNDQUEUELOWAT -#define TCP_SNDQUEUELOWAT LWIP_MAX(((TCP_SND_QUEUELEN)/2), 5) -#endif - -/** - * TCP_OOSEQ_MAX_BYTES: The maximum number of bytes queued on ooseq per pcb. - * Default is 0 (no limit). Only valid for TCP_QUEUE_OOSEQ==0. - */ -#ifndef TCP_OOSEQ_MAX_BYTES -#define TCP_OOSEQ_MAX_BYTES 0 -#endif - -/** - * TCP_OOSEQ_MAX_PBUFS: The maximum number of pbufs queued on ooseq per pcb. - * Default is 0 (no limit). Only valid for TCP_QUEUE_OOSEQ==0. - */ -#ifndef TCP_OOSEQ_MAX_PBUFS -#define TCP_OOSEQ_MAX_PBUFS 0 -#endif - -/** - * TCP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb. - */ -#ifndef TCP_LISTEN_BACKLOG -#define TCP_LISTEN_BACKLOG 0 -#endif - -/** - * The maximum allowed backlog for TCP listen netconns. - * This backlog is used unless another is explicitly specified. - * 0xff is the maximum (u8_t). - */ -#ifndef TCP_DEFAULT_LISTEN_BACKLOG -#define TCP_DEFAULT_LISTEN_BACKLOG 0xff -#endif - -/** - * TCP_OVERSIZE: The maximum number of bytes that tcp_write may - * allocate ahead of time in an attempt to create shorter pbuf chains - * for transmission. The meaningful range is 0 to TCP_MSS. Some - * suggested values are: - * - * 0: Disable oversized allocation. Each tcp_write() allocates a new - pbuf (old behaviour). - * 1: Allocate size-aligned pbufs with minimal excess. Use this if your - * scatter-gather DMA requires aligned fragments. - * 128: Limit the pbuf/memory overhead to 20%. - * TCP_MSS: Try to create unfragmented TCP packets. - * TCP_MSS/4: Try to create 4 fragments or less per TCP packet. - */ -#ifndef TCP_OVERSIZE -#define TCP_OVERSIZE TCP_MSS -#endif - -/** - * LWIP_TCP_TIMESTAMPS==1: support the TCP timestamp option. - */ -#ifndef LWIP_TCP_TIMESTAMPS -#define LWIP_TCP_TIMESTAMPS 0 -#endif - -/** - * TCP_WND_UPDATE_THRESHOLD: difference in window to trigger an - * explicit window update - */ -#ifndef TCP_WND_UPDATE_THRESHOLD -#define TCP_WND_UPDATE_THRESHOLD (TCP_WND / 4) -#endif - -/** - * LWIP_EVENT_API and LWIP_CALLBACK_API: Only one of these should be set to 1. - * LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all - * events (accept, sent, etc) that happen in the system. - * LWIP_CALLBACK_API==1: The PCB callback function is called directly - * for the event. This is the default. - */ -#if !defined(LWIP_EVENT_API) && !defined(LWIP_CALLBACK_API) -#define LWIP_EVENT_API 0 -#define LWIP_CALLBACK_API 1 -#endif - - -/* - ---------------------------------- - ---------- Pbuf options ---------- - ---------------------------------- -*/ -/** - * PBUF_LINK_HLEN: the number of bytes that should be allocated for a - * link level header. The default is 14, the standard value for - * Ethernet. - */ -#ifndef PBUF_LINK_HLEN -#define PBUF_LINK_HLEN (14 + ETH_PAD_SIZE) -#endif - -/** - * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is - * designed to accomodate single full size TCP frame in one pbuf, including - * TCP_MSS, IP header, and link header. - */ -#ifndef PBUF_POOL_BUFSIZE -#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_HLEN) -#endif - -/* - ------------------------------------------------ - ---------- Network Interfaces options ---------- - ------------------------------------------------ -*/ -/** - * LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname - * field. - */ -#ifndef LWIP_NETIF_HOSTNAME -#define LWIP_NETIF_HOSTNAME 0 -#endif - -/** - * LWIP_NETIF_API==1: Support netif api (in netifapi.c) - */ -#ifndef LWIP_NETIF_API -#define LWIP_NETIF_API 0 -#endif - -/** - * LWIP_NETIF_STATUS_CALLBACK==1: Support a callback function whenever an interface - * changes its up/down status (i.e., due to DHCP IP acquistion) - */ -#ifndef LWIP_NETIF_STATUS_CALLBACK -#define LWIP_NETIF_STATUS_CALLBACK 0 -#endif - -/** - * LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface - * whenever the link changes (i.e., link down) - */ -#ifndef LWIP_NETIF_LINK_CALLBACK -#define LWIP_NETIF_LINK_CALLBACK 0 -#endif - -/** - * LWIP_NETIF_REMOVE_CALLBACK==1: Support a callback function that is called - * when a netif has been removed - */ -#ifndef LWIP_NETIF_REMOVE_CALLBACK -#define LWIP_NETIF_REMOVE_CALLBACK 0 -#endif - -/** - * LWIP_NETIF_HWADDRHINT==1: Cache link-layer-address hints (e.g. table - * indices) in struct netif. TCP and UDP can make use of this to prevent - * scanning the ARP table for every sent packet. While this is faster for big - * ARP tables or many concurrent connections, it might be counterproductive - * if you have a tiny ARP table or if there never are concurrent connections. - */ -#ifndef LWIP_NETIF_HWADDRHINT -#define LWIP_NETIF_HWADDRHINT 0 -#endif - -/** - * LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP - * address equal to the netif IP address, looping them back up the stack. - */ -#ifndef LWIP_NETIF_LOOPBACK -#define LWIP_NETIF_LOOPBACK 0 -#endif - -/** - * LWIP_LOOPBACK_MAX_PBUFS: Maximum number of pbufs on queue for loopback - * sending for each netif (0 = disabled) - */ -#ifndef LWIP_LOOPBACK_MAX_PBUFS -#define LWIP_LOOPBACK_MAX_PBUFS 0 -#endif - -/** - * LWIP_NETIF_LOOPBACK_MULTITHREADING: Indicates whether threading is enabled in - * the system, as netifs must change how they behave depending on this setting - * for the LWIP_NETIF_LOOPBACK option to work. - * Setting this is needed to avoid reentering non-reentrant functions like - * tcp_input(). - * LWIP_NETIF_LOOPBACK_MULTITHREADING==1: Indicates that the user is using a - * multithreaded environment like tcpip.c. In this case, netif->input() - * is called directly. - * LWIP_NETIF_LOOPBACK_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup. - * The packets are put on a list and netif_poll() must be called in - * the main application loop. - */ -#ifndef LWIP_NETIF_LOOPBACK_MULTITHREADING -#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS) -#endif - -/** - * LWIP_NETIF_TX_SINGLE_PBUF: if this is set to 1, lwIP tries to put all data - * to be sent into one single pbuf. This is for compatibility with DMA-enabled - * MACs that do not support scatter-gather. - * Beware that this might involve CPU-memcpy before transmitting that would not - * be needed without this flag! Use this only if you need to! - * - * @todo: TCP and IP-frag do not work with this, yet: - */ -#ifndef LWIP_NETIF_TX_SINGLE_PBUF -#define LWIP_NETIF_TX_SINGLE_PBUF 0 -#endif /* LWIP_NETIF_TX_SINGLE_PBUF */ - -/* - ------------------------------------ - ---------- LOOPIF options ---------- - ------------------------------------ -*/ -/** - * LWIP_HAVE_LOOPIF==1: Support loop interface (127.0.0.1) and loopif.c - */ -#ifndef LWIP_HAVE_LOOPIF -#define LWIP_HAVE_LOOPIF 0 -#endif - -/* - ------------------------------------ - ---------- SLIPIF options ---------- - ------------------------------------ -*/ -/** - * LWIP_HAVE_SLIPIF==1: Support slip interface and slipif.c - */ -#ifndef LWIP_HAVE_SLIPIF -#define LWIP_HAVE_SLIPIF 0 -#endif - -/* - ------------------------------------ - ---------- Thread options ---------- - ------------------------------------ -*/ -/** - * TCPIP_THREAD_NAME: The name assigned to the main tcpip thread. - */ -#ifndef TCPIP_THREAD_NAME -#define TCPIP_THREAD_NAME "tcpip_thread" -#endif - -/** - * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread. - * The stack size value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef TCPIP_THREAD_STACKSIZE -#define TCPIP_THREAD_STACKSIZE 0 -#endif - -/** - * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread. - * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef TCPIP_THREAD_PRIO -#define TCPIP_THREAD_PRIO 1 -#endif - -/** - * TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages - * The queue size value itself is platform-dependent, but is passed to - * sys_mbox_new() when tcpip_init is called. - */ -#ifndef TCPIP_MBOX_SIZE -#define TCPIP_MBOX_SIZE 0 -#endif - -/** - * SLIPIF_THREAD_NAME: The name assigned to the slipif_loop thread. - */ -#ifndef SLIPIF_THREAD_NAME -#define SLIPIF_THREAD_NAME "slipif_loop" -#endif - -/** - * SLIP_THREAD_STACKSIZE: The stack size used by the slipif_loop thread. - * The stack size value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef SLIPIF_THREAD_STACKSIZE -#define SLIPIF_THREAD_STACKSIZE 0 -#endif - -/** - * SLIPIF_THREAD_PRIO: The priority assigned to the slipif_loop thread. - * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef SLIPIF_THREAD_PRIO -#define SLIPIF_THREAD_PRIO 1 -#endif - -/** - * PPP_THREAD_NAME: The name assigned to the pppInputThread. - */ -#ifndef PPP_THREAD_NAME -#define PPP_THREAD_NAME "pppInputThread" -#endif - -/** - * PPP_THREAD_STACKSIZE: The stack size used by the pppInputThread. - * The stack size value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef PPP_THREAD_STACKSIZE -#define PPP_THREAD_STACKSIZE 0 -#endif - -/** - * PPP_THREAD_PRIO: The priority assigned to the pppInputThread. - * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef PPP_THREAD_PRIO -#define PPP_THREAD_PRIO 1 -#endif - -/** - * DEFAULT_THREAD_NAME: The name assigned to any other lwIP thread. - */ -#ifndef DEFAULT_THREAD_NAME -#define DEFAULT_THREAD_NAME "lwIP" -#endif - -/** - * DEFAULT_THREAD_STACKSIZE: The stack size used by any other lwIP thread. - * The stack size value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef DEFAULT_THREAD_STACKSIZE -#define DEFAULT_THREAD_STACKSIZE 0 -#endif - -/** - * DEFAULT_THREAD_PRIO: The priority assigned to any other lwIP thread. - * The priority value itself is platform-dependent, but is passed to - * sys_thread_new() when the thread is created. - */ -#ifndef DEFAULT_THREAD_PRIO -#define DEFAULT_THREAD_PRIO 1 -#endif - -/** - * DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a - * NETCONN_RAW. The queue size value itself is platform-dependent, but is passed - * to sys_mbox_new() when the recvmbox is created. - */ -#ifndef DEFAULT_RAW_RECVMBOX_SIZE -#define DEFAULT_RAW_RECVMBOX_SIZE 0 -#endif - -/** - * DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a - * NETCONN_UDP. The queue size value itself is platform-dependent, but is passed - * to sys_mbox_new() when the recvmbox is created. - */ -#ifndef DEFAULT_UDP_RECVMBOX_SIZE -#define DEFAULT_UDP_RECVMBOX_SIZE 0 -#endif - -/** - * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a - * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed - * to sys_mbox_new() when the recvmbox is created. - */ -#ifndef DEFAULT_TCP_RECVMBOX_SIZE -#define DEFAULT_TCP_RECVMBOX_SIZE 0 -#endif - -/** - * DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections. - * The queue size value itself is platform-dependent, but is passed to - * sys_mbox_new() when the acceptmbox is created. - */ -#ifndef DEFAULT_ACCEPTMBOX_SIZE -#define DEFAULT_ACCEPTMBOX_SIZE 0 -#endif - -/* - ---------------------------------------------- - ---------- Sequential layer options ---------- - ---------------------------------------------- -*/ -/** - * LWIP_TCPIP_CORE_LOCKING: (EXPERIMENTAL!) - * Don't use it if you're not an active lwIP project member - */ -#ifndef LWIP_TCPIP_CORE_LOCKING -#define LWIP_TCPIP_CORE_LOCKING 0 -#endif - -/** - * LWIP_TCPIP_CORE_LOCKING_INPUT: (EXPERIMENTAL!) - * Don't use it if you're not an active lwIP project member - */ -#ifndef LWIP_TCPIP_CORE_LOCKING_INPUT -#define LWIP_TCPIP_CORE_LOCKING_INPUT 0 -#endif - -/** - * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) - */ -#ifndef LWIP_NETCONN -#define LWIP_NETCONN 1 -#endif - -/** LWIP_TCPIP_TIMEOUT==1: Enable tcpip_timeout/tcpip_untimeout tod create - * timers running in tcpip_thread from another thread. - */ -#ifndef LWIP_TCPIP_TIMEOUT -#define LWIP_TCPIP_TIMEOUT 1 -#endif - -/* - ------------------------------------ - ---------- Socket options ---------- - ------------------------------------ -*/ -/** - * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) - */ -#ifndef LWIP_SOCKET -#define LWIP_SOCKET 1 -#endif - -/** - * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names. - * (only used if you use sockets.c) - */ -#ifndef LWIP_COMPAT_SOCKETS -#define LWIP_COMPAT_SOCKETS 1 -#endif - -/** - * LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names. - * Disable this option if you use a POSIX operating system that uses the same - * names (read, write & close). (only used if you use sockets.c) - */ -#ifndef LWIP_POSIX_SOCKETS_IO_NAMES -#define LWIP_POSIX_SOCKETS_IO_NAMES 1 -#endif - -/** - * LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT - * options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set - * in seconds. (does not require sockets.c, and will affect tcp.c) - */ -#ifndef LWIP_TCP_KEEPALIVE -#define LWIP_TCP_KEEPALIVE 0 -#endif - -/** - * LWIP_SO_SNDTIMEO==1: Enable send timeout for sockets/netconns and - * SO_SNDTIMEO processing. - */ -#ifndef LWIP_SO_SNDTIMEO -#define LWIP_SO_SNDTIMEO 0 -#endif - -/** - * LWIP_SO_RCVTIMEO==1: Enable receive timeout for sockets/netconns and - * SO_RCVTIMEO processing. - */ -#ifndef LWIP_SO_RCVTIMEO -#define LWIP_SO_RCVTIMEO 0 -#endif - -/** - * LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing. - */ -#ifndef LWIP_SO_RCVBUF -#define LWIP_SO_RCVBUF 0 -#endif - -/** - * If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize. - */ -#ifndef RECV_BUFSIZE_DEFAULT -#define RECV_BUFSIZE_DEFAULT INT_MAX -#endif - -/** - * SO_REUSE==1: Enable SO_REUSEADDR option. - */ -#ifndef SO_REUSE -#define SO_REUSE 0 -#endif - -/** - * SO_REUSE_RXTOALL==1: Pass a copy of incoming broadcast/multicast packets - * to all local matches if SO_REUSEADDR is turned on. - * WARNING: Adds a memcpy for every packet if passing to more than one pcb! - */ -#ifndef SO_REUSE_RXTOALL -#define SO_REUSE_RXTOALL 0 -#endif - -/** - * LWIP_FIONREAD_LINUXMODE==0 (default): ioctl/FIONREAD returns the amount of - * pending data in the network buffer. This is the way windows does it. It's - * the default for lwIP since it is smaller. - * LWIP_FIONREAD_LINUXMODE==1: ioctl/FIONREAD returns the size of the next - * pending datagram in bytes. This is the way linux does it. This code is only - * here for compatibility. - */ -#ifndef LWIP_FIONREAD_LINUXMODE -#define LWIP_FIONREAD_LINUXMODE 0 -#endif - -/* - ---------------------------------------- - ---------- Statistics options ---------- - ---------------------------------------- -*/ -/** - * LWIP_STATS==1: Enable statistics collection in lwip_stats. - */ -#ifndef LWIP_STATS -#define LWIP_STATS 1 -#endif - -#if LWIP_STATS - -/** - * LWIP_STATS_DISPLAY==1: Compile in the statistics output functions. - */ -#ifndef LWIP_STATS_DISPLAY -#define LWIP_STATS_DISPLAY 0 -#endif - -/** - * LINK_STATS==1: Enable link stats. - */ -#ifndef LINK_STATS -#define LINK_STATS 1 -#endif - -/** - * ETHARP_STATS==1: Enable etharp stats. - */ -#ifndef ETHARP_STATS -#define ETHARP_STATS (LWIP_ARP) -#endif - -/** - * IP_STATS==1: Enable IP stats. - */ -#ifndef IP_STATS -#define IP_STATS 1 -#endif - -/** - * IPFRAG_STATS==1: Enable IP fragmentation stats. Default is - * on if using either frag or reass. - */ -#ifndef IPFRAG_STATS -#define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG) -#endif - -/** - * ICMP_STATS==1: Enable ICMP stats. - */ -#ifndef ICMP_STATS -#define ICMP_STATS 1 -#endif - -/** - * IGMP_STATS==1: Enable IGMP stats. - */ -#ifndef IGMP_STATS -#define IGMP_STATS (LWIP_IGMP) -#endif - -/** - * UDP_STATS==1: Enable UDP stats. Default is on if - * UDP enabled, otherwise off. - */ -#ifndef UDP_STATS -#define UDP_STATS (LWIP_UDP) -#endif - -/** - * TCP_STATS==1: Enable TCP stats. Default is on if TCP - * enabled, otherwise off. - */ -#ifndef TCP_STATS -#define TCP_STATS (LWIP_TCP) -#endif - -/** - * MEM_STATS==1: Enable mem.c stats. - */ -#ifndef MEM_STATS -#define MEM_STATS ((MEM_LIBC_MALLOC == 0) && (MEM_USE_POOLS == 0)) -#endif - -/** - * MEMP_STATS==1: Enable memp.c pool stats. - */ -#ifndef MEMP_STATS -#define MEMP_STATS (MEMP_MEM_MALLOC == 0) -#endif - -/** - * SYS_STATS==1: Enable system stats (sem and mbox counts, etc). - */ -#ifndef SYS_STATS -#define SYS_STATS (NO_SYS == 0) -#endif - -/** - * IP6_STATS==1: Enable IPv6 stats. - */ -#ifndef IP6_STATS -#define IP6_STATS (LWIP_IPV6) -#endif - -/** - * ICMP6_STATS==1: Enable ICMP for IPv6 stats. - */ -#ifndef ICMP6_STATS -#define ICMP6_STATS (LWIP_IPV6 && LWIP_ICMP6) -#endif - -/** - * IP6_FRAG_STATS==1: Enable IPv6 fragmentation stats. - */ -#ifndef IP6_FRAG_STATS -#define IP6_FRAG_STATS (LWIP_IPV6 && (LWIP_IPV6_FRAG || LWIP_IPV6_REASS)) -#endif - -/** - * MLD6_STATS==1: Enable MLD for IPv6 stats. - */ -#ifndef MLD6_STATS -#define MLD6_STATS (LWIP_IPV6 && LWIP_IPV6_MLD) -#endif - -/** - * ND6_STATS==1: Enable Neighbor discovery for IPv6 stats. - */ -#ifndef ND6_STATS -#define ND6_STATS (LWIP_IPV6) -#endif - -#else - -#define LINK_STATS 0 -#define IP_STATS 0 -#define IPFRAG_STATS 0 -#define ICMP_STATS 0 -#define IGMP_STATS 0 -#define UDP_STATS 0 -#define TCP_STATS 0 -#define MEM_STATS 0 -#define MEMP_STATS 0 -#define SYS_STATS 0 -#define LWIP_STATS_DISPLAY 0 -#define IP6_STATS 0 -#define ICMP6_STATS 0 -#define IP6_FRAG_STATS 0 -#define MLD6_STATS 0 -#define ND6_STATS 0 - -#endif /* LWIP_STATS */ - -/* - --------------------------------- - ---------- PPP options ---------- - --------------------------------- -*/ -/** - * PPP_SUPPORT==1: Enable PPP. - */ -#ifndef PPP_SUPPORT -#define PPP_SUPPORT 0 -#endif - -/** - * PPPOE_SUPPORT==1: Enable PPP Over Ethernet - */ -#ifndef PPPOE_SUPPORT -#define PPPOE_SUPPORT 0 -#endif - -/** - * PPPOS_SUPPORT==1: Enable PPP Over Serial - */ -#ifndef PPPOS_SUPPORT -#define PPPOS_SUPPORT PPP_SUPPORT -#endif - -#if PPP_SUPPORT - -/** - * NUM_PPP: Max PPP sessions. - */ -#ifndef NUM_PPP -#define NUM_PPP 1 -#endif - -/** - * PAP_SUPPORT==1: Support PAP. - */ -#ifndef PAP_SUPPORT -#define PAP_SUPPORT 0 -#endif - -/** - * CHAP_SUPPORT==1: Support CHAP. - */ -#ifndef CHAP_SUPPORT -#define CHAP_SUPPORT 0 -#endif - -/** - * MSCHAP_SUPPORT==1: Support MSCHAP. CURRENTLY NOT SUPPORTED! DO NOT SET! - */ -#ifndef MSCHAP_SUPPORT -#define MSCHAP_SUPPORT 0 -#endif - -/** - * CBCP_SUPPORT==1: Support CBCP. CURRENTLY NOT SUPPORTED! DO NOT SET! - */ -#ifndef CBCP_SUPPORT -#define CBCP_SUPPORT 0 -#endif - -/** - * CCP_SUPPORT==1: Support CCP. CURRENTLY NOT SUPPORTED! DO NOT SET! - */ -#ifndef CCP_SUPPORT -#define CCP_SUPPORT 0 -#endif - -/** - * VJ_SUPPORT==1: Support VJ header compression. - */ -#ifndef VJ_SUPPORT -#define VJ_SUPPORT 0 -#endif - -/** - * MD5_SUPPORT==1: Support MD5 (see also CHAP). - */ -#ifndef MD5_SUPPORT -#define MD5_SUPPORT 0 -#endif - -/* - * Timeouts - */ -#ifndef FSM_DEFTIMEOUT -#define FSM_DEFTIMEOUT 6 /* Timeout time in seconds */ -#endif - -#ifndef FSM_DEFMAXTERMREQS -#define FSM_DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */ -#endif - -#ifndef FSM_DEFMAXCONFREQS -#define FSM_DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */ -#endif - -#ifndef FSM_DEFMAXNAKLOOPS -#define FSM_DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */ -#endif - -#ifndef UPAP_DEFTIMEOUT -#define UPAP_DEFTIMEOUT 6 /* Timeout (seconds) for retransmitting req */ -#endif - -#ifndef UPAP_DEFREQTIME -#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ -#endif - -#ifndef CHAP_DEFTIMEOUT -#define CHAP_DEFTIMEOUT 6 /* Timeout time in seconds */ -#endif - -#ifndef CHAP_DEFTRANSMITS -#define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */ -#endif - -/* Interval in seconds between keepalive echo requests, 0 to disable. */ -#ifndef LCP_ECHOINTERVAL -#define LCP_ECHOINTERVAL 0 -#endif - -/* Number of unanswered echo requests before failure. */ -#ifndef LCP_MAXECHOFAILS -#define LCP_MAXECHOFAILS 3 -#endif - -/* Max Xmit idle time (in jiffies) before resend flag char. */ -#ifndef PPP_MAXIDLEFLAG -#define PPP_MAXIDLEFLAG 100 -#endif - -/* - * Packet sizes - * - * Note - lcp shouldn't be allowed to negotiate stuff outside these - * limits. See lcp.h in the pppd directory. - * (XXX - these constants should simply be shared by lcp.c instead - * of living in lcp.h) - */ -#define PPP_MTU 1500 /* Default MTU (size of Info field) */ -#ifndef PPP_MAXMTU -/* #define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN) */ -#define PPP_MAXMTU 1500 /* Largest MTU we allow */ -#endif -#define PPP_MINMTU 64 -#define PPP_MRU 1500 /* default MRU = max length of info field */ -#define PPP_MAXMRU 1500 /* Largest MRU we allow */ -#ifndef PPP_DEFMRU -#define PPP_DEFMRU 296 /* Try for this */ -#endif -#define PPP_MINMRU 128 /* No MRUs below this */ - -#ifndef MAXNAMELEN -#define MAXNAMELEN 256 /* max length of hostname or name for auth */ -#endif -#ifndef MAXSECRETLEN -#define MAXSECRETLEN 256 /* max length of password or secret */ -#endif - -#endif /* PPP_SUPPORT */ - -/* - -------------------------------------- - ---------- Checksum options ---------- - -------------------------------------- -*/ -/** - * CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets. - */ -#ifndef CHECKSUM_GEN_IP -#define CHECKSUM_GEN_IP 1 -#endif - -/** - * CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets. - */ -#ifndef CHECKSUM_GEN_UDP -#define CHECKSUM_GEN_UDP 1 -#endif - -/** - * CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets. - */ -#ifndef CHECKSUM_GEN_TCP -#define CHECKSUM_GEN_TCP 1 -#endif - -/** - * CHECKSUM_GEN_ICMP==1: Generate checksums in software for outgoing ICMP packets. - */ -#ifndef CHECKSUM_GEN_ICMP -#define CHECKSUM_GEN_ICMP 1 -#endif - -/** - * CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets. - */ -#ifndef CHECKSUM_CHECK_IP -#define CHECKSUM_CHECK_IP 1 -#endif - -/** - * CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets. - */ -#ifndef CHECKSUM_CHECK_UDP -#define CHECKSUM_CHECK_UDP 1 -#endif - -/** - * CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets. - */ -#ifndef CHECKSUM_CHECK_TCP -#define CHECKSUM_CHECK_TCP 1 -#endif - -/** - * LWIP_CHECKSUM_ON_COPY==1: Calculate checksum when copying data from - * application buffers to pbufs. - */ -#ifndef LWIP_CHECKSUM_ON_COPY -#define LWIP_CHECKSUM_ON_COPY 0 -#endif - -/* - --------------------------------------- - ---------- IPv6 options --------------- - --------------------------------------- -*/ -/** - * LWIP_IPV6==1: Enable IPv6 - */ -#ifndef LWIP_IPV6 -#define LWIP_IPV6 0 -#endif - -/** - * LWIP_IPV6_NUM_ADDRESSES: Number of IPv6 addresses per netif. - */ -#ifndef LWIP_IPV6_NUM_ADDRESSES -#define LWIP_IPV6_NUM_ADDRESSES 3 -#endif - -/** - * LWIP_IPV6_FORWARD==1: Forward IPv6 packets across netifs - */ -#ifndef LWIP_IPV6_FORWARD -#define LWIP_IPV6_FORWARD 0 -#endif - -/** - * LWIP_ICMP6==1: Enable ICMPv6 (mandatory per RFC) - */ -#ifndef LWIP_ICMP6 -#define LWIP_ICMP6 (LWIP_IPV6) -#endif - -/** - * LWIP_ICMP6_DATASIZE: bytes from original packet to send back in - * ICMPv6 error messages. - */ -#ifndef LWIP_ICMP6_DATASIZE -#define LWIP_ICMP6_DATASIZE 8 -#endif - -/** - * LWIP_ICMP6_HL: default hop limit for ICMPv6 messages - */ -#ifndef LWIP_ICMP6_HL -#define LWIP_ICMP6_HL 255 -#endif - -/** - * LWIP_ICMP6_CHECKSUM_CHECK==1: verify checksum on ICMPv6 packets - */ -#ifndef LWIP_ICMP6_CHECKSUM_CHECK -#define LWIP_ICMP6_CHECKSUM_CHECK 1 -#endif - -/** - * LWIP_IPV6_MLD==1: Enable multicast listener discovery protocol. - */ -#ifndef LWIP_IPV6_MLD -#define LWIP_IPV6_MLD (LWIP_IPV6) -#endif - -/** - * MEMP_NUM_MLD6_GROUP: Max number of IPv6 multicast that can be joined. - */ -#ifndef MEMP_NUM_MLD6_GROUP -#define MEMP_NUM_MLD6_GROUP 4 -#endif - -/** - * LWIP_IPV6_FRAG==1: Fragment outgoing IPv6 packets that are too big. - */ -#ifndef LWIP_IPV6_FRAG -#define LWIP_IPV6_FRAG 0 -#endif - -/** - * LWIP_IPV6_REASS==1: reassemble incoming IPv6 packets that fragmented - */ -#ifndef LWIP_IPV6_REASS -#define LWIP_IPV6_REASS (LWIP_IPV6) -#endif - -/** - * LWIP_ND6_QUEUEING==1: queue outgoing IPv6 packets while MAC address - * is being resolved. - */ -#ifndef LWIP_ND6_QUEUEING -#define LWIP_ND6_QUEUEING (LWIP_IPV6) -#endif - -/** - * MEMP_NUM_ND6_QUEUE: Max number of IPv6 packets to queue during MAC resolution. - */ -#ifndef MEMP_NUM_ND6_QUEUE -#define MEMP_NUM_ND6_QUEUE 20 -#endif - -/** - * LWIP_ND6_NUM_NEIGHBORS: Number of entries in IPv6 neighbor cache - */ -#ifndef LWIP_ND6_NUM_NEIGHBORS -#define LWIP_ND6_NUM_NEIGHBORS 10 -#endif - -/** - * LWIP_ND6_NUM_DESTINATIONS: number of entries in IPv6 destination cache - */ -#ifndef LWIP_ND6_NUM_DESTINATIONS -#define LWIP_ND6_NUM_DESTINATIONS 10 -#endif - -/** - * LWIP_ND6_NUM_PREFIXES: number of entries in IPv6 on-link prefixes cache - */ -#ifndef LWIP_ND6_NUM_PREFIXES -#define LWIP_ND6_NUM_PREFIXES 5 -#endif - -/** - * LWIP_ND6_NUM_ROUTERS: number of entries in IPv6 default router cache - */ -#ifndef LWIP_ND6_NUM_ROUTERS -#define LWIP_ND6_NUM_ROUTERS 3 -#endif - -/** - * LWIP_ND6_MAX_MULTICAST_SOLICIT: max number of multicast solicit messages to send - * (neighbor solicit and router solicit) - */ -#ifndef LWIP_ND6_MAX_MULTICAST_SOLICIT -#define LWIP_ND6_MAX_MULTICAST_SOLICIT 3 -#endif - -/** - * LWIP_ND6_MAX_UNICAST_SOLICIT: max number of unicast neighbor solicitation messages - * to send during neighbor reachability detection. - */ -#ifndef LWIP_ND6_MAX_UNICAST_SOLICIT -#define LWIP_ND6_MAX_UNICAST_SOLICIT 3 -#endif - -/** - * Unused: See ND RFC (time in milliseconds). - */ -#ifndef LWIP_ND6_MAX_ANYCAST_DELAY_TIME -#define LWIP_ND6_MAX_ANYCAST_DELAY_TIME 1000 -#endif - -/** - * Unused: See ND RFC - */ -#ifndef LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT -#define LWIP_ND6_MAX_NEIGHBOR_ADVERTISEMENT 3 -#endif - -/** - * LWIP_ND6_REACHABLE_TIME: default neighbor reachable time (in milliseconds). - * May be updated by router advertisement messages. - */ -#ifndef LWIP_ND6_REACHABLE_TIME -#define LWIP_ND6_REACHABLE_TIME 30000 -#endif - -/** - * LWIP_ND6_RETRANS_TIMER: default retransmission timer for solicitation messages - */ -#ifndef LWIP_ND6_RETRANS_TIMER -#define LWIP_ND6_RETRANS_TIMER 1000 -#endif - -/** - * LWIP_ND6_DELAY_FIRST_PROBE_TIME: Delay before first unicast neighbor solicitation - * message is sent, during neighbor reachability detection. - */ -#ifndef LWIP_ND6_DELAY_FIRST_PROBE_TIME -#define LWIP_ND6_DELAY_FIRST_PROBE_TIME 5000 -#endif - -/** - * LWIP_ND6_ALLOW_RA_UPDATES==1: Allow Router Advertisement messages to update - * Reachable time and retransmission timers, and netif MTU. - */ -#ifndef LWIP_ND6_ALLOW_RA_UPDATES -#define LWIP_ND6_ALLOW_RA_UPDATES 1 -#endif - -/** - * LWIP_IPV6_SEND_ROUTER_SOLICIT==1: Send router solicitation messages during - * network startup. - */ -#ifndef LWIP_IPV6_SEND_ROUTER_SOLICIT -#define LWIP_IPV6_SEND_ROUTER_SOLICIT 1 -#endif - -/** - * LWIP_ND6_TCP_REACHABILITY_HINTS==1: Allow TCP to provide Neighbor Discovery - * with reachability hints for connected destinations. This helps avoid sending - * unicast neighbor solicitation messages. - */ -#ifndef LWIP_ND6_TCP_REACHABILITY_HINTS -#define LWIP_ND6_TCP_REACHABILITY_HINTS 1 -#endif - -/** - * LWIP_IPV6_AUTOCONFIG==1: Enable stateless address autoconfiguration as per RFC 4862. - */ -#ifndef LWIP_IPV6_AUTOCONFIG -#define LWIP_IPV6_AUTOCONFIG (LWIP_IPV6) -#endif - -/** - * LWIP_IPV6_DUP_DETECT_ATTEMPTS: Number of duplicate address detection attempts. - */ -#ifndef LWIP_IPV6_DUP_DETECT_ATTEMPTS -#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1 -#endif - -/** - * LWIP_IPV6_DHCP6==1: enable DHCPv6 stateful address autoconfiguration. - */ -#ifndef LWIP_IPV6_DHCP6 -#define LWIP_IPV6_DHCP6 0 -#endif - -/* - --------------------------------------- - ---------- Hook options --------------- - --------------------------------------- -*/ - -/* Hooks are undefined by default, define them to a function if you need them. */ - -/** - * LWIP_HOOK_IP4_INPUT(pbuf, input_netif): - * - called from ip_input() (IPv4) - * - pbuf: received struct pbuf passed to ip_input() - * - input_netif: struct netif on which the packet has been received - * Return values: - * - 0: Hook has not consumed the packet, packet is processed as normal - * - != 0: Hook has consumed the packet. - * If the hook consumed the packet, 'pbuf' is in the responsibility of the hook - * (i.e. free it when done). - */ - -/** - * LWIP_HOOK_IP4_ROUTE(dest): - * - called from ip_route() (IPv4) - * - dest: destination IPv4 address - * Returns the destination netif or NULL if no destination netif is found. In - * that case, ip_route() continues as normal. - */ - -/* - --------------------------------------- - ---------- Debugging options ---------- - --------------------------------------- -*/ -/** - * LWIP_DBG_MIN_LEVEL: After masking, the value of the debug is - * compared against this value. If it is smaller, then debugging - * messages are written. - */ -#ifndef LWIP_DBG_MIN_LEVEL -#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL -#endif - -/** - * LWIP_DBG_TYPES_ON: A mask that can be used to globally enable/disable - * debug messages of certain types. - */ -#ifndef LWIP_DBG_TYPES_ON -#define LWIP_DBG_TYPES_ON LWIP_DBG_ON -#endif - -/** - * ETHARP_DEBUG: Enable debugging in etharp.c. - */ -#ifndef ETHARP_DEBUG -#define ETHARP_DEBUG LWIP_DBG_OFF -#endif - -/** - * NETIF_DEBUG: Enable debugging in netif.c. - */ -#ifndef NETIF_DEBUG -#define NETIF_DEBUG LWIP_DBG_OFF -#endif - -/** - * PBUF_DEBUG: Enable debugging in pbuf.c. - */ -#ifndef PBUF_DEBUG -#define PBUF_DEBUG LWIP_DBG_OFF -#endif - -/** - * API_LIB_DEBUG: Enable debugging in api_lib.c. - */ -#ifndef API_LIB_DEBUG -#define API_LIB_DEBUG LWIP_DBG_OFF -#endif - -/** - * API_MSG_DEBUG: Enable debugging in api_msg.c. - */ -#ifndef API_MSG_DEBUG -#define API_MSG_DEBUG LWIP_DBG_OFF -#endif - -/** - * SOCKETS_DEBUG: Enable debugging in sockets.c. - */ -#ifndef SOCKETS_DEBUG -#define SOCKETS_DEBUG LWIP_DBG_OFF -#endif - -/** - * ICMP_DEBUG: Enable debugging in icmp.c. - */ -#ifndef ICMP_DEBUG -#define ICMP_DEBUG LWIP_DBG_OFF -#endif - -/** - * IGMP_DEBUG: Enable debugging in igmp.c. - */ -#ifndef IGMP_DEBUG -#define IGMP_DEBUG LWIP_DBG_OFF -#endif - -/** - * INET_DEBUG: Enable debugging in inet.c. - */ -#ifndef INET_DEBUG -#define INET_DEBUG LWIP_DBG_OFF -#endif - -/** - * IP_DEBUG: Enable debugging for IP. - */ -#ifndef IP_DEBUG -#define IP_DEBUG LWIP_DBG_OFF -#endif - -/** - * IP_REASS_DEBUG: Enable debugging in ip_frag.c for both frag & reass. - */ -#ifndef IP_REASS_DEBUG -#define IP_REASS_DEBUG LWIP_DBG_OFF -#endif - -/** - * RAW_DEBUG: Enable debugging in raw.c. - */ -#ifndef RAW_DEBUG -#define RAW_DEBUG LWIP_DBG_OFF -#endif - -/** - * MEM_DEBUG: Enable debugging in mem.c. - */ -#ifndef MEM_DEBUG -#define MEM_DEBUG LWIP_DBG_OFF -#endif - -/** - * MEMP_DEBUG: Enable debugging in memp.c. - */ -#ifndef MEMP_DEBUG -#define MEMP_DEBUG LWIP_DBG_OFF -#endif - -/** - * SYS_DEBUG: Enable debugging in sys.c. - */ -#ifndef SYS_DEBUG -#define SYS_DEBUG LWIP_DBG_OFF -#endif - -/** - * TIMERS_DEBUG: Enable debugging in timers.c. - */ -#ifndef TIMERS_DEBUG -#define TIMERS_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_DEBUG: Enable debugging for TCP. - */ -#ifndef TCP_DEBUG -#define TCP_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_INPUT_DEBUG: Enable debugging in tcp_in.c for incoming debug. - */ -#ifndef TCP_INPUT_DEBUG -#define TCP_INPUT_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_FR_DEBUG: Enable debugging in tcp_in.c for fast retransmit. - */ -#ifndef TCP_FR_DEBUG -#define TCP_FR_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_RTO_DEBUG: Enable debugging in TCP for retransmit - * timeout. - */ -#ifndef TCP_RTO_DEBUG -#define TCP_RTO_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_CWND_DEBUG: Enable debugging for TCP congestion window. - */ -#ifndef TCP_CWND_DEBUG -#define TCP_CWND_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_WND_DEBUG: Enable debugging in tcp_in.c for window updating. - */ -#ifndef TCP_WND_DEBUG -#define TCP_WND_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_OUTPUT_DEBUG: Enable debugging in tcp_out.c output functions. - */ -#ifndef TCP_OUTPUT_DEBUG -#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_RST_DEBUG: Enable debugging for TCP with the RST message. - */ -#ifndef TCP_RST_DEBUG -#define TCP_RST_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCP_QLEN_DEBUG: Enable debugging for TCP queue lengths. - */ -#ifndef TCP_QLEN_DEBUG -#define TCP_QLEN_DEBUG LWIP_DBG_OFF -#endif - -/** - * UDP_DEBUG: Enable debugging in UDP. - */ -#ifndef UDP_DEBUG -#define UDP_DEBUG LWIP_DBG_OFF -#endif - -/** - * TCPIP_DEBUG: Enable debugging in tcpip.c. - */ -#ifndef TCPIP_DEBUG -#define TCPIP_DEBUG LWIP_DBG_OFF -#endif - -/** - * PPP_DEBUG: Enable debugging for PPP. - */ -#ifndef PPP_DEBUG -#define PPP_DEBUG LWIP_DBG_OFF -#endif - -/** - * SLIP_DEBUG: Enable debugging in slipif.c. - */ -#ifndef SLIP_DEBUG -#define SLIP_DEBUG LWIP_DBG_OFF -#endif - -/** - * DHCP_DEBUG: Enable debugging in dhcp.c. - */ -#ifndef DHCP_DEBUG -#define DHCP_DEBUG LWIP_DBG_OFF -#endif - -/** - * AUTOIP_DEBUG: Enable debugging in autoip.c. - */ -#ifndef AUTOIP_DEBUG -#define AUTOIP_DEBUG LWIP_DBG_OFF -#endif - -/** - * SNMP_MSG_DEBUG: Enable debugging for SNMP messages. - */ -#ifndef SNMP_MSG_DEBUG -#define SNMP_MSG_DEBUG LWIP_DBG_OFF -#endif - -/** - * SNMP_MIB_DEBUG: Enable debugging for SNMP MIBs. - */ -#ifndef SNMP_MIB_DEBUG -#define SNMP_MIB_DEBUG LWIP_DBG_OFF -#endif - -/** - * DNS_DEBUG: Enable debugging for DNS. - */ -#ifndef DNS_DEBUG -#define DNS_DEBUG LWIP_DBG_OFF -#endif - -/** - * IP6_DEBUG: Enable debugging for IPv6. - */ -#ifndef IP6_DEBUG -#define IP6_DEBUG LWIP_DBG_OFF -#endif - -#endif /* __LWIP_OPT_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/pbuf.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/pbuf.h deleted file mode 100644 index 4f8dca8a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/pbuf.h +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef __LWIP_PBUF_H__ -#define __LWIP_PBUF_H__ - -#include "lwip/opt.h" -#include "lwip/err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Currently, the pbuf_custom code is only needed for one specific configuration - * of IP_FRAG */ -#define LWIP_SUPPORT_CUSTOM_PBUF (IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF) - -/* @todo: We need a mechanism to prevent wasting memory in every pbuf - (TCP vs. UDP, IPv4 vs. IPv6: UDP/IPv4 packets may waste up to 28 bytes) */ - -#define PBUF_TRANSPORT_HLEN 20 -#if LWIP_IPV6 -#define PBUF_IP_HLEN 40 -#else -#define PBUF_IP_HLEN 20 -#endif - -typedef enum { - PBUF_TRANSPORT, - PBUF_IP, - PBUF_LINK, - PBUF_RAW -} pbuf_layer; - -typedef enum { - PBUF_RAM, /* pbuf data is stored in RAM */ - PBUF_ROM, /* pbuf data is stored in ROM */ - PBUF_REF, /* pbuf comes from the pbuf pool */ - PBUF_POOL /* pbuf payload refers to RAM */ -} pbuf_type; - - -/** indicates this packet's data should be immediately passed to the application */ -#define PBUF_FLAG_PUSH 0x01U -/** indicates this is a custom pbuf: pbuf_free and pbuf_header handle such a - a pbuf differently */ -#define PBUF_FLAG_IS_CUSTOM 0x02U -/** indicates this pbuf is UDP multicast to be looped back */ -#define PBUF_FLAG_MCASTLOOP 0x04U -/** indicates this pbuf was received as link-level broadcast */ -#define PBUF_FLAG_LLBCAST 0x08U -/** indicates this pbuf was received as link-level multicast */ -#define PBUF_FLAG_LLMCAST 0x10U -/** indicates this pbuf includes a TCP FIN flag */ -#define PBUF_FLAG_TCP_FIN 0x20U - -struct pbuf { - /** next pbuf in singly linked pbuf chain */ - struct pbuf *next; - - /** pointer to the actual data in the buffer */ - void *payload; - - /** - * total length of this buffer and all next buffers in chain - * belonging to the same packet. - * - * For non-queue packet chains this is the invariant: - * p->tot_len == p->len + (p->next? p->next->tot_len: 0) - */ - u16_t tot_len; - - /** length of this buffer */ - u16_t len; - - /** pbuf_type as u8_t instead of enum to save space */ - u8_t /*pbuf_type*/ type; - - /** misc flags */ - u8_t flags; - - /** - * the reference count always equals the number of pointers - * that refer to this pbuf. This can be pointers from an application, - * the stack itself, or pbuf->next pointers from a chain. - */ - u16_t ref; -}; - -#if LWIP_SUPPORT_CUSTOM_PBUF -/** Prototype for a function to free a custom pbuf */ -typedef void (*pbuf_free_custom_fn)(struct pbuf *p); - -/** A custom pbuf: like a pbuf, but following a function pointer to free it. */ -struct pbuf_custom { - /** The actual pbuf */ - struct pbuf pbuf; - /** This function is called when pbuf_free deallocates this pbuf(_custom) */ - pbuf_free_custom_fn custom_free_function; -}; -#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ - -#if LWIP_TCP && TCP_QUEUE_OOSEQ -/** Define this to 0 to prevent freeing ooseq pbufs when the PBUF_POOL is empty */ -#ifndef PBUF_POOL_FREE_OOSEQ -#define PBUF_POOL_FREE_OOSEQ 1 -#endif /* PBUF_POOL_FREE_OOSEQ */ -#if NO_SYS && PBUF_POOL_FREE_OOSEQ -extern volatile u8_t pbuf_free_ooseq_pending; -void pbuf_free_ooseq(void); -/** When not using sys_check_timeouts(), call PBUF_CHECK_FREE_OOSEQ() - at regular intervals from main level to check if ooseq pbufs need to be - freed! */ -#define PBUF_CHECK_FREE_OOSEQ() do { if(pbuf_free_ooseq_pending) { \ - /* pbuf_alloc() reported PBUF_POOL to be empty -> try to free some \ - ooseq queued pbufs now */ \ - pbuf_free_ooseq(); }}while(0) -#endif /* NO_SYS && PBUF_POOL_FREE_OOSEQ*/ -#endif /* LWIP_TCP && TCP_QUEUE_OOSEQ */ - -/* Initializes the pbuf module. This call is empty for now, but may not be in future. */ -#define pbuf_init() - -struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type); -#if LWIP_SUPPORT_CUSTOM_PBUF -struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, - struct pbuf_custom *p, void *payload_mem, - u16_t payload_mem_len); -#endif /* LWIP_SUPPORT_CUSTOM_PBUF */ -void pbuf_realloc(struct pbuf *p, u16_t size); -u8_t pbuf_header(struct pbuf *p, s16_t header_size); -void pbuf_ref(struct pbuf *p); -u8_t pbuf_free(struct pbuf *p); -u8_t pbuf_clen(struct pbuf *p); -void pbuf_cat(struct pbuf *head, struct pbuf *tail); -void pbuf_chain(struct pbuf *head, struct pbuf *tail); -struct pbuf *pbuf_dechain(struct pbuf *p); -err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from); -u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset); -err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len); -struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer); -#if LWIP_CHECKSUM_ON_COPY -err_t pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, - u16_t len, u16_t *chksum); -#endif /* LWIP_CHECKSUM_ON_COPY */ - -u8_t pbuf_get_at(struct pbuf* p, u16_t offset); -u16_t pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n); -u16_t pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset); -u16_t pbuf_strstr(struct pbuf* p, const char* substr); - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_PBUF_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/raw.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/raw.h deleted file mode 100644 index f0c8ed47..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/raw.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_RAW_H__ -#define __LWIP_RAW_H__ - -#include "lwip/opt.h" - -#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/pbuf.h" -#include "lwip/def.h" -#include "lwip/ip.h" -#include "lwip/ip_addr.h" -#include "lwip/ip6_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct raw_pcb; - -/** Function prototype for raw pcb receive callback functions. - * @param arg user supplied argument (raw_pcb.recv_arg) - * @param pcb the raw_pcb which received data - * @param p the packet buffer that was received - * @param addr the remote IP address from which the packet was received - * @return 1 if the packet was 'eaten' (aka. deleted), - * 0 if the packet lives on - * If returning 1, the callback is responsible for freeing the pbuf - * if it's not used any more. - */ -typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p, - ip_addr_t *addr); - -#if LWIP_IPV6 -/** Function prototype for raw pcb IPv6 receive callback functions. - * @param arg user supplied argument (raw_pcb.recv_arg) - * @param pcb the raw_pcb which received data - * @param p the packet buffer that was received - * @param addr the remote IPv6 address from which the packet was received - * @return 1 if the packet was 'eaten' (aka. deleted), - * 0 if the packet lives on - * If returning 1, the callback is responsible for freeing the pbuf - * if it's not used any more. - */ -typedef u8_t (*raw_recv_ip6_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p, - ip6_addr_t *addr); -#endif /* LWIP_IPV6 */ - -#if LWIP_IPV6 -#define RAW_PCB_RECV_IP6 raw_recv_ip6_fn ip6; -#else -#define RAW_PCB_RECV_IP6 -#endif /* LWIP_IPV6 */ - -struct raw_pcb { - /* Common members of all PCB types */ - IP_PCB; - - struct raw_pcb *next; - - u8_t protocol; - - /** receive callback function */ - union { - raw_recv_fn ip4; - RAW_PCB_RECV_IP6 - } recv; - /* user-supplied argument for the recv callback */ - void *recv_arg; -}; - -/* The following functions is the application layer interface to the - RAW code. */ -struct raw_pcb * raw_new (u8_t proto); -void raw_remove (struct raw_pcb *pcb); -err_t raw_bind (struct raw_pcb *pcb, ip_addr_t *ipaddr); -err_t raw_connect (struct raw_pcb *pcb, ip_addr_t *ipaddr); - -void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg); -err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr); -err_t raw_send (struct raw_pcb *pcb, struct pbuf *p); - -#if LWIP_IPV6 -struct raw_pcb * raw_new_ip6 (u8_t proto); -#define raw_bind_ip6(pcb, ip6addr) raw_bind(pcb, ip6_2_ip(ip6addr)) -#define raw_connect_ip6(pcb, ip6addr) raw_connect(pcb, ip6_2_ip(ip6addr)) -#define raw_recv_ip6(pcb, recv_ip6_fn, recv_arg) raw_recv(pcb, (raw_recv_fn)recv_ip6_fn, recv_arg) -#define raw_sendto_ip6(pcb, pbuf, ip6addr) raw_sendto(pcb, pbuf, ip6_2_ip(ip6addr)) -#endif /* LWIP_IPV6 */ - -/* The following functions are the lower layer interface to RAW. */ -u8_t raw_input (struct pbuf *p, struct netif *inp); -#define raw_init() /* Compatibility define, not init needed. */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_RAW */ - -#endif /* __LWIP_RAW_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/sio.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/sio.h deleted file mode 100644 index 28ae2f22..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/sio.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - */ - -/* - * This is the interface to the platform specific serial IO module - * It needs to be implemented by those platforms which need SLIP or PPP - */ - -#ifndef __SIO_H__ -#define __SIO_H__ - -#include "lwip/arch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* If you want to define sio_fd_t elsewhere or differently, - define this in your cc.h file. */ -#ifndef __sio_fd_t_defined -typedef void * sio_fd_t; -#endif - -/* The following functions can be defined to something else in your cc.h file - or be implemented in your custom sio.c file. */ - -#ifndef sio_open -/** - * Opens a serial device for communication. - * - * @param devnum device number - * @return handle to serial device if successful, NULL otherwise - */ -sio_fd_t sio_open(u8_t devnum); -#endif - -#ifndef sio_send -/** - * Sends a single character to the serial device. - * - * @param c character to send - * @param fd serial device handle - * - * @note This function will block until the character can be sent. - */ -void sio_send(u8_t c, sio_fd_t fd); -#endif - -#ifndef sio_recv -/** - * Receives a single character from the serial device. - * - * @param fd serial device handle - * - * @note This function will block until a character is received. - */ -u8_t sio_recv(sio_fd_t fd); -#endif - -#ifndef sio_read -/** - * Reads from the serial device. - * - * @param fd serial device handle - * @param data pointer to data buffer for receiving - * @param len maximum length (in bytes) of data to receive - * @return number of bytes actually received - may be 0 if aborted by sio_read_abort - * - * @note This function will block until data can be received. The blocking - * can be cancelled by calling sio_read_abort(). - */ -u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len); -#endif - -#ifndef sio_tryread -/** - * Tries to read from the serial device. Same as sio_read but returns - * immediately if no data is available and never blocks. - * - * @param fd serial device handle - * @param data pointer to data buffer for receiving - * @param len maximum length (in bytes) of data to receive - * @return number of bytes actually received - */ -u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len); -#endif - -#ifndef sio_write -/** - * Writes to the serial device. - * - * @param fd serial device handle - * @param data pointer to data to send - * @param len length (in bytes) of data to send - * @return number of bytes actually sent - * - * @note This function will block until all data can be sent. - */ -u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len); -#endif - -#ifndef sio_read_abort -/** - * Aborts a blocking sio_read() call. - * - * @param fd serial device handle - */ -void sio_read_abort(sio_fd_t fd); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __SIO_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp.h deleted file mode 100644 index 2ed043dd..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp.h +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Copyright (c) 2001, 2002 Leon Woestenberg - * Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Leon Woestenberg - * - */ -#ifndef __LWIP_SNMP_H__ -#define __LWIP_SNMP_H__ - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#include "lwip/ip_addr.h" - -struct udp_pcb; -struct netif; - -/** - * @see RFC1213, "MIB-II, 6. Definitions" - */ -enum snmp_ifType { - snmp_ifType_other=1, /* none of the following */ - snmp_ifType_regular1822, - snmp_ifType_hdh1822, - snmp_ifType_ddn_x25, - snmp_ifType_rfc877_x25, - snmp_ifType_ethernet_csmacd, - snmp_ifType_iso88023_csmacd, - snmp_ifType_iso88024_tokenBus, - snmp_ifType_iso88025_tokenRing, - snmp_ifType_iso88026_man, - snmp_ifType_starLan, - snmp_ifType_proteon_10Mbit, - snmp_ifType_proteon_80Mbit, - snmp_ifType_hyperchannel, - snmp_ifType_fddi, - snmp_ifType_lapb, - snmp_ifType_sdlc, - snmp_ifType_ds1, /* T-1 */ - snmp_ifType_e1, /* european equiv. of T-1 */ - snmp_ifType_basicISDN, - snmp_ifType_primaryISDN, /* proprietary serial */ - snmp_ifType_propPointToPointSerial, - snmp_ifType_ppp, - snmp_ifType_softwareLoopback, - snmp_ifType_eon, /* CLNP over IP [11] */ - snmp_ifType_ethernet_3Mbit, - snmp_ifType_nsip, /* XNS over IP */ - snmp_ifType_slip, /* generic SLIP */ - snmp_ifType_ultra, /* ULTRA technologies */ - snmp_ifType_ds3, /* T-3 */ - snmp_ifType_sip, /* SMDS */ - snmp_ifType_frame_relay -}; - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -/** SNMP "sysuptime" Interval */ -#define SNMP_SYSUPTIME_INTERVAL 10 - -/** fixed maximum length for object identifier type */ -#define LWIP_SNMP_OBJ_ID_LEN 32 - -/** internal object identifier representation */ -struct snmp_obj_id -{ - u8_t len; - s32_t id[LWIP_SNMP_OBJ_ID_LEN]; -}; - -/* system */ -void snmp_set_sysdesr(u8_t* str, u8_t* len); -void snmp_set_sysobjid(struct snmp_obj_id *oid); -void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid); -void snmp_inc_sysuptime(void); -void snmp_add_sysuptime(u32_t value); -void snmp_get_sysuptime(u32_t *value); -void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen); -void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen); -void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen); - -/* network interface */ -void snmp_add_ifinoctets(struct netif *ni, u32_t value); -void snmp_inc_ifinucastpkts(struct netif *ni); -void snmp_inc_ifinnucastpkts(struct netif *ni); -void snmp_inc_ifindiscards(struct netif *ni); -void snmp_add_ifoutoctets(struct netif *ni, u32_t value); -void snmp_inc_ifoutucastpkts(struct netif *ni); -void snmp_inc_ifoutnucastpkts(struct netif *ni); -void snmp_inc_ifoutdiscards(struct netif *ni); -void snmp_inc_iflist(void); -void snmp_dec_iflist(void); - -/* ARP (for atTable and ipNetToMediaTable) */ -void snmp_insert_arpidx_tree(struct netif *ni, ip_addr_t *ip); -void snmp_delete_arpidx_tree(struct netif *ni, ip_addr_t *ip); - -/* IP */ -void snmp_inc_ipinreceives(void); -void snmp_inc_ipinhdrerrors(void); -void snmp_inc_ipinaddrerrors(void); -void snmp_inc_ipforwdatagrams(void); -void snmp_inc_ipinunknownprotos(void); -void snmp_inc_ipindiscards(void); -void snmp_inc_ipindelivers(void); -void snmp_inc_ipoutrequests(void); -void snmp_inc_ipoutdiscards(void); -void snmp_inc_ipoutnoroutes(void); -void snmp_inc_ipreasmreqds(void); -void snmp_inc_ipreasmoks(void); -void snmp_inc_ipreasmfails(void); -void snmp_inc_ipfragoks(void); -void snmp_inc_ipfragfails(void); -void snmp_inc_ipfragcreates(void); -void snmp_inc_iproutingdiscards(void); -void snmp_insert_ipaddridx_tree(struct netif *ni); -void snmp_delete_ipaddridx_tree(struct netif *ni); -void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni); -void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni); - -/* ICMP */ -void snmp_inc_icmpinmsgs(void); -void snmp_inc_icmpinerrors(void); -void snmp_inc_icmpindestunreachs(void); -void snmp_inc_icmpintimeexcds(void); -void snmp_inc_icmpinparmprobs(void); -void snmp_inc_icmpinsrcquenchs(void); -void snmp_inc_icmpinredirects(void); -void snmp_inc_icmpinechos(void); -void snmp_inc_icmpinechoreps(void); -void snmp_inc_icmpintimestamps(void); -void snmp_inc_icmpintimestampreps(void); -void snmp_inc_icmpinaddrmasks(void); -void snmp_inc_icmpinaddrmaskreps(void); -void snmp_inc_icmpoutmsgs(void); -void snmp_inc_icmpouterrors(void); -void snmp_inc_icmpoutdestunreachs(void); -void snmp_inc_icmpouttimeexcds(void); -void snmp_inc_icmpoutparmprobs(void); -void snmp_inc_icmpoutsrcquenchs(void); -void snmp_inc_icmpoutredirects(void); -void snmp_inc_icmpoutechos(void); -void snmp_inc_icmpoutechoreps(void); -void snmp_inc_icmpouttimestamps(void); -void snmp_inc_icmpouttimestampreps(void); -void snmp_inc_icmpoutaddrmasks(void); -void snmp_inc_icmpoutaddrmaskreps(void); - -/* TCP */ -void snmp_inc_tcpactiveopens(void); -void snmp_inc_tcppassiveopens(void); -void snmp_inc_tcpattemptfails(void); -void snmp_inc_tcpestabresets(void); -void snmp_inc_tcpinsegs(void); -void snmp_inc_tcpoutsegs(void); -void snmp_inc_tcpretranssegs(void); -void snmp_inc_tcpinerrs(void); -void snmp_inc_tcpoutrsts(void); - -/* UDP */ -void snmp_inc_udpindatagrams(void); -void snmp_inc_udpnoports(void); -void snmp_inc_udpinerrors(void); -void snmp_inc_udpoutdatagrams(void); -void snmp_insert_udpidx_tree(struct udp_pcb *pcb); -void snmp_delete_udpidx_tree(struct udp_pcb *pcb); - -/* SNMP */ -void snmp_inc_snmpinpkts(void); -void snmp_inc_snmpoutpkts(void); -void snmp_inc_snmpinbadversions(void); -void snmp_inc_snmpinbadcommunitynames(void); -void snmp_inc_snmpinbadcommunityuses(void); -void snmp_inc_snmpinasnparseerrs(void); -void snmp_inc_snmpintoobigs(void); -void snmp_inc_snmpinnosuchnames(void); -void snmp_inc_snmpinbadvalues(void); -void snmp_inc_snmpinreadonlys(void); -void snmp_inc_snmpingenerrs(void); -void snmp_add_snmpintotalreqvars(u8_t value); -void snmp_add_snmpintotalsetvars(u8_t value); -void snmp_inc_snmpingetrequests(void); -void snmp_inc_snmpingetnexts(void); -void snmp_inc_snmpinsetrequests(void); -void snmp_inc_snmpingetresponses(void); -void snmp_inc_snmpintraps(void); -void snmp_inc_snmpouttoobigs(void); -void snmp_inc_snmpoutnosuchnames(void); -void snmp_inc_snmpoutbadvalues(void); -void snmp_inc_snmpoutgenerrs(void); -void snmp_inc_snmpoutgetrequests(void); -void snmp_inc_snmpoutgetnexts(void); -void snmp_inc_snmpoutsetrequests(void); -void snmp_inc_snmpoutgetresponses(void); -void snmp_inc_snmpouttraps(void); -void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid); -void snmp_set_snmpenableauthentraps(u8_t *value); -void snmp_get_snmpenableauthentraps(u8_t *value); - -/* LWIP_SNMP support not available */ -/* define everything to be empty */ -#else - -/* system */ -#define snmp_set_sysdesr(str, len) -#define snmp_set_sysobjid(oid); -#define snmp_get_sysobjid_ptr(oid) -#define snmp_inc_sysuptime() -#define snmp_add_sysuptime(value) -#define snmp_get_sysuptime(value) -#define snmp_set_syscontact(ocstr, ocstrlen); -#define snmp_set_sysname(ocstr, ocstrlen); -#define snmp_set_syslocation(ocstr, ocstrlen); - -/* network interface */ -#define snmp_add_ifinoctets(ni,value) -#define snmp_inc_ifinucastpkts(ni) -#define snmp_inc_ifinnucastpkts(ni) -#define snmp_inc_ifindiscards(ni) -#define snmp_add_ifoutoctets(ni,value) -#define snmp_inc_ifoutucastpkts(ni) -#define snmp_inc_ifoutnucastpkts(ni) -#define snmp_inc_ifoutdiscards(ni) -#define snmp_inc_iflist() -#define snmp_dec_iflist() - -/* ARP */ -#define snmp_insert_arpidx_tree(ni,ip) -#define snmp_delete_arpidx_tree(ni,ip) - -/* IP */ -#define snmp_inc_ipinreceives() -#define snmp_inc_ipinhdrerrors() -#define snmp_inc_ipinaddrerrors() -#define snmp_inc_ipforwdatagrams() -#define snmp_inc_ipinunknownprotos() -#define snmp_inc_ipindiscards() -#define snmp_inc_ipindelivers() -#define snmp_inc_ipoutrequests() -#define snmp_inc_ipoutdiscards() -#define snmp_inc_ipoutnoroutes() -#define snmp_inc_ipreasmreqds() -#define snmp_inc_ipreasmoks() -#define snmp_inc_ipreasmfails() -#define snmp_inc_ipfragoks() -#define snmp_inc_ipfragfails() -#define snmp_inc_ipfragcreates() -#define snmp_inc_iproutingdiscards() -#define snmp_insert_ipaddridx_tree(ni) -#define snmp_delete_ipaddridx_tree(ni) -#define snmp_insert_iprteidx_tree(dflt, ni) -#define snmp_delete_iprteidx_tree(dflt, ni) - -/* ICMP */ -#define snmp_inc_icmpinmsgs() -#define snmp_inc_icmpinerrors() -#define snmp_inc_icmpindestunreachs() -#define snmp_inc_icmpintimeexcds() -#define snmp_inc_icmpinparmprobs() -#define snmp_inc_icmpinsrcquenchs() -#define snmp_inc_icmpinredirects() -#define snmp_inc_icmpinechos() -#define snmp_inc_icmpinechoreps() -#define snmp_inc_icmpintimestamps() -#define snmp_inc_icmpintimestampreps() -#define snmp_inc_icmpinaddrmasks() -#define snmp_inc_icmpinaddrmaskreps() -#define snmp_inc_icmpoutmsgs() -#define snmp_inc_icmpouterrors() -#define snmp_inc_icmpoutdestunreachs() -#define snmp_inc_icmpouttimeexcds() -#define snmp_inc_icmpoutparmprobs() -#define snmp_inc_icmpoutsrcquenchs() -#define snmp_inc_icmpoutredirects() -#define snmp_inc_icmpoutechos() -#define snmp_inc_icmpoutechoreps() -#define snmp_inc_icmpouttimestamps() -#define snmp_inc_icmpouttimestampreps() -#define snmp_inc_icmpoutaddrmasks() -#define snmp_inc_icmpoutaddrmaskreps() -/* TCP */ -#define snmp_inc_tcpactiveopens() -#define snmp_inc_tcppassiveopens() -#define snmp_inc_tcpattemptfails() -#define snmp_inc_tcpestabresets() -#define snmp_inc_tcpinsegs() -#define snmp_inc_tcpoutsegs() -#define snmp_inc_tcpretranssegs() -#define snmp_inc_tcpinerrs() -#define snmp_inc_tcpoutrsts() - -/* UDP */ -#define snmp_inc_udpindatagrams() -#define snmp_inc_udpnoports() -#define snmp_inc_udpinerrors() -#define snmp_inc_udpoutdatagrams() -#define snmp_insert_udpidx_tree(pcb) -#define snmp_delete_udpidx_tree(pcb) - -/* SNMP */ -#define snmp_inc_snmpinpkts() -#define snmp_inc_snmpoutpkts() -#define snmp_inc_snmpinbadversions() -#define snmp_inc_snmpinbadcommunitynames() -#define snmp_inc_snmpinbadcommunityuses() -#define snmp_inc_snmpinasnparseerrs() -#define snmp_inc_snmpintoobigs() -#define snmp_inc_snmpinnosuchnames() -#define snmp_inc_snmpinbadvalues() -#define snmp_inc_snmpinreadonlys() -#define snmp_inc_snmpingenerrs() -#define snmp_add_snmpintotalreqvars(value) -#define snmp_add_snmpintotalsetvars(value) -#define snmp_inc_snmpingetrequests() -#define snmp_inc_snmpingetnexts() -#define snmp_inc_snmpinsetrequests() -#define snmp_inc_snmpingetresponses() -#define snmp_inc_snmpintraps() -#define snmp_inc_snmpouttoobigs() -#define snmp_inc_snmpoutnosuchnames() -#define snmp_inc_snmpoutbadvalues() -#define snmp_inc_snmpoutgenerrs() -#define snmp_inc_snmpoutgetrequests() -#define snmp_inc_snmpoutgetnexts() -#define snmp_inc_snmpoutsetrequests() -#define snmp_inc_snmpoutgetresponses() -#define snmp_inc_snmpouttraps() -#define snmp_get_snmpgrpid_ptr(oid) -#define snmp_set_snmpenableauthentraps(value) -#define snmp_get_snmpenableauthentraps(value) - -#endif /* LWIP_SNMP */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_SNMP_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp_asn1.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp_asn1.h deleted file mode 100644 index 605fa3f1..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp_asn1.h +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file - * Abstract Syntax Notation One (ISO 8824, 8825) codec. - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#ifndef __LWIP_SNMP_ASN1_H__ -#define __LWIP_SNMP_ASN1_H__ - -#include "lwip/opt.h" -#include "lwip/err.h" -#include "lwip/pbuf.h" -#include "lwip/snmp.h" - -#if LWIP_SNMP - -#ifdef __cplusplus -extern "C" { -#endif - -#define SNMP_ASN1_UNIV (0) /* (!0x80 | !0x40) */ -#define SNMP_ASN1_APPLIC (0x40) /* (!0x80 | 0x40) */ -#define SNMP_ASN1_CONTXT (0x80) /* ( 0x80 | !0x40) */ - -#define SNMP_ASN1_CONSTR (0x20) /* ( 0x20) */ -#define SNMP_ASN1_PRIMIT (0) /* (!0x20) */ - -/* universal tags */ -#define SNMP_ASN1_INTEG 2 -#define SNMP_ASN1_OC_STR 4 -#define SNMP_ASN1_NUL 5 -#define SNMP_ASN1_OBJ_ID 6 -#define SNMP_ASN1_SEQ 16 - -/* application specific (SNMP) tags */ -#define SNMP_ASN1_IPADDR 0 /* octet string size(4) */ -#define SNMP_ASN1_COUNTER 1 /* u32_t */ -#define SNMP_ASN1_GAUGE 2 /* u32_t */ -#define SNMP_ASN1_TIMETICKS 3 /* u32_t */ -#define SNMP_ASN1_OPAQUE 4 /* octet string */ - -/* context specific (SNMP) tags */ -#define SNMP_ASN1_PDU_GET_REQ 0 -#define SNMP_ASN1_PDU_GET_NEXT_REQ 1 -#define SNMP_ASN1_PDU_GET_RESP 2 -#define SNMP_ASN1_PDU_SET_REQ 3 -#define SNMP_ASN1_PDU_TRAP 4 - -err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type); -err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length); -err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value); -err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value); -err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid); -err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw); - -void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed); -void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed); -void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed); -void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed); -err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type); -err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length); -err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value); -err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value); -err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident); -err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_SNMP */ - -#endif /* __LWIP_SNMP_ASN1_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp_msg.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp_msg.h deleted file mode 100644 index 1183e3a9..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp_msg.h +++ /dev/null @@ -1,315 +0,0 @@ -/** - * @file - * SNMP Agent message handling structures. - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#ifndef __LWIP_SNMP_MSG_H__ -#define __LWIP_SNMP_MSG_H__ - -#include "lwip/opt.h" -#include "lwip/snmp.h" -#include "lwip/snmp_structs.h" -#include "lwip/ip_addr.h" -#include "lwip/err.h" - -#if LWIP_SNMP - -#if SNMP_PRIVATE_MIB -/* When using a private MIB, you have to create a file 'private_mib.h' that contains - * a 'struct mib_array_node mib_private' which contains your MIB. */ -#include "private_mib.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* The listen port of the SNMP agent. Clients have to make their requests to - this port. Most standard clients won't work if you change this! */ -#ifndef SNMP_IN_PORT -#define SNMP_IN_PORT 161 -#endif -/* The remote port the SNMP agent sends traps to. Most standard trap sinks won't - work if you change this! */ -#ifndef SNMP_TRAP_PORT -#define SNMP_TRAP_PORT 162 -#endif - -#define SNMP_ES_NOERROR 0 -#define SNMP_ES_TOOBIG 1 -#define SNMP_ES_NOSUCHNAME 2 -#define SNMP_ES_BADVALUE 3 -#define SNMP_ES_READONLY 4 -#define SNMP_ES_GENERROR 5 - -#define SNMP_GENTRAP_COLDSTART 0 -#define SNMP_GENTRAP_WARMSTART 1 -#define SNMP_GENTRAP_AUTHFAIL 4 -#define SNMP_GENTRAP_ENTERPRISESPC 6 - -struct snmp_varbind -{ - /* next pointer, NULL for last in list */ - struct snmp_varbind *next; - /* previous pointer, NULL for first in list */ - struct snmp_varbind *prev; - - /* object identifier length (in s32_t) */ - u8_t ident_len; - /* object identifier array */ - s32_t *ident; - - /* object value ASN1 type */ - u8_t value_type; - /* object value length (in u8_t) */ - u8_t value_len; - /* object value */ - void *value; - - /* encoding varbind seq length length */ - u8_t seqlenlen; - /* encoding object identifier length length */ - u8_t olenlen; - /* encoding object value length length */ - u8_t vlenlen; - /* encoding varbind seq length */ - u16_t seqlen; - /* encoding object identifier length */ - u16_t olen; - /* encoding object value length */ - u16_t vlen; -}; - -struct snmp_varbind_root -{ - struct snmp_varbind *head; - struct snmp_varbind *tail; - /* number of variable bindings in list */ - u8_t count; - /* encoding varbind-list seq length length */ - u8_t seqlenlen; - /* encoding varbind-list seq length */ - u16_t seqlen; -}; - -/** output response message header length fields */ -struct snmp_resp_header_lengths -{ - /* encoding error-index length length */ - u8_t erridxlenlen; - /* encoding error-status length length */ - u8_t errstatlenlen; - /* encoding request id length length */ - u8_t ridlenlen; - /* encoding pdu length length */ - u8_t pdulenlen; - /* encoding community length length */ - u8_t comlenlen; - /* encoding version length length */ - u8_t verlenlen; - /* encoding sequence length length */ - u8_t seqlenlen; - - /* encoding error-index length */ - u16_t erridxlen; - /* encoding error-status length */ - u16_t errstatlen; - /* encoding request id length */ - u16_t ridlen; - /* encoding pdu length */ - u16_t pdulen; - /* encoding community length */ - u16_t comlen; - /* encoding version length */ - u16_t verlen; - /* encoding sequence length */ - u16_t seqlen; -}; - -/** output response message header length fields */ -struct snmp_trap_header_lengths -{ - /* encoding timestamp length length */ - u8_t tslenlen; - /* encoding specific-trap length length */ - u8_t strplenlen; - /* encoding generic-trap length length */ - u8_t gtrplenlen; - /* encoding agent-addr length length */ - u8_t aaddrlenlen; - /* encoding enterprise-id length length */ - u8_t eidlenlen; - /* encoding pdu length length */ - u8_t pdulenlen; - /* encoding community length length */ - u8_t comlenlen; - /* encoding version length length */ - u8_t verlenlen; - /* encoding sequence length length */ - u8_t seqlenlen; - - /* encoding timestamp length */ - u16_t tslen; - /* encoding specific-trap length */ - u16_t strplen; - /* encoding generic-trap length */ - u16_t gtrplen; - /* encoding agent-addr length */ - u16_t aaddrlen; - /* encoding enterprise-id length */ - u16_t eidlen; - /* encoding pdu length */ - u16_t pdulen; - /* encoding community length */ - u16_t comlen; - /* encoding version length */ - u16_t verlen; - /* encoding sequence length */ - u16_t seqlen; -}; - -/* Accepting new SNMP messages. */ -#define SNMP_MSG_EMPTY 0 -/* Search for matching object for variable binding. */ -#define SNMP_MSG_SEARCH_OBJ 1 -/* Perform SNMP operation on in-memory object. - Pass-through states, for symmetry only. */ -#define SNMP_MSG_INTERNAL_GET_OBJDEF 2 -#define SNMP_MSG_INTERNAL_GET_VALUE 3 -#define SNMP_MSG_INTERNAL_SET_TEST 4 -#define SNMP_MSG_INTERNAL_GET_OBJDEF_S 5 -#define SNMP_MSG_INTERNAL_SET_VALUE 6 -/* Perform SNMP operation on object located externally. - In theory this could be used for building a proxy agent. - Practical use is for an enterprise spc. app. gateway. */ -#define SNMP_MSG_EXTERNAL_GET_OBJDEF 7 -#define SNMP_MSG_EXTERNAL_GET_VALUE 8 -#define SNMP_MSG_EXTERNAL_SET_TEST 9 -#define SNMP_MSG_EXTERNAL_GET_OBJDEF_S 10 -#define SNMP_MSG_EXTERNAL_SET_VALUE 11 - -#define SNMP_COMMUNITY_STR_LEN 64 -struct snmp_msg_pstat -{ - /* lwIP local port (161) binding */ - struct udp_pcb *pcb; - /* source IP address */ - ip_addr_t sip; - /* source UDP port */ - u16_t sp; - /* request type */ - u8_t rt; - /* request ID */ - s32_t rid; - /* error status */ - s32_t error_status; - /* error index */ - s32_t error_index; - /* community name (zero terminated) */ - u8_t community[SNMP_COMMUNITY_STR_LEN + 1]; - /* community string length (exclusive zero term) */ - u8_t com_strlen; - /* one out of MSG_EMPTY, MSG_DEMUX, MSG_INTERNAL, MSG_EXTERNAL_x */ - u8_t state; - /* saved arguments for MSG_EXTERNAL_x */ - struct mib_external_node *ext_mib_node; - struct snmp_name_ptr ext_name_ptr; - struct obj_def ext_object_def; - struct snmp_obj_id ext_oid; - /* index into input variable binding list */ - u8_t vb_idx; - /* ptr into input variable binding list */ - struct snmp_varbind *vb_ptr; - /* list of variable bindings from input */ - struct snmp_varbind_root invb; - /* list of variable bindings to output */ - struct snmp_varbind_root outvb; - /* output response lengths used in ASN encoding */ - struct snmp_resp_header_lengths rhl; -}; - -struct snmp_msg_trap -{ - /* lwIP local port (161) binding */ - struct udp_pcb *pcb; - /* destination IP address in network order */ - ip_addr_t dip; - - /* source enterprise ID (sysObjectID) */ - struct snmp_obj_id *enterprise; - /* source IP address, raw network order format */ - u8_t sip_raw[4]; - /* generic trap code */ - u32_t gen_trap; - /* specific trap code */ - u32_t spc_trap; - /* timestamp */ - u32_t ts; - /* list of variable bindings to output */ - struct snmp_varbind_root outvb; - /* output trap lengths used in ASN encoding */ - struct snmp_trap_header_lengths thl; -}; - -/** Agent Version constant, 0 = v1 oddity */ -extern const s32_t snmp_version; -/** Agent default "public" community string */ -extern const char snmp_publiccommunity[7]; - -extern struct snmp_msg_trap trap_msg; - -/** Agent setup, start listening to port 161. */ -void snmp_init(void); -void snmp_trap_dst_enable(u8_t dst_idx, u8_t enable); -void snmp_trap_dst_ip_set(u8_t dst_idx, ip_addr_t *dst); - -/** Varbind-list functions. */ -struct snmp_varbind* snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u8_t len); -void snmp_varbind_free(struct snmp_varbind *vb); -void snmp_varbind_list_free(struct snmp_varbind_root *root); -void snmp_varbind_tail_add(struct snmp_varbind_root *root, struct snmp_varbind *vb); -struct snmp_varbind* snmp_varbind_tail_remove(struct snmp_varbind_root *root); - -/** Handle an internal (recv) or external (private response) event. */ -void snmp_msg_event(u8_t request_id); -err_t snmp_send_response(struct snmp_msg_pstat *m_stat); -err_t snmp_send_trap(s8_t generic_trap, struct snmp_obj_id *eoid, s32_t specific_trap); -void snmp_coldstart_trap(void); -void snmp_authfail_trap(void); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_SNMP */ - -#endif /* __LWIP_SNMP_MSG_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp_structs.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp_structs.h deleted file mode 100644 index 0d3b46a9..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/snmp_structs.h +++ /dev/null @@ -1,268 +0,0 @@ -/** - * @file - * Generic MIB tree structures. - * - * @todo namespace prefixes - */ - -/* - * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * Author: Christiaan Simons - */ - -#ifndef __LWIP_SNMP_STRUCTS_H__ -#define __LWIP_SNMP_STRUCTS_H__ - -#include "lwip/opt.h" - -#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/snmp.h" - -#if SNMP_PRIVATE_MIB -/* When using a private MIB, you have to create a file 'private_mib.h' that contains - * a 'struct mib_array_node mib_private' which contains your MIB. */ -#include "private_mib.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* MIB object instance */ -#define MIB_OBJECT_NONE 0 -#define MIB_OBJECT_SCALAR 1 -#define MIB_OBJECT_TAB 2 - -/* MIB access types */ -#define MIB_ACCESS_READ 1 -#define MIB_ACCESS_WRITE 2 - -/* MIB object access */ -#define MIB_OBJECT_READ_ONLY MIB_ACCESS_READ -#define MIB_OBJECT_READ_WRITE (MIB_ACCESS_READ | MIB_ACCESS_WRITE) -#define MIB_OBJECT_WRITE_ONLY MIB_ACCESS_WRITE -#define MIB_OBJECT_NOT_ACCESSIBLE 0 - -/** object definition returned by (get_object_def)() */ -struct obj_def -{ - /* MIB_OBJECT_NONE (0), MIB_OBJECT_SCALAR (1), MIB_OBJECT_TAB (2) */ - u8_t instance; - /* 0 read-only, 1 read-write, 2 write-only, 3 not-accessible */ - u8_t access; - /* ASN type for this object */ - u8_t asn_type; - /* value length (host length) */ - u16_t v_len; - /* length of instance part of supplied object identifier */ - u8_t id_inst_len; - /* instance part of supplied object identifier */ - s32_t *id_inst_ptr; -}; - -struct snmp_name_ptr -{ - u8_t ident_len; - s32_t *ident; -}; - -/** MIB const scalar (.0) node */ -#define MIB_NODE_SC 0x01 -/** MIB const array node */ -#define MIB_NODE_AR 0x02 -/** MIB array node (mem_malloced from RAM) */ -#define MIB_NODE_RA 0x03 -/** MIB list root node (mem_malloced from RAM) */ -#define MIB_NODE_LR 0x04 -/** MIB node for external objects */ -#define MIB_NODE_EX 0x05 - -/** node "base class" layout, the mandatory fields for a node */ -struct mib_node -{ - /** returns struct obj_def for the given object identifier */ - void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); - /** returns object value for the given object identifier, - @note the caller must allocate at least len bytes for the value */ - void (*get_value)(struct obj_def *od, u16_t len, void *value); - /** tests length and/or range BEFORE setting */ - u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); - /** sets object value, only to be called when set_test() */ - void (*set_value)(struct obj_def *od, u16_t len, void *value); - /** One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX */ - u8_t node_type; - /* array or max list length */ - u16_t maxlength; -}; - -/** derived node for scalars .0 index */ -typedef struct mib_node mib_scalar_node; - -/** derived node, points to a fixed size const array - of sub-identifiers plus a 'child' pointer */ -struct mib_array_node -{ - /* inherited "base class" members */ - void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); - void (*get_value)(struct obj_def *od, u16_t len, void *value); - u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); - void (*set_value)(struct obj_def *od, u16_t len, void *value); - - u8_t node_type; - u16_t maxlength; - - /* additional struct members */ - const s32_t *objid; - struct mib_node* const *nptr; -}; - -/** derived node, points to a fixed size mem_malloced array - of sub-identifiers plus a 'child' pointer */ -struct mib_ram_array_node -{ - /* inherited "base class" members */ - void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); - void (*get_value)(struct obj_def *od, u16_t len, void *value); - u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); - void (*set_value)(struct obj_def *od, u16_t len, void *value); - - u8_t node_type; - u16_t maxlength; - - /* aditional struct members */ - s32_t *objid; - struct mib_node **nptr; -}; - -struct mib_list_node -{ - struct mib_list_node *prev; - struct mib_list_node *next; - s32_t objid; - struct mib_node *nptr; -}; - -/** derived node, points to a doubly linked list - of sub-identifiers plus a 'child' pointer */ -struct mib_list_rootnode -{ - /* inherited "base class" members */ - void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); - void (*get_value)(struct obj_def *od, u16_t len, void *value); - u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); - void (*set_value)(struct obj_def *od, u16_t len, void *value); - - u8_t node_type; - u16_t maxlength; - - /* additional struct members */ - struct mib_list_node *head; - struct mib_list_node *tail; - /* counts list nodes in list */ - u16_t count; -}; - -/** derived node, has access functions for mib object in external memory or device - using 'tree_level' and 'idx', with a range 0 .. (level_length() - 1) */ -struct mib_external_node -{ - /* inherited "base class" members */ - void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od); - void (*get_value)(struct obj_def *od, u16_t len, void *value); - u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); - void (*set_value)(struct obj_def *od, u16_t len, void *value); - - u8_t node_type; - u16_t maxlength; - - /* additional struct members */ - /** points to an external (in memory) record of some sort of addressing - information, passed to and interpreted by the funtions below */ - void* addr_inf; - /** tree levels under this node */ - u8_t tree_levels; - /** number of objects at this level */ - u16_t (*level_length)(void* addr_inf, u8_t level); - /** compares object sub identifier with external id - return zero when equal, nonzero when unequal */ - s32_t (*ident_cmp)(void* addr_inf, u8_t level, u16_t idx, s32_t sub_id); - void (*get_objid)(void* addr_inf, u8_t level, u16_t idx, s32_t *sub_id); - - /** async Questions */ - void (*get_object_def_q)(void* addr_inf, u8_t rid, u8_t ident_len, s32_t *ident); - void (*get_value_q)(u8_t rid, struct obj_def *od); - void (*set_test_q)(u8_t rid, struct obj_def *od); - void (*set_value_q)(u8_t rid, struct obj_def *od, u16_t len, void *value); - /** async Answers */ - void (*get_object_def_a)(u8_t rid, u8_t ident_len, s32_t *ident, struct obj_def *od); - void (*get_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); - u8_t (*set_test_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); - void (*set_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); - /** async Panic Close (agent returns error reply, - e.g. used for external transaction cleanup) */ - void (*get_object_def_pc)(u8_t rid, u8_t ident_len, s32_t *ident); - void (*get_value_pc)(u8_t rid, struct obj_def *od); - void (*set_test_pc)(u8_t rid, struct obj_def *od); - void (*set_value_pc)(u8_t rid, struct obj_def *od); -}; - -/** export MIB tree from mib2.c */ -extern const struct mib_array_node internet; - -/** dummy function pointers for non-leaf MIB nodes from mib2.c */ -void noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od); -void noleafs_get_value(struct obj_def *od, u16_t len, void *value); -u8_t noleafs_set_test(struct obj_def *od, u16_t len, void *value); -void noleafs_set_value(struct obj_def *od, u16_t len, void *value); - -void snmp_oidtoip(s32_t *ident, ip_addr_t *ip); -void snmp_iptooid(ip_addr_t *ip, s32_t *ident); -void snmp_ifindextonetif(s32_t ifindex, struct netif **netif); -void snmp_netiftoifindex(struct netif *netif, s32_t *ifidx); - -struct mib_list_node* snmp_mib_ln_alloc(s32_t id); -void snmp_mib_ln_free(struct mib_list_node *ln); -struct mib_list_rootnode* snmp_mib_lrn_alloc(void); -void snmp_mib_lrn_free(struct mib_list_rootnode *lrn); - -s8_t snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **insn); -s8_t snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn); -struct mib_list_rootnode *snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n); - -struct mib_node* snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_name_ptr *np); -struct mib_node* snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret); -u8_t snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident); -u8_t snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret); - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_SNMP */ - -#endif /* __LWIP_SNMP_STRUCTS_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/sockets.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/sockets.h deleted file mode 100644 index 73461374..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/sockets.h +++ /dev/null @@ -1,411 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - - -#ifndef __LWIP_SOCKETS_H__ -#define __LWIP_SOCKETS_H__ - -#include "lwip/opt.h" - -#if LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ - -#include /* for size_t */ - -#include "lwip/ip_addr.h" -#include "lwip/inet.h" -#include "lwip/inet6.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* members are in network byte order */ -struct sockaddr_in { - u8_t sin_len; - u8_t sin_family; - u16_t sin_port; - struct in_addr sin_addr; -#define SIN_ZERO_LEN 8 - char sin_zero[SIN_ZERO_LEN]; -}; - -#if LWIP_IPV6 -struct sockaddr_in6 { - u8_t sin6_len; /* length of this structure */ - u8_t sin6_family; /* AF_INET6 */ - u16_t sin6_port; /* Transport layer port # */ - u32_t sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ -}; -#endif /* LWIP_IPV6 */ - -struct sockaddr { - u8_t sa_len; - u8_t sa_family; -#if LWIP_IPV6 - u8_t sa_data[22]; -#else /* LWIP_IPV6 */ - u8_t sa_data[14]; -#endif /* LWIP_IPV6 */ -}; - -/* If your port already typedef's socklen_t, define SOCKLEN_T_DEFINED - to prevent this code from redefining it. */ -#if !defined(socklen_t) && !defined(SOCKLEN_T_DEFINED) -typedef u32_t socklen_t; -#endif - -/* Socket protocol types (TCP/UDP/RAW) */ -#define SOCK_STREAM 1 -#define SOCK_DGRAM 2 -#define SOCK_RAW 3 - -/* - * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c) - */ -#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */ -#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ -#define SO_REUSEADDR 0x0004 /* Allow local address reuse */ -#define SO_KEEPALIVE 0x0008 /* keep connections alive */ -#define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */ -#define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ -#define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */ -#define SO_LINGER 0x0080 /* linger on close if data present */ -#define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */ -#define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */ - -#define SO_DONTLINGER ((int)(~SO_LINGER)) - -/* - * Additional options, not kept in so_options. - */ -#define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */ -#define SO_RCVBUF 0x1002 /* receive buffer size */ -#define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */ -#define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */ -#define SO_SNDTIMEO 0x1005 /* Unimplemented: send timeout */ -#define SO_RCVTIMEO 0x1006 /* receive timeout */ -#define SO_ERROR 0x1007 /* get error status and clear */ -#define SO_TYPE 0x1008 /* get socket type */ -#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */ -#define SO_NO_CHECK 0x100a /* don't create UDP checksum */ - - -/* - * Structure used for manipulating linger option. - */ -struct linger { - int l_onoff; /* option on/off */ - int l_linger; /* linger time */ -}; - -/* - * Level number for (get/set)sockopt() to apply to socket itself. - */ -#define SOL_SOCKET 0xfff /* options for socket level */ - - -#define AF_UNSPEC 0 -#define AF_INET 2 -#if LWIP_IPV6 -#define AF_INET6 10 -#else /* LWIP_IPV6 */ -#define AF_INET6 AF_UNSPEC -#endif /* LWIP_IPV6 */ -#define PF_INET AF_INET -#define PF_INET6 AF_INET6 -#define PF_UNSPEC AF_UNSPEC - -#define IPPROTO_IP 0 -#define IPPROTO_TCP 6 -#define IPPROTO_UDP 17 -#if LWIP_IPV6 -#define IPPROTO_IPV6 41 -#endif /* LWIP_IPV6 */ -#define IPPROTO_UDPLITE 136 - -/* Flags we can use with send and recv. */ -#define MSG_PEEK 0x01 /* Peeks at an incoming message */ -#define MSG_WAITALL 0x02 /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */ -#define MSG_OOB 0x04 /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */ -#define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */ -#define MSG_MORE 0x10 /* Sender will send more */ - - -/* - * Options for level IPPROTO_IP - */ -#define IP_TOS 1 -#define IP_TTL 2 - -#if LWIP_TCP -/* - * Options for level IPPROTO_TCP - */ -#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ -#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */ -#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */ -#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */ -#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */ -#endif /* LWIP_TCP */ - -#if LWIP_IPV6 -/* - * Options for level IPPROTO_IPV6 - */ -#define IPV6_V6ONLY 27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */ -#endif /* LWIP_IPV6 */ - -#if LWIP_UDP && LWIP_UDPLITE -/* - * Options for level IPPROTO_UDPLITE - */ -#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */ -#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */ -#endif /* LWIP_UDP && LWIP_UDPLITE*/ - - -#if LWIP_IGMP -/* - * Options and types for UDP multicast traffic handling - */ -#define IP_ADD_MEMBERSHIP 3 -#define IP_DROP_MEMBERSHIP 4 -#define IP_MULTICAST_TTL 5 -#define IP_MULTICAST_IF 6 -#define IP_MULTICAST_LOOP 7 - -typedef struct ip_mreq { - struct in_addr imr_multiaddr; /* IP multicast address of group */ - struct in_addr imr_interface; /* local IP address of interface */ -} ip_mreq; -#endif /* LWIP_IGMP */ - -/* - * The Type of Service provides an indication of the abstract - * parameters of the quality of service desired. These parameters are - * to be used to guide the selection of the actual service parameters - * when transmitting a datagram through a particular network. Several - * networks offer service precedence, which somehow treats high - * precedence traffic as more important than other traffic (generally - * by accepting only traffic above a certain precedence at time of high - * load). The major choice is a three way tradeoff between low-delay, - * high-reliability, and high-throughput. - * The use of the Delay, Throughput, and Reliability indications may - * increase the cost (in some sense) of the service. In many networks - * better performance for one of these parameters is coupled with worse - * performance on another. Except for very unusual cases at most two - * of these three indications should be set. - */ -#define IPTOS_TOS_MASK 0x1E -#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK) -#define IPTOS_LOWDELAY 0x10 -#define IPTOS_THROUGHPUT 0x08 -#define IPTOS_RELIABILITY 0x04 -#define IPTOS_LOWCOST 0x02 -#define IPTOS_MINCOST IPTOS_LOWCOST - -/* - * The Network Control precedence designation is intended to be used - * within a network only. The actual use and control of that - * designation is up to each network. The Internetwork Control - * designation is intended for use by gateway control originators only. - * If the actual use of these precedence designations is of concern to - * a particular network, it is the responsibility of that network to - * control the access to, and use of, those precedence designations. - */ -#define IPTOS_PREC_MASK 0xe0 -#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK) -#define IPTOS_PREC_NETCONTROL 0xe0 -#define IPTOS_PREC_INTERNETCONTROL 0xc0 -#define IPTOS_PREC_CRITIC_ECP 0xa0 -#define IPTOS_PREC_FLASHOVERRIDE 0x80 -#define IPTOS_PREC_FLASH 0x60 -#define IPTOS_PREC_IMMEDIATE 0x40 -#define IPTOS_PREC_PRIORITY 0x20 -#define IPTOS_PREC_ROUTINE 0x00 - - -/* - * Commands for ioctlsocket(), taken from the BSD file fcntl.h. - * lwip_ioctl only supports FIONREAD and FIONBIO, for now - * - * Ioctl's have the command encoded in the lower word, - * and the size of any in or out parameters in the upper - * word. The high 2 bits of the upper word are used - * to encode the in/out status of the parameter; for now - * we restrict parameters to at most 128 bytes. - */ -#if !defined(FIONREAD) || !defined(FIONBIO) -#define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */ -#define IOC_VOID 0x20000000UL /* no parameters */ -#define IOC_OUT 0x40000000UL /* copy out parameters */ -#define IOC_IN 0x80000000UL /* copy in parameters */ -#define IOC_INOUT (IOC_IN|IOC_OUT) - /* 0x20000000 distinguishes new & - old ioctl's */ -#define _IO(x,y) (IOC_VOID|((x)<<8)|(y)) - -#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) - -#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) -#endif /* !defined(FIONREAD) || !defined(FIONBIO) */ - -#ifndef FIONREAD -#define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */ -#endif -#ifndef FIONBIO -#define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */ -#endif - -/* Socket I/O Controls: unimplemented */ -#ifndef SIOCSHIWAT -#define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */ -#define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */ -#define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */ -#define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */ -#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */ -#endif - -/* commands for fnctl */ -#ifndef F_GETFL -#define F_GETFL 3 -#endif -#ifndef F_SETFL -#define F_SETFL 4 -#endif - -/* File status flags and file access modes for fnctl, - these are bits in an int. */ -#ifndef O_NONBLOCK -#define O_NONBLOCK 1 /* nonblocking I/O */ -#endif -#ifndef O_NDELAY -#define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */ -#endif - -#ifndef SHUT_RD - #define SHUT_RD 0 - #define SHUT_WR 1 - #define SHUT_RDWR 2 -#endif - -/* FD_SET used for lwip_select */ -#ifndef FD_SET - #undef FD_SETSIZE - /* Make FD_SETSIZE match NUM_SOCKETS in socket.c */ - #define FD_SETSIZE MEMP_NUM_NETCONN - #define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7))) - #define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7))) - #define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7))) - #define FD_ZERO(p) memset((void*)(p),0,sizeof(*(p))) - - typedef struct fd_set { - unsigned char fd_bits [(FD_SETSIZE+7)/8]; - } fd_set; - -#endif /* FD_SET */ - -/** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided - * by your system, set this to 0 and include in cc.h */ -#ifndef LWIP_TIMEVAL_PRIVATE -#define LWIP_TIMEVAL_PRIVATE 1 -#endif - -#if LWIP_TIMEVAL_PRIVATE -struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* and microseconds */ -}; -#endif /* LWIP_TIMEVAL_PRIVATE */ - -void lwip_socket_init(void); - -int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen); -int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen); -int lwip_shutdown(int s, int how); -int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen); -int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen); -int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen); -int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen); -int lwip_close(int s); -int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen); -int lwip_listen(int s, int backlog); -int lwip_recv(int s, void *mem, size_t len, int flags); -int lwip_read(int s, void *mem, size_t len); -int lwip_recvfrom(int s, void *mem, size_t len, int flags, - struct sockaddr *from, socklen_t *fromlen); -int lwip_send(int s, const void *dataptr, size_t size, int flags); -int lwip_sendto(int s, const void *dataptr, size_t size, int flags, - const struct sockaddr *to, socklen_t tolen); -int lwip_socket(int domain, int type, int protocol); -int lwip_write(int s, const void *dataptr, size_t size); -int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, - struct timeval *timeout); -int lwip_ioctl(int s, long cmd, void *argp); -int lwip_fcntl(int s, int cmd, int val); - -#if LWIP_COMPAT_SOCKETS -#define accept(a,b,c) lwip_accept(a,b,c) -#define bind(a,b,c) lwip_bind(a,b,c) -#define shutdown(a,b) lwip_shutdown(a,b) -#define closesocket(s) lwip_close(s) -#define connect(a,b,c) lwip_connect(a,b,c) -#define getsockname(a,b,c) lwip_getsockname(a,b,c) -#define getpeername(a,b,c) lwip_getpeername(a,b,c) -#define setsockopt(a,b,c,d,e) lwip_setsockopt(a,b,c,d,e) -#define getsockopt(a,b,c,d,e) lwip_getsockopt(a,b,c,d,e) -#define listen(a,b) lwip_listen(a,b) -#define recv(a,b,c,d) lwip_recv(a,b,c,d) -#define recvfrom(a,b,c,d,e,f) lwip_recvfrom(a,b,c,d,e,f) -#define send(a,b,c,d) lwip_send(a,b,c,d) -#define sendto(a,b,c,d,e,f) lwip_sendto(a,b,c,d,e,f) -#define socket(a,b,c) lwip_socket(a,b,c) -#define select(a,b,c,d,e) lwip_select(a,b,c,d,e) -#define ioctlsocket(a,b,c) lwip_ioctl(a,b,c) - -#if LWIP_POSIX_SOCKETS_IO_NAMES -#define read(a,b,c) lwip_read(a,b,c) -#define write(a,b,c) lwip_write(a,b,c) -#define close(s) lwip_close(s) -#define fcntl(a,b,c) lwip_fcntl(a,b,c) -#endif /* LWIP_POSIX_SOCKETS_IO_NAMES */ - -#endif /* LWIP_COMPAT_SOCKETS */ - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_SOCKET */ - -#endif /* __LWIP_SOCKETS_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/stats.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/stats.h deleted file mode 100644 index d9112160..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/stats.h +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_STATS_H__ -#define __LWIP_STATS_H__ - -#include "lwip/opt.h" - -#include "lwip/mem.h" -#include "lwip/memp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if LWIP_STATS - -#ifndef LWIP_STATS_LARGE -#define LWIP_STATS_LARGE 0 -#endif - -#if LWIP_STATS_LARGE -#define STAT_COUNTER u32_t -#define STAT_COUNTER_F U32_F -#else -#define STAT_COUNTER u16_t -#define STAT_COUNTER_F U16_F -#endif - -struct stats_proto { - STAT_COUNTER xmit; /* Transmitted packets. */ - STAT_COUNTER recv; /* Received packets. */ - STAT_COUNTER fw; /* Forwarded packets. */ - STAT_COUNTER drop; /* Dropped packets. */ - STAT_COUNTER chkerr; /* Checksum error. */ - STAT_COUNTER lenerr; /* Invalid length error. */ - STAT_COUNTER memerr; /* Out of memory error. */ - STAT_COUNTER rterr; /* Routing error. */ - STAT_COUNTER proterr; /* Protocol error. */ - STAT_COUNTER opterr; /* Error in options. */ - STAT_COUNTER err; /* Misc error. */ - STAT_COUNTER cachehit; -}; - -struct stats_igmp { - STAT_COUNTER xmit; /* Transmitted packets. */ - STAT_COUNTER recv; /* Received packets. */ - STAT_COUNTER drop; /* Dropped packets. */ - STAT_COUNTER chkerr; /* Checksum error. */ - STAT_COUNTER lenerr; /* Invalid length error. */ - STAT_COUNTER memerr; /* Out of memory error. */ - STAT_COUNTER proterr; /* Protocol error. */ - STAT_COUNTER rx_v1; /* Received v1 frames. */ - STAT_COUNTER rx_group; /* Received group-specific queries. */ - STAT_COUNTER rx_general; /* Received general queries. */ - STAT_COUNTER rx_report; /* Received reports. */ - STAT_COUNTER tx_join; /* Sent joins. */ - STAT_COUNTER tx_leave; /* Sent leaves. */ - STAT_COUNTER tx_report; /* Sent reports. */ -}; - -struct stats_mem { -#ifdef LWIP_DEBUG - const char *name; -#endif /* LWIP_DEBUG */ - mem_size_t avail; - mem_size_t used; - mem_size_t max; - STAT_COUNTER err; - STAT_COUNTER illegal; -}; - -struct stats_syselem { - STAT_COUNTER used; - STAT_COUNTER max; - STAT_COUNTER err; -}; - -struct stats_sys { - struct stats_syselem sem; - struct stats_syselem mutex; - struct stats_syselem mbox; -}; - -struct stats_ { -#if LINK_STATS - struct stats_proto link; -#endif -#if ETHARP_STATS - struct stats_proto etharp; -#endif -#if IPFRAG_STATS - struct stats_proto ip_frag; -#endif -#if IP_STATS - struct stats_proto ip; -#endif -#if ICMP_STATS - struct stats_proto icmp; -#endif -#if IGMP_STATS - struct stats_igmp igmp; -#endif -#if UDP_STATS - struct stats_proto udp; -#endif -#if TCP_STATS - struct stats_proto tcp; -#endif -#if MEM_STATS - struct stats_mem mem; -#endif -#if MEMP_STATS - struct stats_mem memp[MEMP_MAX]; -#endif -#if SYS_STATS - struct stats_sys sys; -#endif -#if IP6_STATS - struct stats_proto ip6; -#endif -#if ICMP6_STATS - struct stats_proto icmp6; -#endif -#if IP6_FRAG_STATS - struct stats_proto ip6_frag; -#endif -#if MLD6_STATS - struct stats_igmp mld6; -#endif -#if ND6_STATS - struct stats_proto nd6; -#endif -}; - -extern struct stats_ lwip_stats; - -void stats_init(void); - -#define STATS_INC(x) ++lwip_stats.x -#define STATS_DEC(x) --lwip_stats.x -#define STATS_INC_USED(x, y) do { lwip_stats.x.used += y; \ - if (lwip_stats.x.max < lwip_stats.x.used) { \ - lwip_stats.x.max = lwip_stats.x.used; \ - } \ - } while(0) -#else /* LWIP_STATS */ -#define stats_init() -#define STATS_INC(x) -#define STATS_DEC(x) -#define STATS_INC_USED(x) -#endif /* LWIP_STATS */ - -#if TCP_STATS -#define TCP_STATS_INC(x) STATS_INC(x) -#define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP") -#else -#define TCP_STATS_INC(x) -#define TCP_STATS_DISPLAY() -#endif - -#if UDP_STATS -#define UDP_STATS_INC(x) STATS_INC(x) -#define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP") -#else -#define UDP_STATS_INC(x) -#define UDP_STATS_DISPLAY() -#endif - -#if ICMP_STATS -#define ICMP_STATS_INC(x) STATS_INC(x) -#define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP") -#else -#define ICMP_STATS_INC(x) -#define ICMP_STATS_DISPLAY() -#endif - -#if IGMP_STATS -#define IGMP_STATS_INC(x) STATS_INC(x) -#define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp, "IGMP") -#else -#define IGMP_STATS_INC(x) -#define IGMP_STATS_DISPLAY() -#endif - -#if IP_STATS -#define IP_STATS_INC(x) STATS_INC(x) -#define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP") -#else -#define IP_STATS_INC(x) -#define IP_STATS_DISPLAY() -#endif - -#if IPFRAG_STATS -#define IPFRAG_STATS_INC(x) STATS_INC(x) -#define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG") -#else -#define IPFRAG_STATS_INC(x) -#define IPFRAG_STATS_DISPLAY() -#endif - -#if ETHARP_STATS -#define ETHARP_STATS_INC(x) STATS_INC(x) -#define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP") -#else -#define ETHARP_STATS_INC(x) -#define ETHARP_STATS_DISPLAY() -#endif - -#if LINK_STATS -#define LINK_STATS_INC(x) STATS_INC(x) -#define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK") -#else -#define LINK_STATS_INC(x) -#define LINK_STATS_DISPLAY() -#endif - -#if MEM_STATS -#define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y -#define MEM_STATS_INC(x) STATS_INC(mem.x) -#define MEM_STATS_INC_USED(x, y) STATS_INC_USED(mem, y) -#define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y -#define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP") -#else -#define MEM_STATS_AVAIL(x, y) -#define MEM_STATS_INC(x) -#define MEM_STATS_INC_USED(x, y) -#define MEM_STATS_DEC_USED(x, y) -#define MEM_STATS_DISPLAY() -#endif - -#if MEMP_STATS -#define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y -#define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x) -#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x) -#define MEMP_STATS_INC_USED(x, i) STATS_INC_USED(memp[i], 1) -#define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i) -#else -#define MEMP_STATS_AVAIL(x, i, y) -#define MEMP_STATS_INC(x, i) -#define MEMP_STATS_DEC(x, i) -#define MEMP_STATS_INC_USED(x, i) -#define MEMP_STATS_DISPLAY(i) -#endif - -#if SYS_STATS -#define SYS_STATS_INC(x) STATS_INC(sys.x) -#define SYS_STATS_DEC(x) STATS_DEC(sys.x) -#define SYS_STATS_INC_USED(x) STATS_INC_USED(sys.x, 1) -#define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys) -#else -#define SYS_STATS_INC(x) -#define SYS_STATS_DEC(x) -#define SYS_STATS_INC_USED(x) -#define SYS_STATS_DISPLAY() -#endif - -#if IP6_STATS -#define IP6_STATS_INC(x) STATS_INC(x) -#define IP6_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip6, "IPv6") -#else -#define IP6_STATS_INC(x) -#define IP6_STATS_DISPLAY() -#endif - -#if ICMP6_STATS -#define ICMP6_STATS_INC(x) STATS_INC(x) -#define ICMP6_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp6, "ICMPv6") -#else -#define ICMP6_STATS_INC(x) -#define ICMP6_STATS_DISPLAY() -#endif - -#if IP6_FRAG_STATS -#define IP6_FRAG_STATS_INC(x) STATS_INC(x) -#define IP6_FRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip6_frag, "IPv6 FRAG") -#else -#define IP6_FRAG_STATS_INC(x) -#define IP6_FRAG_STATS_DISPLAY() -#endif - -#if MLD6_STATS -#define MLD6_STATS_INC(x) STATS_INC(x) -#define MLD6_STATS_DISPLAY() stats_display_igmp(&lwip_stats.mld6, "MLDv1") -#else -#define MLD6_STATS_INC(x) -#define MLD6_STATS_DISPLAY() -#endif - -#if ND6_STATS -#define ND6_STATS_INC(x) STATS_INC(x) -#define ND6_STATS_DISPLAY() stats_display_proto(&lwip_stats.nd6, "ND") -#else -#define ND6_STATS_INC(x) -#define ND6_STATS_DISPLAY() -#endif - -/* Display of statistics */ -#if LWIP_STATS_DISPLAY -void stats_display(void); -void stats_display_proto(struct stats_proto *proto, const char *name); -void stats_display_igmp(struct stats_igmp *igmp, const char *name); -void stats_display_mem(struct stats_mem *mem, const char *name); -void stats_display_memp(struct stats_mem *mem, int index); -void stats_display_sys(struct stats_sys *sys); -#else /* LWIP_STATS_DISPLAY */ -#define stats_display() -#define stats_display_proto(proto, name) -#define stats_display_igmp(igmp, name) -#define stats_display_mem(mem, name) -#define stats_display_memp(mem, index) -#define stats_display_sys(sys) -#endif /* LWIP_STATS_DISPLAY */ - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_STATS_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/sys.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/sys.h deleted file mode 100644 index fd45ee8a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/sys.h +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_SYS_H__ -#define __LWIP_SYS_H__ - -#include "lwip/opt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if NO_SYS - -/* For a totally minimal and standalone system, we provide null - definitions of the sys_ functions. */ -typedef u8_t sys_sem_t; -typedef u8_t sys_mutex_t; -typedef u8_t sys_mbox_t; - -#define sys_sem_new(s, c) ERR_OK -#define sys_sem_signal(s) -#define sys_sem_wait(s) -#define sys_arch_sem_wait(s,t) -#define sys_sem_free(s) -#define sys_sem_valid(s) 0 -#define sys_sem_set_invalid(s) -#define sys_mutex_new(mu) ERR_OK -#define sys_mutex_lock(mu) -#define sys_mutex_unlock(mu) -#define sys_mutex_free(mu) -#define sys_mutex_valid(mu) 0 -#define sys_mutex_set_invalid(mu) -#define sys_mbox_new(m, s) ERR_OK -#define sys_mbox_fetch(m,d) -#define sys_mbox_tryfetch(m,d) -#define sys_mbox_post(m,d) -#define sys_mbox_trypost(m,d) -#define sys_mbox_free(m) -#define sys_mbox_valid(m) -#define sys_mbox_set_invalid(m) - -#define sys_thread_new(n,t,a,s,p) - -#define sys_msleep(t) - -#else /* NO_SYS */ - -/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */ -#define SYS_ARCH_TIMEOUT 0xffffffffUL - -/** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate. - * For now we use the same magic value, but we allow this to change in future. - */ -#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT - -#include "lwip/err.h" -#include "arch/sys_arch.h" - -/** Function prototype for thread functions */ -typedef void (*lwip_thread_fn)(void *arg); - -/* Function prototypes for functions to be implemented by platform ports - (in sys_arch.c) */ - -/* Mutex functions: */ - -/** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores - should be used instead */ -#if LWIP_COMPAT_MUTEX -/* for old ports that don't have mutexes: define them to binary semaphores */ -#define sys_mutex_t sys_sem_t -#define sys_mutex_new(mutex) sys_sem_new(mutex, 1) -#define sys_mutex_lock(mutex) sys_sem_wait(mutex) -#define sys_mutex_unlock(mutex) sys_sem_signal(mutex) -#define sys_mutex_free(mutex) sys_sem_free(mutex) -#define sys_mutex_valid(mutex) sys_sem_valid(mutex) -#define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex) - -#else /* LWIP_COMPAT_MUTEX */ - -/** Create a new mutex - * @param mutex pointer to the mutex to create - * @return a new mutex */ -err_t sys_mutex_new(sys_mutex_t *mutex); -/** Lock a mutex - * @param mutex the mutex to lock */ -void sys_mutex_lock(sys_mutex_t *mutex); -/** Unlock a mutex - * @param mutex the mutex to unlock */ -void sys_mutex_unlock(sys_mutex_t *mutex); -/** Delete a semaphore - * @param mutex the mutex to delete */ -void sys_mutex_free(sys_mutex_t *mutex); -#ifndef sys_mutex_valid -/** Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid */ -int sys_mutex_valid(sys_mutex_t *mutex); -#endif -#ifndef sys_mutex_set_invalid -/** Set a mutex invalid so that sys_mutex_valid returns 0 */ -void sys_mutex_set_invalid(sys_mutex_t *mutex); -#endif -#endif /* LWIP_COMPAT_MUTEX */ - -/* Semaphore functions: */ - -/** Create a new semaphore - * @param sem pointer to the semaphore to create - * @param count initial count of the semaphore - * @return ERR_OK if successful, another err_t otherwise */ -err_t sys_sem_new(sys_sem_t *sem, u8_t count); -/** Signals a semaphore - * @param sem the semaphore to signal */ -void sys_sem_signal(sys_sem_t *sem); -/** Wait for a semaphore for the specified timeout - * @param sem the semaphore to wait for - * @param timeout timeout in milliseconds to wait (0 = wait forever) - * @return time (in milliseconds) waited for the semaphore - * or SYS_ARCH_TIMEOUT on timeout */ -u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout); -/** Delete a semaphore - * @param sem semaphore to delete */ -void sys_sem_free(sys_sem_t *sem); -/** Wait for a semaphore - forever/no timeout */ -#define sys_sem_wait(sem) sys_arch_sem_wait(sem, 0) -#ifndef sys_sem_valid -/** Check if a sempahore is valid/allocated: return 1 for valid, 0 for invalid */ -int sys_sem_valid(sys_sem_t *sem); -#endif -#ifndef sys_sem_set_invalid -/** Set a semaphore invalid so that sys_sem_valid returns 0 */ -void sys_sem_set_invalid(sys_sem_t *sem); -#endif - -/* Time functions. */ -#ifndef sys_msleep -void sys_msleep(u32_t ms); /* only has a (close to) 1 jiffy resolution. */ -#endif - -/* Mailbox functions. */ - -/** Create a new mbox of specified size - * @param mbox pointer to the mbox to create - * @param size (miminum) number of messages in this mbox - * @return ERR_OK if successful, another err_t otherwise */ -err_t sys_mbox_new(sys_mbox_t *mbox, int size); -/** Post a message to an mbox - may not fail - * -> blocks if full, only used from tasks not from ISR - * @param mbox mbox to posts the message - * @param msg message to post (ATTENTION: can be NULL) */ -void sys_mbox_post(sys_mbox_t *mbox, void *msg); -/** Try to post a message to an mbox - may fail if full or ISR - * @param mbox mbox to posts the message - * @param msg message to post (ATTENTION: can be NULL) */ -err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg); -/** Wait for a new message to arrive in the mbox - * @param mbox mbox to get a message from - * @param msg pointer where the message is stored - * @param timeout maximum time (in milliseconds) to wait for a message (0 = wait forever) - * @return time (in milliseconds) waited for a message, may be 0 if not waited - or SYS_ARCH_TIMEOUT on timeout - * The returned time has to be accurate to prevent timer jitter! */ -u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout); -/* Allow port to override with a macro, e.g. special timout for sys_arch_mbox_fetch() */ -#ifndef sys_arch_mbox_tryfetch -/** Wait for a new message to arrive in the mbox - * @param mbox mbox to get a message from - * @param msg pointer where the message is stored - * @return 0 (milliseconds) if a message has been received - * or SYS_MBOX_EMPTY if the mailbox is empty */ -u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg); -#endif -/** For now, we map straight to sys_arch implementation. */ -#define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg) -/** Delete an mbox - * @param mbox mbox to delete */ -void sys_mbox_free(sys_mbox_t *mbox); -#define sys_mbox_fetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 0) -#ifndef sys_mbox_valid -/** Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid */ -int sys_mbox_valid(sys_mbox_t *mbox); -#endif -#ifndef sys_mbox_set_invalid -/** Set an mbox invalid so that sys_mbox_valid returns 0 */ -void sys_mbox_set_invalid(sys_mbox_t *mbox); -#endif - -/** The only thread function: - * Creates a new thread - * @param name human-readable name for the thread (used for debugging purposes) - * @param thread thread-function - * @param arg parameter passed to 'thread' - * @param stacksize stack size in bytes for the new thread (may be ignored by ports) - * @param prio priority of the new thread (may be ignored by ports) */ -sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio); - -#endif /* NO_SYS */ - -/* sys_init() must be called before anthing else. */ -void sys_init(void); - -#ifndef sys_jiffies -/** Ticks/jiffies since power up. */ -u32_t sys_jiffies(void); -#endif - -/** Returns the current time in milliseconds, - * may be the same as sys_jiffies or at least based on it. */ -u32_t sys_now(void); - -/* Critical Region Protection */ -/* These functions must be implemented in the sys_arch.c file. - In some implementations they can provide a more light-weight protection - mechanism than using semaphores. Otherwise semaphores can be used for - implementation */ -#ifndef SYS_ARCH_PROTECT -/** SYS_LIGHTWEIGHT_PROT - * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection - * for certain critical regions during buffer allocation, deallocation and memory - * allocation and deallocation. - */ -#if SYS_LIGHTWEIGHT_PROT - -/** SYS_ARCH_DECL_PROTECT - * declare a protection variable. This macro will default to defining a variable of - * type sys_prot_t. If a particular port needs a different implementation, then - * this macro may be defined in sys_arch.h. - */ -#define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev -/** SYS_ARCH_PROTECT - * Perform a "fast" protect. This could be implemented by - * disabling interrupts for an embedded system or by using a semaphore or - * mutex. The implementation should allow calling SYS_ARCH_PROTECT when - * already protected. The old protection level is returned in the variable - * "lev". This macro will default to calling the sys_arch_protect() function - * which should be implemented in sys_arch.c. If a particular port needs a - * different implementation, then this macro may be defined in sys_arch.h - */ -#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect() -/** SYS_ARCH_UNPROTECT - * Perform a "fast" set of the protection level to "lev". This could be - * implemented by setting the interrupt level to "lev" within the MACRO or by - * using a semaphore or mutex. This macro will default to calling the - * sys_arch_unprotect() function which should be implemented in - * sys_arch.c. If a particular port needs a different implementation, then - * this macro may be defined in sys_arch.h - */ -#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev) -sys_prot_t sys_arch_protect(void); -void sys_arch_unprotect(sys_prot_t pval); - -#else - -#define SYS_ARCH_DECL_PROTECT(lev) -#define SYS_ARCH_PROTECT(lev) -#define SYS_ARCH_UNPROTECT(lev) - -#endif /* SYS_LIGHTWEIGHT_PROT */ - -#endif /* SYS_ARCH_PROTECT */ - -/* - * Macros to set/get and increase/decrease variables in a thread-safe way. - * Use these for accessing variable that are used from more than one thread. - */ - -#ifndef SYS_ARCH_INC -#define SYS_ARCH_INC(var, val) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - var += val; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_INC */ - -#ifndef SYS_ARCH_DEC -#define SYS_ARCH_DEC(var, val) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - var -= val; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_DEC */ - -#ifndef SYS_ARCH_GET -#define SYS_ARCH_GET(var, ret) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - ret = var; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_GET */ - -#ifndef SYS_ARCH_SET -#define SYS_ARCH_SET(var, val) do { \ - SYS_ARCH_DECL_PROTECT(old_level); \ - SYS_ARCH_PROTECT(old_level); \ - var = val; \ - SYS_ARCH_UNPROTECT(old_level); \ - } while(0) -#endif /* SYS_ARCH_SET */ - - -#ifdef __cplusplus -} -#endif - -#endif /* __LWIP_SYS_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/tcp.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/tcp.h deleted file mode 100644 index 535b6a38..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/tcp.h +++ /dev/null @@ -1,400 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_TCP_H__ -#define __LWIP_TCP_H__ - -#include "lwip/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/mem.h" -#include "lwip/pbuf.h" -#include "lwip/ip.h" -#include "lwip/icmp.h" -#include "lwip/err.h" -#include "lwip/ip6.h" -#include "lwip/ip6_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -struct tcp_pcb; - -/** Function prototype for tcp accept callback functions. Called when a new - * connection can be accepted on a listening pcb. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param newpcb The new connection pcb - * @param err An error code if there has been an error accepting. - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_accept_fn)(void *arg, struct tcp_pcb *newpcb, err_t err); - -/** Function prototype for tcp receive callback functions. Called when data has - * been received. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb The connection pcb which received data - * @param p The received data (or NULL when the connection has been closed!) - * @param err An error code if there has been an error receiving - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_recv_fn)(void *arg, struct tcp_pcb *tpcb, - struct pbuf *p, err_t err); - -/** Function prototype for tcp sent callback functions. Called when sent data has - * been acknowledged by the remote side. Use it to free corresponding resources. - * This also means that the pcb has now space available to send new data. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb The connection pcb for which data has been acknowledged - * @param len The amount of bytes acknowledged - * @return ERR_OK: try to send some data by calling tcp_output - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_sent_fn)(void *arg, struct tcp_pcb *tpcb, - u16_t len); - -/** Function prototype for tcp poll callback functions. Called periodically as - * specified by @see tcp_poll. - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb tcp pcb - * @return ERR_OK: try to send some data by calling tcp_output - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - */ -typedef err_t (*tcp_poll_fn)(void *arg, struct tcp_pcb *tpcb); - -/** Function prototype for tcp error callback functions. Called when the pcb - * receives a RST or is unexpectedly closed for any other reason. - * - * @note The corresponding pcb is already freed when this callback is called! - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param err Error code to indicate why the pcb has been closed - * ERR_ABRT: aborted through tcp_abort or by a TCP timer - * ERR_RST: the connection was reset by the remote host - */ -typedef void (*tcp_err_fn)(void *arg, err_t err); - -/** Function prototype for tcp connected callback functions. Called when a pcb - * is connected to the remote side after initiating a connection attempt by - * calling tcp_connect(). - * - * @param arg Additional argument to pass to the callback function (@see tcp_arg()) - * @param tpcb The connection pcb which is connected - * @param err An unused error code, always ERR_OK currently ;-) TODO! - * Only return ERR_ABRT if you have called tcp_abort from within the - * callback function! - * - * @note When a connection attempt fails, the error callback is currently called! - */ -typedef err_t (*tcp_connected_fn)(void *arg, struct tcp_pcb *tpcb, err_t err); - -enum tcp_state { - CLOSED = 0, - LISTEN = 1, - SYN_SENT = 2, - SYN_RCVD = 3, - ESTABLISHED = 4, - FIN_WAIT_1 = 5, - FIN_WAIT_2 = 6, - CLOSE_WAIT = 7, - CLOSING = 8, - LAST_ACK = 9, - TIME_WAIT = 10 -}; - -#if LWIP_CALLBACK_API - /* Function to call when a listener has been connected. - * @param arg user-supplied argument (tcp_pcb.callback_arg) - * @param pcb a new tcp_pcb that now is connected - * @param err an error argument (TODO: that is current always ERR_OK?) - * @return ERR_OK: accept the new connection, - * any other err_t abortsthe new connection - */ -#define DEF_ACCEPT_CALLBACK tcp_accept_fn accept; -#else /* LWIP_CALLBACK_API */ -#define DEF_ACCEPT_CALLBACK -#endif /* LWIP_CALLBACK_API */ - -/** - * members common to struct tcp_pcb and struct tcp_listen_pcb - */ -#define TCP_PCB_COMMON(type) \ - type *next; /* for the linked list */ \ - void *callback_arg; \ - /* the accept callback for listen- and normal pcbs, if LWIP_CALLBACK_API */ \ - DEF_ACCEPT_CALLBACK \ - enum tcp_state state; /* TCP state */ \ - u8_t prio; \ - /* ports are in host byte order */ \ - int bound_to_netif; \ - u16_t local_port; \ - char local_netif[3] - - -/* the TCP protocol control block */ -struct tcp_pcb { -/** common PCB members */ - IP_PCB; -/** protocol specific PCB members */ - TCP_PCB_COMMON(struct tcp_pcb); - - /* ports are in host byte order */ - u16_t remote_port; - - u8_t flags; -#define TF_ACK_DELAY ((u8_t)0x01U) /* Delayed ACK. */ -#define TF_ACK_NOW ((u8_t)0x02U) /* Immediate ACK. */ -#define TF_INFR ((u8_t)0x04U) /* In fast recovery. */ -#define TF_TIMESTAMP ((u8_t)0x08U) /* Timestamp option enabled */ -#define TF_RXCLOSED ((u8_t)0x10U) /* rx closed by tcp_shutdown */ -#define TF_FIN ((u8_t)0x20U) /* Connection was closed locally (FIN segment enqueued). */ -#define TF_NODELAY ((u8_t)0x40U) /* Disable Nagle algorithm */ -#define TF_NAGLEMEMERR ((u8_t)0x80U) /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */ - - /* the rest of the fields are in host byte order - as we have to do some math with them */ - - /* Timers */ - u8_t polltmr, pollinterval; - u8_t last_timer; - u32_t tmr; - - /* receiver variables */ - u32_t rcv_nxt; /* next seqno expected */ - u16_t rcv_wnd; /* receiver window available */ - u16_t rcv_ann_wnd; /* receiver window to announce */ - u32_t rcv_ann_right_edge; /* announced right edge of window */ - - /* Retransmission timer. */ - s16_t rtime; - - u16_t mss; /* maximum segment size */ - - /* RTT (round trip time) estimation variables */ - u32_t rttest; /* RTT estimate in 500ms ticks */ - u32_t rtseq; /* sequence number being timed */ - s16_t sa, sv; /* @todo document this */ - - s16_t rto; /* retransmission time-out */ - u8_t nrtx; /* number of retransmissions */ - - /* fast retransmit/recovery */ - u8_t dupacks; - u32_t lastack; /* Highest acknowledged seqno. */ - - /* congestion avoidance/control variables */ - u16_t cwnd; - u16_t ssthresh; - - /* sender variables */ - u32_t snd_nxt; /* next new seqno to be sent */ - u32_t snd_wl1, snd_wl2; /* Sequence and acknowledgement numbers of last - window update. */ - u32_t snd_lbb; /* Sequence number of next byte to be buffered. */ - u16_t snd_wnd; /* sender window */ - u16_t snd_wnd_max; /* the maximum sender window announced by the remote host */ - - u16_t acked; - - u16_t snd_buf; /* Available buffer space for sending (in bytes). */ -#define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3) - u16_t snd_queuelen; /* Available buffer space for sending (in tcp_segs). */ - -#if TCP_OVERSIZE - /* Extra bytes available at the end of the last pbuf in unsent. */ - u16_t unsent_oversize; -#endif /* TCP_OVERSIZE */ - - /* These are ordered by sequence number: */ - struct tcp_seg *unsent; /* Unsent (queued) segments. */ - struct tcp_seg *unacked; /* Sent but unacknowledged segments. */ -#if TCP_QUEUE_OOSEQ - struct tcp_seg *ooseq; /* Received out of sequence segments. */ -#endif /* TCP_QUEUE_OOSEQ */ - - struct pbuf *refused_data; /* Data previously received but not yet taken by upper layer */ - -#if LWIP_CALLBACK_API - /* Function to be called when more send buffer space is available. */ - tcp_sent_fn sent; - /* Function to be called when (in-sequence) data has arrived. */ - tcp_recv_fn recv; - /* Function to be called when a connection has been set up. */ - tcp_connected_fn connected; - /* Function which is called periodically. */ - tcp_poll_fn poll; - /* Function to be called whenever a fatal error occurs. */ - tcp_err_fn errf; -#endif /* LWIP_CALLBACK_API */ - -#if LWIP_TCP_TIMESTAMPS - u32_t ts_lastacksent; - u32_t ts_recent; -#endif /* LWIP_TCP_TIMESTAMPS */ - - /* idle time before KEEPALIVE is sent */ - u32_t keep_idle; -#if LWIP_TCP_KEEPALIVE - u32_t keep_intvl; - u32_t keep_cnt; -#endif /* LWIP_TCP_KEEPALIVE */ - - /* Persist timer counter */ - u8_t persist_cnt; - /* Persist timer back-off */ - u8_t persist_backoff; - - /* KEEPALIVE counter */ - u8_t keep_cnt_sent; -}; - -struct tcp_pcb_listen { -/* Common members of all PCB types */ - IP_PCB; -/* Protocol specific PCB members */ - TCP_PCB_COMMON(struct tcp_pcb_listen); - -#if TCP_LISTEN_BACKLOG - u8_t backlog; - u8_t accepts_pending; -#endif /* TCP_LISTEN_BACKLOG */ -#if LWIP_IPV6 - u8_t accept_any_ip_version; -#endif /* LWIP_IPV6 */ -}; - -#if LWIP_EVENT_API - -enum lwip_event { - LWIP_EVENT_ACCEPT, - LWIP_EVENT_SENT, - LWIP_EVENT_RECV, - LWIP_EVENT_CONNECTED, - LWIP_EVENT_POLL, - LWIP_EVENT_ERR -}; - -err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb, - enum lwip_event, - struct pbuf *p, - u16_t size, - err_t err); - -#endif /* LWIP_EVENT_API */ - -/* Application program's interface: */ -struct tcp_pcb * tcp_new (void); - -void tcp_arg (struct tcp_pcb *pcb, void *arg); -void tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept); -void tcp_recv (struct tcp_pcb *pcb, tcp_recv_fn recv); -void tcp_sent (struct tcp_pcb *pcb, tcp_sent_fn sent); -void tcp_poll (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval); -void tcp_err (struct tcp_pcb *pcb, tcp_err_fn err); - -#define tcp_mss(pcb) (((pcb)->flags & TF_TIMESTAMP) ? ((pcb)->mss - 12) : (pcb)->mss) -#define tcp_sndbuf(pcb) ((pcb)->snd_buf) -#define tcp_sndqueuelen(pcb) ((pcb)->snd_queuelen) -#define tcp_nagle_disable(pcb) ((pcb)->flags |= TF_NODELAY) -#define tcp_nagle_enable(pcb) ((pcb)->flags &= ~TF_NODELAY) -#define tcp_nagle_disabled(pcb) (((pcb)->flags & TF_NODELAY) != 0) - -#if TCP_LISTEN_BACKLOG -#define tcp_accepted(pcb) do { \ - LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", pcb->state == LISTEN); \ - (((struct tcp_pcb_listen *)(pcb))->accepts_pending--); } while(0) -#else /* TCP_LISTEN_BACKLOG */ -#define tcp_accepted(pcb) LWIP_ASSERT("pcb->state == LISTEN (called for wrong pcb?)", \ - (pcb)->state == LISTEN) -#endif /* TCP_LISTEN_BACKLOG */ - -void tcp_recved (struct tcp_pcb *pcb, u16_t len); -err_t tcp_bind (struct tcp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port); -err_t tcp_bind_to_netif (struct tcp_pcb *pcb, const char ifname[3]); -err_t tcp_connect (struct tcp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port, tcp_connected_fn connected); - -struct tcp_pcb * tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog); -#define tcp_listen(pcb) tcp_listen_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG) - -void tcp_abort (struct tcp_pcb *pcb); -err_t tcp_close (struct tcp_pcb *pcb); -err_t tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx); - -/* Flags for "apiflags" parameter in tcp_write */ -#define TCP_WRITE_FLAG_COPY 0x01 -#define TCP_WRITE_FLAG_MORE 0x02 - -err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len, - u8_t apiflags); - -void tcp_setprio (struct tcp_pcb *pcb, u8_t prio); - -#define TCP_PRIO_MIN 1 -#define TCP_PRIO_NORMAL 64 -#define TCP_PRIO_MAX 127 - -err_t tcp_output (struct tcp_pcb *pcb); - - -const char* tcp_debug_state_str(enum tcp_state s); - -#if LWIP_IPV6 -struct tcp_pcb * tcp_new_ip6 (void); -#define tcp_bind_ip6(pcb, ip6addr, port) \ - tcp_bind(pcb, ip6_2_ip(ip6addr), port) -#define tcp_connect_ip6(pcb, ip6addr, port, connected) \ - tcp_connect(pcb, ip6_2_ip(ip6addr), port, connected) -struct tcp_pcb * tcp_listen_dual_with_backlog(struct tcp_pcb *pcb, u8_t backlog); -#define tcp_listen_dual(pcb) tcp_listen_dual_with_backlog(pcb, TCP_DEFAULT_LISTEN_BACKLOG) -#else /* LWIP_IPV6 */ -#define tcp_listen_dual_with_backlog(pcb, backlog) tcp_listen_with_backlog(pcb, backlog) -#define tcp_listen_dual(pcb) tcp_listen(pcb) -#endif /* LWIP_IPV6 */ - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_TCP */ - -#endif /* __LWIP_TCP_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/tcp_impl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/tcp_impl.h deleted file mode 100644 index 2afc20d3..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/tcp_impl.h +++ /dev/null @@ -1,508 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_TCP_IMPL_H__ -#define __LWIP_TCP_IMPL_H__ - -#include "lwip/opt.h" - -#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/tcp.h" -#include "lwip/mem.h" -#include "lwip/pbuf.h" -#include "lwip/ip.h" -#include "lwip/icmp.h" -#include "lwip/err.h" -#include "lwip/ip6.h" -#include "lwip/ip6_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Functions for interfacing with TCP: */ - -/* Lower layer interface to TCP: */ -void tcp_init (void); /* Initialize this module. */ -void tcp_tmr (void); /* Must be called every - TCP_TMR_INTERVAL - ms. (Typically 250 ms). */ -/* It is also possible to call these two functions at the right - intervals (instead of calling tcp_tmr()). */ -void tcp_slowtmr (void); -void tcp_fasttmr (void); - - -/* Only used by IP to pass a TCP segment to TCP: */ -void tcp_input (struct pbuf *p, struct netif *inp); -/* Used within the TCP code only: */ -struct tcp_pcb * tcp_alloc (u8_t prio); -void tcp_abandon (struct tcp_pcb *pcb, int reset); -err_t tcp_send_empty_ack(struct tcp_pcb *pcb); -void tcp_rexmit (struct tcp_pcb *pcb); -void tcp_rexmit_rto (struct tcp_pcb *pcb); -void tcp_rexmit_fast (struct tcp_pcb *pcb); -u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb); -err_t tcp_process_refused_data(struct tcp_pcb *pcb); - -/** - * This is the Nagle algorithm: try to combine user data to send as few TCP - * segments as possible. Only send if - * - no previously transmitted data on the connection remains unacknowledged or - * - the TF_NODELAY flag is set (nagle algorithm turned off for this pcb) or - * - the only unsent segment is at least pcb->mss bytes long (or there is more - * than one unsent segment - with lwIP, this can happen although unsent->len < mss) - * - or if we are in fast-retransmit (TF_INFR) - */ -#define tcp_do_output_nagle(tpcb) ((((tpcb)->unacked == NULL) || \ - ((tpcb)->flags & (TF_NODELAY | TF_INFR)) || \ - (((tpcb)->unsent != NULL) && (((tpcb)->unsent->next != NULL) || \ - ((tpcb)->unsent->len >= (tpcb)->mss))) || \ - ((tcp_sndbuf(tpcb) == 0) || (tcp_sndqueuelen(tpcb) >= TCP_SND_QUEUELEN)) \ - ) ? 1 : 0) -#define tcp_output_nagle(tpcb) (tcp_do_output_nagle(tpcb) ? tcp_output(tpcb) : ERR_OK) - - -#define TCP_SEQ_LT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) < 0) -#define TCP_SEQ_LEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) <= 0) -#define TCP_SEQ_GT(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) > 0) -#define TCP_SEQ_GEQ(a,b) ((s32_t)((u32_t)(a) - (u32_t)(b)) >= 0) -/* is b<=a<=c? */ -#if 0 /* see bug #10548 */ -#define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b)) -#endif -#define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c)) -#define TCP_FIN 0x01U -#define TCP_SYN 0x02U -#define TCP_RST 0x04U -#define TCP_PSH 0x08U -#define TCP_ACK 0x10U -#define TCP_URG 0x20U -#define TCP_ECE 0x40U -#define TCP_CWR 0x80U - -#define TCP_FLAGS 0x3fU - -/* Length of the TCP header, excluding options. */ -#define TCP_HLEN 20 - -#ifndef TCP_TMR_INTERVAL -#define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */ -#endif /* TCP_TMR_INTERVAL */ - -#ifndef TCP_FAST_INTERVAL -#define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */ -#endif /* TCP_FAST_INTERVAL */ - -#ifndef TCP_SLOW_INTERVAL -#define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */ -#endif /* TCP_SLOW_INTERVAL */ - -#define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */ -#define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */ - -#define TCP_OOSEQ_TIMEOUT 6U /* x RTO */ - -#ifndef TCP_MSL -#define TCP_MSL 60000UL /* The maximum segment lifetime in milliseconds */ -#endif - -/* Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing */ -#ifndef TCP_KEEPIDLE_DEFAULT -#define TCP_KEEPIDLE_DEFAULT 7200000UL /* Default KEEPALIVE timer in milliseconds */ -#endif - -#ifndef TCP_KEEPINTVL_DEFAULT -#define TCP_KEEPINTVL_DEFAULT 75000UL /* Default Time between KEEPALIVE probes in milliseconds */ -#endif - -#ifndef TCP_KEEPCNT_DEFAULT -#define TCP_KEEPCNT_DEFAULT 9U /* Default Counter for KEEPALIVE probes */ -#endif - -#define TCP_MAXIDLE TCP_KEEPCNT_DEFAULT * TCP_KEEPINTVL_DEFAULT /* Maximum KEEPALIVE probe time */ - -/* Fields are (of course) in network byte order. - * Some fields are converted to host byte order in tcp_input(). - */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct tcp_hdr { - PACK_STRUCT_FIELD(u16_t src); - PACK_STRUCT_FIELD(u16_t dest); - PACK_STRUCT_FIELD(u32_t seqno); - PACK_STRUCT_FIELD(u32_t ackno); - PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags); - PACK_STRUCT_FIELD(u16_t wnd); - PACK_STRUCT_FIELD(u16_t chksum); - PACK_STRUCT_FIELD(u16_t urgp); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define TCPH_HDRLEN(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 12) -#define TCPH_FLAGS(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS) - -#define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr)) -#define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = (((phdr)->_hdrlen_rsvd_flags & PP_HTONS((u16_t)(~(u16_t)(TCP_FLAGS)))) | htons(flags)) -#define TCPH_HDRLEN_FLAGS_SET(phdr, len, flags) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | (flags)) - -#define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = ((phdr)->_hdrlen_rsvd_flags | htons(flags)) -#define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = htons(ntohs((phdr)->_hdrlen_rsvd_flags) | (TCPH_FLAGS(phdr) & ~(flags)) ) - -#define TCP_TCPLEN(seg) ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & (TCP_FIN | TCP_SYN)) != 0)) - -/** Flags used on input processing, not on pcb->flags -*/ -#define TF_RESET (u8_t)0x08U /* Connection was reset. */ -#define TF_CLOSED (u8_t)0x10U /* Connection was sucessfully closed. */ -#define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */ - - -#if LWIP_EVENT_API - -#define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_ACCEPT, NULL, 0, err) -#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_SENT, NULL, space, ERR_OK) -#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_RECV, (p), 0, (err)) -#define TCP_EVENT_CLOSED(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_RECV, NULL, 0, ERR_OK) -#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_CONNECTED, NULL, 0, (err)) -#define TCP_EVENT_POLL(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ - LWIP_EVENT_POLL, NULL, 0, ERR_OK) -#define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \ - LWIP_EVENT_ERR, NULL, 0, (err)) - -#else /* LWIP_EVENT_API */ - -#define TCP_EVENT_ACCEPT(pcb,err,ret) \ - do { \ - if((pcb)->accept != NULL) \ - (ret) = (pcb)->accept((pcb)->callback_arg,(pcb),(err)); \ - else (ret) = ERR_ARG; \ - } while (0) - -#define TCP_EVENT_SENT(pcb,space,ret) \ - do { \ - if((pcb)->sent != NULL) \ - (ret) = (pcb)->sent((pcb)->callback_arg,(pcb),(space)); \ - else (ret) = ERR_OK; \ - } while (0) - -#define TCP_EVENT_RECV(pcb,p,err,ret) \ - do { \ - if((pcb)->recv != NULL) { \ - (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err));\ - } else { \ - (ret) = tcp_recv_null(NULL, (pcb), (p), (err)); \ - } \ - } while (0) - -#define TCP_EVENT_CLOSED(pcb,ret) \ - do { \ - if(((pcb)->recv != NULL)) { \ - (ret) = (pcb)->recv((pcb)->callback_arg,(pcb),NULL,ERR_OK);\ - } else { \ - (ret) = ERR_OK; \ - } \ - } while (0) - -#define TCP_EVENT_CONNECTED(pcb,err,ret) \ - do { \ - if((pcb)->connected != NULL) \ - (ret) = (pcb)->connected((pcb)->callback_arg,(pcb),(err)); \ - else (ret) = ERR_OK; \ - } while (0) - -#define TCP_EVENT_POLL(pcb,ret) \ - do { \ - if((pcb)->poll != NULL) \ - (ret) = (pcb)->poll((pcb)->callback_arg,(pcb)); \ - else (ret) = ERR_OK; \ - } while (0) - -#define TCP_EVENT_ERR(errf,arg,err) \ - do { \ - if((errf) != NULL) \ - (errf)((arg),(err)); \ - } while (0) - -#endif /* LWIP_EVENT_API */ - -/** Enabled extra-check for TCP_OVERSIZE if LWIP_DEBUG is enabled */ -#if TCP_OVERSIZE && defined(LWIP_DEBUG) -#define TCP_OVERSIZE_DBGCHECK 1 -#else -#define TCP_OVERSIZE_DBGCHECK 0 -#endif - -/** Don't generate checksum on copy if CHECKSUM_GEN_TCP is disabled */ -#define TCP_CHECKSUM_ON_COPY (LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_TCP) - -/* This structure represents a TCP segment on the unsent, unacked and ooseq queues */ -struct tcp_seg { - struct tcp_seg *next; /* used when putting segements on a queue */ - struct pbuf *p; /* buffer containing data + TCP header */ - u16_t len; /* the TCP length of this segment */ -#if TCP_OVERSIZE_DBGCHECK - u16_t oversize_left; /* Extra bytes available at the end of the last - pbuf in unsent (used for asserting vs. - tcp_pcb.unsent_oversized only) */ -#endif /* TCP_OVERSIZE_DBGCHECK */ -#if TCP_CHECKSUM_ON_COPY - u16_t chksum; - u8_t chksum_swapped; -#endif /* TCP_CHECKSUM_ON_COPY */ - u8_t flags; -#define TF_SEG_OPTS_MSS (u8_t)0x01U /* Include MSS option. */ -#define TF_SEG_OPTS_TS (u8_t)0x02U /* Include timestamp option. */ -#define TF_SEG_DATA_CHECKSUMMED (u8_t)0x04U /* ALL data (not the header) is - checksummed into 'chksum' */ - struct tcp_hdr *tcphdr; /* the TCP header */ -}; - -#define LWIP_TCP_OPT_LENGTH(flags) \ - (flags & TF_SEG_OPTS_MSS ? 4 : 0) + \ - (flags & TF_SEG_OPTS_TS ? 12 : 0) - -/** This returns a TCP header option for MSS in an u32_t */ -#define TCP_BUILD_MSS_OPTION(mss) htonl(0x02040000 | ((mss) & 0xFFFF)) - -/* Global variables: */ -extern struct tcp_pcb *tcp_input_pcb; -extern u32_t tcp_ticks; -extern u8_t tcp_active_pcbs_changed; - -/* The TCP PCB lists. */ -union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */ - struct tcp_pcb_listen *listen_pcbs; - struct tcp_pcb *pcbs; -}; -extern struct tcp_pcb *tcp_bound_pcbs; -extern union tcp_listen_pcbs_t tcp_listen_pcbs; -extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a - state in which they accept or send - data. */ -extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */ - -extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */ - -/* Axioms about the above lists: - 1) Every TCP PCB that is not CLOSED is in one of the lists. - 2) A PCB is only in one of the lists. - 3) All PCBs in the tcp_listen_pcbs list is in LISTEN state. - 4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state. -*/ -/* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB - with a PCB list or removes a PCB from a list, respectively. */ -#ifndef TCP_DEBUG_PCB_LISTS -#define TCP_DEBUG_PCB_LISTS 0 -#endif -#if TCP_DEBUG_PCB_LISTS -#define TCP_REG(pcbs, npcb) do {\ - LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \ - for(tcp_tmp_pcb = *(pcbs); \ - tcp_tmp_pcb != NULL; \ - tcp_tmp_pcb = tcp_tmp_pcb->next) { \ - LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != (npcb)); \ - } \ - LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", ((pcbs) == &tcp_bound_pcbs) || ((npcb)->state != CLOSED)); \ - (npcb)->next = *(pcbs); \ - LWIP_ASSERT("TCP_REG: npcb->next != npcb", (npcb)->next != (npcb)); \ - *(pcbs) = (npcb); \ - LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ - tcp_timer_needed(); \ - } while(0) -#define TCP_RMV(pcbs, npcb) do { \ - LWIP_ASSERT("TCP_RMV: pcbs != NULL", *(pcbs) != NULL); \ - LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", (npcb), *(pcbs))); \ - if(*(pcbs) == (npcb)) { \ - *(pcbs) = (*pcbs)->next; \ - } else for(tcp_tmp_pcb = *(pcbs); tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \ - if(tcp_tmp_pcb->next == (npcb)) { \ - tcp_tmp_pcb->next = (npcb)->next; \ - break; \ - } \ - } \ - (npcb)->next = NULL; \ - LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ - LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \ - } while(0) - -#else /* LWIP_DEBUG */ - -#define TCP_REG(pcbs, npcb) \ - do { \ - (npcb)->next = *pcbs; \ - *(pcbs) = (npcb); \ - tcp_timer_needed(); \ - } while (0) - -#define TCP_RMV(pcbs, npcb) \ - do { \ - if(*(pcbs) == (npcb)) { \ - (*(pcbs)) = (*pcbs)->next; \ - } \ - else { \ - for(tcp_tmp_pcb = *pcbs; \ - tcp_tmp_pcb != NULL; \ - tcp_tmp_pcb = tcp_tmp_pcb->next) { \ - if(tcp_tmp_pcb->next == (npcb)) { \ - tcp_tmp_pcb->next = (npcb)->next; \ - break; \ - } \ - } \ - } \ - (npcb)->next = NULL; \ - } while(0) - -#endif /* LWIP_DEBUG */ - -#define TCP_REG_ACTIVE(npcb) \ - do { \ - TCP_REG(&tcp_active_pcbs, npcb); \ - tcp_active_pcbs_changed = 1; \ - } while (0) - -#define TCP_RMV_ACTIVE(npcb) \ - do { \ - TCP_RMV(&tcp_active_pcbs, npcb); \ - tcp_active_pcbs_changed = 1; \ - } while (0) - -#define TCP_PCB_REMOVE_ACTIVE(pcb) \ - do { \ - tcp_pcb_remove(&tcp_active_pcbs, pcb); \ - tcp_active_pcbs_changed = 1; \ - } while (0) - - -/* Internal functions: */ -struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb); -void tcp_pcb_purge(struct tcp_pcb *pcb); -void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb); - -void tcp_segs_free(struct tcp_seg *seg); -void tcp_seg_free(struct tcp_seg *seg); -struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg); - -#define tcp_ack(pcb) \ - do { \ - if((pcb)->flags & TF_ACK_DELAY) { \ - (pcb)->flags &= ~TF_ACK_DELAY; \ - (pcb)->flags |= TF_ACK_NOW; \ - } \ - else { \ - (pcb)->flags |= TF_ACK_DELAY; \ - } \ - } while (0) - -#define tcp_ack_now(pcb) \ - do { \ - (pcb)->flags |= TF_ACK_NOW; \ - } while (0) - -err_t tcp_send_fin(struct tcp_pcb *pcb); -err_t tcp_enqueue_flags(struct tcp_pcb *pcb, u8_t flags); - -void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg); - -void tcp_rst_impl(u32_t seqno, u32_t ackno, - ipX_addr_t *local_ip, ipX_addr_t *remote_ip, - u16_t local_port, u16_t remote_port -#if LWIP_IPV6 - , u8_t isipv6 -#endif /* LWIP_IPV6 */ - ); -#if LWIP_IPV6 -#define tcp_rst(seqno, ackno, local_ip, remote_ip, local_port, remote_port, isipv6) \ - tcp_rst_impl(seqno, ackno, local_ip, remote_ip, local_port, remote_port, isipv6) -#else /* LWIP_IPV6 */ -#define tcp_rst(seqno, ackno, local_ip, remote_ip, local_port, remote_port, isipv6) \ - tcp_rst_impl(seqno, ackno, local_ip, remote_ip, local_port, remote_port) -#endif /* LWIP_IPV6 */ - -u32_t tcp_next_iss(void); - -void tcp_keepalive(struct tcp_pcb *pcb); -void tcp_zero_window_probe(struct tcp_pcb *pcb); - -#if TCP_CALCULATE_EFF_SEND_MSS -u16_t tcp_eff_send_mss_impl(u16_t sendmss, ipX_addr_t *dest -#if LWIP_IPV6 - , ipX_addr_t *src, u8_t isipv6 -#endif /* LWIP_IPV6 */ - ); -#if LWIP_IPV6 -#define tcp_eff_send_mss(sendmss, src, dest, isipv6) tcp_eff_send_mss_impl(sendmss, dest, src, isipv6) -#else /* LWIP_IPV6 */ -#define tcp_eff_send_mss(sendmss, src, dest, isipv6) tcp_eff_send_mss_impl(sendmss, dest) -#endif /* LWIP_IPV6 */ -#endif /* TCP_CALCULATE_EFF_SEND_MSS */ - -#if LWIP_CALLBACK_API -err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); -#endif /* LWIP_CALLBACK_API */ - -#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG -void tcp_debug_print(struct tcp_hdr *tcphdr); -void tcp_debug_print_flags(u8_t flags); -void tcp_debug_print_state(enum tcp_state s); -void tcp_debug_print_pcbs(void); -s16_t tcp_pcbs_sane(void); -#else -# define tcp_debug_print(tcphdr) -# define tcp_debug_print_flags(flags) -# define tcp_debug_print_state(s) -# define tcp_debug_print_pcbs() -# define tcp_pcbs_sane() 1 -#endif /* TCP_DEBUG */ - -/** External function (implemented in timers.c), called when TCP detects - * that a timer is needed (i.e. active- or time-wait-pcb found). */ -void tcp_timer_needed(void); - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_TCP */ - -#endif /* __LWIP_TCP_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/tcpip.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/tcpip.h deleted file mode 100644 index 04567f2c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/tcpip.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_TCPIP_H__ -#define __LWIP_TCPIP_H__ - -#include "lwip/opt.h" - -#if !NO_SYS /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/api_msg.h" -#include "lwip/netifapi.h" -#include "lwip/pbuf.h" -#include "lwip/api.h" -#include "lwip/sys.h" -#include "lwip/timers.h" -#include "lwip/netif.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Define this to something that triggers a watchdog. This is called from - * tcpip_thread after processing a message. */ -#ifndef LWIP_TCPIP_THREAD_ALIVE -#define LWIP_TCPIP_THREAD_ALIVE() -#endif - -#if LWIP_TCPIP_CORE_LOCKING -/** The global semaphore to lock the stack. */ -extern sys_mutex_t lock_tcpip_core; -#define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core) -#define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core) -#ifdef LWIP_DEBUG -#define TCIP_APIMSG_SET_ERR(m, e) (m)->msg.err = e /* catch functions that don't set err */ -#else -#define TCIP_APIMSG_SET_ERR(m, e) -#endif -#define TCPIP_APIMSG_NOERR(m,f) do { \ - TCIP_APIMSG_SET_ERR(m, ERR_VAL); \ - LOCK_TCPIP_CORE(); \ - f(&((m)->msg)); \ - UNLOCK_TCPIP_CORE(); \ -} while(0) -#define TCPIP_APIMSG(m,f,e) do { \ - TCPIP_APIMSG_NOERR(m,f); \ - (e) = (m)->msg.err; \ -} while(0) -#define TCPIP_APIMSG_ACK(m) -#define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m) -#define TCPIP_NETIFAPI_ACK(m) -#else /* LWIP_TCPIP_CORE_LOCKING */ -#define LOCK_TCPIP_CORE() -#define UNLOCK_TCPIP_CORE() -#define TCPIP_APIMSG_NOERR(m,f) do { (m)->function = f; tcpip_apimsg(m); } while(0) -#define TCPIP_APIMSG(m,f,e) do { (m)->function = f; (e) = tcpip_apimsg(m); } while(0) -#define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed) -#define TCPIP_NETIFAPI(m) tcpip_netifapi(m) -#define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem) -#endif /* LWIP_TCPIP_CORE_LOCKING */ - -/** Function prototype for the init_done function passed to tcpip_init */ -typedef void (*tcpip_init_done_fn)(void *arg); -/** Function prototype for functions passed to tcpip_callback() */ -typedef void (*tcpip_callback_fn)(void *ctx); - -/* Forward declarations */ -struct tcpip_callback_msg; - -void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg); - -#if LWIP_NETCONN -err_t tcpip_apimsg(struct api_msg *apimsg); -#endif /* LWIP_NETCONN */ - -err_t tcpip_input(struct pbuf *p, struct netif *inp); - -#if LWIP_NETIF_API -err_t tcpip_netifapi(struct netifapi_msg *netifapimsg); -#if LWIP_TCPIP_CORE_LOCKING -err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg); -#endif /* LWIP_TCPIP_CORE_LOCKING */ -#endif /* LWIP_NETIF_API */ - -err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block); -#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1) - -struct tcpip_callback_msg* tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx); -void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg); -err_t tcpip_trycallback(struct tcpip_callback_msg* msg); - -/* free pbufs or heap memory from another context without blocking */ -err_t pbuf_free_callback(struct pbuf *p); -err_t mem_free_callback(void *m); - -#if LWIP_TCPIP_TIMEOUT -err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg); -err_t tcpip_untimeout(sys_timeout_handler h, void *arg); -#endif /* LWIP_TCPIP_TIMEOUT */ - -enum tcpip_msg_type { -#if LWIP_NETCONN - TCPIP_MSG_API, -#endif /* LWIP_NETCONN */ - TCPIP_MSG_INPKT, -#if LWIP_NETIF_API - TCPIP_MSG_NETIFAPI, -#endif /* LWIP_NETIF_API */ -#if LWIP_TCPIP_TIMEOUT - TCPIP_MSG_TIMEOUT, - TCPIP_MSG_UNTIMEOUT, -#endif /* LWIP_TCPIP_TIMEOUT */ - TCPIP_MSG_CALLBACK, - TCPIP_MSG_CALLBACK_STATIC -}; - -struct tcpip_msg { - enum tcpip_msg_type type; - sys_sem_t *sem; - union { -#if LWIP_NETCONN - struct api_msg *apimsg; -#endif /* LWIP_NETCONN */ -#if LWIP_NETIF_API - struct netifapi_msg *netifapimsg; -#endif /* LWIP_NETIF_API */ - struct { - struct pbuf *p; - struct netif *netif; - } inp; - struct { - tcpip_callback_fn function; - void *ctx; - } cb; -#if LWIP_TCPIP_TIMEOUT - struct { - u32_t msecs; - sys_timeout_handler h; - void *arg; - } tmo; -#endif /* LWIP_TCPIP_TIMEOUT */ - } msg; -}; - -#ifdef __cplusplus -} -#endif - -#endif /* !NO_SYS */ - -#endif /* __LWIP_TCPIP_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/timers.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/timers.h deleted file mode 100644 index 04e78e0f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/timers.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * Simon Goldschmidt - * - */ -#ifndef __LWIP_TIMERS_H__ -#define __LWIP_TIMERS_H__ - -#include "lwip/opt.h" - -/* Timers are not supported when NO_SYS==1 and NO_SYS_NO_TIMERS==1 */ -#define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) - -#if LWIP_TIMERS - -#include "lwip/err.h" -#if !NO_SYS -#include "lwip/sys.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef LWIP_DEBUG_TIMERNAMES -#ifdef LWIP_DEBUG -#define LWIP_DEBUG_TIMERNAMES SYS_DEBUG -#else /* LWIP_DEBUG */ -#define LWIP_DEBUG_TIMERNAMES 0 -#endif /* LWIP_DEBUG*/ -#endif - -/** Function prototype for a timeout callback function. Register such a function - * using sys_timeout(). - * - * @param arg Additional argument to pass to the function - set up by sys_timeout() - */ -typedef void (* sys_timeout_handler)(void *arg); - -struct sys_timeo { - struct sys_timeo *next; - u32_t time; - sys_timeout_handler h; - void *arg; -#if LWIP_DEBUG_TIMERNAMES - const char* handler_name; -#endif /* LWIP_DEBUG_TIMERNAMES */ -}; - -void sys_timeouts_init(void); - -#if LWIP_DEBUG_TIMERNAMES -void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name); -#define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) -#else /* LWIP_DEBUG_TIMERNAMES */ -void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg); -#endif /* LWIP_DEBUG_TIMERNAMES */ - -void sys_untimeout(sys_timeout_handler handler, void *arg); -#if NO_SYS -void sys_check_timeouts(void); -void sys_restart_timeouts(void); -#else /* NO_SYS */ -void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg); -#endif /* NO_SYS */ - - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_TIMERS */ -#endif /* __LWIP_TIMERS_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/udp.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/udp.h deleted file mode 100644 index 14d5c0ae..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/lwip/udp.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __LWIP_UDP_H__ -#define __LWIP_UDP_H__ - -#include "lwip/opt.h" - -#if LWIP_UDP /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/pbuf.h" -#include "lwip/netif.h" -#include "lwip/ip_addr.h" -#include "lwip/ip.h" -#include "lwip/ip6_addr.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define UDP_HLEN 8 - -/* Fields are (of course) in network byte order. */ -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct udp_hdr { - PACK_STRUCT_FIELD(u16_t src); - PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ - PACK_STRUCT_FIELD(u16_t len); - PACK_STRUCT_FIELD(u16_t chksum); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define UDP_FLAGS_NOCHKSUM 0x01U -#define UDP_FLAGS_UDPLITE 0x02U -#define UDP_FLAGS_CONNECTED 0x04U -#define UDP_FLAGS_MULTICAST_LOOP 0x08U - -struct udp_pcb; - -/** Function prototype for udp pcb receive callback functions - * addr and port are in same byte order as in the pcb - * The callback is responsible for freeing the pbuf - * if it's not used any more. - * - * ATTENTION: Be aware that 'addr' points into the pbuf 'p' so freeing this pbuf - * makes 'addr' invalid, too. - * - * @param arg user supplied argument (udp_pcb.recv_arg) - * @param pcb the udp_pcb which received data - * @param p the packet buffer that was received - * @param addr the remote IP address from which the packet was received - * @param port the remote port from which the packet was received - */ -typedef void (*udp_recv_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *addr, u16_t port); - -#if LWIP_IPV6 -/** Function prototype for udp pcb IPv6 receive callback functions - * The callback is responsible for freeing the pbuf - * if it's not used any more. - * - * @param arg user supplied argument (udp_pcb.recv_arg) - * @param pcb the udp_pcb which received data - * @param p the packet buffer that was received - * @param addr the remote IPv6 address from which the packet was received - * @param port the remote port from which the packet was received - */ -typedef void (*udp_recv_ip6_fn)(void *arg, struct udp_pcb *pcb, struct pbuf *p, - ip6_addr_t *addr, u16_t port); -#endif /* LWIP_IPV6 */ - -#if LWIP_IPV6 -#define UDP_PCB_RECV_IP6 udp_recv_ip6_fn ip6; -#else -#define UDP_PCB_RECV_IP6 -#endif /* LWIP_IPV6 */ - -struct udp_pcb { -/* Common members of all PCB types */ - IP_PCB; - -/* Protocol specific PCB members */ - - struct udp_pcb *next; - - u8_t flags; - /** ports are in host byte order */ - u16_t local_port, remote_port; - -#if LWIP_IGMP - /** outgoing network interface for multicast packets */ - ip_addr_t multicast_ip; -#endif /* LWIP_IGMP */ - -#if LWIP_UDPLITE - /** used for UDP_LITE only */ - u16_t chksum_len_rx, chksum_len_tx; -#endif /* LWIP_UDPLITE */ - - /** receive callback function */ - union { - udp_recv_fn ip4; - UDP_PCB_RECV_IP6 - }recv; - /** user-supplied argument for the recv callback */ - void *recv_arg; -}; -/* udp_pcbs export for exernal reference (e.g. SNMP agent) */ -extern struct udp_pcb *udp_pcbs; - -/* The following functions is the application layer interface to the - UDP code. */ -struct udp_pcb * udp_new (void); -void udp_remove (struct udp_pcb *pcb); -err_t udp_bind (struct udp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port); -err_t udp_connect (struct udp_pcb *pcb, ip_addr_t *ipaddr, - u16_t port); -void udp_disconnect (struct udp_pcb *pcb); -void udp_recv (struct udp_pcb *pcb, udp_recv_fn recv, - void *recv_arg); -err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port, - struct netif *netif); -err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port); -err_t udp_send (struct udp_pcb *pcb, struct pbuf *p); - -#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP -err_t udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port, - struct netif *netif, u8_t have_chksum, - u16_t chksum); -err_t udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, - ip_addr_t *dst_ip, u16_t dst_port, - u8_t have_chksum, u16_t chksum); -err_t udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, - u8_t have_chksum, u16_t chksum); -#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ - -#define udp_flags(pcb) ((pcb)->flags) -#define udp_setflags(pcb, f) ((pcb)->flags = (f)) - -/* The following functions are the lower layer interface to UDP. */ -void udp_input (struct pbuf *p, struct netif *inp); - -void udp_init (void); - -#if LWIP_IPV6 -struct udp_pcb * udp_new_ip6(void); -#define udp_bind_ip6(pcb, ip6addr, port) \ - udp_bind(pcb, ip6_2_ip(ip6addr), port) -#define udp_connect_ip6(pcb, ip6addr, port) \ - udp_connect(pcb, ip6_2_ip(ip6addr), port) -#define udp_recv_ip6(pcb, recv_ip6_fn, recv_arg) \ - udp_recv(pcb, (udp_recv_fn)recv_ip6_fn, recv_arg) -#define udp_sendto_ip6(pcb, pbuf, ip6addr, port) \ - udp_sendto(pcb, pbuf, ip6_2_ip(ip6addr), port) -#define udp_sendto_if_ip6(pcb, pbuf, ip6addr, port, netif) \ - udp_sendto_if(pcb, pbuf, ip6_2_ip(ip6addr), port, netif) -#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP -#define udp_sendto_chksum_ip6(pcb, pbuf, ip6addr, port, have_chk, chksum) \ - udp_sendto_chksum(pcb, pbuf, ip6_2_ip(ip6addr), port, have_chk, chksum) -#define udp_sendto_if_chksum_ip6(pcb, pbuf, ip6addr, port, netif, have_chk, chksum) \ - udp_sendto_if_chksum(pcb, pbuf, ip6_2_ip(ip6addr), port, netif, have_chk, chksum) -#endif /*LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */ -#endif /* LWIP_IPV6 */ - -#if UDP_DEBUG -void udp_debug_print(struct udp_hdr *udphdr); -#else -#define udp_debug_print(udphdr) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_UDP */ - -#endif /* __LWIP_UDP_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/netif/etharp.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/netif/etharp.h deleted file mode 100644 index 8275a28f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/netif/etharp.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * Copyright (c) 2003-2004 Leon Woestenberg - * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ - -#ifndef __NETIF_ETHARP_H__ -#define __NETIF_ETHARP_H__ - -#include "lwip/opt.h" - -#if LWIP_ARP || LWIP_ETHERNET /* don't build if not configured for use in lwipopts.h */ - -#include "lwip/pbuf.h" -#include "lwip/ip_addr.h" -#include "lwip/netif.h" -#include "lwip/ip.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ETHARP_HWADDR_LEN -#define ETHARP_HWADDR_LEN 6 -#endif - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct eth_addr { - PACK_STRUCT_FIELD(u8_t addr[ETHARP_HWADDR_LEN]); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** Ethernet header */ -struct eth_hdr { -#if ETH_PAD_SIZE - PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]); -#endif - PACK_STRUCT_FIELD(struct eth_addr dest); - PACK_STRUCT_FIELD(struct eth_addr src); - PACK_STRUCT_FIELD(u16_t type); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define SIZEOF_ETH_HDR (14 + ETH_PAD_SIZE) - -#if ETHARP_SUPPORT_VLAN - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** VLAN header inserted between ethernet header and payload - * if 'type' in ethernet header is ETHTYPE_VLAN. - * See IEEE802.Q */ -struct eth_vlan_hdr { - PACK_STRUCT_FIELD(u16_t prio_vid); - PACK_STRUCT_FIELD(u16_t tpid); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define SIZEOF_VLAN_HDR 4 -#define VLAN_ID(vlan_hdr) (htons((vlan_hdr)->prio_vid) & 0xFFF) - -#endif /* ETHARP_SUPPORT_VLAN */ - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -/** the ARP message, see RFC 826 ("Packet format") */ -struct etharp_hdr { - PACK_STRUCT_FIELD(u16_t hwtype); - PACK_STRUCT_FIELD(u16_t proto); - PACK_STRUCT_FIELD(u8_t hwlen); - PACK_STRUCT_FIELD(u8_t protolen); - PACK_STRUCT_FIELD(u16_t opcode); - PACK_STRUCT_FIELD(struct eth_addr shwaddr); - PACK_STRUCT_FIELD(struct ip_addr2 sipaddr); - PACK_STRUCT_FIELD(struct eth_addr dhwaddr); - PACK_STRUCT_FIELD(struct ip_addr2 dipaddr); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#define SIZEOF_ETHARP_HDR 28 -#define SIZEOF_ETHARP_PACKET (SIZEOF_ETH_HDR + SIZEOF_ETHARP_HDR) - -/** 5 seconds period */ -#define ARP_TMR_INTERVAL 5000 - -#define ETHTYPE_ARP 0x0806U -#define ETHTYPE_IP 0x0800U -#define ETHTYPE_VLAN 0x8100U -#define ETHTYPE_IPV6 0x86DDU -#define ETHTYPE_PPPOEDISC 0x8863U /* PPP Over Ethernet Discovery Stage */ -#define ETHTYPE_PPPOE 0x8864U /* PPP Over Ethernet Session Stage */ - -/** MEMCPY-like macro to copy to/from struct eth_addr's that are local variables - * or known to be 32-bit aligned within the protocol header. */ -#ifndef ETHADDR32_COPY -#define ETHADDR32_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN) -#endif - -/** MEMCPY-like macro to copy to/from struct eth_addr's that are no local - * variables and known to be 16-bit aligned within the protocol header. */ -#ifndef ETHADDR16_COPY -#define ETHADDR16_COPY(src, dst) SMEMCPY(src, dst, ETHARP_HWADDR_LEN) -#endif - -#if LWIP_ARP /* don't build if not configured for use in lwipopts.h */ - -/** ARP message types (opcodes) */ -#define ARP_REQUEST 1 -#define ARP_REPLY 2 - -/** Define this to 1 and define LWIP_ARP_FILTER_NETIF_FN(pbuf, netif, type) - * to a filter function that returns the correct netif when using multiple - * netifs on one hardware interface where the netif's low-level receive - * routine cannot decide for the correct netif (e.g. when mapping multiple - * IP addresses to one hardware interface). - */ -#ifndef LWIP_ARP_FILTER_NETIF -#define LWIP_ARP_FILTER_NETIF 0 -#endif - -#if ARP_QUEUEING -/** struct for queueing outgoing packets for unknown address - * defined here to be accessed by memp.h - */ -struct etharp_q_entry { - struct etharp_q_entry *next; - struct pbuf *p; -}; -#endif /* ARP_QUEUEING */ - -#define etharp_init() /* Compatibility define, not init needed. */ -void etharp_tmr(void); -s8_t etharp_find_addr(struct netif *netif, ip_addr_t *ipaddr, - struct eth_addr **eth_ret, ip_addr_t **ip_ret); -err_t etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr); -err_t etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q); -err_t etharp_request(struct netif *netif, ip_addr_t *ipaddr); -/** For Ethernet network interfaces, we might want to send "gratuitous ARP"; - * this is an ARP packet sent by a node in order to spontaneously cause other - * nodes to update an entry in their ARP cache. - * From RFC 3220 "IP Mobility Support for IPv4" section 4.6. */ -#define etharp_gratuitous(netif) etharp_request((netif), &(netif)->ip_addr) -void etharp_cleanup_netif(struct netif *netif); - -#if ETHARP_SUPPORT_STATIC_ENTRIES -err_t etharp_add_static_entry(ip_addr_t *ipaddr, struct eth_addr *ethaddr); -err_t etharp_remove_static_entry(ip_addr_t *ipaddr); -#endif /* ETHARP_SUPPORT_STATIC_ENTRIES */ - -#if LWIP_AUTOIP -err_t etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, - const struct eth_addr *ethdst_addr, - const struct eth_addr *hwsrc_addr, const ip_addr_t *ipsrc_addr, - const struct eth_addr *hwdst_addr, const ip_addr_t *ipdst_addr, - const u16_t opcode); -#endif /* LWIP_AUTOIP */ - -#endif /* LWIP_ARP */ - -err_t ethernet_input(struct pbuf *p, struct netif *netif); - -#define eth_addr_cmp(addr1, addr2) (memcmp((addr1)->addr, (addr2)->addr, ETHARP_HWADDR_LEN) == 0) - -extern const struct eth_addr ethbroadcast, ethzero; - -#ifdef __cplusplus -} -#endif - -#endif /* LWIP_ARP || LWIP_ETHERNET */ - -#endif /* __NETIF_ARP_H__ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/netif/ppp_oe.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/netif/ppp_oe.h deleted file mode 100644 index e1cdfa51..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/netif/ppp_oe.h +++ /dev/null @@ -1,190 +0,0 @@ -/***************************************************************************** -* ppp_oe.h - PPP Over Ethernet implementation for lwIP. -* -* Copyright (c) 2006 by Marc Boucher, Services Informatiques (MBSI) inc. -* -* The authors hereby grant permission to use, copy, modify, distribute, -* and license this software and its documentation for any purpose, provided -* that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any -* distributions. No written agreement, license, or royalty fee is required -* for any of the authorized uses. -* -* THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR -* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -* IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -****************************************************************************** -* REVISION HISTORY -* -* 06-01-01 Marc Boucher -* Ported to lwIP. -*****************************************************************************/ - - - -/* based on NetBSD: if_pppoe.c,v 1.64 2006/01/31 23:50:15 martin Exp */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef PPP_OE_H -#define PPP_OE_H - -#include "lwip/opt.h" - -#if PPPOE_SUPPORT > 0 - -#include "netif/etharp.h" - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct pppoehdr { - PACK_STRUCT_FIELD(u8_t vertype); - PACK_STRUCT_FIELD(u8_t code); - PACK_STRUCT_FIELD(u16_t session); - PACK_STRUCT_FIELD(u16_t plen); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/bpstruct.h" -#endif -PACK_STRUCT_BEGIN -struct pppoetag { - PACK_STRUCT_FIELD(u16_t tag); - PACK_STRUCT_FIELD(u16_t len); -} PACK_STRUCT_STRUCT; -PACK_STRUCT_END -#ifdef PACK_STRUCT_USE_INCLUDES -# include "arch/epstruct.h" -#endif - - -#define PPPOE_STATE_INITIAL 0 -#define PPPOE_STATE_PADI_SENT 1 -#define PPPOE_STATE_PADR_SENT 2 -#define PPPOE_STATE_SESSION 3 -#define PPPOE_STATE_CLOSING 4 -/* passive */ -#define PPPOE_STATE_PADO_SENT 1 - -#define PPPOE_HEADERLEN sizeof(struct pppoehdr) -#define PPPOE_VERTYPE 0x11 /* VER=1, TYPE = 1 */ - -#define PPPOE_TAG_EOL 0x0000 /* end of list */ -#define PPPOE_TAG_SNAME 0x0101 /* service name */ -#define PPPOE_TAG_ACNAME 0x0102 /* access concentrator name */ -#define PPPOE_TAG_HUNIQUE 0x0103 /* host unique */ -#define PPPOE_TAG_ACCOOKIE 0x0104 /* AC cookie */ -#define PPPOE_TAG_VENDOR 0x0105 /* vendor specific */ -#define PPPOE_TAG_RELAYSID 0x0110 /* relay session id */ -#define PPPOE_TAG_SNAME_ERR 0x0201 /* service name error */ -#define PPPOE_TAG_ACSYS_ERR 0x0202 /* AC system error */ -#define PPPOE_TAG_GENERIC_ERR 0x0203 /* gerneric error */ - -#define PPPOE_CODE_PADI 0x09 /* Active Discovery Initiation */ -#define PPPOE_CODE_PADO 0x07 /* Active Discovery Offer */ -#define PPPOE_CODE_PADR 0x19 /* Active Discovery Request */ -#define PPPOE_CODE_PADS 0x65 /* Active Discovery Session confirmation */ -#define PPPOE_CODE_PADT 0xA7 /* Active Discovery Terminate */ - -#ifndef ETHERMTU -#define ETHERMTU 1500 -#endif - -/* two byte PPP protocol discriminator, then IP data */ -#define PPPOE_MAXMTU (ETHERMTU-PPPOE_HEADERLEN-2) - -#ifndef PPPOE_MAX_AC_COOKIE_LEN -#define PPPOE_MAX_AC_COOKIE_LEN 64 -#endif - -struct pppoe_softc { - struct pppoe_softc *next; - struct netif *sc_ethif; /* ethernet interface we are using */ - int sc_pd; /* ppp unit number */ - void (*sc_linkStatusCB)(int pd, int up); - - int sc_state; /* discovery phase or session connected */ - struct eth_addr sc_dest; /* hardware address of concentrator */ - u16_t sc_session; /* PPPoE session id */ - -#ifdef PPPOE_TODO - char *sc_service_name; /* if != NULL: requested name of service */ - char *sc_concentrator_name; /* if != NULL: requested concentrator id */ -#endif /* PPPOE_TODO */ - u8_t sc_ac_cookie[PPPOE_MAX_AC_COOKIE_LEN]; /* content of AC cookie we must echo back */ - size_t sc_ac_cookie_len; /* length of cookie data */ -#ifdef PPPOE_SERVER - u8_t *sc_hunique; /* content of host unique we must echo back */ - size_t sc_hunique_len; /* length of host unique */ -#endif - int sc_padi_retried; /* number of PADI retries already done */ - int sc_padr_retried; /* number of PADR retries already done */ -}; - - -#define pppoe_init() /* compatibility define, no initialization needed */ - -err_t pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr); -err_t pppoe_destroy(struct netif *ifp); - -int pppoe_connect(struct pppoe_softc *sc); -void pppoe_disconnect(struct pppoe_softc *sc); - -void pppoe_disc_input(struct netif *netif, struct pbuf *p); -void pppoe_data_input(struct netif *netif, struct pbuf *p); - -err_t pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb); - -/** used in ppp.c */ -#define PPPOE_HDRLEN (sizeof(struct eth_hdr) + PPPOE_HEADERLEN) - -#endif /* PPPOE_SUPPORT */ - -#endif /* PPP_OE_H */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/netif/slipif.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/netif/slipif.h deleted file mode 100644 index 7b6ce5e2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/netif/slipif.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - * Author: Adam Dunkels - * - */ -#ifndef __NETIF_SLIPIF_H__ -#define __NETIF_SLIPIF_H__ - -#include "lwip/opt.h" -#include "lwip/netif.h" - -/** Set this to 1 to start a thread that blocks reading on the serial line - * (using sio_read()). - */ -#ifndef SLIP_USE_RX_THREAD -#define SLIP_USE_RX_THREAD !NO_SYS -#endif - -/** Set this to 1 to enable functions to pass in RX bytes from ISR context. - * If enabled, slipif_received_byte[s]() process incoming bytes and put assembled - * packets on a queue, which is fed into lwIP from slipif_poll(). - * If disabled, slipif_poll() polls the serila line (using sio_tryread()). - */ -#ifndef SLIP_RX_FROM_ISR -#define SLIP_RX_FROM_ISR 0 -#endif - -/** Set this to 1 (default for SLIP_RX_FROM_ISR) to queue incoming packets - * received by slipif_received_byte[s]() as long as PBUF_POOL pbufs are available. - * If disabled, packets will be dropped if more than one packet is received. - */ -#ifndef SLIP_RX_QUEUE -#define SLIP_RX_QUEUE SLIP_RX_FROM_ISR -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -err_t slipif_init(struct netif * netif); -void slipif_poll(struct netif *netif); -#if SLIP_RX_FROM_ISR -void slipif_process_rxqueue(struct netif *netif); -void slipif_received_byte(struct netif *netif, u8_t data); -void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); -#endif /* SLIP_RX_FROM_ISR */ - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/posix/netdb.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/posix/netdb.h deleted file mode 100644 index 7134032d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/posix/netdb.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file - * This file is a posix wrapper for lwip/netdb.h. - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#include "lwip/netdb.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/posix/sys/socket.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/posix/sys/socket.h deleted file mode 100644 index f7c7066e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/lwip/src/include/posix/sys/socket.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file - * This file is a posix wrapper for lwip/sockets.h. - */ - -/* - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - * OF SUCH DAMAGE. - * - * This file is part of the lwIP TCP/IP stack. - * - */ - -#include "lwip/sockets.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/BRefTarget.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/BRefTarget.h deleted file mode 100644 index 4324605a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/BRefTarget.h +++ /dev/null @@ -1,114 +0,0 @@ -/** - * @file BRefTarget.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_B_REF_TARGET_H -#define BADVPN_B_REF_TARGET_H - -#include - -#include -#include - -/** - * Represents a reference-counted object. - */ -typedef struct BRefTarget_s BRefTarget; - -/** - * Callback function called after the reference count of a {@link BRefTarget} - * reaches has reached zero. At this point the BRefTarget object has already - * been invalidated, i.e. {@link BRefTarget_Ref} must not be called on this - * object after this handler is called. - */ -typedef void (*BRefTarget_func_release) (BRefTarget *o); - -struct BRefTarget_s { - BRefTarget_func_release func_release; - int refcnt; - DebugObject d_obj; -}; - -/** - * Initializes a reference target object. The initial reference count of the object - * is 1. The \a func_release argument specifies the function to be called from - * {@link BRefTarget_Deref} when the reference count reaches zero. - */ -static void BRefTarget_Init (BRefTarget *o, BRefTarget_func_release func_release); - -/** - * Decrements the reference count of a reference target object. If the reference - * count has reached zero, the object's {@link BRefTarget_func_release} function - * is called, and the object is considered destroyed. - */ -static void BRefTarget_Deref (BRefTarget *o); - -/** - * Increments the reference count of a reference target object. - * Returns 1 on success and 0 on failure. - */ -static int BRefTarget_Ref (BRefTarget *o) WARN_UNUSED; - -static void BRefTarget_Init (BRefTarget *o, BRefTarget_func_release func_release) -{ - ASSERT(func_release) - - o->func_release = func_release; - o->refcnt = 1; - - DebugObject_Init(&o->d_obj); -} - -static void BRefTarget_Deref (BRefTarget *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->refcnt > 0) - - o->refcnt--; - - if (o->refcnt == 0) { - DebugObject_Free(&o->d_obj); - o->func_release(o); - } -} - -static int BRefTarget_Ref (BRefTarget *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->refcnt > 0) - - if (o->refcnt == INT_MAX) { - return 0; - } - - o->refcnt++; - - return 1; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf16Decoder.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf16Decoder.h deleted file mode 100644 index 819ac94c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf16Decoder.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @file Utf16Decoder.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_UTF16DECODER_H -#define BADVPN_UTF16DECODER_H - -#include - -#include - -/** - * Decodes UTF-16 data into Unicode characters. - */ -typedef struct { - int cont; - uint32_t ch; -} Utf16Decoder; - -/** - * Initializes the UTF-16 decoder. - * - * @param o the object - */ -static void Utf16Decoder_Init (Utf16Decoder *o); - -/** - * Inputs a 16-bit value to the decoder. - * - * @param o the object - * @param b 16-bit value to input - * @param out_ch will receive a Unicode character if this function returns 1. - * If written, the character will be in the range 0 - 0x10FFFF, - * excluding the surrogate range 0xD800 - 0xDFFF. - * @return 1 if a Unicode character has been written to *out_ch, 0 if not - */ -static int Utf16Decoder_Input (Utf16Decoder *o, uint16_t b, uint32_t *out_ch); - -void Utf16Decoder_Init (Utf16Decoder *o) -{ - o->cont = 0; -} - -int Utf16Decoder_Input (Utf16Decoder *o, uint16_t b, uint32_t *out_ch) -{ - // high surrogate - if (b >= UINT16_C(0xD800) && b <= UINT16_C(0xDBFF)) { - // set continuation state - o->cont = 1; - - // add high bits - o->ch = (uint32_t)(b - UINT16_C(0xD800)) << 10; - - return 0; - } - - // low surrogate - if (b >= UINT16_C(0xDC00) && b <= UINT16_C(0xDFFF)) { - // check continuation - if (!o->cont) { - return 0; - } - - // add low bits - o->ch |= (b - UINT16_C(0xDC00)); - - // reset state - o->cont = 0; - - // don't report surrogates - if (o->ch >= UINT32_C(0xD800) && o->ch <= UINT32_C(0xDFFF)) { - return 0; - } - - // return character - *out_ch = o->ch; - return 1; - } - - // reset state - o->cont = 0; - - // return character - *out_ch = b; - return 1; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf16Encoder.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf16Encoder.h deleted file mode 100644 index 4900b426..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf16Encoder.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @file Utf16Encoder.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_UTF16ENCODER_H -#define BADVPN_UTF16ENCODER_H - -#include - -/** - * Encodes a Unicode character into a sequence of 16-bit values according to UTF-16. - * - * @param ch Unicode character to encode - * @param out will receive the encoded 16-bit values. Must have space for 2 values. - * @return number of 16-bit values written, 0-2, with 0 meaning the character cannot - * be encoded - */ -static int Utf16Encoder_EncodeCharacter (uint32_t ch, uint16_t *out); - -int Utf16Encoder_EncodeCharacter (uint32_t ch, uint16_t *out) -{ - if (ch <= UINT32_C(0xFFFF)) { - // surrogates - if (ch >= UINT32_C(0xD800) && ch <= UINT32_C(0xDFFF)) { - return 0; - } - - out[0] = ch; - return 1; - } - - if (ch <= UINT32_C(0x10FFFF)) { - uint32_t x = ch - UINT32_C(0x10000); - out[0] = UINT32_C(0xD800) + (x >> 10); - out[1] = UINT32_C(0xDC00) + (x & UINT32_C(0x3FF)); - return 2; - } - - return 0; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf8Decoder.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf8Decoder.h deleted file mode 100644 index c6412b18..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf8Decoder.h +++ /dev/null @@ -1,143 +0,0 @@ -/** - * @file Utf8Decoder.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_UTF8DECODER_H -#define BADVPN_UTF8DECODER_H - -#include - -#include - -/** - * Decodes UTF-8 data into Unicode characters. - */ -typedef struct { - int bytes; - int pos; - uint32_t ch; -} Utf8Decoder; - -/** - * Initializes the UTF-8 decoder. - * - * @param o the object - */ -static void Utf8Decoder_Init (Utf8Decoder *o); - -/** - * Inputs a byte to the decoder. - * - * @param o the object - * @param b byte to input - * @param out_ch will receive a Unicode character if this function returns 1. - * If written, the character will be in the range 0 - 0x10FFFF, - * excluding the surrogate range 0xD800 - 0xDFFF. - * @return 1 if a Unicode character has been written to *out_ch, 0 if not - */ -static int Utf8Decoder_Input (Utf8Decoder *o, uint8_t b, uint32_t *out_ch); - -void Utf8Decoder_Init (Utf8Decoder *o) -{ - o->bytes = 0; -} - -int Utf8Decoder_Input (Utf8Decoder *o, uint8_t b, uint32_t *out_ch) -{ - // one-byte character - if ((b & 128) == 0) { - o->bytes = 0; - *out_ch = b; - return 1; - } - - // start of two-byte character - if ((b & 224) == 192) { - o->bytes = 2; - o->pos = 1; - o->ch = (uint32_t)(b & 31) << 6; - return 0; - } - - // start of three-byte character - if ((b & 240) == 224) { - o->bytes = 3; - o->pos = 1; - o->ch = (uint32_t)(b & 15) << 12; - return 0; - } - - // start of four-byte character - if ((b & 248) == 240) { - o->bytes = 4; - o->pos = 1; - o->ch = (uint32_t)(b & 7) << 18; - return 0; - } - - // continuation of multi-byte character - if ((b & 192) == 128 && o->bytes > 0) { - ASSERT(o->bytes <= 4) - ASSERT(o->pos > 0) - ASSERT(o->pos < o->bytes) - - // add bits from this byte - o->ch |= (uint32_t)(b & 63) << (6 * (o->bytes - o->pos - 1)); - - // end of multi-byte character? - if (o->pos == o->bytes - 1) { - // reset state - o->bytes = 0; - - // don't report out-of-range characters - if (o->ch > UINT32_C(0x10FFFF)) { - return 0; - } - - // don't report surrogates - if (o->ch >= UINT32_C(0xD800) && o->ch <= UINT32_C(0xDFFF)) { - return 0; - } - - *out_ch = o->ch; - return 1; - } - - // increment byte index - o->pos++; - - return 0; - } - - // error, reset state - o->bytes = 0; - - return 0; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf8Encoder.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf8Encoder.h deleted file mode 100644 index 00eb5e68..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/Utf8Encoder.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @file Utf8Encoder.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_UTF8ENCODER_H -#define BADVPN_UTF8ENCODER_H - -#include - -/** - * Encodes a Unicode character into a sequence of bytes according to UTF-8. - * - * @param ch Unicode character to encode - * @param out will receive the encoded bytes. Must have space for 4 bytes. - * @return number of bytes written, 0-4, with 0 meaning the character cannot - * be encoded - */ -static int Utf8Encoder_EncodeCharacter (uint32_t ch, uint8_t *out); - -int Utf8Encoder_EncodeCharacter (uint32_t ch, uint8_t *out) -{ - if (ch <= UINT32_C(0x007F)) { - out[0] = ch; - return 1; - } - - if (ch <= UINT32_C(0x07FF)) { - out[0] = (0xC0 | (ch >> 6)); - out[1] = (0x80 | ((ch >> 0) & 0x3F)); - return 2; - } - - if (ch <= UINT32_C(0xFFFF)) { - // surrogates - if (ch >= UINT32_C(0xD800) && ch <= UINT32_C(0xDFFF)) { - return 0; - } - - out[0] = (0xE0 | (ch >> 12)); - out[1] = (0x80 | ((ch >> 6) & 0x3F)); - out[2] = (0x80 | ((ch >> 0) & 0x3F)); - return 3; - } - - if (ch < UINT32_C(0x10FFFF)) { - out[0] = (0xF0 | (ch >> 18)); - out[1] = (0x80 | ((ch >> 12) & 0x3F)); - out[2] = (0x80 | ((ch >> 6) & 0x3F)); - out[3] = (0x80 | ((ch >> 0) & 0x3F)); - return 4; - } - - return 0; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/arp_proto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/arp_proto.h deleted file mode 100644 index 71a6c98d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/arp_proto.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @file arp_proto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Definitions for the ARP protocol. - */ - -#ifndef BADVPN_ARP_PROTO_H -#define BADVPN_ARP_PROTO_H - -#include - -#include - -#define ARP_HARDWARE_TYPE_ETHERNET 1 - -#define ARP_OPCODE_REQUEST 1 -#define ARP_OPCODE_REPLY 2 - -B_START_PACKED -struct arp_packet { - uint16_t hardware_type; - uint16_t protocol_type; - uint8_t hardware_size; - uint8_t protocol_size; - uint16_t opcode; - uint8_t sender_mac[6]; - uint32_t sender_ip; - uint8_t target_mac[6]; - uint32_t target_ip; -} B_PACKED; -B_END_PACKED - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/array_length.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/array_length.h deleted file mode 100644 index 15de964c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/array_length.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @file array_length.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_ARRAY_LENGTH -#define BADVPN_ARRAY_LENGTH - -#define B_ARRAY_LENGTH(arr) (sizeof((arr)) / sizeof((arr)[0])) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ascii_utils.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ascii_utils.h deleted file mode 100644 index 2baa9fc2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ascii_utils.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file ascii_utils.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_ASCII_UTILS_H -#define BADVPN_ASCII_UTILS_H - -static char b_ascii_tolower (char c) -{ - return (c >= 'A' && c <= 'Z') ? (c + 32) : c; -} - -static char b_ascii_toupper (char c) -{ - return (c >= 'a' && c <= 'z') ? (c - 32) : c; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/balign.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/balign.h deleted file mode 100644 index 57152afb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/balign.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @file balign.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Integer alignment macros. - */ - -#ifndef BADVPN_MISC_BALIGN_H -#define BADVPN_MISC_BALIGN_H - -#include -#include - -/** - * Checks if aligning x up to n would overflow. - */ -static int balign_up_overflows (size_t x, size_t n) -{ - size_t r = x % n; - - return (r && x > SIZE_MAX - (n - r)); -} - -/** - * Aligns x up to n. - */ -static size_t balign_up (size_t x, size_t n) -{ - size_t r = x % n; - return (r ? x + (n - r) : x); -} - -/** - * Aligns x down to n. - */ -static size_t balign_down (size_t x, size_t n) -{ - return (x - (x % n)); -} - -/** - * Calculates the quotient of a and b, rounded up. - */ -static size_t bdivide_up (size_t a, size_t b) -{ - size_t r = a % b; - return (r > 0 ? a / b + 1 : a / b); -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/balloc.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/balloc.h deleted file mode 100644 index ff946b6a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/balloc.h +++ /dev/null @@ -1,248 +0,0 @@ -/** - * @file balloc.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Memory allocation functions. - */ - -#ifndef BADVPN_MISC_BALLOC_H -#define BADVPN_MISC_BALLOC_H - -#include -#include -#include -#include - -#include "misc/debug.h" -#include "misc/bsize.h" -#include "misc/maxalign.h" - -/** - * Allocates memory. - * - * @param bytes number of bytes to allocate. - * @return a non-NULL pointer to the memory, or NULL on failure. - * The memory allocated can be freed using {@link BFree}. - */ -static void * BAlloc (size_t bytes); - -/** - * Frees memory. - * - * @param m memory to free. Must have been obtained with {@link BAlloc}, - * {@link BAllocArray}, or {@link BAllocArray2}. May be NULL; - * in this case, this function does nothing. - */ -static void BFree (void *m); - -/** - * Changes the size of a memory block. On success, the memory block - * may be moved to a different address. - * - * @param m pointer to a memory block obtained from {@link BAlloc} - * or other functions in this group. If this is NULL, the - * call is equivalent to {@link BAlloc}(bytes). - * @param bytes new size of the memory block - * @return new pointer to the memory block, or NULL on failure - */ -static void * BRealloc (void *m, size_t bytes); - -/** - * Allocates memory, with size given as a {@link bsize_t}. - * - * @param bytes number of bytes to allocate. If the size is overflow, - * this function will return NULL. - * @return a non-NULL pointer to the memory, or NULL on failure. - * The memory allocated can be freed using {@link BFree}. - */ -static void * BAllocSize (bsize_t bytes); - -/** - * Allocates memory for an array. - * A check is first done to make sure the multiplication doesn't overflow; - * otherwise, this is equivalent to {@link BAlloc}(count * bytes). - * This may be slightly faster if 'bytes' is constant, because a division - * with 'bytes' is performed. - * - * @param count number of elements. - * @param bytes size of one array element. - * @return a non-NULL pointer to the memory, or NULL on failure. - * The memory allocated can be freed using {@link BFree}. - */ -static void * BAllocArray (size_t count, size_t bytes); - -/** - * Reallocates memory that was allocated using one of the allocation - * functions in this file. On success, the memory may be moved to a - * different address, leaving the old address invalid. - * - * @param mem pointer to an existing memory block. May be NULL, in which - * case this is equivalent to {@link BAllocArray}. - * @param count number of elements for reallocation - * @param bytes size of one array element for reallocation - * @return a non-NULL pointer to the address of the reallocated memory - * block, or NULL on failure. On failure, the original memory - * block is left intact. - */ -static void * BReallocArray (void *mem, size_t count, size_t bytes); - -/** - * Allocates memory for a two-dimensional array. - * - * Checks are first done to make sure the multiplications don't overflow; - * otherwise, this is equivalent to {@link BAlloc}((count2 * (count1 * bytes)). - * - * @param count2 number of elements in one dimension. - * @param count1 number of elements in the other dimension. - * @param bytes size of one array element. - * @return a non-NULL pointer to the memory, or NULL on failure. - * The memory allocated can be freed using {@link BFree}. - */ -static void * BAllocArray2 (size_t count2, size_t count1, size_t bytes); - -/** - * Adds to a size_t with overflow detection. - * - * @param s pointer to a size_t to add to - * @param add number to add - * @return 1 on success, 0 on failure - */ -static int BSizeAdd (size_t *s, size_t add); - -/** - * Aligns a size_t upwards with overflow detection. - * - * @param s pointer to a size_t to align - * @param align alignment value. Must be >0. - * @return 1 on success, 0 on failure - */ -static int BSizeAlign (size_t *s, size_t align); - -void * BAlloc (size_t bytes) -{ - if (bytes == 0) { - return malloc(1); - } - - return malloc(bytes); -} - -void BFree (void *m) -{ - free(m); -} - -void * BRealloc (void *m, size_t bytes) -{ - if (bytes == 0) { - return realloc(m, 1); - } - - return realloc(m, bytes); -} - -void * BAllocSize (bsize_t bytes) -{ - if (bytes.is_overflow) { - return NULL; - } - - return BAlloc(bytes.value); -} - -void * BAllocArray (size_t count, size_t bytes) -{ - if (count == 0 || bytes == 0) { - return malloc(1); - } - - if (count > SIZE_MAX / bytes) { - return NULL; - } - - return BAlloc(count * bytes); -} - -void * BReallocArray (void *mem, size_t count, size_t bytes) -{ - if (count == 0 || bytes == 0) { - return realloc(mem, 1); - } - - if (count > SIZE_MAX / bytes) { - return NULL; - } - - return realloc(mem, count * bytes); -} - -void * BAllocArray2 (size_t count2, size_t count1, size_t bytes) -{ - if (count2 == 0 || count1 == 0 || bytes == 0) { - return malloc(1); - } - - if (count1 > SIZE_MAX / bytes) { - return NULL; - } - - if (count2 > SIZE_MAX / (count1 * bytes)) { - return NULL; - } - - return BAlloc(count2 * (count1 * bytes)); -} - -int BSizeAdd (size_t *s, size_t add) -{ - ASSERT(s) - - if (add > SIZE_MAX - *s) { - return 0; - } - *s += add; - return 1; -} - -int BSizeAlign (size_t *s, size_t align) -{ - ASSERT(s) - ASSERT(align > 0) - - size_t mod = *s % align; - if (mod > 0) { - if (align - mod > SIZE_MAX - *s) { - return 0; - } - *s += align - mod; - } - return 1; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/blimits.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/blimits.h deleted file mode 100644 index 8bcdc2a7..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/blimits.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @file blimits.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_BLIMITS_H -#define BADVPN_BLIMITS_H - -#include - -#define BTYPE_IS_SIGNED(type) ((type)-1 < 0) - -#define BSIGNED_TYPE_MIN(type) ( \ - sizeof(type) == 1 ? INT8_MIN : ( \ - sizeof(type) == 2 ? INT16_MIN : ( \ - sizeof(type) == 4 ? INT32_MIN : ( \ - sizeof(type) == 8 ? INT64_MIN : 0)))) - -#define BSIGNED_TYPE_MAX(type) ( \ - sizeof(type) == 1 ? INT8_MAX : ( \ - sizeof(type) == 2 ? INT16_MAX : ( \ - sizeof(type) == 4 ? INT32_MAX : ( \ - sizeof(type) == 8 ? INT64_MAX : 0)))) - -#define BUNSIGNED_TYPE_MIN(type) ((type)0) - -#define BUNSIGNED_TYPE_MAX(type) ( \ - sizeof(type) == 1 ? UINT8_MAX : ( \ - sizeof(type) == 2 ? UINT16_MAX : ( \ - sizeof(type) == 4 ? UINT32_MAX : ( \ - sizeof(type) == 8 ? UINT64_MAX : 0)))) - -#define BTYPE_MIN(type) (BTYPE_IS_SIGNED(type) ? BSIGNED_TYPE_MIN(type) : BUNSIGNED_TYPE_MIN(type)) -#define BTYPE_MAX(type) (BTYPE_IS_SIGNED(type) ? BSIGNED_TYPE_MAX(type) : BUNSIGNED_TYPE_MAX(type)) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/bsize.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/bsize.h deleted file mode 100644 index c28dbf69..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/bsize.h +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @file bsize.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Arithmetic with overflow detection. - */ - -#ifndef BADVPN_MISC_BSIZE_H -#define BADVPN_MISC_BSIZE_H - -#include -#include -#include - -typedef struct { - int is_overflow; - size_t value; -} bsize_t; - -static bsize_t bsize_fromsize (size_t v); -static bsize_t bsize_fromint (int v); -static bsize_t bsize_overflow (void); -static int bsize_tosize (bsize_t s, size_t *out); -static int bsize_toint (bsize_t s, int *out); -static bsize_t bsize_add (bsize_t s1, bsize_t s2); -static bsize_t bsize_max (bsize_t s1, bsize_t s2); -static bsize_t bsize_mul (bsize_t s1, bsize_t s2); - -bsize_t bsize_fromsize (size_t v) -{ - bsize_t s = {0, v}; - return s; -} - -bsize_t bsize_fromint (int v) -{ - bsize_t s = {(v < 0 || v > SIZE_MAX), v}; - return s; -} - -static bsize_t bsize_overflow (void) -{ - bsize_t s = {1, 0}; - return s; -} - -int bsize_tosize (bsize_t s, size_t *out) -{ - if (s.is_overflow) { - return 0; - } - - if (out) { - *out = s.value; - } - - return 1; -} - -int bsize_toint (bsize_t s, int *out) -{ - if (s.is_overflow || s.value > INT_MAX) { - return 0; - } - - if (out) { - *out = (int)s.value; - } - - return 1; -} - -bsize_t bsize_add (bsize_t s1, bsize_t s2) -{ - bsize_t s = {(s1.is_overflow || s2.is_overflow || s2.value > SIZE_MAX - s1.value), (s1.value + s2.value)}; - return s; -} - -bsize_t bsize_max (bsize_t s1, bsize_t s2) -{ - bsize_t s = {(s1.is_overflow || s2.is_overflow), ((s1.value > s2.value) * s1.value + (s1.value <= s2.value) * s2.value)}; - return s; -} - -bsize_t bsize_mul (bsize_t s1, bsize_t s2) -{ - bsize_t s = {(s1.is_overflow || s2.is_overflow || (s1.value != 0 && s2.value > SIZE_MAX / s1.value)), (s1.value * s2.value)}; - return s; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/bsort.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/bsort.h deleted file mode 100644 index 24d7a66a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/bsort.h +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @file bsort.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Sorting functions. - */ - -#ifndef BADVPN_MISC_BSORT_H -#define BADVPN_MISC_BSORT_H - -#include -#include -#include - -#include -#include - -typedef int (*BSort_comparator) (const void *e1, const void *e2); - -static void BInsertionSort (void *arr, size_t count, size_t esize, BSort_comparator compatator, void *temp); - -void BInsertionSort (void *arr, size_t count, size_t esize, BSort_comparator compatator, void *temp) -{ - ASSERT(esize > 0) - - for (size_t i = 0; i < count; i++) { - size_t j = i; - while (j > 0) { - uint8_t *x = (uint8_t *)arr + (j - 1) * esize; - uint8_t *y = (uint8_t *)arr + j * esize; - int c = compatator(x, y); - if (c <= 0) { - break; - } - memcpy(temp, x, esize); - memcpy(x, y, esize); - memcpy(y, temp, esize); - j--; - } - } -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/bstring.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/bstring.h deleted file mode 100644 index caef1062..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/bstring.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @file bstring.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_BSTRING_H -#define BADVPN_BSTRING_H - -#include - -#include -#include - -#define BSTRING_TYPE_STATIC 5 -#define BSTRING_TYPE_DYNAMIC 7 -#define BSTRING_TYPE_EXTERNAL 11 - -#define BSTRING_STATIC_SIZE 23 -#define BSTRING_STATIC_MAX (BSTRING_STATIC_SIZE - 1) - -typedef struct { - union { - struct { - char type; - char static_string[BSTRING_STATIC_SIZE]; - } us; - struct { - char type; - char *dynamic_string; - } ud; - struct { - char type; - const char *external_string; - } ue; - } u; -} BString; - -static void BString__assert (BString *o) -{ - switch (o->u.us.type) { - case BSTRING_TYPE_STATIC: - case BSTRING_TYPE_DYNAMIC: - case BSTRING_TYPE_EXTERNAL: - return; - } - - ASSERT(0); -} - -static int BString_Init (BString *o, const char *str) -{ - if (strlen(str) <= BSTRING_STATIC_MAX) { - strcpy(o->u.us.static_string, str); - o->u.us.type = BSTRING_TYPE_STATIC; - } else { - if (!(o->u.ud.dynamic_string = malloc(strlen(str) + 1))) { - return 0; - } - strcpy(o->u.ud.dynamic_string, str); - o->u.ud.type = BSTRING_TYPE_DYNAMIC; - } - - BString__assert(o); - return 1; -} - -static void BString_InitStatic (BString *o, const char *str) -{ - ASSERT(strlen(str) <= BSTRING_STATIC_MAX) - - strcpy(o->u.us.static_string, str); - o->u.us.type = BSTRING_TYPE_STATIC; - - BString__assert(o); -} - -static void BString_InitExternal (BString *o, const char *str) -{ - o->u.ue.external_string = str; - o->u.ue.type = BSTRING_TYPE_EXTERNAL; - - BString__assert(o); -} - -static void BString_InitAllocated (BString *o, char *str) -{ - o->u.ud.dynamic_string = str; - o->u.ud.type = BSTRING_TYPE_DYNAMIC; - - BString__assert(o); -} - -static void BString_Free (BString *o) -{ - BString__assert(o); - - if (o->u.ud.type == BSTRING_TYPE_DYNAMIC) { - free(o->u.ud.dynamic_string); - } -} - -static const char * BString_Get (BString *o) -{ - BString__assert(o); - - switch (o->u.us.type) { - case BSTRING_TYPE_STATIC: return o->u.us.static_string; - case BSTRING_TYPE_DYNAMIC: return o->u.ud.dynamic_string; - case BSTRING_TYPE_EXTERNAL: return o->u.ue.external_string; - } - - ASSERT(0); - return NULL; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/byteorder.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/byteorder.h deleted file mode 100644 index 055b0a59..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/byteorder.h +++ /dev/null @@ -1,196 +0,0 @@ -/** - * @file byteorder.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Byte order conversion functions. - * - * hton* functions convert from host to big-endian (network) byte order. - * htol* functions convert from host to little-endian byte order. - * ntoh* functions convert from big-endian (network) to host byte order. - * ltoh* functions convert from little-endian to host byte order. - */ - -#ifndef BADVPN_MISC_BYTEORDER_H -#define BADVPN_MISC_BYTEORDER_H - -#if (defined(BADVPN_LITTLE_ENDIAN) + defined(BADVPN_BIG_ENDIAN)) != 1 -#error Unknown byte order or too many byte orders -#endif - -#include - -static uint16_t badvpn_reverse16 (uint16_t x) -{ - uint16_t y; - *((uint8_t *)&y+0) = *((uint8_t *)&x+1); - *((uint8_t *)&y+1) = *((uint8_t *)&x+0); - return y; -} - -static uint32_t badvpn_reverse32 (uint32_t x) -{ - uint32_t y; - *((uint8_t *)&y+0) = *((uint8_t *)&x+3); - *((uint8_t *)&y+1) = *((uint8_t *)&x+2); - *((uint8_t *)&y+2) = *((uint8_t *)&x+1); - *((uint8_t *)&y+3) = *((uint8_t *)&x+0); - return y; -} - -static uint64_t badvpn_reverse64 (uint64_t x) -{ - uint64_t y; - *((uint8_t *)&y+0) = *((uint8_t *)&x+7); - *((uint8_t *)&y+1) = *((uint8_t *)&x+6); - *((uint8_t *)&y+2) = *((uint8_t *)&x+5); - *((uint8_t *)&y+3) = *((uint8_t *)&x+4); - *((uint8_t *)&y+4) = *((uint8_t *)&x+3); - *((uint8_t *)&y+5) = *((uint8_t *)&x+2); - *((uint8_t *)&y+6) = *((uint8_t *)&x+1); - *((uint8_t *)&y+7) = *((uint8_t *)&x+0); - return y; -} - -static uint8_t hton8 (uint8_t x) -{ - return x; -} - -static uint8_t htol8 (uint8_t x) -{ - return x; -} - -#if defined(BADVPN_LITTLE_ENDIAN) - -static uint16_t hton16 (uint16_t x) -{ - return badvpn_reverse16(x); -} - -static uint32_t hton32 (uint32_t x) -{ - return badvpn_reverse32(x); -} - -static uint64_t hton64 (uint64_t x) -{ - return badvpn_reverse64(x); -} - -static uint16_t htol16 (uint16_t x) -{ - return x; -} - -static uint32_t htol32 (uint32_t x) -{ - return x; -} - -static uint64_t htol64 (uint64_t x) -{ - return x; -} - -#elif defined(BADVPN_BIG_ENDIAN) - -static uint16_t hton16 (uint16_t x) -{ - return x; -} - -static uint32_t hton32 (uint32_t x) -{ - return x; -} - -static uint64_t hton64 (uint64_t x) -{ - return x; -} - -static uint16_t htol16 (uint16_t x) -{ - return badvpn_reverse16(x); -} - -static uint32_t htol32 (uint32_t x) -{ - return badvpn_reverse32(x); -} - -static uint64_t htol64 (uint64_t x) -{ - return badvpn_reverse64(x); -} - -#endif - -static uint8_t ntoh8 (uint8_t x) -{ - return hton8(x); -} - -static uint16_t ntoh16 (uint16_t x) -{ - return hton16(x); -} - -static uint32_t ntoh32 (uint32_t x) -{ - return hton32(x); -} - -static uint64_t ntoh64 (uint64_t x) -{ - return hton64(x); -} - -static uint8_t ltoh8 (uint8_t x) -{ - return htol8(x); -} - -static uint16_t ltoh16 (uint16_t x) -{ - return htol16(x); -} - -static uint32_t ltoh32 (uint32_t x) -{ - return htol32(x); -} - -static uint64_t ltoh64 (uint64_t x) -{ - return htol64(x); -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/cmdline.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/cmdline.h deleted file mode 100644 index 396d7948..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/cmdline.h +++ /dev/null @@ -1,168 +0,0 @@ -/** - * @file cmdline.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Command line construction functions. - */ - -#ifndef BADVPN_MISC_CMDLINE_H -#define BADVPN_MISC_CMDLINE_H - -#include -#include - -#include -#include -#include -#include - -typedef struct { - struct ExpArray arr; - size_t n; -} CmdLine; - -static int CmdLine_Init (CmdLine *c); -static void CmdLine_Free (CmdLine *c); -static int CmdLine_Append (CmdLine *c, const char *str); -static int CmdLine_AppendNoNull (CmdLine *c, const char *str, size_t str_len); -static int CmdLine_AppendNoNullMr (CmdLine *c, MemRef mr); -static int CmdLine_AppendMulti (CmdLine *c, int num, ...); -static int CmdLine_Finish (CmdLine *c); -static char ** CmdLine_Get (CmdLine *c); - -static int _CmdLine_finished (CmdLine *c) -{ - return (c->n > 0 && ((char **)c->arr.v)[c->n - 1] == NULL); -} - -int CmdLine_Init (CmdLine *c) -{ - if (!ExpArray_init(&c->arr, sizeof(char *), 16)) { - return 0; - } - - c->n = 0; - - return 1; -} - -void CmdLine_Free (CmdLine *c) -{ - for (size_t i = 0; i < c->n; i++) { - free(((char **)c->arr.v)[i]); - } - - free(c->arr.v); -} - -int CmdLine_Append (CmdLine *c, const char *str) -{ - ASSERT(str) - ASSERT(!_CmdLine_finished(c)) - - if (!ExpArray_resize(&c->arr, c->n + 1)) { - return 0; - } - - if (!(((char **)c->arr.v)[c->n] = strdup(str))) { - return 0; - } - - c->n++; - - return 1; -} - -int CmdLine_AppendNoNull (CmdLine *c, const char *str, size_t str_len) -{ - ASSERT(str) - ASSERT(!memchr(str, '\0', str_len)) - ASSERT(!_CmdLine_finished(c)) - - if (!ExpArray_resize(&c->arr, c->n + 1)) { - return 0; - } - - if (!(((char **)c->arr.v)[c->n] = b_strdup_bin(str, str_len))) { - return 0; - } - - c->n++; - - return 1; -} - -int CmdLine_AppendNoNullMr (CmdLine *c, MemRef mr) -{ - return CmdLine_AppendNoNull(c, mr.ptr, mr.len); -} - -int CmdLine_AppendMulti (CmdLine *c, int num, ...) -{ - int res = 1; - - va_list vl; - va_start(vl, num); - - for (int i = 0; i < num; i++) { - const char *str = va_arg(vl, const char *); - if (!CmdLine_Append(c, str)) { - res = 0; - break; - } - } - - va_end(vl); - - return res; -} - -int CmdLine_Finish (CmdLine *c) -{ - ASSERT(!_CmdLine_finished(c)) - - if (!ExpArray_resize(&c->arr, c->n + 1)) { - return 0; - } - - ((char **)c->arr.v)[c->n] = NULL; - - c->n++; - - return 1; -} - -char ** CmdLine_Get (CmdLine *c) -{ - ASSERT(_CmdLine_finished(c)) - - return (char **)c->arr.v; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/compare.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/compare.h deleted file mode 100644 index 8d1a1b99..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/compare.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @file compare.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_COMPARE_H -#define BADVPN_COMPARE_H - -#define B_COMPARE(a, b) (((a) > (b)) - ((a) < (b))) -#define B_COMPARE_COMBINE(cmp1, cmp2) ((cmp1) ? (cmp1) : (cmp2)) -#define B_COMPARE2(a, b, c, d) B_COMPARE_COMBINE(B_COMPARE((a), (b)), B_COMPARE((c), (d))) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/concat_strings.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/concat_strings.h deleted file mode 100644 index 1166906c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/concat_strings.h +++ /dev/null @@ -1,85 +0,0 @@ -/** - * @file concat_strings.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Function for concatenating strings. - */ - -#ifndef BADVPN_MISC_CONCAT_STRINGS_H -#define BADVPN_MISC_CONCAT_STRINGS_H - -#include -#include -#include - -#include "misc/debug.h" - -static char * concat_strings (int num, ...) -{ - ASSERT(num >= 0) - - // calculate sum of lengths - size_t sum = 0; - va_list ap; - va_start(ap, num); - for (int i = 0; i < num; i++) { - const char *str = va_arg(ap, const char *); - size_t str_len = strlen(str); - if (str_len > SIZE_MAX - 1 - sum) { - va_end(ap); - return NULL; - } - sum += str_len; - } - va_end(ap); - - // allocate memory - char *res_str = (char *)malloc(sum + 1); - if (!res_str) { - return NULL; - } - - // copy strings - sum = 0; - va_start(ap, num); - for (int i = 0; i < num; i++) { - const char *str = va_arg(ap, const char *); - size_t str_len = strlen(str); - memcpy(res_str + sum, str, str_len); - sum += str_len; - } - va_end(ap); - - // terminate - res_str[sum] = '\0'; - - return res_str; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/dead.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/dead.h deleted file mode 100644 index 7f574219..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/dead.h +++ /dev/null @@ -1,134 +0,0 @@ -/** - * @file dead.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Dead mechanism definitions. - * - * The dead mechanism is a way for a piece of code to detect whether some - * specific event has occured during some operation (usually during calling - * a user-provided handler function), without requiring access to memory - * that might no longer be available because of the event. - * - * It works somehow like that: - * - * First a dead variable ({@link dead_t}) is allocated somewhere, and - * initialized with {@link DEAD_INIT}, e.g.: - * DEAD_INIT(dead); - * - * When the event that needs to be caught occurs, {@link DEAD_KILL} is - * called, e.g.: - * DEAD_KILL(dead); - * The memory used by the dead variable is no longer needed after - * that. - * - * If a piece of code needs to know whether the event occured during some - * operation (but it must not have occured before!), it puts {@link DEAD_ENTER}} - * in front of the operation, and does {@link DEAD_LEAVE} at the end. If - * {@link DEAD_LEAVE} returned nonzero, the event occured, otherwise it did - * not. Example: - * DEAD_ENTER(dead) - * HandlerFunction(); - * if (DEAD_LEAVE(dead)) { - * (event occured) - * } - * - * If is is needed to check for the event more than once in a single block, - * {@link DEAD_DECLARE} should be put somewhere before, and {@link DEAD_ENTER2} - * should be used instead of {@link DEAD_ENTER}. - * - * If it is needed to check for multiple events (dead variables) at the same - * time, DEAD_*_N macros should be used instead, specifying different - * identiers as the first argument for different dead variables. - */ - -#ifndef BADVPN_MISC_DEAD_H -#define BADVPN_MISC_DEAD_H - -#include - -/** - * Dead variable. - */ -typedef int *dead_t; - -/** - * Initializes a dead variable. - */ -#define DEAD_INIT(ptr) { ptr = NULL; } - -/** - * Kills the dead variable, - */ -#define DEAD_KILL(ptr) { if (ptr) *(ptr) = 1; } - -/** - * Kills the dead variable with the given value, or does nothing - * if the value is 0. The value will seen by {@link DEAD_KILLED}. - */ -#define DEAD_KILL_WITH(ptr, val) { if (ptr) *(ptr) = (val); } - -/** - * Declares dead catching variables. - */ -#define DEAD_DECLARE int badvpn__dead; dead_t badvpn__prev_ptr; - -/** - * Enters a dead catching using already declared dead catching variables. - * The dead variable must have been initialized with {@link DEAD_INIT}, - * and {@link DEAD_KILL} must not have been called yet. - * {@link DEAD_LEAVE2} must be called before the current scope is left. - */ -#define DEAD_ENTER2(ptr) { badvpn__dead = 0; badvpn__prev_ptr = ptr; ptr = &badvpn__dead; } - -/** - * Declares dead catching variables and enters a dead catching. - * The dead variable must have been initialized with {@link DEAD_INIT}, - * and {@link DEAD_KILL} must not have been called yet. - * {@link DEAD_LEAVE2} must be called before the current scope is left. - */ -#define DEAD_ENTER(ptr) DEAD_DECLARE DEAD_ENTER2(ptr) - -/** - * Leaves a dead catching. - */ -#define DEAD_LEAVE2(ptr) { if (!badvpn__dead) ptr = badvpn__prev_ptr; if (badvpn__prev_ptr) *badvpn__prev_ptr = badvpn__dead; } - -/** - * Returns 1 if {@link DEAD_KILL} was called for the dead variable, 0 otherwise. - * Must be called after entering a dead catching. - */ -#define DEAD_KILLED (badvpn__dead) - -#define DEAD_DECLARE_N(n) int badvpn__dead##n; dead_t badvpn__prev_ptr##n; -#define DEAD_ENTER2_N(n, ptr) { badvpn__dead##n = 0; badvpn__prev_ptr##n = ptr; ptr = &badvpn__dead##n;} -#define DEAD_ENTER_N(n, ptr) DEAD_DECLARE_N(n) DEAD_ENTER2_N(n, ptr) -#define DEAD_LEAVE2_N(n, ptr) { if (!badvpn__dead##n) ptr = badvpn__prev_ptr##n; if (badvpn__prev_ptr##n) *badvpn__prev_ptr##n = badvpn__dead##n; } -#define DEAD_KILLED_N(n) (badvpn__dead##n) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/debug.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/debug.h deleted file mode 100644 index 8e5b07fb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/debug.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @file debug.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Debugging macros. - */ - -/** - * @def DEBUG - * - * Macro for printing debugging text. Use the same way as printf, - * but without a newline. - * Prepends "function_name: " and appends a newline. - */ - -/** - * @def ASSERT_FORCE - * - * Macro for forced assertions. - * Evaluates the argument and terminates the program abnormally - * if the result is false. - */ - -/** - * @def ASSERT - * - * Macro for assertions. - * The argument may or may not be evaluated. - * If the argument is evaluated, it must not evaluate to false. - */ - -/** - * @def ASSERT_EXECUTE - * - * Macro for always-evaluated assertions. - * The argument is evaluated. - * The argument must not evaluate to false. - */ - -/** - * @def DEBUG_ZERO_MEMORY - * - * If debugging is enabled, zeroes the given memory region. - * First argument is pointer to the memory region, second is - * number of bytes. - */ - -/** - * @def WARN_UNUSED - * - * Tells the compiler that the result of a function should not be unused. - * Insert at the end of the declaration of a function before the semicolon. - */ - -/** - * @def B_USE - * - * This can be used to suppress warnings about unused variables. It can - * be applied to a variable or any expression. It does not evaluate the - * expression. - */ - -#ifndef BADVPN_MISC_DEBUG_H -#define BADVPN_MISC_DEBUG_H - -#include -#include -#include -#include -#include - -#define DEBUG(...) \ - { \ - fprintf(stderr, "%s: ", __FUNCTION__); \ - fprintf(stderr, __VA_ARGS__); \ - fprintf(stderr, "\n"); \ - } - -#define ASSERT_FORCE(e) \ - { \ - if (!(e)) { \ - fprintf(stderr, "%s:%d Assertion failed\n", __FILE__, __LINE__); \ - } \ - } - -#ifdef NDEBUG - #define DEBUG_ZERO_MEMORY(buf, len) {} - #define ASSERT(e) {} - #define ASSERT_EXECUTE(e) { (e); } -#else - #define DEBUG_ZERO_MEMORY(buf, len) { memset((buf), 0, (len)); } - #ifdef BADVPN_USE_C_ASSERT - #define ASSERT(e) { assert(e); } - #define ASSERT_EXECUTE(e) \ - { \ - int _assert_res = !!(e); \ - assert(_assert_res); \ - } - #else - #define ASSERT(e) ASSERT_FORCE(e) - #define ASSERT_EXECUTE(e) ASSERT_FORCE(e) - #endif -#endif - -#ifdef __GNUC__ - #define WARN_UNUSED __attribute__((warn_unused_result)) -#else - #define WARN_UNUSED -#endif - -#define B_USE(expr) (void)(sizeof((expr))); - -#define B_ASSERT_USE(expr) { ASSERT(expr) B_USE(expr) } - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/debugcounter.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/debugcounter.h deleted file mode 100644 index c305dbe5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/debugcounter.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @file debugcounter.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Counter for detecting leaks. - */ - -#ifndef BADVPN_MISC_DEBUGCOUNTER_H -#define BADVPN_MISC_DEBUGCOUNTER_H - -#include - -#include "misc/debug.h" - -/** - * Counter for detecting leaks. - */ -typedef struct { -#ifndef NDEBUG - int32_t c; -#endif -} DebugCounter; - -#ifndef NDEBUG -#define DEBUGCOUNTER_STATIC { 0 } -#else -#define DEBUGCOUNTER_STATIC {} -#endif - -/** - * Initializes the object. - * The object is initialized with counter value zero. - * - * @param obj the object - */ -static void DebugCounter_Init (DebugCounter *obj) -{ -#ifndef NDEBUG - obj->c = 0; -#endif -} - -/** - * Frees the object. - * This does not have to be called when the counter is no longer needed. - * The counter value must be zero. - * - * @param obj the object - */ -static void DebugCounter_Free (DebugCounter *obj) -{ -#ifndef NDEBUG - ASSERT(obj->c == 0 || obj->c == INT32_MAX) -#endif -} - -/** - * Increments the counter. - * Increments the counter value by one. - * - * @param obj the object - */ -static void DebugCounter_Increment (DebugCounter *obj) -{ -#ifndef NDEBUG - ASSERT(obj->c >= 0) - - if (obj->c != INT32_MAX) { - obj->c++; - } -#endif -} - -/** - * Decrements the counter. - * The counter value must be >0. - * Decrements the counter value by one. - * - * @param obj the object - */ -static void DebugCounter_Decrement (DebugCounter *obj) -{ -#ifndef NDEBUG - ASSERT(obj->c > 0) - - if (obj->c != INT32_MAX) { - obj->c--; - } -#endif -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/debugerror.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/debugerror.h deleted file mode 100644 index 44dc6859..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/debugerror.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file debugerror.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Mechanism for ensuring an object is destroyed from inside an error handler - * or its jobs. - */ - -#ifndef BADVPN_MISC_DEBUGERROR_H -#define BADVPN_MISC_DEBUGERROR_H - -#include "misc/debug.h" -#include "base/BPending.h" - -#ifndef NDEBUG - #define DEBUGERROR(de, call) \ - { \ - ASSERT(!BPending_IsSet(&(de)->job)) \ - BPending_Set(&(de)->job); \ - (call); \ - } -#else - #define DEBUGERROR(de, call) { (call); } -#endif - -typedef struct { - #ifndef NDEBUG - BPending job; - #endif -} DebugError; - -static void DebugError_Init (DebugError *o, BPendingGroup *pg); -static void DebugError_Free (DebugError *o); -static void DebugError_AssertNoError (DebugError *o); - -#ifndef NDEBUG -static void _DebugError_job_handler (DebugError *o) -{ - ASSERT(0); -} -#endif - -void DebugError_Init (DebugError *o, BPendingGroup *pg) -{ - #ifndef NDEBUG - BPending_Init(&o->job, pg, (BPending_handler)_DebugError_job_handler, o); - #endif -} - -void DebugError_Free (DebugError *o) -{ - #ifndef NDEBUG - BPending_Free(&o->job); - #endif -} - -void DebugError_AssertNoError (DebugError *o) -{ - #ifndef NDEBUG - ASSERT(!BPending_IsSet(&o->job)) - #endif -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/dhcp_proto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/dhcp_proto.h deleted file mode 100644 index ed835445..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/dhcp_proto.h +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @file dhcp_proto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Definitions for the DHCP protocol. - */ - -#ifndef BADVPN_MISC_DHCP_PROTO_H -#define BADVPN_MISC_DHCP_PROTO_H - -#include - -#include - -#define DHCP_OP_BOOTREQUEST 1 -#define DHCP_OP_BOOTREPLY 2 - -#define DHCP_HARDWARE_ADDRESS_TYPE_ETHERNET 1 - -#define DHCP_MAGIC 0x63825363 - -#define DHCP_OPTION_PAD 0 -#define DHCP_OPTION_END 255 - -#define DHCP_OPTION_SUBNET_MASK 1 -#define DHCP_OPTION_ROUTER 3 -#define DHCP_OPTION_DOMAIN_NAME_SERVER 6 -#define DHCP_OPTION_HOST_NAME 12 -#define DHCP_OPTION_REQUESTED_IP_ADDRESS 50 -#define DHCP_OPTION_IP_ADDRESS_LEASE_TIME 51 -#define DHCP_OPTION_DHCP_MESSAGE_TYPE 53 -#define DHCP_OPTION_DHCP_SERVER_IDENTIFIER 54 -#define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 -#define DHCP_OPTION_MAXIMUM_MESSAGE_SIZE 57 -#define DHCP_OPTION_RENEWAL_TIME_VALUE 58 -#define DHCP_OPTION_REBINDING_TIME_VALUE 59 -#define DHCP_OPTION_VENDOR_CLASS_IDENTIFIER 60 -#define DHCP_OPTION_CLIENT_IDENTIFIER 61 - -#define DHCP_MESSAGE_TYPE_DISCOVER 1 -#define DHCP_MESSAGE_TYPE_OFFER 2 -#define DHCP_MESSAGE_TYPE_REQUEST 3 -#define DHCP_MESSAGE_TYPE_DECLINE 4 -#define DHCP_MESSAGE_TYPE_ACK 5 -#define DHCP_MESSAGE_TYPE_NAK 6 -#define DHCP_MESSAGE_TYPE_RELEASE 7 - -B_START_PACKED -struct dhcp_header { - uint8_t op; - uint8_t htype; - uint8_t hlen; - uint8_t hops; - uint32_t xid; - uint16_t secs; - uint16_t flags; - uint32_t ciaddr; - uint32_t yiaddr; - uint32_t siaddr; - uint32_t giaddr; - uint8_t chaddr[16]; - uint8_t sname[64]; - uint8_t file[128]; - uint32_t magic; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct dhcp_option_header { - uint8_t type; - uint8_t len; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct dhcp_option_dhcp_message_type { - uint8_t type; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct dhcp_option_maximum_message_size { - uint16_t size; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct dhcp_option_dhcp_server_identifier { - uint32_t id; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct dhcp_option_time { - uint32_t time; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct dhcp_option_addr { - uint32_t addr; -} B_PACKED; -B_END_PACKED - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ethernet_proto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ethernet_proto.h deleted file mode 100644 index 6e49e02b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ethernet_proto.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @file ethernet_proto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Definitions for the Ethernet protocol. - */ - -#ifndef BADVPN_MISC_ETHERNET_PROTO_H -#define BADVPN_MISC_ETHERNET_PROTO_H - -#include - -#include - -#define ETHERTYPE_IPV4 0x0800 -#define ETHERTYPE_ARP 0x0806 - -B_START_PACKED -struct ethernet_header { - uint8_t dest[6]; - uint8_t source[6]; - uint16_t type; -} B_PACKED; -B_END_PACKED - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/exparray.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/exparray.h deleted file mode 100644 index b24149f8..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/exparray.h +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file exparray.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Dynamic array which grows exponentionally on demand. - */ - -#ifndef BADVPN_MISC_EXPARRAY_H -#define BADVPN_MISC_EXPARRAY_H - -#include -#include -#include - -#include - -struct ExpArray { - size_t esize; - size_t size; - void *v; -}; - -static int ExpArray_init (struct ExpArray *o, size_t esize, size_t size) -{ - ASSERT(esize > 0) - ASSERT(size > 0) - - o->esize = esize; - o->size = size; - - if (o->size > SIZE_MAX / o->esize) { - return 0; - } - - if (!(o->v = malloc(o->size * o->esize))) { - return 0; - } - - return 1; -} - -static int ExpArray_resize (struct ExpArray *o, size_t size) -{ - ASSERT(size > 0) - - if (size <= o->size) { - return 1; - } - - size_t newsize = o->size; - - while (newsize < size) { - if (2 > SIZE_MAX / newsize) { - return 0; - } - - newsize = 2 * newsize; - } - - if (newsize > SIZE_MAX / o->esize) { - return 0; - } - - void *newarr = realloc(o->v, newsize * o->esize); - if (!newarr) { - return 0; - } - - o->size = newsize; - o->v = newarr; - - return 1; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/expstring.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/expstring.h deleted file mode 100644 index 8081e2f7..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/expstring.h +++ /dev/null @@ -1,174 +0,0 @@ -/** - * @file expstring.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_MISC_EXPSTRING_H -#define BADVPN_MISC_EXPSTRING_H - -#include - -#include -#include -#include -#include - -typedef struct { - struct ExpArray arr; - size_t n; -} ExpString; - -static int ExpString_Init (ExpString *c); -static void ExpString_Free (ExpString *c); -static int ExpString_Append (ExpString *c, const char *str); -static int ExpString_AppendChar (ExpString *c, char ch); -static int ExpString_AppendByte (ExpString *c, uint8_t x); -static int ExpString_AppendBinary (ExpString *c, const uint8_t *data, size_t len); -static int ExpString_AppendBinaryMr (ExpString *c, MemRef data); -static int ExpString_AppendZeros (ExpString *c, size_t len); -static char * ExpString_Get (ExpString *c); -static size_t ExpString_Length (ExpString *c); -static MemRef ExpString_GetMr (ExpString *c); - -int ExpString_Init (ExpString *c) -{ - if (!ExpArray_init(&c->arr, 1, 16)) { - return 0; - } - - c->n = 0; - ((char *)c->arr.v)[c->n] = '\0'; - - return 1; -} - -void ExpString_Free (ExpString *c) -{ - free(c->arr.v); -} - -int ExpString_Append (ExpString *c, const char *str) -{ - ASSERT(str) - - size_t l = strlen(str); - bsize_t newsize = bsize_add(bsize_fromsize(c->n), bsize_add(bsize_fromsize(l), bsize_fromint(1))); - - if (newsize.is_overflow || !ExpArray_resize(&c->arr, newsize.value)) { - return 0; - } - - memcpy((char *)c->arr.v + c->n, str, l); - c->n += l; - ((char *)c->arr.v)[c->n] = '\0'; - - return 1; -} - -int ExpString_AppendChar (ExpString *c, char ch) -{ - ASSERT(ch != '\0') - - bsize_t newsize = bsize_add(bsize_fromsize(c->n), bsize_fromint(2)); - - if (newsize.is_overflow || !ExpArray_resize(&c->arr, newsize.value)) { - return 0; - } - - ((char *)c->arr.v)[c->n] = ch; - c->n++; - ((char *)c->arr.v)[c->n] = '\0'; - - return 1; -} - -int ExpString_AppendByte (ExpString *c, uint8_t x) -{ - bsize_t newsize = bsize_add(bsize_fromsize(c->n), bsize_fromint(2)); - - if (newsize.is_overflow || !ExpArray_resize(&c->arr, newsize.value)) { - return 0; - } - - ((uint8_t *)c->arr.v)[c->n] = x; - c->n++; - ((char *)c->arr.v)[c->n] = '\0'; - - return 1; -} - -int ExpString_AppendBinary (ExpString *c, const uint8_t *data, size_t len) -{ - bsize_t newsize = bsize_add(bsize_fromsize(c->n), bsize_add(bsize_fromsize(len), bsize_fromint(1))); - - if (newsize.is_overflow || !ExpArray_resize(&c->arr, newsize.value)) { - return 0; - } - - memcpy((char *)c->arr.v + c->n, data, len); - c->n += len; - ((char *)c->arr.v)[c->n] = '\0'; - - return 1; -} - -int ExpString_AppendBinaryMr (ExpString *c, MemRef data) -{ - return ExpString_AppendBinary(c, (uint8_t const *)data.ptr, data.len); -} - -int ExpString_AppendZeros (ExpString *c, size_t len) -{ - bsize_t newsize = bsize_add(bsize_fromsize(c->n), bsize_add(bsize_fromsize(len), bsize_fromint(1))); - - if (newsize.is_overflow || !ExpArray_resize(&c->arr, newsize.value)) { - return 0; - } - - memset((char *)c->arr.v + c->n, 0, len); - c->n += len; - ((char *)c->arr.v)[c->n] = '\0'; - - return 1; -} - -char * ExpString_Get (ExpString *c) -{ - return (char *)c->arr.v; -} - -size_t ExpString_Length (ExpString *c) -{ - return c->n; -} - -MemRef ExpString_GetMr (ExpString *c) -{ - return MemRef_Make((char const *)c->arr.v, c->n); -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/find_char.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/find_char.h deleted file mode 100644 index a3a868e6..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/find_char.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file find_char.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_FIND_CHAR_H -#define BADVPN_FIND_CHAR_H - -#include - -#include "misc/debug.h" - -/** - * Finds the first character 'c' in the string represented by 'str' and 'len'. - * If found, returns 1 and writes the position to *out_pos (if out_pos!=NULL). - * If not found, returns 0 and does not modify *out_pos. - */ -static int b_find_char_bin (const char *str, size_t len, char c, size_t *out_pos) -{ - ASSERT(str) - - for (size_t i = 0; i < len; i++) { - if (str[i] == c) { - if (out_pos) { - *out_pos = i; - } - return 1; - } - } - - return 0; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/find_program.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/find_program.h deleted file mode 100644 index d381e185..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/find_program.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @file find_program.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Function that finds the absolute path of a program by checking a predefined - * list of directories. - */ - -#ifndef BADVPN_FIND_PROGRAM_H -#define BADVPN_FIND_PROGRAM_H - -#include -#include -#include - -#include -#include -#include - -static char * badvpn_find_program (const char *name); - -static char * badvpn_find_program (const char *name) -{ - ASSERT(name) - - char *path = getenv("PATH"); - if (path) { - while (1) { - size_t i = 0; - while (path[i] != ':' && path[i] != '\0') { - i++; - } - char const *src = path; - size_t src_len = i; - if (src_len == 0) { - src = "."; - src_len = 1; - } - size_t name_len = strlen(name); - char *entry = BAllocSize(bsize_add(bsize_fromsize(src_len), bsize_add(bsize_fromsize(name_len), bsize_fromsize(2)))); - if (!entry) { - goto fail; - } - memcpy(entry, src, src_len); - entry[src_len] = '/'; - strcpy(entry + (src_len + 1), name); - if (access(entry, X_OK) == 0) { - return entry; - } - free(entry); - if (path[i] == '\0') { - break; - } - path += i + 1; - } - } - - const char *dirs[] = {"/usr/sbin", "/usr/bin", "/sbin", "/bin", NULL}; - - for (size_t i = 0; dirs[i]; i++) { - char *try_path = concat_strings(3, dirs[i], "/", name); - if (!try_path) { - goto fail; - } - - if (access(try_path, X_OK) == 0) { - return try_path; - } - - free(try_path); - } - -fail: - return NULL; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/get_iface_info.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/get_iface_info.h deleted file mode 100644 index 190741b3..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/get_iface_info.h +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @file get_iface_info.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_GETIFACEINFO_H -#define BADVPN_GETIFACEINFO_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/** - * Returns information about a network interface with the given name. - * - * @param ifname name of interface to get information for - * @param out_mac the MAC address will be returned here, unless NULL - * @param out_mtu the MTU will be returned here, unless NULL - * @param out_ifindex the interface index will be returned here, unless NULL - * @return 1 on success, 0 on failure - */ -static int badvpn_get_iface_info (const char *ifname, uint8_t *out_mac, int *out_mtu, int *out_ifindex) WARN_UNUSED; - - -static int badvpn_get_iface_info (const char *ifname, uint8_t *out_mac, int *out_mtu, int *out_ifindex) -{ - ASSERT(ifname) - - struct ifreq ifr; - - int s = socket(AF_INET, SOCK_DGRAM, 0); - if (s < 0) { - goto fail0; - } - - // get MAC - if (out_mac) { - memset(&ifr, 0, sizeof(ifr)); - snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname); - if (ioctl(s, SIOCGIFHWADDR, &ifr)) { - goto fail1; - } - if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) { - goto fail1; - } - memcpy(out_mac, ifr.ifr_hwaddr.sa_data, 6); - } - - // get MTU - if (out_mtu) { - memset(&ifr, 0, sizeof(ifr)); - snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname); - if (ioctl(s, SIOCGIFMTU, &ifr)) { - goto fail1; - } - *out_mtu = ifr.ifr_mtu; - } - - // get interface index - if (out_ifindex) { - memset(&ifr, 0, sizeof(ifr)); - snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname); - if (ioctl(s, SIOCGIFINDEX, &ifr)) { - goto fail1; - } - *out_ifindex = ifr.ifr_ifindex; - } - - close(s); - - return 1; - -fail1: - close(s); -fail0: - return 0; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/grow_array.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/grow_array.h deleted file mode 100644 index 9a42d04c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/grow_array.h +++ /dev/null @@ -1,139 +0,0 @@ -/** - * @file grow_array.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Preprocessor inputs: -// GROWARRAY_NAME - prefix of of functions to define -// GROWARRAY_OBJECT_TYPE - type of structure where array and capacity sizes are -// GROWARRAY_ARRAY_MEMBER - array member -// GROWARRAY_CAPACITY_MEMBER - capacity member -// GROWARRAY_MAX_CAPACITY - max value of capacity member - -#include -#include -#include - -#include -#include -#include - -#define GrowArrayObject GROWARRAY_OBJECT_TYPE -#define GrowArray_Init MERGE(GROWARRAY_NAME, _Init) -#define GrowArray_InitEmpty MERGE(GROWARRAY_NAME, _InitEmpty) -#define GrowArray_Free MERGE(GROWARRAY_NAME, _Free) -#define GrowArray_DoubleUp MERGE(GROWARRAY_NAME, _DoubleUp) -#define GrowArray_DoubleUpLimit MERGE(GROWARRAY_NAME, _DoubleUpLimit) - -static int GrowArray_Init (GrowArrayObject *o, size_t capacity) WARN_UNUSED; -static void GrowArray_InitEmpty (GrowArrayObject *o); -static void GrowArray_Free (GrowArrayObject *o); -static int GrowArray_DoubleUp (GrowArrayObject *o) WARN_UNUSED; -static int GrowArray_DoubleUpLimit (GrowArrayObject *o, size_t limit) WARN_UNUSED; - -static int GrowArray_Init (GrowArrayObject *o, size_t capacity) -{ - if (capacity > GROWARRAY_MAX_CAPACITY) { - return 0; - } - - if (capacity == 0) { - o->GROWARRAY_ARRAY_MEMBER = NULL; - } else { - if (!(o->GROWARRAY_ARRAY_MEMBER = BAllocArray(capacity, sizeof(o->GROWARRAY_ARRAY_MEMBER[0])))) { - return 0; - } - } - - o->GROWARRAY_CAPACITY_MEMBER = capacity; - - return 1; -} - -static void GrowArray_InitEmpty (GrowArrayObject *o) -{ - o->GROWARRAY_ARRAY_MEMBER = NULL; - o->GROWARRAY_CAPACITY_MEMBER = 0; -} - -static void GrowArray_Free (GrowArrayObject *o) -{ - if (o->GROWARRAY_ARRAY_MEMBER) { - BFree(o->GROWARRAY_ARRAY_MEMBER); - } -} - -static int GrowArray_DoubleUp (GrowArrayObject *o) -{ - return GrowArray_DoubleUpLimit(o, SIZE_MAX); -} - -static int GrowArray_DoubleUpLimit (GrowArrayObject *o, size_t limit) -{ - if (o->GROWARRAY_CAPACITY_MEMBER > SIZE_MAX / 2 || o->GROWARRAY_CAPACITY_MEMBER > GROWARRAY_MAX_CAPACITY / 2) { - return 0; - } - - size_t newcap = 2 * o->GROWARRAY_CAPACITY_MEMBER; - if (newcap == 0) { - newcap = 1; - } - - if (newcap > limit) { - newcap = limit; - if (newcap == o->GROWARRAY_CAPACITY_MEMBER) { - return 0; - } - } - - void *newarr = BAllocArray(newcap, sizeof(o->GROWARRAY_ARRAY_MEMBER[0])); - if (!newarr) { - return 0; - } - - memcpy(newarr, o->GROWARRAY_ARRAY_MEMBER, o->GROWARRAY_CAPACITY_MEMBER * sizeof(o->GROWARRAY_ARRAY_MEMBER[0])); - - BFree(o->GROWARRAY_ARRAY_MEMBER); - - o->GROWARRAY_ARRAY_MEMBER = newarr; - o->GROWARRAY_CAPACITY_MEMBER = newcap; - - return 1; -} - -#undef GROWARRAY_NAME -#undef GROWARRAY_OBJECT_TYPE -#undef GROWARRAY_ARRAY_MEMBER -#undef GROWARRAY_CAPACITY_MEMBER -#undef GROWARRAY_MAX_CAPACITY - -#undef GrowArrayObject -#undef GrowArray_Init -#undef GrowArray_InitEmpty -#undef GrowArray_Free -#undef GrowArray_DoubleUp -#undef GrowArray_DoubleUpLimit diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/hashfun.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/hashfun.h deleted file mode 100644 index 5e8956ab..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/hashfun.h +++ /dev/null @@ -1,60 +0,0 @@ -/** - * @file hashfun.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_HASHFUN_H -#define BADVPN_HASHFUN_H - -#include -#include - -static size_t badvpn_djb2_hash (const uint8_t *str) -{ - size_t hash = 5381; - int c; - - while (c = *str++) { - hash = ((hash << 5) + hash) + c; - } - - return hash; -} - -static size_t badvpn_djb2_hash_bin (const uint8_t *str, size_t str_len) -{ - size_t hash = 5381; - - while (str_len-- > 0) { - int c = *str++; - hash = ((hash << 5) + hash) + c; - } - - return hash; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/igmp_proto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/igmp_proto.h deleted file mode 100644 index 9188ea02..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/igmp_proto.h +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @file igmp_proto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Definitions for the IGMP protocol. - */ - -#ifndef BADVPN_MISC_IGMP_PROTO_H -#define BADVPN_MISC_IGMP_PROTO_H - -#include - -#include - -#define IGMP_TYPE_MEMBERSHIP_QUERY 0x11 -#define IGMP_TYPE_V1_MEMBERSHIP_REPORT 0x12 -#define IGMP_TYPE_V2_MEMBERSHIP_REPORT 0x16 -#define IGMP_TYPE_V3_MEMBERSHIP_REPORT 0x22 -#define IGMP_TYPE_V2_LEAVE_GROUP 0x17 - -#define IGMP_RECORD_TYPE_MODE_IS_INCLUDE 1 -#define IGMP_RECORD_TYPE_MODE_IS_EXCLUDE 2 -#define IGMP_RECORD_TYPE_CHANGE_TO_INCLUDE_MODE 3 -#define IGMP_RECORD_TYPE_CHANGE_TO_EXCLUDE_MODE 4 - -B_START_PACKED -struct igmp_source { - uint32_t addr; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct igmp_base { - uint8_t type; - uint8_t max_resp_code; - uint16_t checksum; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct igmp_v3_query_extra { - uint32_t group; - uint8_t reserved4_suppress1_qrv3; - uint8_t qqic; - uint16_t number_of_sources; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct igmp_v3_report_extra { - uint16_t reserved; - uint16_t number_of_group_records; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct igmp_v3_report_record { - uint8_t type; - uint8_t aux_data_len; - uint16_t number_of_sources; - uint32_t group; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct igmp_v2_extra { - uint32_t group; -} B_PACKED; -B_END_PACKED - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipaddr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipaddr.h deleted file mode 100644 index 6de58522..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipaddr.h +++ /dev/null @@ -1,201 +0,0 @@ -/** - * @file ipaddr.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * IP address parsing functions. - */ - -#ifndef BADVPN_MISC_IPADDR_H -#define BADVPN_MISC_IPADDR_H - -#include -#include - -#include -#include -#include -#include -#include -#include - -struct ipv4_ifaddr { - uint32_t addr; - int prefix; -}; - -static int ipaddr_parse_ipv4_addr (MemRef name, uint32_t *out_addr); -static int ipaddr_parse_ipv4_prefix (MemRef str, int *num); -static int ipaddr_parse_ipv4_ifaddr (MemRef str, struct ipv4_ifaddr *out); -static int ipaddr_ipv4_ifaddr_from_addr_mask (uint32_t addr, uint32_t mask, struct ipv4_ifaddr *out); -static uint32_t ipaddr_ipv4_mask_from_prefix (int prefix); -static int ipaddr_ipv4_prefix_from_mask (uint32_t mask, int *out_prefix); -static int ipaddr_ipv4_addrs_in_network (uint32_t addr1, uint32_t addr2, int netprefix); - -#define IPADDR_PRINT_MAX 19 - -static void ipaddr_print_addr (uint32_t addr, char *out); -static void ipaddr_print_ifaddr (struct ipv4_ifaddr ifaddr, char *out); - -int ipaddr_parse_ipv4_addr (MemRef name, uint32_t *out_addr) -{ - for (size_t i = 0; ; i++) { - size_t j; - for (j = 0; j < name.len && name.ptr[j] != '.'; j++); - - if ((j == name.len && i < 3) || (j < name.len && i == 3)) { - return 0; - } - - if (j < 1 || j > 3) { - return 0; - } - - uintmax_t d; - if (!parse_unsigned_integer(MemRef_SubTo(name, j), &d)) { - return 0; - } - - if (d > 255) { - return 0; - } - - ((uint8_t *)out_addr)[i] = d; - - if (i == 3) { - return 1; - } - - name.ptr += j + 1; - name.len -= j + 1; - } -} - -int ipaddr_parse_ipv4_prefix (MemRef str, int *num) -{ - uintmax_t d; - if (!parse_unsigned_integer(str, &d)) { - return 0; - } - if (d > 32) { - return 0; - } - - *num = d; - return 1; -} - -int ipaddr_parse_ipv4_ifaddr (MemRef str, struct ipv4_ifaddr *out) -{ - size_t slash_pos; - if (!MemRef_FindChar(str, '/', &slash_pos)) { - return 0; - } - - return (ipaddr_parse_ipv4_addr(MemRef_SubTo(str, slash_pos), &out->addr) && - ipaddr_parse_ipv4_prefix(MemRef_SubFrom(str, slash_pos + 1), &out->prefix)); -} - -int ipaddr_ipv4_ifaddr_from_addr_mask (uint32_t addr, uint32_t mask, struct ipv4_ifaddr *out) -{ - int prefix; - if (!ipaddr_ipv4_prefix_from_mask(mask, &prefix)) { - return 0; - } - - out->addr = addr; - out->prefix = prefix; - return 1; -} - -uint32_t ipaddr_ipv4_mask_from_prefix (int prefix) -{ - ASSERT(prefix >= 0) - ASSERT(prefix <= 32) - - uint32_t t = 0; - for (int i = 0; i < prefix; i++) { - t |= 1 << (32 - i - 1); - } - - return hton32(t); -} - -int ipaddr_ipv4_prefix_from_mask (uint32_t mask, int *out_prefix) -{ - uint32_t t = 0; - int i; - for (i = 0; i <= 32; i++) { - if (ntoh32(mask) == t) { - break; - } - if (i < 32) { - t |= (1 << (32 - i - 1)); - } - } - if (!(i <= 32)) { - return 0; - } - - *out_prefix = i; - return 1; -} - -int ipaddr_ipv4_addrs_in_network (uint32_t addr1, uint32_t addr2, int netprefix) -{ - ASSERT(netprefix >= 0) - ASSERT(netprefix <= 32) - - uint32_t mask = ipaddr_ipv4_mask_from_prefix(netprefix); - - return !!((addr1 & mask) == (addr2 & mask)); -} - -void ipaddr_print_addr (uint32_t addr, char *out) -{ - ASSERT(out) - - uint8_t *b = (uint8_t *)&addr; - - sprintf(out, "%"PRIu8".%"PRIu8".%"PRIu8".%"PRIu8, - b[0], b[1], b[2], b[3]); -} - -void ipaddr_print_ifaddr (struct ipv4_ifaddr ifaddr, char *out) -{ - ASSERT(ifaddr.prefix >= 0) - ASSERT(ifaddr.prefix <= 32) - ASSERT(out) - - uint8_t *b = (uint8_t *)&ifaddr.addr; - - sprintf(out, "%"PRIu8".%"PRIu8".%"PRIu8".%"PRIu8"/%d", - b[0], b[1], b[2], b[3], ifaddr.prefix); -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipaddr6.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipaddr6.h deleted file mode 100644 index 5befd790..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipaddr6.h +++ /dev/null @@ -1,383 +0,0 @@ -/** - * @file ipaddr6.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * IPv6 address parsing functions. - */ - -#ifndef BADVPN_MISC_IPADDR6_H -#define BADVPN_MISC_IPADDR6_H - -#include -#include -#include -#include - -#include "misc/debug.h" -#include "misc/byteorder.h" -#include "misc/parse_number.h" -#include "misc/find_char.h" -#include "misc/print_macros.h" -#include "misc/memref.h" - -struct ipv6_addr { - uint8_t bytes[16]; -}; - -struct ipv6_ifaddr { - struct ipv6_addr addr; - int prefix; -}; - -static int ipaddr6_parse_ipv6_addr (MemRef name, struct ipv6_addr *out_addr); -static int ipaddr6_parse_ipv6_prefix (MemRef str, int *out_num); -static int ipaddr6_parse_ipv6_ifaddr (MemRef str, struct ipv6_ifaddr *out); -static int ipaddr6_ipv6_ifaddr_from_addr_mask (struct ipv6_addr addr, struct ipv6_addr mask, struct ipv6_ifaddr *out); -static void ipaddr6_ipv6_mask_from_prefix (int prefix, struct ipv6_addr *out_mask); -static int ipaddr6_ipv6_prefix_from_mask (struct ipv6_addr mask, int *out_prefix); -static int ipaddr6_ipv6_addrs_in_network (struct ipv6_addr addr1, struct ipv6_addr addr2, int netprefix); - -#define IPADDR6_PRINT_MAX 44 - -static void ipaddr6_print_addr (struct ipv6_addr addr, char *out_buf); -static void ipaddr6_print_ifaddr (struct ipv6_ifaddr addr, char *out_buf); - -int ipaddr6_parse_ipv6_addr (MemRef name, struct ipv6_addr *out_addr) -{ - int num_blocks = 0; - int compress_pos = -1; - uint16_t block = 0; - int empty = 1; - - size_t i = 0; - - while (i < name.len) { - if (name.ptr[i] == '.') { - goto ipv4_ending; - } else if (name.ptr[i] == ':') { - int is_double = (i + 1 < name.len && name.ptr[i + 1] == ':'); - - if (i > 0) { - if (empty || num_blocks == 7) { - return 0; - } - out_addr->bytes[2 * num_blocks + 0] = block >> 8; - out_addr->bytes[2 * num_blocks + 1] = block & 0xFF; - num_blocks++; - block = 0; - empty = 1; - } - else if (!is_double) { - return 0; - } - - if (is_double) { - if (compress_pos != -1) { - return 0; - } - compress_pos = num_blocks; - } - - i += 1 + is_double; - } else { - int digit = decode_hex_digit(name.ptr[i]); - if (digit < 0) { - return 0; - } - if (block > UINT16_MAX / 16) { - return 0; - } - block *= 16; - if (digit > UINT16_MAX - block) { - return 0; - } - block += digit; - empty = 0; - i += 1; - } - } - - if (!empty) { - out_addr->bytes[2 * num_blocks + 0] = block >> 8; - out_addr->bytes[2 * num_blocks + 1] = block & 0xFF; - num_blocks++; - } - else if (num_blocks != compress_pos) { - return 0; - } - -ipv4_done: - if (compress_pos == -1) { - if (num_blocks != 8) { - return 0; - } - compress_pos = 0; - } - - int num_rear = num_blocks - compress_pos; - memmove(out_addr->bytes + 2 * (8 - num_rear), out_addr->bytes + 2 * compress_pos, 2 * num_rear); - memset(out_addr->bytes + 2 * compress_pos, 0, 2 * (8 - num_rear - compress_pos)); - - return 1; - -ipv4_ending: - if (empty || (num_blocks == 0 && compress_pos == -1)) { - return 0; - } - - while (name.ptr[i - 1] != ':') { - i--; - } - - uint8_t bytes[4]; - int cur_byte = 0; - uint8_t byte = 0; - empty = 1; - - while (i < name.len) { - if (name.ptr[i] == '.') { - if (empty || cur_byte == 3) { - return 0; - } - bytes[cur_byte] = byte; - cur_byte++; - byte = 0; - empty = 1; - } else { - if (!empty && byte == 0) { - return 0; - } - int digit = decode_decimal_digit(name.ptr[i]); - if (digit < 0) { - return 0; - } - if (byte > UINT8_MAX / 10) { - return 0; - } - byte *= 10; - if (digit > UINT8_MAX - byte) { - return 0; - } - byte += digit; - empty = 0; - } - i++; - } - - if (cur_byte != 3 || empty) { - return 0; - } - bytes[cur_byte] = byte; - - if (8 - num_blocks < 2) { - return 0; - } - memcpy(out_addr->bytes + 2 * num_blocks, bytes, 4); - num_blocks += 2; - - goto ipv4_done; -} - -int ipaddr6_parse_ipv6_prefix (MemRef str, int *out_num) -{ - uintmax_t d; - if (!parse_unsigned_integer(str, &d)) { - return 0; - } - if (d > 128) { - return 0; - } - - *out_num = d; - return 1; -} - -int ipaddr6_parse_ipv6_ifaddr (MemRef str, struct ipv6_ifaddr *out) -{ - size_t slash_pos; - if (!MemRef_FindChar(str, '/', &slash_pos)) { - return 0; - } - - return (ipaddr6_parse_ipv6_addr(MemRef_SubTo(str, slash_pos), &out->addr) && - ipaddr6_parse_ipv6_prefix(MemRef_SubFrom(str, slash_pos + 1), &out->prefix)); -} - -int ipaddr6_ipv6_ifaddr_from_addr_mask (struct ipv6_addr addr, struct ipv6_addr mask, struct ipv6_ifaddr *out) -{ - int prefix; - if (!ipaddr6_ipv6_prefix_from_mask(mask, &prefix)) { - return 0; - } - - out->addr = addr; - out->prefix = prefix; - return 1; -} - -void ipaddr6_ipv6_mask_from_prefix (int prefix, struct ipv6_addr *out_mask) -{ - ASSERT(prefix >= 0) - ASSERT(prefix <= 128) - - int quot = prefix / 8; - int rem = prefix % 8; - - if (quot > 0) { - memset(out_mask->bytes, UINT8_MAX, quot); - } - if (16 - quot > 0) { - memset(out_mask->bytes + quot, 0, 16 - quot); - } - - for (int i = 0; i < rem; i++) { - out_mask->bytes[quot] |= (uint8_t)1 << (8 - i - 1); - } -} - -int ipaddr6_ipv6_prefix_from_mask (struct ipv6_addr mask, int *out_prefix) -{ - int prefix = 0; - int i = 0; - - while (i < 16 && mask.bytes[i] == UINT8_MAX) { - prefix += 8; - i++; - } - - if (i < 16) { - uint8_t t = 0; - int j; - for (j = 0; j <= 8; j++) { - if (mask.bytes[i] == t) { - break; - } - if (j < 8) { - t |= ((uint8_t)1 << (8 - j - 1)); - } - } - if (!(j <= 8)) { - return 0; - } - - prefix += j; - i++; - - while (i < 16) { - if (mask.bytes[i] != 0) { - return 0; - } - i++; - } - } - - *out_prefix = prefix; - return 1; -} - -int ipaddr6_ipv6_addrs_in_network (struct ipv6_addr addr1, struct ipv6_addr addr2, int netprefix) -{ - ASSERT(netprefix >= 0) - ASSERT(netprefix <= 128) - - int quot = netprefix / 8; - int rem = netprefix % 8; - - if (memcmp(addr1.bytes, addr2.bytes, quot)) { - return 0; - } - - if (rem == 0) { - return 1; - } - - uint8_t t = 0; - for (int i = 0; i < rem; i++) { - t |= (uint8_t)1 << (8 - i - 1); - } - - return ((addr1.bytes[quot] & t) == (addr2.bytes[quot] & t)); -} - -void ipaddr6_print_addr (struct ipv6_addr addr, char *out_buf) -{ - int largest_start = 0; - int largest_len = 0; - int current_start = 0; - int current_len = 0; - - for (int i = 0; i < 8; i++) { - if (addr.bytes[2 * i] == 0 && addr.bytes[2 * i + 1] == 0) { - current_len++; - if (current_len > largest_len) { - largest_start = current_start; - largest_len = current_len; - } - } else { - current_start = i + 1; - current_len = 0; - } - } - - if (largest_len > 1) { - for (int i = 0; i < largest_start; i++) { - uint16_t block = ((uint16_t)addr.bytes[2 * i] << 8) | addr.bytes[2 * i + 1]; - out_buf += sprintf(out_buf, "%"PRIx16":", block); - } - if (largest_start == 0) { - out_buf += sprintf(out_buf, ":"); - } - - for (int i = largest_start + largest_len; i < 8; i++) { - uint16_t block = ((uint16_t)addr.bytes[2 * i] << 8) | addr.bytes[2 * i + 1]; - out_buf += sprintf(out_buf, ":%"PRIx16, block); - } - if (largest_start + largest_len == 8) { - out_buf += sprintf(out_buf, ":"); - } - } else { - const char *prefix = ""; - for (int i = 0; i < 8; i++) { - uint16_t block = ((uint16_t)addr.bytes[2 * i] << 8) | addr.bytes[2 * i + 1]; - out_buf += sprintf(out_buf, "%s%"PRIx16, prefix, block); - prefix = ":"; - } - } -} - -void ipaddr6_print_ifaddr (struct ipv6_ifaddr addr, char *out_buf) -{ - ASSERT(addr.prefix >= 0) - ASSERT(addr.prefix <= 128) - - ipaddr6_print_addr(addr.addr, out_buf); - sprintf(out_buf + strlen(out_buf), "/%d", addr.prefix); -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipv4_proto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipv4_proto.h deleted file mode 100644 index cb10e110..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipv4_proto.h +++ /dev/null @@ -1,145 +0,0 @@ -/** - * @file ipv4_proto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Definitions for the IPv4 protocol. - */ - -#ifndef BADVPN_MISC_IPV4_PROTO_H -#define BADVPN_MISC_IPV4_PROTO_H - -#include -#include - -#include "misc/debug.h" -#include "misc/byteorder.h" -#include "misc/packed.h" -#include "misc/read_write_int.h" - -#define IPV4_PROTOCOL_IGMP 2 -#define IPV4_PROTOCOL_UDP 17 - -B_START_PACKED -struct ipv4_header { - uint8_t version4_ihl4; - uint8_t ds; - uint16_t total_length; - // - uint16_t identification; - uint16_t flags3_fragmentoffset13; - // - uint8_t ttl; - uint8_t protocol; - uint16_t checksum; - // - uint32_t source_address; - // - uint32_t destination_address; -} B_PACKED; -B_END_PACKED - -#define IPV4_GET_VERSION(_header) (((_header).version4_ihl4&0xF0)>>4) -#define IPV4_GET_IHL(_header) (((_header).version4_ihl4&0x0F)>>0) - -#define IPV4_MAKE_VERSION_IHL(size) (((size)/4) + (4 << 4)) - -static uint16_t ipv4_checksum (const struct ipv4_header *header, const char *extra, uint16_t extra_len) -{ - ASSERT(extra_len % 2 == 0) - ASSERT(extra_len == 0 || extra) - - uint32_t t = 0; - - for (uint16_t i = 0; i < sizeof(*header) / 2; i++) { - t += badvpn_read_be16((const char *)header + 2 * i); - } - - for (uint16_t i = 0; i < extra_len / 2; i++) { - t += badvpn_read_be16((const char *)extra + 2 * i); - } - - while (t >> 16) { - t = (t & 0xFFFF) + (t >> 16); - } - - return hton16(~t); -} - -static int ipv4_check (uint8_t *data, int data_len, struct ipv4_header *out_header, uint8_t **out_payload, int *out_payload_len) -{ - ASSERT(data_len >= 0) - ASSERT(out_header) - ASSERT(out_payload) - ASSERT(out_payload_len) - - // check base header - if (data_len < sizeof(struct ipv4_header)) { - return 0; - } - memcpy(out_header, data, sizeof(*out_header)); - - // check version - if (IPV4_GET_VERSION(*out_header) != 4) { - return 0; - } - - // check options - uint16_t header_len = IPV4_GET_IHL(*out_header) * 4; - if (header_len < sizeof(struct ipv4_header)) { - return 0; - } - if (header_len > data_len) { - return 0; - } - - // check total length - uint16_t total_length = ntoh16(out_header->total_length); - if (total_length < header_len) { - return 0; - } - if (total_length > data_len) { - return 0; - } - - // check checksum - uint16_t checksum_in_packet = out_header->checksum; - out_header->checksum = hton16(0); - uint16_t checksum_computed = ipv4_checksum(out_header, (char *)data + sizeof(*out_header), header_len - sizeof(*out_header)); - out_header->checksum = checksum_in_packet; - if (checksum_in_packet != checksum_computed) { - return 0; - } - - *out_payload = data + header_len; - *out_payload_len = total_length - header_len; - - return 1; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipv6_proto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipv6_proto.h deleted file mode 100644 index d681ea4f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/ipv6_proto.h +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @file ipv6_proto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_IPV6_PROTO_H -#define BADVPN_IPV6_PROTO_H - -#include -#include - -#include "misc/debug.h" -#include "misc/byteorder.h" -#include "misc/packed.h" - -#define IPV6_NEXT_IGMP 2 -#define IPV6_NEXT_UDP 17 - -B_START_PACKED -struct ipv6_header { - uint8_t version4_tc4; - uint8_t tc4_fl4; - uint16_t fl; - uint16_t payload_length; - uint8_t next_header; - uint8_t hop_limit; - uint8_t source_address[16]; - uint8_t destination_address[16]; -} B_PACKED; -B_END_PACKED - -static int ipv6_check (uint8_t *data, int data_len, struct ipv6_header *out_header, uint8_t **out_payload, int *out_payload_len) -{ - ASSERT(data_len >= 0) - ASSERT(out_header) - ASSERT(out_payload) - ASSERT(out_payload_len) - - // check base header - if (data_len < sizeof(struct ipv6_header)) { - return 0; - } - memcpy(out_header, data, sizeof(*out_header)); - - // check version - if ((ntoh8(out_header->version4_tc4) >> 4) != 6) { - return 0; - } - - // check payload length - uint16_t payload_length = ntoh16(out_header->payload_length); - if (payload_length > data_len - sizeof(struct ipv6_header)) { - return 0; - } - - *out_payload = data + sizeof(struct ipv6_header); - *out_payload_len = payload_length; - - return 1; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/loggers_string.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/loggers_string.h deleted file mode 100644 index 66986b84..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/loggers_string.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file loggers_string.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * List of available loggers. - */ - -#ifndef BADVPN_MISC_LOGGERSSTRING_H -#define BADVPN_MISC_LOGGERSSTRING_H - -#ifdef BADVPN_USE_WINAPI -#define LOGGERS_STRING "stdout" -#else -#define LOGGERS_STRING "stdout/syslog" -#endif - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/loglevel.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/loglevel.h deleted file mode 100644 index afe6a766..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/loglevel.h +++ /dev/null @@ -1,80 +0,0 @@ -/** - * @file loglevel.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Log level specification parsing function. - */ - -#ifndef BADVPN_MISC_LOGLEVEL_H -#define BADVPN_MISC_LOGLEVEL_H - -#include - -#include "base/BLog.h" - -/** - * Parses the log level string. - * - * @param str log level string. Recognizes none, error, warning, notice, - * info, debug. - * @return 0 for none, one of BLOG_* for some log level, -1 for unrecognized - */ -static int parse_loglevel (char *str); - -int parse_loglevel (char *str) -{ - if (!strcmp(str, "none")) { - return 0; - } - if (!strcmp(str, "error")) { - return BLOG_ERROR; - } - if (!strcmp(str, "warning")) { - return BLOG_WARNING; - } - if (!strcmp(str, "notice")) { - return BLOG_NOTICE; - } - if (!strcmp(str, "info")) { - return BLOG_INFO; - } - if (!strcmp(str, "debug")) { - return BLOG_DEBUG; - } - - char *endptr; - long int res = strtol(str, &endptr, 10); - if (*str && !*endptr && res >= 0 && res <= BLOG_DEBUG) { - return res; - } - - return -1; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/maxalign.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/maxalign.h deleted file mode 100644 index cb1f4605..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/maxalign.h +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @file maxalign.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_MAXALIGN_H -#define BADVPN_MAXALIGN_H - -#include -#include - -typedef union { - short a; - long b; - long long c; - double d; - long double e; - void *f; - uint8_t g; - uint16_t h; - uint32_t i; - uint64_t j; - size_t k; - void (*l) (void); -} bmax_align_t; - -#define BMAX_ALIGN (__alignof(bmax_align_t)) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/memref.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/memref.h deleted file mode 100644 index 1003b3c3..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/memref.h +++ /dev/null @@ -1,175 +0,0 @@ -/** - * @file memref.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_MEMREF_H -#define BADVPN_MEMREF_H - -#include -#include -#include - -#include "misc/debug.h" -#include "misc/balloc.h" -#include "misc/strdup.h" - -typedef struct { - char const *ptr; - size_t len; -} MemRef; - -static MemRef MemRef_Make (char const *ptr, size_t len); -static MemRef MemRef_MakeCstr (char const *ptr); -static char MemRef_At (MemRef o, size_t pos); -static void MemRef_AssertRange (MemRef o, size_t offset, size_t length); -static MemRef MemRef_SubFrom (MemRef o, size_t offset); -static MemRef MemRef_SubTo (MemRef o, size_t length); -static MemRef MemRef_Sub (MemRef o, size_t offset, size_t length); -static char * MemRef_StrDup (MemRef o); -static void MemRef_CopyOut (MemRef o, char *out); -static int MemRef_Equal (MemRef o, MemRef other); -static int MemRef_FindChar (MemRef o, char ch, size_t *out_index); - -#define MEMREF_LOOP_CHARS__BODY(char_rel_pos_var, char_var, body) \ -{ \ - for (size_t char_rel_pos_var = 0; char_rel_pos_var < MemRef__Loop_length; char_rel_pos_var++) { \ - char char_var = MemRef__Loop_o.ptr[MemRef__Loop_offset + char_rel_pos_var]; \ - { body } \ - } \ -} - -#define MEMREF_LOOP_CHARS_RANGE(o, offset, length, char_rel_pos_var, char_var, body) \ -{ \ - MemRef MemRef__Loop_o = (o); \ - size_t MemRef__Loop_offset = (offset); \ - size_t MemRef__Loop_length = (length); \ - MEMREF_LOOP_CHARS__BODY(char_rel_pos_var, char_var, body) \ -} - -#define MEMREF_LOOP_CHARS(o, char_rel_pos_var, char_var, body) \ -{ \ - MemRef MemRef__Loop_o = (o); \ - size_t MemRef__Loop_offset = 0; \ - size_t MemRef__Loop_length = MemRef__Loop_o.len; \ - MEMREF_LOOP_CHARS__BODY(char_rel_pos_var, char_var, body) \ -} - -// - -static MemRef MemRef_Make (char const *ptr, size_t len) -{ - MemRef res; - res.ptr = ptr; - res.len = len; - return res; -} - -static MemRef MemRef_MakeCstr (char const *ptr) -{ - ASSERT(ptr) - - return MemRef_Make(ptr, strlen(ptr)); -} - -static char MemRef_At (MemRef o, size_t pos) -{ - ASSERT(o.ptr) - ASSERT(pos < o.len) - - return o.ptr[pos]; -} - -static void MemRef_AssertRange (MemRef o, size_t offset, size_t length) -{ - ASSERT(offset <= o.len) - ASSERT(length <= o.len - offset) -} - -static MemRef MemRef_SubFrom (MemRef o, size_t offset) -{ - ASSERT(o.ptr) - ASSERT(offset <= o.len) - - return MemRef_Make(o.ptr + offset, o.len - offset); -} - -static MemRef MemRef_SubTo (MemRef o, size_t length) -{ - ASSERT(o.ptr) - ASSERT(length <= o.len) - - return MemRef_Make(o.ptr, length); -} - -static MemRef MemRef_Sub (MemRef o, size_t offset, size_t length) -{ - ASSERT(o.ptr) - MemRef_AssertRange(o, offset, length); - - return MemRef_Make(o.ptr + offset, length); -} - -static char * MemRef_StrDup (MemRef o) -{ - ASSERT(o.ptr) - - return b_strdup_bin(o.ptr, o.len); -} - -static void MemRef_CopyOut (MemRef o, char *out) -{ - ASSERT(o.ptr) - ASSERT(out) - - memcpy(out, o.ptr, o.len); -} - -static int MemRef_Equal (MemRef o, MemRef other) -{ - ASSERT(o.ptr) - ASSERT(other.ptr) - - return (o.len == other.len) && !memcmp(o.ptr, other.ptr, o.len); -} - -static int MemRef_FindChar (MemRef o, char ch, size_t *out_index) -{ - ASSERT(o.ptr) - - for (size_t i = 0; i < o.len; i++) { - if (o.ptr[i] == ch) { - if (out_index) { - *out_index = i; - } - return 1; - } - } - return 0; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/merge.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/merge.h deleted file mode 100644 index 53227712..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/merge.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file merge.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_MERGE_H -#define BADVPN_MERGE_H - -#define MERGE_HELPER(x, y) x ## y -#define MERGE(x, y) MERGE_HELPER(x, y) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/minmax.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/minmax.h deleted file mode 100644 index ca82055e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/minmax.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @file minmax.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Minimum and maximum macros. - */ - -#ifndef BADVPN_MISC_MINMAX_H -#define BADVPN_MISC_MINMAX_H - -#include -#include - -#define DEFINE_BMINMAX(name, type) \ -static type bmin ## name (type a, type b) { return (a < b ? a : b); } \ -static type bmax ## name (type a, type b) { return (a > b ? a : b); } - -DEFINE_BMINMAX(_size, size_t) -DEFINE_BMINMAX(_int, int) -DEFINE_BMINMAX(_int8, int8_t) -DEFINE_BMINMAX(_int16, int16_t) -DEFINE_BMINMAX(_int32, int32_t) -DEFINE_BMINMAX(_int64, int64_t) -DEFINE_BMINMAX(_uint, unsigned int) -DEFINE_BMINMAX(_uint8, uint8_t) -DEFINE_BMINMAX(_uint16, uint16_t) -DEFINE_BMINMAX(_uint32, uint32_t) -DEFINE_BMINMAX(_uint64, uint64_t) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/modadd.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/modadd.h deleted file mode 100644 index 4e4f04ad..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/modadd.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file modadd.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Modular addition macro. - * - * Calculates (x + y) mod m, assuming - * 0 <= x < m and 0 <= y < m. - */ - -#ifndef BADVPN_MISC_MODADD_H -#define BADVPN_MISC_MODADD_H - -#include - -#define DECLARE_BMODADD(type, name) \ -static type bmodadd_##name (type x, type y, type m) \ -{ \ - ASSERT(x >= 0) \ - ASSERT(x < m) \ - ASSERT(y >= 0) \ - ASSERT(y < m) \ - \ - if (y >= m - x) { \ - return (y - (m - x)); \ - } else { \ - return (x + y); \ - } \ -} \ - -DECLARE_BMODADD(int, int) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/mswsock.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/mswsock.h deleted file mode 100644 index 4f4c38df..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/mswsock.h +++ /dev/null @@ -1,229 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER.PD within this package. - */ - -#include - -#ifndef _MSWSOCK_ -#define _MSWSOCK_ - -#ifdef __cplusplus -extern "C" { -#endif - -#define SO_CONNDATA 0x7000 -#define SO_CONNOPT 0x7001 -#define SO_DISCDATA 0x7002 -#define SO_DISCOPT 0x7003 -#define SO_CONNDATALEN 0x7004 -#define SO_CONNOPTLEN 0x7005 -#define SO_DISCDATALEN 0x7006 -#define SO_DISCOPTLEN 0x7007 - -#define SO_OPENTYPE 0x7008 - -#define SO_SYNCHRONOUS_ALERT 0x10 -#define SO_SYNCHRONOUS_NONALERT 0x20 - -#define SO_MAXDG 0x7009 -#define SO_MAXPATHDG 0x700A -#define SO_UPDATE_ACCEPT_CONTEXT 0x700B -#define SO_CONNECT_TIME 0x700C -#define SO_UPDATE_CONNECT_CONTEXT 0x7010 - -#define TCP_BSDURGENT 0x7000 - -#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12) -#if (_WIN32_WINNT < 0x0600) && (_WIN32_WINNT >= 0x0501) -#define SIO_SOCKET_CLOSE_NOTIFY _WSAIOW(IOC_VENDOR,13) -#endif /* >= XP && < VISTA */ -#if (_WIN32_WINNT >= 0x0600) -#define SIO_BSP_HANDLE _WSAIOR(IOC_WS2,27) -#define SIO_BSP_HANDLE_SELECT _WSAIOR(IOC_WS2,28) -#define SIO_BSP_HANDLE_POLL _WSAIOR(IOC_WS2,29) - -#define SIO_EXT_SELECT _WSAIORW(IOC_WS2,30) -#define SIO_EXT_POLL _WSAIORW(IOC_WS2,31) -#define SIO_EXT_SENDMSG _WSAIORW(IOC_WS2,32) - -#define SIO_BASE_HANDLE _WSAIOR(IOC_WS2,34) -#endif /* _WIN32_WINNT >= 0x0600 */ - -#ifndef __MSWSOCK_WS1_SHARED - int WINAPI WSARecvEx(SOCKET s,char *buf,int len,int *flags); -#endif /* __MSWSOCK_WS1_SHARED */ - -#define TF_DISCONNECT 0x01 -#define TF_REUSE_SOCKET 0x02 -#define TF_WRITE_BEHIND 0x04 -#define TF_USE_DEFAULT_WORKER 0x00 -#define TF_USE_SYSTEM_THREAD 0x10 -#define TF_USE_KERNEL_APC 0x20 - -#include -#ifndef __MSWSOCK_WS1_SHARED - WINBOOL WINAPI TransmitFile(SOCKET hSocket,HANDLE hFile,DWORD nNumberOfBytesToWrite,DWORD nNumberOfBytesPerSend,LPOVERLAPPED lpOverlapped,LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,DWORD dwReserved); - WINBOOL WINAPI AcceptEx(SOCKET sListenSocket,SOCKET sAcceptSocket,PVOID lpOutputBuffer,DWORD dwReceiveDataLength,DWORD dwLocalAddressLength,DWORD dwRemoteAddressLength,LPDWORD lpdwBytesReceived,LPOVERLAPPED lpOverlapped); - VOID WINAPI GetAcceptExSockaddrs(PVOID lpOutputBuffer,DWORD dwReceiveDataLength,DWORD dwLocalAddressLength,DWORD dwRemoteAddressLength,struct sockaddr **LocalSockaddr,LPINT LocalSockaddrLength,struct sockaddr **RemoteSockaddr,LPINT RemoteSockaddrLength); -#endif /* __MSWSOCK_WS1_SHARED */ - - typedef WINBOOL (WINAPI *LPFN_TRANSMITFILE)(SOCKET hSocket,HANDLE hFile,DWORD nNumberOfBytesToWrite,DWORD nNumberOfBytesPerSend,LPOVERLAPPED lpOverlapped,LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,DWORD dwReserved); - -#define WSAID_TRANSMITFILE {0xb5367df0,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} - - typedef WINBOOL (WINAPI *LPFN_ACCEPTEX)(SOCKET sListenSocket,SOCKET sAcceptSocket,PVOID lpOutputBuffer,DWORD dwReceiveDataLength,DWORD dwLocalAddressLength,DWORD dwRemoteAddressLength,LPDWORD lpdwBytesReceived,LPOVERLAPPED lpOverlapped); - -#define WSAID_ACCEPTEX {0xb5367df1,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} - - typedef VOID (WINAPI *LPFN_GETACCEPTEXSOCKADDRS)(PVOID lpOutputBuffer,DWORD dwReceiveDataLength,DWORD dwLocalAddressLength,DWORD dwRemoteAddressLength,struct sockaddr **LocalSockaddr,LPINT LocalSockaddrLength,struct sockaddr **RemoteSockaddr,LPINT RemoteSockaddrLength); - -#define WSAID_GETACCEPTEXSOCKADDRS {0xb5367df2,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}} - - typedef struct _TRANSMIT_PACKETS_ELEMENT { - ULONG dwElFlags; -#define TP_ELEMENT_MEMORY 1 -#define TP_ELEMENT_FILE 2 -#define TP_ELEMENT_EOP 4 - ULONG cLength; - __MINGW_EXTENSION union { - __MINGW_EXTENSION struct { - LARGE_INTEGER nFileOffset; - HANDLE hFile; - }; - PVOID pBuffer; - }; - } TRANSMIT_PACKETS_ELEMENT,*PTRANSMIT_PACKETS_ELEMENT,*LPTRANSMIT_PACKETS_ELEMENT; - -#define TP_DISCONNECT TF_DISCONNECT -#define TP_REUSE_SOCKET TF_REUSE_SOCKET -#define TP_USE_DEFAULT_WORKER TF_USE_DEFAULT_WORKER -#define TP_USE_SYSTEM_THREAD TF_USE_SYSTEM_THREAD -#define TP_USE_KERNEL_APC TF_USE_KERNEL_APC - - typedef WINBOOL (WINAPI *LPFN_TRANSMITPACKETS) (SOCKET hSocket,LPTRANSMIT_PACKETS_ELEMENT lpPacketArray,DWORD nElementCount,DWORD nSendSize,LPOVERLAPPED lpOverlapped,DWORD dwFlags); - -#define WSAID_TRANSMITPACKETS {0xd9689da0,0x1f90,0x11d3,{0x99,0x71,0x00,0xc0,0x4f,0x68,0xc8,0x76}} - - typedef WINBOOL (WINAPI *LPFN_CONNECTEX)(SOCKET s,const struct sockaddr *name,int namelen,PVOID lpSendBuffer,DWORD dwSendDataLength,LPDWORD lpdwBytesSent,LPOVERLAPPED lpOverlapped); - -#define WSAID_CONNECTEX {0x25a207b9,0xddf3,0x4660,{0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e}} - - typedef WINBOOL (WINAPI *LPFN_DISCONNECTEX)(SOCKET s,LPOVERLAPPED lpOverlapped,DWORD dwFlags,DWORD dwReserved); - -#define WSAID_DISCONNECTEX {0x7fda2e11,0x8630,0x436f,{0xa0,0x31,0xf5,0x36,0xa6,0xee,0xc1,0x57}} - -#define DE_REUSE_SOCKET TF_REUSE_SOCKET - -#define NLA_NAMESPACE_GUID {0x6642243a,0x3ba8,0x4aa6,{0xba,0xa5,0x2e,0xb,0xd7,0x1f,0xdd,0x83}} - -#define NLA_SERVICE_CLASS_GUID {0x37e515,0xb5c9,0x4a43,{0xba,0xda,0x8b,0x48,0xa8,0x7a,0xd2,0x39}} - -#define NLA_ALLUSERS_NETWORK 0x00000001 -#define NLA_FRIENDLY_NAME 0x00000002 - - typedef enum _NLA_BLOB_DATA_TYPE { - NLA_RAW_DATA = 0,NLA_INTERFACE = 1,NLA_802_1X_LOCATION = 2,NLA_CONNECTIVITY = 3,NLA_ICS = 4 - } NLA_BLOB_DATA_TYPE,*PNLA_BLOB_DATA_TYPE; - - typedef enum _NLA_CONNECTIVITY_TYPE { - NLA_NETWORK_AD_HOC = 0,NLA_NETWORK_MANAGED = 1,NLA_NETWORK_UNMANAGED = 2,NLA_NETWORK_UNKNOWN = 3 - } NLA_CONNECTIVITY_TYPE,*PNLA_CONNECTIVITY_TYPE; - - typedef enum _NLA_INTERNET { - NLA_INTERNET_UNKNOWN = 0,NLA_INTERNET_NO = 1,NLA_INTERNET_YES = 2 - } NLA_INTERNET,*PNLA_INTERNET; - - typedef struct _NLA_BLOB { - struct { - NLA_BLOB_DATA_TYPE type; - DWORD dwSize; - DWORD nextOffset; - } header; - union { - CHAR rawData[1]; - struct { - DWORD dwType; - DWORD dwSpeed; - CHAR adapterName[1]; - } interfaceData; - struct { - CHAR information[1]; - } locationData; - struct { - NLA_CONNECTIVITY_TYPE type; - NLA_INTERNET internet; - } connectivity; - struct { - struct { - DWORD speed; - DWORD type; - DWORD state; - WCHAR machineName[256]; - WCHAR sharedAdapterName[256]; - } remote; - } ICS; - } data; - } NLA_BLOB,*PNLA_BLOB,*LPNLA_BLOB; - -#ifdef BADVPN_SHIPPED_MSWSOCK_DECLARE_WSAMSG - typedef struct _WSAMSG { - LPSOCKADDR name; - INT namelen; - LPWSABUF lpBuffers; - DWORD dwBufferCount; - WSABUF Control; - DWORD dwFlags; - } WSAMSG,*PWSAMSG,*LPWSAMSG; -#endif - - typedef struct _WSACMSGHDR { - SIZE_T cmsg_len; - INT cmsg_level; - INT cmsg_type; - } WSACMSGHDR,*PWSACMSGHDR,*LPWSACMSGHDR; - -#define WSA_CMSGHDR_ALIGN(length) (((length) + TYPE_ALIGNMENT(WSACMSGHDR)-1) & (~(TYPE_ALIGNMENT(WSACMSGHDR)-1))) -#define WSA_CMSGDATA_ALIGN(length) (((length) + MAX_NATURAL_ALIGNMENT-1) & (~(MAX_NATURAL_ALIGNMENT-1))) -#define WSA_CMSG_FIRSTHDR(msg) (((msg)->Control.len >= sizeof(WSACMSGHDR)) ? (LPWSACMSGHDR)(msg)->Control.buf : (LPWSACMSGHDR)NULL) -#define WSA_CMSG_NXTHDR(msg,cmsg) ((!(cmsg)) ? WSA_CMSG_FIRSTHDR(msg) : ((((u_char *)(cmsg) + WSA_CMSGHDR_ALIGN((cmsg)->cmsg_len) + sizeof(WSACMSGHDR)) > (u_char *)((msg)->Control.buf) + (msg)->Control.len) ? (LPWSACMSGHDR)NULL : (LPWSACMSGHDR)((u_char *)(cmsg) + WSA_CMSGHDR_ALIGN((cmsg)->cmsg_len)))) -#define WSA_CMSG_DATA(cmsg) ((u_char *)(cmsg) + WSA_CMSGDATA_ALIGN(sizeof(WSACMSGHDR))) -#define WSA_CMSG_SPACE(length) (WSA_CMSGDATA_ALIGN(sizeof(WSACMSGHDR) + WSA_CMSGHDR_ALIGN(length))) -#define WSA_CMSG_LEN(length) (WSA_CMSGDATA_ALIGN(sizeof(WSACMSGHDR)) + length) - -#define MSG_TRUNC 0x0100 -#define MSG_CTRUNC 0x0200 -#define MSG_BCAST 0x0400 -#define MSG_MCAST 0x0800 - - typedef INT (WINAPI *LPFN_WSARECVMSG)(SOCKET s, LPWSAMSG lpMsg, - LPDWORD lpdwNumberOfBytesRecvd, - LPWSAOVERLAPPED lpOverlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); - -#define WSAID_WSARECVMSG {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}} - -#if(_WIN32_WINNT >= 0x0600) - typedef struct { - LPWSAMSG lpMsg; - DWORD dwFlags; - LPDWORD lpNumberOfBytesSent; - LPWSAOVERLAPPED lpOverlapped; - LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine; - } WSASENDMSG, *LPWSASENDMSG; - - typedef INT (WSAAPI *LPFN_WSASENDMSG)(SOCKET s, LPWSAMSG lpMsg, DWORD dwFlags, - LPDWORD lpNumberOfBytesSent, - LPWSAOVERLAPPED lpOverlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); - -#define WSAID_WSASENDMSG {0xa441e712,0x754f,0x43ca,{0x84,0xa7,0x0d,0xee,0x44,0xcf,0x60,0x6d}} - -#endif /* (_WIN32_WINNT >= 0x0600) */ - -#ifdef __cplusplus -} -#endif - -#endif /* _MSWSOCK_ */ diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/nonblocking.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/nonblocking.h deleted file mode 100644 index fe82584a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/nonblocking.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file nonblocking.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Function for enabling non-blocking mode for a file descriptor. - */ - -#ifndef BADVPN_MISC_NONBLOCKING_H -#define BADVPN_MISC_NONBLOCKING_H - -#include -#include - -static int badvpn_set_nonblocking (int fd); - -int badvpn_set_nonblocking (int fd) -{ - if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { - return 0; - } - - return 1; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/nsskey.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/nsskey.h deleted file mode 100644 index 8268235f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/nsskey.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @file nsskey.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Function for opening a NSS certificate and its private key. - */ - -#ifndef BADVPN_MISC_NSSKEY_H -#define BADVPN_MISC_NSSKEY_H - -#include - -#include -#include -#include -#include - -#include - -#include - -/** - * Opens a NSS certificate and its private key. - * - * @param name name of the certificate - * @param out_cert on success, the certificate will be returned here. Should be - * released with CERT_DestroyCertificate. - * @param out_key on success, the private key will be returned here. Should be - * released with SECKEY_DestroyPrivateKey. - * @return 1 on success, 0 on failure - */ -static int open_nss_cert_and_key (char *name, CERTCertificate **out_cert, SECKEYPrivateKey **out_key) WARN_UNUSED; - -static SECKEYPrivateKey * find_nss_private_key (char *name) -{ - SECKEYPrivateKey *key = NULL; - - PK11SlotList *slot_list = PK11_GetAllTokens(CKM_INVALID_MECHANISM, PR_FALSE, PR_FALSE, NULL); - if (!slot_list) { - return NULL; - } - - PK11SlotListElement *slot_entry; - for (slot_entry = slot_list->head; !key && slot_entry; slot_entry = slot_entry->next) { - SECKEYPrivateKeyList *key_list = PK11_ListPrivKeysInSlot(slot_entry->slot, name, NULL); - if (!key_list) { - BLog(BLOG_ERROR, "PK11_ListPrivKeysInSlot failed"); - continue; - } - - SECKEYPrivateKeyListNode *key_node; - for (key_node = PRIVKEY_LIST_HEAD(key_list); !key && !PRIVKEY_LIST_END(key_node, key_list); key_node = PRIVKEY_LIST_NEXT(key_node)) { - char *key_name = PK11_GetPrivateKeyNickname(key_node->key); - if (!key_name || strcmp(key_name, name)) { - PORT_Free((void *)key_name); - continue; - } - PORT_Free((void *)key_name); - - key = SECKEY_CopyPrivateKey(key_node->key); - } - - SECKEY_DestroyPrivateKeyList(key_list); - } - - PK11_FreeSlotList(slot_list); - - return key; -} - -int open_nss_cert_and_key (char *name, CERTCertificate **out_cert, SECKEYPrivateKey **out_key) -{ - CERTCertificate *cert; - cert = CERT_FindCertByNicknameOrEmailAddr(CERT_GetDefaultCertDB(), name); - if (!cert) { - BLog(BLOG_ERROR, "CERT_FindCertByName failed (%d)", (int)PR_GetError()); - return 0; - } - - SECKEYPrivateKey *key = find_nss_private_key(name); - if (!key) { - BLog(BLOG_ERROR, "Failed to find private key"); - CERT_DestroyCertificate(cert); - return 0; - } - - *out_cert = cert; - *out_key = key; - return 1; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/offset.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/offset.h deleted file mode 100644 index 23b7683c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/offset.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file offset.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Macros for determining offsets of members in structs. - */ - -#ifndef BADVPN_MISC_OFFSET_H -#define BADVPN_MISC_OFFSET_H - -#include -#include - -/** - * Returns a pointer to a struct, given a pointer to its member. - */ -#define UPPER_OBJECT(_ptr, _object_type, _field_name) ((_object_type *)((char *)(_ptr) - offsetof(_object_type, _field_name))) - -/** - * Returns the offset of one struct member from another. - * Expands to an int. - */ -#define OFFSET_DIFF(_object_type, _field1, _field2) ((int)offsetof(_object_type, _field1) - (int)offsetof(_object_type, _field2)) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/open_standard_streams.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/open_standard_streams.h deleted file mode 100644 index 7fd6d414..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/open_standard_streams.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @file open_standard_streams.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_OPEN_STANDARD_STREAMS_H -#define BADVPN_OPEN_STANDARD_STREAMS_H - -#ifndef BADVPN_USE_WINAPI -#include -#include -#include -#include -#endif - -static void open_standard_streams (void) -{ -#ifndef BADVPN_USE_WINAPI - int fd; - - do { - fd = open("/dev/null", O_RDWR); - if (fd > 2) { - close(fd); - } - } while (fd >= 0 && fd <= 2); -#endif -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/overflow.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/overflow.h deleted file mode 100644 index 9fde52ad..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/overflow.h +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @file overflow.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Functions for checking for overflow of integer addition. - */ - -#ifndef BADVPN_MISC_OVERFLOW_H -#define BADVPN_MISC_OVERFLOW_H - -#include -#include - -#define DEFINE_UNSIGNED_OVERFLOW(_name, _type, _max) \ -static int add_ ## _name ## _overflows (_type a, _type b) \ -{\ - return (b > _max - a); \ -} - -#define DEFINE_SIGNED_OVERFLOW(_name, _type, _min, _max) \ -static int add_ ## _name ## _overflows (_type a, _type b) \ -{\ - if ((a < 0) ^ (b < 0)) return 0; \ - if (a < 0) return -(a < _min - b); \ - return (a > _max - b); \ -} - -DEFINE_UNSIGNED_OVERFLOW(uint, unsigned int, UINT_MAX) -DEFINE_UNSIGNED_OVERFLOW(uint8, uint8_t, UINT8_MAX) -DEFINE_UNSIGNED_OVERFLOW(uint16, uint16_t, UINT16_MAX) -DEFINE_UNSIGNED_OVERFLOW(uint32, uint32_t, UINT32_MAX) -DEFINE_UNSIGNED_OVERFLOW(uint64, uint64_t, UINT64_MAX) - -DEFINE_SIGNED_OVERFLOW(int, int, INT_MIN, INT_MAX) -DEFINE_SIGNED_OVERFLOW(int8, int8_t, INT8_MIN, INT8_MAX) -DEFINE_SIGNED_OVERFLOW(int16, int16_t, INT16_MIN, INT16_MAX) -DEFINE_SIGNED_OVERFLOW(int32, int32_t, INT32_MIN, INT32_MAX) -DEFINE_SIGNED_OVERFLOW(int64, int64_t, INT64_MIN, INT64_MAX) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/packed.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/packed.h deleted file mode 100644 index 2175536a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/packed.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * @file packed.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Structure packing macros. - */ - -#ifndef BADVPN_PACKED_H -#define BADVPN_PACKED_H - -#ifdef _MSC_VER - -#define B_START_PACKED __pragma(pack(push, 1)) -#define B_END_PACKED __pragma(pack(pop)) -#define B_PACKED - -#else - -#define B_START_PACKED -#define B_END_PACKED -#define B_PACKED __attribute__((packed)) - -#endif - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/parse_number.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/parse_number.h deleted file mode 100644 index 3a3db3a1..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/parse_number.h +++ /dev/null @@ -1,234 +0,0 @@ -/** - * @file parse_number.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Numeric string parsing. - */ - -#ifndef BADVPN_MISC_PARSE_NUMBER_H -#define BADVPN_MISC_PARSE_NUMBER_H - -#include -#include -#include -#include - -#include "misc/memref.h" -#include "misc/debug.h" - -// public parsing functions -static int decode_decimal_digit (char c); -static int decode_hex_digit (char c); -static int parse_unsigned_integer (MemRef str, uintmax_t *out) WARN_UNUSED; -static int parse_unsigned_hex_integer (MemRef str, uintmax_t *out) WARN_UNUSED; -static int parse_signmag_integer (MemRef str, int *out_sign, uintmax_t *out_mag) WARN_UNUSED; - -// public generation functions -static int compute_decimal_repr_size (uintmax_t x); -static void generate_decimal_repr (uintmax_t x, char *out, int repr_size); -static int generate_decimal_repr_string (uintmax_t x, char *out); - -// implementation follows - -// decimal representation of UINTMAX_MAX -static const char parse_number__uintmax_max_str[] = "18446744073709551615"; - -// make sure UINTMAX_MAX is what we think it is -static const char parse_number__uintmax_max_str_assert[(UINTMAX_MAX == UINTMAX_C(18446744073709551615)) ? 1 : -1]; - -static int decode_decimal_digit (char c) -{ - switch (c) { - case '0': return 0; - case '1': return 1; - case '2': return 2; - case '3': return 3; - case '4': return 4; - case '5': return 5; - case '6': return 6; - case '7': return 7; - case '8': return 8; - case '9': return 9; - } - - return -1; -} - -static int decode_hex_digit (char c) -{ - switch (c) { - case '0': return 0; - case '1': return 1; - case '2': return 2; - case '3': return 3; - case '4': return 4; - case '5': return 5; - case '6': return 6; - case '7': return 7; - case '8': return 8; - case '9': return 9; - case 'A': case 'a': return 10; - case 'B': case 'b': return 11; - case 'C': case 'c': return 12; - case 'D': case 'd': return 13; - case 'E': case 'e': return 14; - case 'F': case 'f': return 15; - } - - return -1; -} - -static int parse__no_overflow (const char *str, size_t str_len, uintmax_t *out) -{ - uintmax_t n = 0; - - while (str_len > 0) { - if (*str < '0' || *str > '9') { - return 0; - } - - n = 10 * n + (*str - '0'); - - str++; - str_len--; - } - - *out = n; - return 1; -} - -int parse_unsigned_integer (MemRef str, uintmax_t *out) -{ - // we do not allow empty strings - if (str.len == 0) { - return 0; - } - - // remove leading zeros - while (str.len > 0 && *str.ptr == '0') { - str.ptr++; - str.len--; - } - - // detect overflow - if (str.len > sizeof(parse_number__uintmax_max_str) - 1 || - (str.len == sizeof(parse_number__uintmax_max_str) - 1 && memcmp(str.ptr, parse_number__uintmax_max_str, sizeof(parse_number__uintmax_max_str) - 1) > 0)) { - return 0; - } - - // will not overflow (but can still have invalid characters) - return parse__no_overflow(str.ptr, str.len, out); -} - -int parse_unsigned_hex_integer (MemRef str, uintmax_t *out) -{ - uintmax_t n = 0; - - if (str.len == 0) { - return 0; - } - - while (str.len > 0) { - int digit = decode_hex_digit(*str.ptr); - if (digit < 0) { - return 0; - } - - if (n > UINTMAX_MAX / 16) { - return 0; - } - n *= 16; - - if (digit > UINTMAX_MAX - n) { - return 0; - } - n += digit; - - str.ptr++; - str.len--; - } - - *out = n; - return 1; -} - -int parse_signmag_integer (MemRef str, int *out_sign, uintmax_t *out_mag) -{ - int sign = 1; - if (str.len > 0 && (str.ptr[0] == '+' || str.ptr[0] == '-')) { - sign = 1 - 2 * (str.ptr[0] == '-'); - str.ptr++; - str.len--; - } - - if (!parse_unsigned_integer(str, out_mag)) { - return 0; - } - - *out_sign = sign; - return 1; -} - -int compute_decimal_repr_size (uintmax_t x) -{ - int size = 0; - - do { - size++; - x /= 10; - } while (x > 0); - - return size; -} - -void generate_decimal_repr (uintmax_t x, char *out, int repr_size) -{ - ASSERT(out) - ASSERT(repr_size == compute_decimal_repr_size(x)) - - out += repr_size; - - do { - *(--out) = '0' + (x % 10); - x /= 10; - } while (x > 0); -} - -int generate_decimal_repr_string (uintmax_t x, char *out) -{ - ASSERT(out) - - int repr_size = compute_decimal_repr_size(x); - generate_decimal_repr(x, out, repr_size); - out[repr_size] = '\0'; - - return repr_size; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/print_macros.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/print_macros.h deleted file mode 100644 index a07fdbe4..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/print_macros.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @file print_macros.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Format macros for printf() for non-standard compilers. - */ - -#ifndef BADVPN_PRINT_MACROS -#define BADVPN_PRINT_MACROS - -#ifdef _MSC_VER - -// size_t -#define PRIsz "Iu" - -// signed exact width (intN_t) -#define PRId8 "d" -#define PRIi8 "i" -#define PRId16 "d" -#define PRIi16 "i" -#define PRId32 "I32d" -#define PRIi32 "I32i" -#define PRId64 "I64d" -#define PRIi64 "I64i" - -// unsigned exact width (uintN_t) -#define PRIo8 "o" -#define PRIu8 "u" -#define PRIx8 "x" -#define PRIX8 "X" -#define PRIo16 "o" -#define PRIu16 "u" -#define PRIx16 "x" -#define PRIX16 "X" -#define PRIo32 "I32o" -#define PRIu32 "I32u" -#define PRIx32 "I32x" -#define PRIX32 "I32X" -#define PRIo64 "I64o" -#define PRIu64 "I64u" -#define PRIx64 "I64x" -#define PRIX64 "I64X" - -// signed maximum width (intmax_t) -#define PRIdMAX "I64d" -#define PRIiMAX "I64i" - -// unsigned maximum width (uintmax_t) -#define PRIoMAX "I64o" -#define PRIuMAX "I64u" -#define PRIxMAX "I64x" -#define PRIXMAX "I64X" - -// signed pointer (intptr_t) -#define PRIdPTR "Id" -#define PRIiPTR "Ii" - -// unsigned pointer (uintptr_t) -#define PRIoPTR "Io" -#define PRIuPTR "Iu" -#define PRIxPTR "Ix" -#define PRIXPTR "IX" - -#else - -#include - -#define PRIsz "zu" - -#endif - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/read_file.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/read_file.h deleted file mode 100644 index e1862e5b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/read_file.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @file read_file.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Function for reading a file into memory using stdio. - */ - -#ifndef BADVPN_MISC_READ_FILE_H -#define BADVPN_MISC_READ_FILE_H - -#include -#include -#include -#include - -static int read_file (const char *file, uint8_t **out_data, size_t *out_len) -{ - FILE *f = fopen(file, "r"); - if (!f) { - goto fail0; - } - - size_t buf_len = 0; - size_t buf_size = 128; - - uint8_t *buf = (uint8_t *)malloc(buf_size); - if (!buf) { - goto fail1; - } - - while (1) { - if (buf_len == buf_size) { - if (2 > SIZE_MAX / buf_size) { - goto fail; - } - size_t newsize = 2 * buf_size; - - uint8_t *newbuf = (uint8_t *)realloc(buf, newsize); - if (!newbuf) { - goto fail; - } - - buf = newbuf; - buf_size = newsize; - } - - size_t bytes = fread(buf + buf_len, 1, buf_size - buf_len, f); - if (bytes == 0) { - if (feof(f)) { - break; - } - goto fail; - } - - buf_len += bytes; - } - - fclose(f); - - *out_data = buf; - *out_len = buf_len; - return 1; - -fail: - free(buf); -fail1: - fclose(f); -fail0: - return 0; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/read_write_int.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/read_write_int.h deleted file mode 100644 index bc4ed2c0..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/read_write_int.h +++ /dev/null @@ -1,181 +0,0 @@ -/** - * @file read_write_int.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_READ_WRITE_INT_H -#define BADVPN_READ_WRITE_INT_H - -#include - -static uint8_t badvpn_read_le8 (const char *c_ptr); -static uint16_t badvpn_read_le16 (const char *c_ptr); -static uint32_t badvpn_read_le32 (const char *c_ptr); -static uint64_t badvpn_read_le64 (const char *c_ptr); - -static uint8_t badvpn_read_be8 (const char *c_ptr); -static uint16_t badvpn_read_be16 (const char *c_ptr); -static uint32_t badvpn_read_be32 (const char *c_ptr); -static uint64_t badvpn_read_be64 (const char *c_ptr); - -static void badvpn_write_le8 (uint8_t x, char *c_ptr); -static void badvpn_write_le16 (uint16_t x, char *c_ptr); -static void badvpn_write_le32 (uint32_t x, char *c_ptr); -static void badvpn_write_le64 (uint64_t x, char *c_ptr); - -static void badvpn_write_be8 (uint8_t x, char *c_ptr); -static void badvpn_write_be16 (uint16_t x, char *c_ptr); -static void badvpn_write_be32 (uint32_t x, char *c_ptr); -static void badvpn_write_be64 (uint64_t x, char *c_ptr); - -static uint8_t badvpn_read_le8 (const char *c_ptr) -{ - const uint8_t *ptr = (const uint8_t *)c_ptr; - return ((uint8_t)ptr[0] << 0); -} - -static uint16_t badvpn_read_le16 (const char *c_ptr) -{ - const uint8_t *ptr = (const uint8_t *)c_ptr; - return ((uint16_t)ptr[1] << 8) | ((uint16_t)ptr[0] << 0); -} - -static uint32_t badvpn_read_le32 (const char *c_ptr) -{ - const uint8_t *ptr = (const uint8_t *)c_ptr; - return ((uint32_t)ptr[3] << 24) | ((uint32_t)ptr[2] << 16) | - ((uint32_t)ptr[1] << 8) | ((uint32_t)ptr[0] << 0); -} - -static uint64_t badvpn_read_le64 (const char *c_ptr) -{ - const uint8_t *ptr = (const uint8_t *)c_ptr; - return ((uint64_t)ptr[7] << 56) | ((uint64_t)ptr[6] << 48) | - ((uint64_t)ptr[5] << 40) | ((uint64_t)ptr[4] << 32) | - ((uint64_t)ptr[3] << 24) | ((uint64_t)ptr[2] << 16) | - ((uint64_t)ptr[1] << 8) | ((uint64_t)ptr[0] << 0); -} - -static uint8_t badvpn_read_be8 (const char *c_ptr) -{ - const uint8_t *ptr = (const uint8_t *)c_ptr; - return ((uint8_t)ptr[0] << 0); -} - -static uint16_t badvpn_read_be16 (const char *c_ptr) -{ - const uint8_t *ptr = (const uint8_t *)c_ptr; - return ((uint16_t)ptr[0] << 8) | ((uint16_t)ptr[1] << 0); -} - -static uint32_t badvpn_read_be32 (const char *c_ptr) -{ - const uint8_t *ptr = (const uint8_t *)c_ptr; - return ((uint32_t)ptr[0] << 24) | ((uint32_t)ptr[1] << 16) | - ((uint32_t)ptr[2] << 8) | ((uint32_t)ptr[3] << 0); -} - -static uint64_t badvpn_read_be64 (const char *c_ptr) -{ - const uint8_t *ptr = (const uint8_t *)c_ptr; - return ((uint64_t)ptr[0] << 56) | ((uint64_t)ptr[1] << 48) | - ((uint64_t)ptr[2] << 40) | ((uint64_t)ptr[3] << 32) | - ((uint64_t)ptr[4] << 24) | ((uint64_t)ptr[5] << 16) | - ((uint64_t)ptr[6] << 8) | ((uint64_t)ptr[7] << 0); -} - -static void badvpn_write_le8 (uint8_t x, char *c_ptr) -{ - uint8_t *ptr = (uint8_t *)c_ptr; - ptr[0] = x >> 0; -} - -static void badvpn_write_le16 (uint16_t x, char *c_ptr) -{ - uint8_t *ptr = (uint8_t *)c_ptr; - ptr[1] = x >> 8; - ptr[0] = x >> 0; -} - -static void badvpn_write_le32 (uint32_t x, char *c_ptr) -{ - uint8_t *ptr = (uint8_t *)c_ptr; - ptr[3] = x >> 24; - ptr[2] = x >> 16; - ptr[1] = x >> 8; - ptr[0] = x >> 0; -} - -static void badvpn_write_le64 (uint64_t x, char *c_ptr) -{ - uint8_t *ptr = (uint8_t *)c_ptr; - ptr[7] = x >> 56; - ptr[6] = x >> 48; - ptr[5] = x >> 40; - ptr[4] = x >> 32; - ptr[3] = x >> 24; - ptr[2] = x >> 16; - ptr[1] = x >> 8; - ptr[0] = x >> 0; -} - -static void badvpn_write_be8 (uint8_t x, char *c_ptr) -{ - uint8_t *ptr = (uint8_t *)c_ptr; - ptr[0] = x >> 0; -} - -static void badvpn_write_be16 (uint16_t x, char *c_ptr) -{ - uint8_t *ptr = (uint8_t *)c_ptr; - ptr[0] = x >> 8; - ptr[1] = x >> 0; -} - -static void badvpn_write_be32 (uint32_t x, char *c_ptr) -{ - uint8_t *ptr = (uint8_t *)c_ptr; - ptr[0] = x >> 24; - ptr[1] = x >> 16; - ptr[2] = x >> 8; - ptr[3] = x >> 0; -} - -static void badvpn_write_be64 (uint64_t x, char *c_ptr) -{ - uint8_t *ptr = (uint8_t *)c_ptr; - ptr[0] = x >> 56; - ptr[1] = x >> 48; - ptr[2] = x >> 40; - ptr[3] = x >> 32; - ptr[4] = x >> 24; - ptr[5] = x >> 16; - ptr[6] = x >> 8; - ptr[7] = x >> 0; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/socks_proto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/socks_proto.h deleted file mode 100644 index 94e4d9a6..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/socks_proto.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @file socks_proto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Definitions for the SOCKS protocol. - */ - -#ifndef BADVPN_MISC_SOCKS_PROTO_H -#define BADVPN_MISC_SOCKS_PROTO_H - -#include - -#include "misc/packed.h" - -#define SOCKS_VERSION 0x05 - -#define SOCKS_METHOD_NO_AUTHENTICATION_REQUIRED 0x00 -#define SOCKS_METHOD_GSSAPI 0x01 -#define SOCKS_METHOD_USERNAME_PASSWORD 0x02 -#define SOCKS_METHOD_NO_ACCEPTABLE_METHODS 0xFF - -#define SOCKS_CMD_CONNECT 0x01 -#define SOCKS_CMD_BIND 0x02 -#define SOCKS_CMD_UDP_ASSOCIATE 0x03 - -#define SOCKS_ATYP_IPV4 0x01 -#define SOCKS_ATYP_DOMAINNAME 0x03 -#define SOCKS_ATYP_IPV6 0x04 - -#define SOCKS_REP_SUCCEEDED 0x00 -#define SOCKS_REP_GENERAL_FAILURE 0x01 -#define SOCKS_REP_CONNECTION_NOT_ALLOWED 0x02 -#define SOCKS_REP_NETWORK_UNREACHABLE 0x03 -#define SOCKS_REP_HOST_UNREACHABLE 0x04 -#define SOCKS_REP_CONNECTION_REFUSED 0x05 -#define SOCKS_REP_TTL_EXPIRED 0x06 -#define SOCKS_REP_COMMAND_NOT_SUPPORTED 0x07 -#define SOCKS_REP_ADDRESS_TYPE_NOT_SUPPORTED 0x08 - -B_START_PACKED -struct socks_client_hello_header { - uint8_t ver; - uint8_t nmethods; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct socks_client_hello_method { - uint8_t method; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct socks_server_hello { - uint8_t ver; - uint8_t method; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct socks_request_header { - uint8_t ver; - uint8_t cmd; - uint8_t rsv; - uint8_t atyp; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct socks_reply_header { - uint8_t ver; - uint8_t rep; - uint8_t rsv; - uint8_t atyp; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct socks_addr_ipv4 { - uint32_t addr; - uint16_t port; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct socks_addr_ipv6 { - uint8_t addr[16]; - uint16_t port; -} B_PACKED; -B_END_PACKED - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/sslsocket.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/sslsocket.h deleted file mode 100644 index 71e43c20..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/sslsocket.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * @file sslsocket.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Structure for moving around sockets, possibly together with SSL compoments. - */ - -#ifndef BADVPN_MISC_SSLSOCKET_H -#define BADVPN_MISC_SSLSOCKET_H - -#include - -#include -#include - -typedef struct { - BConnection con; - PRFileDesc bottom_prfd; - PRFileDesc *ssl_prfd; -} sslsocket; - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/stdbuf_cmdline.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/stdbuf_cmdline.h deleted file mode 100644 index 8459c645..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/stdbuf_cmdline.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @file stdbuf_cmdline.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Builds command line for running a program via stdbuf. - */ - -#ifndef BADVPN_STDBUF_CMDLINE_H -#define BADVPN_STDBUF_CMDLINE_H - -#include - -#include -#include -#include - -/** - * Builds the initial part of command line for calling a program via stdbuf - * with standard output buffering set to line-buffered. - * - * @param out {@link CmdLine} to append the result to. Note than on failure, only - * some part of the cmdline may have been appended. - * @param stdbuf_exec full path to stdbuf executable - * @param exec path to the executable. Must not contain nulls. - * @param exec_len number of characters in exec - * @return 1 on success, 0 on failure - */ -static int build_stdbuf_cmdline (CmdLine *out, const char *stdbuf_exec, const char *exec, size_t exec_len) WARN_UNUSED; - -int build_stdbuf_cmdline (CmdLine *out, const char *stdbuf_exec, const char *exec, size_t exec_len) -{ - ASSERT(!memchr(exec, '\0', exec_len)) - - if (!CmdLine_AppendMulti(out, 3, stdbuf_exec, "-o", "L")) { - goto fail1; - } - - if (exec[0] == '/') { - if (!CmdLine_AppendNoNull(out, exec, exec_len)) { - goto fail1; - } - } else { - bsize_t size = bsize_add(bsize_fromsize(exec_len), bsize_fromsize(3)); - char *real_exec = BAllocSize(size); - if (!real_exec) { - goto fail1; - } - - memcpy(real_exec, "./", 2); - memcpy(real_exec + 2, exec, exec_len); - real_exec[2 + exec_len] = '\0'; - - int res = CmdLine_Append(out, real_exec); - free(real_exec); - if (!res) { - goto fail1; - } - } - - return 1; - -fail1: - return 0; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/strdup.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/strdup.h deleted file mode 100644 index 7f57af1a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/strdup.h +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @file strdup.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Allocate memory for a string and copy it there. - */ - -#ifndef BADVPN_STRDUP_H -#define BADVPN_STRDUP_H - -#include -#include -#include - -#include "misc/debug.h" - -/** - * Allocate and copy a null-terminated string. - */ -static char * b_strdup (const char *str) -{ - ASSERT(str) - - size_t len = strlen(str); - - char *s = (char *)malloc(len + 1); - if (!s) { - return NULL; - } - - memcpy(s, str, len + 1); - - return s; -} - -/** - * Allocate memory for a null-terminated string and use the - * given data as its contents. A null terminator is appended - * after the specified data. - */ -static char * b_strdup_bin (const char *str, size_t len) -{ - ASSERT(str) - - if (len == SIZE_MAX) { - return NULL; - } - - char *s = (char *)malloc(len + 1); - if (!s) { - return NULL; - } - - memcpy(s, str, len); - s[len] = '\0'; - - return s; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/string_begins_with.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/string_begins_with.h deleted file mode 100644 index 3c9c5e91..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/string_begins_with.h +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @file string_begins_with.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Function for checking if a string begins with a given string. - */ - -#ifndef BADVPN_MISC_STRING_BEGINS_WITH -#define BADVPN_MISC_STRING_BEGINS_WITH - -#include -#include - -#include - -static size_t data_begins_with (const char *str, size_t str_len, const char *needle) -{ - ASSERT(strlen(needle) > 0) - - size_t len = 0; - - while (str_len > 0 && *needle) { - if (*str != *needle) { - return 0; - } - str++; - str_len--; - needle++; - len++; - } - - if (*needle) { - return 0; - } - - return len; -} - -static size_t string_begins_with (const char *str, const char *needle) -{ - ASSERT(strlen(needle) > 0) - - return data_begins_with(str, strlen(str), needle); -} - -static size_t data_begins_with_bin (const char *str, size_t str_len, const char *needle, size_t needle_len) -{ - ASSERT(needle_len > 0) - - size_t len = 0; - - while (str_len > 0 && needle_len > 0) { - if (*str != *needle) { - return 0; - } - str++; - str_len--; - needle++; - needle_len--; - len++; - } - - if (needle_len > 0) { - return 0; - } - - return len; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/substring.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/substring.h deleted file mode 100644 index 958d5ffc..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/substring.h +++ /dev/null @@ -1,82 +0,0 @@ -#include - -#include -#include - -static void build_substring_backtrack_table (MemRef str, size_t *out_table) -{ - ASSERT(str.len > 0) - - size_t x = 0; - - for (size_t i = 1; i < str.len; i++) { - out_table[i] = x; - while (x > 0 && str.ptr[i] != str.ptr[x]) { - x = out_table[x]; - } - if (str.ptr[i] == str.ptr[x]) { - x++; - } - } -} - -static int find_substring (MemRef text, MemRef word, const size_t *table, size_t *out_position) -{ - ASSERT(word.len > 0) - - size_t x = 0; - - for (size_t i = 0; i < text.len; i++) { - while (x > 0 && text.ptr[i] != word.ptr[x]) { - x = table[x]; - } - if (text.ptr[i] == word.ptr[x]) { - if (x + 1 == word.len) { - *out_position = i - x; - return 1; - } - x++; - } - } - - return 0; -} - -static void build_substring_backtrack_table_reverse (MemRef str, size_t *out_table) -{ - ASSERT(str.len > 0) - - size_t x = 0; - - for (size_t i = 1; i < str.len; i++) { - out_table[i] = x; - while (x > 0 && str.ptr[str.len - 1 - i] != str.ptr[str.len - 1 - x]) { - x = out_table[x]; - } - if (str.ptr[str.len - 1 - i] == str.ptr[str.len - 1 - x]) { - x++; - } - } -} - -static int find_substring_reverse (MemRef text, MemRef word, const size_t *table, size_t *out_position) -{ - ASSERT(word.len > 0) - - size_t x = 0; - - for (size_t i = 0; i < text.len; i++) { - while (x > 0 && text.ptr[text.len - 1 - i] != word.ptr[word.len - 1 - x]) { - x = table[x]; - } - if (text.ptr[text.len - 1 - i] == word.ptr[word.len - 1 - x]) { - if (x + 1 == word.len) { - *out_position = (text.len - 1 - i); - return 1; - } - x++; - } - } - - return 0; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/udp_proto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/udp_proto.h deleted file mode 100644 index fde677ad..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/udp_proto.h +++ /dev/null @@ -1,170 +0,0 @@ -/** - * @file udp_proto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Definitions for the UDP protocol. - */ - -#ifndef BADVPN_MISC_UDP_PROTO_H -#define BADVPN_MISC_UDP_PROTO_H - -#include - -#include "misc/debug.h" -#include "misc/byteorder.h" -#include "misc/ipv4_proto.h" -#include "misc/ipv6_proto.h" -#include "misc/read_write_int.h" - -B_START_PACKED -struct udp_header { - uint16_t source_port; - uint16_t dest_port; - uint16_t length; - uint16_t checksum; -} B_PACKED; -B_END_PACKED - -static uint32_t udp_checksum_summer (const char *data, uint16_t len) -{ - ASSERT(len % 2 == 0) - - uint32_t t = 0; - - for (uint16_t i = 0; i < len / 2; i++) { - t += badvpn_read_be16(data + 2 * i); - } - - return t; -} - -static uint16_t udp_checksum (const struct udp_header *header, const uint8_t *payload, uint16_t payload_len, uint32_t source_addr, uint32_t dest_addr) -{ - uint32_t t = 0; - - t += udp_checksum_summer((char *)&source_addr, sizeof(source_addr)); - t += udp_checksum_summer((char *)&dest_addr, sizeof(dest_addr)); - - uint16_t x; - x = hton16(IPV4_PROTOCOL_UDP); - t += udp_checksum_summer((char *)&x, sizeof(x)); - x = hton16(sizeof(*header) + payload_len); - t += udp_checksum_summer((char *)&x, sizeof(x)); - - t += udp_checksum_summer((const char *)header, sizeof(*header)); - - if (payload_len % 2 == 0) { - t += udp_checksum_summer((const char *)payload, payload_len); - } else { - t += udp_checksum_summer((const char *)payload, payload_len - 1); - - x = hton16(((uint16_t)payload[payload_len - 1]) << 8); - t += udp_checksum_summer((char *)&x, sizeof(x)); - } - - while (t >> 16) { - t = (t & 0xFFFF) + (t >> 16); - } - - if (t == 0) { - t = UINT16_MAX; - } - - return hton16(~t); -} - -static uint16_t udp_ip6_checksum (const struct udp_header *header, const uint8_t *payload, uint16_t payload_len, const uint8_t *source_addr, const uint8_t *dest_addr) -{ - uint32_t t = 0; - - t += udp_checksum_summer((const char *)source_addr, 16); - t += udp_checksum_summer((const char *)dest_addr, 16); - - uint32_t x; - x = hton32(sizeof(*header) + payload_len); - t += udp_checksum_summer((char *)&x, sizeof(x)); - x = hton32(IPV6_NEXT_UDP); - t += udp_checksum_summer((char *)&x, sizeof(x)); - - t += udp_checksum_summer((const char *)header, sizeof(*header)); - - if (payload_len % 2 == 0) { - t += udp_checksum_summer((const char *)payload, payload_len); - } else { - t += udp_checksum_summer((const char *)payload, payload_len - 1); - - uint16_t y; - y = hton16(((uint16_t)payload[payload_len - 1]) << 8); - t += udp_checksum_summer((char *)&y, sizeof(y)); - } - - while (t >> 16) { - t = (t & 0xFFFF) + (t >> 16); - } - - if (t == 0) { - t = UINT16_MAX; - } - - return hton16(~t); -} - -static int udp_check (const uint8_t *data, int data_len, struct udp_header *out_header, uint8_t **out_payload, int *out_payload_len) -{ - ASSERT(data_len >= 0) - ASSERT(out_header) - ASSERT(out_payload) - ASSERT(out_payload_len) - - // parse UDP header - if (data_len < sizeof(struct udp_header)) { - return 0; - } - memcpy(out_header, data, sizeof(*out_header)); - data += sizeof(*out_header); - data_len -= sizeof(*out_header); - - // verify UDP payload - int udp_length = ntoh16(out_header->length); - if (udp_length < sizeof(*out_header)) { - return 0; - } - if (udp_length > sizeof(*out_header) + data_len) { - return 0; - } - - // ignore stray data - data_len = udp_length - sizeof(*out_header); - - *out_payload = (uint8_t *)data; - *out_payload_len = data_len; - return 1; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/unicode_funcs.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/unicode_funcs.h deleted file mode 100644 index 2442e7fe..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/unicode_funcs.h +++ /dev/null @@ -1,232 +0,0 @@ -/** - * @file unicode_funcs.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_UNICODE_FUNCS_H -#define BADVPN_UNICODE_FUNCS_H - -#include -#include -#include -#include -#include -#include - -/** - * Decodes UTF-16 data as bytes into an allocated null-terminated UTF-8 string. - * - * @param data UTF-16 data, in big endian - * @param data_len size of data in bytes - * @param out_is_error if not NULL and the function returns a string, - * *out_is_error will be set to 0 or 1, indicating - * whether there have been errors decoding the input. - * A null decoded character is treated as an error. - * @return An UTF-8 null-terminated string which can be freed with free(), - * or NULL if out of memory. - */ -static char * unicode_decode_utf16_to_utf8 (const uint8_t *data, size_t data_len, int *out_is_error); - -/** - * Decodes UTF-8 data into UTF-16 data as bytes. - * - * @param data UTF-8 data - * @param data_len size of data in bytes - * @param out output buffer - * @param out_avail number of bytes available in output buffer - * @param out_len if not NULL, *out_len will contain the number of bytes - * required to store the resulting data (or overflow) - * @param out_is_error if not NULL, *out_is_error will contain 0 or 1, - * indicating whether there have been errors decoding - * the input - */ -static void unicode_decode_utf8_to_utf16 (const uint8_t *data, size_t data_len, uint8_t *out, size_t out_avail, bsize_t *out_len, int *out_is_error); - -static char * unicode_decode_utf16_to_utf8 (const uint8_t *data, size_t data_len, int *out_is_error) -{ - // will build the resulting UTF-8 string by appending to ExpString - ExpString str; - if (!ExpString_Init(&str)) { - goto fail0; - } - - // init UTF-16 decoder - Utf16Decoder decoder; - Utf16Decoder_Init(&decoder); - - // set initial input and input matching positions - size_t i_in = 0; - size_t i_ch = 0; - - int error = 0; - - while (i_in < data_len) { - // read two input bytes from the input position - uint8_t x = data[i_in++]; - if (i_in == data_len) { - break; - } - uint8_t y = data[i_in++]; - - // combine them into a 16-bit value - uint16_t xy = (((uint16_t)x << 8) | (uint16_t)y); - - // give the 16-bit value to the UTF-16 decoder and maybe - // receive a Unicode character back - uint32_t ch; - if (!Utf16Decoder_Input(&decoder, xy, &ch)) { - continue; - } - - if (!error) { - // encode the Unicode character back into UTF-16 - uint16_t chenc[2]; - int chenc_n = Utf16Encoder_EncodeCharacter(ch, chenc); - ASSERT(chenc_n > 0) - - // match the result with input - for (int chenc_i = 0; chenc_i < chenc_n; chenc_i++) { - uint8_t cx = (chenc[chenc_i] >> 8); - uint8_t cy = (chenc[chenc_i] & 0xFF); - - if (i_ch >= data_len || data[i_ch] != cx) { - error = 1; - break; - } - i_ch++; - - if (i_ch >= data_len || data[i_ch] != cy) { - error = 1; - break; - } - i_ch++; - } - } - - // we don't like null Unicode characters because we're building a - // null-terminated UTF-8 string - if (ch == 0) { - error = 1; - continue; - } - - // encode the Unicode character into UTF-8 - uint8_t enc[5]; - int enc_n = Utf8Encoder_EncodeCharacter(ch, enc); - ASSERT(enc_n > 0) - - // append the resulting UTF-8 bytes to the result string - enc[enc_n] = 0; - if (!ExpString_Append(&str, enc)) { - goto fail1; - } - } - - // check if we matched the whole input string when encoding back - if (i_ch < data_len) { - error = 1; - } - - if (out_is_error) { - *out_is_error = error; - } - return ExpString_Get(&str); - -fail1: - ExpString_Free(&str); -fail0: - return NULL; -} - -static void unicode_decode_utf8_to_utf16 (const uint8_t *data, size_t data_len, uint8_t *out, size_t out_avail, bsize_t *out_len, int *out_is_error) -{ - Utf8Decoder decoder; - Utf8Decoder_Init(&decoder); - - size_t i_in = 0; - size_t i_ch = 0; - - bsize_t len = bsize_fromsize(0); - - int error = 0; - - while (i_in < data_len) { - uint8_t x = data[i_in++]; - - uint32_t ch; - if (!Utf8Decoder_Input(&decoder, x, &ch)) { - continue; - } - - if (!error) { - uint8_t chenc[4]; - int chenc_n = Utf8Encoder_EncodeCharacter(ch, chenc); - ASSERT(chenc_n > 0) - - for (int chenc_i = 0; chenc_i < chenc_n; chenc_i++) { - if (i_ch >= data_len || data[i_ch] != chenc[chenc_i]) { - error = 1; - break; - } - i_ch++; - } - } - - uint16_t enc[2]; - int enc_n = Utf16Encoder_EncodeCharacter(ch, enc); - ASSERT(enc_n > 0) - - len = bsize_add(len, bsize_fromsize(2 * enc_n)); - - for (int enc_i = 0; enc_i < enc_n; enc_i++) { - if (out_avail == 0) { - break; - } - *(out++) = (enc[enc_i] >> 8); - out_avail--; - - if (out_avail == 0) { - break; - } - *(out++) = (enc[enc_i] & 0xFF); - out_avail--; - } - } - - if (i_ch < data_len) { - error = 1; - } - - if (out_len) { - *out_len = len; - } - if (out_is_error) { - *out_is_error = error; - } -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/version.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/version.h deleted file mode 100644 index 1079ab09..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/version.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file version.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Product information definitions. - */ - -#ifndef BADVPN_MISC_VERSION_H -#define BADVPN_MISC_VERSION_H - -#define GLOBAL_PRODUCT_NAME "BadVPN" -#define GLOBAL_VERSION "1.999.130" -#define GLOBAL_COPYRIGHT_NOTICE "Copyright (C) 2010 Ambroz Bizjak " - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/write_file.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/write_file.h deleted file mode 100644 index 50b323a5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/misc/write_file.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file write_file.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_WRITE_FILE_H -#define BADVPN_WRITE_FILE_H - -#include -#include -#include - -#include -#include - -static int write_file (const char *file, MemRef data) -{ - FILE *f = fopen(file, "w"); - if (!f) { - goto fail0; - } - - while (data.len > 0) { - size_t res = fwrite(data.ptr, 1, data.len, f); - if (res == 0) { - goto fail1; - } - - ASSERT(res <= data.len) - - data = MemRef_SubFrom(data, res); - } - - if (fclose(f) != 0) { - return 0; - } - - return 1; - -fail1: - fclose(f); -fail0: - return 0; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/addr.bproto b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/addr.bproto deleted file mode 100644 index f020350d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/addr.bproto +++ /dev/null @@ -1,11 +0,0 @@ -// message for an AddrProto address -message addr { - // address type. from addr.h - required uint8 type = 1; - // for IPv4 and IPv6 addresses, the port (network byte order) - optional data("2") ip_port = 2; - // for IPv4 addresses, the IP address - optional data("4") ipv4_addr = 3; - // for IPv6 addresses, the IP address - optional data("16") ipv6_addr = 4; -}; diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/addr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/addr.h deleted file mode 100644 index 9d202654..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/addr.h +++ /dev/null @@ -1,207 +0,0 @@ -/** - * @file addr.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * AddrProto, a protocol for encoding network addresses. - * - * AddrProto is built with BProto, the protocol and code generator for building - * custom message protocols. The BProto specification file is addr.bproto. - */ - -#ifndef BADVPN_PROTOCOL_ADDR_H -#define BADVPN_PROTOCOL_ADDR_H - -#include -#include - -#include -#include -#include - -#include - -#include - -#define ADDR_TYPE_IPV4 1 -#define ADDR_TYPE_IPV6 2 - -#define ADDR_SIZE_IPV4 (addr_SIZEtype + addr_SIZEip_port + addr_SIZEipv4_addr) -#define ADDR_SIZE_IPV6 (addr_SIZEtype + addr_SIZEip_port + addr_SIZEipv6_addr) - -/** - * Determines if the given address is supported by AddrProto. - * Depends only on the type of the address. - * - * @param addr address to check. Must be recognized according to {@link BAddr_IsRecognized}. - * @return 1 if supported, 0 if not - */ -static int addr_supported (BAddr addr); - -/** - * Determines the size of the given address when encoded by AddrProto. - * Depends only on the type of the address. - * - * @param addr address to check. Must be supported according to {@link addr_supported}. - * @return encoded size - */ -static int addr_size (BAddr addr); - -/** - * Encodes an address according to AddrProto. - * - * @param out output buffer. Must have at least addr_size(addr) space. - * @param addr address to encode. Must be supported according to {@link addr_supported}. - */ -static void addr_write (uint8_t *out, BAddr addr); - -/** - * Decodes an address according to AddrProto. - * - * @param data input buffer containing the address to decode - * @param data_len size of input. Must be >=0. - * @param out_addr the decoded address will be stored here on success - * @return 1 on success, 0 on failure - */ -static int addr_read (uint8_t *data, int data_len, BAddr *out_addr) WARN_UNUSED; - -int addr_supported (BAddr addr) -{ - BAddr_Assert(&addr); - - switch (addr.type) { - case BADDR_TYPE_IPV4: - case BADDR_TYPE_IPV6: - return 1; - default: - return 0; - } -} - -int addr_size (BAddr addr) -{ - ASSERT(addr_supported(addr)) - - switch (addr.type) { - case BADDR_TYPE_IPV4: - return ADDR_SIZE_IPV4; - case BADDR_TYPE_IPV6: - return ADDR_SIZE_IPV6; - default: - ASSERT(0) - return 0; - } -} - -void addr_write (uint8_t *out, BAddr addr) -{ - ASSERT(addr_supported(addr)) - - addrWriter writer; - addrWriter_Init(&writer, out); - - switch (addr.type) { - case BADDR_TYPE_IPV4: { - addrWriter_Addtype(&writer, ADDR_TYPE_IPV4); - uint8_t *out_port = addrWriter_Addip_port(&writer); - memcpy(out_port, &addr.ipv4.port, sizeof(addr.ipv4.port)); - uint8_t *out_addr = addrWriter_Addipv4_addr(&writer); - memcpy(out_addr, &addr.ipv4.ip, sizeof(addr.ipv4.ip)); - } break; - case BADDR_TYPE_IPV6: { - addrWriter_Addtype(&writer, ADDR_TYPE_IPV6); - uint8_t *out_port = addrWriter_Addip_port(&writer); - memcpy(out_port, &addr.ipv6.port, sizeof(addr.ipv6.port)); - uint8_t *out_addr = addrWriter_Addipv6_addr(&writer); - memcpy(out_addr, addr.ipv6.ip, sizeof(addr.ipv6.ip)); - } break; - default: - ASSERT(0); - } - - int len = addrWriter_Finish(&writer); - B_USE(len) - - ASSERT(len == addr_size(addr)) -} - -int addr_read (uint8_t *data, int data_len, BAddr *out_addr) -{ - ASSERT(data_len >= 0) - - addrParser parser; - if (!addrParser_Init(&parser, data, data_len)) { - BLog(BLOG_ERROR, "failed to parse addr"); - return 0; - } - - uint8_t type = 0; // to remove warning - addrParser_Gettype(&parser, &type); - - switch (type) { - case ADDR_TYPE_IPV4: { - uint8_t *port_data; - if (!addrParser_Getip_port(&parser, &port_data)) { - BLog(BLOG_ERROR, "port missing for IPv4 address"); - return 0; - } - uint8_t *addr_data; - if (!addrParser_Getipv4_addr(&parser, &addr_data)) { - BLog(BLOG_ERROR, "address missing for IPv4 address"); - return 0; - } - uint16_t port; - uint32_t addr; - memcpy(&port, port_data, sizeof(port)); - memcpy(&addr, addr_data, sizeof(addr)); - BAddr_InitIPv4(out_addr, addr, port); - } break; - case ADDR_TYPE_IPV6: { - uint8_t *port_data; - if (!addrParser_Getip_port(&parser, &port_data)) { - BLog(BLOG_ERROR, "port missing for IPv6 address"); - return 0; - } - uint8_t *addr_data; - if (!addrParser_Getipv6_addr(&parser, &addr_data)) { - BLog(BLOG_ERROR, "address missing for IPv6 address"); - return 0; - } - uint16_t port; - memcpy(&port, port_data, sizeof(port)); - BAddr_InitIPv6(out_addr, addr_data, port); - } break; - default: - BLog(BLOG_ERROR, "unknown address type %d", (int)type); - return 0; - } - - return 1; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/dataproto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/dataproto.h deleted file mode 100644 index 998d9535..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/dataproto.h +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @file dataproto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Definitions for DataProto, the protocol for data transport between VPN peers. - * - * All multi-byte integers in structs are little-endian, unless stated otherwise. - * - * A DataProto packet consists of: - * - the header (struct {@link dataproto_header}) - * - between zero and DATAPROTO_MAX_PEER_IDS destination peer IDs (struct {@link dataproto_peer_id}) - * - the payload, e.g. Ethernet frame - */ - -#ifndef BADVPN_PROTOCOL_DATAPROTO_H -#define BADVPN_PROTOCOL_DATAPROTO_H - -#include - -#include -#include - -#define DATAPROTO_MAX_PEER_IDS 1 - -#define DATAPROTO_FLAGS_RECEIVING_KEEPALIVES 1 - -/** - * DataProto header. - */ -B_START_PACKED -struct dataproto_header { - /** - * Bitwise OR of flags. Possible flags: - * - DATAPROTO_FLAGS_RECEIVING_KEEPALIVES - * Indicates that when the peer sent this packet, it has received at least - * one packet from the other peer in the last keep-alive tolerance time. - */ - uint8_t flags; - - /** - * ID of the peer this frame originates from. - */ - peerid_t from_id; - - /** - * Number of destination peer IDs that follow. - * Must be <=DATAPROTO_MAX_PEER_IDS. - */ - peerid_t num_peer_ids; -} B_PACKED; -B_END_PACKED - -/** - * Structure for a destination peer ID in DataProto. - * Wraps a single peerid_t in a packed struct for easy access. - */ -B_START_PACKED -struct dataproto_peer_id { - peerid_t id; -} B_PACKED; -B_END_PACKED - -#define DATAPROTO_MAX_OVERHEAD (sizeof(struct dataproto_header) + DATAPROTO_MAX_PEER_IDS * sizeof(struct dataproto_peer_id)) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/fragmentproto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/fragmentproto.h deleted file mode 100644 index 4d2315e7..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/fragmentproto.h +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @file fragmentproto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Definitions for FragmentProto, a protocol that allows sending of arbitrarily sized packets over - * a link with a fixed MTU. - * - * All multi-byte integers in structs are little-endian, unless stated otherwise. - * - * A FragmentProto packet consists of a number of chunks. - * Each chunk consists of: - * - the chunk header (struct {@link fragmentproto_chunk_header}) - * - the chunk payload, i.e. part of the frame specified in the header - */ - -#ifndef BADVPN_PROTOCOL_FRAGMENTPROTO_H -#define BADVPN_PROTOCOL_FRAGMENTPROTO_H - -#include - -#include -#include - -typedef uint16_t fragmentproto_frameid; - -/** - * FragmentProto chunk header. - */ -B_START_PACKED -struct fragmentproto_chunk_header { - /** - * Identifier of the frame this chunk belongs to. - * Frames should be given ascending identifiers as they are encoded - * into chunks (except when the ID wraps to zero). - */ - fragmentproto_frameid frame_id; - - /** - * Position in the frame where this chunk starts. - */ - uint16_t chunk_start; - - /** - * Length of the chunk's payload. - */ - uint16_t chunk_len; - - /** - * Whether this is the last chunk of the frame, i.e. - * the total length of the frame is chunk_start + chunk_len. - */ - uint8_t is_last; -} B_PACKED; -B_END_PACKED - -/** - * Calculates how many chunks are needed at most for encoding one frame of the - * given maximum size with FragmentProto onto a carrier with a given MTU. - * This includes the case when the first chunk of a frame is not the first chunk - * in a FragmentProto packet. - * - * @param carrier_mtu MTU of the carrier, i.e. maximum length of FragmentProto packets. Must be >sizeof(struct fragmentproto_chunk_header). - * @param frame_mtu maximum frame size. Must be >=0. - * @return maximum number of chunks needed. Will be >0. - */ -static int fragmentproto_max_chunks_for_frame (int carrier_mtu, int frame_mtu) -{ - ASSERT(carrier_mtu > sizeof(struct fragmentproto_chunk_header)) - ASSERT(frame_mtu >= 0) - - return (bdivide_up(frame_mtu, (carrier_mtu - sizeof(struct fragmentproto_chunk_header))) + 1); -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/msgproto.bproto b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/msgproto.bproto deleted file mode 100644 index 202931e2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/msgproto.bproto +++ /dev/null @@ -1,43 +0,0 @@ -// message for all MsgProto messages -message msg { - // message type, from msgproto.h - required uint16 type = 1; - // message payload. Is itself one of the messages below - // for "youconnect", "seed" and "confirmseed" messages, - // and empty for other messages - required data payload = 2; -}; - -// "youconnect" message payload -message msg_youconnect { - // external addresses to try; one or more msg_youconnect_addr messages - required repeated data addr = 1; - // encryption key if using UDP and encryption is enabled - optional data key = 2; - // password if using TCP - optional uint64 password = 3; -}; - -// an external address -message msg_youconnect_addr { - // scope name for this address - required data name = 1; - // address according to AddrProto - required data addr = 2; -}; - -// "seed" message payload -message msg_seed { - // identifier for the seed being send - required uint16 seed_id = 1; - // seed encryption key - required data key = 2; - // seed IV - required data iv = 3; -}; - -// "confirmseed" message payload -message msg_confirmseed { - // identifier for the seed being confirmed - required uint16 seed_id = 1; -}; diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/msgproto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/msgproto.h deleted file mode 100644 index 286abb08..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/msgproto.h +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @file msgproto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * MsgProto is used by each pair of VPN peers as messages through the server, in order to - * establish a direct data connection. MsgProto operates on top of the SCProto message - * service, optionally secured with SSL; see {@link scproto.h} for details. - * - * MsgProto is built with BProto, the protocol and code generator for building - * custom message protocols. The BProto specification file is msgproto.bproto. - * - * It goes roughly like that: - * - * We name one peer the master and the other the slave. The master is the one with - * greater ID. - * When the peers get to know about each other, the master starts the binding procedure. - * It binds/listens to an address, and sends the slave the "youconnect" message. It - * contains a list of external addresses for that bind address and additional parameters. - * Each external address includes a string called a scope name. The slave, which receives - * the "youconnect" message, finds the first external address whose scope it recognizes, - * and attempts to establish connection to that address. If it finds an address, buf fails - * at connecting, it sends "youretry", which makes the master restart the binding procedure - * after some time. If it however does not recognize any external address, it sends - * "cannotconnect" back to the master. - * When the master receives the "cannotconnect", it tries the next bind address, as described - * above. When the master runs out of bind addresses, it sends "cannotbind" to the slave. - * When the slave receives the "cannotbind", it starts its own binding procedure, similarly - * to what is described above, with master and slave reversed. First difference is if the - * master fails to connect to a recognized address, it doesn't send "youretry", but rather - * simply restarts the whole procedure after some time. The other difference is when the - * slave runs out of bind addresses, it not only sends "cannotbind" to the master, but - * registers relaying to the master. And in this case, when the master receives the "cannotbind", - * it doesn't start the binding procedure all all over, but registers relaying to the slave. - */ - -#ifndef BADVPN_PROTOCOL_MSGPROTO_H -#define BADVPN_PROTOCOL_MSGPROTO_H - -#include - -#define MSGID_YOUCONNECT 1 -#define MSGID_CANNOTCONNECT 2 -#define MSGID_CANNOTBIND 3 -#define MSGID_YOURETRY 5 -#define MSGID_SEED 6 -#define MSGID_CONFIRMSEED 7 - -#define MSG_MAX_PAYLOAD (SC_MAX_MSGLEN - msg_SIZEtype - msg_SIZEpayload(0)) - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/packetproto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/packetproto.h deleted file mode 100644 index fcac3e5d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/packetproto.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file packetproto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Definitions for PacketProto, a protocol that allows sending of packets - * over a reliable stream connection. - * - * All multi-byte integers in structs are little-endian, unless stated otherwise. - * - * Packets are encoded into a stream by representing each packet with: - * - a 16-bit little-endian unsigned integer representing the length - * of the payload - * - that many bytes of payload - */ - -#ifndef BADVPN_PROTOCOL_PACKETPROTO_H -#define BADVPN_PROTOCOL_PACKETPROTO_H - -#include -#include - -#include "misc/packed.h" - -/** - * PacketProto packet header. - * Wraps a single uint16_t in a packed struct for easy access. - */ -B_START_PACKED -struct packetproto_header -{ - /** - * Length of the packet payload that follows. - */ - uint16_t len; -} B_PACKED; -B_END_PACKED - -#define PACKETPROTO_ENCLEN(_len) (sizeof(struct packetproto_header) + (_len)) - -#define PACKETPROTO_MAXPAYLOAD UINT16_MAX - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/requestproto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/requestproto.h deleted file mode 100644 index 2ec3d0dc..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/requestproto.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @file requestproto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_REQUESTPROTO_H -#define BADVPN_REQUESTPROTO_H - -#include - -#include - -#define REQUESTPROTO_TYPE_CLIENT_REQUEST 1 -#define REQUESTPROTO_TYPE_CLIENT_ABORT 2 -#define REQUESTPROTO_TYPE_SERVER_REPLY 3 -#define REQUESTPROTO_TYPE_SERVER_FINISHED 4 -#define REQUESTPROTO_TYPE_SERVER_ERROR 5 - -B_START_PACKED -struct requestproto_header { - uint32_t request_id; - uint32_t type; -} B_PACKED; -B_END_PACKED - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/scproto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/scproto.h deleted file mode 100644 index f138e0a5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/scproto.h +++ /dev/null @@ -1,266 +0,0 @@ -/** - * @file scproto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Definitions for SCProto, the protocol that the clients communicate in - * with the server. - * - * All multi-byte integers in structs are little-endian, unless stated otherwise. - * - * A SCProto packet consists of: - * - a header (struct {@link sc_header}) which contains the type of the - * packet - * - the payload - * - * It goes roughly like that: - * - * When the client connects to the server, it sends a "clienthello" packet - * to the server. The packet contains the protocol version the client is using. - * When the server receives the "clienthello" packet, it checks the version. - * If it doesn't match, it disconnects the client. Otherwise the server sends - * the client a "serverhello" packet to the client. That packet contains - * the ID of the client and possibly its IPv4 address as the server sees it - * (zero if not applicable). - * - * The server than proceeds to synchronize the peers' knowledge of each other. - * It does that by sending a "newclient" messages to a client to inform it of - * another peer, and "endclient" messages to inform it that a peer is gone. - * Each client, upon receiving a "newclient" message, MUST sent a corresponding - * "acceptpeer" message, before sending any messages to the new peer. - * The server forwards messages between synchronized peers to allow them to - * communicate. A peer sends a message to another peer by sending the "outmsg" - * packet to the server, and the server delivers a message to a peer by sending - * it the "inmsg" packet. - * - * The message service is reliable; messages from one client to another are - * expected to arrive unmodified and in the same order. There is, however, - * no flow control. This means that messages can not be used for bulk transfers - * between the clients (and they are not). If the server runs out of buffer for - * messages from one client to another, it will stop forwarding messages, and - * will reset knowledge of the two clients after some delay. Similarly, if one - * of the clients runs out of buffer locally, it will send the "resetpeer" - * packet to make the server reset knowledge. - * - * The messages transport either: - * - * - If the relevant "newclient" packets do not contain the - * SCID_NEWCLIENT_FLAG_SSL flag, then plaintext MsgProto messages. - * - * - If the relevant "newclient" packets do contain the SCID_NEWCLIENT_FLAG_SSL - * flag, then SSL, broken down into packets, PacketProto inside SSL, and finally - * MsgProto inside PacketProto. The master peer (one with higher ID) acts as an - * SSL server, and the other acts as an SSL client. The peers must identify with - * the same certificate they used when connecting to the server, and each peer - * must byte-compare the other's certificate agains the one provided to it by - * by the server in the relevent "newclient" message. - */ - -#ifndef BADVPN_PROTOCOL_SCPROTO_H -#define BADVPN_PROTOCOL_SCPROTO_H - -#include - -#include - -#define SC_VERSION 29 -#define SC_OLDVERSION_NOSSL 27 -#define SC_OLDVERSION_BROKENCERT 26 - -#define SC_KEEPALIVE_INTERVAL 10000 - -/** - * SCProto packet header. - * Follows up to SC_MAX_PAYLOAD bytes of payload. - */ -B_START_PACKED -struct sc_header { - /** - * Message type. - */ - uint8_t type; -} B_PACKED; -B_END_PACKED - -#define SC_MAX_PAYLOAD 2000 -#define SC_MAX_ENC (sizeof(struct sc_header) + SC_MAX_PAYLOAD) - -typedef uint16_t peerid_t; - -#define SCID_KEEPALIVE 0 -#define SCID_CLIENTHELLO 1 -#define SCID_SERVERHELLO 2 -#define SCID_NEWCLIENT 3 -#define SCID_ENDCLIENT 4 -#define SCID_OUTMSG 5 -#define SCID_INMSG 6 -#define SCID_RESETPEER 7 -#define SCID_ACCEPTPEER 8 - -/** - * "clienthello" client packet payload. - * Packet type is SCID_CLIENTHELLO. - */ -B_START_PACKED -struct sc_client_hello { - /** - * Protocol version the client is using. - */ - uint16_t version; -} B_PACKED; -B_END_PACKED - -/** - * "serverhello" server packet payload. - * Packet type is SCID_SERVERHELLO. - */ -B_START_PACKED -struct sc_server_hello { - /** - * Flags. Not used yet. - */ - uint16_t flags; - - /** - * Peer ID of the client. - */ - peerid_t id; - - /** - * IPv4 address of the client as seen by the server - * (network byte order). Zero if not applicable. - */ - uint32_t clientAddr; -} B_PACKED; -B_END_PACKED - -/** - * "newclient" server packet payload. - * Packet type is SCID_NEWCLIENT. - * If the server is using TLS, follows up to SCID_NEWCLIENT_MAX_CERT_LEN - * bytes of the new client's certificate (encoded in DER). - */ -B_START_PACKED -struct sc_server_newclient { - /** - * ID of the new peer. - */ - peerid_t id; - - /** - * Flags. Possible flags: - * - SCID_NEWCLIENT_FLAG_RELAY_SERVER - * You can relay frames to other peers through this peer. - * - SCID_NEWCLIENT_FLAG_RELAY_CLIENT - * You must allow this peer to relay frames to other peers through you. - * - SCID_NEWCLIENT_FLAG_SSL - * SSL must be used to talk to this peer through messages. - */ - uint16_t flags; -} B_PACKED; -B_END_PACKED - -#define SCID_NEWCLIENT_FLAG_RELAY_SERVER 1 -#define SCID_NEWCLIENT_FLAG_RELAY_CLIENT 2 -#define SCID_NEWCLIENT_FLAG_SSL 4 - -#define SCID_NEWCLIENT_MAX_CERT_LEN (SC_MAX_PAYLOAD - sizeof(struct sc_server_newclient)) - -/** - * "endclient" server packet payload. - * Packet type is SCID_ENDCLIENT. - */ -B_START_PACKED -struct sc_server_endclient { - /** - * ID of the removed peer. - */ - peerid_t id; -} B_PACKED; -B_END_PACKED - -/** - * "outmsg" client packet header. - * Packet type is SCID_OUTMSG. - * Follows up to SC_MAX_MSGLEN bytes of message payload. - */ -B_START_PACKED -struct sc_client_outmsg { - /** - * ID of the destionation peer. - */ - peerid_t clientid; -} B_PACKED; -B_END_PACKED - -/** - * "inmsg" server packet payload. - * Packet type is SCID_INMSG. - * Follows up to SC_MAX_MSGLEN bytes of message payload. - */ -B_START_PACKED -struct sc_server_inmsg { - /** - * ID of the source peer. - */ - peerid_t clientid; -} B_PACKED; -B_END_PACKED - -#define _SC_MAX_OUTMSGLEN (SC_MAX_PAYLOAD - sizeof(struct sc_client_outmsg)) -#define _SC_MAX_INMSGLEN (SC_MAX_PAYLOAD - sizeof(struct sc_server_inmsg)) - -#define SC_MAX_MSGLEN (_SC_MAX_OUTMSGLEN < _SC_MAX_INMSGLEN ? _SC_MAX_OUTMSGLEN : _SC_MAX_INMSGLEN) - -/** - * "resetpeer" client packet header. - * Packet type is SCID_RESETPEER. - */ -B_START_PACKED -struct sc_client_resetpeer { - /** - * ID of the peer to reset. - */ - peerid_t clientid; -} B_PACKED; -B_END_PACKED - -/** - * "acceptpeer" client packet payload. - * Packet type is SCID_ACCEPTPEER. - */ -B_START_PACKED -struct sc_client_acceptpeer { - /** - * ID of the peer to accept. - */ - peerid_t clientid; -} B_PACKED; -B_END_PACKED - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/spproto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/spproto.h deleted file mode 100644 index 4b5bf5dc..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/spproto.h +++ /dev/null @@ -1,195 +0,0 @@ -/** - * @file spproto.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Protocol for securing datagram communication. - * - * Security features implemented: - * - Encryption. Encrypts packets with a block cipher. - * Protects against a third party from seeing the data - * being transmitted. - * - Hashes. Adds a hash of the packet into the packet. - * Combined with encryption, protects against tampering - * with packets and crafting new packets. - * - One-time passwords. Adds a password to each packet - * for the receiver to recognize. Protects agains replaying - * packets and crafting new packets. - * - * A SPProto plaintext packet contains the following, in order: - * - if OTPs are used, a struct {@link spproto_otpdata} which contains - * the seed ID and the OTP, - * - if hashes are used, the hash, - * - payload data. - * - * If encryption is used: - * - the plaintext is padded by appending a 0x01 byte and as many 0x00 - * bytes as needed to align to block size, - * - the padded plaintext is encrypted, and - * - the initialization vector (IV) is prepended. - */ - -#ifndef BADVPN_PROTOCOL_SPPROTO_H -#define BADVPN_PROTOCOL_SPPROTO_H - -#include -#include - -#include -#include -#include -#include -#include -#include - -#define SPPROTO_HASH_MODE_NONE 0 -#define SPPROTO_ENCRYPTION_MODE_NONE 0 -#define SPPROTO_OTP_MODE_NONE 0 - -/** - * Stores security parameters for SPProto. - */ -struct spproto_security_params { - /** - * Hash mode. - * Either SPPROTO_HASH_MODE_NONE for no hashes, or a valid bhash - * hash mode. - */ - int hash_mode; - - /** - * Encryption mode. - * Either SPPROTO_ENCRYPTION_MODE_NONE for no encryption, or a valid - * {@link BEncryption} cipher. - */ - int encryption_mode; - - /** - * One-time password (OTP) mode. - * Either SPPROTO_OTP_MODE_NONE for no OTPs, or a valid - * {@link BEncryption} cipher. - */ - int otp_mode; - - /** - * If OTPs are used (otp_mode != SPPROTO_OTP_MODE_NONE), number of - * OTPs generated from a single seed. - */ - int otp_num; -}; - -#define SPPROTO_HAVE_HASH(_params) ((_params).hash_mode != SPPROTO_HASH_MODE_NONE) -#define SPPROTO_HASH_SIZE(_params) ( \ - SPPROTO_HAVE_HASH(_params) ? \ - BHash_size((_params).hash_mode) : \ - 0 \ -) - -#define SPPROTO_HAVE_ENCRYPTION(_params) ((_params).encryption_mode != SPPROTO_ENCRYPTION_MODE_NONE) - -#define SPPROTO_HAVE_OTP(_params) ((_params).otp_mode != SPPROTO_OTP_MODE_NONE) - -B_START_PACKED -struct spproto_otpdata { - uint16_t seed_id; - otp_t otp; -} B_PACKED; -B_END_PACKED - -#define SPPROTO_HEADER_OTPDATA_OFF(_params) 0 -#define SPPROTO_HEADER_OTPDATA_LEN(_params) (SPPROTO_HAVE_OTP(_params) ? sizeof(struct spproto_otpdata) : 0) -#define SPPROTO_HEADER_HASH_OFF(_params) (SPPROTO_HEADER_OTPDATA_OFF(_params) + SPPROTO_HEADER_OTPDATA_LEN(_params)) -#define SPPROTO_HEADER_HASH_LEN(_params) SPPROTO_HASH_SIZE(_params) -#define SPPROTO_HEADER_LEN(_params) (SPPROTO_HEADER_HASH_OFF(_params) + SPPROTO_HEADER_HASH_LEN(_params)) - -/** - * Asserts that the given SPProto security parameters are valid. - * - * @param params security parameters - */ -static void spproto_assert_security_params (struct spproto_security_params params) -{ - ASSERT(params.hash_mode == SPPROTO_HASH_MODE_NONE || BHash_type_valid(params.hash_mode)) - ASSERT(params.encryption_mode == SPPROTO_ENCRYPTION_MODE_NONE || BEncryption_cipher_valid(params.encryption_mode)) - ASSERT(params.otp_mode == SPPROTO_OTP_MODE_NONE || BEncryption_cipher_valid(params.otp_mode)) - ASSERT(params.otp_mode == SPPROTO_OTP_MODE_NONE || params.otp_num > 0) -} - -/** - * Calculates the maximum payload size for SPProto given the - * security parameters and the maximum encoded packet size. - * - * @param params security parameters - * @param carrier_mtu maximum encoded packet size. Must be >=0. - * @return maximum payload size. Negative means is is impossible - * to encode anything. - */ -static int spproto_payload_mtu_for_carrier_mtu (struct spproto_security_params params, int carrier_mtu) -{ - spproto_assert_security_params(params); - ASSERT(carrier_mtu >= 0) - - if (params.encryption_mode == SPPROTO_ENCRYPTION_MODE_NONE) { - return (carrier_mtu - SPPROTO_HEADER_LEN(params)); - } else { - int block_size = BEncryption_cipher_block_size(params.encryption_mode); - return (balign_down(carrier_mtu, block_size) - block_size - SPPROTO_HEADER_LEN(params) - 1); - } -} - -/** - * Calculates the maximum encoded packet size for SPProto given the - * security parameters and the maximum payload size. - * - * @param params security parameters - * @param payload_mtu maximum payload size. Must be >=0. - * @return maximum encoded packet size, -1 if payload_mtu is too large - */ -static int spproto_carrier_mtu_for_payload_mtu (struct spproto_security_params params, int payload_mtu) -{ - spproto_assert_security_params(params); - ASSERT(payload_mtu >= 0) - - if (params.encryption_mode == SPPROTO_ENCRYPTION_MODE_NONE) { - if (payload_mtu > INT_MAX - SPPROTO_HEADER_LEN(params)) { - return -1; - } - - return (SPPROTO_HEADER_LEN(params) + payload_mtu); - } else { - int block_size = BEncryption_cipher_block_size(params.encryption_mode); - - if (payload_mtu > INT_MAX - (block_size + SPPROTO_HEADER_LEN(params) + block_size)) { - return -1; - } - - return (block_size + balign_up((SPPROTO_HEADER_LEN(params) + payload_mtu + 1), block_size)); - } -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/udpgw_proto.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/udpgw_proto.h deleted file mode 100644 index e781c14b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/protocol/udpgw_proto.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) Ambroz Bizjak - * Contributions: - * Transparent DNS: Copyright (C) Kerem Hadimli - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_PROTOCOL_UDPGW_PROTO_H -#define BADVPN_PROTOCOL_UDPGW_PROTO_H - -#include - -#include "misc/bsize.h" -#include "misc/packed.h" - -#define UDPGW_CLIENT_FLAG_KEEPALIVE (1 << 0) -#define UDPGW_CLIENT_FLAG_REBIND (1 << 1) -#define UDPGW_CLIENT_FLAG_DNS (1 << 2) -#define UDPGW_CLIENT_FLAG_IPV6 (1 << 3) - -#ifdef BADVPN_SOCKS_UDP_RELAY -B_START_PACKED -struct socks_udp_header { - uint16_t rsv; - uint8_t frag; - uint8_t atyp; -} B_PACKED; -B_END_PACKED -#endif - -B_START_PACKED -struct udpgw_header { - uint8_t flags; - uint16_t conid; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct udpgw_addr_ipv4 { - uint32_t addr_ip; - uint16_t addr_port; -} B_PACKED; -B_END_PACKED - -B_START_PACKED -struct udpgw_addr_ipv6 { - uint8_t addr_ip[16]; - uint16_t addr_port; -} B_PACKED; -B_END_PACKED - -static int udpgw_compute_mtu (int dgram_mtu) -{ - bsize_t bs = bsize_add( -#ifdef BADVPN_SOCKS_UDP_RELAY - bsize_fromsize(sizeof(struct socks_udp_header)), -#else - bsize_fromsize(sizeof(struct udpgw_header)), -#endif - bsize_add( - bsize_max( - bsize_fromsize(sizeof(struct udpgw_addr_ipv4)), - bsize_fromsize(sizeof(struct udpgw_addr_ipv6)) - ), - bsize_fromint(dgram_mtu) - ) - ); - - int s; - if (!bsize_toint(bs, &s)) { - return -1; - } - - return s; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/socksclient/BSocksClient.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/socksclient/BSocksClient.c deleted file mode 100644 index c20e46e0..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/socksclient/BSocksClient.c +++ /dev/null @@ -1,626 +0,0 @@ -/** - * @file BSocksClient.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "misc/byteorder.h" -#include "misc/balloc.h" -#include "base/BLog.h" - -#include "socksclient/BSocksClient.h" - -#include "generated/blog_channel_BSocksClient.h" -//#include -#include - -#define STATE_CONNECTING 1 -#define STATE_SENDING_HELLO 2 -#define STATE_SENT_HELLO 3 -#define STATE_SENDING_PASSWORD 10 -#define STATE_SENT_PASSWORD 11 -#define STATE_SENDING_REQUEST 4 -#define STATE_SENT_REQUEST 5 -#define STATE_RECEIVED_REPLY_HEADER 6 -#define STATE_UP 7 - -static void report_error (BSocksClient *o, int error); -static void init_control_io (BSocksClient *o); -static void free_control_io (BSocksClient *o); -static void init_up_io (BSocksClient *o); -static void free_up_io (BSocksClient *o); -static int reserve_buffer (BSocksClient *o, bsize_t size); -static void start_receive (BSocksClient *o, uint8_t *dest, int total); -static void do_receive (BSocksClient *o); -static void connector_handler (BSocksClient* o, int is_error); -static void connection_handler (BSocksClient* o, int event); -static void recv_handler_done (BSocksClient *o, int data_len); -static void send_handler_done (BSocksClient *o); -static void auth_finished (BSocksClient *p); - -void report_error (BSocksClient *o, int error) -{ - DEBUGERROR(&o->d_err, o->handler(o->user, error)) -} - -void init_control_io (BSocksClient *o) -{ - // init receiving - BConnection_RecvAsync_Init(&o->con); - o->control.recv_if = BConnection_RecvAsync_GetIf(&o->con); - StreamRecvInterface_Receiver_Init(o->control.recv_if, (StreamRecvInterface_handler_done)recv_handler_done, o); - - // init sending - BConnection_SendAsync_Init(&o->con); - PacketStreamSender_Init(&o->control.send_sender, BConnection_SendAsync_GetIf(&o->con), INT_MAX, BReactor_PendingGroup(o->reactor)); - o->control.send_if = PacketStreamSender_GetInput(&o->control.send_sender); - PacketPassInterface_Sender_Init(o->control.send_if, (PacketPassInterface_handler_done)send_handler_done, o); -} - -void free_control_io (BSocksClient *o) -{ - // free sending - PacketStreamSender_Free(&o->control.send_sender); - BConnection_SendAsync_Free(&o->con); - - // free receiving - BConnection_RecvAsync_Free(&o->con); -} - -void init_up_io (BSocksClient *o) -{ - // init receiving - BConnection_RecvAsync_Init(&o->con); - - // init sending - BConnection_SendAsync_Init(&o->con); -} - -void free_up_io (BSocksClient *o) -{ - // free sending - BConnection_SendAsync_Free(&o->con); - - // free receiving - BConnection_RecvAsync_Free(&o->con); -} - -int reserve_buffer (BSocksClient *o, bsize_t size) -{ - if (size.is_overflow) { - BLog(BLOG_ERROR, "size overflow"); - return 0; - } - - char *buffer = (char *)BRealloc(o->buffer, size.value); - if (!buffer) { - BLog(BLOG_ERROR, "BRealloc failed"); - return 0; - } - - o->buffer = buffer; - - return 1; -} - -void start_receive (BSocksClient *o, uint8_t *dest, int total) -{ - ASSERT(total > 0) - - o->control.recv_dest = dest; - o->control.recv_len = 0; - o->control.recv_total = total; - - do_receive(o); -} - -void do_receive (BSocksClient *o) -{ - ASSERT(o->control.recv_len < o->control.recv_total) - - StreamRecvInterface_Receiver_Recv(o->control.recv_if, o->control.recv_dest + o->control.recv_len, o->control.recv_total - o->control.recv_len); -} - -void connector_handler (BSocksClient* o, int is_error) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->state == STATE_CONNECTING) - - // check connection result - if (is_error) { - BLog(BLOG_ERROR, "connection failed"); - goto fail0; - } - - // init connection - if (!BConnection_Init(&o->con, BConnection_source_connector(&o->connector), o->reactor, o, (BConnection_handler)connection_handler)) { - BLog(BLOG_ERROR, "BConnection_Init failed"); - goto fail0; - } - - BLog(BLOG_DEBUG, "connected"); - - // init control I/O - init_control_io(o); - - // check number of methods - if (o->num_auth_info == 0 || o->num_auth_info > 255) { - BLog(BLOG_ERROR, "invalid number of authentication methods"); - goto fail1; - } - - // allocate buffer for sending hello - bsize_t size = bsize_add( - bsize_fromsize(sizeof(struct socks_client_hello_header)), - bsize_mul( - bsize_fromsize(o->num_auth_info), - bsize_fromsize(sizeof(struct socks_client_hello_method)) - ) - ); - if (!reserve_buffer(o, size)) { - goto fail1; - } - - // write hello header - struct socks_client_hello_header header; - header.ver = hton8(SOCKS_VERSION); - header.nmethods = hton8(o->num_auth_info); - memcpy(o->buffer, &header, sizeof(header)); - - // write hello methods - for (size_t i = 0; i < o->num_auth_info; i++) { - struct socks_client_hello_method method; - method.method = hton8(o->auth_info[i].auth_type); - memcpy(o->buffer + sizeof(header) + i * sizeof(method), &method, sizeof(method)); - } -#if SOCKS_DATA_LOG_ENABLE - BLog(BLOG_DEBUG, "tun2socks socks send hello data", size.value); -#endif - // send - PacketPassInterface_Sender_Send(o->control.send_if, (uint8_t *)o->buffer, size.value); - - // set state - o->state = STATE_SENDING_HELLO; - - return; - -fail1: - free_control_io(o); - BConnection_Free(&o->con); -fail0: - report_error(o, BSOCKSCLIENT_EVENT_ERROR); - return; -} - -void connection_handler (BSocksClient* o, int event) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->state != STATE_CONNECTING) - - if (o->state == STATE_UP && event == BCONNECTION_EVENT_RECVCLOSED) { - report_error(o, BSOCKSCLIENT_EVENT_ERROR_CLOSED); - return; - } - - report_error(o, BSOCKSCLIENT_EVENT_ERROR); - return; -} - -void recv_handler_done (BSocksClient *o, int data_len) -{ - ASSERT(data_len >= 0) - ASSERT(data_len <= o->control.recv_total - o->control.recv_len) - - DebugObject_Access(&o->d_obj); - - o->control.recv_len += data_len; - - if (o->control.recv_len < o->control.recv_total) { - do_receive(o); - return; - } -#if TCP_DATA_LOG_ENABLE - struct in_addr a = {o->dest_addr.ipv4.ip}; - char *ip = inet_ntoa(a); - BLog(BLOG_INFO, "socks client<%s:%d> recv_handler_done state: %d, data ", ip, o->dest_addr.ipv4.port, o->state, data_len); - -#endif - - switch (o->state) { - case STATE_SENT_HELLO: { - BLog(BLOG_DEBUG, "received hello"); - - struct socks_server_hello imsg; - memcpy(&imsg, o->buffer, sizeof(imsg)); - - if (ntoh8(imsg.ver) != SOCKS_VERSION) { - BLog(BLOG_NOTICE, "wrong version"); - goto fail; - } - - size_t auth_index; - for (auth_index = 0; auth_index < o->num_auth_info; auth_index++) { - if (o->auth_info[auth_index].auth_type == ntoh8(imsg.method)) { - break; - } - } - - if (auth_index == o->num_auth_info) { - BLog(BLOG_NOTICE, "server didn't accept any authentication method"); - goto fail; - } - - const struct BSocksClient_auth_info *ai = &o->auth_info[auth_index]; - - switch (ai->auth_type) { - case SOCKS_METHOD_NO_AUTHENTICATION_REQUIRED: { - BLog(BLOG_DEBUG, "no authentication"); - - auth_finished(o); - } break; - - case SOCKS_METHOD_USERNAME_PASSWORD: { - BLog(BLOG_DEBUG, "password authentication"); - - if (ai->password.username_len == 0 || ai->password.username_len > 255 || - ai->password.password_len == 0 || ai->password.password_len > 255 - ) { - BLog(BLOG_NOTICE, "invalid username/password length"); - goto fail; - } - - // allocate password packet - bsize_t size = bsize_fromsize(1 + 1 + ai->password.username_len + 1 + ai->password.password_len); - if (!reserve_buffer(o, size)) { - goto fail; - } - - // write password packet - char *ptr = o->buffer; - *ptr++ = 1; - *ptr++ = ai->password.username_len; - memcpy(ptr, ai->password.username, ai->password.username_len); - ptr += ai->password.username_len; - *ptr++ = ai->password.password_len; - memcpy(ptr, ai->password.password, ai->password.password_len); - ptr += ai->password.password_len; - - // start sending - PacketPassInterface_Sender_Send(o->control.send_if, (uint8_t *)o->buffer, size.value); - - // set state - o->state = STATE_SENDING_PASSWORD; - } break; - - default: ASSERT(0); - } - } break; - - case STATE_SENT_REQUEST: { - BLog(BLOG_DEBUG, "received reply header"); - - struct socks_reply_header imsg; - memcpy(&imsg, o->buffer, sizeof(imsg)); - - if (ntoh8(imsg.ver) != SOCKS_VERSION) { - BLog(BLOG_NOTICE, "wrong version"); - goto fail; - } - - if (ntoh8(imsg.rep) != SOCKS_REP_SUCCEEDED) { - BLog(BLOG_NOTICE, "reply not successful"); - goto fail; - } - - int addr_len; - switch (ntoh8(imsg.atyp)) { - case SOCKS_ATYP_IPV4: - addr_len = sizeof(struct socks_addr_ipv4); - break; - case SOCKS_ATYP_IPV6: - addr_len = sizeof(struct socks_addr_ipv6); - break; - default: - BLog(BLOG_NOTICE, "reply has unknown address type"); - goto fail; - } - - // receive the rest of the reply - start_receive(o, (uint8_t *)o->buffer + sizeof(imsg), addr_len); - - // set state - o->state = STATE_RECEIVED_REPLY_HEADER; - } break; - - case STATE_SENT_PASSWORD: { - BLog(BLOG_DEBUG, "received password reply"); - - if (o->buffer[0] != 1) { - BLog(BLOG_NOTICE, "password reply has unknown version"); - goto fail; - } - - if (o->buffer[1] != 0) { - BLog(BLOG_NOTICE, "password reply is negative"); - goto fail; - } - - auth_finished(o); - } break; - - case STATE_RECEIVED_REPLY_HEADER: { - BLog(BLOG_DEBUG, "received reply rest"); - - // free buffer - BFree(o->buffer); - o->buffer = NULL; - - // free control I/O - free_control_io(o); - - // init up I/O - init_up_io(o); - - // set state - o->state = STATE_UP; - - // call handler - o->handler(o->user, BSOCKSCLIENT_EVENT_UP); - return; - } break; - - default: - ASSERT(0); - } - - return; - -fail: - report_error(o, BSOCKSCLIENT_EVENT_ERROR); -} - -void send_handler_done (BSocksClient *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->buffer) -#if TCP_DATA_LOG_ENABLE - struct in_addr a = {o->dest_addr.ipv4.ip}; - char *ip = inet_ntoa(a); - BLog(BLOG_DEBUG, "socks client<%s:%d> send_handler_done state: %d", ip, o->dest_addr.ipv4.port, o->state); -#endif - - switch (o->state) { - case STATE_SENDING_HELLO: { - BLog(BLOG_DEBUG, "sent hello"); - - // allocate buffer for receiving hello - bsize_t size = bsize_fromsize(sizeof(struct socks_server_hello)); - if (!reserve_buffer(o, size)) { - goto fail; - } - - // receive hello - start_receive(o, (uint8_t *)o->buffer, size.value); - - // set state - o->state = STATE_SENT_HELLO; - } break; - - case STATE_SENDING_REQUEST: { - BLog(BLOG_DEBUG, "sent request"); - - // allocate buffer for receiving reply - bsize_t size = bsize_add( - bsize_fromsize(sizeof(struct socks_reply_header)), - bsize_max(bsize_fromsize(sizeof(struct socks_addr_ipv4)), bsize_fromsize(sizeof(struct socks_addr_ipv6))) - ); - if (!reserve_buffer(o, size)) { - goto fail; - } - - // receive reply header - start_receive(o, (uint8_t *)o->buffer, sizeof(struct socks_reply_header)); - - // set state - o->state = STATE_SENT_REQUEST; - } break; - - case STATE_SENDING_PASSWORD: { - BLog(BLOG_DEBUG, "send password"); - - // allocate buffer for receiving reply - bsize_t size = bsize_fromsize(2); - if (!reserve_buffer(o, size)) { - goto fail; - } - - // receive reply header - start_receive(o, (uint8_t *)o->buffer, size.value); - - // set state - o->state = STATE_SENT_PASSWORD; - } break; - - default: - ASSERT(0); - } - - return; - -fail: - report_error(o, BSOCKSCLIENT_EVENT_ERROR); -} - -void auth_finished (BSocksClient *o) -{ - // allocate request buffer - bsize_t size = bsize_fromsize(sizeof(struct socks_request_header)); - switch (o->dest_addr.type) { - case BADDR_TYPE_IPV4: size = bsize_add(size, bsize_fromsize(sizeof(struct socks_addr_ipv4))); break; - case BADDR_TYPE_IPV6: size = bsize_add(size, bsize_fromsize(sizeof(struct socks_addr_ipv6))); break; - } - if (!reserve_buffer(o, size)) { - report_error(o, BSOCKSCLIENT_EVENT_ERROR); - return; - } - - // write request - struct socks_request_header header; - header.ver = hton8(SOCKS_VERSION); - header.cmd = hton8(SOCKS_CMD_CONNECT); - header.rsv = hton8(0); - switch (o->dest_addr.type) { - case BADDR_TYPE_IPV4: { - header.atyp = hton8(SOCKS_ATYP_IPV4); - struct socks_addr_ipv4 addr; - addr.addr = o->dest_addr.ipv4.ip; - addr.port = o->dest_addr.ipv4.port; - memcpy(o->buffer + sizeof(header), &addr, sizeof(addr)); - } break; - case BADDR_TYPE_IPV6: { - header.atyp = hton8(SOCKS_ATYP_IPV6); - struct socks_addr_ipv6 addr; - memcpy(addr.addr, o->dest_addr.ipv6.ip, sizeof(o->dest_addr.ipv6.ip)); - addr.port = o->dest_addr.ipv6.port; - memcpy(o->buffer + sizeof(header), &addr, sizeof(addr)); - } break; - default: - ASSERT(0); - } - memcpy(o->buffer, &header, sizeof(header)); -#if SOCKS_DATA_LOG_ENABLE - BLog(BLOG_DEBUG, "tun2socks socks send request data", size.value); -#endif - // send request - PacketPassInterface_Sender_Send(o->control.send_if, (uint8_t *)o->buffer, size.value); - - // set state - o->state = STATE_SENDING_REQUEST; -} - -struct BSocksClient_auth_info BSocksClient_auth_none (void) -{ - struct BSocksClient_auth_info info; - info.auth_type = SOCKS_METHOD_NO_AUTHENTICATION_REQUIRED; - return info; -} - -struct BSocksClient_auth_info BSocksClient_auth_password (const char *username, size_t username_len, const char *password, size_t password_len) -{ - struct BSocksClient_auth_info info; - info.auth_type = SOCKS_METHOD_USERNAME_PASSWORD; - info.password.username = username; - info.password.username_len = username_len; - info.password.password = password; - info.password.password_len = password_len; - return info; -} - -int BSocksClient_Init (BSocksClient *o, - BAddr server_addr, const struct BSocksClient_auth_info *auth_info, size_t num_auth_info, - BAddr dest_addr, BSocksClient_handler handler, void *user, BReactor *reactor) -{ - ASSERT(!BAddr_IsInvalid(&server_addr)) - ASSERT(dest_addr.type == BADDR_TYPE_IPV4 || dest_addr.type == BADDR_TYPE_IPV6) -#ifndef NDEBUG - for (size_t i = 0; i < num_auth_info; i++) { - ASSERT(auth_info[i].auth_type == SOCKS_METHOD_NO_AUTHENTICATION_REQUIRED || - auth_info[i].auth_type == SOCKS_METHOD_USERNAME_PASSWORD) - } -#endif - - // init arguments - o->auth_info = auth_info; - o->num_auth_info = num_auth_info; - o->dest_addr = dest_addr; - o->handler = handler; - o->user = user; - o->reactor = reactor; - - // set no buffer - o->buffer = NULL; - - // init connector - if (!BConnector_Init(&o->connector, server_addr, o->reactor, o, (BConnector_handler)connector_handler)) { - BLog(BLOG_ERROR, "BConnector_Init failed"); - goto fail0; - } - - // set state - o->state = STATE_CONNECTING; - - DebugError_Init(&o->d_err, BReactor_PendingGroup(o->reactor)); - DebugObject_Init(&o->d_obj); - return 1; - -fail0: - return 0; -} - -void BSocksClient_Free (BSocksClient *o) -{ - DebugObject_Free(&o->d_obj); - DebugError_Free(&o->d_err); - - if (o->state != STATE_CONNECTING) { - if (o->state == STATE_UP) { - // free up I/O - free_up_io(o); - } else { - // free control I/O - free_control_io(o); - } - - // free connection - BConnection_Free(&o->con); - } - - // free connector - BConnector_Free(&o->connector); - - // free buffer - if (o->buffer) { - BFree(o->buffer); - } -} - -StreamPassInterface * BSocksClient_GetSendInterface (BSocksClient *o) -{ - ASSERT(o->state == STATE_UP) - DebugObject_Access(&o->d_obj); - - return BConnection_SendAsync_GetIf(&o->con); -} - -StreamRecvInterface * BSocksClient_GetRecvInterface (BSocksClient *o) -{ - ASSERT(o->state == STATE_UP) - DebugObject_Access(&o->d_obj); - - return BConnection_RecvAsync_GetIf(&o->con); -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/socksclient/BSocksClient.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/socksclient/BSocksClient.h deleted file mode 100644 index 41c69505..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/socksclient/BSocksClient.h +++ /dev/null @@ -1,147 +0,0 @@ -/** - * @file BSocksClient.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * SOCKS5 client. TCP only, no authentication. - */ - -#ifndef BADVPN_SOCKS_BSOCKSCLIENT_H -#define BADVPN_SOCKS_BSOCKSCLIENT_H - -#include - -#include "misc/debug.h" -#include "misc/debugerror.h" -#include "misc/socks_proto.h" -#include "misc/packed.h" -#include "base/DebugObject.h" -#include "system/BConnection.h" -#include "flow/PacketStreamSender.h" - -#define BSOCKSCLIENT_EVENT_ERROR 1 -#define BSOCKSCLIENT_EVENT_UP 2 -#define BSOCKSCLIENT_EVENT_ERROR_CLOSED 3 - -/** - * Handler for events generated by the SOCKS client. - * - * @param user as in {@link BSocksClient_Init} - * @param event event type. One of BSOCKSCLIENT_EVENT_ERROR, BSOCKSCLIENT_EVENT_UP - * and BSOCKSCLIENT_EVENT_ERROR_CLOSED. - * If event is BSOCKSCLIENT_EVENT_UP, the object was previously in down - * state and has transitioned to up state; I/O can be done from this point on. - * If event is BSOCKSCLIENT_EVENT_ERROR or BSOCKSCLIENT_EVENT_ERROR_CLOSED, - * the object must be freed from within the job closure of this handler, - * and no further I/O must be attempted. - */ -typedef void (*BSocksClient_handler) (void *user, int event); - -struct BSocksClient_auth_info { - int auth_type; - union { - struct { - const char *username; - size_t username_len; - const char *password; - size_t password_len; - } password; - }; -}; - -typedef struct { - const struct BSocksClient_auth_info *auth_info; - size_t num_auth_info; - BAddr dest_addr; - BSocksClient_handler handler; - void *user; - BReactor *reactor; - int state; - char *buffer; - BConnector connector; - BConnection con; - union { - struct { - PacketPassInterface *send_if; - PacketStreamSender send_sender; - StreamRecvInterface *recv_if; - uint8_t *recv_dest; - int recv_len; - int recv_total; - } control; - }; - DebugError d_err; - DebugObject d_obj; -} BSocksClient; - -struct BSocksClient_auth_info BSocksClient_auth_none (void); -struct BSocksClient_auth_info BSocksClient_auth_password (const char *username, size_t username_len, const char *password, size_t password_len); - -/** - * Initializes the object. - * The object is initialized in down state. The object must transition to up - * state before the user may begin any I/O. - * - * @param o the object - * @param server_addr SOCKS5 server address - * @param dest_addr remote address - * @param handler handler for up and error events - * @param user value passed to handler - * @param reactor reactor we live in - * @return 1 on success, 0 on failure - */ -int BSocksClient_Init (BSocksClient *o, - BAddr server_addr, const struct BSocksClient_auth_info *auth_info, size_t num_auth_info, - BAddr dest_addr, BSocksClient_handler handler, void *user, BReactor *reactor) WARN_UNUSED; - -/** - * Frees the object. - * - * @param o the object - */ -void BSocksClient_Free (BSocksClient *o); - -/** - * Returns the send interface. - * The object must be in up state. - * - * @param o the object - * @return send interface - */ -StreamPassInterface * BSocksClient_GetSendInterface (BSocksClient *o); - -/** - * Returns the receive interface. - * The object must be in up state. - * - * @param o the object - * @return receive interface - */ -StreamRecvInterface * BSocksClient_GetRecvInterface (BSocksClient *o); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/BAVL.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/BAVL.h deleted file mode 100644 index fc6f540e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/BAVL.h +++ /dev/null @@ -1,797 +0,0 @@ -/** - * @file BAVL.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * AVL tree. - */ - -#ifndef BADVPN_STRUCTURE_BAVL_H -#define BADVPN_STRUCTURE_BAVL_H - -//#define BAVL_DEBUG - -#include -#include - -#include "misc/debug.h" - -/** - * Handler function called by tree algorithms to compare two values. - * For any two values, the comparator must always return the same result. - * The <= relation defined by the comparator must be a total order. - * Values are obtained like that: - * - The value of a node in the tree, or a node that is being inserted is: - * (uint8_t *)node + offset. - * - The value being looked up is the same as given to the lookup function. - * - * @param user as in {@link BAVL_Init} - * @param val1 first value - * @param val2 second value - * @return -1 if val1 < val2, 0 if val1 = val2, 1 if val1 > val2 - */ -typedef int (*BAVL_comparator) (void *user, void *val1, void *val2); - -struct BAVLNode; - -/** - * AVL tree. - */ -typedef struct { - int offset; - BAVL_comparator comparator; - void *user; - struct BAVLNode *root; -} BAVL; - -/** - * AVL tree node. - */ -typedef struct BAVLNode { - struct BAVLNode *parent; - struct BAVLNode *link[2]; - int8_t balance; -#ifdef BAVL_COUNT - uint64_t count; -#endif -} BAVLNode; - -/** - * Initializes the tree. - * - * @param o tree to initialize - * @param offset offset of a value from its node - * @param comparator value comparator handler function - * @param user value to pass to comparator - */ -static void BAVL_Init (BAVL *o, int offset, BAVL_comparator comparator, void *user); - -/** - * Inserts a node into the tree. - * Must not be called from comparator. - * - * @param o the tree - * @param node uninitialized node to insert. Must have a valid value (its value - * may be passed to the comparator during insertion). - * @param ref if not NULL, will return (regardless if insertion succeeded): - * - the greatest node lesser than the inserted value, or (not in order) - * - the smallest node greater than the inserted value, or - * - NULL meaning there were no nodes in the tree. - * @param 1 on success, 0 if an element with an equal value is already in the tree - */ -static int BAVL_Insert (BAVL *o, BAVLNode *node, BAVLNode **ref); - -/** - * Removes a node from the tree. - * Must not be called from comparator. - * - * @param o the tree - * @param node node to remove - */ -static void BAVL_Remove (BAVL *o, BAVLNode *node); - -/** - * Checks if the tree is empty. - * Must not be called from comparator. - * - * @param o the tree - * @return 1 if empty, 0 if not - */ -static int BAVL_IsEmpty (const BAVL *o); - -/** - * Looks for a value in the tree. - * Must not be called from comparator. - * - * @param o the tree - * @param val value to look for - * @return If a node is in the thee with an equal value, that node. - * Else if the tree is not empty: - * - the greatest node lesser than the given value, or (not in order) - * - the smallest node greater than the given value. - * NULL if the tree is empty. - */ -static BAVLNode * BAVL_Lookup (const BAVL *o, void *val); - -/** - * Looks for a value in the tree. - * Must not be called from comparator. - * - * @param o the tree - * @param val value to look for - * @return If a node is in the thee with an equal value, that node. - * Else NULL. - */ -static BAVLNode * BAVL_LookupExact (const BAVL *o, void *val); - -/** - * Returns the smallest node in the tree, or NULL if the tree is empty. - * - * @param o the tree - * @return smallest node or NULL - */ -static BAVLNode * BAVL_GetFirst (const BAVL *o); - -/** - * Returns the greatest node in the tree, or NULL if the tree is empty. - * - * @param o the tree - * @return greatest node or NULL - */ -static BAVLNode * BAVL_GetLast (const BAVL *o); - -/** - * Returns the node that follows the given node, or NULL if it's the - * last node. - * - * @param o the tree - * @param n node - * @return next node, or NULL - */ -static BAVLNode * BAVL_GetNext (const BAVL *o, BAVLNode *n); - -/** - * Returns the node that precedes the given node, or NULL if it's the - * first node. - * - * @param o the tree - * @param n node - * @return previous node, or NULL - */ -static BAVLNode * BAVL_GetPrev (const BAVL *o, BAVLNode *n); - -#ifdef BAVL_COUNT -static uint64_t BAVL_Count (const BAVL *o); -static uint64_t BAVL_IndexOf (const BAVL *o, BAVLNode *n); -static BAVLNode * BAVL_GetAt (const BAVL *o, uint64_t index); -#endif - -static void BAVL_Verify (BAVL *o); - -#define BAVL_MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b)) -#define BAVL_OPTNEG(_a, _neg) ((_neg) ? -(_a) : (_a)) - -static void * _BAVL_node_value (const BAVL *o, BAVLNode *n) -{ - return ((uint8_t *)n + o->offset); -} - -static int _BAVL_compare_values (const BAVL *o, void *v1, void *v2) -{ - int res = o->comparator(o->user, v1, v2); - - ASSERT(res == -1 || res == 0 || res == 1) - - return res; -} - -static int _BAVL_compare_nodes (BAVL *o, BAVLNode *n1, BAVLNode *n2) -{ - return _BAVL_compare_values(o, _BAVL_node_value(o, n1), _BAVL_node_value(o, n2)); -} - -#ifdef BAVL_AUTO_VERIFY -#define BAVL_ASSERT(_h) BAVL_Verify((_h)); -#else -#define BAVL_ASSERT(_h) -#endif - -static int _BAVL_assert_recurser (BAVL *o, BAVLNode *n) -{ - ASSERT_FORCE(n->balance >= -1) - ASSERT_FORCE(n->balance <= 1) - - int height_left = 0; - int height_right = 0; -#ifdef BAVL_COUNT - uint64_t count_left = 0; - uint64_t count_right = 0; -#endif - - // check left subtree - if (n->link[0]) { - // check parent link - ASSERT_FORCE(n->link[0]->parent == n) - // check binary search tree - ASSERT_FORCE(_BAVL_compare_nodes(o, n->link[0], n) == -1) - // recursively calculate height - height_left = _BAVL_assert_recurser(o, n->link[0]); -#ifdef BAVL_COUNT - count_left = n->link[0]->count; -#endif - } - - // check right subtree - if (n->link[1]) { - // check parent link - ASSERT_FORCE(n->link[1]->parent == n) - // check binary search tree - ASSERT_FORCE(_BAVL_compare_nodes(o, n->link[1], n) == 1) - // recursively calculate height - height_right = _BAVL_assert_recurser(o, n->link[1]); -#ifdef BAVL_COUNT - count_right = n->link[1]->count; -#endif - } - - // check balance factor - ASSERT_FORCE(n->balance == height_right - height_left) - -#ifdef BAVL_COUNT - // check count - ASSERT_FORCE(n->count == 1 + count_left + count_right) -#endif - - return (BAVL_MAX(height_left, height_right) + 1); -} - -#ifdef BAVL_COUNT -static void _BAVL_update_count_from_children (BAVLNode *n) -{ - n->count = 1 + (n->link[0] ? n->link[0]->count : 0) + (n->link[1] ? n->link[1]->count : 0); -} -#endif - -static void _BAVL_rotate (BAVL *tree, BAVLNode *r, uint8_t dir) -{ - BAVLNode *nr = r->link[!dir]; - - r->link[!dir] = nr->link[dir]; - if (r->link[!dir]) { - r->link[!dir]->parent = r; - } - nr->link[dir] = r; - nr->parent = r->parent; - if (nr->parent) { - nr->parent->link[r == r->parent->link[1]] = nr; - } else { - tree->root = nr; - } - r->parent = nr; - -#ifdef BAVL_COUNT - // update counts - _BAVL_update_count_from_children(r); // first r! - _BAVL_update_count_from_children(nr); -#endif -} - -static BAVLNode * _BAVL_subtree_max (BAVLNode *n) -{ - ASSERT(n) - while (n->link[1]) { - n = n->link[1]; - } - return n; -} - -static void _BAVL_replace_subtree (BAVL *tree, BAVLNode *dest, BAVLNode *n) -{ - ASSERT(dest) - - if (dest->parent) { - dest->parent->link[dest == dest->parent->link[1]] = n; - } else { - tree->root = n; - } - if (n) { - n->parent = dest->parent; - } - -#ifdef BAVL_COUNT - // update counts - for (BAVLNode *c = dest->parent; c; c = c->parent) { - ASSERT(c->count >= dest->count) - c->count -= dest->count; - if (n) { - ASSERT(n->count <= UINT64_MAX - c->count) - c->count += n->count; - } - } -#endif -} - -static void _BAVL_swap_nodes (BAVL *tree, BAVLNode *n1, BAVLNode *n2) -{ - if (n2->parent == n1 || n1->parent == n2) { - // when the nodes are directly connected we need special handling - // make sure n1 is above n2 - if (n1->parent == n2) { - BAVLNode *t = n1; - n1 = n2; - n2 = t; - } - - uint8_t side = (n2 == n1->link[1]); - BAVLNode *c = n1->link[!side]; - - if (n1->link[0] = n2->link[0]) { - n1->link[0]->parent = n1; - } - if (n1->link[1] = n2->link[1]) { - n1->link[1]->parent = n1; - } - - if (n2->parent = n1->parent) { - n2->parent->link[n1 == n1->parent->link[1]] = n2; - } else { - tree->root = n2; - } - - n2->link[side] = n1; - n1->parent = n2; - if (n2->link[!side] = c) { - c->parent = n2; - } - } else { - BAVLNode *temp; - - // swap parents - temp = n1->parent; - if (n1->parent = n2->parent) { - n1->parent->link[n2 == n2->parent->link[1]] = n1; - } else { - tree->root = n1; - } - if (n2->parent = temp) { - n2->parent->link[n1 == temp->link[1]] = n2; - } else { - tree->root = n2; - } - - // swap left children - temp = n1->link[0]; - if (n1->link[0] = n2->link[0]) { - n1->link[0]->parent = n1; - } - if (n2->link[0] = temp) { - n2->link[0]->parent = n2; - } - - // swap right children - temp = n1->link[1]; - if (n1->link[1] = n2->link[1]) { - n1->link[1]->parent = n1; - } - if (n2->link[1] = temp) { - n2->link[1]->parent = n2; - } - } - - // swap balance factors - int8_t b = n1->balance; - n1->balance = n2->balance; - n2->balance = b; - -#ifdef BAVL_COUNT - // swap counts - uint64_t c = n1->count; - n1->count = n2->count; - n2->count = c; -#endif -} - -static void _BAVL_rebalance (BAVL *o, BAVLNode *node, uint8_t side, int8_t deltac) -{ - ASSERT(side == 0 || side == 1) - ASSERT(deltac >= -1 && deltac <= 1) - ASSERT(node->balance >= -1 && node->balance <= 1) - - // if no subtree changed its height, no more rebalancing is needed - if (deltac == 0) { - return; - } - - // calculate how much our height changed - int8_t delta = BAVL_MAX(deltac, BAVL_OPTNEG(node->balance, side)) - BAVL_MAX(0, BAVL_OPTNEG(node->balance, side)); - ASSERT(delta >= -1 && delta <= 1) - - // update our balance factor - node->balance -= BAVL_OPTNEG(deltac, side); - - BAVLNode *child; - BAVLNode *gchild; - - // perform transformations if the balance factor is wrong - if (node->balance == 2 || node->balance == -2) { - uint8_t bside; - int8_t bsidef; - if (node->balance == 2) { - bside = 1; - bsidef = 1; - } else { - bside = 0; - bsidef = -1; - } - - ASSERT(node->link[bside]) - child = node->link[bside]; - switch (child->balance * bsidef) { - case 1: - _BAVL_rotate(o, node, !bside); - node->balance = 0; - child->balance = 0; - node = child; - delta -= 1; - break; - case 0: - _BAVL_rotate(o, node, !bside); - node->balance = 1 * bsidef; - child->balance = -1 * bsidef; - node = child; - break; - case -1: - ASSERT(child->link[!bside]) - gchild = child->link[!bside]; - _BAVL_rotate(o, child, bside); - _BAVL_rotate(o, node, !bside); - node->balance = -BAVL_MAX(0, gchild->balance * bsidef) * bsidef; - child->balance = BAVL_MAX(0, -gchild->balance * bsidef) * bsidef; - gchild->balance = 0; - node = gchild; - delta -= 1; - break; - default: - ASSERT(0); - } - } - - ASSERT(delta >= -1 && delta <= 1) - // Transformations above preserve this. Proof: - // - if a child subtree gained 1 height and rebalancing was needed, - // it was the heavier subtree. Then delta was was originally 1, because - // the heaviest subtree gained one height. If the transformation reduces - // delta by one, it becomes 0. - // - if a child subtree lost 1 height and rebalancing was needed, it - // was the lighter subtree. Then delta was originally 0, because - // the height of the heaviest subtree was unchanged. If the transformation - // reduces delta by one, it becomes -1. - - if (node->parent) { - _BAVL_rebalance(o, node->parent, node == node->parent->link[1], delta); - } -} - -void BAVL_Init (BAVL *o, int offset, BAVL_comparator comparator, void *user) -{ - o->offset = offset; - o->comparator = comparator; - o->user = user; - o->root = NULL; - - BAVL_ASSERT(o) -} - -int BAVL_Insert (BAVL *o, BAVLNode *node, BAVLNode **ref) -{ - // insert to root? - if (!o->root) { - o->root = node; - node->parent = NULL; - node->link[0] = NULL; - node->link[1] = NULL; - node->balance = 0; -#ifdef BAVL_COUNT - node->count = 1; -#endif - - BAVL_ASSERT(o) - - if (ref) { - *ref = NULL; - } - return 1; - } - - // find node to insert to - BAVLNode *c = o->root; - int side; - while (1) { - // compare - int comp = _BAVL_compare_nodes(o, node, c); - - // have we found a node that compares equal? - if (comp == 0) { - if (ref) { - *ref = c; - } - return 0; - } - - side = (comp == 1); - - // have we reached a leaf? - if (!c->link[side]) { - break; - } - - c = c->link[side]; - } - - // insert - c->link[side] = node; - node->parent = c; - node->link[0] = NULL; - node->link[1] = NULL; - node->balance = 0; -#ifdef BAVL_COUNT - node->count = 1; -#endif - -#ifdef BAVL_COUNT - // update counts - for (BAVLNode *p = c; p; p = p->parent) { - ASSERT(p->count < UINT64_MAX) - p->count++; - } -#endif - - // rebalance - _BAVL_rebalance(o, c, side, 1); - - BAVL_ASSERT(o) - - if (ref) { - *ref = c; - } - return 1; -} - -void BAVL_Remove (BAVL *o, BAVLNode *node) -{ - // if we have both subtrees, swap the node and the largest node - // in the left subtree, so we have at most one subtree - if (node->link[0] && node->link[1]) { - // find the largest node in the left subtree - BAVLNode *max = _BAVL_subtree_max(node->link[0]); - // swap the nodes - _BAVL_swap_nodes(o, node, max); - } - - // have at most one child now - ASSERT(!(node->link[0] && node->link[1])) - - BAVLNode *parent = node->parent; - BAVLNode *child = (node->link[0] ? node->link[0] : node->link[1]); - - if (parent) { - // remember on which side node is - int side = (node == parent->link[1]); - // replace node with child - _BAVL_replace_subtree(o, node, child); - // rebalance - _BAVL_rebalance(o, parent, side, -1); - } else { - // replace node with child - _BAVL_replace_subtree(o, node, child); - } - - BAVL_ASSERT(o) -} - -int BAVL_IsEmpty (const BAVL *o) -{ - return (!o->root); -} - -BAVLNode * BAVL_Lookup (const BAVL *o, void *val) -{ - if (!o->root) { - return NULL; - } - - BAVLNode *c = o->root; - while (1) { - // compare - int comp = _BAVL_compare_values(o, val, _BAVL_node_value(o, c)); - - // have we found a node that compares equal? - if (comp == 0) { - return c; - } - - int side = (comp == 1); - - // have we reached a leaf? - if (!c->link[side]) { - return c; - } - - c = c->link[side]; - } -} - -BAVLNode * BAVL_LookupExact (const BAVL *o, void *val) -{ - if (!o->root) { - return NULL; - } - - BAVLNode *c = o->root; - while (1) { - // compare - int comp = _BAVL_compare_values(o, val, _BAVL_node_value(o, c)); - - // have we found a node that compares equal? - if (comp == 0) { - return c; - } - - int side = (comp == 1); - - // have we reached a leaf? - if (!c->link[side]) { - return NULL; - } - - c = c->link[side]; - } -} - -BAVLNode * BAVL_GetFirst (const BAVL *o) -{ - if (!o->root) { - return NULL; - } - - BAVLNode *n = o->root; - while (n->link[0]) { - n = n->link[0]; - } - - return n; -} - -BAVLNode * BAVL_GetLast (const BAVL *o) -{ - if (!o->root) { - return NULL; - } - - BAVLNode *n = o->root; - while (n->link[1]) { - n = n->link[1]; - } - - return n; -} - -BAVLNode * BAVL_GetNext (const BAVL *o, BAVLNode *n) -{ - if (n->link[1]) { - n = n->link[1]; - while (n->link[0]) { - n = n->link[0]; - } - } else { - while (n->parent && n == n->parent->link[1]) { - n = n->parent; - } - n = n->parent; - } - - return n; -} - -BAVLNode * BAVL_GetPrev (const BAVL *o, BAVLNode *n) -{ - if (n->link[0]) { - n = n->link[0]; - while (n->link[1]) { - n = n->link[1]; - } - } else { - while (n->parent && n == n->parent->link[0]) { - n = n->parent; - } - n = n->parent; - } - - return n; -} - -#ifdef BAVL_COUNT - -static uint64_t BAVL_Count (const BAVL *o) -{ - return (o->root ? o->root->count : 0); -} - -static uint64_t BAVL_IndexOf (const BAVL *o, BAVLNode *n) -{ - uint64_t index = (n->link[0] ? n->link[0]->count : 0); - - for (BAVLNode *c = n; c->parent; c = c->parent) { - if (c == c->parent->link[1]) { - ASSERT(c->parent->count > c->count) - ASSERT(c->parent->count - c->count <= UINT64_MAX - index) - index += c->parent->count - c->count; - } - } - - return index; -} - -static BAVLNode * BAVL_GetAt (const BAVL *o, uint64_t index) -{ - if (index >= BAVL_Count(o)) { - return NULL; - } - - BAVLNode *c = o->root; - - while (1) { - ASSERT(c) - ASSERT(index < c->count) - - uint64_t left_count = (c->link[0] ? c->link[0]->count : 0); - - if (index == left_count) { - return c; - } - - if (index < left_count) { - c = c->link[0]; - } else { - c = c->link[1]; - index -= left_count + 1; - } - } -} - -#endif - -static void BAVL_Verify (BAVL *o) -{ - if (o->root) { - ASSERT(!o->root->parent) - _BAVL_assert_recurser(o, o->root); - } -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl.h deleted file mode 100644 index 6d98194b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file CAvl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_CAVL_H -#define BADVPN_CAVL_H - -#include "misc/debug.h" -#include "misc/merge.h" - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_decl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_decl.h deleted file mode 100644 index 7d54a815..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_decl.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * @file CAvl_decl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "CAvl_header.h" - -typedef struct { - CAvlLink root; -} CAvl; - -typedef struct { - CAvlEntry *ptr; - CAvlLink link; -} CAvlRef; - -static int CAvlIsNullRef (CAvlRef node); -static int CAvlIsValidRef (CAvlRef node); -static CAvlRef CAvlDeref (CAvlArg arg, CAvlLink link); - -static void CAvl_Init (CAvl *o); -#if !CAVL_PARAM_FEATURE_KEYS_ARE_INDICES -static int CAvl_Insert (CAvl *o, CAvlArg arg, CAvlRef node, CAvlRef *out_ref); -#else -static void CAvl_InsertAt (CAvl *o, CAvlArg arg, CAvlRef node, CAvlCount index); -#endif -static void CAvl_Remove (CAvl *o, CAvlArg arg, CAvlRef node); -#if !CAVL_PARAM_FEATURE_KEYS_ARE_INDICES && !CAVL_PARAM_FEATURE_NOKEYS -static CAvlRef CAvl_Lookup (const CAvl *o, CAvlArg arg, CAvlKey key); -static CAvlRef CAvl_LookupExact (const CAvl *o, CAvlArg arg, CAvlKey key); -static CAvlRef CAvl_GetFirstGreater (const CAvl *o, CAvlArg arg, CAvlKey key); -static CAvlRef CAvl_GetLastLesser (const CAvl *o, CAvlArg arg, CAvlKey key); -static CAvlRef CAvl_GetFirstGreaterEqual (const CAvl *o, CAvlArg arg, CAvlKey key); -static CAvlRef CAvl_GetLastLesserEqual (const CAvl *o, CAvlArg arg, CAvlKey key); -#endif -static CAvlRef CAvl_GetFirst (const CAvl *o, CAvlArg arg); -static CAvlRef CAvl_GetLast (const CAvl *o, CAvlArg arg); -static CAvlRef CAvl_GetNext (const CAvl *o, CAvlArg arg, CAvlRef node); -static CAvlRef CAvl_GetPrev (const CAvl *o, CAvlArg arg, CAvlRef node); -static int CAvl_IsEmpty (const CAvl *o); -static void CAvl_Verify (const CAvl *o, CAvlArg arg); -#if CAVL_PARAM_FEATURE_COUNTS -static CAvlCount CAvl_Count (const CAvl *o, CAvlArg arg); -static CAvlCount CAvl_IndexOf (const CAvl *o, CAvlArg arg, CAvlRef node); -static CAvlRef CAvl_GetAt (const CAvl *o, CAvlArg arg, CAvlCount index); -#endif -#if CAVL_PARAM_FEATURE_ASSOC -static CAvlAssoc CAvl_AssocSum (const CAvl *o, CAvlArg arg); -static CAvlAssoc CAvl_ExclusiveAssocPrefixSum (const CAvl *o, CAvlArg arg, CAvlRef node); -static CAvlRef CAvl_FindLastExclusiveAssocPrefixSumLesserEqual (const CAvl *o, CAvlArg arg, CAvlAssoc sum, int (*sum_less) (void *, CAvlAssoc, CAvlAssoc), void *user); -#endif - -#include "CAvl_footer.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_footer.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_footer.h deleted file mode 100644 index 43b85c3a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_footer.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @file CAvl_footer.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#undef CAVL_PARAM_NAME -#undef CAVL_PARAM_FEATURE_COUNTS -#undef CAVL_PARAM_FEATURE_KEYS_ARE_INDICES -#undef CAVL_PARAM_FEATURE_NOKEYS -#undef CAVL_PARAM_FEATURE_ASSOC -#undef CAVL_PARAM_TYPE_ENTRY -#undef CAVL_PARAM_TYPE_LINK -#undef CAVL_PARAM_TYPE_KEY -#undef CAVL_PARAM_TYPE_ARG -#undef CAVL_PARAM_TYPE_COUNT -#undef CAVL_PARAM_TYPE_ASSOC -#undef CAVL_PARAM_VALUE_COUNT_MAX -#undef CAVL_PARAM_VALUE_NULL -#undef CAVL_PARAM_VALUE_ASSOC_ZERO -#undef CAVL_PARAM_FUN_DEREF -#undef CAVL_PARAM_FUN_COMPARE_ENTRIES -#undef CAVL_PARAM_FUN_COMPARE_KEY_ENTRY -#undef CAVL_PARAM_FUN_ASSOC_VALUE -#undef CAVL_PARAM_FUN_ASSOC_OPER -#undef CAVL_PARAM_MEMBER_CHILD -#undef CAVL_PARAM_MEMBER_BALANCE -#undef CAVL_PARAM_MEMBER_PARENT -#undef CAVL_PARAM_MEMBER_COUNT -#undef CAVL_PARAM_MEMBER_ASSOC - -#undef CAvl -#undef CAvlEntry -#undef CAvlLink -#undef CAvlRef -#undef CAvlArg -#undef CAvlKey -#undef CAvlCount -#undef CAvlAssoc - -#undef CAvlIsNullRef -#undef CAvlIsValidRef -#undef CAvlDeref - -#undef CAvl_Init -#undef CAvl_Insert -#undef CAvl_InsertAt -#undef CAvl_Remove -#undef CAvl_Lookup -#undef CAvl_LookupExact -#undef CAvl_GetFirstGreater -#undef CAvl_GetLastLesser -#undef CAvl_GetFirstGreaterEqual -#undef CAvl_GetLastLesserEqual -#undef CAvl_GetFirst -#undef CAvl_GetLast -#undef CAvl_GetNext -#undef CAvl_GetPrev -#undef CAvl_IsEmpty -#undef CAvl_Verify -#undef CAvl_Count -#undef CAvl_IndexOf -#undef CAvl_GetAt -#undef CAvl_AssocSum -#undef CAvl_ExclusiveAssocPrefixSum -#undef CAvl_FindLastExclusiveAssocPrefixSumLesserEqual - -#undef CAvl_link -#undef CAvl_balance -#undef CAvl_parent -#undef CAvl_count -#undef CAvl_assoc -#undef CAvl_nulllink -#undef CAvl_nullref -#undef CAvl_compare_entries -#undef CAvl_compare_key_entry -#undef CAvl_compute_node_assoc -#undef CAvl_check_parent -#undef CAvl_verify_recurser -#undef CAvl_assert_tree -#undef CAvl_update_count_from_children -#undef CAvl_rotate -#undef CAvl_subtree_min -#undef CAvl_subtree_max -#undef CAvl_replace_subtree_fix_assoc -#undef CAvl_swap_for_remove -#undef CAvl_rebalance -#undef CAvl_child_count -#undef CAvl_MAX -#undef CAvl_OPTNEG diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_header.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_header.h deleted file mode 100644 index 91ea7df6..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_header.h +++ /dev/null @@ -1,141 +0,0 @@ -/** - * @file CAvl_header.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Preprocessor inputs: -// CAVL_PARAM_NAME - name of this data structure -// CAVL_PARAM_FEATURE_COUNTS - whether to keep count information (0 or 1) -// CAVL_PARAM_FEATURE_KEYS_ARE_INDICES - (0 or 1) whether to assume the keys are entry indices -// (number of entries lesser than given entry). If yes, CAVL_PARAM_TYPE_KEY is unused. -// Requires CAVL_PARAM_FEATURE_COUNTS. -// CAVL_PARAM_FEATURE_NOKEYS - define to 1 if there is no need for a lookup operation -// CAVL_PARAM_FEATURE_ASSOC - define to 1 for computation of an associative operation on subtrees. -// If enabled, the following macros must be defined: CAVL_PARAM_TYPE_ASSOC, -// CAVL_PARAM_VALUE_ASSOC_ZERO, CAVL_PARAM_FUN_ASSOC_VALUE, -// CAVL_PARAM_FUN_ASSOC_OPER, CAVL_PARAM_MEMBER_ASSOC. -// CAVL_PARAM_TYPE_ENTRY - type of entry -// CAVL_PARAM_TYPE_LINK - type of entry link (usually pointer or index) -// CAVL_PARAM_TYPE_KEY - type of key (only if not CAVL_PARAM_FEATURE_KEYS_ARE_INDICES and -// not CAVL_PARAM_FEATURE_NOKEYS) -// CAVL_PARAM_TYPE_ARG - type of argument pass through to callbacks -// CAVL_PARAM_TYPE_COUNT - type of count (only if CAVL_PARAM_FEATURE_COUNTS) -// CAVL_PARAM_TYPE_ASSOC - type of associative operation result -// CAVL_PARAM_VALUE_COUNT_MAX - maximum value of count (type is CAVL_PARAM_TYPE_COUNT) -// CAVL_PARAM_VALUE_NULL - value of invalid link (type is CAVL_PARAM_TYPE_LINK) -// CAVL_PARAM_VALUE_ASSOC_ZERO - zero value for associative operation (type is CAVL_PARAM_TYPE_ASSOC). -// This must be both a left- and right-identity for the associative operation. -// CAVL_PARAM_FUN_DEREF(arg, link) - dereference a non-null link; returns pointer to CAVL_PARAM_TYPE_LINK -// CAVL_PARAM_FUN_COMPARE_ENTRIES(arg, entry1, entry2) - compare to entries; returns -1/0/1 -// CAVL_PARAM_FUN_COMPARE_KEY_ENTRY(arg, key1, entry2) - compare key and entry; returns -1/0/1 -// CAVL_PARAM_FUN_ASSOC_VALUE(arg, entry) - get value of a node for associative operation. -// The result will be cast to CAVL_PARAM_TYPE_ASSOC. -// CAVL_PARAM_FUN_ASSOC_OPER(arg, value1, value2) - compute the associative operation on two values. -// The type of the two values is CAVL_PARAM_TYPE_ASSOC, and the result will be cast to -// CAVL_PARAM_TYPE_ASSOC. -// CAVL_PARAM_MEMBER_CHILD - name of the child member in entry (type is CAVL_PARAM_TYPE_LINK[2]) -// CAVL_PARAM_MEMBER_BALANCE - name of the balance member in entry (type is any signed integer) -// CAVL_PARAM_MEMBER_PARENT - name of the parent member in entry (type is CAVL_PARAM_TYPE_LINK) -// CAVL_PARAM_MEMBER_COUNT - name of the count member in entry (type is CAVL_PARAM_TYPE_COUNT) -// (only if CAVL_PARAM_FEATURE_COUNTS) -// CAVL_PARAM_MEMBER_ASSOC - name of assoc member in entry (type is CAVL_PARAM_TYPE_ASSOC) - -#ifndef BADVPN_CAVL_H -#error CAvl.h has not been included -#endif - -#if CAVL_PARAM_FEATURE_KEYS_ARE_INDICES && !CAVL_PARAM_FEATURE_COUNTS -#error CAVL_PARAM_FEATURE_KEYS_ARE_INDICES requires CAVL_PARAM_FEATURE_COUNTS -#endif - -#if CAVL_PARAM_FEATURE_KEYS_ARE_INDICES && CAVL_PARAM_FEATURE_NOKEYS -#error CAVL_PARAM_FEATURE_KEYS_ARE_INDICES and CAVL_PARAM_FEATURE_NOKEYS cannot be used together -#endif - -// types -#define CAvl CAVL_PARAM_NAME -#define CAvlEntry CAVL_PARAM_TYPE_ENTRY -#define CAvlLink CAVL_PARAM_TYPE_LINK -#define CAvlRef MERGE(CAVL_PARAM_NAME, Ref) -#define CAvlArg CAVL_PARAM_TYPE_ARG -#define CAvlKey CAVL_PARAM_TYPE_KEY -#define CAvlCount CAVL_PARAM_TYPE_COUNT -#define CAvlAssoc CAVL_PARAM_TYPE_ASSOC - -// non-object public functions -#define CAvlIsNullRef MERGE(CAvl, IsNullRef) -#define CAvlIsValidRef MERGE(CAvl, IsValidRef) -#define CAvlDeref MERGE(CAvl, Deref) - -// public functions -#define CAvl_Init MERGE(CAvl, _Init) -#define CAvl_Insert MERGE(CAvl, _Insert) -#define CAvl_InsertAt MERGE(CAvl, _InsertAt) -#define CAvl_Remove MERGE(CAvl, _Remove) -#define CAvl_Lookup MERGE(CAvl, _Lookup) -#define CAvl_LookupExact MERGE(CAvl, _LookupExact) -#define CAvl_GetFirstGreater MERGE(CAvl, _GetFirstGreater) -#define CAvl_GetLastLesser MERGE(CAvl, _GetLastLesser) -#define CAvl_GetFirstGreaterEqual MERGE(CAvl, _GetFirstGreaterEqual) -#define CAvl_GetLastLesserEqual MERGE(CAvl, _GetLastLesserEqual) -#define CAvl_GetFirst MERGE(CAvl, _GetFirst) -#define CAvl_GetLast MERGE(CAvl, _GetLast) -#define CAvl_GetNext MERGE(CAvl, _GetNext) -#define CAvl_GetPrev MERGE(CAvl, _GetPrev) -#define CAvl_IsEmpty MERGE(CAvl, _IsEmpty) -#define CAvl_Verify MERGE(CAvl, _Verify) -#define CAvl_Count MERGE(CAvl, _Count) -#define CAvl_IndexOf MERGE(CAvl, _IndexOf) -#define CAvl_GetAt MERGE(CAvl, _GetAt) -#define CAvl_AssocSum MERGE(CAvl, _AssocSum) -#define CAvl_ExclusiveAssocPrefixSum MERGE(CAvl, _ExclusiveAssocPrefixSum) -#define CAvl_FindLastExclusiveAssocPrefixSumLesserEqual MERGE(CAvl, _FindLastExclusiveAssocPrefixSumLesserEqual) - -// private stuff -#define CAvl_link(entry) ((entry).ptr->CAVL_PARAM_MEMBER_CHILD) -#define CAvl_balance(entry) ((entry).ptr->CAVL_PARAM_MEMBER_BALANCE) -#define CAvl_parent(entry) ((entry).ptr->CAVL_PARAM_MEMBER_PARENT) -#define CAvl_count(entry) ((entry).ptr->CAVL_PARAM_MEMBER_COUNT) -#define CAvl_assoc(entry) ((entry).ptr->CAVL_PARAM_MEMBER_ASSOC) -#define CAvl_nulllink MERGE(CAvl, __nulllink) -#define CAvl_nullref MERGE(CAvl, __nullref) -#define CAvl_compare_entries MERGE(CAVL_PARAM_NAME, _compare_entries) -#define CAvl_compare_key_entry MERGE(CAVL_PARAM_NAME, _compare_key_entry) -#define CAvl_compute_node_assoc MERGE(CAVL_PARAM_NAME, _compute_node_assoc) -#define CAvl_check_parent MERGE(CAVL_PARAM_NAME, _check_parent) -#define CAvl_verify_recurser MERGE(CAVL_PARAM_NAME, _verify_recurser) -#define CAvl_assert_tree MERGE(CAVL_PARAM_NAME, _assert_tree) -#define CAvl_update_count_from_children MERGE(CAVL_PARAM_NAME, _update_count_from_children) -#define CAvl_rotate MERGE(CAVL_PARAM_NAME, _rotate) -#define CAvl_subtree_min MERGE(CAVL_PARAM_NAME, _subtree_min) -#define CAvl_subtree_max MERGE(CAVL_PARAM_NAME, _subtree_max) -#define CAvl_replace_subtree_fix_assoc MERGE(CAVL_PARAM_NAME, _replace_subtree_fix_counts) -#define CAvl_swap_for_remove MERGE(CAVL_PARAM_NAME, _swap_entries) -#define CAvl_rebalance MERGE(CAVL_PARAM_NAME, _rebalance) -#define CAvl_child_count MERGE(CAvl, __child_count) -#define CAvl_MAX(_a, _b) ((_a) > (_b) ? (_a) : (_b)) -#define CAvl_OPTNEG(_a, _neg) ((_neg) ? -(_a) : (_a)) diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_impl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_impl.h deleted file mode 100644 index 984bdea1..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CAvl_impl.h +++ /dev/null @@ -1,949 +0,0 @@ -/** - * @file CAvl_impl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "CAvl_header.h" - -static CAvlLink CAvl_nulllink (void) -{ - return CAVL_PARAM_VALUE_NULL; -} - -static CAvlRef CAvl_nullref (void) -{ - CAvlRef n; - n.link = CAVL_PARAM_VALUE_NULL; - n.ptr = NULL; - return n; -} - -#if !CAVL_PARAM_FEATURE_KEYS_ARE_INDICES - -static int CAvl_compare_entries (CAvlArg arg, CAvlRef node1, CAvlRef node2) -{ - int res = CAVL_PARAM_FUN_COMPARE_ENTRIES(arg, node1, node2); - ASSERT(res >= -1) - ASSERT(res <= 1) - - return res; -} - -#if !CAVL_PARAM_FEATURE_NOKEYS - -static int CAvl_compare_key_entry (CAvlArg arg, CAvlKey key1, CAvlRef node2) -{ - int res = CAVL_PARAM_FUN_COMPARE_KEY_ENTRY(arg, key1, node2); - ASSERT(res >= -1) - ASSERT(res <= 1) - - return res; -} - -#endif - -#endif - -#if CAVL_PARAM_FEATURE_ASSOC - -static CAvlAssoc CAvl_compute_node_assoc (CAvlArg arg, CAvlRef node) -{ - CAvlAssoc sum = CAVL_PARAM_FUN_ASSOC_VALUE(arg, node); - if (CAvl_link(node)[0] != CAvl_nulllink()) { - sum = CAVL_PARAM_FUN_ASSOC_OPER(arg, CAvl_assoc(CAvlDeref(arg, CAvl_link(node)[0])), sum); - } - if (CAvl_link(node)[1] != CAvl_nulllink()) { - sum = CAVL_PARAM_FUN_ASSOC_OPER(arg, sum, CAvl_assoc(CAvlDeref(arg, CAvl_link(node)[1]))); - } - return sum; -} - -#endif - -static int CAvl_check_parent (CAvlRef p, CAvlRef c) -{ - return (p.link == CAvl_parent(c)) && (p.link == CAvl_nulllink() || c.link == CAvl_link(p)[0] || c.link == CAvl_link(p)[1]); -} - -static int CAvl_verify_recurser (CAvlArg arg, CAvlRef n) -{ - ASSERT_FORCE(CAvl_balance(n) >= -1) - ASSERT_FORCE(CAvl_balance(n) <= 1) - - int height_left = 0; - int height_right = 0; -#if CAVL_PARAM_FEATURE_COUNTS - CAvlCount count_left = 0; - CAvlCount count_right = 0; -#endif - - // check left subtree - if (CAvl_link(n)[0] != CAvl_nulllink()) { - // check parent link - ASSERT_FORCE(CAvl_parent(CAvlDeref(arg, CAvl_link(n)[0])) == n.link) - // check binary search tree -#if !CAVL_PARAM_FEATURE_KEYS_ARE_INDICES - ASSERT_FORCE(CAvl_compare_entries(arg, CAvlDeref(arg, CAvl_link(n)[0]), n) == -1) -#endif - // recursively calculate height - height_left = CAvl_verify_recurser(arg, CAvlDeref(arg, CAvl_link(n)[0])); -#if CAVL_PARAM_FEATURE_COUNTS - count_left = CAvl_count(CAvlDeref(arg, CAvl_link(n)[0])); -#endif - } - - // check right subtree - if (CAvl_link(n)[1] != CAvl_nulllink()) { - // check parent link - ASSERT_FORCE(CAvl_parent(CAvlDeref(arg, CAvl_link(n)[1])) == n.link) - // check binary search tree -#if !CAVL_PARAM_FEATURE_KEYS_ARE_INDICES - ASSERT_FORCE(CAvl_compare_entries(arg, CAvlDeref(arg, CAvl_link(n)[1]), n) == 1) -#endif - // recursively calculate height - height_right = CAvl_verify_recurser(arg, CAvlDeref(arg, CAvl_link(n)[1])); -#if CAVL_PARAM_FEATURE_COUNTS - count_right = CAvl_count(CAvlDeref(arg, CAvl_link(n)[1])); -#endif - } - - // check balance factor - ASSERT_FORCE(CAvl_balance(n) == height_right - height_left) - -#if CAVL_PARAM_FEATURE_COUNTS - // check count - ASSERT_FORCE(CAvl_count(n) == 1 + count_left + count_right) -#endif - -#if CAVL_PARAM_FEATURE_ASSOC - // check assoc - ASSERT_FORCE(CAvl_assoc(n) == CAvl_compute_node_assoc(arg, n)) -#endif - - return CAvl_MAX(height_left, height_right) + 1; -} - -static void CAvl_assert_tree (CAvl *o, CAvlArg arg) -{ -#ifdef CAVL_AUTO_VERIFY - CAvl_Verify(o, arg); -#endif -} - -#if CAVL_PARAM_FEATURE_COUNTS -static void CAvl_update_count_from_children (CAvlArg arg, CAvlRef n) -{ - CAvlCount left_count = CAvl_link(n)[0] != CAvl_nulllink() ? CAvl_count(CAvlDeref(arg, CAvl_link(n)[0])) : 0; - CAvlCount right_count = CAvl_link(n)[1] != CAvl_nulllink() ? CAvl_count(CAvlDeref(arg, CAvl_link(n)[1])) : 0; - CAvl_count(n) = 1 + left_count + right_count; -} -#endif - -static void CAvl_rotate (CAvl *o, CAvlArg arg, CAvlRef r, uint8_t dir, CAvlRef r_parent) -{ - ASSERT(CAvl_check_parent(r_parent, r)) - CAvlRef nr = CAvlDeref(arg, CAvl_link(r)[!dir]); - - CAvl_link(r)[!dir] = CAvl_link(nr)[dir]; - if (CAvl_link(r)[!dir] != CAvl_nulllink()) { - CAvl_parent(CAvlDeref(arg, CAvl_link(r)[!dir])) = r.link; - } - CAvl_link(nr)[dir] = r.link; - CAvl_parent(nr) = r_parent.link; - if (r_parent.link != CAvl_nulllink()) { - CAvl_link(r_parent)[r.link == CAvl_link(r_parent)[1]] = nr.link; - } else { - o->root = nr.link; - } - CAvl_parent(r) = nr.link; - -#if CAVL_PARAM_FEATURE_COUNTS - CAvl_update_count_from_children(arg, r); - CAvl_update_count_from_children(arg, nr); -#endif - -#if CAVL_PARAM_FEATURE_ASSOC - CAvl_assoc(r) = CAvl_compute_node_assoc(arg, r); - CAvl_assoc(nr) = CAvl_compute_node_assoc(arg, nr); -#endif -} - -static CAvlRef CAvl_subtree_min (CAvlArg arg, CAvlRef n) -{ - ASSERT(n.link != CAvl_nulllink()) - - while (CAvl_link(n)[0] != CAvl_nulllink()) { - n = CAvlDeref(arg, CAvl_link(n)[0]); - } - - return n; -} - -static CAvlRef CAvl_subtree_max (CAvlArg arg, CAvlRef n) -{ - ASSERT(n.link != CAvl_nulllink()) - - while (CAvl_link(n)[1] != CAvl_nulllink()) { - n = CAvlDeref(arg, CAvl_link(n)[1]); - } - - return n; -} - -static void CAvl_replace_subtree_fix_assoc (CAvl *o, CAvlArg arg, CAvlRef dest, CAvlRef n, CAvlRef dest_parent) -{ - ASSERT(dest.link != CAvl_nulllink()) - ASSERT(CAvl_check_parent(dest_parent, dest)) - - if (dest_parent.link != CAvl_nulllink()) { - CAvl_link(dest_parent)[dest.link == CAvl_link(dest_parent)[1]] = n.link; - } else { - o->root = n.link; - } - if (n.link != CAvl_nulllink()) { - CAvl_parent(n) = CAvl_parent(dest); - } - -#if CAVL_PARAM_FEATURE_COUNTS || CAVL_PARAM_FEATURE_ASSOC - for (CAvlRef c = dest_parent; c.link != CAvl_nulllink(); c = CAvlDeref(arg, CAvl_parent(c))) { -#if CAVL_PARAM_FEATURE_COUNTS - ASSERT(CAvl_count(c) >= CAvl_count(dest)) - CAvl_count(c) -= CAvl_count(dest); - if (n.link != CAvl_nulllink()) { - ASSERT(CAvl_count(n) <= CAVL_PARAM_VALUE_COUNT_MAX - CAvl_count(c)) - CAvl_count(c) += CAvl_count(n); - } -#endif -#if CAVL_PARAM_FEATURE_ASSOC - CAvl_assoc(c) = CAvl_compute_node_assoc(arg, c); -#endif - } -#endif -} - -static void CAvl_swap_for_remove (CAvl *o, CAvlArg arg, CAvlRef node, CAvlRef enode, CAvlRef node_parent, CAvlRef enode_parent) -{ - ASSERT(CAvl_check_parent(node_parent, node)) - ASSERT(CAvl_check_parent(enode_parent, enode)) - - if (enode_parent.link == node.link) { - // when the nodes are directly connected we need special handling - - uint8_t side = (enode.link == CAvl_link(node)[1]); - CAvlRef c = CAvlDeref(arg, CAvl_link(node)[!side]); - - if ((CAvl_link(node)[0] = CAvl_link(enode)[0]) != CAvl_nulllink()) { - CAvl_parent(CAvlDeref(arg, CAvl_link(node)[0])) = node.link; - } - if ((CAvl_link(node)[1] = CAvl_link(enode)[1]) != CAvl_nulllink()) { - CAvl_parent(CAvlDeref(arg, CAvl_link(node)[1])) = node.link; - } - - CAvl_parent(enode) = CAvl_parent(node); - if (node_parent.link != CAvl_nulllink()) { - CAvl_link(node_parent)[node.link == CAvl_link(node_parent)[1]] = enode.link; - } else { - o->root = enode.link; - } - - CAvl_link(enode)[side] = node.link; - CAvl_parent(node) = enode.link; - if ((CAvl_link(enode)[!side] = c.link) != CAvl_nulllink()) { - CAvl_parent(c) = enode.link; - } - } else { - CAvlRef temp; - - // swap parents - temp = node_parent; - CAvl_parent(node) = CAvl_parent(enode); - if (enode_parent.link != CAvl_nulllink()) { - CAvl_link(enode_parent)[enode.link == CAvl_link(enode_parent)[1]] = node.link; - } else { - o->root = node.link; - } - CAvl_parent(enode) = temp.link; - if (temp.link != CAvl_nulllink()) { - CAvl_link(temp)[node.link == CAvl_link(temp)[1]] = enode.link; - } else { - o->root = enode.link; - } - - // swap left children - temp = CAvlDeref(arg, CAvl_link(node)[0]); - if ((CAvl_link(node)[0] = CAvl_link(enode)[0]) != CAvl_nulllink()) { - CAvl_parent(CAvlDeref(arg, CAvl_link(node)[0])) = node.link; - } - if ((CAvl_link(enode)[0] = temp.link) != CAvl_nulllink()) { - CAvl_parent(CAvlDeref(arg, CAvl_link(enode)[0])) = enode.link; - } - - // swap right children - temp = CAvlDeref(arg, CAvl_link(node)[1]); - if ((CAvl_link(node)[1] = CAvl_link(enode)[1]) != CAvl_nulllink()) { - CAvl_parent(CAvlDeref(arg, CAvl_link(node)[1])) = node.link; - } - if ((CAvl_link(enode)[1] = temp.link) != CAvl_nulllink()) { - CAvl_parent(CAvlDeref(arg, CAvl_link(enode)[1])) = enode.link; - } - } - - // swap balance factors - int8_t b = CAvl_balance(node); - CAvl_balance(node) = CAvl_balance(enode); - CAvl_balance(enode) = b; - -#if CAVL_PARAM_FEATURE_COUNTS - // swap counts - CAvlCount c = CAvl_count(node); - CAvl_count(node) = CAvl_count(enode); - CAvl_count(enode) = c; -#endif - - // not fixing assoc values here because CAvl_replace_subtree_fix_assoc() will do it -} - -static void CAvl_rebalance (CAvl *o, CAvlArg arg, CAvlRef node, uint8_t side, int8_t deltac) -{ - ASSERT(side == 0 || side == 1) - ASSERT(deltac >= -1 && deltac <= 1) - ASSERT(CAvl_balance(node) >= -1 && CAvl_balance(node) <= 1) - - // if no subtree changed its height, no more rebalancing is needed - if (deltac == 0) { - return; - } - - // calculate how much our height changed - int8_t delta = CAvl_MAX(deltac, CAvl_OPTNEG(CAvl_balance(node), side)) - CAvl_MAX(0, CAvl_OPTNEG(CAvl_balance(node), side)); - ASSERT(delta >= -1 && delta <= 1) - - // update our balance factor - CAvl_balance(node) -= CAvl_OPTNEG(deltac, side); - - CAvlRef child; - CAvlRef gchild; - - // perform transformations if the balance factor is wrong - if (CAvl_balance(node) == 2 || CAvl_balance(node) == -2) { - uint8_t bside; - int8_t bsidef; - if (CAvl_balance(node) == 2) { - bside = 1; - bsidef = 1; - } else { - bside = 0; - bsidef = -1; - } - - ASSERT(CAvl_link(node)[bside] != CAvl_nulllink()) - child = CAvlDeref(arg, CAvl_link(node)[bside]); - - switch (CAvl_balance(child) * bsidef) { - case 1: - CAvl_rotate(o, arg, node, !bside, CAvlDeref(arg, CAvl_parent(node))); - CAvl_balance(node) = 0; - CAvl_balance(child) = 0; - node = child; - delta -= 1; - break; - case 0: - CAvl_rotate(o, arg, node, !bside, CAvlDeref(arg, CAvl_parent(node))); - CAvl_balance(node) = 1 * bsidef; - CAvl_balance(child) = -1 * bsidef; - node = child; - break; - case -1: - ASSERT(CAvl_link(child)[!bside] != CAvl_nulllink()) - gchild = CAvlDeref(arg, CAvl_link(child)[!bside]); - CAvl_rotate(o, arg, child, bside, node); - CAvl_rotate(o, arg, node, !bside, CAvlDeref(arg, CAvl_parent(node))); - CAvl_balance(node) = -CAvl_MAX(0, CAvl_balance(gchild) * bsidef) * bsidef; - CAvl_balance(child) = CAvl_MAX(0, -CAvl_balance(gchild) * bsidef) * bsidef; - CAvl_balance(gchild) = 0; - node = gchild; - delta -= 1; - break; - default: - ASSERT(0); - } - } - - ASSERT(delta >= -1 && delta <= 1) - // Transformations above preserve this. Proof: - // - if a child subtree gained 1 height and rebalancing was needed, - // it was the heavier subtree. Then delta was was originally 1, because - // the heaviest subtree gained one height. If the transformation reduces - // delta by one, it becomes 0. - // - if a child subtree lost 1 height and rebalancing was needed, it - // was the lighter subtree. Then delta was originally 0, because - // the height of the heaviest subtree was unchanged. If the transformation - // reduces delta by one, it becomes -1. - - if (CAvl_parent(node) != CAvl_nulllink()) { - CAvlRef node_parent = CAvlDeref(arg, CAvl_parent(node)); - CAvl_rebalance(o, arg, node_parent, node.link == CAvl_link(node_parent)[1], delta); - } -} - -#if CAVL_PARAM_FEATURE_KEYS_ARE_INDICES -static CAvlCount CAvl_child_count (CAvlArg arg, CAvlRef n, int dir) -{ - return (CAvl_link(n)[dir] != CAvl_nulllink() ? CAvl_count(CAvlDeref(arg, CAvl_link(n)[dir])) : 0); -} -#endif - -static int CAvlIsNullRef (CAvlRef node) -{ - return node.link == CAvl_nulllink(); -} - -static int CAvlIsValidRef (CAvlRef node) -{ - return node.link != CAvl_nulllink(); -} - -static CAvlRef CAvlDeref (CAvlArg arg, CAvlLink link) -{ - if (link == CAvl_nulllink()) { - return CAvl_nullref(); - } - - CAvlRef n; - n.ptr = CAVL_PARAM_FUN_DEREF(arg, link); - n.link = link; - - ASSERT(n.ptr) - - return n; -} - -static void CAvl_Init (CAvl *o) -{ - o->root = CAvl_nulllink(); -} - -#if !CAVL_PARAM_FEATURE_KEYS_ARE_INDICES - -static int CAvl_Insert (CAvl *o, CAvlArg arg, CAvlRef node, CAvlRef *out_ref) -{ - ASSERT(node.link != CAvl_nulllink()) -#if CAVL_PARAM_FEATURE_COUNTS - ASSERT(CAvl_Count(o, arg) < CAVL_PARAM_VALUE_COUNT_MAX) -#endif - - // insert to root? - if (o->root == CAvl_nulllink()) { - o->root = node.link; - CAvl_parent(node) = CAvl_nulllink(); - CAvl_link(node)[0] = CAvl_nulllink(); - CAvl_link(node)[1] = CAvl_nulllink(); - CAvl_balance(node) = 0; -#if CAVL_PARAM_FEATURE_COUNTS - CAvl_count(node) = 1; -#endif -#if CAVL_PARAM_FEATURE_ASSOC - CAvl_assoc(node) = CAVL_PARAM_FUN_ASSOC_VALUE(arg, node); -#endif - - CAvl_assert_tree(o, arg); - - if (out_ref) { - *out_ref = CAvl_nullref(); - } - return 1; - } - - CAvlRef c = CAvlDeref(arg, o->root); - int side; - while (1) { - int comp = CAvl_compare_entries(arg, node, c); - - if (comp == 0) { - if (out_ref) { - *out_ref = c; - } - return 0; - } - - side = (comp == 1); - - if (CAvl_link(c)[side] == CAvl_nulllink()) { - break; - } - - c = CAvlDeref(arg, CAvl_link(c)[side]); - } - - CAvl_link(c)[side] = node.link; - CAvl_parent(node) = c.link; - CAvl_link(node)[0] = CAvl_nulllink(); - CAvl_link(node)[1] = CAvl_nulllink(); - CAvl_balance(node) = 0; -#if CAVL_PARAM_FEATURE_COUNTS - CAvl_count(node) = 1; -#endif -#if CAVL_PARAM_FEATURE_ASSOC - CAvl_assoc(node) = CAVL_PARAM_FUN_ASSOC_VALUE(arg, node); -#endif - -#if CAVL_PARAM_FEATURE_COUNTS || CAVL_PARAM_FEATURE_ASSOC - for (CAvlRef p = c; p.link != CAvl_nulllink(); p = CAvlDeref(arg, CAvl_parent(p))) { -#if CAVL_PARAM_FEATURE_COUNTS - CAvl_count(p)++; -#endif -#if CAVL_PARAM_FEATURE_ASSOC - CAvl_assoc(p) = CAvl_compute_node_assoc(arg, p); -#endif - } -#endif - - CAvl_rebalance(o, arg, c, side, 1); - - CAvl_assert_tree(o, arg); - - if (out_ref) { - *out_ref = c; - } - return 1; -} - -#else - -static void CAvl_InsertAt (CAvl *o, CAvlArg arg, CAvlRef node, CAvlCount index) -{ - ASSERT(node.link != CAvl_nulllink()) - ASSERT(index <= CAvl_Count(o, arg)) - ASSERT(CAvl_Count(o, arg) < CAVL_PARAM_VALUE_COUNT_MAX) - - // insert to root? - if (o->root == CAvl_nulllink()) { - o->root = node.link; - CAvl_parent(node) = CAvl_nulllink(); - CAvl_link(node)[0] = CAvl_nulllink(); - CAvl_link(node)[1] = CAvl_nulllink(); - CAvl_balance(node) = 0; - CAvl_count(node) = 1; -#if CAVL_PARAM_FEATURE_ASSOC - CAvl_assoc(node) = CAVL_PARAM_FUN_ASSOC_VALUE(arg, node); -#endif - - CAvl_assert_tree(o, arg); - return; - } - - CAvlRef c = CAvlDeref(arg, o->root); - CAvlCount c_idx = CAvl_child_count(arg, c, 0); - int side; - while (1) { - side = (index > c_idx); - - if (CAvl_link(c)[side] == CAvl_nulllink()) { - break; - } - - c = CAvlDeref(arg, CAvl_link(c)[side]); - - if (side == 0) { - c_idx -= 1 + CAvl_child_count(arg, c, 1); - } else { - c_idx += 1 + CAvl_child_count(arg, c, 0); - } - } - - CAvl_link(c)[side] = node.link; - CAvl_parent(node) = c.link; - CAvl_link(node)[0] = CAvl_nulllink(); - CAvl_link(node)[1] = CAvl_nulllink(); - CAvl_balance(node) = 0; - CAvl_count(node) = 1; -#if CAVL_PARAM_FEATURE_ASSOC - CAvl_assoc(node) = CAVL_PARAM_FUN_ASSOC_VALUE(arg, node); -#endif - - for (CAvlRef p = c; p.link != CAvl_nulllink(); p = CAvlDeref(arg, CAvl_parent(p))) { - CAvl_count(p)++; -#if CAVL_PARAM_FEATURE_ASSOC - CAvl_assoc(p) = CAvl_compute_node_assoc(arg, p); -#endif - } - - CAvl_rebalance(o, arg, c, side, 1); - - CAvl_assert_tree(o, arg); - return; -} - -#endif - -static void CAvl_Remove (CAvl *o, CAvlArg arg, CAvlRef node) -{ - ASSERT(node.link != CAvl_nulllink()) - ASSERT(o->root != CAvl_nulllink()) - - if (CAvl_link(node)[0] != CAvl_nulllink() && CAvl_link(node)[1] != CAvl_nulllink()) { - CAvlRef max = CAvl_subtree_max(arg, CAvlDeref(arg, CAvl_link(node)[0])); - CAvl_swap_for_remove(o, arg, node, max, CAvlDeref(arg, CAvl_parent(node)), CAvlDeref(arg, CAvl_parent(max))); - } - - ASSERT(CAvl_link(node)[0] == CAvl_nulllink() || CAvl_link(node)[1] == CAvl_nulllink()) - - CAvlRef paren = CAvlDeref(arg, CAvl_parent(node)); - CAvlRef child = (CAvl_link(node)[0] != CAvl_nulllink() ? CAvlDeref(arg, CAvl_link(node)[0]) : CAvlDeref(arg, CAvl_link(node)[1])); - - if (paren.link != CAvl_nulllink()) { - int side = (node.link == CAvl_link(paren)[1]); - CAvl_replace_subtree_fix_assoc(o, arg, node, child, paren); - CAvl_rebalance(o, arg, paren, side, -1); - } else { - CAvl_replace_subtree_fix_assoc(o, arg, node, child, paren); - } - - CAvl_assert_tree(o, arg); -} - -#if !CAVL_PARAM_FEATURE_KEYS_ARE_INDICES && !CAVL_PARAM_FEATURE_NOKEYS - -static CAvlRef CAvl_Lookup (const CAvl *o, CAvlArg arg, CAvlKey key) -{ - if (o->root == CAvl_nulllink()) { - return CAvl_nullref(); - } - - CAvlRef c = CAvlDeref(arg, o->root); - while (1) { - // compare - int comp = CAvl_compare_key_entry(arg, key, c); - - // have we found a node that compares equal? - if (comp == 0) { - return c; - } - - int side = (comp == 1); - - // have we reached a leaf? - if (CAvl_link(c)[side] == CAvl_nulllink()) { - return c; - } - - c = CAvlDeref(arg, CAvl_link(c)[side]); - } -} - -static CAvlRef CAvl_LookupExact (const CAvl *o, CAvlArg arg, CAvlKey key) -{ - if (o->root == CAvl_nulllink()) { - return CAvl_nullref(); - } - - CAvlRef c = CAvlDeref(arg, o->root); - while (1) { - // compare - int comp = CAvl_compare_key_entry(arg, key, c); - - // have we found a node that compares equal? - if (comp == 0) { - return c; - } - - int side = (comp == 1); - - // have we reached a leaf? - if (CAvl_link(c)[side] == CAvl_nulllink()) { - return CAvl_nullref(); - } - - c = CAvlDeref(arg, CAvl_link(c)[side]); - } -} - -static CAvlRef CAvl_GetFirstGreater (const CAvl *o, CAvlArg arg, CAvlKey key) -{ - CAvlRef c = CAvl_Lookup(o, arg, key); - if (CAvlIsNullRef(c)) { - return CAvl_nullref(); - } - - if (CAvl_compare_key_entry(arg, key, c) >= 0) { - c = CAvl_GetNext(o, arg, c); - if (CAvlIsNullRef(c)) { - return CAvl_nullref(); - } - } - - ASSERT(CAvl_compare_key_entry(arg, key, c) < 0); - - return c; -} - -static CAvlRef CAvl_GetLastLesser (const CAvl *o, CAvlArg arg, CAvlKey key) -{ - CAvlRef c = CAvl_Lookup(o, arg, key); - if (CAvlIsNullRef(c)) { - return CAvl_nullref(); - } - - if (CAvl_compare_key_entry(arg, key, c) <= 0) { - c = CAvl_GetPrev(o, arg, c); - if (CAvlIsNullRef(c)) { - return CAvl_nullref(); - } - } - - ASSERT(CAvl_compare_key_entry(arg, key, c) > 0); - - return c; -} - -static CAvlRef CAvl_GetFirstGreaterEqual (const CAvl *o, CAvlArg arg, CAvlKey key) -{ - CAvlRef c = CAvl_Lookup(o, arg, key); - if (CAvlIsNullRef(c)) { - return CAvl_nullref(); - } - - if (CAvl_compare_key_entry(arg, key, c) > 0) { - c = CAvl_GetNext(o, arg, c); - if (CAvlIsNullRef(c)) { - return CAvl_nullref(); - } - } - - ASSERT(CAvl_compare_key_entry(arg, key, c) <= 0); - - return c; -} - -static CAvlRef CAvl_GetLastLesserEqual (const CAvl *o, CAvlArg arg, CAvlKey key) -{ - CAvlRef c = CAvl_Lookup(o, arg, key); - if (CAvlIsNullRef(c)) { - return CAvl_nullref(); - } - - if (CAvl_compare_key_entry(arg, key, c) < 0) { - c = CAvl_GetPrev(o, arg, c); - if (CAvlIsNullRef(c)) { - return CAvl_nullref(); - } - } - - ASSERT(CAvl_compare_key_entry(arg, key, c) >= 0); - - return c; -} - -#endif - -static CAvlRef CAvl_GetFirst (const CAvl *o, CAvlArg arg) -{ - if (o->root == CAvl_nulllink()) { - return CAvl_nullref(); - } - - return CAvl_subtree_min(arg, CAvlDeref(arg, o->root)); -} - -static CAvlRef CAvl_GetLast (const CAvl *o, CAvlArg arg) -{ - if (o->root == CAvl_nulllink()) { - return CAvl_nullref(); - } - - return CAvl_subtree_max(arg, CAvlDeref(arg, o->root)); -} - -static CAvlRef CAvl_GetNext (const CAvl *o, CAvlArg arg, CAvlRef node) -{ - ASSERT(node.link != CAvl_nulllink()) - ASSERT(o->root != CAvl_nulllink()) - - if (CAvl_link(node)[1] != CAvl_nulllink()) { - node = CAvlDeref(arg, CAvl_link(node)[1]); - while (CAvl_link(node)[0] != CAvl_nulllink()) { - node = CAvlDeref(arg, CAvl_link(node)[0]); - } - } else { - while (CAvl_parent(node) != CAvl_nulllink() && node.link == CAvl_link(CAvlDeref(arg, CAvl_parent(node)))[1]) { - node = CAvlDeref(arg, CAvl_parent(node)); - } - node = CAvlDeref(arg, CAvl_parent(node)); - } - - return node; -} - -static CAvlRef CAvl_GetPrev (const CAvl *o, CAvlArg arg, CAvlRef node) -{ - ASSERT(node.link != CAvl_nulllink()) - ASSERT(o->root != CAvl_nulllink()) - - if (CAvl_link(node)[0] != CAvl_nulllink()) { - node = CAvlDeref(arg, CAvl_link(node)[0]); - while (CAvl_link(node)[1] != CAvl_nulllink()) { - node = CAvlDeref(arg, CAvl_link(node)[1]); - } - } else { - while (CAvl_parent(node) != CAvl_nulllink() && node.link == CAvl_link(CAvlDeref(arg, CAvl_parent(node)))[0]) { - node = CAvlDeref(arg, CAvl_parent(node)); - } - node = CAvlDeref(arg, CAvl_parent(node)); - } - - return node; -} - -static int CAvl_IsEmpty (const CAvl *o) -{ - return o->root == CAvl_nulllink(); -} - -static void CAvl_Verify (const CAvl *o, CAvlArg arg) -{ - if (o->root != CAvl_nulllink()) { - CAvlRef root = CAvlDeref(arg, o->root); - ASSERT(CAvl_parent(root) == CAvl_nulllink()) - CAvl_verify_recurser(arg, root); - } -} - -#if CAVL_PARAM_FEATURE_COUNTS - -static CAvlCount CAvl_Count (const CAvl *o, CAvlArg arg) -{ - return (o->root != CAvl_nulllink() ? CAvl_count(CAvlDeref(arg, o->root)) : 0); -} - -static CAvlCount CAvl_IndexOf (const CAvl *o, CAvlArg arg, CAvlRef node) -{ - ASSERT(node.link != CAvl_nulllink()) - ASSERT(o->root != CAvl_nulllink()) - - CAvlCount index = (CAvl_link(node)[0] != CAvl_nulllink() ? CAvl_count(CAvlDeref(arg, CAvl_link(node)[0])) : 0); - - CAvlRef paren = CAvlDeref(arg, CAvl_parent(node)); - - for (CAvlRef c = node; paren.link != CAvl_nulllink(); c = paren, paren = CAvlDeref(arg, CAvl_parent(c))) { - if (c.link == CAvl_link(paren)[1]) { - ASSERT(CAvl_count(paren) > CAvl_count(c)) - ASSERT(CAvl_count(paren) - CAvl_count(c) <= CAVL_PARAM_VALUE_COUNT_MAX - index) - index += CAvl_count(paren) - CAvl_count(c); - } - } - - return index; -} - -static CAvlRef CAvl_GetAt (const CAvl *o, CAvlArg arg, CAvlCount index) -{ - if (index >= CAvl_Count(o, arg)) { - return CAvl_nullref(); - } - - CAvlRef c = CAvlDeref(arg, o->root); - - while (1) { - ASSERT(c.link != CAvl_nulllink()) - ASSERT(index < CAvl_count(c)) - - CAvlCount left_count = (CAvl_link(c)[0] != CAvl_nulllink() ? CAvl_count(CAvlDeref(arg, CAvl_link(c)[0])) : 0); - - if (index == left_count) { - return c; - } - - if (index < left_count) { - c = CAvlDeref(arg, CAvl_link(c)[0]); - } else { - c = CAvlDeref(arg, CAvl_link(c)[1]); - index -= left_count + 1; - } - } -} - -#endif - -#if CAVL_PARAM_FEATURE_ASSOC - -static CAvlAssoc CAvl_AssocSum (const CAvl *o, CAvlArg arg) -{ - if (o->root == CAvl_nulllink()) { - return CAVL_PARAM_VALUE_ASSOC_ZERO; - } - CAvlRef root = CAvlDeref(arg, o->root); - return CAvl_assoc(root); -} - -static CAvlAssoc CAvl_ExclusiveAssocPrefixSum (const CAvl *o, CAvlArg arg, CAvlRef node) -{ - ASSERT(node.link != CAvl_nulllink()) - ASSERT(o->root != CAvl_nulllink()) - - CAvlAssoc sum = (CAvl_link(node)[0] != CAvl_nulllink() ? CAvl_assoc(CAvlDeref(arg, CAvl_link(node)[0])) : CAVL_PARAM_VALUE_ASSOC_ZERO); - - CAvlRef paren = CAvlDeref(arg, CAvl_parent(node)); - - for (CAvlRef c = node; paren.link != CAvl_nulllink(); c = paren, paren = CAvlDeref(arg, CAvl_parent(c))) { - if (c.link == CAvl_link(paren)[1]) { - CAvlAssoc c_val = CAVL_PARAM_FUN_ASSOC_VALUE(arg, paren); - sum = CAVL_PARAM_FUN_ASSOC_OPER(arg, c_val, sum); - if (CAvl_link(paren)[0] != CAvl_nulllink()) { - sum = CAVL_PARAM_FUN_ASSOC_OPER(arg, CAvl_assoc(CAvlDeref(arg, CAvl_link(paren)[0])), sum); - } - } - } - - return sum; -} - -static CAvlRef CAvl_FindLastExclusiveAssocPrefixSumLesserEqual (const CAvl *o, CAvlArg arg, CAvlAssoc sum, int (*sum_less) (void *, CAvlAssoc, CAvlAssoc), void *user) -{ - CAvlRef result = CAvl_nullref(); - CAvlRef c = CAvlDeref(arg, o->root); - CAvlAssoc sum_offset = CAVL_PARAM_VALUE_ASSOC_ZERO; - - while (c.link != CAvl_nulllink()) { - CAvlAssoc left_sum = (CAvl_link(c)[0] != CAvl_nulllink() ? CAvl_assoc(CAvlDeref(arg, CAvl_link(c)[0])) : CAVL_PARAM_VALUE_ASSOC_ZERO); - CAvlAssoc c_prefixsum = CAVL_PARAM_FUN_ASSOC_OPER(arg, sum_offset, left_sum); - - if (sum_less(user, sum, c_prefixsum)) { - c = CAvlDeref(arg, CAvl_link(c)[0]); - } else { - result = c; - CAvlAssoc c_val = CAVL_PARAM_FUN_ASSOC_VALUE(arg, c); - sum_offset = CAVL_PARAM_FUN_ASSOC_OPER(arg, c_prefixsum, c_val); - c = CAvlDeref(arg, CAvl_link(c)[1]); - } - } - - return result; -} - -#endif - -#include "CAvl_footer.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash.h deleted file mode 100644 index 45fef7a3..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @file CHash.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_CHASH_H -#define BADVPN_CHASH_H - -#include - -#include -#include -#include - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_decl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_decl.h deleted file mode 100644 index d47702a1..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_decl.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - * @file CHash_decl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "CHash_header.h" - -typedef struct { - CHashLink *buckets; - size_t num_buckets; -} CHash; - -typedef struct { - CHashEntry *ptr; - CHashLink link; -} CHashRef; - -static CHashLink CHashNullLink (void); -static CHashRef CHashNullRef (void); -static int CHashIsNullLink (CHashLink link); -static int CHashIsNullRef (CHashRef ref); -static CHashRef CHashDerefMayNull (CHashArg arg, CHashLink link); -static CHashRef CHashDerefNonNull (CHashArg arg, CHashLink link); - -static int CHash_Init (CHash *o, size_t num_buckets); -static void CHash_Free (CHash *o); -static int CHash_Insert (CHash *o, CHashArg arg, CHashRef entry, CHashRef *out_existing); -static void CHash_InsertMulti (CHash *o, CHashArg arg, CHashRef entry); -static void CHash_Remove (CHash *o, CHashArg arg, CHashRef entry); -static CHashRef CHash_Lookup (const CHash *o, CHashArg arg, CHashKey key); -static CHashRef CHash_GetNextEqual (const CHash *o, CHashArg arg, CHashRef entry); -static int CHash_MultiplyBuckets (CHash *o, CHashArg arg, int exp); -static void CHash_Verify (const CHash *o, CHashArg arg); - -#include "CHash_footer.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_footer.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_footer.h deleted file mode 100644 index cb95dafd..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_footer.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @file CHash_footer.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// preprocessor inputs -#undef CHASH_PARAM_NAME -#undef CHASH_PARAM_ENTRY -#undef CHASH_PARAM_LINK -#undef CHASH_PARAM_KEY -#undef CHASH_PARAM_ARG -#undef CHASH_PARAM_NULL -#undef CHASH_PARAM_DEREF -#undef CHASH_PARAM_ENTRYHASH -#undef CHASH_PARAM_KEYHASH -#undef CHASH_PARAM_ENTRYHASH_IS_CHEAP -#undef CHASH_PARAM_COMPARE_ENTRIES -#undef CHASH_PARAM_COMPARE_KEY_ENTRY -#undef CHASH_PARAM_ENTRY_NEXT - -// types -#undef CHash -#undef CHashEntry -#undef CHashLink -#undef CHashRef -#undef CHashArg -#undef CHashKey - -// non-object public functions -#undef CHashNullLink -#undef CHashNullRef -#undef CHashIsNullLink -#undef CHashIsNullRef -#undef CHashDerefMayNull -#undef CHashDerefNonNull - -// public functions -#undef CHash_Init -#undef CHash_Free -#undef CHash_Insert -#undef CHash_InsertMulti -#undef CHash_Remove -#undef CHash_Lookup -#undef CHash_GetNextEqual -#undef CHash_MultiplyBuckets -#undef CHash_Verify - -// private things -#undef CHash_next -#undef CHash_assert_valid_entry diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_header.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_header.h deleted file mode 100644 index 27800aca..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_header.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file CHash_header.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Preprocessor inputs: -// CHASH_PARAM_NAME - name of this data structure -// CHASH_PARAM_ENTRY - type of entry -// CHASH_PARAM_LINK - type of entry link (usually a pointer or index to an array) -// CHASH_PARAM_KEY - type of key -// CHASH_PARAM_ARG - type of argument pass through to comparisons -// CHASH_PARAM_NULL - invalid link -// CHASH_PARAM_DEREF(arg, link) - dereference a non-null link -// CHASH_PARAM_ENTRYHASH(arg, entry) - hash function for entries; returns size_t -// CHASH_PARAM_KEYHASH(arg, key) - hash function for keys; returns size_t -// CHASH_PARAM_ENTRYHASH_IS_CHEAP - define to 1 if CHASH_PARAM_ENTRYHASH is cheap (e.g. hashes are precomputed) -// CHASH_PARAM_COMPARE_ENTRIES(arg, entry1, entry2) - compares two entries; returns 1 for equality, 0 otherwise -// CHASH_PARAM_COMPARE_KEY_ENTRY(arg, key1, entry2) - compares key and entry; returns 1 for equality, 0 otherwise -// CHASH_PARAM_ENTRY_NEXT - next member in entry - -#ifndef BADVPN_CHASH_H -#error CHash.h has not been included -#endif - -// types -#define CHash CHASH_PARAM_NAME -#define CHashEntry CHASH_PARAM_ENTRY -#define CHashLink CHASH_PARAM_LINK -#define CHashRef MERGE(CHash, Ref) -#define CHashArg CHASH_PARAM_ARG -#define CHashKey CHASH_PARAM_KEY - -// non-object public functions -#define CHashNullLink MERGE(CHash, NullLink) -#define CHashNullRef MERGE(CHash, NullRef) -#define CHashIsNullLink MERGE(CHash, IsNullLink) -#define CHashIsNullRef MERGE(CHash, IsNullRef) -#define CHashDerefMayNull MERGE(CHash, DerefMayNull) -#define CHashDerefNonNull MERGE(CHash, DerefNonNull) - -// public functions -#define CHash_Init MERGE(CHash, _Init) -#define CHash_Free MERGE(CHash, _Free) -#define CHash_Insert MERGE(CHash, _Insert) -#define CHash_InsertMulti MERGE(CHash, _InsertMulti) -#define CHash_Remove MERGE(CHash, _Remove) -#define CHash_Lookup MERGE(CHash, _Lookup) -#define CHash_GetNextEqual MERGE(CHash, _GetNextEqual) -#define CHash_MultiplyBuckets MERGE(CHash, _MultiplyBuckets) -#define CHash_Verify MERGE(CHash, _Verify) - -// private things -#define CHash_next(entry) ((entry).ptr->CHASH_PARAM_ENTRY_NEXT) -#define CHash_assert_valid_entry MERGE(CHash, _assert_valid_entry) diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_impl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_impl.h deleted file mode 100644 index 0bded845..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/CHash_impl.h +++ /dev/null @@ -1,312 +0,0 @@ -/** - * @file CHash_impl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "CHash_header.h" - -static void CHash_assert_valid_entry (CHashArg arg, CHashRef entry) -{ - ASSERT(entry.link != CHashNullLink()) - ASSERT(entry.ptr == CHASH_PARAM_DEREF(arg, entry.link)) -} - -static CHashLink CHashNullLink (void) -{ - return CHASH_PARAM_NULL; -} - -static CHashRef CHashNullRef (void) -{ - CHashRef entry = {NULL, CHashNullLink()}; - return entry; -} - -static int CHashIsNullLink (CHashLink link) -{ - return (link == CHashNullLink()); -} - -static int CHashIsNullRef (CHashRef ref) -{ - return CHashIsNullLink(ref.link); -} - -static CHashRef CHashDerefMayNull (CHashArg arg, CHashLink link) -{ - if (link == CHashNullLink()) { - return CHashNullRef(); - } - - CHashRef entry = {CHASH_PARAM_DEREF(arg, link), link}; - ASSERT(entry.ptr) - - return entry; -} - -static CHashRef CHashDerefNonNull (CHashArg arg, CHashLink link) -{ - ASSERT(link != CHashNullLink()) - - CHashRef entry = {CHASH_PARAM_DEREF(arg, link), link}; - ASSERT(entry.ptr) - - return entry; -} - -static int CHash_Init (CHash *o, size_t num_buckets) -{ - if (num_buckets == 0) { - num_buckets = 1; - } - - o->num_buckets = num_buckets; - - o->buckets = (CHashLink *)BAllocArray(o->num_buckets, sizeof(o->buckets[0])); - if (!o->buckets) { - return 0; - } - - for (size_t i = 0; i < o->num_buckets; i++) { - o->buckets[i] = CHashNullLink(); - } - - return 1; -} - -static void CHash_Free (CHash *o) -{ - BFree(o->buckets); -} - -static int CHash_Insert (CHash *o, CHashArg arg, CHashRef entry, CHashRef *out_existing) -{ - CHash_assert_valid_entry(arg, entry); - - size_t index = CHASH_PARAM_ENTRYHASH(arg, entry) % o->num_buckets; - - CHashLink link = o->buckets[index]; - while (link != CHashNullLink()) { - CHashRef cur = CHashDerefNonNull(arg, link); - if (CHASH_PARAM_COMPARE_ENTRIES(arg, cur, entry)) { - if (out_existing) { - *out_existing = cur; - } - return 0; - } - link = CHash_next(cur); - } - - CHash_next(entry) = o->buckets[index]; - o->buckets[index] = entry.link; - - return 1; -} - -static void CHash_InsertMulti (CHash *o, CHashArg arg, CHashRef entry) -{ - CHash_assert_valid_entry(arg, entry); - - size_t index = CHASH_PARAM_ENTRYHASH(arg, entry) % o->num_buckets; - - CHashRef prev = CHashNullRef(); - CHashLink link = o->buckets[index]; - while (link != CHashNullLink()) { - CHashRef cur = CHashDerefNonNull(arg, link); - if (CHASH_PARAM_COMPARE_ENTRIES(arg, cur, entry)) { - break; - } - prev = cur; - link = CHash_next(cur); - } - - if (link == CHashNullLink() || prev.link == CHashNullLink()) { - CHash_next(entry) = o->buckets[index]; - o->buckets[index] = entry.link; - } else { - CHash_next(entry) = link; - CHash_next(prev) = entry.link; - } -} - -static void CHash_Remove (CHash *o, CHashArg arg, CHashRef entry) -{ - CHash_assert_valid_entry(arg, entry); - - size_t index = CHASH_PARAM_ENTRYHASH(arg, entry) % o->num_buckets; - - CHashRef prev = CHashNullRef(); - CHashLink link = o->buckets[index]; - while (link != entry.link) { - CHashRef cur = CHashDerefNonNull(arg, link); - prev = cur; - link = CHash_next(cur); - ASSERT(link != CHashNullLink()) - } - - if (prev.link == CHashNullLink()) { - o->buckets[index] = CHash_next(entry); - } else { - CHash_next(prev) = CHash_next(entry); - } -} - -static CHashRef CHash_Lookup (const CHash *o, CHashArg arg, CHashKey key) -{ - size_t hash = CHASH_PARAM_KEYHASH(arg, key); - size_t index = hash % o->num_buckets; - - CHashLink link = o->buckets[index]; - while (link != CHashNullLink()) { - CHashRef cur = CHashDerefNonNull(arg, link); -#if CHASH_PARAM_ENTRYHASH_IS_CHEAP - if (CHASH_PARAM_ENTRYHASH(arg, cur) == hash && CHASH_PARAM_COMPARE_KEY_ENTRY(arg, key, cur)) { -#else - if (CHASH_PARAM_COMPARE_KEY_ENTRY(arg, key, cur)) { -#endif - return cur; - } - link = CHash_next(cur); - } - - return CHashNullRef(); -} - -static CHashRef CHash_GetNextEqual (const CHash *o, CHashArg arg, CHashRef entry) -{ - CHash_assert_valid_entry(arg, entry); - - CHashLink next = CHash_next(entry); - - if (next == CHashNullLink()) { - return CHashNullRef(); - } - - CHashRef next_ref = CHashDerefNonNull(arg, next); - if (!CHASH_PARAM_COMPARE_ENTRIES(arg, next_ref, entry)) { - return CHashNullRef(); - } - - return next_ref; -} - -static int CHash_MultiplyBuckets (CHash *o, CHashArg arg, int exp) -{ - ASSERT(exp > 0) - - size_t new_num_buckets = o->num_buckets; - while (exp-- > 0) { - if (new_num_buckets > SIZE_MAX / 2) { - return 0; - } - new_num_buckets *= 2; - } - - CHashLink *new_buckets = (CHashLink *)BReallocArray(o->buckets, new_num_buckets, sizeof(new_buckets[0])); - if (!new_buckets) { - return 0; - } - o->buckets = new_buckets; - - for (size_t i = o->num_buckets; i < new_num_buckets; i++) { - o->buckets[i] = CHashNullLink(); - } - - for (size_t i = 0; i < o->num_buckets; i++) { - CHashRef prev = CHashNullRef(); - CHashLink link = o->buckets[i]; - - while (link != CHashNullLink()) { - CHashRef cur = CHashDerefNonNull(arg, link); - link = CHash_next(cur); - - size_t new_index = CHASH_PARAM_ENTRYHASH(arg, cur) % new_num_buckets; - if (new_index == i) { - prev = cur; - continue; - } - - if (CHashIsNullRef(prev)) { - o->buckets[i] = CHash_next(cur); - } else { - CHash_next(prev) = CHash_next(cur); - } - - CHash_next(cur) = o->buckets[new_index]; - o->buckets[new_index] = cur.link; - } - } - - for (size_t i = o->num_buckets; i < new_num_buckets; i++) { - CHashLink new_bucket_link = CHashNullLink(); - - CHashLink link = o->buckets[i]; - while (link != CHashNullLink()) { - CHashRef cur = CHashDerefNonNull(arg, link); - link = CHash_next(cur); - - CHash_next(cur) = new_bucket_link; - new_bucket_link = cur.link; - } - - o->buckets[i] = new_bucket_link; - } - - o->num_buckets = new_num_buckets; - - return 1; -} - -static void CHash_Verify (const CHash *o, CHashArg arg) -{ - ASSERT_FORCE(o->num_buckets > 0) - ASSERT_FORCE(o->buckets) - - for (size_t i = 0; i < o->num_buckets; i++) { - CHashRef cur = CHashDerefMayNull(arg, o->buckets[i]); - CHashRef same_first = cur; - - while (!CHashIsNullRef(cur)) { - size_t index = CHASH_PARAM_ENTRYHASH(arg, cur) % o->num_buckets; - ASSERT_FORCE(index == i) - - if (!CHASH_PARAM_COMPARE_ENTRIES(arg, cur, same_first)) { - same_first = cur; - } - - CHashRef ccur = CHashDerefNonNull(arg, o->buckets[i]); - while (ccur.link != same_first.link) { - ASSERT_FORCE(!CHASH_PARAM_COMPARE_ENTRIES(arg, ccur, cur)) - ccur = CHashDerefMayNull(arg, CHash_next(ccur)); - } - - cur = CHashDerefMayNull(arg, CHash_next(cur)); - } - } -} - -#include "CHash_footer.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/ChunkBuffer2.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/ChunkBuffer2.h deleted file mode 100644 index 966fbef2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/ChunkBuffer2.h +++ /dev/null @@ -1,317 +0,0 @@ -/** - * @file ChunkBuffer2.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Circular packet buffer - */ - -#ifndef BADVPN_STRUCTURE_CHUNKBUFFER2_H -#define BADVPN_STRUCTURE_CHUNKBUFFER2_H - -#include -#include -#include - -#include "misc/balign.h" -#include "misc/debug.h" - -#ifndef NDEBUG -#define CHUNKBUFFER2_ASSERT_BUFFER(_buf) _ChunkBuffer2_assert_buffer(_buf); -#define CHUNKBUFFER2_ASSERT_IO(_buf) _ChunkBuffer2_assert_io(_buf); -#else -#define CHUNKBUFFER2_ASSERT_BUFFER(_buf) -#define CHUNKBUFFER2_ASSERT_IO(_buf) -#endif - -struct ChunkBuffer2_block { - int len; -}; - -typedef struct { - struct ChunkBuffer2_block *buffer; - int size; - int wrap; - int start; - int used; - int mtu; - uint8_t *input_dest; - int input_avail; - uint8_t *output_dest; - int output_avail; -} ChunkBuffer2; - -// calculates a buffer size needed to hold at least 'num' packets long at least 'chunk_len' -static int ChunkBuffer2_calc_blocks (int chunk_len, int num); - -// initialize -static void ChunkBuffer2_Init (ChunkBuffer2 *buf, struct ChunkBuffer2_block *buffer, int blocks, int mtu); - -// submit a packet written to the buffer -static void ChunkBuffer2_SubmitPacket (ChunkBuffer2 *buf, int len); - -// remove the first packet -static void ChunkBuffer2_ConsumePacket (ChunkBuffer2 *buf); - -static int _ChunkBuffer2_end (ChunkBuffer2 *buf) -{ - if (buf->used >= buf->wrap - buf->start) { - return (buf->used - (buf->wrap - buf->start)); - } else { - return (buf->start + buf->used); - } -} - -#ifndef NDEBUG - -static void _ChunkBuffer2_assert_buffer (ChunkBuffer2 *buf) -{ - ASSERT(buf->size > 0) - ASSERT(buf->wrap > 0) - ASSERT(buf->wrap <= buf->size) - ASSERT(buf->start >= 0) - ASSERT(buf->start < buf->wrap) - ASSERT(buf->used >= 0) - ASSERT(buf->used <= buf->wrap) - ASSERT(buf->wrap == buf->size || buf->used >= buf->wrap - buf->start) - ASSERT(buf->mtu >= 0) -} - -static void _ChunkBuffer2_assert_io (ChunkBuffer2 *buf) -{ - // check input - - int end = _ChunkBuffer2_end(buf); - - if (buf->size - end - 1 < buf->mtu) { - // it will never be possible to write a MTU long packet here - ASSERT(!buf->input_dest) - ASSERT(buf->input_avail == -1) - } else { - // calculate number of free blocks - int free; - if (buf->used >= buf->wrap - buf->start) { - free = buf->start - end; - } else { - free = buf->size - end; - } - - if (free > 0) { - // got space at least for a header. More space will become available as packets are - // read from the buffer, up to MTU. - ASSERT(buf->input_dest == (uint8_t *)&buf->buffer[end + 1]) - ASSERT(buf->input_avail == (free - 1) * sizeof(struct ChunkBuffer2_block)) - } else { - // no space - ASSERT(!buf->input_dest) - ASSERT(buf->input_avail == -1) - } - } - - // check output - - if (buf->used > 0) { - int datalen = buf->buffer[buf->start].len; - ASSERT(datalen >= 0) - int blocklen = bdivide_up(datalen, sizeof(struct ChunkBuffer2_block)); - ASSERT(blocklen <= buf->used - 1) - ASSERT(blocklen <= buf->wrap - buf->start - 1) - ASSERT(buf->output_dest == (uint8_t *)&buf->buffer[buf->start + 1]) - ASSERT(buf->output_avail == datalen) - } else { - ASSERT(!buf->output_dest) - ASSERT(buf->output_avail == -1) - } -} - -#endif - -static void _ChunkBuffer2_update_input (ChunkBuffer2 *buf) -{ - int end = _ChunkBuffer2_end(buf); - - if (buf->size - end - 1 < buf->mtu) { - // it will never be possible to write a MTU long packet here - buf->input_dest = NULL; - buf->input_avail = -1; - return; - } - - // calculate number of free blocks - int free; - if (buf->used >= buf->wrap - buf->start) { - free = buf->start - end; - } else { - free = buf->size - end; - } - - if (free > 0) { - // got space at least for a header. More space will become available as packets are - // read from the buffer, up to MTU. - buf->input_dest = (uint8_t *)&buf->buffer[end + 1]; - buf->input_avail = (free - 1) * sizeof(struct ChunkBuffer2_block); - } else { - // no space - buf->input_dest = NULL; - buf->input_avail = -1; - } -} - -static void _ChunkBuffer2_update_output (ChunkBuffer2 *buf) -{ - if (buf->used > 0) { - int datalen = buf->buffer[buf->start].len; - ASSERT(datalen >= 0) -#ifndef NDEBUG - int blocklen = bdivide_up(datalen, sizeof(struct ChunkBuffer2_block)); - ASSERT(blocklen <= buf->used - 1) - ASSERT(blocklen <= buf->wrap - buf->start - 1) -#endif - buf->output_dest = (uint8_t *)&buf->buffer[buf->start + 1]; - buf->output_avail = datalen; - } else { - buf->output_dest = NULL; - buf->output_avail = -1; - } -} - -int ChunkBuffer2_calc_blocks (int chunk_len, int num) -{ - int chunk_data_blocks = bdivide_up(chunk_len, sizeof(struct ChunkBuffer2_block)); - - if (chunk_data_blocks > INT_MAX - 1) { - return -1; - } - int chunk_blocks = 1 + chunk_data_blocks; - - if (num > INT_MAX - 1) { - return -1; - } - int num_chunks = num + 1; - - if (chunk_blocks > INT_MAX / num_chunks) { - return -1; - } - int blocks = chunk_blocks * num_chunks; - - return blocks; -} - -void ChunkBuffer2_Init (ChunkBuffer2 *buf, struct ChunkBuffer2_block *buffer, int blocks, int mtu) -{ - ASSERT(blocks > 0) - ASSERT(mtu >= 0) - - buf->buffer = buffer; - buf->size = blocks; - buf->wrap = blocks; - buf->start = 0; - buf->used = 0; - buf->mtu = bdivide_up(mtu, sizeof(struct ChunkBuffer2_block)); - - CHUNKBUFFER2_ASSERT_BUFFER(buf) - - _ChunkBuffer2_update_input(buf); - _ChunkBuffer2_update_output(buf); - - CHUNKBUFFER2_ASSERT_IO(buf) -} - -void ChunkBuffer2_SubmitPacket (ChunkBuffer2 *buf, int len) -{ - ASSERT(buf->input_dest) - ASSERT(len >= 0) - ASSERT(len <= buf->input_avail) - - CHUNKBUFFER2_ASSERT_BUFFER(buf) - CHUNKBUFFER2_ASSERT_IO(buf) - - int end = _ChunkBuffer2_end(buf); - int blocklen = bdivide_up(len, sizeof(struct ChunkBuffer2_block)); - - ASSERT(blocklen <= buf->size - end - 1) - ASSERT(buf->used < buf->wrap - buf->start || blocklen <= buf->start - end - 1) - - buf->buffer[end].len = len; - buf->used += 1 + blocklen; - - if (buf->used <= buf->wrap - buf->start && buf->mtu > buf->size - (end + 1 + blocklen) - 1) { - buf->wrap = end + 1 + blocklen; - } - - CHUNKBUFFER2_ASSERT_BUFFER(buf) - - // update input - _ChunkBuffer2_update_input(buf); - - // update output - if (buf->used == 1 + blocklen) { - _ChunkBuffer2_update_output(buf); - } - - CHUNKBUFFER2_ASSERT_IO(buf) -} - -void ChunkBuffer2_ConsumePacket (ChunkBuffer2 *buf) -{ - ASSERT(buf->output_dest) - - CHUNKBUFFER2_ASSERT_BUFFER(buf) - CHUNKBUFFER2_ASSERT_IO(buf) - - ASSERT(1 <= buf->wrap - buf->start) - ASSERT(1 <= buf->used) - - int blocklen = bdivide_up(buf->buffer[buf->start].len, sizeof(struct ChunkBuffer2_block)); - - ASSERT(blocklen <= buf->wrap - buf->start - 1) - ASSERT(blocklen <= buf->used - 1) - - int data_wrapped = (buf->used >= buf->wrap - buf->start); - - buf->start += 1 + blocklen; - buf->used -= 1 + blocklen; - if (buf->start == buf->wrap) { - buf->start = 0; - buf->wrap = buf->size; - } - - CHUNKBUFFER2_ASSERT_BUFFER(buf) - - // update input - if (data_wrapped) { - _ChunkBuffer2_update_input(buf); - } - - // update output - _ChunkBuffer2_update_output(buf); - - CHUNKBUFFER2_ASSERT_IO(buf) -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/IndexedList.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/IndexedList.h deleted file mode 100644 index ca611e9b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/IndexedList.h +++ /dev/null @@ -1,225 +0,0 @@ -/** - * @file IndexedList.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * A data structure similar to a list, but with efficient index-based access. - */ - -#ifndef BADVPN_INDEXEDLIST_H -#define BADVPN_INDEXEDLIST_H - -#include -#include - -#include -#include -#include - -typedef struct IndexedList_s IndexedList; -typedef struct IndexedListNode_s IndexedListNode; - -typedef IndexedListNode *IndexedList__tree_link; - -#include "IndexedList_tree.h" -#include - -struct IndexedList_s { - IndexedList__Tree tree; -}; - -struct IndexedListNode_s { - IndexedListNode *tree_child[2]; - IndexedListNode *tree_parent; - int8_t tree_balance; - uint64_t tree_count; -}; - -/** - * Initializes the indexed list. - * - * @param o uninitialized list object to initialize - */ -static void IndexedList_Init (IndexedList *o); - -/** - * Inserts a node into the indexed list. - * - * @param o indexed list to insert into - * @param node uninitialized node to insert - * @param index index to insert at (starting with zero). Any existing elements - * at or after this index will be shifted forward, i.e. their - * indices will be incremented by one. Must be <=count. - */ -static void IndexedList_InsertAt (IndexedList *o, IndexedListNode *node, uint64_t index); - -/** - * Removes a nove from the indexed list. - * - * @param o indexed list to remove from - * @param node node in the list to remove - */ -static void IndexedList_Remove (IndexedList *o, IndexedListNode *node); - -/** - * Returns the number of nodes in the indexed list. - * - * @param o indexed list - * @return number of nodes - */ -static uint64_t IndexedList_Count (IndexedList *o); - -/** - * Returns the index of a node in the indexed list. - * - * @param o indexed list - * @param node node in the list to get index of - * @return index of the node - */ -static uint64_t IndexedList_IndexOf (IndexedList *o, IndexedListNode *node); - -/** - * Returns the node at the specified index in the indexed list. - * - * @param o indexed list - * @param index index of the node to return. Must be < count. - * @return node at the specified index - */ -static IndexedListNode * IndexedList_GetAt (IndexedList *o, uint64_t index); - -/** - * Returns the first node, or NULL if the list is empty. - * - * @param o indexed list - * @return first node, or NULL - */ -static IndexedListNode * IndexedList_GetFirst (IndexedList *o); - -/** - * Returns the last node, or NULL if the list is empty. - * - * @param o indexed list - * @return last node, or NULL - */ -static IndexedListNode * IndexedList_GetLast (IndexedList *o); - -/** - * Returns the next node of a given node, or NULL this is the last node. - * - * @param o indexed list - * @param node existing node - * @return next node, or NULL - */ -static IndexedListNode * IndexedList_GetNext (IndexedList *o, IndexedListNode *node); - -/** - * Returns the previous node of a given node, or NULL this is the first node. - * - * @param o indexed list - * @param node existing node - * @return previous node, or NULL - */ -static IndexedListNode * IndexedList_GetPrev (IndexedList *o, IndexedListNode *node); - -#include "IndexedList_tree.h" -#include - -static IndexedListNode * IndexedList__deref (IndexedList__TreeRef ref) -{ - return ref.link; -} - -static void IndexedList_Init (IndexedList *o) -{ - IndexedList__Tree_Init(&o->tree); -} - -static void IndexedList_InsertAt (IndexedList *o, IndexedListNode *node, uint64_t index) -{ - ASSERT(index <= IndexedList__Tree_Count(&o->tree, 0)) - ASSERT(IndexedList__Tree_Count(&o->tree, 0) < UINT64_MAX - 1) - - uint64_t orig_count = IndexedList__Tree_Count(&o->tree, 0); - B_USE(orig_count) - - IndexedList__Tree_InsertAt(&o->tree, 0, IndexedList__TreeDeref(0, node), index); - - ASSERT(IndexedList__Tree_IndexOf(&o->tree, 0, IndexedList__TreeDeref(0, node)) == index) - ASSERT(IndexedList__Tree_Count(&o->tree, 0) == orig_count + 1) -} - -static void IndexedList_Remove (IndexedList *o, IndexedListNode *node) -{ - IndexedList__Tree_Remove(&o->tree, 0, IndexedList__TreeDeref(0, node)); -} - -static uint64_t IndexedList_Count (IndexedList *o) -{ - return IndexedList__Tree_Count(&o->tree, 0); -} - -static uint64_t IndexedList_IndexOf (IndexedList *o, IndexedListNode *node) -{ - return IndexedList__Tree_IndexOf(&o->tree, 0, IndexedList__TreeDeref(0, node)); -} - -static IndexedListNode * IndexedList_GetAt (IndexedList *o, uint64_t index) -{ - ASSERT(index < IndexedList__Tree_Count(&o->tree, 0)) - - IndexedList__TreeRef ref = IndexedList__Tree_GetAt(&o->tree, 0, index); - ASSERT(!IndexedList__TreeIsNullRef(ref)) - - return ref.ptr; -} - -static IndexedListNode * IndexedList_GetFirst (IndexedList *o) -{ - return IndexedList__deref(IndexedList__Tree_GetFirst(&o->tree, 0)); -} - -static IndexedListNode * IndexedList_GetLast (IndexedList *o) -{ - return IndexedList__deref(IndexedList__Tree_GetLast(&o->tree, 0)); -} - -static IndexedListNode * IndexedList_GetNext (IndexedList *o, IndexedListNode *node) -{ - ASSERT(node) - - return IndexedList__deref(IndexedList__Tree_GetNext(&o->tree, 0, IndexedList__TreeDeref(0, node))); -} - -static IndexedListNode * IndexedList_GetPrev (IndexedList *o, IndexedListNode *node) -{ - ASSERT(node) - - return IndexedList__deref(IndexedList__Tree_GetPrev(&o->tree, 0, IndexedList__TreeDeref(0, node))); -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/IndexedList_tree.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/IndexedList_tree.h deleted file mode 100644 index 130f00fd..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/IndexedList_tree.h +++ /dev/null @@ -1,15 +0,0 @@ -#define CAVL_PARAM_NAME IndexedList__Tree -#define CAVL_PARAM_FEATURE_COUNTS 1 -#define CAVL_PARAM_FEATURE_KEYS_ARE_INDICES 1 -#define CAVL_PARAM_FEATURE_NOKEYS 0 -#define CAVL_PARAM_TYPE_ENTRY IndexedListNode -#define CAVL_PARAM_TYPE_LINK IndexedList__tree_link -#define CAVL_PARAM_TYPE_ARG int -#define CAVL_PARAM_TYPE_COUNT uint64_t -#define CAVL_PARAM_VALUE_COUNT_MAX UINT64_MAX -#define CAVL_PARAM_VALUE_NULL ((IndexedList__tree_link)NULL) -#define CAVL_PARAM_FUN_DEREF(arg, link) (link) -#define CAVL_PARAM_MEMBER_CHILD tree_child -#define CAVL_PARAM_MEMBER_BALANCE tree_balance -#define CAVL_PARAM_MEMBER_PARENT tree_parent -#define CAVL_PARAM_MEMBER_COUNT tree_count diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/LinkedList0.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/LinkedList0.h deleted file mode 100644 index feef4d7b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/LinkedList0.h +++ /dev/null @@ -1,202 +0,0 @@ -/** - * @file LinkedList0.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Very simple doubly linked list, with only a 'first' pointer an no 'last' - * pointer. - */ - -#ifndef BADVPN_STRUCTURE_LINKEDLIST0_H -#define BADVPN_STRUCTURE_LINKEDLIST0_H - -#include - -#include - -/** - * Linked list node. - */ -typedef struct LinkedList0Node_t -{ - struct LinkedList0Node_t *p; - struct LinkedList0Node_t *n; -} LinkedList0Node; - -/** - * Simple doubly linked list. - */ -typedef struct -{ - LinkedList0Node *first; -} LinkedList0; - -/** - * Initializes the linked list. - * - * @param list list to initialize - */ -static void LinkedList0_Init (LinkedList0 *list); - -/** - * Determines if the list is empty. - * - * @param list the list - * @return 1 if empty, 0 if not - */ -static int LinkedList0_IsEmpty (LinkedList0 *list); - -/** - * Returns the first node of the list. - * - * @param list the list - * @return first node of the list, or NULL if the list is empty - */ -static LinkedList0Node * LinkedList0_GetFirst (LinkedList0 *list); - -/** - * Inserts a node to the beginning of the list. - * - * @param list the list - * @param node uninitialized node to insert - */ -static void LinkedList0_Prepend (LinkedList0 *list, LinkedList0Node *node); - -/** - * Inserts a node before a given node. - * - * @param list the list - * @param node uninitialized node to insert - * @param target node in the list to insert before - */ -static void LinkedList0_InsertBefore (LinkedList0 *list, LinkedList0Node *node, LinkedList0Node *target); - -/** - * Inserts a node after a given node. - * - * @param list the list - * @param node uninitialized node to insert - * @param target node in the list to insert after - */ -static void LinkedList0_InsertAfter (LinkedList0 *list, LinkedList0Node *node, LinkedList0Node *target); - -/** - * Removes a node from the list. - * - * @param list the list - * @param node node to remove - */ -static void LinkedList0_Remove (LinkedList0 *list, LinkedList0Node *node); - -/** - * Returns the next node of a given node. - * - * @param node reference node - * @return next node, or NULL if none - */ -static LinkedList0Node * LinkedList0Node_Next (LinkedList0Node *node); - -/** - * Returns the previous node of a given node. - * - * @param node reference node - * @return previous node, or NULL if none - */ -static LinkedList0Node * LinkedList0Node_Prev (LinkedList0Node *node); - -void LinkedList0_Init (LinkedList0 *list) -{ - list->first = NULL; -} - -int LinkedList0_IsEmpty (LinkedList0 *list) -{ - return (!list->first); -} - -LinkedList0Node * LinkedList0_GetFirst (LinkedList0 *list) -{ - return (list->first); -} - -void LinkedList0_Prepend (LinkedList0 *list, LinkedList0Node *node) -{ - node->p = NULL; - node->n = list->first; - if (list->first) { - list->first->p = node; - } - list->first = node; -} - -void LinkedList0_InsertBefore (LinkedList0 *list, LinkedList0Node *node, LinkedList0Node *target) -{ - node->p = target->p; - node->n = target; - if (target->p) { - target->p->n = node; - } else { - list->first = node; - } - target->p = node; -} - -void LinkedList0_InsertAfter (LinkedList0 *list, LinkedList0Node *node, LinkedList0Node *target) -{ - node->p = target; - node->n = target->n; - if (target->n) { - target->n->p = node; - } - target->n = node; -} - -void LinkedList0_Remove (LinkedList0 *list, LinkedList0Node *node) -{ - // remove from list - if (node->p) { - node->p->n = node->n; - } else { - list->first = node->n; - } - if (node->n) { - node->n->p = node->p; - } -} - -LinkedList0Node * LinkedList0Node_Next (LinkedList0Node *node) -{ - return node->n; -} - -LinkedList0Node * LinkedList0Node_Prev (LinkedList0Node *node) -{ - return node->p; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/LinkedList1.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/LinkedList1.h deleted file mode 100644 index 15ec2694..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/LinkedList1.h +++ /dev/null @@ -1,275 +0,0 @@ -/** - * @file LinkedList1.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Simple doubly linked list. - */ - -#ifndef BADVPN_STRUCTURE_LINKEDLIST1_H -#define BADVPN_STRUCTURE_LINKEDLIST1_H - -#include - -#include "misc/debug.h" - -/** - * Linked list node. - */ -typedef struct LinkedList1Node_t -{ - struct LinkedList1Node_t *p; - struct LinkedList1Node_t *n; -} LinkedList1Node; - -/** - * Simple doubly linked list. - */ -typedef struct -{ - LinkedList1Node *first; - LinkedList1Node *last; -} LinkedList1; - -/** - * Initializes the linked list. - * - * @param list list to initialize - */ -static void LinkedList1_Init (LinkedList1 *list); - -/** - * Determines if the list is empty. - * - * @param list the list - * @return 1 if empty, 0 if not - */ -static int LinkedList1_IsEmpty (LinkedList1 *list); - -/** - * Returns the first node of the list. - * - * @param list the list - * @return first node of the list, or NULL if the list is empty - */ -static LinkedList1Node * LinkedList1_GetFirst (LinkedList1 *list); - -/** - * Returns the last node of the list. - * - * @param list the list - * @return last node of the list, or NULL if the list is empty - */ -static LinkedList1Node * LinkedList1_GetLast (LinkedList1 *list); - -/** - * Inserts a node to the beginning of the list. - * - * @param list the list - * @param node uninitialized node to insert - */ -static void LinkedList1_Prepend (LinkedList1 *list, LinkedList1Node *node); - -/** - * Inserts a node to the end of the list. - * - * @param list the list - * @param node uninitialized node to insert - */ -static void LinkedList1_Append (LinkedList1 *list, LinkedList1Node *node); - -/** - * Inserts a node before a given node. - * - * @param list the list - * @param node uninitialized node to insert - * @param target node in the list to insert before - */ -static void LinkedList1_InsertBefore (LinkedList1 *list, LinkedList1Node *node, LinkedList1Node *target); - -/** - * Inserts a node after a given node. - * - * @param list the list - * @param node uninitialized node to insert - * @param target node in the list to insert after - */ -static void LinkedList1_InsertAfter (LinkedList1 *list, LinkedList1Node *node, LinkedList1Node *target); - -/** - * Removes a node from the list. - * - * @param list the list - * @param node node to remove - */ -static void LinkedList1_Remove (LinkedList1 *list, LinkedList1Node *node); - -/** - * Inserts the nodes in the list \a ins_list into this list, after the node \a target. - * If \a target is NULL, the nodes are inserted to the beginning. - * Note that because the first and last node in \a ins_list are modified - * (unless the list is empty), \a ins_list is invalidated and must no longer - * be used to access the inserted nodes. - */ -static void LinkedList1_InsertListAfter (LinkedList1 *list, LinkedList1 ins_list, LinkedList1Node *target); - -/** - * Returns the next node of a given node. - * - * @param node reference node - * @return next node, or NULL if none - */ -static LinkedList1Node * LinkedList1Node_Next (LinkedList1Node *node); - -/** - * Returns the previous node of a given node. - * - * @param node reference node - * @return previous node, or NULL if none - */ -static LinkedList1Node * LinkedList1Node_Prev (LinkedList1Node *node); - -void LinkedList1_Init (LinkedList1 *list) -{ - list->first = NULL; - list->last = NULL; -} - -int LinkedList1_IsEmpty (LinkedList1 *list) -{ - return (list->first) == NULL; -} - -LinkedList1Node * LinkedList1_GetFirst (LinkedList1 *list) -{ - return (list->first); -} - -LinkedList1Node * LinkedList1_GetLast (LinkedList1 *list) -{ - return (list->last); -} - -void LinkedList1_Prepend (LinkedList1 *list, LinkedList1Node *node) -{ - node->p = NULL; - node->n = list->first; - if (list->first) { - list->first->p = node; - } else { - list->last = node; - } - list->first = node; -} - -void LinkedList1_Append (LinkedList1 *list, LinkedList1Node *node) -{ - node->p = list->last; - node->n = NULL; - if (list->last) { - list->last->n = node; - } else { - list->first = node; - } - list->last = node; -} - -void LinkedList1_InsertBefore (LinkedList1 *list, LinkedList1Node *node, LinkedList1Node *target) -{ - node->p = target->p; - node->n = target; - if (target->p) { - target->p->n = node; - } else { - list->first = node; - } - target->p = node; -} - -void LinkedList1_InsertAfter (LinkedList1 *list, LinkedList1Node *node, LinkedList1Node *target) -{ - node->p = target; - node->n = target->n; - if (target->n) { - target->n->p = node; - } else { - list->last = node; - } - target->n = node; -} - -void LinkedList1_Remove (LinkedList1 *list, LinkedList1Node *node) -{ - // remove from list - if (node->p) { - node->p->n = node->n; - } else { - list->first = node->n; - } - if (node->n) { - node->n->p = node->p; - } else { - list->last = node->p; - } -} - -void LinkedList1_InsertListAfter (LinkedList1 *list, LinkedList1 ins_list, LinkedList1Node *target) -{ - if (!ins_list.first) { - return; - } - - LinkedList1Node *t_next = (target ? target->n : list->first); - - ins_list.first->p = target; - ins_list.last->n = t_next; - - if (target) { - target->n = ins_list.first; - } else { - list->first = ins_list.first; - } - - if (t_next) { - t_next->p = ins_list.last; - } else { - list->last = ins_list.last; - } -} - -LinkedList1Node * LinkedList1Node_Next (LinkedList1Node *node) -{ - return node->n; -} - -LinkedList1Node * LinkedList1Node_Prev (LinkedList1Node *node) -{ - return node->p; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/LinkedList3.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/LinkedList3.h deleted file mode 100644 index 8f54cdb5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/LinkedList3.h +++ /dev/null @@ -1,362 +0,0 @@ -/** - * @file LinkedList3.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Doubly linked list that support multiple iterations and removing - * aritrary elements during iteration, without a central object to - * represent the list. - */ - -#ifndef BADVPN_STRUCTURE_LINKEDLIST3_H -#define BADVPN_STRUCTURE_LINKEDLIST3_H - -#include -#include - -#include - -struct _LinkedList3Iterator; - -/** - * Linked list node. - */ -typedef struct _LinkedList3Node { - struct _LinkedList3Node *p; - struct _LinkedList3Node *n; - struct _LinkedList3Iterator *it; -} LinkedList3Node; - -/** - * Linked list iterator. - */ -typedef struct _LinkedList3Iterator { - int8_t dir; - struct _LinkedList3Node *e; - struct _LinkedList3Iterator *pi; - struct _LinkedList3Iterator *ni; -} LinkedList3Iterator; - -/** - * Initializes a list node to form a new list consisting of a - * single node. - * - * @param node list node structure to initialize. The node must remain - * available until it is freed with {@link LinkedList3Node_Free}, - * or the list is no longer required. - */ -static void LinkedList3Node_InitLonely (LinkedList3Node *node); - -/** - * Initializes a list node to go after an existing node. - * - * @param node list node structure to initialize. The node must remain - * available until it is freed with {@link LinkedList3Node_Free}, - * or the list is no longer required. - * @param ref existing list node - */ -static void LinkedList3Node_InitAfter (LinkedList3Node *node, LinkedList3Node *ref); - -/** - * Initializes a list node to go before an existing node. - * - * @param node list node structure to initialize. The node must remain - * available until it is freed with {@link LinkedList3Node_Free}, - * or the list is no longer required. - * @param ref existing list node - */ -static void LinkedList3Node_InitBefore (LinkedList3Node *node, LinkedList3Node *ref); - -/** - * Frees a list node, removing it a list (if there were other nodes - * in the list). - * - * @param node list node to free - */ -static void LinkedList3Node_Free (LinkedList3Node *node); - -/** - * Determines if a list node is a single node in a list. - * - * @param node list node - * @return 1 if the node ia a single node, 0 if not - */ -static int LinkedList3Node_IsLonely (LinkedList3Node *node); - -/** - * Returnes the node preceding this node (if there is one), - * the node following this node (if there is one), or NULL, - * respectively. - * - * @param node list node - * @return neighbour node or NULL if none - */ -static LinkedList3Node * LinkedList3Node_PrevOrNext (LinkedList3Node *node); - -/** - * Returnes the node following this node (if there is one), - * the node preceding this node (if there is one), or NULL, - * respectively. - * - * @param node list node - * @return neighbour node or NULL if none - */ -static LinkedList3Node * LinkedList3Node_NextOrPrev (LinkedList3Node *node); - -/** - * Returns the node preceding this node, or NULL if there is none. - * - * @param node list node - * @return left neighbour, or NULL if none - */ -static LinkedList3Node * LinkedList3Node_Prev (LinkedList3Node *node); - -/** - * Returns the node following this node, or NULL if there is none. - * - * @param node list node - * @return right neighbour, or NULL if none - */ -static LinkedList3Node * LinkedList3Node_Next (LinkedList3Node *node); - -/** - * Returns the first node in the list which this node is part of. - * It is found by iterating the list from this node to the beginning. - * - * @param node list node - * @return first node in the list - */ -static LinkedList3Node * LinkedList3Node_First (LinkedList3Node *node); - -/** - * Returns the last node in the list which this node is part of. - * It is found by iterating the list from this node to the end. - * - * @param node list node - * @return last node in the list - */ -static LinkedList3Node * LinkedList3Node_Last (LinkedList3Node *node); - -/** - * Initializes a linked list iterator. - * The iterator structure must remain available until either of these occurs: - * - the list is no longer needed, or - * - the iterator is freed with {@link LinkedList3Iterator_Free}, or - * - the iterator reaches the end of iteration. - * - * @param it uninitialized iterator to initialize - * @param e initial position of the iterator. NULL for end of iteration. - * @param dir direction of iteration. Must be 1 (forward) or -1 (backward). - */ -static void LinkedList3Iterator_Init (LinkedList3Iterator *it, LinkedList3Node *e, int dir); - -/** - * Frees a linked list iterator. - * - * @param it iterator to free - */ -static void LinkedList3Iterator_Free (LinkedList3Iterator *it); - -/** - * Moves the iterator one node forward or backward (depending on its direction), or, - * if it's at the last or first node (depending on the direction), it reaches - * the end of iteration, or, if it's at the end of iteration, it remains there. - * Returns the the previous position. - * - * @param it the iterator - * @return node on the position of iterator before it was (possibly) moved, or NULL - * if it was at the end of iteration - */ -static LinkedList3Node * LinkedList3Iterator_Next (LinkedList3Iterator *it); - -void LinkedList3Node_InitLonely (LinkedList3Node *node) -{ - node->p = NULL; - node->n = NULL; - node->it = NULL; -} - -void LinkedList3Node_InitAfter (LinkedList3Node *node, LinkedList3Node *ref) -{ - ASSERT(ref) - - node->p = ref; - node->n = ref->n; - ref->n = node; - if (node->n) { - node->n->p = node; - } - node->it = NULL; -} - -void LinkedList3Node_InitBefore (LinkedList3Node *node, LinkedList3Node *ref) -{ - ASSERT(ref) - - node->n = ref; - node->p = ref->p; - ref->p = node; - if (node->p) { - node->p->n = node; - } - node->it = NULL; -} - -void LinkedList3Node_Free (LinkedList3Node *node) -{ - // jump iterators - while (node->it) { - LinkedList3Iterator_Next(node->it); - } - - if (node->p) { - node->p->n = node->n; - } - if (node->n) { - node->n->p = node->p; - } -} - -int LinkedList3Node_IsLonely (LinkedList3Node *node) -{ - return (!node->p && !node->n); -} - -LinkedList3Node * LinkedList3Node_PrevOrNext (LinkedList3Node *node) -{ - if (node->p) { - return node->p; - } - if (node->n) { - return node->n; - } - return NULL; -} - -LinkedList3Node * LinkedList3Node_NextOrPrev (LinkedList3Node *node) -{ - if (node->n) { - return node->n; - } - if (node->p) { - return node->p; - } - return NULL; -} - -LinkedList3Node * LinkedList3Node_Prev (LinkedList3Node *node) -{ - return node->p; -} - -LinkedList3Node * LinkedList3Node_Next (LinkedList3Node *node) -{ - return node->n; -} - -LinkedList3Node * LinkedList3Node_First (LinkedList3Node *node) -{ - while (node->p) { - node = node->p; - } - - return node; -} - -LinkedList3Node * LinkedList3Node_Last (LinkedList3Node *node) -{ - while (node->n) { - node = node->n; - } - - return node; -} - -void LinkedList3Iterator_Init (LinkedList3Iterator *it, LinkedList3Node *e, int dir) -{ - ASSERT(dir == -1 || dir == 1) - - it->dir = dir; - it->e = e; - - if (e) { - // link into node's iterator list - it->pi = NULL; - it->ni = e->it; - if (e->it) { - e->it->pi = it; - } - e->it = it; - } -} - -void LinkedList3Iterator_Free (LinkedList3Iterator *it) -{ - if (it->e) { - // remove from node's iterator list - if (it->ni) { - it->ni->pi = it->pi; - } - if (it->pi) { - it->pi->ni = it->ni; - } else { - it->e->it = it->ni; - } - } -} - -LinkedList3Node * LinkedList3Iterator_Next (LinkedList3Iterator *it) -{ - // remember original entry - LinkedList3Node *orig = it->e; - - // jump to next entry - if (it->e) { - // get next entry - LinkedList3Node *next = NULL; // to remove warning - switch (it->dir) { - case 1: - next = it->e->n; - break; - case -1: - next = it->e->p; - break; - default: - ASSERT(0); - } - // destroy interator - LinkedList3Iterator_Free(it); - // re-initialize at next entry - LinkedList3Iterator_Init(it, next, it->dir); - } - - // return original entry - return orig; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl.h deleted file mode 100644 index 36aa10ef..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @file SAvl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_SAVL_H -#define BADVPN_SAVL_H - -#include -#include - -#include "structure/CAvl.h" -#include "misc/merge.h" -#include "misc/debug.h" - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_decl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_decl.h deleted file mode 100644 index c1d9244d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_decl.h +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @file SAvl_decl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SAvl_header.h" - -typedef SAvlEntry *SAvl__TreeLink; - -#include "SAvl_tree.h" -#include "structure/CAvl_decl.h" - -typedef struct { - SAvl__Tree tree; -} SAvl; - -typedef struct { - SAvlEntry *child[2]; - SAvlEntry *parent; - int8_t balance; -#if SAVL_PARAM_FEATURE_COUNTS - SAvlCount count; -#endif -} SAvlNode; - -static void SAvl_Init (SAvl *o); -static int SAvl_Insert (SAvl *o, SAvlArg arg, SAvlEntry *entry, SAvlEntry **out_existing); -static void SAvl_Remove (SAvl *o, SAvlArg arg, SAvlEntry *entry); -#if !SAVL_PARAM_FEATURE_NOKEYS -static SAvlEntry * SAvl_Lookup (const SAvl *o, SAvlArg arg, SAvlKey key); -static SAvlEntry * SAvl_LookupExact (const SAvl *o, SAvlArg arg, SAvlKey key); -static SAvlEntry * SAvl_GetFirstGreater (const SAvl *o, SAvlArg arg, SAvlKey key); -static SAvlEntry * SAvl_GetLastLesser (const SAvl *o, SAvlArg arg, SAvlKey key); -static SAvlEntry * SAvl_GetFirstGreaterEqual (const SAvl *o, SAvlArg arg, SAvlKey key); -static SAvlEntry * SAvl_GetLastLesserEqual (const SAvl *o, SAvlArg arg, SAvlKey key); -#endif -static SAvlEntry * SAvl_GetFirst (const SAvl *o, SAvlArg arg); -static SAvlEntry * SAvl_GetLast (const SAvl *o, SAvlArg arg); -static SAvlEntry * SAvl_GetNext (const SAvl *o, SAvlArg arg, SAvlEntry *entry); -static SAvlEntry * SAvl_GetPrev (const SAvl *o, SAvlArg arg, SAvlEntry *entry); -static int SAvl_IsEmpty (const SAvl *o); -static void SAvl_Verify (const SAvl *o, SAvlArg arg); -#if SAVL_PARAM_FEATURE_COUNTS -static SAvlCount SAvl_Count (const SAvl *o, SAvlArg arg); -static SAvlCount SAvl_IndexOf (const SAvl *o, SAvlArg arg, SAvlEntry *entry); -static SAvlEntry * SAvl_GetAt (const SAvl *o, SAvlArg arg, SAvlCount index); -#endif - -#include "SAvl_footer.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_footer.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_footer.h deleted file mode 100644 index ad90e404..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_footer.h +++ /dev/null @@ -1,89 +0,0 @@ -/** - * @file SAvl_footer.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#undef SAVL_PARAM_NAME -#undef SAVL_PARAM_FEATURE_COUNTS -#undef SAVL_PARAM_FEATURE_NOKEYS -#undef SAVL_PARAM_TYPE_ENTRY -#undef SAVL_PARAM_TYPE_KEY -#undef SAVL_PARAM_TYPE_ARG -#undef SAVL_PARAM_TYPE_COUNT -#undef SAVL_PARAM_VALUE_COUNT_MAX -#undef SAVL_PARAM_FUN_COMPARE_ENTRIES -#undef SAVL_PARAM_FUN_COMPARE_KEY_ENTRY -#undef SAVL_PARAM_MEMBER_NODE - -#undef SAvl -#undef SAvlEntry -#undef SAvlArg -#undef SAvlKey -#undef SAvlCount -#undef SAvlNode - -#undef SAvl_Init -#undef SAvl_Insert -#undef SAvl_Remove -#undef SAvl_Lookup -#undef SAvl_LookupExact -#undef SAvl_GetFirstGreater -#undef SAvl_GetLastLesser -#undef SAvl_GetFirstGreaterEqual -#undef SAvl_GetLastLesserEqual -#undef SAvl_GetFirst -#undef SAvl_GetLast -#undef SAvl_GetNext -#undef SAvl_GetPrev -#undef SAvl_IsEmpty -#undef SAvl_Verify -#undef SAvl_Count -#undef SAvl_IndexOf -#undef SAvl_GetAt - -#undef SAvl__Tree -#undef SAvl__TreeRef -#undef SAvl__TreeLink -#undef SAvl__TreeDeref -#undef SAvl__Tree_Init -#undef SAvl__Tree_Insert -#undef SAvl__Tree_Remove -#undef SAvl__Tree_Lookup -#undef SAvl__Tree_LookupExact -#undef SAvl__Tree_GetFirstGreater -#undef SAvl__Tree_GetLastLesser -#undef SAvl__Tree_GetFirstGreaterEqual -#undef SAvl__Tree_GetLastLesserEqual -#undef SAvl__Tree_GetFirst -#undef SAvl__Tree_GetLast -#undef SAvl__Tree_GetNext -#undef SAvl__Tree_GetPrev -#undef SAvl__Tree_IsEmpty -#undef SAvl__Tree_Verify -#undef SAvl__Tree_Count -#undef SAvl__Tree_IndexOf -#undef SAvl__Tree_GetAt diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_header.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_header.h deleted file mode 100644 index 5d7d9b15..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_header.h +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @file SAvl_header.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Preprocessor inputs. All types must be typedef names unless stated otherwise. -// SAVL_PARAM_NAME - name of this data structure -// SAVL_PARAM_FEATURE_COUNTS - whether to keep count information (0 or 1) -// SAVL_PARAM_FEATURE_NOKEYS - define to 1 if there is no need for a lookup operation -// SAVL_PARAM_TYPE_ENTRY - type of entry. This can also be a struct (e.g.: struct Foo). -// SAVL_PARAM_TYPE_KEY - type of key (ignored if SAVL_PARAM_FEATURE_NOKEYS) -// SAVL_PARAM_TYPE_ARG - type of argument pass through to callbacks -// SAVL_PARAM_TYPE_COUNT - type of count (only if SAVL_PARAM_FEATURE_COUNTS) -// SAVL_PARAM_VALUE_COUNT_MAX - maximum value of count (of type SAVL_PARAM_TYPE_COUNT) (only if SAVL_PARAM_FEATURE_COUNTS) -// SAVL_PARAM_FUN_COMPARE_ENTRIES(arg, entry1, entry2) - compare two entries; returns -1/0/1 -// SAVL_PARAM_FUN_COMPARE_KEY_ENTRY(arg, key1, entry2) - compare key and entry; returns -1/0/1 (ignored if SAVL_PARAM_FEATURE_NOKEYS) -// SAVL_PARAM_MEMBER_NODE - node member in entry - -// types -#define SAvl SAVL_PARAM_NAME -#define SAvlEntry SAVL_PARAM_TYPE_ENTRY -#define SAvlArg SAVL_PARAM_TYPE_ARG -#define SAvlKey SAVL_PARAM_TYPE_KEY -#define SAvlCount SAVL_PARAM_TYPE_COUNT -#define SAvlNode MERGE(SAvl, Node) - -// public functions -#define SAvl_Init MERGE(SAvl, _Init) -#define SAvl_Insert MERGE(SAvl, _Insert) -#define SAvl_Remove MERGE(SAvl, _Remove) -#define SAvl_Lookup MERGE(SAvl, _Lookup) -#define SAvl_LookupExact MERGE(SAvl, _LookupExact) -#define SAvl_GetFirstGreater MERGE(SAvl, _GetFirstGreater) -#define SAvl_GetLastLesser MERGE(SAvl, _GetLastLesser) -#define SAvl_GetFirstGreaterEqual MERGE(SAvl, _GetFirstGreaterEqual) -#define SAvl_GetLastLesserEqual MERGE(SAvl, _GetLastLesserEqual) -#define SAvl_GetFirst MERGE(SAvl, _GetFirst) -#define SAvl_GetLast MERGE(SAvl, _GetLast) -#define SAvl_GetNext MERGE(SAvl, _GetNext) -#define SAvl_GetPrev MERGE(SAvl, _GetPrev) -#define SAvl_IsEmpty MERGE(SAvl, _IsEmpty) -#define SAvl_Verify MERGE(SAvl, _Verify) -#define SAvl_Count MERGE(SAvl, _Count) -#define SAvl_IndexOf MERGE(SAvl, _IndexOf) -#define SAvl_GetAt MERGE(SAvl, _GetAt) - -// internal stuff -#define SAvl__Tree MERGE(SAvl, __Tree) -#define SAvl__TreeRef MERGE(SAvl, __TreeRef) -#define SAvl__TreeLink MERGE(SAvl, __TreeLink) -#define SAvl__TreeDeref MERGE(SAvl, __TreeDeref) -#define SAvl__Tree_Init MERGE(SAvl, __Tree_Init) -#define SAvl__Tree_Insert MERGE(SAvl, __Tree_Insert) -#define SAvl__Tree_Remove MERGE(SAvl, __Tree_Remove) -#define SAvl__Tree_Lookup MERGE(SAvl, __Tree_Lookup) -#define SAvl__Tree_LookupExact MERGE(SAvl, __Tree_LookupExact) -#define SAvl__Tree_GetFirstGreater MERGE(SAvl, __Tree_GetFirstGreater) -#define SAvl__Tree_GetLastLesser MERGE(SAvl, __Tree_GetLastLesser) -#define SAvl__Tree_GetFirstGreaterEqual MERGE(SAvl, __Tree_GetFirstGreaterEqual) -#define SAvl__Tree_GetLastLesserEqual MERGE(SAvl, __Tree_GetLastLesserEqual) -#define SAvl__Tree_GetFirst MERGE(SAvl, __Tree_GetFirst) -#define SAvl__Tree_GetLast MERGE(SAvl, __Tree_GetLast) -#define SAvl__Tree_GetNext MERGE(SAvl, __Tree_GetNext) -#define SAvl__Tree_GetPrev MERGE(SAvl, __Tree_GetPrev) -#define SAvl__Tree_IsEmpty MERGE(SAvl, __Tree_IsEmpty) -#define SAvl__Tree_Verify MERGE(SAvl, __Tree_Verify) -#define SAvl__Tree_Count MERGE(SAvl, __Tree_Count) -#define SAvl__Tree_IndexOf MERGE(SAvl, __Tree_IndexOf) -#define SAvl__Tree_GetAt MERGE(SAvl, __Tree_GetAt) diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_impl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_impl.h deleted file mode 100644 index 95fd65f2..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_impl.h +++ /dev/null @@ -1,164 +0,0 @@ -/** - * @file SAvl_impl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SAvl_header.h" - -#include "SAvl_tree.h" -#include "structure/CAvl_impl.h" - -static void SAvl_Init (SAvl *o) -{ - SAvl__Tree_Init(&o->tree); -} - -static int SAvl_Insert (SAvl *o, SAvlArg arg, SAvlEntry *entry, SAvlEntry **out_existing) -{ - ASSERT(entry) -#if SAVL_PARAM_FEATURE_COUNTS - ASSERT(SAvl_Count(o, arg) < SAVL_PARAM_VALUE_COUNT_MAX) -#endif - - SAvl__TreeRef out_ref; - int res = SAvl__Tree_Insert(&o->tree, arg, SAvl__TreeDeref(arg, entry), &out_ref); - - if (out_existing) { - *out_existing = out_ref.link; - } - - return res; -} - -static void SAvl_Remove (SAvl *o, SAvlArg arg, SAvlEntry *entry) -{ - ASSERT(entry) - - SAvl__Tree_Remove(&o->tree, arg, SAvl__TreeDeref(arg, entry)); -} - -#if !SAVL_PARAM_FEATURE_NOKEYS - -static SAvlEntry * SAvl_Lookup (const SAvl *o, SAvlArg arg, SAvlKey key) -{ - SAvl__TreeRef ref = SAvl__Tree_Lookup(&o->tree, arg, key); - return ref.link; -} - -static SAvlEntry * SAvl_LookupExact (const SAvl *o, SAvlArg arg, SAvlKey key) -{ - SAvl__TreeRef ref = SAvl__Tree_LookupExact(&o->tree, arg, key); - return ref.link; -} - -static SAvlEntry * SAvl_GetFirstGreater (const SAvl *o, SAvlArg arg, SAvlKey key) -{ - SAvl__TreeRef ref = SAvl__Tree_GetFirstGreater(&o->tree, arg, key); - return ref.link; -} - -static SAvlEntry * SAvl_GetLastLesser (const SAvl *o, SAvlArg arg, SAvlKey key) -{ - SAvl__TreeRef ref = SAvl__Tree_GetLastLesser(&o->tree, arg, key); - return ref.link; -} - -static SAvlEntry * SAvl_GetFirstGreaterEqual (const SAvl *o, SAvlArg arg, SAvlKey key) -{ - SAvl__TreeRef ref = SAvl__Tree_GetFirstGreaterEqual(&o->tree, arg, key); - return ref.link; -} - -static SAvlEntry * SAvl_GetLastLesserEqual (const SAvl *o, SAvlArg arg, SAvlKey key) -{ - SAvl__TreeRef ref = SAvl__Tree_GetLastLesserEqual(&o->tree, arg, key); - return ref.link; -} - -#endif - -static SAvlEntry * SAvl_GetFirst (const SAvl *o, SAvlArg arg) -{ - SAvl__TreeRef ref = SAvl__Tree_GetFirst(&o->tree, arg); - return ref.link; -} - -static SAvlEntry * SAvl_GetLast (const SAvl *o, SAvlArg arg) -{ - SAvl__TreeRef ref = SAvl__Tree_GetLast(&o->tree, arg); - return ref.link; -} - -static SAvlEntry * SAvl_GetNext (const SAvl *o, SAvlArg arg, SAvlEntry *entry) -{ - ASSERT(entry) - - SAvl__TreeRef ref = SAvl__Tree_GetNext(&o->tree, arg, SAvl__TreeDeref(arg, entry)); - return ref.link; -} - -static SAvlEntry * SAvl_GetPrev (const SAvl *o, SAvlArg arg, SAvlEntry *entry) -{ - ASSERT(entry) - - SAvl__TreeRef ref = SAvl__Tree_GetPrev(&o->tree, arg, SAvl__TreeDeref(arg, entry)); - return ref.link; -} - -static int SAvl_IsEmpty (const SAvl *o) -{ - return SAvl__Tree_IsEmpty(&o->tree); -} - -static void SAvl_Verify (const SAvl *o, SAvlArg arg) -{ - return SAvl__Tree_Verify(&o->tree, arg); -} - -#if SAVL_PARAM_FEATURE_COUNTS - -static SAvlCount SAvl_Count (const SAvl *o, SAvlArg arg) -{ - return SAvl__Tree_Count(&o->tree, arg); -} - -static SAvlCount SAvl_IndexOf (const SAvl *o, SAvlArg arg, SAvlEntry *entry) -{ - ASSERT(entry) - - return SAvl__Tree_IndexOf(&o->tree, arg, SAvl__TreeDeref(arg, entry)); -} - -static SAvlEntry * SAvl_GetAt (const SAvl *o, SAvlArg arg, SAvlCount index) -{ - SAvl__TreeRef ref = SAvl__Tree_GetAt(&o->tree, arg, index); - return ref.link; -} - -#endif - -#include "SAvl_footer.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_tree.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_tree.h deleted file mode 100644 index 5e5b18bb..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SAvl_tree.h +++ /dev/null @@ -1,18 +0,0 @@ -#define CAVL_PARAM_NAME SAvl__Tree -#define CAVL_PARAM_FEATURE_COUNTS SAVL_PARAM_FEATURE_COUNTS -#define CAVL_PARAM_FEATURE_KEYS_ARE_INDICES 0 -#define CAVL_PARAM_FEATURE_NOKEYS SAVL_PARAM_FEATURE_NOKEYS -#define CAVL_PARAM_TYPE_ENTRY SAvlEntry -#define CAVL_PARAM_TYPE_LINK SAvl__TreeLink -#define CAVL_PARAM_TYPE_KEY SAvlKey -#define CAVL_PARAM_TYPE_ARG SAvlArg -#define CAVL_PARAM_TYPE_COUNT SAvlCount -#define CAVL_PARAM_VALUE_COUNT_MAX SAVL_PARAM_VALUE_COUNT_MAX -#define CAVL_PARAM_VALUE_NULL ((SAvl__TreeLink)NULL) -#define CAVL_PARAM_FUN_DEREF(arg, link) (link) -#define CAVL_PARAM_FUN_COMPARE_ENTRIES(arg, entry1, entry2) SAVL_PARAM_FUN_COMPARE_ENTRIES((arg), (entry1).link, (entry2).link) -#define CAVL_PARAM_FUN_COMPARE_KEY_ENTRY(arg, key1, entry2) SAVL_PARAM_FUN_COMPARE_KEY_ENTRY((arg), (key1), (entry2).link) -#define CAVL_PARAM_MEMBER_CHILD SAVL_PARAM_MEMBER_NODE . child -#define CAVL_PARAM_MEMBER_BALANCE SAVL_PARAM_MEMBER_NODE . balance -#define CAVL_PARAM_MEMBER_PARENT SAVL_PARAM_MEMBER_NODE . parent -#define CAVL_PARAM_MEMBER_COUNT SAVL_PARAM_MEMBER_NODE . count diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList.h deleted file mode 100644 index 966a3de8..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file SLinkedList.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_SLINKEDLIST_H -#define BADVPN_SLINKEDLIST_H - -#include - -#include "misc/merge.h" -#include "misc/debug.h" - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_decl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_decl.h deleted file mode 100644 index 4a0ade48..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_decl.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * @file SLinkedList_decl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SLinkedList_header.h" - -typedef struct { - SLinkedListEntry *first; -#if SLINKEDLIST_PARAM_FEATURE_LAST - SLinkedListEntry *last; -#endif -} SLinkedList; - -typedef struct { - SLinkedListEntry *prev; - SLinkedListEntry *next; -} SLinkedListNode; - -static void SLinkedListMarkRemoved (SLinkedListEntry *entry); -static int SLinkedListIsRemoved (SLinkedListEntry *entry); - -static void SLinkedList_Init (SLinkedList *o); -static SLinkedListEntry * SLinkedList_Next (SLinkedList *o, SLinkedListEntry *entry); -static SLinkedListEntry * SLinkedList_Prev (SLinkedList *o, SLinkedListEntry *entry); -static void SLinkedList_Prepend (SLinkedList *o, SLinkedListEntry *entry); -#if SLINKEDLIST_PARAM_FEATURE_LAST -static void SLinkedList_Append (SLinkedList *o, SLinkedListEntry *entry); -#endif -static void SLinkedList_InsertBefore (SLinkedList *o, SLinkedListEntry *entry, SLinkedListEntry *before_entry); -static void SLinkedList_InsertAfter (SLinkedList *o, SLinkedListEntry *entry, SLinkedListEntry *after_entry); -static void SLinkedList_Remove (SLinkedList *o, SLinkedListEntry *entry); -static void SLinkedList_RemoveFirst (SLinkedList *o); -#if SLINKEDLIST_PARAM_FEATURE_LAST -static void SLinkedList_RemoveLast (SLinkedList *o); -#endif -static SLinkedListEntry * SLinkedList_First (const SLinkedList *o); -#if SLINKEDLIST_PARAM_FEATURE_LAST -static SLinkedListEntry * SLinkedList_Last (const SLinkedList *o); -#endif -static int SLinkedList_IsEmpty (const SLinkedList *o); - -#include "SLinkedList_footer.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_footer.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_footer.h deleted file mode 100644 index 10ab1e32..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_footer.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file SLinkedList_footer.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#undef SLINKEDLIST_PARAM_NAME -#undef SLINKEDLIST_PARAM_FEATURE_LAST -#undef SLINKEDLIST_PARAM_TYPE_ENTRY -#undef SLINKEDLIST_PARAM_MEMBER_NODE - -#undef SLinkedList -#undef SLinkedListEntry -#undef SLinkedListNode - -#undef SLinkedListMarkRemoved -#undef SLinkedListIsRemoved - -#undef SLinkedList_Init -#undef SLinkedList_Next -#undef SLinkedList_Prev -#undef SLinkedList_Prepend -#undef SLinkedList_Append -#undef SLinkedList_InsertBefore -#undef SLinkedList_InsertAfter -#undef SLinkedList_Remove -#undef SLinkedList_RemoveFirst -#undef SLinkedList_RemoveLast -#undef SLinkedList_First -#undef SLinkedList_Last -#undef SLinkedList_IsEmpty - -#undef SLinkedList_prev -#undef SLinkedList_next diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_header.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_header.h deleted file mode 100644 index 4a0fd54a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_header.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @file SLinkedList_header.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Preprocessor inputs: -// SLINKEDLIST_PARAM_NAME - name of this data structure -// SLINKEDLIST_PARAM_FEATURE_LAST - whether to keep track of the last entry in the list (0/1) -// SLINKEDLIST_PARAM_TYPE_ENTRY - type of entry -// SLINKEDLIST_PARAM_MEMBER_NODE - name of the node member in entry - -// types -#define SLinkedList SLINKEDLIST_PARAM_NAME -#define SLinkedListEntry SLINKEDLIST_PARAM_TYPE_ENTRY -#define SLinkedListNode MERGE(SLinkedList, Node) - -// non-object public functions -#define SLinkedListMarkRemoved MERGE(SLinkedList, MarkRemoved) -#define SLinkedListIsRemoved MERGE(SLinkedList, IsRemoved) - -// public functions -#define SLinkedList_Init MERGE(SLinkedList, _Init) -#define SLinkedList_Next MERGE(SLinkedList, _Next) -#define SLinkedList_Prev MERGE(SLinkedList, _Prev) -#define SLinkedList_Prepend MERGE(SLinkedList, _Prepend) -#define SLinkedList_Append MERGE(SLinkedList, _Append) -#define SLinkedList_InsertBefore MERGE(SLinkedList, _InsertBefore) -#define SLinkedList_InsertAfter MERGE(SLinkedList, _InsertAfter) -#define SLinkedList_Remove MERGE(SLinkedList, _Remove) -#define SLinkedList_RemoveFirst MERGE(SLinkedList, _RemoveFirst) -#define SLinkedList_RemoveLast MERGE(SLinkedList, _RemoveLast) -#define SLinkedList_First MERGE(SLinkedList, _First) -#define SLinkedList_Last MERGE(SLinkedList, _Last) -#define SLinkedList_IsEmpty MERGE(SLinkedList, _IsEmpty) - -// private things -#define SLinkedList_prev(entry) ((entry)->SLINKEDLIST_PARAM_MEMBER_NODE . prev) -#define SLinkedList_next(entry) ((entry)->SLINKEDLIST_PARAM_MEMBER_NODE . next) diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_impl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_impl.h deleted file mode 100644 index 1bbce9a5..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/SLinkedList_impl.h +++ /dev/null @@ -1,182 +0,0 @@ -/** - * @file SLinkedList_impl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SLinkedList_header.h" - -static void SLinkedListMarkRemoved (SLinkedListEntry *entry) -{ - ASSERT(entry) - - SLinkedList_next(entry) = entry; -} - -static int SLinkedListIsRemoved (SLinkedListEntry *entry) -{ - ASSERT(entry) - - return (entry == SLinkedList_next(entry)); -} - -static void SLinkedList_Init (SLinkedList *o) -{ - o->first = NULL; -} - -static SLinkedListEntry * SLinkedList_Next (SLinkedList *o, SLinkedListEntry *entry) -{ - ASSERT(entry) - - return SLinkedList_next(entry); -} - -static SLinkedListEntry * SLinkedList_Prev (SLinkedList *o, SLinkedListEntry *entry) -{ - ASSERT(entry) - - return (entry == o->first) ? NULL : SLinkedList_prev(entry); -} - -static void SLinkedList_Prepend (SLinkedList *o, SLinkedListEntry *entry) -{ - ASSERT(entry) - - SLinkedList_next(entry) = o->first; - if (o->first) { - SLinkedList_prev(o->first) = entry; - } else { -#if SLINKEDLIST_PARAM_FEATURE_LAST - o->last = entry; -#endif - } - o->first = entry; -} - -#if SLINKEDLIST_PARAM_FEATURE_LAST -static void SLinkedList_Append (SLinkedList *o, SLinkedListEntry *entry) -{ - ASSERT(entry) - - SLinkedList_next(entry) = NULL; - if (o->first) { - SLinkedList_prev(entry) = o->last; - SLinkedList_next(o->last) = entry; - } else { - o->first = entry; - } - o->last = entry; -} -#endif - -static void SLinkedList_InsertBefore (SLinkedList *o, SLinkedListEntry *entry, SLinkedListEntry *before_entry) -{ - ASSERT(entry) - ASSERT(before_entry) - - SLinkedList_next(entry) = before_entry; - if (before_entry != o->first) { - SLinkedList_prev(entry) = SLinkedList_prev(before_entry); - SLinkedList_next(SLinkedList_prev(before_entry)) = entry; - } else { - o->first = entry; - } - SLinkedList_prev(before_entry) = entry; -} - -static void SLinkedList_InsertAfter (SLinkedList *o, SLinkedListEntry *entry, SLinkedListEntry *after_entry) -{ - ASSERT(entry) - ASSERT(after_entry) - - SLinkedList_next(entry) = SLinkedList_next(after_entry); - SLinkedList_prev(entry) = after_entry; - if (SLinkedList_next(after_entry)) { - SLinkedList_prev(SLinkedList_next(after_entry)) = entry; - } else { -#if SLINKEDLIST_PARAM_FEATURE_LAST - o->last = entry; -#endif - } - SLinkedList_next(after_entry) = entry; -} - -static void SLinkedList_Remove (SLinkedList *o, SLinkedListEntry *entry) -{ - if (entry != o->first) { - SLinkedList_next(SLinkedList_prev(entry)) = SLinkedList_next(entry); - if (SLinkedList_next(entry)) { - SLinkedList_prev(SLinkedList_next(entry)) = SLinkedList_prev(entry); - } else { -#if SLINKEDLIST_PARAM_FEATURE_LAST - o->last = SLinkedList_prev(entry); -#endif - } - } else { - o->first = SLinkedList_next(entry); - } -} - -static void SLinkedList_RemoveFirst (SLinkedList *o) -{ - ASSERT(o->first) - - o->first = SLinkedList_next(o->first); -} - -#if SLINKEDLIST_PARAM_FEATURE_LAST -static void SLinkedList_RemoveLast (SLinkedList *o) -{ - ASSERT(o->first) - - if (o->last == o->first) { - o->first = NULL; - } else { - SLinkedList_next(SLinkedList_prev(o->last)) = NULL; - o->last = SLinkedList_prev(o->last); - } -} -#endif - -static SLinkedListEntry * SLinkedList_First (const SLinkedList *o) -{ - return o->first; -} - -#if SLINKEDLIST_PARAM_FEATURE_LAST -static SLinkedListEntry * SLinkedList_Last (const SLinkedList *o) -{ - return (!o->first ? NULL : o->last); -} -#endif - -static int SLinkedList_IsEmpty (const SLinkedList *o) -{ - return !o->first; -} - -#include "SLinkedList_footer.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector.h deleted file mode 100644 index f173c28c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file Vector.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -#include -#include -#include diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_decl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_decl.h deleted file mode 100644 index 8e36c9dd..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_decl.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file Vector_decl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "Vector_header.h" - -typedef struct { - VectorElem *elems; - size_t capacity; - size_t count; -} Vector; - -static int Vector_Init (Vector *o, size_t capacity) WARN_UNUSED; -static void Vector_Free (Vector *o); -static size_t Vector_Count (Vector *o); -static VectorElem * Vector_Get (Vector *o, size_t index); -static int Vector_Reserve (Vector *o, size_t capacity) WARN_UNUSED; -static VectorElem * Vector_Push (Vector *o, size_t *out_index) WARN_UNUSED; -static VectorElem * Vector_Pop (Vector *o, size_t *out_index); - -#include "Vector_footer.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_footer.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_footer.h deleted file mode 100644 index 3e561d9a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_footer.h +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @file Vector_footer.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#undef VECTOR_NAME -#undef VECTOR_ELEM_TYPE - -#undef Vector -#undef VectorElem -#undef Vector_Init -#undef Vector_Free -#undef Vector_Count -#undef Vector_Get -#undef Vector_Reserve -#undef Vector_Push -#undef Vector_Pop diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_header.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_header.h deleted file mode 100644 index 61be2294..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_header.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file Vector_header.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// Preprocessor inputs: -// VECTOR_NAME - prefix of functions and types to be defined -// VECTOR_ELEM_TYPE - type of vector elements - -#define Vector VECTOR_NAME -#define VectorElem VECTOR_ELEM_TYPE -#define Vector_Init MERGE(VECTOR_NAME, _Init) -#define Vector_Free MERGE(VECTOR_NAME, _Free) -#define Vector_Count MERGE(VECTOR_NAME, _Count) -#define Vector_Get MERGE(VECTOR_NAME, _Get) -#define Vector_Reserve MERGE(VECTOR_NAME, _Reserve) -#define Vector_Push MERGE(VECTOR_NAME, _Push) -#define Vector_Pop MERGE(VECTOR_NAME, _Pop) diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_impl.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_impl.h deleted file mode 100644 index b71d515b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/structure/Vector_impl.h +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @file Vector_impl.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "Vector_header.h" - -static int Vector_Init (Vector *o, size_t capacity) -{ - if (capacity == 0) { - o->elems = NULL; - } else { - o->elems = BAllocArray(capacity, sizeof(VectorElem)); - if (!o->elems) { - return 0; - } - } - o->capacity = capacity; - o->count = 0; - return 1; -} - -static void Vector_Free (Vector *o) -{ - BFree(o->elems); -} - -static size_t Vector_Count (Vector *o) -{ - return o->count; -} - -static VectorElem * Vector_Get (Vector *o, size_t index) -{ - ASSERT(index < o->capacity) - - return &o->elems[index]; -} - -static int Vector_Reserve (Vector *o, size_t capacity) -{ - if (capacity > o->capacity) { - size_t new_capacity = o->capacity; - do { - if (new_capacity > SIZE_MAX / 2) { - return 0; - } - new_capacity = (new_capacity == 0) ? 1 : (2 * new_capacity); - } while (capacity > new_capacity); - - VectorElem *new_elems = BAllocArray(new_capacity, sizeof(VectorElem)); - if (!new_elems) { - return 0; - } - - if (o->count > 0) { - memcpy(new_elems, o->elems, o->count * sizeof(VectorElem)); - } - - BFree(o->elems); - - o->elems = new_elems; - o->capacity = new_capacity; - } - - return 1; -} - -static VectorElem * Vector_Push (Vector *o, size_t *out_index) -{ - if (o->count == SIZE_MAX || !Vector_Reserve(o, o->count + 1)) { - return NULL; - } - if (out_index) { - *out_index = o->count; - } - VectorElem *ptr = &o->elems[o->count]; - o->count++; - return ptr; -} - -static VectorElem * Vector_Pop (Vector *o, size_t *out_index) -{ - ASSERT(o->count > 0) - - o->count--; - if (out_index) { - *out_index = o->count; - } - return &o->elems[o->count]; -} - -#include "Vector_footer.h" diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BAddr.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BAddr.h deleted file mode 100644 index c43ec3b4..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BAddr.h +++ /dev/null @@ -1,808 +0,0 @@ -/** - * @file BAddr.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Network address abstractions. - */ - -#ifndef BADVPN_SYSTEM_BADDR_H -#define BADVPN_SYSTEM_BADDR_H - -#include -#include -#include -#include -#include - -#ifdef BADVPN_USE_WINAPI -#include -#else -#include -#include -#include -#include -#endif - -#include "misc/byteorder.h" -#include "misc/debug.h" -#include "misc/print_macros.h" -#include "misc/read_write_int.h" -#include "misc/compare.h" - -#define BADDR_TYPE_NONE 0 -#define BADDR_TYPE_IPV4 1 -#define BADDR_TYPE_IPV6 2 -#ifdef BADVPN_LINUX - #define BADDR_TYPE_PACKET 5 -#endif - -#define BADDR_MAX_ADDR_LEN 128 - -#define BIPADDR_MAX_PRINT_LEN 40 -#define BADDR_MAX_PRINT_LEN 120 - -#define BADDR_PACKET_HEADER_TYPE_ETHERNET 1 - -#define BADDR_PACKET_PACKET_TYPE_HOST 1 -#define BADDR_PACKET_PACKET_TYPE_BROADCAST 2 -#define BADDR_PACKET_PACKET_TYPE_MULTICAST 3 -#define BADDR_PACKET_PACKET_TYPE_OTHERHOST 4 -#define BADDR_PACKET_PACKET_TYPE_OUTGOING 5 - -typedef struct { - int type; - union { - uint32_t ipv4; - uint8_t ipv6[16]; - }; -} BIPAddr; - -static void BIPAddr_InitInvalid (BIPAddr *addr); - -static void BIPAddr_InitIPv4 (BIPAddr *addr, uint32_t ip); - -static void BIPAddr_InitIPv6 (BIPAddr *addr, uint8_t *ip); - -static void BIPAddr_Assert (BIPAddr *addr); - -static int BIPAddr_IsInvalid (BIPAddr *addr); - -static int BIPAddr_Resolve (BIPAddr *addr, char *str, int noresolve) WARN_UNUSED; - -static int BIPAddr_Compare (BIPAddr *addr1, BIPAddr *addr2); - -/** - * Converts an IP address to human readable form. - * - * @param addr IP address to convert - * @param out destination buffer. Must be at least BIPADDR_MAX_PRINT_LEN characters long. - */ -static void BIPAddr_Print (BIPAddr *addr, char *out); - -/** - * Socket address - IP address and transport protocol port number - */ -typedef struct { - int type; - union { - struct { - uint32_t ip; - uint16_t port; - } ipv4; - struct { - uint8_t ip[16]; - uint16_t port; - } ipv6; - struct { - uint16_t phys_proto; - int interface_index; - int header_type; - int packet_type; - uint8_t phys_addr[8]; - } packet; - }; -} BAddr; - -/** - * Makes an invalid address. - */ -static BAddr BAddr_MakeNone (void); - -/** - * Makes an IPv4 address. - * - * @param ip IP address in network byte order - * @param port port number in network byte order - */ -static BAddr BAddr_MakeIPv4 (uint32_t ip, uint16_t port); - -/** - * Makes an IPv6 address. - * - * @param ip IP address (16 bytes) - * @param port port number in network byte order - */ -static BAddr BAddr_MakeIPv6 (const uint8_t *ip, uint16_t port); - -/** - * Makes an address from a BIPAddr and port number. - * - * @param ipaddr the BIPAddr - * @param port port number in network byte order - */ -static BAddr BAddr_MakeFromIpaddrAndPort (BIPAddr ipaddr, uint16_t port); - -/** - * Deprecated, use BAddr_MakeNone. - */ -static void BAddr_InitNone (BAddr *addr); - -/** - * Deprecated, use BAddr_MakeIPv4. - */ -static void BAddr_InitIPv4 (BAddr *addr, uint32_t ip, uint16_t port); - -/** - * Deprecated, use BAddr_MakeIPv6. - */ -static void BAddr_InitIPv6 (BAddr *addr, uint8_t *ip, uint16_t port); - -/** - * Deprecated, use BAddr_MakeFromIpaddrAndPort. - */ -static void BAddr_InitFromIpaddrAndPort (BAddr *addr, BIPAddr ipaddr, uint16_t port); - -/** - * Initializes a packet socket (data link layer) address. - * Only Ethernet addresses are supported. - * - * @param addr the object - * @param phys_proto identifier for the upper protocol, network byte order (EtherType) - * @param interface_index network interface index - * @param header_type data link layer header type. Must be BADDR_PACKET_HEADER_TYPE_ETHERNET. - * @param packet_type the manner in which packets are sent/received. Must be one of - * BADDR_PACKET_PACKET_TYPE_HOST, BADDR_PACKET_PACKET_TYPE_BROADCAST, - * BADDR_PACKET_PACKET_TYPE_MULTICAST, BADDR_PACKET_PACKET_TYPE_OTHERHOST, - * BADDR_PACKET_PACKET_TYPE_OUTGOING. - * @param phys_addr data link layer address (MAC address) - */ -static void BAddr_InitPacket (BAddr *addr, uint16_t phys_proto, int interface_index, int header_type, int packet_type, uint8_t *phys_addr); - -/** - * Does nothing. - * - * @param addr the object - */ -static void BAddr_Assert (BAddr *addr); - -/** - * Determines whether the address is an invalid address. - * - * @param addr the object - * @return 1 if invalid, 0 if invalid - **/ -static int BAddr_IsInvalid (BAddr *addr); - -/** - * Returns the port number in the address. - * - * @param addr the object - * Must be an IPv4 or IPv6 address. - * @return port number, in network byte order - */ -static uint16_t BAddr_GetPort (BAddr *addr); - -/** - * Returns the IP address in the address. - * - * @param addr the object - * @param ipaddr IP address will be returned here. If \a addr is not - * an IPv4 or IPv6 address, an invalid address will be - * returned. - */ -static void BAddr_GetIPAddr (BAddr *addr, BIPAddr *ipaddr); - -/** - * Sets the port number in the address. - * - * @param addr the object - * Must be an IPv4 or IPv6 address. - * @param port port number, in network byte order - */ -static void BAddr_SetPort (BAddr *addr, uint16_t port); - -/** - * Converts an IP address to human readable form. - * - * @param addr address to convert - * @param out destination buffer. Must be at least BADDR_MAX_PRINT_LEN characters long. - */ -static void BAddr_Print (BAddr *addr, char *out); - -/** - * Resolves an address string. - * Format is "addr:port" for IPv4, "[addr]:port" for IPv6. - * addr is be a numeric address or a name. - * port is a numeric port number. - * - * @param addr output address - * @param name if not NULL, the name portion of the address will be - * stored here - * @param name_len if name is not NULL, the size of the name buffer - * @param noresolve only accept numeric addresses. Avoids blocking the caller. - * @return 1 on success, 0 on parse error - */ -static int BAddr_Parse2 (BAddr *addr, char *str, char *name, int name_len, int noresolve) WARN_UNUSED; - -/** - * Resolves an address string. - * IPv4 input format is "a.b.c.d:p", where a.b.c.d is the IP address - * and d is the port number. - * IPv6 input format is "[addr]:p", where addr is an IPv6 addres in - * standard notation and p is the port number. - * - * @param addr output address - * @param name if not NULL, the name portion of the address will be - * stored here - * @param name_len if name is not NULL, the size of the name buffer - * @return 1 on success, 0 on parse error - */ -static int BAddr_Parse (BAddr *addr, char *str, char *name, int name_len) WARN_UNUSED; - -static int BAddr_Compare (BAddr *addr1, BAddr *addr2); - -static int BAddr_CompareOrder (BAddr *addr1, BAddr *addr2); - -void BIPAddr_InitInvalid (BIPAddr *addr) -{ - addr->type = BADDR_TYPE_NONE; -} - -void BIPAddr_InitIPv4 (BIPAddr *addr, uint32_t ip) -{ - addr->type = BADDR_TYPE_IPV4; - addr->ipv4 = ip; -} - -void BIPAddr_InitIPv6 (BIPAddr *addr, uint8_t *ip) -{ - addr->type = BADDR_TYPE_IPV6; - memcpy(addr->ipv6, ip, 16); -} - -void BIPAddr_Assert (BIPAddr *addr) -{ - switch (addr->type) { - case BADDR_TYPE_NONE: - case BADDR_TYPE_IPV4: - case BADDR_TYPE_IPV6: - return; - default: - ASSERT(0); - } -} - -int BIPAddr_IsInvalid (BIPAddr *addr) -{ - BIPAddr_Assert(addr); - - return (addr->type == BADDR_TYPE_NONE); -} - -int BIPAddr_Resolve (BIPAddr *addr, char *str, int noresolve) -{ - int len = strlen(str); - - char *addr_start; - int addr_len; - - // determine address type - if (len >= 1 && str[0] == '[' && str[len - 1] == ']') { - addr->type = BADDR_TYPE_IPV6; - addr_start = str + 1; - addr_len = len - 2; - } else { - addr->type = BADDR_TYPE_IPV4; - addr_start = str; - addr_len = len; - } - - // copy - char addr_str[BADDR_MAX_ADDR_LEN + 1]; - if (addr_len > BADDR_MAX_ADDR_LEN) { - return 0; - } - memcpy(addr_str, addr_start, addr_len); - addr_str[addr_len] = '\0'; - - // initialize hints - struct addrinfo hints; - memset(&hints, 0, sizeof(hints)); - switch (addr->type) { - case BADDR_TYPE_IPV6: - hints.ai_family = AF_INET6; - break; - case BADDR_TYPE_IPV4: - hints.ai_family = AF_INET; - break; - } - if (noresolve) { - hints.ai_flags |= AI_NUMERICHOST; - } - - // call getaddrinfo - struct addrinfo *addrs; - int res; - if ((res = getaddrinfo(addr_str, NULL, &hints, &addrs)) != 0) { - return 0; - } - - // set address - switch (addr->type) { - case BADDR_TYPE_IPV6: - memcpy(addr->ipv6, ((struct sockaddr_in6 *)addrs->ai_addr)->sin6_addr.s6_addr, sizeof(addr->ipv6)); - break; - case BADDR_TYPE_IPV4: - addr->ipv4 = ((struct sockaddr_in *)addrs->ai_addr)->sin_addr.s_addr; - break; - } - - freeaddrinfo(addrs); - - return 1; -} - -int BIPAddr_Compare (BIPAddr *addr1, BIPAddr *addr2) -{ - BIPAddr_Assert(addr1); - BIPAddr_Assert(addr2); - - if (addr1->type != addr2->type) { - return 0; - } - - switch (addr1->type) { - case BADDR_TYPE_NONE: - return 0; - case BADDR_TYPE_IPV4: - return (addr1->ipv4 == addr2->ipv4); - case BADDR_TYPE_IPV6: - return (!memcmp(addr1->ipv6, addr2->ipv6, sizeof(addr1->ipv6))); - default: - ASSERT(0) - return 0; - } -} - -uint16_t BAddr_GetPort (BAddr *addr) -{ - BAddr_Assert(addr); - ASSERT(addr->type == BADDR_TYPE_IPV4 || addr->type == BADDR_TYPE_IPV6) - - switch (addr->type) { - case BADDR_TYPE_IPV4: - return addr->ipv4.port; - case BADDR_TYPE_IPV6: - return addr->ipv6.port; - default: - ASSERT(0) - return 0; - } -} - -void BAddr_GetIPAddr (BAddr *addr, BIPAddr *ipaddr) -{ - BAddr_Assert(addr); - - switch (addr->type) { - case BADDR_TYPE_IPV4: - BIPAddr_InitIPv4(ipaddr, addr->ipv4.ip); - return; - case BADDR_TYPE_IPV6: - BIPAddr_InitIPv6(ipaddr, addr->ipv6.ip); - return; - default: - BIPAddr_InitInvalid(ipaddr); - } -} - -void BAddr_SetPort (BAddr *addr, uint16_t port) -{ - BAddr_Assert(addr); - ASSERT(addr->type == BADDR_TYPE_IPV4 || addr->type == BADDR_TYPE_IPV6) - - switch (addr->type) { - case BADDR_TYPE_IPV4: - addr->ipv4.port = port; - break; - case BADDR_TYPE_IPV6: - addr->ipv6.port = port; - break; - default: - ASSERT(0); - } -} - -void BIPAddr_Print (BIPAddr *addr, char *out) -{ - switch (addr->type) { - case BADDR_TYPE_NONE: - sprintf(out, "(none)"); - break; - case BADDR_TYPE_IPV4: - sprintf(out, "%"PRIu8".%"PRIu8".%"PRIu8".%"PRIu8, - *((uint8_t *)&addr->ipv4 + 0), - *((uint8_t *)&addr->ipv4 + 1), - *((uint8_t *)&addr->ipv4 + 2), - *((uint8_t *)&addr->ipv4 + 3) - ); - break; - case BADDR_TYPE_IPV6: { - const char *ptr = (const char *)addr->ipv6; - sprintf(out, - "%"PRIx16":%"PRIx16":%"PRIx16":%"PRIx16":" - "%"PRIx16":%"PRIx16":%"PRIx16":%"PRIx16, - badvpn_read_be16(ptr + 0), - badvpn_read_be16(ptr + 2), - badvpn_read_be16(ptr + 4), - badvpn_read_be16(ptr + 6), - badvpn_read_be16(ptr + 8), - badvpn_read_be16(ptr + 10), - badvpn_read_be16(ptr + 12), - badvpn_read_be16(ptr + 14) - ); - } break; - default: - ASSERT(0); - } -} - -BAddr BAddr_MakeNone (void) -{ - BAddr addr; - addr.type = BADDR_TYPE_NONE; - return addr; -} - -BAddr BAddr_MakeIPv4 (uint32_t ip, uint16_t port) -{ - BAddr addr; - addr.type = BADDR_TYPE_IPV4; - addr.ipv4.ip = ip; - addr.ipv4.port = port; - return addr; -} - -BAddr BAddr_MakeIPv6 (const uint8_t *ip, uint16_t port) -{ - BAddr addr; - addr.type = BADDR_TYPE_IPV6; - memcpy(addr.ipv6.ip, ip, 16); - addr.ipv6.port = port; - return addr; -} - -BAddr BAddr_MakeFromIpaddrAndPort (BIPAddr ipaddr, uint16_t port) -{ - BIPAddr_Assert(&ipaddr); - - switch (ipaddr.type) { - case BADDR_TYPE_NONE: - return BAddr_MakeNone(); - case BADDR_TYPE_IPV4: - return BAddr_MakeIPv4(ipaddr.ipv4, port); - case BADDR_TYPE_IPV6: - return BAddr_MakeIPv6(ipaddr.ipv6, port); - default: - ASSERT(0); - return BAddr_MakeNone(); - } -} - -void BAddr_InitNone (BAddr *addr) -{ - *addr = BAddr_MakeNone(); -} - -void BAddr_InitIPv4 (BAddr *addr, uint32_t ip, uint16_t port) -{ - *addr = BAddr_MakeIPv4(ip, port); -} - -void BAddr_InitIPv6 (BAddr *addr, uint8_t *ip, uint16_t port) -{ - *addr = BAddr_MakeIPv6(ip, port); -} - -void BAddr_InitFromIpaddrAndPort (BAddr *addr, BIPAddr ipaddr, uint16_t port) -{ - BIPAddr_Assert(&ipaddr); - - *addr = BAddr_MakeFromIpaddrAndPort(ipaddr, port); -} - -#ifdef BADVPN_LINUX - -void BAddr_InitPacket (BAddr *addr, uint16_t phys_proto, int interface_index, int header_type, int packet_type, uint8_t *phys_addr) -{ - ASSERT(header_type == BADDR_PACKET_HEADER_TYPE_ETHERNET) - ASSERT(packet_type == BADDR_PACKET_PACKET_TYPE_HOST || packet_type == BADDR_PACKET_PACKET_TYPE_BROADCAST || - packet_type == BADDR_PACKET_PACKET_TYPE_MULTICAST || packet_type == BADDR_PACKET_PACKET_TYPE_OTHERHOST || - packet_type == BADDR_PACKET_PACKET_TYPE_OUTGOING) - - addr->type = BADDR_TYPE_PACKET; - addr->packet.phys_proto = phys_proto; - addr->packet.interface_index = interface_index; - addr->packet.header_type = header_type; - addr->packet.packet_type = packet_type; - memcpy(addr->packet.phys_addr, phys_addr, 6); -} - -#endif - -void BAddr_Assert (BAddr *addr) -{ - switch (addr->type) { - case BADDR_TYPE_NONE: - case BADDR_TYPE_IPV4: - case BADDR_TYPE_IPV6: - #ifdef BADVPN_LINUX - case BADDR_TYPE_PACKET: - #endif - return; - default: - ASSERT(0); - } -} - -int BAddr_IsInvalid (BAddr *addr) -{ - BAddr_Assert(addr); - - return (addr->type == BADDR_TYPE_NONE); -} - -void BAddr_Print (BAddr *addr, char *out) -{ - BAddr_Assert(addr); - - BIPAddr ipaddr; - - switch (addr->type) { - case BADDR_TYPE_NONE: - sprintf(out, "(none)"); - break; - case BADDR_TYPE_IPV4: - BIPAddr_InitIPv4(&ipaddr, addr->ipv4.ip); - BIPAddr_Print(&ipaddr, out); - sprintf(out + strlen(out), ":%"PRIu16, ntoh16(addr->ipv4.port)); - break; - case BADDR_TYPE_IPV6: - BIPAddr_InitIPv6(&ipaddr, addr->ipv6.ip); - BIPAddr_Print(&ipaddr, out); - sprintf(out + strlen(out), ":%"PRIu16, ntoh16(addr->ipv6.port)); - break; - #ifdef BADVPN_LINUX - case BADDR_TYPE_PACKET: - ASSERT(addr->packet.header_type == BADDR_PACKET_HEADER_TYPE_ETHERNET) - sprintf(out, "proto=%"PRIu16",ifindex=%d,htype=eth,ptype=%d,addr=%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8, - addr->packet.phys_proto, (int)addr->packet.interface_index, (int)addr->packet.packet_type, - addr->packet.phys_addr[0], addr->packet.phys_addr[1], addr->packet.phys_addr[2], - addr->packet.phys_addr[3], addr->packet.phys_addr[4], addr->packet.phys_addr[5]); - break; - #endif - default: - ASSERT(0); - } -} - -int BAddr_Parse2 (BAddr *addr, char *str, char *name, int name_len, int noresolve) -{ - int len = strlen(str); - if (len < 1 || len > 1000) { - return 0; - } - - int addr_start; - int addr_len; - int port_start; - int port_len; - - // leading '[' indicates an IPv6 address - if (str[0] == '[') { - addr->type = BADDR_TYPE_IPV6; - // find ']' - int i=1; - while (i < len && str[i] != ']') i++; - if (i >= len) { - return 0; - } - addr_start = 1; - addr_len = i - addr_start; - // follows ':' and port number - if (i + 1 >= len || str[i + 1] != ':') { - return 0; - } - port_start = i + 2; - port_len = len - port_start; - } - // otherwise it's an IPv4 address - else { - addr->type = BADDR_TYPE_IPV4; - // find ':' - int i=0; - while (i < len && str[i] != ':') i++; - if (i >= len) { - return 0; - } - addr_start = 0; - addr_len = i - addr_start; - port_start = i + 1; - port_len = len - port_start; - } - - // copy address and port to zero-terminated buffers - - char addr_str[128]; - if (addr_len >= sizeof(addr_str)) { - return 0; - } - memcpy(addr_str, str + addr_start, addr_len); - addr_str[addr_len] = '\0'; - - char port_str[6]; - if (port_len >= sizeof(port_str)) { - return 0; - } - memcpy(port_str, str + port_start, port_len); - port_str[port_len] = '\0'; - - // parse port - char *err; - long int conv_res = strtol(port_str, &err, 10); - if (port_str[0] == '\0' || *err != '\0') { - return 0; - } - if (conv_res < 0 || conv_res > UINT16_MAX) { - return 0; - } - uint16_t port = conv_res; - port = hton16(port); - - // initialize hints - struct addrinfo hints; - memset(&hints, 0, sizeof(hints)); - switch (addr->type) { - case BADDR_TYPE_IPV6: - hints.ai_family = AF_INET6; - break; - case BADDR_TYPE_IPV4: - hints.ai_family = AF_INET; - break; - } - if (noresolve) { - hints.ai_flags |= AI_NUMERICHOST; - } - - // call getaddrinfo - struct addrinfo *addrs; - int res; - if ((res = getaddrinfo(addr_str, NULL, &hints, &addrs)) != 0) { - return 0; - } - - // set address - switch (addr->type) { - case BADDR_TYPE_IPV6: - memcpy(addr->ipv6.ip, ((struct sockaddr_in6 *)addrs->ai_addr)->sin6_addr.s6_addr, sizeof(addr->ipv6.ip)); - addr->ipv6.port = port; - break; - case BADDR_TYPE_IPV4: - addr->ipv4.ip = ((struct sockaddr_in *)addrs->ai_addr)->sin_addr.s_addr; - addr->ipv4.port = port; - break; - } - - freeaddrinfo(addrs); - - if (name) { - if (strlen(addr_str) >= name_len) { - return 0; - } - strcpy(name, addr_str); - } - - return 1; -} - -int BAddr_Parse (BAddr *addr, char *str, char *name, int name_len) -{ - return BAddr_Parse2(addr, str, name, name_len, 0); -} - -int BAddr_Compare (BAddr *addr1, BAddr *addr2) -{ - BAddr_Assert(addr1); - BAddr_Assert(addr2); - - if (addr1->type != addr2->type) { - return 0; - } - - switch (addr1->type) { - case BADDR_TYPE_IPV4: - return (addr1->ipv4.ip == addr2->ipv4.ip && addr1->ipv4.port == addr2->ipv4.port); - case BADDR_TYPE_IPV6: - return (!memcmp(addr1->ipv6.ip, addr2->ipv6.ip, sizeof(addr1->ipv6.ip)) && addr1->ipv6.port == addr2->ipv6.port); - default: - return 0; - } -} - -int BAddr_CompareOrder (BAddr *addr1, BAddr *addr2) -{ - BAddr_Assert(addr1); - BAddr_Assert(addr2); - - int cmp = B_COMPARE(addr1->type, addr2->type); - if (cmp) { - return cmp; - } - - switch (addr1->type) { - case BADDR_TYPE_NONE: { - return 0; - } break; - case BADDR_TYPE_IPV4: { - uint32_t ip1 = ntoh32(addr1->ipv4.ip); - uint32_t ip2 = ntoh32(addr2->ipv4.ip); - cmp = B_COMPARE(ip1, ip2); - if (cmp) { - return cmp; - } - uint16_t port1 = ntoh16(addr1->ipv4.port); - uint16_t port2 = ntoh16(addr2->ipv4.port); - return B_COMPARE(port1, port2); - } break; - case BADDR_TYPE_IPV6: { - cmp = memcmp(addr1->ipv6.ip, addr2->ipv6.ip, sizeof(addr1->ipv6.ip)); - if (cmp) { - return B_COMPARE(cmp, 0); - } - uint16_t port1 = ntoh16(addr1->ipv6.port); - uint16_t port2 = ntoh16(addr2->ipv6.port); - return B_COMPARE(port1, port2); - } break; - default: { - return 0; - } break; - } -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection.h deleted file mode 100644 index 5af0a040..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection.h +++ /dev/null @@ -1,424 +0,0 @@ -/** - * @file BConnection.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_SYSTEM_BCONNECTION -#define BADVPN_SYSTEM_BCONNECTION - -#include "misc/debug.h" -#include "flow/StreamPassInterface.h" -#include "flow/StreamRecvInterface.h" -#include "system/BAddr.h" -#include "system/BReactor.h" -#include "system/BNetwork.h" - - - -/** - * Checks if the given address is supported by {@link BConnection} and related objects. - * - * @param addr address to check. Must be a proper {@link BAddr} object according to - * {@link BIPAddr_Assert}. - * @return 1 if supported, 0 if not - */ -int BConnection_AddressSupported (BAddr addr); - - -#define BLISCON_FROM_ADDR 1 -#define BLISCON_FROM_UNIX 2 - -struct BLisCon_from { - int type; - union { - struct { - BAddr addr; - } from_addr; -#ifndef BADVPN_USE_WINAPI - struct { - char const *socket_path; - } from_unix; -#endif - } u; -}; - -static struct BLisCon_from BLisCon_from_addr (BAddr addr) -{ - struct BLisCon_from res; - res.type = BLISCON_FROM_ADDR; - res.u.from_addr.addr = addr; - return res; -} - -#ifndef BADVPN_USE_WINAPI -static struct BLisCon_from BLisCon_from_unix (char const *socket_path) -{ - struct BLisCon_from res; - res.type = BLISCON_FROM_UNIX; - res.u.from_unix.socket_path = socket_path; - return res; -} -#endif - - -struct BListener_s; - -/** - * Object which listens for connections on an address. - * When a connection is ready, the {@link BListener_handler} handler is called, from which - * the connection can be accepted into a new {@link BConnection} object. - */ -typedef struct BListener_s BListener; - -/** - * Handler called when a new connection is ready. - * The connection can be accepted by calling {@link BConnection_Init} with the a - * BCONNECTION_SOURCE_LISTENER 'source' argument. - * If no attempt is made to accept the connection from the job closure of this handler, - * the connection will be discarded. - * - * @param user as in {@link BListener_Init} - */ -typedef void (*BListener_handler) (void *user); - -/** - * Common listener initialization function. - * - * The other type-specific init functions are wrappers around this one. - */ -int BListener_InitFrom (BListener *o, struct BLisCon_from from, - BReactor *reactor, void *user, - BListener_handler handler) WARN_UNUSED; - -/** - * Initializes the object for listening on an address. - * {@link BNetwork_GlobalInit} must have been done. - * - * @param o the object - * @param addr address to listen on - * @param reactor reactor we live in - * @param user argument to handler - * @param handler handler called when a connection can be accepted - * @return 1 on success, 0 on failure - */ -int BListener_Init (BListener *o, BAddr addr, BReactor *reactor, void *user, - BListener_handler handler) WARN_UNUSED; - -#ifndef BADVPN_USE_WINAPI -/** - * Initializes the object for listening on a Unix socket. - * {@link BNetwork_GlobalInit} must have been done. - * - * @param o the object - * @param socket_path socket path for listening - * @param reactor reactor we live in - * @param user argument to handler - * @param handler handler called when a connection can be accepted - * @return 1 on success, 0 on failure - */ -int BListener_InitUnix (BListener *o, const char *socket_path, BReactor *reactor, void *user, - BListener_handler handler) WARN_UNUSED; -#endif - -/** - * Frees the object. - * - * @param o the object - */ -void BListener_Free (BListener *o); - - - -struct BConnector_s; - -/** - * Object which connects to an address. - * When the connection attempt finishes, the {@link BConnector_handler} handler is called, from which, - * if successful, the resulting connection can be moved to a new {@link BConnection} object. - */ -typedef struct BConnector_s BConnector; - -/** - * Handler called when the connection attempt finishes. - * If the connection attempt succeeded (is_error==0), the new connection can be used by calling - * {@link BConnection_Init} with a BCONNECTION_SOURCE_TYPE_CONNECTOR 'source' argument. - * This handler will be called at most once. The connector object need not be freed after it - * is called. - * - * @param user as in {@link BConnector_Init} - * @param is_error whether the connection attempt succeeded (0) or failed (1) - */ -typedef void (*BConnector_handler) (void *user, int is_error); - -/** - * Common connector initialization function. - * - * The other type-specific init functions are wrappers around this one. - */ -int BConnector_InitFrom (BConnector *o, struct BLisCon_from from, BReactor *reactor, void *user, - BConnector_handler handler) WARN_UNUSED; - -/** - * Initializes the object for connecting to an address. - * {@link BNetwork_GlobalInit} must have been done. - * - * @param o the object - * @param addr address to connect to - * @param reactor reactor we live in - * @param user argument to handler - * @param handler handler called when the connection attempt finishes - * @return 1 on success, 0 on failure - */ -int BConnector_Init (BConnector *o, BAddr addr, BReactor *reactor, void *user, - BConnector_handler handler) WARN_UNUSED; - -#ifndef BADVPN_USE_WINAPI -/** - * Initializes the object for connecting to a Unix socket. - * {@link BNetwork_GlobalInit} must have been done. - * - * @param o the object - * @param socket_path socket path for connecting - * @param reactor reactor we live in - * @param user argument to handler - * @param handler handler called when the connection attempt finishes - * @return 1 on success, 0 on failure - */ -int BConnector_InitUnix (BConnector *o, const char *socket_path, BReactor *reactor, void *user, - BConnector_handler handler) WARN_UNUSED; -#endif - -/** - * Frees the object. - * - * @param o the object - */ -void BConnector_Free (BConnector *o); - - - -#define BCONNECTION_SOURCE_TYPE_LISTENER 1 -#define BCONNECTION_SOURCE_TYPE_CONNECTOR 2 -#define BCONNECTION_SOURCE_TYPE_PIPE 3 - -struct BConnection_source { - int type; - union { - struct { - BListener *listener; - BAddr *out_addr; - } listener; - struct { - BConnector *connector; - } connector; -#ifndef BADVPN_USE_WINAPI - struct { - int pipefd; - int close_it; - } pipe; -#endif - } u; -}; - -static struct BConnection_source BConnection_source_listener (BListener *listener, BAddr *out_addr) -{ - struct BConnection_source s; - s.type = BCONNECTION_SOURCE_TYPE_LISTENER; - s.u.listener.listener = listener; - s.u.listener.out_addr = out_addr; - return s; -} - -static struct BConnection_source BConnection_source_connector (BConnector *connector) -{ - struct BConnection_source s; - s.type = BCONNECTION_SOURCE_TYPE_CONNECTOR; - s.u.connector.connector = connector; - return s; -} - -#ifndef BADVPN_USE_WINAPI -static struct BConnection_source BConnection_source_pipe (int pipefd, int close_it) -{ - struct BConnection_source s; - s.type = BCONNECTION_SOURCE_TYPE_PIPE; - s.u.pipe.pipefd = pipefd; - s.u.pipe.close_it = close_it; - return s; -} -#endif - -struct BConnection_s; - -/** - * Object which represents a stream connection. This is usually a TCP connection, either client - * or server, but may also be used with any file descriptor (e.g. pipe) on Unix-like systems. - * Sending and receiving is performed via {@link StreamPassInterface} and {@link StreamRecvInterface}, - * respectively. - */ -typedef struct BConnection_s BConnection; - -#define BCONNECTION_EVENT_ERROR 1 -#define BCONNECTION_EVENT_RECVCLOSED 2 - -/** - * Handler called when an error occurs or the receive end of the connection was closed - * by the remote peer. - * - If event is BCONNECTION_EVENT_ERROR, the connection is no longer usable and must be freed - * from withing the job closure of this handler. No further I/O or interface initialization - * must occur. - * - If event is BCONNECTION_EVENT_RECVCLOSED, no further receive I/O or receive interface - * initialization must occur. It is guarantted that the receive interface was initialized. - * - * @param user as in {@link BConnection_Init} or {@link BConnection_SetHandlers} - * @param event what happened - BCONNECTION_EVENT_ERROR or BCONNECTION_EVENT_RECVCLOSED - */ -typedef void (*BConnection_handler) (void *user, int event); - -/** - * Initializes the object. - * {@link BNetwork_GlobalInit} must have been done. - * - * @param o the object - * @param source specifies what the connection comes from. This argument must be created with one of the - * following macros: - * - BCONNECTION_SOURCE_LISTENER(BListener *, BAddr *) - * Accepts a connection ready on a {@link BListener} object. Must be called from the job - * closure of the listener's {@link BListener_handler}, and must be the first attempt - * for this handler invocation. The address of the client is written if the address - * argument is not NULL (theoretically an invalid address may be returned). - * - BCONNECTION_SOURCE_CONNECTOR(Bconnector *) - * Uses a connection establised with {@link BConnector}. Must be called from the job - * closure of the connector's {@link BConnector_handler}, the handler must be reporting - * successful connection, and must be the first attempt for this handler invocation. - * - BCONNECTION_SOURCE_PIPE(int pipefd, int close_it) - * On Unix-like systems, uses the provided file descriptor. The file descriptor number must - * be >=0. If close_it is true, the connector will take responsibility of closing the - * pipefd. Note that it will be closed even when this Init fails. - * @param reactor reactor we live in - * @param user argument to handler - * @param handler handler called when an error occurs or the receive end of the connection was closed - * by the remote peer. - * @return 1 on success, 0 on failure - */ -int BConnection_Init (BConnection *o, struct BConnection_source source, BReactor *reactor, void *user, - BConnection_handler handler) WARN_UNUSED; - -/** - * Frees the object. - * The send and receive interfaces must not be initialized. - * If the connection was created with a BCONNECTION_SOURCE_PIPE 'source' argument, the file descriptor - * will not be closed. - * - * @param o the object - */ -void BConnection_Free (BConnection *o); - -/** - * Updates the handler function. - * - * @param o the object - * @param user argument to handler - * @param handler new handler function, as in {@link BConnection_Init}. Additionally, may be NULL to - * remove the current handler. In this case, a proper handler must be set before anything - * can happen with the connection. This is used when moving the connection ownership from - * one module to another. - */ -void BConnection_SetHandlers (BConnection *o, void *user, BConnection_handler handler); - -/** - * Sets the SO_SNDBUF socket option. - * - * @param o the object - * @param buf_size value for SO_SNDBUF option - * @return 1 on success, 0 on failure - */ -int BConnection_SetSendBuffer (BConnection *o, int buf_size); - -/** - * Initializes the send interface for the connection. - * The send interface must not be initialized. - * - * @param o the object - */ -void BConnection_SendAsync_Init (BConnection *o); - -/** - * Frees the send interface for the connection. - * The send interface must be initialized. - * If the send interface was busy when this is called, the connection is no longer usable and must be - * freed before any further I/O or interface initialization. - * - * @param o the object - */ -void BConnection_SendAsync_Free (BConnection *o); - -/** - * Returns the send interface. - * The send interface must be initialized. - * - * @param o the object - * @return send interface - */ -StreamPassInterface * BConnection_SendAsync_GetIf (BConnection *o); - -/** - * Initializes the receive interface for the connection. - * The receive interface must not be initialized. - * - * @param o the object - */ -void BConnection_RecvAsync_Init (BConnection *o); - -/** - * Frees the receive interface for the connection. - * The receive interface must be initialized. - * If the receive interface was busy when this is called, the connection is no longer usable and must be - * freed before any further I/O or interface initialization. - * - * @param o the object - */ -void BConnection_RecvAsync_Free (BConnection *o); - -/** - * Returns the receive interface. - * The receive interface must be initialized. - * - * @param o the object - * @return receive interface - */ -StreamRecvInterface * BConnection_RecvAsync_GetIf (BConnection *o); - - - -#ifdef BADVPN_USE_WINAPI -#include "BConnection_win.h" -#else -#include "BConnection_unix.h" -#endif - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection_common.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection_common.c deleted file mode 100644 index 79950eae..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection_common.c +++ /dev/null @@ -1,58 +0,0 @@ -/** - * @file BConnection_common.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "BConnection.h" - -int BListener_Init (BListener *o, BAddr addr, BReactor *reactor, void *user, - BListener_handler handler) -{ - return BListener_InitFrom(o, BLisCon_from_addr(addr), reactor, user, handler); -} - -#ifndef BADVPN_USE_WINAPI -int BListener_InitUnix (BListener *o, const char *socket_path, BReactor *reactor, void *user, - BListener_handler handler) -{ - return BListener_InitFrom(o, BLisCon_from_unix(socket_path), reactor, user, handler); -} -#endif - -int BConnector_Init (BConnector *o, BAddr addr, BReactor *reactor, void *user, - BConnector_handler handler) -{ - return BConnector_InitFrom(o, BLisCon_from_addr(addr), reactor, user, handler); -} - -#ifndef BADVPN_USE_WINAPI -int BConnector_InitUnix (BConnector *o, const char *socket_path, BReactor *reactor, void *user, - BConnector_handler handler) -{ - return BConnector_InitFrom(o, BLisCon_from_unix(socket_path), reactor, user, handler); -} -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection_unix.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection_unix.c deleted file mode 100644 index 14dcb2fd..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection_unix.c +++ /dev/null @@ -1,968 +0,0 @@ -/** - * @file BConnection_unix.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "misc/nonblocking.h" -#include "misc/strdup.h" -#include "base/BLog.h" - -#include "BConnection.h" - -#include "generated/blog_channel_BConnection.h" - -#define MAX_UNIX_SOCKET_PATH 200 - -#define SEND_STATE_NOT_INITED 0 -#define SEND_STATE_READY 1 -#define SEND_STATE_BUSY 2 - -#define RECV_STATE_NOT_INITED 0 -#define RECV_STATE_READY 1 -#define RECV_STATE_BUSY 2 -#define RECV_STATE_INITED_CLOSED 3 -#define RECV_STATE_NOT_INITED_CLOSED 4 - -struct sys_addr { - socklen_t len; - union { - struct sockaddr generic; - struct sockaddr_in ipv4; - struct sockaddr_in6 ipv6; - } addr; -}; - -struct unix_addr { - socklen_t len; - union { - struct sockaddr_un addr; - uint8_t bytes[offsetof(struct sockaddr_un, sun_path) + MAX_UNIX_SOCKET_PATH + 1]; - } u; -}; - -static int build_unix_address (struct unix_addr *out, const char *socket_path); -static void addr_socket_to_sys (struct sys_addr *out, BAddr addr); -static void addr_sys_to_socket (BAddr *out, struct sys_addr addr); -static void listener_fd_handler (BListener *o, int events); -static void listener_default_job_handler (BListener *o); -static void connector_fd_handler (BConnector *o, int events); -static void connector_job_handler (BConnector *o); -static void connection_report_error (BConnection *o); -static void connection_send (BConnection *o); -static void connection_recv (BConnection *o); -static void connection_fd_handler (BConnection *o, int events); -static void connection_send_job_handler (BConnection *o); -static void connection_recv_job_handler (BConnection *o); -static void connection_send_if_handler_send (BConnection *o, uint8_t *data, int data_len); -static void connection_recv_if_handler_recv (BConnection *o, uint8_t *data, int data_len); - -static int build_unix_address (struct unix_addr *out, const char *socket_path) -{ - ASSERT(socket_path); - - if (strlen(socket_path) > MAX_UNIX_SOCKET_PATH) { - return 0; - } - - out->len = offsetof(struct sockaddr_un, sun_path) + strlen(socket_path) + 1; - out->u.addr.sun_family = AF_UNIX; - strcpy(out->u.addr.sun_path, socket_path); - - return 1; -} - -static void addr_socket_to_sys (struct sys_addr *out, BAddr addr) -{ - switch (addr.type) { - case BADDR_TYPE_IPV4: { - out->len = sizeof(out->addr.ipv4); - memset(&out->addr.ipv4, 0, sizeof(out->addr.ipv4)); - out->addr.ipv4.sin_family = AF_INET; - out->addr.ipv4.sin_port = addr.ipv4.port; - out->addr.ipv4.sin_addr.s_addr = addr.ipv4.ip; - } break; - - case BADDR_TYPE_IPV6: { - out->len = sizeof(out->addr.ipv6); - memset(&out->addr.ipv6, 0, sizeof(out->addr.ipv6)); - out->addr.ipv6.sin6_family = AF_INET6; - out->addr.ipv6.sin6_port = addr.ipv6.port; - out->addr.ipv6.sin6_flowinfo = 0; - memcpy(out->addr.ipv6.sin6_addr.s6_addr, addr.ipv6.ip, 16); - out->addr.ipv6.sin6_scope_id = 0; - } break; - - default: ASSERT(0); - } -} - -static void addr_sys_to_socket (BAddr *out, struct sys_addr addr) -{ - switch (addr.addr.generic.sa_family) { - case AF_INET: { - ASSERT(addr.len == sizeof(struct sockaddr_in)) - BAddr_InitIPv4(out, addr.addr.ipv4.sin_addr.s_addr, addr.addr.ipv4.sin_port); - } break; - - case AF_INET6: { - ASSERT(addr.len == sizeof(struct sockaddr_in6)) - BAddr_InitIPv6(out, addr.addr.ipv6.sin6_addr.s6_addr, addr.addr.ipv6.sin6_port); - } break; - - default: { - BAddr_InitNone(out); - } break; - } -} - -static void listener_fd_handler (BListener *o, int events) -{ - DebugObject_Access(&o->d_obj); - - // set default job - BPending_Set(&o->default_job); - - // call handler - o->handler(o->user); - return; -} - -static void listener_default_job_handler (BListener *o) -{ - DebugObject_Access(&o->d_obj); - - BLog(BLOG_ERROR, "discarding connection"); - - // accept - int newfd = accept(o->fd, NULL, NULL); - if (newfd < 0) { - BLog(BLOG_ERROR, "accept failed"); - return; - } - - // close new fd - if (close(newfd) < 0) { - BLog(BLOG_ERROR, "close failed"); - } -} - -static void connector_fd_handler (BConnector *o, int events) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->fd >= 0) - ASSERT(!o->connected) - ASSERT(o->have_bfd) - - // free BFileDescriptor - BReactor_RemoveFileDescriptor(o->reactor, &o->bfd); - - // set have no BFileDescriptor - o->have_bfd = 0; - - // read connection result - int result; - socklen_t result_len = sizeof(result); - if (getsockopt(o->fd, SOL_SOCKET, SO_ERROR, &result, &result_len) < 0) { - BLog(BLOG_ERROR, "getsockopt failed"); - goto fail0; - } - ASSERT_FORCE(result_len == sizeof(result)) - - if (result != 0) { - BLog(BLOG_ERROR, "connection failed"); - goto fail0; - } - - // set connected - o->connected = 1; - -fail0: - // call handler - o->handler(o->user, !o->connected); - return; -} - -static void connector_job_handler (BConnector *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->fd >= 0) - ASSERT(o->connected) - ASSERT(!o->have_bfd) - - // call handler - o->handler(o->user, 0); - return; -} - -static void connection_report_error (BConnection *o) -{ - DebugError_AssertNoError(&o->d_err); - ASSERT(o->handler) - - // report error - DEBUGERROR(&o->d_err, o->handler(o->user, BCONNECTION_EVENT_ERROR)); - return; -} - -static void connection_send (BConnection *o) -{ - DebugError_AssertNoError(&o->d_err); - ASSERT(o->send.state == SEND_STATE_BUSY) - - // limit - if (!o->is_hupd) { - if (!BReactorLimit_Increment(&o->send.limit)) { - // wait for fd - o->wait_events |= BREACTOR_WRITE; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - return; - } - } - - // send - int bytes = write(o->fd, o->send.busy_data, o->send.busy_data_len); - if (bytes < 0) { - if (!o->is_hupd && (errno == EAGAIN || errno == EWOULDBLOCK)) { - // wait for fd - o->wait_events |= BREACTOR_WRITE; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - return; - } - - BLog(BLOG_ERROR, "send failed"); - connection_report_error(o); - return; - } - BLog(BLOG_INFO, "clien try write: %d, written: %d", o->send.busy_data_len, bytes); - - ASSERT(bytes > 0) - ASSERT(bytes <= o->send.busy_data_len) - - // set ready - o->send.state = SEND_STATE_READY; - - // done - StreamPassInterface_Done(&o->send.iface, bytes); -} - -static void connection_recv (BConnection *o) -{ - DebugError_AssertNoError(&o->d_err); - ASSERT(o->recv.state == RECV_STATE_BUSY) - - // limit - if (!o->is_hupd) { - if (!BReactorLimit_Increment(&o->recv.limit)) { - // wait for fd - o->wait_events |= BREACTOR_READ; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - return; - } - } - BLog(BLOG_INFO, "clien try read: %d", o->recv.busy_data_avail); - - // recv - int bytes = recv(o->fd, o->recv.busy_data, o->recv.busy_data_avail, 0); - if (bytes < 0) { - if (!o->is_hupd && (errno == EAGAIN || errno == EWOULDBLOCK)) { - // wait for fd - o->wait_events |= BREACTOR_READ; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - return; - } - BLog(BLOG_ERROR, "recv failed"); - connection_report_error(o); - return; - } - BLog(BLOG_INFO, "clien try read: %d, received: %d", o->recv.busy_data_avail, bytes); - - if (bytes == 0) { - // set recv inited closed - o->recv.state = RECV_STATE_INITED_CLOSED; - - // report recv closed - o->handler(o->user, BCONNECTION_EVENT_RECVCLOSED); - return; - } - - ASSERT(bytes > 0) - ASSERT(bytes <= o->recv.busy_data_avail) - - // set not busy - o->recv.state = RECV_STATE_READY; - // done - StreamRecvInterface_Done(&o->recv.iface, bytes); -} - -static void connection_fd_handler (BConnection *o, int events) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(!o->is_hupd) - - // clear handled events - o->wait_events &= ~events; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - - int have_send = 0; - int have_recv = 0; - - // if we got a HUP event, stop monitoring the file descriptor - if ((events & BREACTOR_HUP)) { - BReactor_RemoveFileDescriptor(o->reactor, &o->bfd); - o->is_hupd = 1; - } - - if ((events & BREACTOR_WRITE) || ((events & (BREACTOR_ERROR|BREACTOR_HUP)) && o->send.state == SEND_STATE_BUSY)) { - ASSERT(o->send.state == SEND_STATE_BUSY) - have_send = 1; - } - - if ((events & BREACTOR_READ) || ((events & (BREACTOR_ERROR|BREACTOR_HUP)) && o->recv.state == RECV_STATE_BUSY)) { - ASSERT(o->recv.state == RECV_STATE_BUSY) - have_recv = 1; - } - - if (have_send) { - if (have_recv) { - BPending_Set(&o->recv.job); - } - - connection_send(o); - return; - } - - if (have_recv) { - connection_recv(o); - return; - } - - if (!o->is_hupd) { - BLog(BLOG_ERROR, "fd error event"); - connection_report_error(o); - return; - } -} - -static void connection_send_job_handler (BConnection *o) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(o->send.state == SEND_STATE_BUSY) - - connection_send(o); - return; -} - -static void connection_recv_job_handler (BConnection *o) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(o->recv.state == RECV_STATE_BUSY) - - connection_recv(o); - return; -} - -static void connection_send_if_handler_send (BConnection *o, uint8_t *data, int data_len) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(o->send.state == SEND_STATE_READY) - ASSERT(data_len > 0) - - // remember data - o->send.busy_data = data; - o->send.busy_data_len = data_len; - - // set busy - o->send.state = SEND_STATE_BUSY; - - connection_send(o); - return; -} - -static void connection_recv_if_handler_recv (BConnection *o, uint8_t *data, int data_avail) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(o->recv.state == RECV_STATE_READY) - ASSERT(data_avail > 0) - - // remember data - o->recv.busy_data = data; - o->recv.busy_data_avail = data_avail; - - // set busy - o->recv.state = RECV_STATE_BUSY; - - connection_recv(o); - return; -} - -int BConnection_AddressSupported (BAddr addr) -{ - BAddr_Assert(&addr); - - return (addr.type == BADDR_TYPE_IPV4 || addr.type == BADDR_TYPE_IPV6); -} - -int BListener_InitFrom (BListener *o, struct BLisCon_from from, - BReactor *reactor, void *user, - BListener_handler handler) -{ - ASSERT(from.type == BLISCON_FROM_ADDR || from.type == BLISCON_FROM_UNIX) - ASSERT(from.type != BLISCON_FROM_UNIX || from.u.from_unix.socket_path) - ASSERT(handler) - BNetwork_Assert(); - - // init arguments - o->reactor = reactor; - o->user = user; - o->handler = handler; - - // init socket path - o->unix_socket_path = NULL; - if (from.type == BLISCON_FROM_UNIX) { - o->unix_socket_path = b_strdup(from.u.from_unix.socket_path); - if (!o->unix_socket_path) { - BLog(BLOG_ERROR, "b_strdup failed"); - goto fail0; - } - } - - struct unix_addr unixaddr; - struct sys_addr sysaddr; - - if (from.type == BLISCON_FROM_UNIX) { - // build address - if (!build_unix_address(&unixaddr, o->unix_socket_path)) { - BLog(BLOG_ERROR, "build_unix_address failed"); - goto fail1; - } - - // init fd - if ((o->fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { - BLog(BLOG_ERROR, "socket failed"); - goto fail1; - } - } else { - // check address - if (!BConnection_AddressSupported(from.u.from_addr.addr)) { - BLog(BLOG_ERROR, "address not supported"); - goto fail1; - } - - // convert address - addr_socket_to_sys(&sysaddr, from.u.from_addr.addr); - - // init fd - if ((o->fd = socket(sysaddr.addr.generic.sa_family, SOCK_STREAM, 0)) < 0) { - BLog(BLOG_ERROR, "socket failed"); - goto fail1; - } - } - - // set non-blocking - if (!badvpn_set_nonblocking(o->fd)) { - BLog(BLOG_ERROR, "badvpn_set_nonblocking failed"); - goto fail2; - } - - if (from.type == BLISCON_FROM_UNIX) { - // unlink existing socket - if (unlink(o->unix_socket_path) < 0 && errno != ENOENT) { - BLog(BLOG_ERROR, "unlink existing socket failed"); - goto fail2; - } - - // bind - if (bind(o->fd, (struct sockaddr *)&unixaddr.u.addr, unixaddr.len) < 0) { - BLog(BLOG_ERROR, "bind failed"); - goto fail2; - } - } else { - // set SO_REUSEADDR - int optval = 1; - if (setsockopt(o->fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0) { - BLog(BLOG_ERROR, "setsockopt(SO_REUSEADDR) failed"); - } - - // bind - if (bind(o->fd, &sysaddr.addr.generic, sysaddr.len) < 0) { - BLog(BLOG_ERROR, "bind failed"); - goto fail2; - } - } - - // listen - if (listen(o->fd, BCONNECTION_LISTEN_BACKLOG) < 0) { - BLog(BLOG_ERROR, "listen failed"); - goto fail3; - } - - // init BFileDescriptor - BFileDescriptor_Init(&o->bfd, o->fd, (BFileDescriptor_handler)listener_fd_handler, o); - if (!BReactor_AddFileDescriptor(o->reactor, &o->bfd)) { - BLog(BLOG_ERROR, "BReactor_AddFileDescriptor failed"); - goto fail3; - } - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, BREACTOR_READ); - - // init default job - BPending_Init(&o->default_job, BReactor_PendingGroup(o->reactor), (BPending_handler)listener_default_job_handler, o); - - DebugObject_Init(&o->d_obj); - return 1; - -fail3: - if (from.type == BLISCON_FROM_UNIX) { - if (unlink(o->unix_socket_path) < 0) { - BLog(BLOG_ERROR, "unlink socket failed"); - } - } -fail2: - if (close(o->fd) < 0) { - BLog(BLOG_ERROR, "close failed"); - } -fail1: - free(o->unix_socket_path); -fail0: - return 0; -} - -void BListener_Free (BListener *o) -{ - DebugObject_Free(&o->d_obj); - - // free default job - BPending_Free(&o->default_job); - - // free BFileDescriptor - BReactor_RemoveFileDescriptor(o->reactor, &o->bfd); - - // free fd - if (close(o->fd) < 0) { - BLog(BLOG_ERROR, "close failed"); - } - - // unlink unix socket - if (o->unix_socket_path) { - if (unlink(o->unix_socket_path) < 0) { - BLog(BLOG_ERROR, "unlink socket failed"); - } - } - - // free unix socket path - if (o->unix_socket_path) { - free(o->unix_socket_path); - } -} - -int BConnector_InitFrom (BConnector *o, struct BLisCon_from from, BReactor *reactor, void *user, - BConnector_handler handler) -{ - ASSERT(from.type == BLISCON_FROM_ADDR || from.type == BLISCON_FROM_UNIX) - ASSERT(from.type != BLISCON_FROM_UNIX || from.u.from_unix.socket_path) - ASSERT(handler) - BNetwork_Assert(); - - // init arguments - o->reactor = reactor; - o->user = user; - o->handler = handler; - - struct unix_addr unixaddr; - struct sys_addr sysaddr; - - if (from.type == BLISCON_FROM_UNIX) { - // build address - if (!build_unix_address(&unixaddr, from.u.from_unix.socket_path)) { - BLog(BLOG_ERROR, "build_unix_address failed"); - goto fail0; - } - } else { - // check address - if (!BConnection_AddressSupported(from.u.from_addr.addr)) { - BLog(BLOG_ERROR, "address not supported"); - goto fail0; - } - - // convert address - addr_socket_to_sys(&sysaddr, from.u.from_addr.addr); - } - - // init job - BPending_Init(&o->job, BReactor_PendingGroup(o->reactor), (BPending_handler)connector_job_handler, o); - - if (from.type == BLISCON_FROM_UNIX) { - // init fd - if ((o->fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { - BLog(BLOG_ERROR, "socket failed"); - goto fail1; - } - } else { - // init fd - if ((o->fd = socket(sysaddr.addr.generic.sa_family, SOCK_STREAM, 0)) < 0) { - BLog(BLOG_ERROR, "socket failed"); - goto fail1; - } - } - - // set fd non-blocking - if (!badvpn_set_nonblocking(o->fd)) { - BLog(BLOG_ERROR, "badvpn_set_nonblocking failed"); - goto fail2; - } - - // connect fd - int connect_res; - if (from.type == BLISCON_FROM_UNIX) { - connect_res = connect(o->fd, (struct sockaddr *)&unixaddr.u.addr, unixaddr.len); - } else { - connect_res = connect(o->fd, &sysaddr.addr.generic, sysaddr.len); - } - if (connect_res < 0 && errno != EINPROGRESS) { - BLog(BLOG_ERROR, "connect failed"); - goto fail2; - } - - // set not connected - o->connected = 0; - - // set have no BFileDescriptor - o->have_bfd = 0; - - if (connect_res < 0) { - // init BFileDescriptor - BFileDescriptor_Init(&o->bfd, o->fd, (BFileDescriptor_handler)connector_fd_handler, o); - if (!BReactor_AddFileDescriptor(o->reactor, &o->bfd)) { - BLog(BLOG_ERROR, "BReactor_AddFileDescriptor failed"); - goto fail2; - } - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, BREACTOR_WRITE); - - // set have BFileDescriptor - o->have_bfd = 1; - } else { - // set connected - o->connected = 1; - - // set job - BPending_Set(&o->job); - } - - DebugObject_Init(&o->d_obj); - return 1; - -fail2: - if (close(o->fd) < 0) { - BLog(BLOG_ERROR, "close failed"); - } -fail1: - BPending_Free(&o->job); -fail0: - return 0; -} - -void BConnector_Free (BConnector *o) -{ - DebugObject_Free(&o->d_obj); - - // free BFileDescriptor - if (o->have_bfd) { - BReactor_RemoveFileDescriptor(o->reactor, &o->bfd); - } - - // close fd - if (o->fd != -1) { - if (close(o->fd) < 0) { - BLog(BLOG_ERROR, "close failed"); - } - } - - // free job - BPending_Free(&o->job); -} - -int BConnection_Init (BConnection *o, struct BConnection_source source, BReactor *reactor, void *user, - BConnection_handler handler) -{ - switch (source.type) { - case BCONNECTION_SOURCE_TYPE_LISTENER: { - BListener *listener = source.u.listener.listener; - DebugObject_Access(&listener->d_obj); - ASSERT(BPending_IsSet(&listener->default_job)) - } break; - case BCONNECTION_SOURCE_TYPE_CONNECTOR: { - BConnector *connector = source.u.connector.connector; - DebugObject_Access(&connector->d_obj); - ASSERT(connector->fd >= 0) - ASSERT(connector->connected) - ASSERT(!connector->have_bfd) - ASSERT(!BPending_IsSet(&connector->job)) - } break; - case BCONNECTION_SOURCE_TYPE_PIPE: { - ASSERT(source.u.pipe.pipefd >= 0) - } break; - default: ASSERT(0); - } - ASSERT(handler) - BNetwork_Assert(); - - // init arguments - o->reactor = reactor; - o->user = user; - o->handler = handler; - - switch (source.type) { - case BCONNECTION_SOURCE_TYPE_LISTENER: { - BListener *listener = source.u.listener.listener; - - // unset listener's default job - BPending_Unset(&listener->default_job); - - // accept - struct sys_addr sysaddr; - sysaddr.len = sizeof(sysaddr.addr); - if ((o->fd = accept(listener->fd, &sysaddr.addr.generic, &sysaddr.len)) < 0) { - BLog(BLOG_ERROR, "accept failed"); - goto fail0; - } - o->close_fd = 1; - - // set non-blocking - if (!badvpn_set_nonblocking(o->fd)) { - BLog(BLOG_ERROR, "badvpn_set_nonblocking failed"); - goto fail1; - } - - // return address - if (source.u.listener.out_addr) { - addr_sys_to_socket(source.u.listener.out_addr, sysaddr); - } - } break; - - case BCONNECTION_SOURCE_TYPE_CONNECTOR: { - BConnector *connector = source.u.connector.connector; - - // grab fd from connector - o->fd = connector->fd; - connector->fd = -1; - o->close_fd = 1; - } break; - - case BCONNECTION_SOURCE_TYPE_PIPE: { - // use user-provided fd - o->fd = source.u.pipe.pipefd; - o->close_fd = !!source.u.pipe.close_it; - - // set non-blocking - if (!badvpn_set_nonblocking(o->fd)) { - BLog(BLOG_ERROR, "badvpn_set_nonblocking failed"); - goto fail1; - } - } break; - } - - // set not HUPd - o->is_hupd = 0; - - // init BFileDescriptor - BFileDescriptor_Init(&o->bfd, o->fd, (BFileDescriptor_handler)connection_fd_handler, o); - if (!BReactor_AddFileDescriptor(o->reactor, &o->bfd)) { - BLog(BLOG_ERROR, "BReactor_AddFileDescriptor failed"); - goto fail1; - } - - // set no wait events - o->wait_events = 0; - - // init limits - BReactorLimit_Init(&o->send.limit, o->reactor, BCONNECTION_SEND_LIMIT); - BReactorLimit_Init(&o->recv.limit, o->reactor, BCONNECTION_RECV_LIMIT); - - // set send and recv not inited - o->send.state = SEND_STATE_NOT_INITED; - o->recv.state = RECV_STATE_NOT_INITED; - - DebugError_Init(&o->d_err, BReactor_PendingGroup(o->reactor)); - DebugObject_Init(&o->d_obj); - return 1; - -fail1: - if (o->close_fd) { - if (close(o->fd) < 0) { - BLog(BLOG_ERROR, "close failed"); - } - } -fail0: - return 0; -} - -void BConnection_Free (BConnection *o) -{ - DebugObject_Free(&o->d_obj); - DebugError_Free(&o->d_err); - ASSERT(o->send.state == SEND_STATE_NOT_INITED) - ASSERT(o->recv.state == RECV_STATE_NOT_INITED || o->recv.state == RECV_STATE_NOT_INITED_CLOSED) - - // free limits - BReactorLimit_Free(&o->recv.limit); - BReactorLimit_Free(&o->send.limit); - - // free BFileDescriptor - if (!o->is_hupd) { - BReactor_RemoveFileDescriptor(o->reactor, &o->bfd); - } - - // close fd - if (o->close_fd) { - if (close(o->fd) < 0) { - BLog(BLOG_ERROR, "close failed"); - } - } -} - -void BConnection_SetHandlers (BConnection *o, void *user, BConnection_handler handler) -{ - DebugObject_Access(&o->d_obj); - - // set handlers - o->user = user; - o->handler = handler; -} - -int BConnection_SetSendBuffer (BConnection *o, int buf_size) -{ - DebugObject_Access(&o->d_obj); - - if (setsockopt(o->fd, SOL_SOCKET, SO_SNDBUF, (void *)&buf_size, sizeof(buf_size)) < 0) { - BLog(BLOG_ERROR, "setsockopt failed"); - return 0; - } - - return 1; -} - -void BConnection_SendAsync_Init (BConnection *o) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(o->send.state == SEND_STATE_NOT_INITED) - - // init interface - StreamPassInterface_Init(&o->send.iface, (StreamPassInterface_handler_send)connection_send_if_handler_send, o, BReactor_PendingGroup(o->reactor)); - - // init job - BPending_Init(&o->send.job, BReactor_PendingGroup(o->reactor), (BPending_handler)connection_send_job_handler, o); - - // set ready - o->send.state = SEND_STATE_READY; -} - -void BConnection_SendAsync_Free (BConnection *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->send.state == SEND_STATE_READY || o->send.state == SEND_STATE_BUSY) - - // update events - if (!o->is_hupd) { - o->wait_events &= ~BREACTOR_WRITE; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - } - - // free job - BPending_Free(&o->send.job); - - // free interface - StreamPassInterface_Free(&o->send.iface); - - // set not inited - o->send.state = SEND_STATE_NOT_INITED; -} - -StreamPassInterface * BConnection_SendAsync_GetIf (BConnection *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->send.state == SEND_STATE_READY || o->send.state == SEND_STATE_BUSY) - - return &o->send.iface; -} - -void BConnection_RecvAsync_Init (BConnection *o) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(o->recv.state == RECV_STATE_NOT_INITED) - - // init interface - StreamRecvInterface_Init(&o->recv.iface, (StreamRecvInterface_handler_recv)connection_recv_if_handler_recv, o, BReactor_PendingGroup(o->reactor)); - - // init job - BPending_Init(&o->recv.job, BReactor_PendingGroup(o->reactor), (BPending_handler)connection_recv_job_handler, o); - - // set ready - o->recv.state = RECV_STATE_READY; -} - -void BConnection_RecvAsync_Free (BConnection *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->recv.state == RECV_STATE_READY || o->recv.state == RECV_STATE_BUSY || o->recv.state == RECV_STATE_INITED_CLOSED) - - // update events - if (!o->is_hupd) { - o->wait_events &= ~BREACTOR_READ; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - } - - // free job - BPending_Free(&o->recv.job); - - // free interface - StreamRecvInterface_Free(&o->recv.iface); - - // set not inited - o->recv.state = RECV_STATE_NOT_INITED; -} - -StreamRecvInterface * BConnection_RecvAsync_GetIf (BConnection *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->recv.state == RECV_STATE_READY || o->recv.state == RECV_STATE_BUSY || o->recv.state == RECV_STATE_INITED_CLOSED) - - return &o->recv.iface; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection_unix.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection_unix.h deleted file mode 100644 index 38d368ca..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BConnection_unix.h +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @file BConnection_unix.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "misc/debugerror.h" -#include "base/DebugObject.h" - -#define BCONNECTION_SEND_LIMIT 2 -#define BCONNECTION_RECV_LIMIT 2 -#define BCONNECTION_LISTEN_BACKLOG 128 - -struct BListener_s { - BReactor *reactor; - void *user; - BListener_handler handler; - char *unix_socket_path; - int fd; - BFileDescriptor bfd; - BPending default_job; - DebugObject d_obj; -}; - -struct BConnector_s { - BReactor *reactor; - void *user; - BConnector_handler handler; - BPending job; - int fd; - int connected; - int have_bfd; - BFileDescriptor bfd; - DebugObject d_obj; -}; - -struct BConnection_s { - BReactor *reactor; - void *user; - BConnection_handler handler; - int fd; - int close_fd; - int is_hupd; - BFileDescriptor bfd; - int wait_events; - struct { - BReactorLimit limit; - StreamPassInterface iface; - BPending job; - const uint8_t *busy_data; - int busy_data_len; - int state; - } send; - struct { - BReactorLimit limit; - StreamRecvInterface iface; - BPending job; - uint8_t *busy_data; - int busy_data_avail; - int state; - } recv; - DebugError d_err; - DebugObject d_obj; -}; diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BDatagram.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BDatagram.h deleted file mode 100644 index 6196b5df..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BDatagram.h +++ /dev/null @@ -1,209 +0,0 @@ -/** - * @file BDatagram.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_SYSTEM_BDATAGRAM -#define BADVPN_SYSTEM_BDATAGRAM - -#include "misc/debug.h" -#include "flow/PacketPassInterface.h" -#include "flow/PacketRecvInterface.h" -#include "system/BAddr.h" -#include "system/BReactor.h" -#include "system/BNetwork.h" - -struct BDatagram_s; - -/** - * Represents datagram communication. This is usually UDP, but may also be Linux packet sockets. - * Sending and receiving is performed via {@link PacketPassInterface} and {@link PacketRecvInterface}, - * respectively. - */ -typedef struct BDatagram_s BDatagram; - -#define BDATAGRAM_EVENT_ERROR 1 - -/** - * Handler called when an error occurs with the datagram object. - * The datagram object is no longer usable and must be freed from withing the job closure of - * this handler. No further I/O, interface initialization, binding and send address setting - * must occur. - * - * @param user as in {@link BDatagram_Init} - * @param event always BDATAGRAM_EVENT_ERROR - */ -typedef void (*BDatagram_handler) (void *user, int event); - -/** - * Checks if the given address family (from {@link BAddr.h}) is supported by {@link BDatagram} - * and related objects. - * - * @param family family to check - * @return 1 if supported, 0 if not - */ -int BDatagram_AddressFamilySupported (int family); - -/** - * Initializes the object. - * {@link BNetwork_GlobalInit} must have been done. - * - * @param o the object - * @param family address family. Must be supported according to {@link BDatagram_AddressFamilySupported}. - * @param reactor reactor we live in - * @param user argument to handler - * @param handler handler called when an error occurs - * @return 1 on success, 0 on failure - */ -int BDatagram_Init (BDatagram *o, int family, BReactor *reactor, void *user, - BDatagram_handler handler) WARN_UNUSED; - -/** - * Frees the object. - * The send and receive interfaces must not be initialized. - * - * @param o the object - */ -void BDatagram_Free (BDatagram *o); - -/** - * Binds to the given local address. - * May initiate I/O. - * - * @param o the object - * @param addr address to bind to. Its family must be supported according to {@link BDatagram_AddressFamilySupported}. - * @return 1 on success, 0 on failure - */ -int BDatagram_Bind (BDatagram *o, BAddr addr) WARN_UNUSED; - -/** - * Sets addresses for sending. - * May initiate I/O. - * - * @param o the object - * @param remote_addr destination address for sending datagrams. Its family must be supported according - * to {@link BDatagram_AddressFamilySupported}. - * @param local_addr local source IP address. May be an invalid address, otherwise its family must be - * supported according to {@link BDatagram_AddressFamilySupported}. - */ -void BDatagram_SetSendAddrs (BDatagram *o, BAddr remote_addr, BIPAddr local_addr); - -/** - * Returns the remote and local address of the last datagram received. - * Fails if and only if no datagrams have been received yet. - * - * @param o the object - * @param remote_addr returns the remote source address of the datagram. May be an invalid address, theoretically. - * @param local_addr returns the local destination IP address. May be an invalid address. - * @return 1 on success, 0 on failure - */ -int BDatagram_GetLastReceiveAddrs (BDatagram *o, BAddr *remote_addr, BIPAddr *local_addr); - -#ifndef BADVPN_USE_WINAPI -/** - * Returns the underlying socket file descriptor of the datagram object. - * Available on Unix-like systems only. - * - * @param o the object - * @return file descriptor - */ -int BDatagram_GetFd (BDatagram *o); -#endif - -/** - * Sets the SO_REUSEADDR option for the underlying socket. - * - * @param o the object - * @param reuse value of the option. Must be 0 or 1. - */ -int BDatagram_SetReuseAddr (BDatagram *o, int reuse); - -/** - * Initializes the send interface. - * The send interface must not be initialized. - * - * @param o the object - * @param mtu maximum transmission unit. Must be >=0. - */ -void BDatagram_SendAsync_Init (BDatagram *o, int mtu); - -/** - * Frees the send interface. - * The send interface must be initialized. - * If the send interface was busy when this is called, the datagram object is no longer usable and must be - * freed before any further I/O or interface initialization. - * - * @param o the object - */ -void BDatagram_SendAsync_Free (BDatagram *o); - -/** - * Returns the send interface. - * The send interface must be initialized. - * The MTU of the interface will be as in {@link BDatagram_SendAsync_Init}. - * - * @param o the object - * @return send interface - */ -PacketPassInterface * BDatagram_SendAsync_GetIf (BDatagram *o); - -/** - * Initializes the receive interface. - * The receive interface must not be initialized. - * - * @param o the object - * @param mtu maximum transmission unit. Must be >=0. - */ -void BDatagram_RecvAsync_Init (BDatagram *o, int mtu); - -/** - * Frees the receive interface. - * The receive interface must be initialized. - * If the receive interface was busy when this is called, the datagram object is no longer usable and must be - * freed before any further I/O or interface initialization. - * - * @param o the object - */ -void BDatagram_RecvAsync_Free (BDatagram *o); - -/** - * Returns the receive interface. - * The receive interface must be initialized. - * The MTU of the interface will be as in {@link BDatagram_RecvAsync_Init}. - * - * @param o the object - * @return receive interface - */ -PacketRecvInterface * BDatagram_RecvAsync_GetIf (BDatagram *o); - -#ifdef BADVPN_USE_WINAPI -#include "BDatagram_win.h" -#else -#include "BDatagram_unix.h" -#endif - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BDatagram_unix.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BDatagram_unix.c deleted file mode 100644 index 6f9a9323..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BDatagram_unix.c +++ /dev/null @@ -1,881 +0,0 @@ -/** - * @file BDatagram_unix.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include -#include -#include -#include -#ifdef __APPLE__ -#define IPV6_PKTINFO IPV6_2292PKTINFO -#endif -#include -#include -#ifdef BADVPN_LINUX -# include -# include -#endif - -#include "misc/nonblocking.h" -#include "base/BLog.h" - -#include "BDatagram.h" - -#include "generated/blog_channel_BDatagram.h" - -struct sys_addr { - socklen_t len; - union { - struct sockaddr generic; - struct sockaddr_in ipv4; - struct sockaddr_in6 ipv6; -#ifdef BADVPN_LINUX - struct sockaddr_ll packet; -#endif - } addr; -}; - -static int family_socket_to_sys (int family); -static void addr_socket_to_sys (struct sys_addr *out, BAddr addr); -static void addr_sys_to_socket (BAddr *out, struct sys_addr addr); -static void set_pktinfo (int fd, int family); -static void report_error (BDatagram *o); -static void do_send (BDatagram *o); -static void do_recv (BDatagram *o); -static void fd_handler (BDatagram *o, int events); -static void send_job_handler (BDatagram *o); -static void recv_job_handler (BDatagram *o); -static void send_if_handler_send (BDatagram *o, uint8_t *data, int data_len); -static void recv_if_handler_recv (BDatagram *o, uint8_t *data); - -static int family_socket_to_sys (int family) -{ - switch (family) { - case BADDR_TYPE_IPV4: - return AF_INET; - case BADDR_TYPE_IPV6: - return AF_INET6; -#ifdef BADVPN_LINUX - case BADDR_TYPE_PACKET: - return AF_PACKET; -#endif - } - - ASSERT(0); - return 0; -} - -static void addr_socket_to_sys (struct sys_addr *out, BAddr addr) -{ - switch (addr.type) { - case BADDR_TYPE_IPV4: { - out->len = sizeof(out->addr.ipv4); - memset(&out->addr.ipv4, 0, sizeof(out->addr.ipv4)); - out->addr.ipv4.sin_family = AF_INET; - out->addr.ipv4.sin_port = addr.ipv4.port; - out->addr.ipv4.sin_addr.s_addr = addr.ipv4.ip; - } break; - - case BADDR_TYPE_IPV6: { - out->len = sizeof(out->addr.ipv6); - memset(&out->addr.ipv6, 0, sizeof(out->addr.ipv6)); - out->addr.ipv6.sin6_family = AF_INET6; - out->addr.ipv6.sin6_port = addr.ipv6.port; - out->addr.ipv6.sin6_flowinfo = 0; - memcpy(out->addr.ipv6.sin6_addr.s6_addr, addr.ipv6.ip, 16); - out->addr.ipv6.sin6_scope_id = 0; - } break; - -#ifdef BADVPN_LINUX - case BADDR_TYPE_PACKET: { - ASSERT(addr.packet.header_type == BADDR_PACKET_HEADER_TYPE_ETHERNET) - memset(&out->addr.packet, 0, sizeof(out->addr.packet)); - out->len = sizeof(out->addr.packet); - out->addr.packet.sll_family = AF_PACKET; - out->addr.packet.sll_protocol = addr.packet.phys_proto; - out->addr.packet.sll_ifindex = addr.packet.interface_index; - out->addr.packet.sll_hatype = 1; // linux/if_arp.h: #define ARPHRD_ETHER 1 - switch (addr.packet.packet_type) { - case BADDR_PACKET_PACKET_TYPE_HOST: - out->addr.packet.sll_pkttype = PACKET_HOST; - break; - case BADDR_PACKET_PACKET_TYPE_BROADCAST: - out->addr.packet.sll_pkttype = PACKET_BROADCAST; - break; - case BADDR_PACKET_PACKET_TYPE_MULTICAST: - out->addr.packet.sll_pkttype = PACKET_MULTICAST; - break; - case BADDR_PACKET_PACKET_TYPE_OTHERHOST: - out->addr.packet.sll_pkttype = PACKET_OTHERHOST; - break; - case BADDR_PACKET_PACKET_TYPE_OUTGOING: - out->addr.packet.sll_pkttype = PACKET_OUTGOING; - break; - default: - ASSERT(0); - } - out->addr.packet.sll_halen = 6; - memcpy(out->addr.packet.sll_addr, addr.packet.phys_addr, 6); - } break; -#endif - - default: ASSERT(0); - } -} - -static void addr_sys_to_socket (BAddr *out, struct sys_addr addr) -{ - switch (addr.addr.generic.sa_family) { - case AF_INET: { - ASSERT(addr.len == sizeof(struct sockaddr_in)) - BAddr_InitIPv4(out, addr.addr.ipv4.sin_addr.s_addr, addr.addr.ipv4.sin_port); - } break; - - case AF_INET6: { - ASSERT(addr.len == sizeof(struct sockaddr_in6)) - BAddr_InitIPv6(out, addr.addr.ipv6.sin6_addr.s6_addr, addr.addr.ipv6.sin6_port); - } break; - -#ifdef BADVPN_LINUX - case AF_PACKET: { - if (addr.len < offsetof(struct sockaddr_ll, sll_addr) + 6) { - goto fail; - } - if (addr.addr.packet.sll_hatype != 1) { // linux/if_arp.h: #define ARPHRD_ETHER 1 - goto fail; - } - int packet_type; - switch (addr.addr.packet.sll_pkttype) { - case PACKET_HOST: - packet_type = BADDR_PACKET_PACKET_TYPE_HOST; - break; - case PACKET_BROADCAST: - packet_type = BADDR_PACKET_PACKET_TYPE_BROADCAST; - break; - case PACKET_MULTICAST: - packet_type = BADDR_PACKET_PACKET_TYPE_MULTICAST; - break; - case PACKET_OTHERHOST: - packet_type = BADDR_PACKET_PACKET_TYPE_OTHERHOST; - break; - case PACKET_OUTGOING: - packet_type = BADDR_PACKET_PACKET_TYPE_OUTGOING; - break; - default: - goto fail; - } - if (addr.addr.packet.sll_halen != 6) { - goto fail; - } - BAddr_InitPacket(out, addr.addr.packet.sll_protocol, addr.addr.packet.sll_ifindex, BADDR_PACKET_HEADER_TYPE_ETHERNET, packet_type, addr.addr.packet.sll_addr); - } break; -#endif - - fail: - default: { - BAddr_InitNone(out); - } break; - } -} - -static void set_pktinfo (int fd, int family) -{ - int opt = 1; - - switch (family) { - case BADDR_TYPE_IPV4: { -#ifdef BADVPN_FREEBSD - if (setsockopt(fd, IPPROTO_IP, IP_RECVDSTADDR, &opt, sizeof(opt)) < 0) { - BLog(BLOG_ERROR, "setsockopt(IP_RECVDSTADDR) failed"); - } -#else - if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &opt, sizeof(opt)) < 0) { - BLog(BLOG_ERROR, "setsockopt(IP_PKTINFO) failed"); - } -#endif - } break; - -#ifdef IPV6_RECVPKTINFO - case BADDR_TYPE_IPV6: { - if (setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &opt, sizeof(opt)) < 0) { - BLog(BLOG_ERROR, "setsockopt(IPV6_RECVPKTINFO) failed"); - } - } break; -#endif - } -} - -static void report_error (BDatagram *o) -{ - DebugError_AssertNoError(&o->d_err); - - // report error - DEBUGERROR(&o->d_err, o->handler(o->user, BDATAGRAM_EVENT_ERROR)); - return; -} - -static void do_send (BDatagram *o) -{ - DebugError_AssertNoError(&o->d_err); - ASSERT(o->send.inited) - ASSERT(o->send.busy) - ASSERT(o->send.have_addrs) - - // limit - if (!BReactorLimit_Increment(&o->send.limit)) { - // wait for fd - o->wait_events |= BREACTOR_WRITE; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - return; - } - - // convert destination address - struct sys_addr sysaddr; - addr_socket_to_sys(&sysaddr, o->send.remote_addr); - - struct iovec iov; - iov.iov_base = (uint8_t *)o->send.busy_data; - iov.iov_len = o->send.busy_data_len; - - union { -#ifdef BADVPN_FREEBSD - char in[CMSG_SPACE(sizeof(struct in_addr))]; -#else - char in[CMSG_SPACE(sizeof(struct in_pktinfo))]; -#endif - char in6[CMSG_SPACE(sizeof(struct in6_pktinfo))]; - } cdata; - - struct msghdr msg; - memset(&msg, 0, sizeof(msg)); - msg.msg_name = &sysaddr.addr.generic; - msg.msg_namelen = sysaddr.len; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - msg.msg_control = &cdata; - msg.msg_controllen = sizeof(cdata); - - struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); - - size_t controllen = 0; -#ifdef __APPLE__ - int bytes = -1; - switch (o->send.local_addr.type) { - case BADDR_TYPE_IPV4: { - bytes = sendto(o->fd, iov.iov_base, iov.iov_len, 0, msg.msg_name, msg.msg_namelen); - } break; - - case BADDR_TYPE_IPV6: { - memset(cmsg, 0, CMSG_SPACE(sizeof(struct in6_pktinfo))); - cmsg->cmsg_level = IPPROTO_IPV6; - cmsg->cmsg_type = IPV6_PKTINFO; - cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); - struct in6_pktinfo *pktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsg); - memcpy(pktinfo->ipi6_addr.s6_addr, o->send.local_addr.ipv6, 16); - controllen += CMSG_SPACE(sizeof(struct in6_pktinfo)); - msg.msg_controllen = controllen; - if (msg.msg_controllen == 0) { - msg.msg_control = NULL; - } - bytes = sendmsg(o->fd, &msg, 0); - } break; - } -#else - switch (o->send.local_addr.type) { - case BADDR_TYPE_IPV4: { -#ifdef BADVPN_FREEBSD - memset(cmsg, 0, CMSG_SPACE(sizeof(struct in_addr))); - cmsg->cmsg_level = IPPROTO_IP; - cmsg->cmsg_type = IP_SENDSRCADDR; - cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_addr)); - struct in_addr *addrinfo = (struct in_addr *)CMSG_DATA(cmsg); - addrinfo->s_addr = o->send.local_addr.ipv4; - controllen += CMSG_SPACE(sizeof(struct in_addr)); -#else - memset(cmsg, 0, CMSG_SPACE(sizeof(struct in_pktinfo))); - cmsg->cmsg_level = IPPROTO_IP; - cmsg->cmsg_type = IP_PKTINFO; - cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo)); - struct in_pktinfo *pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg); - pktinfo->ipi_spec_dst.s_addr = o->send.local_addr.ipv4; - controllen += CMSG_SPACE(sizeof(struct in_pktinfo)); -#endif - } break; - - case BADDR_TYPE_IPV6: { - memset(cmsg, 0, CMSG_SPACE(sizeof(struct in6_pktinfo))); - cmsg->cmsg_level = IPPROTO_IPV6; - cmsg->cmsg_type = IPV6_PKTINFO; - cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); - struct in6_pktinfo *pktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsg); - memcpy(pktinfo->ipi6_addr.s6_addr, o->send.local_addr.ipv6, 16); - controllen += CMSG_SPACE(sizeof(struct in6_pktinfo)); - } break; - } - - msg.msg_controllen = controllen; - - if (msg.msg_controllen == 0) { - msg.msg_control = NULL; - } - - // send - int bytes = sendmsg(o->fd, &msg, 0); -#endif - if (bytes < 0) { - if (errno == EAGAIN || errno == EWOULDBLOCK) { - // wait for fd - o->wait_events |= BREACTOR_WRITE; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - return; - } - - BLog(BLOG_ERROR, "send failed"); - report_error(o); - return; - } - - ASSERT(bytes >= 0) - ASSERT(bytes <= o->send.busy_data_len) - - if (bytes < o->send.busy_data_len) { - BLog(BLOG_ERROR, "send sent too little"); - } - - // if recv wasn't started yet, start it - if (!o->recv.started) { - // set recv started - o->recv.started = 1; - - // continue receiving - if (o->recv.inited && o->recv.busy) { - BPending_Set(&o->recv.job); - } - } - - // set not busy - o->send.busy = 0; - - // done - PacketPassInterface_Done(&o->send.iface); -} - -static void do_recv (BDatagram *o) -{ - DebugError_AssertNoError(&o->d_err); - ASSERT(o->recv.inited) - ASSERT(o->recv.busy) - ASSERT(o->recv.started) - - // limit - if (!BReactorLimit_Increment(&o->recv.limit)) { - // wait for fd - o->wait_events |= BREACTOR_READ; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - return; - } - - struct sys_addr sysaddr; - - struct iovec iov; - iov.iov_base = o->recv.busy_data; - iov.iov_len = o->recv.mtu; - - union { -#ifdef BADVPN_FREEBSD - char in[CMSG_SPACE(sizeof(struct in_addr))]; -#else - char in[CMSG_SPACE(sizeof(struct in_pktinfo))]; -#endif - char in6[CMSG_SPACE(sizeof(struct in6_pktinfo))]; - } cdata; - - struct msghdr msg; - memset(&msg, 0, sizeof(msg)); - msg.msg_name = &sysaddr.addr.generic; - msg.msg_namelen = sizeof(sysaddr.addr); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - msg.msg_control = &cdata; - msg.msg_controllen = sizeof(cdata); - - // recv - int bytes = recvmsg(o->fd, &msg, 0); - if (bytes < 0) { - if (errno == EAGAIN || errno == EWOULDBLOCK) { - // wait for fd - o->wait_events |= BREACTOR_READ; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - return; - } - - BLog(BLOG_ERROR, "recv failed"); - report_error(o); - return; - } - - ASSERT(bytes >= 0) - ASSERT(bytes <= o->recv.mtu) - - // read returned address - sysaddr.len = msg.msg_namelen; - addr_sys_to_socket(&o->recv.remote_addr, sysaddr); - - // read returned local address - BIPAddr_InitInvalid(&o->recv.local_addr); - for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { -#ifdef BADVPN_FREEBSD - if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_RECVDSTADDR) { - struct in_addr *addrinfo = (struct in_addr *)CMSG_DATA(cmsg); - BIPAddr_InitIPv4(&o->recv.local_addr, addrinfo->s_addr); - } -#else - if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO) { - struct in_pktinfo *pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg); - BIPAddr_InitIPv4(&o->recv.local_addr, pktinfo->ipi_addr.s_addr); - } -#endif - else if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO) { - struct in6_pktinfo *pktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsg); - BIPAddr_InitIPv6(&o->recv.local_addr, pktinfo->ipi6_addr.s6_addr); - } - } - - // set have addresses - o->recv.have_addrs = 1; - - // set not busy - o->recv.busy = 0; - - // done - PacketRecvInterface_Done(&o->recv.iface, bytes); -} - -static void fd_handler (BDatagram *o, int events) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - - // clear handled events - o->wait_events &= ~events; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - - int have_send = 0; - int have_recv = 0; - - if ((events & BREACTOR_WRITE) || ((events & (BREACTOR_ERROR|BREACTOR_HUP)) && o->send.inited && o->send.busy && o->send.have_addrs)) { - ASSERT(o->send.inited) - ASSERT(o->send.busy) - ASSERT(o->send.have_addrs) - - have_send = 1; - } - - if ((events & BREACTOR_READ) || ((events & (BREACTOR_ERROR|BREACTOR_HUP)) && o->recv.inited && o->recv.busy && o->recv.started)) { - ASSERT(o->recv.inited) - ASSERT(o->recv.busy) - ASSERT(o->recv.started) - - have_recv = 1; - } - - if (have_send) { - if (have_recv) { - BPending_Set(&o->recv.job); - } - - do_send(o); - return; - } - - if (have_recv) { - do_recv(o); - return; - } - - BLog(BLOG_ERROR, "fd error event"); - report_error(o); - return; -} - -static void send_job_handler (BDatagram *o) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(o->send.inited) - ASSERT(o->send.busy) - ASSERT(o->send.have_addrs) - - do_send(o); - return; -} - -static void recv_job_handler (BDatagram *o) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(o->recv.inited) - ASSERT(o->recv.busy) - ASSERT(o->recv.started) - - do_recv(o); - return; -} - -static void send_if_handler_send (BDatagram *o, uint8_t *data, int data_len) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(o->send.inited) - ASSERT(!o->send.busy) - ASSERT(data_len >= 0) - ASSERT(data_len <= o->send.mtu) - - // remember data - o->send.busy_data = data; - o->send.busy_data_len = data_len; - - // set busy - o->send.busy = 1; - - // if have no addresses, wait - if (!o->send.have_addrs) { - return; - } - - // set job - BPending_Set(&o->send.job); -} - -static void recv_if_handler_recv (BDatagram *o, uint8_t *data) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(o->recv.inited) - ASSERT(!o->recv.busy) - - // remember data - o->recv.busy_data = data; - - // set busy - o->recv.busy = 1; - - // if recv not started yet, wait - if (!o->recv.started) { - return; - } - - // set job - BPending_Set(&o->recv.job); -} - -int BDatagram_AddressFamilySupported (int family) -{ - switch (family) { - case BADDR_TYPE_IPV4: - case BADDR_TYPE_IPV6: -#ifdef BADVPN_LINUX - case BADDR_TYPE_PACKET: -#endif - return 1; - } - - return 0; -} - -int BDatagram_Init (BDatagram *o, int family, BReactor *reactor, void *user, - BDatagram_handler handler) -{ - ASSERT(BDatagram_AddressFamilySupported(family)) - ASSERT(handler) - BNetwork_Assert(); - - // init arguments - o->reactor = reactor; - o->user = user; - o->handler = handler; - - // init fd - if ((o->fd = socket(family_socket_to_sys(family), SOCK_DGRAM, 0)) < 0) { - BLog(BLOG_ERROR, "socket failed"); - goto fail0; - } - - // set fd non-blocking - if (!badvpn_set_nonblocking(o->fd)) { - BLog(BLOG_ERROR, "badvpn_set_nonblocking failed"); - goto fail1; - } - - // enable receiving pktinfo - set_pktinfo(o->fd, family); - - // init BFileDescriptor - BFileDescriptor_Init(&o->bfd, o->fd, (BFileDescriptor_handler)fd_handler, o); - if (!BReactor_AddFileDescriptor(o->reactor, &o->bfd)) { - BLog(BLOG_ERROR, "BReactor_AddFileDescriptor failed"); - goto fail1; - } - - // set no wait events - o->wait_events = 0; - - // init limits - BReactorLimit_Init(&o->send.limit, o->reactor, BDATAGRAM_SEND_LIMIT); - BReactorLimit_Init(&o->recv.limit, o->reactor, BDATAGRAM_RECV_LIMIT); - - // set have no send and recv addresses - o->send.have_addrs = 0; - o->recv.have_addrs = 0; - - // set recv not started - o->recv.started = 0; - - // set send and recv not inited - o->send.inited = 0; - o->recv.inited = 0; - - DebugError_Init(&o->d_err, BReactor_PendingGroup(o->reactor)); - DebugObject_Init(&o->d_obj); - return 1; - -fail1: - if (close(o->fd) < 0) { - BLog(BLOG_ERROR, "close failed"); - } -fail0: - return 0; -} - -void BDatagram_Free (BDatagram *o) -{ - DebugObject_Free(&o->d_obj); - DebugError_Free(&o->d_err); - ASSERT(!o->recv.inited) - ASSERT(!o->send.inited) - - // free limits - BReactorLimit_Free(&o->recv.limit); - BReactorLimit_Free(&o->send.limit); - - // free BFileDescriptor - BReactor_RemoveFileDescriptor(o->reactor, &o->bfd); - - // free fd - if (close(o->fd) < 0) { - BLog(BLOG_ERROR, "close failed"); - } -} - -int BDatagram_Bind (BDatagram *o, BAddr addr) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(BDatagram_AddressFamilySupported(addr.type)) - - // translate address - struct sys_addr sysaddr; - addr_socket_to_sys(&sysaddr, addr); - - // bind - if (bind(o->fd, &sysaddr.addr.generic, sysaddr.len) < 0) { - BLog(BLOG_ERROR, "bind failed"); - return 0; - } - - // if recv wasn't started yet, start it - if (!o->recv.started) { - // set recv started - o->recv.started = 1; - - // continue receiving - if (o->recv.inited && o->recv.busy) { - BPending_Set(&o->recv.job); - } - } - - return 1; -} - -void BDatagram_SetSendAddrs (BDatagram *o, BAddr remote_addr, BIPAddr local_addr) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(BDatagram_AddressFamilySupported(remote_addr.type)) - ASSERT(local_addr.type == BADDR_TYPE_NONE || BDatagram_AddressFamilySupported(local_addr.type)) - - // set addresses - o->send.remote_addr = remote_addr; - o->send.local_addr = local_addr; - - if (!o->send.have_addrs) { - // set have addresses - o->send.have_addrs = 1; - - // start sending - if (o->send.inited && o->send.busy) { - BPending_Set(&o->send.job); - } - } -} - -int BDatagram_GetLastReceiveAddrs (BDatagram *o, BAddr *remote_addr, BIPAddr *local_addr) -{ - DebugObject_Access(&o->d_obj); - - if (!o->recv.have_addrs) { - return 0; - } - - *remote_addr = o->recv.remote_addr; - *local_addr = o->recv.local_addr; - return 1; -} - -int BDatagram_GetFd (BDatagram *o) -{ - DebugObject_Access(&o->d_obj); - - return o->fd; -} - -int BDatagram_SetReuseAddr (BDatagram *o, int reuse) -{ - DebugObject_Access(&o->d_obj); - ASSERT(reuse == 0 || reuse == 1) - - if (setsockopt(o->fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)) < 0) { - return 0; - } - - return 1; -} - -void BDatagram_SendAsync_Init (BDatagram *o, int mtu) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(!o->send.inited) - ASSERT(mtu >= 0) - - // init arguments - o->send.mtu = mtu; - - // init interface - PacketPassInterface_Init(&o->send.iface, o->send.mtu, (PacketPassInterface_handler_send)send_if_handler_send, o, BReactor_PendingGroup(o->reactor)); - - // init job - BPending_Init(&o->send.job, BReactor_PendingGroup(o->reactor), (BPending_handler)send_job_handler, o); - - // set not busy - o->send.busy = 0; - - // set inited - o->send.inited = 1; -} - -void BDatagram_SendAsync_Free (BDatagram *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->send.inited) - - // update events - o->wait_events &= ~BREACTOR_WRITE; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - - // free job - BPending_Free(&o->send.job); - - // free interface - PacketPassInterface_Free(&o->send.iface); - - // set not inited - o->send.inited = 0; -} - -PacketPassInterface * BDatagram_SendAsync_GetIf (BDatagram *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->send.inited) - - return &o->send.iface; -} - -void BDatagram_RecvAsync_Init (BDatagram *o, int mtu) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(!o->recv.inited) - ASSERT(mtu >= 0) - - // init arguments - o->recv.mtu = mtu; - - // init interface - PacketRecvInterface_Init(&o->recv.iface, o->recv.mtu, (PacketRecvInterface_handler_recv)recv_if_handler_recv, o, BReactor_PendingGroup(o->reactor)); - - // init job - BPending_Init(&o->recv.job, BReactor_PendingGroup(o->reactor), (BPending_handler)recv_job_handler, o); - - // set not busy - o->recv.busy = 0; - - // set inited - o->recv.inited = 1; -} - -void BDatagram_RecvAsync_Free (BDatagram *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->recv.inited) - - // update events - o->wait_events &= ~BREACTOR_READ; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->wait_events); - - // free job - BPending_Free(&o->recv.job); - - // free interface - PacketRecvInterface_Free(&o->recv.iface); - - // set not inited - o->recv.inited = 0; -} - -PacketRecvInterface * BDatagram_RecvAsync_GetIf (BDatagram *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->recv.inited) - - return &o->recv.iface; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BDatagram_unix.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BDatagram_unix.h deleted file mode 100644 index ffc5a529..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BDatagram_unix.h +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @file BDatagram_unix.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "misc/debugerror.h" -#include "base/DebugObject.h" - -#define BDATAGRAM_SEND_LIMIT 2 -#define BDATAGRAM_RECV_LIMIT 2 - -struct BDatagram_s { - BReactor *reactor; - void *user; - BDatagram_handler handler; - int fd; - BFileDescriptor bfd; - int wait_events; - struct { - BReactorLimit limit; - int have_addrs; - BAddr remote_addr; - BIPAddr local_addr; - int inited; - int mtu; - PacketPassInterface iface; - BPending job; - int busy; - const uint8_t *busy_data; - int busy_data_len; - } send; - struct { - BReactorLimit limit; - int started; - int have_addrs; - BAddr remote_addr; - BIPAddr local_addr; - int inited; - int mtu; - PacketRecvInterface iface; - BPending job; - int busy; - uint8_t *busy_data; - } recv; - DebugError d_err; - DebugObject d_obj; -}; diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BNetwork.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BNetwork.c deleted file mode 100644 index 82fb266b..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BNetwork.c +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @file BNetwork.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifdef BADVPN_USE_WINAPI -#include -#include -#include -#else -#include -#include -#endif - -#include "misc/debug.h" -#include "base/BLog.h" - -#include "system/BNetwork.h" - -#include "generated/blog_channel_BNetwork.h" - -extern int bnetwork_initialized; - -#ifndef BADVPN_PLUGIN -int bnetwork_initialized = 0; -#endif - -int BNetwork_GlobalInit (void) -{ - ASSERT(!bnetwork_initialized) - -#ifdef BADVPN_USE_WINAPI - - WORD requested = MAKEWORD(2, 2); - WSADATA wsadata; - if (WSAStartup(requested, &wsadata) != 0) { - BLog(BLOG_ERROR, "WSAStartup failed"); - goto fail0; - } - if (wsadata.wVersion != requested) { - BLog(BLOG_ERROR, "WSAStartup returned wrong version"); - goto fail1; - } - -#else - - struct sigaction act; - memset(&act, 0, sizeof(act)); - act.sa_handler = SIG_IGN; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - if (sigaction(SIGPIPE, &act, NULL) < 0) { - BLog(BLOG_ERROR, "sigaction failed"); - goto fail0; - } - -#endif - - bnetwork_initialized = 1; - - return 1; - -#ifdef BADVPN_USE_WINAPI -fail1: - WSACleanup(); -#endif - -fail0: - return 0; -} - -void BNetwork_Assert (void) -{ - ASSERT(bnetwork_initialized) -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BNetwork.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BNetwork.h deleted file mode 100644 index 0db1744c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BNetwork.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @file BNetwork.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_SYSTEM_BNETWORK_H -#define BADVPN_SYSTEM_BNETWORK_H - -int BNetwork_GlobalInit (void); -void BNetwork_Assert (void); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor.h deleted file mode 100644 index 4c0fa5be..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor.h +++ /dev/null @@ -1,11 +0,0 @@ -#if defined(BADVPN_BREACTOR_BADVPN) + defined(BADVPN_BREACTOR_GLIB) + defined(BADVPN_BREACTOR_EMSCRIPTEN) != 1 -#error No reactor backend or too many reactor backens -#endif - -#if defined(BADVPN_BREACTOR_BADVPN) -#include "BReactor_badvpn.h" -#elif defined(BADVPN_BREACTOR_GLIB) -#include "BReactor_glib.h" -#elif defined(BADVPN_BREACTOR_EMSCRIPTEN) -#include "BReactor_emscripten.h" -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor_badvpn.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor_badvpn.c deleted file mode 100644 index 29e96ebd..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor_badvpn.c +++ /dev/null @@ -1,1430 +0,0 @@ -/** - * @file BReactor_badvpn.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#ifdef BADVPN_USE_WINAPI -#include -#else -#include -#include -#include -#include -#endif - -#include "misc/debug.h" -#include "misc/offset.h" -#include "misc/balloc.h" -#include "misc/compare.h" -#include "base/BLog.h" - -#include "system/BReactor.h" - -#include "generated/blog_channel_BReactor.h" - -#define KEVENT_TAG_FD 1 -#define KEVENT_TAG_KEVENT 2 - -#define TIMER_STATE_INACTIVE 1 -#define TIMER_STATE_RUNNING 2 -#define TIMER_STATE_EXPIRED 3 - -static int compare_timers (BSmallTimer *t1, BSmallTimer *t2) -{ - int cmp = B_COMPARE(t1->absTime, t2->absTime); - if (cmp) { - return cmp; - } - - return B_COMPARE((uintptr_t)t1, (uintptr_t)t2); -} - -#include "BReactor_badvpn_timerstree.h" -#include "structure/CAvl_impl.h" - -static void assert_timer (BSmallTimer *bt) -{ - ASSERT(bt->state == TIMER_STATE_INACTIVE || bt->state == TIMER_STATE_RUNNING || - bt->state == TIMER_STATE_EXPIRED) -} - -static int move_expired_timers (BReactor *bsys, btime_t now) -{ - int moved = 0; - - // move timed out timers to the expired list - BReactor__TimersTreeRef ref; - BSmallTimer *timer; - while (timer = (ref = BReactor__TimersTree_GetFirst(&bsys->timers_tree, 0)).link) { - ASSERT(timer->state == TIMER_STATE_RUNNING) - - // if it's in the future, stop - if (timer->absTime > now) { - break; - } - moved = 1; - - // remove from running timers tree - BReactor__TimersTree_Remove(&bsys->timers_tree, 0, ref); - - // add to expired timers list - LinkedList1_Append(&bsys->timers_expired_list, &timer->u.list_node); - - // set expired - timer->state = TIMER_STATE_EXPIRED; - } - - return moved; -} - -static void move_first_timers (BReactor *bsys) -{ - BReactor__TimersTreeRef ref; - - // get the time of the first timer - BSmallTimer *first_timer = (ref = BReactor__TimersTree_GetFirst(&bsys->timers_tree, 0)).link; - ASSERT(first_timer) - ASSERT(first_timer->state == TIMER_STATE_RUNNING) - btime_t first_time = first_timer->absTime; - - // remove from running timers tree - BReactor__TimersTree_Remove(&bsys->timers_tree, 0, ref); - - // add to expired timers list - LinkedList1_Append(&bsys->timers_expired_list, &first_timer->u.list_node); - - // set expired - first_timer->state = TIMER_STATE_EXPIRED; - - // also move other timers with the same timeout - BSmallTimer *timer; - while (timer = (ref = BReactor__TimersTree_GetFirst(&bsys->timers_tree, 0)).link) { - ASSERT(timer->state == TIMER_STATE_RUNNING) - ASSERT(timer->absTime >= first_time) - - // if it's in the future, stop - if (timer->absTime > first_time) { - break; - } - - // remove from running timers tree - BReactor__TimersTree_Remove(&bsys->timers_tree, 0, ref); - - // add to expired timers list - LinkedList1_Append(&bsys->timers_expired_list, &timer->u.list_node); - - // set expired - timer->state = TIMER_STATE_EXPIRED; - } -} - -#ifdef BADVPN_USE_WINAPI - -static void set_iocp_ready (BReactorIOCPOverlapped *olap, int succeeded, DWORD bytes) -{ - BReactor *reactor = olap->reactor; - ASSERT(!olap->is_ready) - - // set parameters - olap->ready_succeeded = succeeded; - olap->ready_bytes = bytes; - - // insert to IOCP ready list - LinkedList1_Append(&reactor->iocp_ready_list, &olap->ready_list_node); - - // set ready - olap->is_ready = 1; -} - -#endif - -#ifdef BADVPN_USE_EPOLL - -static void set_epoll_fd_pointers (BReactor *bsys) -{ - // Write pointers to our entry pointers into file descriptors. - // If a handler function frees some other file descriptor, the - // free routine will set our pointer to NULL so we don't dispatch it. - for (int i = 0; i < bsys->epoll_results_num; i++) { - struct epoll_event *event = &bsys->epoll_results[i]; - ASSERT(event->data.ptr) - BFileDescriptor *bfd = (BFileDescriptor *)event->data.ptr; - ASSERT(bfd->active) - ASSERT(!bfd->epoll_returned_ptr) - bfd->epoll_returned_ptr = (BFileDescriptor **)&event->data.ptr; - } -} - -#endif - -#ifdef BADVPN_USE_KEVENT - -static void set_kevent_fd_pointers (BReactor *bsys) -{ - for (int i = 0; i < bsys->kevent_results_num; i++) { - struct kevent *event = &bsys->kevent_results[i]; - ASSERT(event->udata) - int *tag = event->udata; - switch (*tag) { - case KEVENT_TAG_FD: { - BFileDescriptor *bfd = UPPER_OBJECT(tag, BFileDescriptor, kevent_tag); - ASSERT(bfd->active) - ASSERT(!bfd->kevent_returned_ptr) - bfd->kevent_returned_ptr = (int **)&event->udata; - } break; - - case KEVENT_TAG_KEVENT: { - BReactorKEvent *kev = UPPER_OBJECT(tag, BReactorKEvent, kevent_tag); - ASSERT(kev->reactor == bsys) - ASSERT(!kev->kevent_returned_ptr) - kev->kevent_returned_ptr = (int **)&event->udata; - } break; - - default: - ASSERT(0); - } - } -} - -static void update_kevent_fd_events (BReactor *bsys, BFileDescriptor *bs, int events) -{ - struct kevent event; - - if (!(bs->waitEvents & BREACTOR_READ) && (events & BREACTOR_READ)) { - memset(&event, 0, sizeof(event)); - event.ident = bs->fd; - event.filter = EVFILT_READ; - event.flags = EV_ADD; - event.udata = &bs->kevent_tag; - ASSERT_FORCE(kevent(bsys->kqueue_fd, &event, 1, NULL, 0, NULL) == 0) - } - else if ((bs->waitEvents & BREACTOR_READ) && !(events & BREACTOR_READ)) { - memset(&event, 0, sizeof(event)); - event.ident = bs->fd; - event.filter = EVFILT_READ; - event.flags = EV_DELETE; - ASSERT_FORCE(kevent(bsys->kqueue_fd, &event, 1, NULL, 0, NULL) == 0) - } - - if (!(bs->waitEvents & BREACTOR_WRITE) && (events & BREACTOR_WRITE)) { - memset(&event, 0, sizeof(event)); - event.ident = bs->fd; - event.filter = EVFILT_WRITE; - event.flags = EV_ADD; - event.udata = &bs->kevent_tag; - ASSERT_FORCE(kevent(bsys->kqueue_fd, &event, 1, NULL, 0, NULL) == 0) - } - else if ((bs->waitEvents & BREACTOR_WRITE) && !(events & BREACTOR_WRITE)) { - memset(&event, 0, sizeof(event)); - event.ident = bs->fd; - event.filter = EVFILT_WRITE; - event.flags = EV_DELETE; - ASSERT_FORCE(kevent(bsys->kqueue_fd, &event, 1, NULL, 0, NULL) == 0) - } -} - -#endif - -#ifdef BADVPN_USE_POLL - -static void set_poll_fd_pointers (BReactor *bsys) -{ - for (int i = 0; i < bsys->poll_results_num; i++) { - BFileDescriptor *bfd = bsys->poll_results_bfds[i]; - ASSERT(bfd) - ASSERT(bfd->active) - ASSERT(bfd->poll_returned_index == -1) - bfd->poll_returned_index = i; - } -} - -#endif - -static void wait_for_events (BReactor *bsys) -{ - // must have processed all pending events - ASSERT(!BPendingGroup_HasJobs(&bsys->pending_jobs)) - ASSERT(LinkedList1_IsEmpty(&bsys->timers_expired_list)) - #ifdef BADVPN_USE_WINAPI - ASSERT(LinkedList1_IsEmpty(&bsys->iocp_ready_list)) - #endif - #ifdef BADVPN_USE_EPOLL - ASSERT(bsys->epoll_results_pos == bsys->epoll_results_num) - #endif - #ifdef BADVPN_USE_KEVENT - ASSERT(bsys->kevent_results_pos == bsys->kevent_results_num) - #endif - #ifdef BADVPN_USE_POLL - ASSERT(bsys->poll_results_pos == bsys->poll_results_num) - #endif - - // clean up epoll results - #ifdef BADVPN_USE_EPOLL - bsys->epoll_results_num = 0; - bsys->epoll_results_pos = 0; - #endif - - // clean up kevent results - #ifdef BADVPN_USE_KEVENT - bsys->kevent_results_num = 0; - bsys->kevent_results_pos = 0; - #endif - - // clean up poll results - #ifdef BADVPN_USE_POLL - bsys->poll_results_num = 0; - bsys->poll_results_pos = 0; - #endif - - // timeout vars - int have_timeout = 0; - btime_t timeout_abs; - btime_t now = 0; // to remove warning - - // compute timeout - BSmallTimer *first_timer = BReactor__TimersTree_GetFirst(&bsys->timers_tree, 0).link; - if (first_timer) { - ASSERT(first_timer->state == TIMER_STATE_RUNNING) - - // get current time - now = btime_gettime(); - - // if some timers have already timed out, return them immediately - if (move_expired_timers(bsys, now)) { - BLog(BLOG_DEBUG, "Got already expired timers"); - return; - } - - // timeout is first timer, remember absolute time - have_timeout = 1; - timeout_abs = first_timer->absTime; - } - - // wait until the timeout is reached or the file descriptor / handle in ready - while (1) { - // compute timeout - btime_t timeout_rel = 0; // to remove warning - btime_t timeout_rel_trunc = 0; // to remove warning - if (have_timeout) { - timeout_rel = timeout_abs - now; - timeout_rel_trunc = timeout_rel; - } - - // perform wait - - #ifdef BADVPN_USE_WINAPI - - if (have_timeout) { - if (timeout_rel_trunc > INFINITE - 1) { - timeout_rel_trunc = INFINITE - 1; - } - } - - DWORD bytes = 0; - ULONG_PTR key; - BReactorIOCPOverlapped *olap = NULL; - BOOL res = GetQueuedCompletionStatus(bsys->iocp_handle, &bytes, &key, (OVERLAPPED **)&olap, (have_timeout ? timeout_rel_trunc : INFINITE)); - - ASSERT_FORCE(olap || have_timeout) - - if (olap || timeout_rel_trunc == timeout_rel) { - if (olap) { - BLog(BLOG_DEBUG, "GetQueuedCompletionStatus returned event"); - - DebugObject_Access(&olap->d_obj); - ASSERT(olap->reactor == bsys) - ASSERT(!olap->is_ready) - - set_iocp_ready(olap, (res == TRUE), bytes); - } else { - BLog(BLOG_DEBUG, "GetQueuedCompletionStatus timed out"); - move_first_timers(bsys); - } - break; - } - - #endif - - #ifdef BADVPN_USE_EPOLL - - if (have_timeout) { - if (timeout_rel_trunc > INT_MAX) { - timeout_rel_trunc = INT_MAX; - } - } - - BLog(BLOG_DEBUG, "Calling epoll_wait"); - - int waitres = epoll_wait(bsys->efd, bsys->epoll_results, BSYSTEM_MAX_RESULTS, (have_timeout ? timeout_rel_trunc : -1)); - if (waitres < 0) { - int error = errno; - if (error == EINTR) { - BLog(BLOG_DEBUG, "epoll_wait interrupted"); - goto try_again; - } - perror("epoll_wait"); - ASSERT_FORCE(0) - } - - ASSERT_FORCE(!(waitres == 0) || have_timeout) - ASSERT_FORCE(waitres <= BSYSTEM_MAX_RESULTS) - - if (waitres != 0 || timeout_rel_trunc == timeout_rel) { - if (waitres != 0) { - BLog(BLOG_DEBUG, "epoll_wait returned %d file descriptors", waitres); - bsys->epoll_results_num = waitres; - set_epoll_fd_pointers(bsys); - } else { - BLog(BLOG_DEBUG, "epoll_wait timed out"); - move_first_timers(bsys); - } - break; - } - - #endif - - #ifdef BADVPN_USE_KEVENT - - struct timespec ts; - if (have_timeout) { - if (timeout_rel_trunc > 86400000) { - timeout_rel_trunc = 86400000; - } - ts.tv_sec = timeout_rel_trunc / 1000; - ts.tv_nsec = (timeout_rel_trunc % 1000) * 1000000; - } - -// BLog(BLOG_DEBUG, "Calling kevent"); - - int waitres = kevent(bsys->kqueue_fd, NULL, 0, bsys->kevent_results, BSYSTEM_MAX_RESULTS, (have_timeout ? &ts : NULL)); - if (waitres < 0) { - int error = errno; - if (error == EINTR) { - BLog(BLOG_DEBUG, "kevent interrupted"); - goto try_again; - } - perror("kevent"); - ASSERT_FORCE(0) - } - - ASSERT_FORCE(!(waitres == 0) || have_timeout) - ASSERT_FORCE(waitres <= BSYSTEM_MAX_RESULTS) - - if (waitres != 0 || timeout_rel_trunc == timeout_rel) { - if (waitres != 0) { -// BLog(BLOG_DEBUG, "kevent returned %d events", waitres); - bsys->kevent_results_num = waitres; - set_kevent_fd_pointers(bsys); - } else { -// BLog(BLOG_DEBUG, "kevent timed out"); - move_first_timers(bsys); - } - break; - } - - #endif - - #ifdef BADVPN_USE_POLL - - if (have_timeout) { - if (timeout_rel_trunc > INT_MAX) { - timeout_rel_trunc = INT_MAX; - } - } - - ASSERT(bsys->poll_num_enabled_fds >= 0) - ASSERT(bsys->poll_num_enabled_fds <= BSYSTEM_MAX_POLL_FDS) - int num_fds = 0; - - LinkedList1Node *list_node = LinkedList1_GetFirst(&bsys->poll_enabled_fds_list); - while (list_node) { - BFileDescriptor *bfd = UPPER_OBJECT(list_node, BFileDescriptor, poll_enabled_fds_list_node); - ASSERT(bfd->active) - ASSERT(bfd->poll_returned_index == -1) - - // calculate poll events - int pevents = 0; - if ((bfd->waitEvents & BREACTOR_READ)) { - pevents |= POLLIN; - } - if ((bfd->waitEvents & BREACTOR_WRITE)) { - pevents |= POLLOUT; - } - - // write pollfd entry - struct pollfd *pfd = &bsys->poll_results_pollfds[num_fds]; - pfd->fd = bfd->fd; - pfd->events = pevents; - pfd->revents = 0; - - // write BFileDescriptor reference entry - bsys->poll_results_bfds[num_fds] = bfd; - - // increment number of fds in array - num_fds++; - - list_node = LinkedList1Node_Next(list_node); - } - - BLog(BLOG_DEBUG, "Calling poll"); - - int waitres = poll(bsys->poll_results_pollfds, num_fds, (have_timeout ? timeout_rel_trunc : -1)); - if (waitres < 0) { - int error = errno; - if (error == EINTR) { - BLog(BLOG_DEBUG, "poll interrupted"); - goto try_again; - } - perror("poll"); - ASSERT_FORCE(0) - } - - ASSERT_FORCE(!(waitres == 0) || have_timeout) - - if (waitres != 0 || timeout_rel_trunc == timeout_rel) { - if (waitres != 0) { - BLog(BLOG_DEBUG, "poll returned %d file descriptors", waitres); - bsys->poll_results_num = num_fds; - bsys->poll_results_pos = 0; - set_poll_fd_pointers(bsys); - } else { - BLog(BLOG_DEBUG, "poll timed out"); - move_first_timers(bsys); - } - break; - } - - #endif - - try_again: - if (have_timeout) { - // get current time - now = btime_gettime(); - // check if we already reached the time we're waiting for - if (now >= timeout_abs) { - BLog(BLOG_DEBUG, "already timed out while trying again"); - move_first_timers(bsys); - break; - } - } - } - - // reset limit objects - LinkedList1Node *list_node; - while (list_node = LinkedList1_GetFirst(&bsys->active_limits_list)) { - BReactorLimit *limit = UPPER_OBJECT(list_node, BReactorLimit, active_limits_list_node); - ASSERT(limit->count > 0) - limit->count = 0; - LinkedList1_Remove(&bsys->active_limits_list, &limit->active_limits_list_node); - } -} - -#ifndef BADVPN_USE_WINAPI - -void BFileDescriptor_Init (BFileDescriptor *bs, int fd, BFileDescriptor_handler handler, void *user) -{ - bs->fd = fd; - bs->handler = handler; - bs->user = user; - bs->active = 0; -} - -#endif - -void BSmallTimer_Init (BSmallTimer *bt, BSmallTimer_handler handler) -{ - bt->handler.smalll = handler; - bt->state = TIMER_STATE_INACTIVE; - bt->is_small = 1; -} - -int BSmallTimer_IsRunning (BSmallTimer *bt) -{ - assert_timer(bt); - - return (bt->state != TIMER_STATE_INACTIVE); -} - -void BTimer_Init (BTimer *bt, btime_t msTime, BTimer_handler handler, void *user) -{ - bt->base.handler.heavy = handler; - bt->base.state = TIMER_STATE_INACTIVE; - bt->base.is_small = 0; - bt->user = user; - bt->msTime = msTime; -} - -int BTimer_IsRunning (BTimer *bt) -{ - return BSmallTimer_IsRunning(&bt->base); -} - -int BReactor_Init (BReactor *bsys) -{ - BLog(BLOG_DEBUG, "Reactor initializing"); - - // set not exiting - bsys->exiting = 0; - - // init jobs - BPendingGroup_Init(&bsys->pending_jobs); - - // init timers - BReactor__TimersTree_Init(&bsys->timers_tree); - LinkedList1_Init(&bsys->timers_expired_list); - - // init limits - LinkedList1_Init(&bsys->active_limits_list); - - #ifdef BADVPN_USE_WINAPI - - // init IOCP list - LinkedList1_Init(&bsys->iocp_list); - - // init IOCP handle - if (!(bsys->iocp_handle = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1))) { - BLog(BLOG_ERROR, "CreateIoCompletionPort failed"); - goto fail0; - } - - // init IOCP ready list - LinkedList1_Init(&bsys->iocp_ready_list); - - #endif - - #ifdef BADVPN_USE_EPOLL - - // create epoll fd - if ((bsys->efd = epoll_create(10)) < 0) { - BLog(BLOG_ERROR, "epoll_create failed"); - goto fail0; - } - - // init results array - bsys->epoll_results_num = 0; - bsys->epoll_results_pos = 0; - - #endif - - #ifdef BADVPN_USE_KEVENT - - // create kqueue fd - if ((bsys->kqueue_fd = kqueue()) < 0) { - BLog(BLOG_ERROR, "kqueue failed"); - goto fail0; - } - - // init results array - bsys->kevent_results_num = 0; - bsys->kevent_results_pos = 0; - - #endif - - #ifdef BADVPN_USE_POLL - - // init enabled fds list - LinkedList1_Init(&bsys->poll_enabled_fds_list); - - // set zero enabled fds - bsys->poll_num_enabled_fds = 0; - - // allocate results arrays - if (!(bsys->poll_results_pollfds = BAllocArray(BSYSTEM_MAX_POLL_FDS, sizeof(bsys->poll_results_pollfds[0])))) { - BLog(BLOG_ERROR, "BAllocArray failed"); - goto fail0; - } - if (!(bsys->poll_results_bfds = BAllocArray(BSYSTEM_MAX_POLL_FDS, sizeof(bsys->poll_results_bfds[0])))) { - BLog(BLOG_ERROR, "BAllocArray failed"); - goto fail1; - } - - // init results array - bsys->poll_results_num = 0; - bsys->poll_results_pos = 0; - - #endif - - DebugObject_Init(&bsys->d_obj); - #ifndef BADVPN_USE_WINAPI - DebugCounter_Init(&bsys->d_fds_counter); - #endif - #ifdef BADVPN_USE_KEVENT - DebugCounter_Init(&bsys->d_kevent_ctr); - #endif - DebugCounter_Init(&bsys->d_limits_ctr); - - return 1; - - #ifdef BADVPN_USE_POLL -fail1: - BFree(bsys->poll_results_pollfds); - #endif -fail0: - BPendingGroup_Free(&bsys->pending_jobs); - BLog(BLOG_ERROR, "Reactor failed to initialize"); - return 0; -} - -void BReactor_Free (BReactor *bsys) -{ - DebugObject_Access(&bsys->d_obj); - - #ifdef BADVPN_USE_WINAPI - while (!LinkedList1_IsEmpty(&bsys->iocp_list)) { - BReactorIOCPOverlapped *olap = UPPER_OBJECT(LinkedList1_GetLast(&bsys->iocp_list), BReactorIOCPOverlapped, iocp_list_node); - ASSERT(olap->reactor == bsys) - olap->handler(olap->user, BREACTOR_IOCP_EVENT_EXITING, 0); - } - #endif - - // {pending group has no BPending objects} - ASSERT(!BPendingGroup_HasJobs(&bsys->pending_jobs)) - ASSERT(BReactor__TimersTree_IsEmpty(&bsys->timers_tree)) - ASSERT(LinkedList1_IsEmpty(&bsys->timers_expired_list)) - ASSERT(LinkedList1_IsEmpty(&bsys->active_limits_list)) - DebugObject_Free(&bsys->d_obj); - #ifdef BADVPN_USE_WINAPI - ASSERT(LinkedList1_IsEmpty(&bsys->iocp_ready_list)) - ASSERT(LinkedList1_IsEmpty(&bsys->iocp_list)) - #endif - #ifndef BADVPN_USE_WINAPI - DebugCounter_Free(&bsys->d_fds_counter); - #endif - #ifdef BADVPN_USE_KEVENT - DebugCounter_Free(&bsys->d_kevent_ctr); - #endif - DebugCounter_Free(&bsys->d_limits_ctr); - #ifdef BADVPN_USE_POLL - ASSERT(bsys->poll_num_enabled_fds == 0) - ASSERT(LinkedList1_IsEmpty(&bsys->poll_enabled_fds_list)) - #endif - - BLog(BLOG_DEBUG, "Reactor freeing"); - - #ifdef BADVPN_USE_WINAPI - - // close IOCP handle - ASSERT_FORCE(CloseHandle(bsys->iocp_handle)) - - #endif - - #ifdef BADVPN_USE_EPOLL - - // close epoll fd - ASSERT_FORCE(close(bsys->efd) == 0) - - #endif - - #ifdef BADVPN_USE_KEVENT - - // close kqueue fd - ASSERT_FORCE(close(bsys->kqueue_fd) == 0) - - #endif - - #ifdef BADVPN_USE_POLL - - // free results arrays - BFree(bsys->poll_results_bfds); - BFree(bsys->poll_results_pollfds); - - #endif - - // free jobs - BPendingGroup_Free(&bsys->pending_jobs); -} - -int BReactor_Exec (BReactor *bsys) -{ - BLog(BLOG_DEBUG, "Entering event loop"); - - while (!bsys->exiting) { - // dispatch job - if (BPendingGroup_HasJobs(&bsys->pending_jobs)) { - BPendingGroup_ExecuteJob(&bsys->pending_jobs); - continue; - } - - // dispatch timer - LinkedList1Node *list_node = LinkedList1_GetFirst(&bsys->timers_expired_list); - if (list_node) { - BSmallTimer *timer = UPPER_OBJECT(list_node, BSmallTimer, u.list_node); - ASSERT(timer->state == TIMER_STATE_EXPIRED) - - // remove from expired list - LinkedList1_Remove(&bsys->timers_expired_list, &timer->u.list_node); - - // set inactive - timer->state = TIMER_STATE_INACTIVE; - - // call handler -// BLog(BLOG_DEBUG, "Dispatching timer"); - if (timer->is_small) { - timer->handler.smalll(timer); - } else { - BTimer *btimer = UPPER_OBJECT(timer, BTimer, base); - timer->handler.heavy(btimer->user); - } - continue; - } - - #ifdef BADVPN_USE_WINAPI - - if (!LinkedList1_IsEmpty(&bsys->iocp_ready_list)) { - BReactorIOCPOverlapped *olap = UPPER_OBJECT(LinkedList1_GetFirst(&bsys->iocp_ready_list), BReactorIOCPOverlapped, ready_list_node); - ASSERT(olap->is_ready) - ASSERT(olap->handler) - - // remove from ready list - LinkedList1_Remove(&bsys->iocp_ready_list, &olap->ready_list_node); - - // set not ready - olap->is_ready = 0; - - int event = (olap->ready_succeeded ? BREACTOR_IOCP_EVENT_SUCCEEDED : BREACTOR_IOCP_EVENT_FAILED); - - // call handler - olap->handler(olap->user, event, olap->ready_bytes); - continue; - } - - #endif - - #ifdef BADVPN_USE_EPOLL - - // dispatch file descriptor - if (bsys->epoll_results_pos < bsys->epoll_results_num) { - // grab event - struct epoll_event *event = &bsys->epoll_results[bsys->epoll_results_pos]; - bsys->epoll_results_pos++; - - // check if the BFileDescriptor was removed - if (!event->data.ptr) { - continue; - } - - // get BFileDescriptor - BFileDescriptor *bfd = (BFileDescriptor *)event->data.ptr; - ASSERT(bfd->active) - ASSERT(bfd->epoll_returned_ptr == (BFileDescriptor **)&event->data.ptr) - - // zero pointer to the epoll entry - bfd->epoll_returned_ptr = NULL; - - // calculate events to report - int events = 0; - if ((bfd->waitEvents&BREACTOR_READ) && (event->events&EPOLLIN)) { - events |= BREACTOR_READ; - } - if ((bfd->waitEvents&BREACTOR_WRITE) && (event->events&EPOLLOUT)) { - events |= BREACTOR_WRITE; - } - if ((event->events&EPOLLERR)) { - events |= BREACTOR_ERROR; - } - if ((event->events&EPOLLHUP)) { - events |= BREACTOR_HUP; - } - - if (!events) { - BLog(BLOG_ERROR, "no events detected?"); - continue; - } - - // call handler - BLog(BLOG_DEBUG, "Dispatching file descriptor"); - bfd->handler(bfd->user, events); - continue; - } - - #endif - - #ifdef BADVPN_USE_KEVENT - - // dispatch kevent - if (bsys->kevent_results_pos < bsys->kevent_results_num) { - // grab event - struct kevent *event = &bsys->kevent_results[bsys->kevent_results_pos]; - bsys->kevent_results_pos++; - - // check if the event was removed - if (!event->udata) { - continue; - } - - // check tag - int *tag = event->udata; - switch (*tag) { - case KEVENT_TAG_FD: { - // get BFileDescriptor - BFileDescriptor *bfd = UPPER_OBJECT(tag, BFileDescriptor, kevent_tag); - ASSERT(bfd->active) - ASSERT(bfd->kevent_returned_ptr == (int **)&event->udata) - - // zero pointer to the kevent entry - bfd->kevent_returned_ptr = NULL; - - // calculate event to report - int events = 0; - if ((bfd->waitEvents&BREACTOR_READ) && event->filter == EVFILT_READ) { - events |= BREACTOR_READ; - } - if ((bfd->waitEvents&BREACTOR_WRITE) && event->filter == EVFILT_WRITE) { - events |= BREACTOR_WRITE; - } - - if (!events) { - BLog(BLOG_ERROR, "no events detected?"); - continue; - } - - // call handler -// BLog(BLOG_DEBUG, "Dispatching file descriptor"); - bfd->handler(bfd->user, events); - continue; - } break; - - case KEVENT_TAG_KEVENT: { - // get BReactorKEvent - BReactorKEvent *kev = UPPER_OBJECT(tag, BReactorKEvent, kevent_tag); - ASSERT(kev->reactor == bsys) - ASSERT(kev->kevent_returned_ptr == (int **)&event->udata) - - // zero pointer to the kevent entry - kev->kevent_returned_ptr = NULL; - - // call handler -// BLog(BLOG_DEBUG, "Dispatching kevent"); - kev->handler(kev->user, event->fflags, event->data); - continue; - } break; - - default: - ASSERT(0); - } - } - - #endif - - #ifdef BADVPN_USE_POLL - - if (bsys->poll_results_pos < bsys->poll_results_num) { - // grab event - struct pollfd *pfd = &bsys->poll_results_pollfds[bsys->poll_results_pos]; - BFileDescriptor *bfd = bsys->poll_results_bfds[bsys->poll_results_pos]; - bsys->poll_results_pos++; - - // skip removed entry - if (!bfd) { - continue; - } - - ASSERT(bfd->active) - ASSERT(bfd->poll_returned_index == bsys->poll_results_pos - 1) - - // remove result reference - bfd->poll_returned_index = -1; - - // calculate events to report - int events = 0; - if ((bfd->waitEvents & BREACTOR_READ) && (pfd->revents & POLLIN)) { - events |= BREACTOR_READ; - } - if ((bfd->waitEvents & BREACTOR_WRITE) && (pfd->revents & POLLOUT)) { - events |= BREACTOR_WRITE; - } - if ((pfd->revents & POLLERR) || (pfd->revents & POLLHUP)) { - events |= BREACTOR_ERROR; - } - - if (!events) { - continue; - } - - // call handler - BLog(BLOG_DEBUG, "Dispatching file descriptor"); - bfd->handler(bfd->user, events); - continue; - } - - #endif - - wait_for_events(bsys); - } - - BLog(BLOG_DEBUG, "Exiting event loop, exit code %d", bsys->exit_code); - - return bsys->exit_code; -} - -void BReactor_Quit (BReactor *bsys, int code) -{ - bsys->exiting = 1; - bsys->exit_code = code; -} - -void BReactor_SetSmallTimer (BReactor *bsys, BSmallTimer *bt, int mode, btime_t time) -{ - assert_timer(bt); - ASSERT(mode == BTIMER_SET_ABSOLUTE || mode == BTIMER_SET_RELATIVE) - - // unlink it if it's already in the list - BReactor_RemoveSmallTimer(bsys, bt); - - // if mode is relative, add current time - if (mode == BTIMER_SET_RELATIVE) { - time = btime_add(btime_gettime(), time); - } - - // set time - bt->absTime = time; - - // set running - bt->state = TIMER_STATE_RUNNING; - - // insert to running timers tree - BReactor__TimersTreeRef ref = {bt, bt}; - int res = BReactor__TimersTree_Insert(&bsys->timers_tree, 0, ref, NULL); - ASSERT_EXECUTE(res) -} - -void BReactor_RemoveSmallTimer (BReactor *bsys, BSmallTimer *bt) -{ - assert_timer(bt); - - if (bt->state == TIMER_STATE_INACTIVE) { - return; - } - - if (bt->state == TIMER_STATE_EXPIRED) { - // remove from expired list - LinkedList1_Remove(&bsys->timers_expired_list, &bt->u.list_node); - } else { - // remove from running tree - BReactor__TimersTreeRef ref = {bt, bt}; - BReactor__TimersTree_Remove(&bsys->timers_tree, 0, ref); - } - - // set inactive - bt->state = TIMER_STATE_INACTIVE; -} - -void BReactor_SetTimer (BReactor *bsys, BTimer *bt) -{ - BReactor_SetSmallTimer(bsys, &bt->base, BTIMER_SET_RELATIVE, bt->msTime); -} - -void BReactor_SetTimerAfter (BReactor *bsys, BTimer *bt, btime_t after) -{ - BReactor_SetSmallTimer(bsys, &bt->base, BTIMER_SET_RELATIVE, after); -} - -void BReactor_SetTimerAbsolute (BReactor *bsys, BTimer *bt, btime_t time) -{ - BReactor_SetSmallTimer(bsys, &bt->base, BTIMER_SET_ABSOLUTE, time); -} - -void BReactor_RemoveTimer (BReactor *bsys, BTimer *bt) -{ - return BReactor_RemoveSmallTimer(bsys, &bt->base); -} - -BPendingGroup * BReactor_PendingGroup (BReactor *bsys) -{ - return &bsys->pending_jobs; -} - -int BReactor_Synchronize (BReactor *bsys, BSmallPending *ref) -{ - ASSERT(ref) - - while (!bsys->exiting) { - ASSERT(BPendingGroup_HasJobs(&bsys->pending_jobs)) - - if (BPendingGroup_PeekJob(&bsys->pending_jobs) == ref) { - return 1; - } - - BPendingGroup_ExecuteJob(&bsys->pending_jobs); - } - - return 0; -} - -#ifndef BADVPN_USE_WINAPI - -int BReactor_AddFileDescriptor (BReactor *bsys, BFileDescriptor *bs) -{ - ASSERT(!bs->active) - - #ifdef BADVPN_USE_EPOLL - - // add epoll entry - struct epoll_event event; - memset(&event, 0, sizeof(event)); - event.events = 0; - event.data.ptr = bs; - if (epoll_ctl(bsys->efd, EPOLL_CTL_ADD, bs->fd, &event) < 0) { - int error = errno; - BLog(BLOG_ERROR, "epoll_ctl failed: %d", error); - return 0; - } - - // set epoll returned pointer - bs->epoll_returned_ptr = NULL; - - #endif - - #ifdef BADVPN_USE_KEVENT - - // set kevent tag - bs->kevent_tag = KEVENT_TAG_FD; - - // set kevent returned pointer - bs->kevent_returned_ptr = NULL; - - #endif - - #ifdef BADVPN_USE_POLL - - if (bsys->poll_num_enabled_fds == BSYSTEM_MAX_POLL_FDS) { - BLog(BLOG_ERROR, "too many fds"); - return 0; - } - - // append to enabled fds list - LinkedList1_Append(&bsys->poll_enabled_fds_list, &bs->poll_enabled_fds_list_node); - bsys->poll_num_enabled_fds++; - - // set not returned - bs->poll_returned_index = -1; - - #endif - - bs->active = 1; - bs->waitEvents = 0; - - DebugCounter_Increment(&bsys->d_fds_counter); - return 1; -} - -void BReactor_RemoveFileDescriptor (BReactor *bsys, BFileDescriptor *bs) -{ - ASSERT(bs->active) - DebugCounter_Decrement(&bsys->d_fds_counter); - - bs->active = 0; - - #ifdef BADVPN_USE_EPOLL - - // delete epoll entry - struct epoll_event event; - memset(&event, 0, sizeof(event)); - ASSERT_FORCE(epoll_ctl(bsys->efd, EPOLL_CTL_DEL, bs->fd, &event) == 0) - - // write through epoll returned pointer - if (bs->epoll_returned_ptr) { - *bs->epoll_returned_ptr = NULL; - } - - #endif - - #ifdef BADVPN_USE_KEVENT - - // delete kevents - update_kevent_fd_events(bsys, bs, 0); - - // write through kevent returned pointer - if (bs->kevent_returned_ptr) { - *bs->kevent_returned_ptr = NULL; - } - - #endif - - #ifdef BADVPN_USE_POLL - - // invalidate results entry - if (bs->poll_returned_index != -1) { - ASSERT(bs->poll_returned_index >= bsys->poll_results_pos) - ASSERT(bs->poll_returned_index < bsys->poll_results_num) - ASSERT(bsys->poll_results_bfds[bs->poll_returned_index] == bs) - - bsys->poll_results_bfds[bs->poll_returned_index] = NULL; - } - - // remove from enabled fds list - LinkedList1_Remove(&bsys->poll_enabled_fds_list, &bs->poll_enabled_fds_list_node); - bsys->poll_num_enabled_fds--; - - #endif -} - -void BReactor_SetFileDescriptorEvents (BReactor *bsys, BFileDescriptor *bs, int events) -{ - ASSERT(bs->active) - ASSERT(!(events&~(BREACTOR_READ|BREACTOR_WRITE))) - - if (bs->waitEvents == events) { - return; - } - - #ifdef BADVPN_USE_EPOLL - - // calculate epoll events - int eevents = 0; - if ((events & BREACTOR_READ)) { - eevents |= EPOLLIN; - } - if ((events & BREACTOR_WRITE)) { - eevents |= EPOLLOUT; - } - - // update epoll entry - struct epoll_event event; - memset(&event, 0, sizeof(event)); - event.events = eevents; - event.data.ptr = bs; - ASSERT_FORCE(epoll_ctl(bsys->efd, EPOLL_CTL_MOD, bs->fd, &event) == 0) - - #endif - - #ifdef BADVPN_USE_KEVENT - - update_kevent_fd_events(bsys, bs, events); - - #endif - - // update events - bs->waitEvents = events; -} - -#endif - -void BReactorLimit_Init (BReactorLimit *o, BReactor *reactor, int limit) -{ - DebugObject_Access(&reactor->d_obj); - ASSERT(limit > 0) - - // init arguments - o->reactor = reactor; - o->limit = limit; - - // set count zero - o->count = 0; - - DebugCounter_Increment(&reactor->d_limits_ctr); - DebugObject_Init(&o->d_obj); -} - -void BReactorLimit_Free (BReactorLimit *o) -{ - BReactor *reactor = o->reactor; - DebugObject_Free(&o->d_obj); - DebugCounter_Decrement(&reactor->d_limits_ctr); - - // remove from active limits list - if (o->count > 0) { - LinkedList1_Remove(&reactor->active_limits_list, &o->active_limits_list_node); - } -} - -int BReactorLimit_Increment (BReactorLimit *o) -{ - BReactor *reactor = o->reactor; - DebugObject_Access(&o->d_obj); - - // check count against limit - if (o->count >= o->limit) { - return 0; - } - - // increment count - o->count++; - - // if limit was zero, add to active limits list - if (o->count == 1) { - LinkedList1_Append(&reactor->active_limits_list, &o->active_limits_list_node); - } - - return 1; -} - -void BReactorLimit_SetLimit (BReactorLimit *o, int limit) -{ - DebugObject_Access(&o->d_obj); - ASSERT(limit > 0) - - // set limit - o->limit = limit; -} - -#ifdef BADVPN_USE_KEVENT - -int BReactorKEvent_Init (BReactorKEvent *o, BReactor *reactor, BReactorKEvent_handler handler, void *user, uintptr_t ident, short filter, u_int fflags, intptr_t data) -{ - DebugObject_Access(&reactor->d_obj); - - // init arguments - o->reactor = reactor; - o->handler = handler; - o->user = user; - o->ident = ident; - o->filter = filter; - - // add kevent - struct kevent event; - memset(&event, 0, sizeof(event)); - event.ident = o->ident; - event.filter = o->filter; - event.flags = EV_ADD; - event.fflags = fflags; - event.data = data; - event.udata = &o->kevent_tag; - if (kevent(o->reactor->kqueue_fd, &event, 1, NULL, 0, NULL) < 0) { - return 0; - } - - // set kevent tag - o->kevent_tag = KEVENT_TAG_KEVENT; - - // set kevent returned pointer - o->kevent_returned_ptr = NULL; - - DebugObject_Init(&o->d_obj); - DebugCounter_Increment(&o->reactor->d_kevent_ctr); - return 1; -} - -void BReactorKEvent_Free (BReactorKEvent *o) -{ - DebugObject_Free(&o->d_obj); - DebugCounter_Decrement(&o->reactor->d_kevent_ctr); - - // write through kevent returned pointer - if (o->kevent_returned_ptr) { - *o->kevent_returned_ptr = NULL; - } - - // delete kevent - struct kevent event; - memset(&event, 0, sizeof(event)); - event.ident = o->ident; - event.filter = o->filter; - event.flags = EV_DELETE; - ASSERT_FORCE(kevent(o->reactor->kqueue_fd, &event, 1, NULL, 0, NULL) == 0) -} - -#endif - -#ifdef BADVPN_USE_WINAPI - -HANDLE BReactor_GetIOCPHandle (BReactor *reactor) -{ - DebugObject_Access(&reactor->d_obj); - - return reactor->iocp_handle; -} - -void BReactorIOCPOverlapped_Init (BReactorIOCPOverlapped *o, BReactor *reactor, void *user, BReactorIOCPOverlapped_handler handler) -{ - DebugObject_Access(&reactor->d_obj); - - // init arguments - o->reactor = reactor; - o->user = user; - o->handler = handler; - - // zero overlapped - memset(&o->olap, 0, sizeof(o->olap)); - - // append to IOCP list - LinkedList1_Append(&reactor->iocp_list, &o->iocp_list_node); - - // set not ready - o->is_ready = 0; - - DebugObject_Init(&o->d_obj); -} - -void BReactorIOCPOverlapped_Free (BReactorIOCPOverlapped *o) -{ - BReactor *reactor = o->reactor; - DebugObject_Free(&o->d_obj); - - // remove from IOCP ready list - if (o->is_ready) { - LinkedList1_Remove(&reactor->iocp_ready_list, &o->ready_list_node); - } - - // remove from IOCP list - LinkedList1_Remove(&reactor->iocp_list, &o->iocp_list_node); -} - -void BReactorIOCPOverlapped_Wait (BReactorIOCPOverlapped *o, int *out_succeeded, DWORD *out_bytes) -{ - BReactor *reactor = o->reactor; - DebugObject_Access(&o->d_obj); - - // wait for IOCP events until we get an event for this olap - while (!o->is_ready) { - DWORD bytes = 0; - ULONG_PTR key; - BReactorIOCPOverlapped *olap = NULL; - BOOL res = GetQueuedCompletionStatus(reactor->iocp_handle, &bytes, &key, (OVERLAPPED **)&olap, INFINITE); - - ASSERT_FORCE(olap) - DebugObject_Access(&olap->d_obj); - ASSERT(olap->reactor == reactor) - - // regular I/O should be done synchronously, so we shoudln't ever get a second completion before an - // existing one is dispatched. If however PostQueuedCompletionStatus is being used to signal events, - // just discard any excess events. - if (!olap->is_ready) { - set_iocp_ready(olap, (res == TRUE), bytes); - } - } - - // remove from IOCP ready list - LinkedList1_Remove(&reactor->iocp_ready_list, &o->ready_list_node); - - // set not ready - o->is_ready = 0; - - if (out_succeeded) { - *out_succeeded = o->ready_succeeded; - } - if (out_bytes) { - *out_bytes = o->ready_bytes; - } -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor_badvpn.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor_badvpn.h deleted file mode 100644 index 8f10532f..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor_badvpn.h +++ /dev/null @@ -1,572 +0,0 @@ -/** - * @file BReactor_badvpn.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Event loop that supports file desciptor (Linux) or HANDLE (Windows) events - * and timers. - */ - -#ifndef BADVPN_SYSTEM_BREACTOR_H -#define BADVPN_SYSTEM_BREACTOR_H - -#if (defined(BADVPN_USE_WINAPI) + defined(BADVPN_USE_EPOLL) + defined(BADVPN_USE_KEVENT) + defined(BADVPN_USE_POLL)) != 1 -#error Unknown event backend or too many event backends -#endif - -#ifdef BADVPN_USE_WINAPI -#include -#endif - -#ifdef BADVPN_USE_EPOLL -#include -#endif - -#ifdef BADVPN_USE_KEVENT -#include -#include -#include -#endif - -#ifdef BADVPN_USE_POLL -#include -#endif - -#include - -#include "misc/debug.h" -#include "misc/debugcounter.h" -#include "base/DebugObject.h" -#include "structure/LinkedList1.h" -#include "structure/CAvl.h" -#include "system/BTime.h" -#include "base/BPending.h" - -struct BSmallTimer_t; -typedef struct BSmallTimer_t *BReactor_timerstree_link; - -#include "BReactor_badvpn_timerstree.h" -#include "structure/CAvl_decl.h" - -#define BTIMER_SET_ABSOLUTE 1 -#define BTIMER_SET_RELATIVE 2 - -/** - * Handler function invoked when the timer expires. - * The timer was in running state. - * The timer enters not running state before this function is invoked. - * This function is being called from within the timer's previosly - * associated reactor. - * - * @param timer pointer to the timer. Use the {@link UPPER_OBJECT} macro - * to obtain the pointer to the containing structure. - */ -typedef void (*BSmallTimer_handler) (struct BSmallTimer_t *timer); - -/** - * Handler function invoked when the timer expires. - * The timer was in running state. - * The timer enters not running state before this function is invoked. - * This function is being called from within the timer's previosly - * associated reactor. - * - * @param user value passed to {@link BTimer_Init} - */ -typedef void (*BTimer_handler) (void *user); - -/** - * Timer object used with {@link BReactor}. - */ -typedef struct BSmallTimer_t { - union { - BSmallTimer_handler smalll; // MSVC doesn't like "small" - BTimer_handler heavy; - } handler; - union { - LinkedList1Node list_node; - struct BSmallTimer_t *tree_child[2]; - } u; - struct BSmallTimer_t *tree_parent; - btime_t absTime; - int8_t tree_balance; - uint8_t state; - uint8_t is_small; -} BSmallTimer; - -/** - * Initializes the timer object. - * The timer object is initialized in not running state. - * - * @param bt the object - * @param handler handler function invoked when the timer expires - */ -void BSmallTimer_Init (BSmallTimer *bt, BSmallTimer_handler handler); - -/** - * Checks if the timer is running. - * - * @param bt the object - * @return 1 if running, 0 if not running - */ -int BSmallTimer_IsRunning (BSmallTimer *bt); - -/** - * Timer object used with {@link BReactor}. This is a legacy wrapper - * around {@link BSmallTimer} with an extra field for the default time. - */ -typedef struct { - BSmallTimer base; - void *user; - btime_t msTime; -} BTimer; - -/** - * Initializes the timer object. - * The timer object is initialized in not running state. - * - * @param bt the object - * @param msTime default timeout in milliseconds - * @param handler handler function invoked when the timer expires - * @param user value to pass to the handler function - */ -void BTimer_Init (BTimer *bt, btime_t msTime, BTimer_handler handler, void *user); - -/** - * Checks if the timer is running. - * - * @param bt the object - * @return 1 if running, 0 if not running - */ -int BTimer_IsRunning (BTimer *bt); - -#ifndef BADVPN_USE_WINAPI - -struct BFileDescriptor_t; - -#define BREACTOR_READ (1 << 0) -#define BREACTOR_WRITE (1 << 1) -#define BREACTOR_ERROR (1 << 2) -#define BREACTOR_HUP (1 << 3) - -/** - * Handler function invoked by the reactor when one or more events are detected. - * The events argument will contain a subset of the monitored events (BREACTOR_READ, BREACTOR_WRITE), - * plus possibly the error event (BREACTOR_ERROR). - * The file descriptor object is in active state, being called from within - * the associated reactor. - * - * @param user value passed to {@link BFileDescriptor_Init} - * @param events bitmask composed of a subset of monitored events (BREACTOR_READ, BREACTOR_WRITE), - * and possibly the error event BREACTOR_ERROR and the hang-up event BREACTOR_HUP. - * Will be nonzero. - */ -typedef void (*BFileDescriptor_handler) (void *user, int events); - -/** - * File descriptor object used with {@link BReactor}. - */ -typedef struct BFileDescriptor_t { - int fd; - BFileDescriptor_handler handler; - void *user; - int active; - int waitEvents; - - #ifdef BADVPN_USE_EPOLL - struct BFileDescriptor_t **epoll_returned_ptr; - #endif - - #ifdef BADVPN_USE_KEVENT - int kevent_tag; - int **kevent_returned_ptr; - #endif - - #ifdef BADVPN_USE_POLL - LinkedList1Node poll_enabled_fds_list_node; - int poll_returned_index; - #endif -} BFileDescriptor; - -/** - * Intializes the file descriptor object. - * The object is initialized in not active state. - * - * @param bs file descriptor object to initialize - * @param fb file descriptor to represent - * @param handler handler function invoked by the reactor when a monitored event is detected - * @param user value passed to the handler functuon - */ -void BFileDescriptor_Init (BFileDescriptor *bs, int fd, BFileDescriptor_handler handler, void *user); - -#endif - -// BReactor - -#define BSYSTEM_MAX_RESULTS 64 -#define BSYSTEM_MAX_HANDLES 64 -#define BSYSTEM_MAX_POLL_FDS 4096 - -/** - * Event loop that supports file desciptor (Linux) or HANDLE (Windows) events - * and timers. - */ -typedef struct { - int exiting; - int exit_code; - - // jobs - BPendingGroup pending_jobs; - - // timers - BReactor__TimersTree timers_tree; - LinkedList1 timers_expired_list; - - // limits - LinkedList1 active_limits_list; - - #ifdef BADVPN_USE_WINAPI - LinkedList1 iocp_list; - HANDLE iocp_handle; - LinkedList1 iocp_ready_list; - #endif - - #ifdef BADVPN_USE_EPOLL - int efd; // epoll fd - struct epoll_event epoll_results[BSYSTEM_MAX_RESULTS]; // epoll returned events buffer - int epoll_results_num; // number of events in the array - int epoll_results_pos; // number of events processed so far - #endif - - #ifdef BADVPN_USE_KEVENT - int kqueue_fd; - struct kevent kevent_results[BSYSTEM_MAX_RESULTS]; - int kevent_results_num; - int kevent_results_pos; - #endif - - #ifdef BADVPN_USE_POLL - LinkedList1 poll_enabled_fds_list; - int poll_num_enabled_fds; - int poll_results_num; - int poll_results_pos; - struct pollfd *poll_results_pollfds; - BFileDescriptor **poll_results_bfds; - #endif - - DebugObject d_obj; - #ifndef BADVPN_USE_WINAPI - DebugCounter d_fds_counter; - #endif - #ifdef BADVPN_USE_KEVENT - DebugCounter d_kevent_ctr; - #endif - DebugCounter d_limits_ctr; -} BReactor; - -/** - * Initializes the reactor. - * {@link BLog_Init} must have been done. - * {@link BTime_Init} must have been done. - * - * @param bsys the object - * @return 1 on success, 0 on failure - */ -int BReactor_Init (BReactor *bsys) WARN_UNUSED; - -/** - * Frees the reactor. - * Must not be called from within the event loop ({@link BReactor_Exec}). - * There must be no {@link BPending} or {@link BSmallPending} objects using the - * pending group returned by {@link BReactor_PendingGroup}. - * There must be no running timers in this reactor. - * There must be no limit objects in this reactor. - * There must be no file descriptors or handles registered - * with this reactor. - * There must be no {@link BReactorKEvent} objects in this reactor. - * - * @param bsys the object - */ -void BReactor_Free (BReactor *bsys); - -/** - * Runs the event loop. - * - * @param bsys the object - * @return value passed to {@link BReactor_Quit} - */ -int BReactor_Exec (BReactor *bsys); - -/** - * Causes the event loop ({@link BReactor_Exec}) to cease - * dispatching events and return. - * Any further calls of {@link BReactor_Exec} will return immediately. - * - * @param bsys the object - * @param code value {@link BReactor_Exec} should return. If this is - * called more than once, it will return the last code. - */ -void BReactor_Quit (BReactor *bsys, int code); - -/** - * Starts a timer to expire at the specified time. - * The timer must have been initialized with {@link BSmallTimer_Init}. - * If the timer is in running state, it must be associated with this reactor. - * The timer enters running state, associated with this reactor. - * - * @param bsys the object - * @param bt timer to start - * @param mode interpretation of time (BTIMER_SET_ABSOLUTE or BTIMER_SET_RELATIVE) - * @param time absolute or relative expiration time - */ -void BReactor_SetSmallTimer (BReactor *bsys, BSmallTimer *bt, int mode, btime_t time); - -/** - * Stops a timer. - * If the timer is in running state, it must be associated with this reactor. - * The timer enters not running state. - * - * @param bsys the object - * @param bt timer to stop - */ -void BReactor_RemoveSmallTimer (BReactor *bsys, BSmallTimer *bt); - -/** - * Starts a timer to expire after its default time. - * The timer must have been initialized with {@link BTimer_Init}. - * If the timer is in running state, it must be associated with this reactor. - * The timer enters running state, associated with this reactor. - * - * @param bsys the object - * @param bt timer to start - */ -void BReactor_SetTimer (BReactor *bsys, BTimer *bt); - -/** - * Starts a timer to expire after a given time. - * The timer must have been initialized with {@link BTimer_Init}. - * If the timer is in running state, it must be associated with this reactor. - * The timer enters running state, associated with this reactor. - * - * @param bsys the object - * @param bt timer to start - * @param after relative expiration time - */ -void BReactor_SetTimerAfter (BReactor *bsys, BTimer *bt, btime_t after); - -/** - * Starts a timer to expire at the specified time. - * The timer must have been initialized with {@link BTimer_Init}. - * If the timer is in running state, it must be associated with this reactor. - * The timer enters running state, associated with this reactor. - * The timer's expiration time is set to the time argument. - * - * @param bsys the object - * @param bt timer to start - * @param time absolute expiration time (according to {@link btime_gettime}) - */ -void BReactor_SetTimerAbsolute (BReactor *bsys, BTimer *bt, btime_t time); - -/** - * Stops a timer. - * If the timer is in running state, it must be associated with this reactor. - * The timer enters not running state. - * - * @param bsys the object - * @param bt timer to stop - */ -void BReactor_RemoveTimer (BReactor *bsys, BTimer *bt); - -/** - * Returns a {@link BPendingGroup} object that can be used to schedule jobs for - * the reactor to execute. These jobs have complete priority over other events - * (timers, file descriptors and Windows handles). - * The returned pending group may only be used as an argument to {@link BPending_Init}, - * and must not be accessed by other means. - * All {@link BPending} and {@link BSmallPending} objects using this group must be - * freed before freeing the reactor. - * - * @param bsys the object - * @return pending group for scheduling jobs for the reactor to execute - */ -BPendingGroup * BReactor_PendingGroup (BReactor *bsys); - -/** - * Executes pending jobs until either: - * - the reference job is reached, or - * - {@link BReactor_Quit} is called. - * The reference job must be reached before the job list empties. - * The reference job will not be executed. - * - * WARNING: Use with care. This should only be used to to work around third-party software - * that does not integrade into the jobs system. In particular, you should think about: - * - the effects the jobs to be executed may have, and - * - the environment those jobs expect to be executed in. - * - * @param bsys the object - * @param ref reference job. It is not accessed in any way, only its address is compared to - * pending jobs before they are executed. - * @return 1 if the reference job was reached, - * 0 if {@link BReactor_Quit} was called (either while executing a job, or before) - */ -int BReactor_Synchronize (BReactor *bsys, BSmallPending *ref); - -#ifndef BADVPN_USE_WINAPI - -/** - * Starts monitoring a file descriptor. - * - * @param bsys the object - * @param bs file descriptor object. Must have been initialized with - * {@link BFileDescriptor_Init} Must be in not active state. - * On success, the file descriptor object enters active state, - * associated with this reactor. - * @return 1 on success, 0 on failure - */ -int BReactor_AddFileDescriptor (BReactor *bsys, BFileDescriptor *bs) WARN_UNUSED; - -/** - * Stops monitoring a file descriptor. - * - * @param bsys the object - * @param bs {@link BFileDescriptor} object. Must be in active state, - * associated with this reactor. The file descriptor object - * enters not active state. - */ -void BReactor_RemoveFileDescriptor (BReactor *bsys, BFileDescriptor *bs); - -/** - * Sets monitored file descriptor events. - * - * @param bsys the object - * @param bs {@link BFileDescriptor} object. Must be in active state, - * associated with this reactor. - * @param events events to watch for. Must not have any bits other than - * BREACTOR_READ and BREACTOR_WRITE. - * This overrides previosly monitored events. - */ -void BReactor_SetFileDescriptorEvents (BReactor *bsys, BFileDescriptor *bs, int events); - -#endif - -typedef struct { - BReactor *reactor; - int limit; - int count; - LinkedList1Node active_limits_list_node; - DebugObject d_obj; -} BReactorLimit; - -/** - * Initializes a limit object. - * A limit object consists of a counter integer, which is initialized to - * zero, is incremented by {@link BReactorLimit_Increment} up to \a limit, - * and is reset to zero every time the event loop performs a wait. - * If the event loop has processed all detected events, and before performing - * a wait, it determines that timers have expired, the counter will not be reset. - * - * @param o the object - * @param reactor reactor the object is tied to - * @param limit maximum counter value. Must be >0. - */ -void BReactorLimit_Init (BReactorLimit *o, BReactor *reactor, int limit); - -/** - * Frees a limit object. - * - * @param o the object - */ -void BReactorLimit_Free (BReactorLimit *o); - -/** - * Attempts to increment the counter of a limit object. - * - * @param o the object - * @return 1 if the counter was lesser than the limit and was incremented, - * 0 if the counter was greater or equal to the limit and could not be - * incremented - */ -int BReactorLimit_Increment (BReactorLimit *o); - -/** - * Sets the limit of a limit object. - * - * @param o the object - * @param limit new limit. Must be >0. - */ -void BReactorLimit_SetLimit (BReactorLimit *o, int limit); - -#ifdef BADVPN_USE_KEVENT - -typedef void (*BReactorKEvent_handler) (void *user, u_int fflags, intptr_t data); - -typedef struct { - BReactor *reactor; - BReactorKEvent_handler handler; - void *user; - uintptr_t ident; - short filter; - int kevent_tag; - int **kevent_returned_ptr; - DebugObject d_obj; -} BReactorKEvent; - -int BReactorKEvent_Init (BReactorKEvent *o, BReactor *reactor, BReactorKEvent_handler handler, void *user, uintptr_t ident, short filter, u_int fflags, intptr_t data); -void BReactorKEvent_Free (BReactorKEvent *o); - -#endif - -#ifdef BADVPN_USE_WINAPI - -#define BREACTOR_IOCP_EVENT_SUCCEEDED 1 -#define BREACTOR_IOCP_EVENT_FAILED 2 -#define BREACTOR_IOCP_EVENT_EXITING 3 - -typedef void (*BReactorIOCPOverlapped_handler) (void *user, int event, DWORD bytes); - -typedef struct { - OVERLAPPED olap; - BReactor *reactor; - void *user; - BReactorIOCPOverlapped_handler handler; - LinkedList1Node iocp_list_node; - int is_ready; - LinkedList1Node ready_list_node; - int ready_succeeded; - DWORD ready_bytes; - DebugObject d_obj; -} BReactorIOCPOverlapped; - -HANDLE BReactor_GetIOCPHandle (BReactor *reactor); - -void BReactorIOCPOverlapped_Init (BReactorIOCPOverlapped *o, BReactor *reactor, void *user, BReactorIOCPOverlapped_handler handler); -void BReactorIOCPOverlapped_Free (BReactorIOCPOverlapped *o); -void BReactorIOCPOverlapped_Wait (BReactorIOCPOverlapped *o, int *out_succeeded, DWORD *out_bytes); - -#endif - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor_badvpn_timerstree.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor_badvpn_timerstree.h deleted file mode 100644 index 3cecd75e..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BReactor_badvpn_timerstree.h +++ /dev/null @@ -1,13 +0,0 @@ -#define CAVL_PARAM_NAME BReactor__TimersTree -#define CAVL_PARAM_FEATURE_COUNTS 0 -#define CAVL_PARAM_FEATURE_KEYS_ARE_INDICES 0 -#define CAVL_PARAM_FEATURE_NOKEYS 1 -#define CAVL_PARAM_TYPE_ENTRY struct BSmallTimer_t -#define CAVL_PARAM_TYPE_LINK BReactor_timerstree_link -#define CAVL_PARAM_TYPE_ARG int -#define CAVL_PARAM_VALUE_NULL ((BReactor_timerstree_link)NULL) -#define CAVL_PARAM_FUN_DEREF(arg, link) (link) -#define CAVL_PARAM_FUN_COMPARE_ENTRIES(arg, entry1, entry2) compare_timers((entry1).link, (entry2).link) -#define CAVL_PARAM_MEMBER_CHILD u.tree_child -#define CAVL_PARAM_MEMBER_BALANCE tree_balance -#define CAVL_PARAM_MEMBER_PARENT tree_parent diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BSignal.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BSignal.c deleted file mode 100644 index 4a71198d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BSignal.c +++ /dev/null @@ -1,188 +0,0 @@ -/** - * @file BSignal.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifdef BADVPN_USE_WINAPI -#include -#else -#include -#include "system/BUnixSignal.h" -#endif - -#include "misc/debug.h" -#include "base/BLog.h" - -#include "system/BSignal.h" - -#include "generated/blog_channel_BSignal.h" - -static struct { - int initialized; - int finished; - BReactor *reactor; - BSignal_handler handler; - void *user; - #ifdef BADVPN_USE_WINAPI - BReactorIOCPOverlapped olap; - CRITICAL_SECTION iocp_handle_mutex; - HANDLE iocp_handle; - #else - BUnixSignal signal; - #endif -} bsignal_global = { - 0 -}; - -#ifdef BADVPN_USE_WINAPI - -static void olap_handler (void *user, int event, DWORD bytes) -{ - ASSERT(bsignal_global.initialized) - ASSERT(!(event == BREACTOR_IOCP_EVENT_EXITING) || bsignal_global.finished) - - if (event == BREACTOR_IOCP_EVENT_EXITING) { - BReactorIOCPOverlapped_Free(&bsignal_global.olap); - return; - } - - if (!bsignal_global.finished) { - // call handler - bsignal_global.handler(bsignal_global.user); - return; - } -} - -static BOOL WINAPI ctrl_handler (DWORD type) -{ - EnterCriticalSection(&bsignal_global.iocp_handle_mutex); - - if (bsignal_global.iocp_handle) { - PostQueuedCompletionStatus(bsignal_global.iocp_handle, 0, 0, &bsignal_global.olap.olap); - } - - LeaveCriticalSection(&bsignal_global.iocp_handle_mutex); - - return TRUE; -} - -#else - -static void unix_signal_handler (void *user, int signo) -{ - ASSERT(signo == SIGTERM || signo == SIGINT) - ASSERT(bsignal_global.initialized) - ASSERT(!bsignal_global.finished) - - BLog(BLOG_DEBUG, "Dispatching signal"); - - // call handler - bsignal_global.handler(bsignal_global.user); - return; -} - -#endif - -int BSignal_Init (BReactor *reactor, BSignal_handler handler, void *user) -{ - ASSERT(!bsignal_global.initialized) - - // init arguments - bsignal_global.reactor = reactor; - bsignal_global.handler = handler; - bsignal_global.user = user; - - BLog(BLOG_DEBUG, "BSignal initializing"); - - #ifdef BADVPN_USE_WINAPI - - // init olap - BReactorIOCPOverlapped_Init(&bsignal_global.olap, bsignal_global.reactor, NULL, olap_handler); - - // init handler mutex - InitializeCriticalSection(&bsignal_global.iocp_handle_mutex); - - // remember IOCP handle - bsignal_global.iocp_handle = BReactor_GetIOCPHandle(bsignal_global.reactor); - - // configure ctrl handler - if (!SetConsoleCtrlHandler(ctrl_handler, TRUE)) { - BLog(BLOG_ERROR, "SetConsoleCtrlHandler failed"); - goto fail1; - } - - #else - - sigset_t sset; - ASSERT_FORCE(sigemptyset(&sset) == 0) - ASSERT_FORCE(sigaddset(&sset, SIGTERM) == 0) - ASSERT_FORCE(sigaddset(&sset, SIGINT) == 0) - - // init BUnixSignal - if (!BUnixSignal_Init(&bsignal_global.signal, bsignal_global.reactor, sset, unix_signal_handler, NULL)) { - BLog(BLOG_ERROR, "BUnixSignal_Init failed"); - goto fail0; - } - - #endif - - bsignal_global.initialized = 1; - bsignal_global.finished = 0; - - return 1; - - #ifdef BADVPN_USE_WINAPI -fail1: - DeleteCriticalSection(&bsignal_global.iocp_handle_mutex); - BReactorIOCPOverlapped_Free(&bsignal_global.olap); - #endif - -fail0: - return 0; -} - -void BSignal_Finish (void) -{ - ASSERT(bsignal_global.initialized) - ASSERT(!bsignal_global.finished) - - #ifdef BADVPN_USE_WINAPI - - // forget IOCP handle - EnterCriticalSection(&bsignal_global.iocp_handle_mutex); - bsignal_global.iocp_handle = NULL; - LeaveCriticalSection(&bsignal_global.iocp_handle_mutex); - - #else - - // free BUnixSignal - BUnixSignal_Free(&bsignal_global.signal, 0); - - #endif - - bsignal_global.finished = 1; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BSignal.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BSignal.h deleted file mode 100644 index 9e7701df..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BSignal.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @file BSignal.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * A global object for catching program termination requests. - */ - -#ifndef BADVPN_SYSTEM_BSIGNAL_H -#define BADVPN_SYSTEM_BSIGNAL_H - -#include "misc/debug.h" -#include "system/BReactor.h" - -typedef void (*BSignal_handler) (void *user); - -/** - * Initializes signal handling. - * The object is created in not capturing state. - * {@link BLog_Init} must have been done. - * - * WARNING: make sure this won't interfere with other components: - * - on Linux, this uses {@link BUnixSignal} to catch SIGTERM and SIGINT, - * - on Windows, this sets up a handler with SetConsoleCtrlHandler. - * - * @param reactor {@link BReactor} from which the handler will be called - * @param handler callback function invoked from the reactor - * @param user value passed to callback function - * @return 1 on success, 0 on failure - */ -int BSignal_Init (BReactor *reactor, BSignal_handler handler, void *user) WARN_UNUSED; - -/** - * Finishes signal handling. - * {@link BSignal_Init} must not be called again. - */ -void BSignal_Finish (void); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BTime.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BTime.c deleted file mode 100644 index 0ab77f9a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BTime.c +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @file BTime.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "system/BTime.h" - -#ifndef BADVPN_PLUGIN -struct _BTime_global btime_global = { - #ifndef NDEBUG - 0 - #endif -}; -#endif - -#ifdef __MACH__ -#include -#include - -int clock_gettime_ex(int clk_id, struct timespec* t) -{ - clock_serv_t cclock; - mach_timespec_t mts; - host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); - clock_get_time(cclock, &mts); - mach_port_deallocate(mach_task_self(), cclock); - t->tv_sec = mts.tv_sec; - t->tv_nsec = mts.tv_nsec; - return 0; -} -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BTime.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BTime.h deleted file mode 100644 index 481a1cde..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BTime.h +++ /dev/null @@ -1,168 +0,0 @@ -/** - * @file BTime.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * System time abstraction used by {@link BReactor}. - */ - -#ifndef BADVPN_SYSTEM_BTIME_H -#define BADVPN_SYSTEM_BTIME_H - -#if defined(BADVPN_USE_WINAPI) -#include -#elif defined(BADVPN_EMSCRIPTEN) -#include -#else -#include -#include -#endif - -#include - -#include "misc/debug.h" -#include "misc/overflow.h" -#include "base/BLog.h" - -#include "generated/blog_channel_BTime.h" - -typedef int64_t btime_t; - -#define BTIME_MIN INT64_MIN - -struct _BTime_global { - #ifndef NDEBUG - int initialized; // initialized statically - #endif - #if defined(BADVPN_USE_WINAPI) - LARGE_INTEGER start_time; - #elif defined(BADVPN_EMSCRIPTEN) - btime_t start_time; - #else - btime_t start_time; - int use_gettimeofday; - #endif -}; - -#ifdef __MACH__ -#define CLOCK_MONOTONIC 1 -int clock_gettime_ex(int clk_id, struct timespec* t); -#endif - -extern struct _BTime_global btime_global; - -static void BTime_Init (void) -{ - ASSERT(!btime_global.initialized) - - #if defined(BADVPN_USE_WINAPI) - - ASSERT_FORCE(QueryPerformanceCounter(&btime_global.start_time)) - - #elif defined(BADVPN_EMSCRIPTEN) - - btime_global.start_time = emscripten_get_now(); - - #else - - struct timespec ts; - if (clock_gettime_ex(CLOCK_MONOTONIC, &ts) < 0) { - BLog(BLOG_WARNING, "CLOCK_MONOTONIC is not available. Timers will be confused by clock changes."); - - struct timeval tv; - ASSERT_FORCE(gettimeofday(&tv, NULL) == 0) - - btime_global.start_time = (int64_t)tv.tv_sec * 1000 + (int64_t)tv.tv_usec/1000; - btime_global.use_gettimeofday = 1; - } else { - btime_global.start_time = (int64_t)ts.tv_sec * 1000 + (int64_t)ts.tv_nsec/1000000; - btime_global.use_gettimeofday = 0; - } - - #endif - - #ifndef NDEBUG - btime_global.initialized = 1; - #endif -} - -static btime_t btime_gettime (void) -{ - ASSERT(btime_global.initialized) - - #if defined(BADVPN_USE_WINAPI) - - LARGE_INTEGER count; - LARGE_INTEGER freq; - ASSERT_FORCE(QueryPerformanceCounter(&count)) - ASSERT_FORCE(QueryPerformanceFrequency(&freq)) - return (((count.QuadPart - btime_global.start_time.QuadPart) * 1000) / freq.QuadPart); - - #elif defined(BADVPN_EMSCRIPTEN) - - return (btime_t)emscripten_get_now() - btime_global.start_time; - - #else - - if (btime_global.use_gettimeofday) { - struct timeval tv; - ASSERT_FORCE(gettimeofday(&tv, NULL) == 0) - return ((int64_t)tv.tv_sec * 1000 + (int64_t)tv.tv_usec/1000); - } else { - struct timespec ts; - ASSERT_FORCE(clock_gettime_ex(CLOCK_MONOTONIC, &ts) == 0) - return (((int64_t)ts.tv_sec * 1000 + (int64_t)ts.tv_nsec/1000000) - btime_global.start_time); - } - - #endif -} - -static btime_t btime_add (btime_t t1, btime_t t2) -{ - // handle overflow - int overflows = add_int64_overflows(t1, t2); - btime_t sum; - if (overflows != 0) { - if (overflows > 0) { - sum = INT64_MAX; - } else { - sum = INT64_MIN; - } - } else { - sum = t1 + t2; - } - - return sum; -} - -static btime_t btime_getpast (void) -{ - return INT64_MIN; -} - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BUnixSignal.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BUnixSignal.c deleted file mode 100644 index aaea06d9..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BUnixSignal.c +++ /dev/null @@ -1,406 +0,0 @@ -/** - * @file BUnixSignal.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include -#include - -#ifdef BADVPN_USE_SIGNALFD -#include -#endif - -#include "misc/balloc.h" -#include "misc/nonblocking.h" -#include "base/BLog.h" - -#include "system/BUnixSignal.h" - -#include "generated/blog_channel_BUnixSignal.h" - -#define BUNIXSIGNAL_MAX_SIGNALS 64 - -#ifdef BADVPN_USE_SIGNALFD - -static void signalfd_handler (BUnixSignal *o, int events) -{ - DebugObject_Access(&o->d_obj); - - // read a signal - struct signalfd_siginfo siginfo; - int bytes = read(o->signalfd_fd, &siginfo, sizeof(siginfo)); - if (bytes < 0) { - int error = errno; - if (error == EAGAIN || error == EWOULDBLOCK) { - return; - } - BLog(BLOG_ERROR, "read failed (%d)", error); - return; - } - ASSERT_FORCE(bytes == sizeof(siginfo)) - - // check signal - if (siginfo.ssi_signo > INT_MAX) { - BLog(BLOG_ERROR, "read returned out of int range signo (%"PRIu32")", siginfo.ssi_signo); - return; - } - int signo = siginfo.ssi_signo; - if (sigismember(&o->signals, signo) <= 0) { - BLog(BLOG_ERROR, "read returned wrong signo (%d)", signo); - return; - } - - BLog(BLOG_DEBUG, "dispatching signal %d", signo); - - // call handler - o->handler(o->user, signo); - return; -} - -#endif - -#ifdef BADVPN_USE_KEVENT - -static void kevent_handler (struct BUnixSignal_kevent_entry *entry, u_int fflags, intptr_t data) -{ - BUnixSignal *o = entry->parent; - DebugObject_Access(&o->d_obj); - - // call signal - o->handler(o->user, entry->signo); - return; -} - -#endif - -#ifdef BADVPN_USE_SELFPIPE - -struct BUnixSignal_selfpipe_entry *bunixsignal_selfpipe_entries[BUNIXSIGNAL_MAX_SIGNALS]; - -static void free_selfpipe_entry (struct BUnixSignal_selfpipe_entry *entry) -{ - BUnixSignal *o = entry->parent; - - // uninstall signal handler - struct sigaction act; - memset(&act, 0, sizeof(act)); - act.sa_handler = SIG_DFL; - sigemptyset(&act.sa_mask); - ASSERT_FORCE(sigaction(entry->signo, &act, NULL) == 0) - - // free BFileDescriptor - BReactor_RemoveFileDescriptor(o->reactor, &entry->pipe_read_bfd); - - // close pipe - ASSERT_FORCE(close(entry->pipefds[0]) == 0) - ASSERT_FORCE(close(entry->pipefds[1]) == 0) -} - -static void pipe_read_fd_handler (struct BUnixSignal_selfpipe_entry *entry, int events) -{ - BUnixSignal *o = entry->parent; - DebugObject_Access(&o->d_obj); - - // read a byte - uint8_t b; - if (read(entry->pipefds[0], &b, sizeof(b)) < 0) { - int error = errno; - if (error == EAGAIN || error == EWOULDBLOCK) { - return; - } - BLog(BLOG_ERROR, "read failed (%d)", error); - return; - } - - // call handler - o->handler(o->user, entry->signo); - return; -} - -static void signal_handler (int signo) -{ - ASSERT(signo >= 0) - ASSERT(signo < BUNIXSIGNAL_MAX_SIGNALS) - - struct BUnixSignal_selfpipe_entry *entry = bunixsignal_selfpipe_entries[signo]; - - uint8_t b = 0; - write(entry->pipefds[1], &b, sizeof(b)); -} - -#endif - -int BUnixSignal_Init (BUnixSignal *o, BReactor *reactor, sigset_t signals, BUnixSignal_handler handler, void *user) -{ - // init arguments - o->reactor = reactor; - o->signals = signals; - o->handler = handler; - o->user = user; - - #ifdef BADVPN_USE_SIGNALFD - - // init signalfd fd - if ((o->signalfd_fd = signalfd(-1, &o->signals, 0)) < 0) { - BLog(BLOG_ERROR, "signalfd failed"); - goto fail0; - } - - // set non-blocking - if (fcntl(o->signalfd_fd, F_SETFL, O_NONBLOCK) < 0) { - BLog(BLOG_ERROR, "cannot set non-blocking"); - goto fail1; - } - - // init signalfd BFileDescriptor - BFileDescriptor_Init(&o->signalfd_bfd, o->signalfd_fd, (BFileDescriptor_handler)signalfd_handler, o); - if (!BReactor_AddFileDescriptor(o->reactor, &o->signalfd_bfd)) { - BLog(BLOG_ERROR, "BReactor_AddFileDescriptor failed"); - goto fail1; - } - BReactor_SetFileDescriptorEvents(o->reactor, &o->signalfd_bfd, BREACTOR_READ); - - // block signals - if (sigprocmask(SIG_BLOCK, &o->signals, 0) < 0) { - BLog(BLOG_ERROR, "sigprocmask block failed"); - goto fail2; - } - - #endif - - #ifdef BADVPN_USE_KEVENT - - // count signals - int num_signals = 0; - for (int i = 0; i < BUNIXSIGNAL_MAX_SIGNALS; i++) { - if (!sigismember(&o->signals, i)) { - continue; - } - num_signals++; - } - - // allocate array - if (!(o->entries = BAllocArray(num_signals, sizeof(o->entries[0])))) { - BLog(BLOG_ERROR, "BAllocArray failed"); - goto fail0; - } - - // init kevents - o->num_entries = 0; - for (int i = 0; i < BUNIXSIGNAL_MAX_SIGNALS; i++) { - if (!sigismember(&o->signals, i)) { - continue; - } - struct BUnixSignal_kevent_entry *entry = &o->entries[o->num_entries]; - entry->parent = o; - entry->signo = i; - if (!BReactorKEvent_Init(&entry->kevent, o->reactor, (BReactorKEvent_handler)kevent_handler, entry, entry->signo, EVFILT_SIGNAL, 0, 0)) { - BLog(BLOG_ERROR, "BReactorKEvent_Init failed"); - goto fail2; - } - o->num_entries++; - } - - // block signals - if (sigprocmask(SIG_BLOCK, &o->signals, 0) < 0) { - BLog(BLOG_ERROR, "sigprocmask block failed"); - goto fail2; - } - - #endif - - #ifdef BADVPN_USE_SELFPIPE - - // count signals - int num_signals = 0; - for (int i = 1; i < BUNIXSIGNAL_MAX_SIGNALS; i++) { - if (!sigismember(&o->signals, i)) { - continue; - } - num_signals++; - } - - // allocate array - if (!(o->entries = BAllocArray(num_signals, sizeof(o->entries[0])))) { - BLog(BLOG_ERROR, "BAllocArray failed"); - goto fail0; - } - - // init entries - o->num_entries = 0; - for (int i = 1; i < BUNIXSIGNAL_MAX_SIGNALS; i++) { - if (!sigismember(&o->signals, i)) { - continue; - } - - struct BUnixSignal_selfpipe_entry *entry = &o->entries[o->num_entries]; - entry->parent = o; - entry->signo = i; - - // init pipe - if (pipe(entry->pipefds) < 0) { - BLog(BLOG_ERROR, "pipe failed"); - goto loop_fail0; - } - - // set pipe ends non-blocking - if (!badvpn_set_nonblocking(entry->pipefds[0]) || !badvpn_set_nonblocking(entry->pipefds[1])) { - BLog(BLOG_ERROR, "set nonblocking failed"); - goto loop_fail1; - } - - // init read end BFileDescriptor - BFileDescriptor_Init(&entry->pipe_read_bfd, entry->pipefds[0], (BFileDescriptor_handler)pipe_read_fd_handler, entry); - if (!BReactor_AddFileDescriptor(o->reactor, &entry->pipe_read_bfd)) { - BLog(BLOG_ERROR, "BReactor_AddFileDescriptor failed"); - goto loop_fail1; - } - BReactor_SetFileDescriptorEvents(o->reactor, &entry->pipe_read_bfd, BREACTOR_READ); - - // set global entry pointer - bunixsignal_selfpipe_entries[entry->signo] = entry; - - // install signal handler - struct sigaction act; - memset(&act, 0, sizeof(act)); - act.sa_handler = signal_handler; - sigemptyset(&act.sa_mask); - if (sigaction(entry->signo, &act, NULL) < 0) { - BLog(BLOG_ERROR, "sigaction failed"); - goto loop_fail2; - } - - o->num_entries++; - - continue; - - loop_fail2: - BReactor_RemoveFileDescriptor(o->reactor, &entry->pipe_read_bfd); - loop_fail1: - ASSERT_FORCE(close(entry->pipefds[0]) == 0) - ASSERT_FORCE(close(entry->pipefds[1]) == 0) - loop_fail0: - goto fail2; - } - - #endif - - DebugObject_Init(&o->d_obj); - - return 1; - - #ifdef BADVPN_USE_SIGNALFD -fail2: - BReactor_RemoveFileDescriptor(o->reactor, &o->signalfd_bfd); -fail1: - ASSERT_FORCE(close(o->signalfd_fd) == 0) - #endif - - #ifdef BADVPN_USE_KEVENT -fail2: - while (o->num_entries > 0) { - BReactorKEvent_Free(&o->entries[o->num_entries - 1].kevent); - o->num_entries--; - } - BFree(o->entries); - #endif - - #ifdef BADVPN_USE_SELFPIPE -fail2: - while (o->num_entries > 0) { - free_selfpipe_entry(&o->entries[o->num_entries - 1]); - o->num_entries--; - } - BFree(o->entries); - #endif - -fail0: - return 0; -} - -void BUnixSignal_Free (BUnixSignal *o, int unblock) -{ - ASSERT(unblock == 0 || unblock == 1) - DebugObject_Free(&o->d_obj); - - #ifdef BADVPN_USE_SIGNALFD - - if (unblock) { - // unblock signals - ASSERT_FORCE(sigprocmask(SIG_UNBLOCK, &o->signals, 0) == 0) - } - - // free signalfd BFileDescriptor - BReactor_RemoveFileDescriptor(o->reactor, &o->signalfd_bfd); - - // free signalfd fd - ASSERT_FORCE(close(o->signalfd_fd) == 0) - - #endif - - #ifdef BADVPN_USE_KEVENT - - if (unblock) { - // unblock signals - ASSERT_FORCE(sigprocmask(SIG_UNBLOCK, &o->signals, 0) == 0) - } - - // free kevents - while (o->num_entries > 0) { - BReactorKEvent_Free(&o->entries[o->num_entries - 1].kevent); - o->num_entries--; - } - - // free array - BFree(o->entries); - - #endif - - #ifdef BADVPN_USE_SELFPIPE - - if (!unblock) { - // block signals - if (sigprocmask(SIG_BLOCK, &o->signals, 0) < 0) { - BLog(BLOG_ERROR, "sigprocmask block failed"); - } - } - - // free entries - while (o->num_entries > 0) { - free_selfpipe_entry(&o->entries[o->num_entries - 1]); - o->num_entries--; - } - - // free array - BFree(o->entries); - - #endif -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BUnixSignal.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BUnixSignal.h deleted file mode 100644 index 53f48ae3..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/system/BUnixSignal.h +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @file BUnixSignal.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * Object for catching unix signals. - */ - -#ifndef BADVPN_SYSTEM_BUNIXSIGNAL_H -#define BADVPN_SYSTEM_BUNIXSIGNAL_H - -#if (defined(BADVPN_USE_SIGNALFD) + defined(BADVPN_USE_KEVENT) + defined(BADVPN_USE_SELFPIPE)) != 1 -#error Unknown signal backend or too many signal backends -#endif - -#include -#include - -#include "misc/debug.h" -#include "system/BReactor.h" -#include "base/DebugObject.h" - -struct BUnixSignal_s; - -/** - * Handler function called when a signal is received. - * - * @param user as in {@link BUnixSignal_Init} - * @param signo signal number. Will be one of the signals provided to {@link signals}. - */ -typedef void (*BUnixSignal_handler) (void *user, int signo); - -#ifdef BADVPN_USE_KEVENT -struct BUnixSignal_kevent_entry { - struct BUnixSignal_s *parent; - int signo; - BReactorKEvent kevent; -}; -#endif - -#ifdef BADVPN_USE_SELFPIPE -struct BUnixSignal_selfpipe_entry { - struct BUnixSignal_s *parent; - int signo; - int pipefds[2]; - BFileDescriptor pipe_read_bfd; -}; -#endif - -/** - * Object for catching unix signals. - */ -typedef struct BUnixSignal_s { - BReactor *reactor; - sigset_t signals; - BUnixSignal_handler handler; - void *user; - - #ifdef BADVPN_USE_SIGNALFD - int signalfd_fd; - BFileDescriptor signalfd_bfd; - #endif - - #ifdef BADVPN_USE_KEVENT - struct BUnixSignal_kevent_entry *entries; - int num_entries; - #endif - - #ifdef BADVPN_USE_SELFPIPE - struct BUnixSignal_selfpipe_entry *entries; - int num_entries; - #endif - - DebugObject d_obj; -} BUnixSignal; - -/** - * Initializes the object. - * {@link BLog_Init} must have been done. - * - * WARNING: for every signal number there should be at most one {@link BUnixSignal} - * object handling it (or anything else that could interfere). - * - * This blocks the signal using sigprocmask() and sets up signalfd() for receiving - * signals. - * - * @param o the object - * @param reactor reactor we live in - * @param signals signals to handle. See man 3 sigsetops. - * @param handler handler function to call when a signal is received - * @param user value passed to callback function - * @return 1 on success, 0 on failure - */ -int BUnixSignal_Init (BUnixSignal *o, BReactor *reactor, sigset_t signals, BUnixSignal_handler handler, void *user) WARN_UNUSED; - -/** - * Frees the object. - * - * @param o the object - * @param unblock whether to unblock the signals using sigprocmask(). Not unblocking it - * can be used while the program is exiting gracefully to prevent the - * signals from being handled handled according to its default disposition - * after this function is called. Must be 0 or 1. - */ -void BUnixSignal_Free (BUnixSignal *o, int unblock); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/SocksUdpGwClient.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/SocksUdpGwClient.c deleted file mode 100644 index 93fb019d..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/SocksUdpGwClient.c +++ /dev/null @@ -1,606 +0,0 @@ -/* - * Copyright (C) Ambroz Bizjak - * Contributions: - * Transparent DNS: Copyright (C) Kerem Hadimli - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "misc/debug.h" -#include "base/BLog.h" - -#include "tun2socks/SocksUdpGwClient.h" - -#include "generated/blog_channel_SocksUdpGwClient.h" - -#ifdef BADVPN_SOCKS_UDP_RELAY - -#include "misc/socks_proto.h" -#define CONNECTION_UDP_BUFFER_SIZE 1 - -#else - -static void free_socks (SocksUdpGwClient *o); -static void try_connect (SocksUdpGwClient *o); -static void reconnect_timer_handler (SocksUdpGwClient *o); -static void socks_client_handler (SocksUdpGwClient *o, int event); -static void udpgw_handler_servererror (SocksUdpGwClient *o); -static void udpgw_handler_received (SocksUdpGwClient *o, BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len); - -#endif - -#ifdef BADVPN_SOCKS_UDP_RELAY -static void dgram_handler (SocksUdpGwClient_connection *o, int event); -static void dgram_handler_received (SocksUdpGwClient_connection *o, uint8_t *data, int data_len); -static int conaddr_comparator (void *unused, SocksUdpGwClient_conaddr *v1, SocksUdpGwClient_conaddr *v2); -static SocksUdpGwClient_connection * find_connection (SocksUdpGwClient *o, SocksUdpGwClient_conaddr conaddr); -static SocksUdpGwClient_connection * reuse_connection (SocksUdpGwClient *o, SocksUdpGwClient_conaddr conaddr); -static void connection_send (SocksUdpGwClient_connection *o, const uint8_t *data, int data_len); -static void connection_first_job_handler (SocksUdpGwClient_connection *con); -static SocksUdpGwClient_connection *connection_init (SocksUdpGwClient *client, SocksUdpGwClient_conaddr conaddr, const uint8_t *data, int data_len); -static void connection_free (SocksUdpGwClient_connection *o); - -static void dgram_handler (SocksUdpGwClient_connection *o, int event) -{ - SocksUdpGwClient *client = o->client; - ASSERT(client); - - DebugObject_Access(&client->d_obj); - - BLog(BLOG_INFO, "UDP error"); -} - -static void dgram_handler_received (SocksUdpGwClient_connection *o, uint8_t *data, int data_len) -{ - SocksUdpGwClient *client = o->client; - ASSERT(client); - - DebugObject_Access(&client->d_obj); - ASSERT(data_len >= 0) - ASSERT(data_len <= client->udpgw_mtu) - - // accept packet - PacketPassInterface_Done(&o->udp_recv_if); - - // check header - if (data_len < sizeof(struct socks_udp_header)) { - BLog(BLOG_ERROR, "missing header"); - return; - } - struct socks_udp_header header; - memcpy(&header, data, sizeof(header)); - data += sizeof(header); - data_len -= sizeof(header); - uint8_t frag = header.frag; - uint8_t atyp = header.atyp; - - // check fragment - if (frag) { - BLog(BLOG_ERROR, "unexpected frag"); - return; - } - - // parse address - BAddr remote_addr; - if (atyp == SOCKS_ATYP_IPV6) { - if (data_len < sizeof(struct udpgw_addr_ipv6)) { - BLog(BLOG_ERROR, "missing ipv6 address"); - return; - } - struct udpgw_addr_ipv6 addr_ipv6; - memcpy(&addr_ipv6, data, sizeof(addr_ipv6)); - data += sizeof(addr_ipv6); - data_len -= sizeof(addr_ipv6); - BAddr_InitIPv6(&remote_addr, addr_ipv6.addr_ip, addr_ipv6.addr_port); - } else { - if (data_len < sizeof(struct udpgw_addr_ipv4)) { - BLog(BLOG_ERROR, "missing ipv4 address"); - return; - } - struct udpgw_addr_ipv4 addr_ipv4; - memcpy(&addr_ipv4, data, sizeof(addr_ipv4)); - data += sizeof(addr_ipv4); - data_len -= sizeof(addr_ipv4); - BAddr_InitIPv4(&remote_addr, addr_ipv4.addr_ip, addr_ipv4.addr_port); - } - - // check remote addr - if (!BAddr_Compare(&remote_addr, &o->conaddr.remote_addr)) { - BLog(BLOG_ERROR, "remote addr not match"); - return; - } - - // check remaining data - if (data_len > client->udp_mtu) { - BLog(BLOG_ERROR, "too much data"); - return; - } - - // submit to user - client->handler_received(client->user, o->conaddr.local_addr, remote_addr, data, data_len); -} - -static int conaddr_comparator (void *unused, SocksUdpGwClient_conaddr *v1, SocksUdpGwClient_conaddr *v2) -{ - int r = BAddr_CompareOrder(&v1->remote_addr, &v2->remote_addr); - if (r) { - return r; - } - return BAddr_CompareOrder(&v1->local_addr, &v2->local_addr); -} - -static SocksUdpGwClient_connection * find_connection (SocksUdpGwClient *o, SocksUdpGwClient_conaddr conaddr) -{ - BAVLNode *tree_node = BAVL_LookupExact(&o->connections_tree, &conaddr); - if (!tree_node) { - return NULL; - } - - return UPPER_OBJECT(tree_node, SocksUdpGwClient_connection, connections_tree_node); -} - -static SocksUdpGwClient_connection * reuse_connection (SocksUdpGwClient *o, SocksUdpGwClient_conaddr conaddr) -{ - ASSERT(!find_connection(o, conaddr)) - ASSERT(o->num_connections > 0) - - // get least recently used connection - SocksUdpGwClient_connection *con = UPPER_OBJECT(LinkedList1_GetFirst(&o->connections_list), SocksUdpGwClient_connection, connections_list_node); - - // remove from connections tree by conaddr - BAVL_Remove(&o->connections_tree, &con->connections_tree_node); - - // set new conaddr - con->conaddr = conaddr; - - // insert to connections tree by conaddr - ASSERT_EXECUTE(BAVL_Insert(&o->connections_tree, &con->connections_tree_node, NULL)) - - return con; -} - -static void connection_send (SocksUdpGwClient_connection *o, const uint8_t *data, int data_len) -{ - // get buffer location - uint8_t *out; - if (!BufferWriter_StartPacket(&o->udp_send_writer, &out)) { - BLog(BLOG_ERROR, "out of UDP buffer"); - return; - } - int out_pos = 0; - - // write header - BAddr remote_addr = o->conaddr.remote_addr; - struct socks_udp_header header; - header.rsv = 0; - header.frag = 0; - if (remote_addr.type == BADDR_TYPE_IPV4) { - header.atyp = SOCKS_ATYP_IPV4; - } else { - header.atyp = SOCKS_ATYP_IPV6; - } - memcpy(out + out_pos, &header, sizeof(header)); - out_pos += sizeof(header); - - // write address - switch (remote_addr.type) { - case BADDR_TYPE_IPV4: { - struct udpgw_addr_ipv4 addr_ipv4; - addr_ipv4.addr_ip = remote_addr.ipv4.ip; - addr_ipv4.addr_port = remote_addr.ipv4.port; - memcpy(out + out_pos, &addr_ipv4, sizeof(addr_ipv4)); - out_pos += sizeof(addr_ipv4); - } break; - case BADDR_TYPE_IPV6: { - struct udpgw_addr_ipv6 addr_ipv6; - memcpy(addr_ipv6.addr_ip, remote_addr.ipv6.ip, sizeof(addr_ipv6.addr_ip)); - addr_ipv6.addr_port = remote_addr.ipv6.port; - memcpy(out + out_pos, &addr_ipv6, sizeof(addr_ipv6)); - out_pos += sizeof(addr_ipv6); - } break; - } - - // write packet to buffer - memcpy(out + out_pos, data, data_len); - out_pos += data_len; - - // submit written message - BufferWriter_EndPacket(&o->udp_send_writer, out_pos); -} - -static void connection_first_job_handler (SocksUdpGwClient_connection *con) -{ - connection_send(con, con->first_data, con->first_data_len); -} - -static SocksUdpGwClient_connection *connection_init (SocksUdpGwClient *client, SocksUdpGwClient_conaddr conaddr, const uint8_t *data, int data_len) -{ - // allocate structure - SocksUdpGwClient_connection *o = (SocksUdpGwClient_connection *) malloc(sizeof(*o)); - if (!o) { - BLog(BLOG_ERROR, "malloc failed"); - goto fail; - } - - // init arguments - o->client = client; - o->conaddr = conaddr; - o->first_data = data; - o->first_data_len = data_len; - - // init first job - BPending_Init(&o->first_job, BReactor_PendingGroup(client->reactor), (BPending_handler)connection_first_job_handler, o); - BPending_Set(&o->first_job); - - // init UDP dgram - if (!BDatagram_Init(&o->udp_dgram, client->remote_udpgw_addr.type, client->reactor, o, (BDatagram_handler)dgram_handler)) { - goto fail0; - } - - // set SO_REUSEADDR - if (!BDatagram_SetReuseAddr(&o->udp_dgram, 1)) { - BLog(BLOG_ERROR, "set SO_REUSEADDR failed"); - goto fail1; - } - - // set UDP dgram send address - BIPAddr ipaddr; - memset(&ipaddr, 0, sizeof(ipaddr)); - ipaddr.type = client->remote_udpgw_addr.type; - BDatagram_SetSendAddrs(&o->udp_dgram, client->remote_udpgw_addr, ipaddr); - - // init UDP dgram interfaces - BDatagram_SendAsync_Init(&o->udp_dgram, client->udp_mtu); - BDatagram_RecvAsync_Init(&o->udp_dgram, client->udp_mtu); - - // init UDP writer - BufferWriter_Init(&o->udp_send_writer, client->udp_mtu, BReactor_PendingGroup(client->reactor)); - - // init UDP buffer - if (!PacketBuffer_Init(&o->udp_send_buffer, BufferWriter_GetOutput(&o->udp_send_writer), BDatagram_SendAsync_GetIf(&o->udp_dgram), CONNECTION_UDP_BUFFER_SIZE, BReactor_PendingGroup(client->reactor))) { - BLog(BLOG_ERROR, "PacketBuffer_Init failed"); - goto fail2; - } - - // init UDP recv interface - PacketPassInterface_Init(&o->udp_recv_if, client->udp_mtu, (PacketPassInterface_handler_send)dgram_handler_received, o, BReactor_PendingGroup(client->reactor)); - - // init UDP recv buffer - if (!SinglePacketBuffer_Init(&o->udp_recv_buffer, BDatagram_RecvAsync_GetIf(&o->udp_dgram), &o->udp_recv_if, BReactor_PendingGroup(client->reactor))) { - BLog(BLOG_ERROR, "SinglePacketBuffer_Init failed"); - goto fail3; - } - - // insert to connections tree by conaddr - ASSERT_EXECUTE(BAVL_Insert(&client->connections_tree, &o->connections_tree_node, NULL)); - - // insert to connections list - LinkedList1_Append(&client->connections_list, &o->connections_list_node); - - // increment number of connections - client->num_connections++; - - // succeed to init - return o; - -fail3: - PacketPassInterface_Free(&o->udp_recv_if); - PacketBuffer_Free(&o->udp_send_buffer); -fail2: - BufferWriter_Free(&o->udp_send_writer); - BDatagram_RecvAsync_Free(&o->udp_dgram); - BDatagram_SendAsync_Free(&o->udp_dgram); -fail1: - BDatagram_Free(&o->udp_dgram); - -fail0: - BPending_Free(&o->first_job); - free(o); -fail: - return NULL; -} - -static void connection_free (SocksUdpGwClient_connection *o) -{ - SocksUdpGwClient *client = o->client; - - // decrement number of connections - client->num_connections--; - - // remove from connections list - LinkedList1_Remove(&client->connections_list, &o->connections_list_node); - - // remove from connections tree by conaddr - BAVL_Remove(&client->connections_tree, &o->connections_tree_node); - - // free UDP receive buffer - SinglePacketBuffer_Free(&o->udp_recv_buffer); - - // free UDP receive interface - PacketPassInterface_Free(&o->udp_recv_if); - - // free UDP buffer - PacketBuffer_Free(&o->udp_send_buffer); - - // free UDP writer - BufferWriter_Free(&o->udp_send_writer); - - // free UDP dgram interfaces - BDatagram_RecvAsync_Free(&o->udp_dgram); - BDatagram_SendAsync_Free(&o->udp_dgram); - - // free UDP dgram - BDatagram_Free(&o->udp_dgram); - - // free structure - free(o); -} - -#else - -static void free_socks (SocksUdpGwClient *o) -{ - ASSERT(o->have_socks) - - // disconnect udpgw client from SOCKS - if (o->socks_up) { - UdpGwClient_DisconnectServer(&o->udpgw_client); - } - - // free SOCKS client - BSocksClient_Free(&o->socks_client); - - // set have no SOCKS - o->have_socks = 0; -} - -static void try_connect (SocksUdpGwClient *o) -{ - ASSERT(!o->have_socks) - ASSERT(!BTimer_IsRunning(&o->reconnect_timer)) - - // init SOCKS client - if (!BSocksClient_Init(&o->socks_client, o->socks_server_addr, o->auth_info, o->num_auth_info, o->remote_udpgw_addr, (BSocksClient_handler)socks_client_handler, o, o->reactor)) { - BLog(BLOG_ERROR, "BSocksClient_Init failed"); - goto fail0; - } - - // set have SOCKS - o->have_socks = 1; - - // set SOCKS not up - o->socks_up = 0; - - return; - -fail0: - // set reconnect timer - BReactor_SetTimer(o->reactor, &o->reconnect_timer); -} - -static void reconnect_timer_handler (SocksUdpGwClient *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(!o->have_socks) - - // try connecting - try_connect(o); -} - -static void socks_client_handler (SocksUdpGwClient *o, int event) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->have_socks) - - switch (event) { - case BSOCKSCLIENT_EVENT_UP: { - ASSERT(!o->socks_up) - - BLog(BLOG_INFO, "SOCKS up"); - - // connect udpgw client to SOCKS - if (!UdpGwClient_ConnectServer(&o->udpgw_client, BSocksClient_GetSendInterface(&o->socks_client), BSocksClient_GetRecvInterface(&o->socks_client))) { - BLog(BLOG_ERROR, "UdpGwClient_ConnectServer failed"); - goto fail0; - } - - // set SOCKS up - o->socks_up = 1; - - return; - - fail0: - // free SOCKS - free_socks(o); - - // set reconnect timer - BReactor_SetTimer(o->reactor, &o->reconnect_timer); - } break; - - case BSOCKSCLIENT_EVENT_ERROR: - case BSOCKSCLIENT_EVENT_ERROR_CLOSED: { - BLog(BLOG_INFO, "SOCKS error"); - - // free SOCKS - free_socks(o); - - // set reconnect timer - BReactor_SetTimer(o->reactor, &o->reconnect_timer); - } break; - - default: ASSERT(0); - } -} - -static void udpgw_handler_servererror (SocksUdpGwClient *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->have_socks) - ASSERT(o->socks_up) - - BLog(BLOG_ERROR, "client reports server error"); - - // free SOCKS - free_socks(o); - - // set reconnect timer - BReactor_SetTimer(o->reactor, &o->reconnect_timer); -} - -static void udpgw_handler_received (SocksUdpGwClient *o, BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len) -{ - DebugObject_Access(&o->d_obj); - - // submit to user - o->handler_received(o->user, local_addr, remote_addr, data, data_len); - return; -} - -#endif - -int SocksUdpGwClient_Init (SocksUdpGwClient *o, int udp_mtu, int max_connections, int send_buffer_size, btime_t keepalive_time, BAddr socks_server_addr, const struct BSocksClient_auth_info *auth_info, size_t num_auth_info, - BAddr remote_udpgw_addr, btime_t reconnect_time, BReactor *reactor, void *user, - SocksUdpGwClient_handler_received handler_received) -{ - // see asserts in UdpGwClient_Init -// ASSERT(!BAddr_IsInvalid(&socks_server_addr)) -#ifndef BADVPN_SOCKS_UDP_RELAY - ASSERT(remote_udpgw_addr.type == BADDR_TYPE_IPV4 || remote_udpgw_addr.type == BADDR_TYPE_IPV6) -#endif - - // init arguments - o->udp_mtu = udp_mtu; - o->socks_server_addr = socks_server_addr; - o->auth_info = auth_info; - o->num_auth_info = num_auth_info; - o->remote_udpgw_addr = remote_udpgw_addr; - o->reactor = reactor; - o->user = user; - o->handler_received = handler_received; - -#ifdef BADVPN_SOCKS_UDP_RELAY - // compute MTUs - o->udpgw_mtu = udpgw_compute_mtu(o->udp_mtu); - o->max_connections = max_connections; - - // limit max connections to number of conid's - if (o->max_connections > UINT16_MAX + 1) { - o->max_connections = UINT16_MAX + 1; - } - - // init connections tree by conaddr - BAVL_Init(&o->connections_tree, OFFSET_DIFF(SocksUdpGwClient_connection, conaddr, connections_tree_node), (BAVL_comparator)conaddr_comparator, NULL); - - // init connections list - LinkedList1_Init(&o->connections_list); -#else - // init udpgw client - if (!UdpGwClient_Init(&o->udpgw_client, udp_mtu, max_connections, send_buffer_size, keepalive_time, o->reactor, o, - (UdpGwClient_handler_servererror)udpgw_handler_servererror, - (UdpGwClient_handler_received)udpgw_handler_received - )) { - goto fail0; - } - - // init reconnect timer - BTimer_Init(&o->reconnect_timer, reconnect_time, (BTimer_handler)reconnect_timer_handler, o); - - // set have no SOCKS - o->have_socks = 0; - - // try connecting - try_connect(o); -#endif - - DebugObject_Init(&o->d_obj); - return 1; - -fail0: - return 0; -} - -void SocksUdpGwClient_Free (SocksUdpGwClient *o) -{ - DebugObject_Free(&o->d_obj); - -#ifdef BADVPN_SOCKS_UDP_RELAY - // free connections - while (!LinkedList1_IsEmpty(&o->connections_list)) { - SocksUdpGwClient_connection *con = UPPER_OBJECT(LinkedList1_GetFirst(&o->connections_list), SocksUdpGwClient_connection, connections_list_node); - connection_free(con); - } -#else - // free SOCKS - if (o->have_socks) { - free_socks(o); - } - - // free reconnect timer - BReactor_RemoveTimer(o->reactor, &o->reconnect_timer); - - // free udpgw client - UdpGwClient_Free(&o->udpgw_client); -#endif -} - -void SocksUdpGwClient_SubmitPacket (SocksUdpGwClient *o, BAddr local_addr, BAddr remote_addr, int is_dns, const uint8_t *data, int data_len) -{ - DebugObject_Access(&o->d_obj); - // see asserts in UdpGwClient_SubmitPacket - -#ifdef BADVPN_SOCKS_UDP_RELAY - ASSERT(local_addr.type == BADDR_TYPE_IPV4 || local_addr.type == BADDR_TYPE_IPV6) - ASSERT(remote_addr.type == BADDR_TYPE_IPV4 || remote_addr.type == BADDR_TYPE_IPV6) - ASSERT(data_len >= 0) - ASSERT(data_len <= o->udp_mtu) - - // build conaddr - SocksUdpGwClient_conaddr conaddr; - conaddr.local_addr = local_addr; - conaddr.remote_addr = remote_addr; - - // lookup connection - SocksUdpGwClient_connection *con = find_connection(o, conaddr); - - // if no connection and can't create a new one, reuse the least recently used une - if (!con && o->num_connections == o->max_connections) { - con = reuse_connection(o, conaddr); - } - - if (!con) { - // create new connection - con = connection_init(o, conaddr, data, data_len); - } else { - // move connection to front of the list - LinkedList1_Remove(&o->connections_list, &con->connections_list_node); - LinkedList1_Append(&o->connections_list, &con->connections_list_node); - - // send packet to existing connection - connection_send(con, data, data_len); - } -#else - // submit to udpgw client - UdpGwClient_SubmitPacket(&o->udpgw_client, local_addr, remote_addr, is_dns, data, data_len); -#endif -} - diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/SocksUdpGwClient.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/SocksUdpGwClient.h deleted file mode 100644 index f69df1f9..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/SocksUdpGwClient.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) Ambroz Bizjak - * Contributions: - * Transparent DNS: Copyright (C) Kerem Hadimli - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_TUN2SOCKS_SOCKSUDPGWCLIENT_H -#define BADVPN_TUN2SOCKS_SOCKSUDPGWCLIENT_H - -#include "misc/debug.h" -#include "base/DebugObject.h" -#include "system/BReactor.h" -#ifdef BADVPN_SOCKS_UDP_RELAY -#include -#include -#include -#include -#include -#include -#include -#include -#include -#else -#include "udpgw_client/UdpGwClient.h" -#include "socksclient/BSocksClient.h" -#endif - -typedef void (*SocksUdpGwClient_handler_received) (void *user, BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len); - -typedef struct { - int udp_mtu; - BAddr socks_server_addr; - const struct BSocksClient_auth_info *auth_info; - size_t num_auth_info; - BAddr remote_udpgw_addr; - BReactor *reactor; - void *user; - SocksUdpGwClient_handler_received handler_received; -#ifdef BADVPN_SOCKS_UDP_RELAY - int udpgw_mtu; - int num_connections; - int max_connections; - BAVL connections_tree; - LinkedList1 connections_list; -#else - UdpGwClient udpgw_client; - BTimer reconnect_timer; - int have_socks; - BSocksClient socks_client; - int socks_up; -#endif - DebugObject d_obj; -} SocksUdpGwClient; - -#ifdef BADVPN_SOCKS_UDP_RELAY -typedef struct { - BAddr local_addr; - BAddr remote_addr; -} SocksUdpGwClient_conaddr; - -typedef struct { - SocksUdpGwClient *client; - SocksUdpGwClient_conaddr conaddr; - BPending first_job; - const uint8_t *first_data; - int first_data_len; - BDatagram udp_dgram; - BufferWriter udp_send_writer; - PacketBuffer udp_send_buffer; - SinglePacketBuffer udp_recv_buffer; - PacketPassInterface udp_recv_if; - BAVLNode connections_tree_node; - LinkedList1Node connections_list_node; -} SocksUdpGwClient_connection; -#endif - -int SocksUdpGwClient_Init (SocksUdpGwClient *o, int udp_mtu, int max_connections, int send_buffer_size, btime_t keepalive_time, BAddr socks_server_addr, const struct BSocksClient_auth_info *auth_info, size_t num_auth_info, - BAddr remote_udpgw_addr, btime_t reconnect_time, BReactor *reactor, void *user, - SocksUdpGwClient_handler_received handler_received) WARN_UNUSED; -void SocksUdpGwClient_Free (SocksUdpGwClient *o); -void SocksUdpGwClient_SubmitPacket (SocksUdpGwClient *o, BAddr local_addr, BAddr remote_addr, int is_dns, const uint8_t *data, int data_len); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/tun2socks.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/tun2socks.c deleted file mode 100644 index 4e07999a..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/tun2socks.c +++ /dev/null @@ -1,1955 +0,0 @@ -/* - * Copyright (C) Ambroz Bizjak - * Contributions: - * Transparent DNS: Copyright (C) Kerem Hadimli - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "misc/version.h" -#include "misc/loggers_string.h" -#include "misc/loglevel.h" -#include "misc/minmax.h" -#include "misc/offset.h" -#include "misc/dead.h" -#include "misc/ipv4_proto.h" -#include "misc/ipv6_proto.h" -#include "misc/udp_proto.h" -#include "misc/byteorder.h" -#include "misc/balloc.h" -#include "misc/open_standard_streams.h" -#include "misc/read_file.h" -#include "misc/ipaddr6.h" -#include "misc/concat_strings.h" -#include "structure/LinkedList1.h" -#include "base/BLog.h" -#include "system/BReactor.h" -#include "system/BSignal.h" -#include "system/BAddr.h" -#include "system/BNetwork.h" -#include "flow/SinglePacketBuffer.h" -#include "socksclient/BSocksClient.h" -#include "tuntap/BTap.h" -#include "lwip/init.h" -#include "lwip/tcp_impl.h" -#include "lwip/netif.h" -#include "lwip/tcp.h" -#include "tun2socks/SocksUdpGwClient.h" -//#include - -#ifndef BADVPN_USE_WINAPI -#include "base/BLog_syslog.h" -#endif - -#include "tun2socks/tun2socks.h" - -#include "generated/blog_channel_tun2socks.h" - -#define LOGGER_STDOUT 1 -#define LOGGER_SYSLOG 2 - -#define SYNC_DECL \ - BPending sync_mark; \ - -#define SYNC_FROMHERE \ - BPending_Init(&sync_mark, BReactor_PendingGroup(&ss), NULL, NULL); \ - BPending_Set(&sync_mark); - -#define SYNC_BREAK \ - BPending_Free(&sync_mark); - -#define SYNC_COMMIT \ - BReactor_Synchronize(&ss, &sync_mark.base); \ - BPending_Free(&sync_mark); - -// command-line options -struct { - int help; - int version; - int logger; - #ifndef BADVPN_USE_WINAPI - char *logger_syslog_facility; - char *logger_syslog_ident; - #endif - int loglevel; - int loglevels[BLOG_NUM_CHANNELS]; - int fd; - int mtu; - char *netif_ipaddr; - char *netif_netmask; - char *netif_ip6addr; - char *socks_server_addr; - char *username; - char *password; - char *password_file; - int append_source_to_username; - char *udpgw_remote_server_addr; - int udpgw_max_connections; - int udpgw_connection_buffer_size; - int udpgw_transparent_dns; -} options; - -// TCP client -struct tcp_client { - dead_t dead; - dead_t dead_client; - LinkedList1Node list_node; - BAddr local_addr; - BAddr remote_addr; - struct tcp_pcb *pcb; - int client_closed; - uint8_t buf[TCP_WND]; - int buf_used; - char *socks_username; - BSocksClient socks_client; - int socks_up; - int socks_closed; - StreamPassInterface *socks_send_if; - StreamRecvInterface *socks_recv_if; - uint8_t socks_recv_buf[CLIENT_SOCKS_RECV_BUF_SIZE]; - int socks_recv_buf_used; - int socks_recv_buf_sent; - int socks_recv_waiting; - int socks_recv_tcp_pending; -}; - -// IP address of netif -BIPAddr netif_ipaddr; - -// netmask of netif -BIPAddr netif_netmask; - -// IP6 address of netif -struct ipv6_addr netif_ip6addr; - -// SOCKS server address -BAddr socks_server_addr; - -// allocated password file contents -uint8_t *password_file_contents; - -// SOCKS authentication information -struct BSocksClient_auth_info socks_auth_info[2]; -size_t socks_num_auth_info; - -// remote udpgw server addr, if provided -BAddr udpgw_remote_server_addr; - -// reactor -BReactor ss; - -// set to 1 by terminate -int quitting; - -// TUN device -BTap device; - -// device write buffer -uint8_t *device_write_buf; - -// device reading -SinglePacketBuffer device_read_buffer; -PacketPassInterface device_read_interface; - -// udpgw client -SocksUdpGwClient udpgw_client; -int udp_mtu; - -// TCP timer -BTimer tcp_timer; - -// job for initializing lwip -BPending lwip_init_job; - -// lwip netif -int have_netif; -struct netif the_netif; - -// lwip TCP listener -struct tcp_pcb *listener; - -// lwip TCP/IPv6 listener -struct tcp_pcb *listener_ip6; - -// TCP clients -LinkedList1 tcp_clients; - -// number of clients -int num_clients; - -static void terminate (void); -static void print_help (const char *name); -static void print_version (void); -static int parse_arguments (int argc, char *argv[]); -static int process_arguments (void); -static void signal_handler (void *unused); -static BAddr baddr_from_lwip (int is_ipv6, const ipX_addr_t *ipx_addr, uint16_t port_hostorder); -static void lwip_init_job_hadler (void *unused); -static void tcp_timer_handler (void *unused); -static void device_error_handler (void *unused); -static void device_read_handler_send (void *unused, uint8_t *data, int data_len); -static int process_device_udp_packet (uint8_t *data, int data_len); -static err_t netif_init_func (struct netif *netif); -static err_t netif_output_func (struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr); -//static err_t netif_output_ip6_func (struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr); -static err_t common_netif_output (struct netif *netif, struct pbuf *p); -static err_t netif_input_func (struct pbuf *p, struct netif *inp); -static void client_logfunc (struct tcp_client *client); -static void client_log (struct tcp_client *client, int level, const char *fmt, ...); -static err_t listener_accept_func (void *arg, struct tcp_pcb *newpcb, err_t err); -static void client_handle_freed_client (struct tcp_client *client); -static void client_free_client (struct tcp_client *client); -static void client_abort_client (struct tcp_client *client); -static void client_free_socks (struct tcp_client *client); -static void client_murder (struct tcp_client *client); -static void client_dealloc (struct tcp_client *client); -static void client_err_func (void *arg, err_t err); -static err_t client_recv_func (void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err); -static void client_socks_handler (struct tcp_client *client, int event); -static void client_send_to_socks (struct tcp_client *client); -static void client_socks_send_handler_done (struct tcp_client *client, int data_len); -static void client_socks_recv_initiate (struct tcp_client *client); -static void client_socks_recv_handler_done (struct tcp_client *client, int data_len); -static int client_socks_recv_send_out (struct tcp_client *client); -static err_t client_sent_func (void *arg, struct tcp_pcb *tpcb, u16_t len); -static void udpgw_client_handler_received (void *unused, BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len); - -int tun2socks_main (int argc, char **argv, int fd, int mtu) -{ - if (argc <= 0) { - return 1; - } - - // open standard streams - open_standard_streams(); - - // parse command-line arguments - if (!parse_arguments(argc, argv)) { - fprintf(stderr, "Failed to parse arguments\n"); - print_help(argv[0]); - goto fail0; - } - - options.fd = fd; - options.mtu = mtu; - // handle --help and --version - if (options.help) { - print_version(); - print_help(argv[0]); - return 0; - } - if (options.version) { - print_version(); - return 0; - } - - // initialize logger - switch (options.logger) { - case LOGGER_STDOUT: - BLog_InitStdout(); - break; - #ifndef BADVPN_USE_WINAPI - case LOGGER_SYSLOG: - if (!BLog_InitSyslog(options.logger_syslog_ident, options.logger_syslog_facility)) { - fprintf(stderr, "Failed to initialize syslog logger\n"); - goto fail0; - } - break; - #endif - default: - ASSERT(0); - } - - // configure logger channels - for (int i = 0; i < BLOG_NUM_CHANNELS; i++) { - if (options.loglevels[i] >= 0) { - BLog_SetChannelLoglevel(i, options.loglevels[i]); - } - else if (options.loglevel >= 0) { - BLog_SetChannelLoglevel(i, options.loglevel); - } - } - - BLog(BLOG_NOTICE, "initializing "GLOBAL_PRODUCT_NAME" "PROGRAM_NAME" "GLOBAL_VERSION); - - // clear password contents pointer - password_file_contents = NULL; - - // initialize network - if (!BNetwork_GlobalInit()) { - BLog(BLOG_ERROR, "BNetwork_GlobalInit failed"); - goto fail1; - } - - // process arguments - if (!process_arguments()) { - BLog(BLOG_ERROR, "Failed to process arguments"); - goto fail1; - } - - // init time - BTime_Init(); - - // init reactor - if (!BReactor_Init(&ss)) { - BLog(BLOG_ERROR, "BReactor_Init failed"); - goto fail1; - } - - // set not quitting - quitting = 0; - -// // setup signal handler -// if (!BSignal_Init(&ss, signal_handler, NULL)) { -// BLog(BLOG_ERROR, "BSignal_Init failed"); -// goto fail2; -// } - - struct BTap_init_data init_data; - init_data.dev_type = BTAP_DEV_TUN ; - init_data.init_type = BTAP_INIT_FD; - init_data.init.fd.fd = fd; - init_data.init.fd.mtu = mtu; - - if (!BTap_Init2(&device, &ss, init_data, device_error_handler, NULL)) { - // init TUN device -// if (!BTap_Init(&device, &ss, options.fd, options.mtu, device_error_handler, NULL, 1)) { - BLog(BLOG_ERROR, "BTap_Init failed"); - goto fail2; - } - - // NOTE: the order of the following is important: - // first device writing must evaluate, - // then lwip (so it can send packets to the device), - // then device reading (so it can pass received packets to lwip). - - // init device reading - PacketPassInterface_Init(&device_read_interface, BTap_GetMTU(&device), device_read_handler_send, NULL, BReactor_PendingGroup(&ss)); - if (!SinglePacketBuffer_Init(&device_read_buffer, BTap_GetOutput(&device), &device_read_interface, BReactor_PendingGroup(&ss))) { - BLog(BLOG_ERROR, "SinglePacketBuffer_Init failed"); - goto fail4; - } - - if (options.udpgw_remote_server_addr) { - // compute maximum UDP payload size we need to pass through udpgw - udp_mtu = BTap_GetMTU(&device) - (int)(sizeof(struct ipv4_header) + sizeof(struct udp_header)); - if (options.netif_ip6addr) { - int udp_ip6_mtu = BTap_GetMTU(&device) - (int)(sizeof(struct ipv6_header) + sizeof(struct udp_header)); - if (udp_mtu < udp_ip6_mtu) { - udp_mtu = udp_ip6_mtu; - } - } - if (udp_mtu < 0) { - udp_mtu = 0; - } - - // make sure our UDP payloads aren't too large for udpgw - int udpgw_mtu = udpgw_compute_mtu(udp_mtu); - if (udpgw_mtu < 0 || udpgw_mtu > PACKETPROTO_MAXPAYLOAD) { - BLog(BLOG_ERROR, "device MTU is too large for UDP"); - goto fail4a; - } - - // init udpgw client - if (!SocksUdpGwClient_Init(&udpgw_client, udp_mtu, DEFAULT_UDPGW_MAX_CONNECTIONS, options.udpgw_connection_buffer_size, UDPGW_KEEPALIVE_TIME, socks_server_addr, socks_auth_info, socks_num_auth_info, udpgw_remote_server_addr, UDPGW_RECONNECT_TIME, &ss, NULL, udpgw_client_handler_received)) { - BLog(BLOG_ERROR, "SocksUdpGwClient_Init failed"); - goto fail4a; - } - } - - // init lwip init job - BPending_Init(&lwip_init_job, BReactor_PendingGroup(&ss), lwip_init_job_hadler, NULL); - BPending_Set(&lwip_init_job); - - // init device write buffer - if (!(device_write_buf = (uint8_t *)BAlloc(BTap_GetMTU(&device)))) { - BLog(BLOG_ERROR, "BAlloc failed"); - goto fail5; - } - - // init TCP timer - // it won't trigger before lwip is initialized, becuase the lwip init is a job - BTimer_Init(&tcp_timer, TCP_TMR_INTERVAL, tcp_timer_handler, NULL); - BReactor_SetTimer(&ss, &tcp_timer); - - // set no netif - have_netif = 0; - - // set no listener - listener = NULL; - listener_ip6 = NULL; - - // init clients list - LinkedList1_Init(&tcp_clients); - - // init number of clients - num_clients = 0; - - // enter event loop - BLog(BLOG_NOTICE, "entering event loop"); - BReactor_Exec(&ss); - - // free clients - LinkedList1Node *node; - while ((node = LinkedList1_GetFirst(&tcp_clients)) != NULL) { - struct tcp_client *client = UPPER_OBJECT(node, struct tcp_client, list_node); - client_murder(client); - } - - // free listener - if (listener_ip6) { - tcp_close(listener_ip6); - } - if (listener) { - tcp_close(listener); - } - - // free netif - if (have_netif) { - netif_remove(&the_netif); - } - - BReactor_RemoveTimer(&ss, &tcp_timer); - BFree(device_write_buf); -fail5: - BPending_Free(&lwip_init_job); - if (options.udpgw_remote_server_addr) { - SocksUdpGwClient_Free(&udpgw_client); - } -fail4a: - SinglePacketBuffer_Free(&device_read_buffer); -fail4: - PacketPassInterface_Free(&device_read_interface); - BTap_Free(&device); -//fail3: -// BSignal_Finish(); -fail2: - BReactor_Free(&ss); -fail1: - BFree(password_file_contents); - BLog(BLOG_NOTICE, "exiting"); - BLog_Free(); -fail0: - DebugObjectGlobal_Finish(); - - return 1; -} - -void stop_tun2socks() { - terminate(); -} - -void terminate (void) -{ - ASSERT(!quitting) - - BLog(BLOG_NOTICE, "tearing down"); - - // set quitting - quitting = 1; - - // exit event loop - BReactor_Quit(&ss, 1); -} - -void print_help (const char *name) -{ - printf( - "Usage:\n" - " %s\n" - " [--help]\n" - " [--version]\n" - " [--logger <"LOGGERS_STRING">]\n" - #ifndef BADVPN_USE_WINAPI - " (logger=syslog?\n" - " [--syslog-facility ]\n" - " [--syslog-ident ]\n" - " )\n" - #endif - " [--loglevel <0-5/none/error/warning/notice/info/debug>]\n" - " [--channel-loglevel <0-5/none/error/warning/notice/info/debug>] ...\n" - " [--tundev ]\n" - " --netif-ipaddr \n" - " --netif-netmask \n" - " --socks-server-addr \n" - " [--netif-ip6addr ]\n" - " [--username ]\n" - " [--password ]\n" - " [--password-file ]\n" - " [--append-source-to-username]\n" -#ifdef BADVPN_SOCKS_UDP_RELAY - " [--enable-udprelay]\n" - " [--udprelay-max-connections ]\n" -#else - " [--udpgw-remote-server-addr ]\n" - " [--udpgw-max-connections ]\n" - " [--udpgw-connection-buffer-size ]\n" - " [--udpgw-transparent-dns]\n" -#endif - "Address format is a.b.c.d:port (IPv4) or [addr]:port (IPv6).\n", - name - ); -} - -void print_version (void) -{ - printf(GLOBAL_PRODUCT_NAME" "PROGRAM_NAME" "GLOBAL_VERSION"\n"GLOBAL_COPYRIGHT_NOTICE"\n"); -} - -int parse_arguments (int argc, char *argv[]) -{ - if (argc <= 0) { - return 0; - } - - options.help = 0; - options.version = 0; - options.logger = LOGGER_STDOUT; - #ifndef BADVPN_USE_WINAPI - options.logger_syslog_facility = "daemon"; - options.logger_syslog_ident = argv[0]; - #endif - options.loglevel = -1; - for (int i = 0; i < BLOG_NUM_CHANNELS; i++) { - options.loglevels[i] = -1; - } - options.fd = 0; - options.mtu = 4096; - options.netif_ipaddr = NULL; - options.netif_netmask = NULL; - options.netif_ip6addr = NULL; - options.socks_server_addr = NULL; - options.username = NULL; - options.password = NULL; - options.password_file = NULL; - options.append_source_to_username = 0; - options.udpgw_remote_server_addr = NULL; - options.udpgw_max_connections = DEFAULT_UDPGW_MAX_CONNECTIONS; - options.udpgw_connection_buffer_size = DEFAULT_UDPGW_CONNECTION_BUFFER_SIZE; - options.udpgw_transparent_dns = 0; - - int i; - for (i = 1; i < argc; i++) { - char *arg = argv[i]; - if (!strcmp(arg, "--help")) { - options.help = 1; - } - else if (!strcmp(arg, "--version")) { - options.version = 1; - } - else if (!strcmp(arg, "--logger")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - char *arg2 = argv[i + 1]; - if (!strcmp(arg2, "stdout")) { - options.logger = LOGGER_STDOUT; - } - #ifndef BADVPN_USE_WINAPI - else if (!strcmp(arg2, "syslog")) { - options.logger = LOGGER_SYSLOG; - } - #endif - else { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i++; - } - #ifndef BADVPN_USE_WINAPI - else if (!strcmp(arg, "--syslog-facility")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - options.logger_syslog_facility = argv[i + 1]; - i++; - } - else if (!strcmp(arg, "--syslog-ident")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - options.logger_syslog_ident = argv[i + 1]; - i++; - } - #endif - else if (!strcmp(arg, "--loglevel")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - if ((options.loglevel = parse_loglevel(argv[i + 1])) < 0) { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i++; - } - else if (!strcmp(arg, "--channel-loglevel")) { - if (2 >= argc - i) { - fprintf(stderr, "%s: requires two arguments\n", arg); - return 0; - } - int channel = BLogGlobal_GetChannelByName(argv[i + 1]); - if (channel < 0) { - fprintf(stderr, "%s: wrong channel argument\n", arg); - return 0; - } - int loglevel = parse_loglevel(argv[i + 2]); - if (loglevel < 0) { - fprintf(stderr, "%s: wrong loglevel argument\n", arg); - return 0; - } - options.loglevels[channel] = loglevel; - i += 2; - } - else if (!strcmp(arg, "--netif-ipaddr")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - options.netif_ipaddr = argv[i + 1]; - i++; - } - else if (!strcmp(arg, "--netif-netmask")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - options.netif_netmask = argv[i + 1]; - i++; - } - else if (!strcmp(arg, "--netif-ip6addr")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - options.netif_ip6addr = argv[i + 1]; - i++; - } - else if (!strcmp(arg, "--socks-server-addr")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - options.socks_server_addr = argv[i + 1]; - i++; - } - else if (!strcmp(arg, "--username")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - options.username = argv[i + 1]; - i++; - } - else if (!strcmp(arg, "--password")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - options.password = argv[i + 1]; - i++; - } - else if (!strcmp(arg, "--password-file")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - options.password_file = argv[i + 1]; - i++; - } - else if (!strcmp(arg, "--append-source-to-username")) { - options.append_source_to_username = 1; - } -#ifdef BADVPN_SOCKS_UDP_RELAY - else if (!strcmp(arg, "--udpgw-remote-server-addr")) { -// options.udpgw_remote_server_addr = "0.0.0.0:0"; - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - options.udpgw_remote_server_addr = argv[i + 1]; - i++; -#else - else if (!strcmp(arg, "--udpgw-remote-server-addr")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - options.udpgw_remote_server_addr = argv[i + 1]; - i++; -#endif - } -#ifdef BADVPN_SOCKS_UDP_RELAY - else if (!strcmp(arg, "--udprelay-max-connections")) { -#else - else if (!strcmp(arg, "--udpgw-max-connections")) { -#endif - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - if ((options.udpgw_max_connections = atoi(argv[i + 1])) <= 0) { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i++; - } -#ifndef BADVPN_SOCKS_UDP_RELAY - else if (!strcmp(arg, "--udpgw-connection-buffer-size")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - if ((options.udpgw_connection_buffer_size = atoi(argv[i + 1])) <= 0) { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i++; - } - else if (!strcmp(arg, "--udpgw-transparent-dns")) { - options.udpgw_transparent_dns = 1; - } -#endif - else { - fprintf(stderr, "unknown option: %s\n", arg); - return 0; - } - } - - if (options.help || options.version) { - return 1; - } - - if (!options.netif_ipaddr) { - fprintf(stderr, "--netif-ipaddr is required\n"); - return 0; - } - - if (!options.netif_netmask) { - fprintf(stderr, "--netif-netmask is required\n"); - return 0; - } - - if (!options.socks_server_addr) { - fprintf(stderr, "--socks-server-addr is required\n"); - return 0; - } - - if (options.username) { - if (!options.password && !options.password_file) { - fprintf(stderr, "username given but password not given\n"); - return 0; - } - - if (options.password && options.password_file) { - fprintf(stderr, "--password and --password-file cannot both be given\n"); - return 0; - } - } - - return 1; -} - -int process_arguments (void) -{ - ASSERT(!password_file_contents) - - // resolve netif ipaddr - if (!BIPAddr_Resolve(&netif_ipaddr, options.netif_ipaddr, 0)) { - BLog(BLOG_ERROR, "netif ipaddr: BIPAddr_Resolve failed"); - return 0; - } - if (netif_ipaddr.type != BADDR_TYPE_IPV4) { - BLog(BLOG_ERROR, "netif ipaddr: must be an IPv4 address"); - return 0; - } - - // resolve netif netmask - if (!BIPAddr_Resolve(&netif_netmask, options.netif_netmask, 0)) { - BLog(BLOG_ERROR, "netif netmask: BIPAddr_Resolve failed"); - return 0; - } - if (netif_netmask.type != BADDR_TYPE_IPV4) { - BLog(BLOG_ERROR, "netif netmask: must be an IPv4 address"); - return 0; - } - - // parse IP6 address - if (options.netif_ip6addr) { - if (!ipaddr6_parse_ipv6_addr(MemRef_MakeCstr(options.netif_ip6addr), &netif_ip6addr)) { - BLog(BLOG_ERROR, "netif ip6addr: incorrect"); - return 0; - } - } - - // resolve SOCKS server address - if (!BAddr_Parse2(&socks_server_addr, options.socks_server_addr, NULL, 0, 0)) { - BLog(BLOG_ERROR, "socks server addr: BAddr_Parse2 failed"); - return 0; - } - - // add none socks authentication method - socks_auth_info[0] = BSocksClient_auth_none(); - socks_num_auth_info = 1; - - // add password socks authentication method - if (options.username) { - const char *password; - size_t password_len; - if (options.password) { - password = options.password; - password_len = strlen(options.password); - } else { - if (!read_file(options.password_file, &password_file_contents, &password_len)) { - BLog(BLOG_ERROR, "failed to read password file"); - return 0; - } - password = (char *)password_file_contents; - } - - socks_auth_info[socks_num_auth_info++] = BSocksClient_auth_password( - options.username, strlen(options.username), - password, password_len - ); - } - - // resolve remote udpgw server address - if (options.udpgw_remote_server_addr) { - if (!BAddr_Parse2(&udpgw_remote_server_addr, options.udpgw_remote_server_addr, NULL, 0, 0)) { -#ifdef BADVPN_SOCKS_UDP_RELAY - BLog(BLOG_ERROR, "udprelay server addr: BAddr_Parse2 failed"); -#else - BLog(BLOG_ERROR, "remote udpgw server addr: BAddr_Parse2 failed"); -#endif - return 0; - } - } - - return 1; -} - -void signal_handler (void *unused) -{ - ASSERT(!quitting) - - BLog(BLOG_NOTICE, "termination requested"); - - terminate(); -} - -BAddr baddr_from_lwip (int is_ipv6, const ipX_addr_t *ipx_addr, uint16_t port_hostorder) -{ - BAddr addr; -// if (is_ipv6) { -// BAddr_InitIPv6(&addr, (uint8_t *)ipx_addr->ip6.addr, hton16(port_hostorder)); -// } else { - BAddr_InitIPv4(&addr, ipx_addr->addr, hton16(port_hostorder)); -// } - return addr; -} - -void lwip_init_job_hadler (void *unused) -{ - ASSERT(!quitting) - ASSERT(netif_ipaddr.type == BADDR_TYPE_IPV4) - ASSERT(netif_netmask.type == BADDR_TYPE_IPV4) - ASSERT(!have_netif) - ASSERT(!listener) - ASSERT(!listener_ip6) - - BLog(BLOG_DEBUG, "lwip init"); - - // NOTE: the device may fail during this, but there's no harm in not checking - // for that at every step - - // init lwip - lwip_init(); - - // make addresses for netif - ip_addr_t addr; - addr.addr = netif_ipaddr.ipv4; - ip_addr_t netmask; - netmask.addr = netif_netmask.ipv4; - ip_addr_t gw; - ip_addr_set_any(&gw); - - // init netif - if (!netif_add(&the_netif, &addr, &netmask, &gw, NULL, netif_init_func, netif_input_func)) { - BLog(BLOG_ERROR, "netif_add failed"); - goto fail; - } - have_netif = 1; - - // set netif up - netif_set_up(&the_netif); - - // set netif pretend TCP - netif_set_pretend_tcp(&the_netif, 1); - - // set netif default - netif_set_default(&the_netif); - -// if (options.netif_ip6addr) { -// // add IPv6 address -// memcpy(netif_ip6_addr(&the_netif, 0), netif_ip6addr.bytes, sizeof(netif_ip6addr.bytes)); -// netif_ip6_addr_set_state(&the_netif, 0, IP6_ADDR_VALID); -// } - - // init listener - struct tcp_pcb *l = tcp_new(); - if (!l) { - BLog(BLOG_ERROR, "tcp_new failed"); - goto fail; - } - - // bind listener - if (tcp_bind_to_netif(l, "ho0") != ERR_OK) { - BLog(BLOG_ERROR, "tcp_bind_to_netif failed"); - tcp_close(l); - goto fail; - } - - // listen listener - if (!(listener = tcp_listen(l))) { - BLog(BLOG_ERROR, "tcp_listen failed"); - tcp_close(l); - goto fail; - } - - // setup listener accept handler - tcp_accept(listener, listener_accept_func); - -// if (options.netif_ip6addr) { -// struct tcp_pcb *l_ip6 = tcp_new_ip6(); -// if (!l_ip6) { -// BLog(BLOG_ERROR, "tcp_new_ip6 failed"); -// goto fail; -// } -// -// if (tcp_bind_to_netif(l_ip6, "ho0") != ERR_OK) { -// BLog(BLOG_ERROR, "tcp_bind_to_netif failed"); -// tcp_close(l_ip6); -// goto fail; -// } -// -// if (!(listener_ip6 = tcp_listen(l_ip6))) { -// BLog(BLOG_ERROR, "tcp_listen failed"); -// tcp_close(l_ip6); -// goto fail; -// } -// -// tcp_accept(listener_ip6, listener_accept_func); -// } - - return; - -fail: - if (!quitting) { - terminate(); - } -} - -void tcp_timer_handler (void *unused) -{ - ASSERT(!quitting) - -// BLog(BLOG_DEBUG, "TCP timer"); - - // schedule next timer - // TODO: calculate timeout so we don't drift - BReactor_SetTimer(&ss, &tcp_timer); - - tcp_tmr(); - return; -} - -void device_error_handler (void *unused) -{ - ASSERT(!quitting) - - BLog(BLOG_ERROR, "device error"); - - terminate(); - return; -} - -void device_read_handler_send (void *unused, uint8_t *data, int data_len) -{ - ASSERT(!quitting) - ASSERT(data_len >= 0) - - BLog(BLOG_DEBUG, "device: received packet"); - - // accept packet - PacketPassInterface_Done(&device_read_interface); - - // process UDP directly - if (process_device_udp_packet(data, data_len)) { - return; - } - - // obtain pbuf - if (data_len > UINT16_MAX) { - BLog(BLOG_WARNING, "device read: packet too large"); - return; - } - struct pbuf *p = pbuf_alloc(PBUF_RAW, data_len, PBUF_POOL); - if (!p) { - BLog(BLOG_WARNING, "device read: pbuf_alloc failed"); - return; - } - - // write packet to pbuf - ASSERT_FORCE(pbuf_take(p, data, data_len) == ERR_OK) - - // pass pbuf to input - if (the_netif.input(p, &the_netif) != ERR_OK) { - BLog(BLOG_WARNING, "device read: input failed"); - pbuf_free(p); - } -} - -int process_device_udp_packet (uint8_t *data, int data_len) -{ - ASSERT(data_len >= 0) - - // do nothing if we don't have udpgw -// if (!options.udpgw_remote_server_addr) { -// goto fail; -// } - - BAddr local_addr; - BAddr remote_addr; - int is_dns = 0; - - uint8_t ip_version = 0; - if (data_len > 0) { - ip_version = (data[0] >> 4); - } - - switch (ip_version) { - case 4: { - // ignore non-UDP packets - if (data_len < sizeof(struct ipv4_header) || data[offsetof(struct ipv4_header, protocol)] != IPV4_PROTOCOL_UDP) { - goto fail; - } - - // parse IPv4 header - struct ipv4_header ipv4_header; - if (!ipv4_check(data, data_len, &ipv4_header, &data, &data_len)) { - goto fail; - } - - // parse UDP - struct udp_header udp_header; - if (!udp_check(data, data_len, &udp_header, &data, &data_len)) { - goto fail; - } - - // verify UDP checksum - uint16_t checksum_in_packet = udp_header.checksum; - udp_header.checksum = 0; - uint16_t checksum_computed = udp_checksum(&udp_header, data, data_len, ipv4_header.source_address, ipv4_header.destination_address); - if (checksum_in_packet != checksum_computed) { - goto fail; - } - - BLog(BLOG_INFO, "UDP: from device %d bytes", data_len); - - // construct addresses - BAddr_InitIPv4(&local_addr, ipv4_header.source_address, udp_header.source_port); - BAddr_InitIPv4(&remote_addr, ipv4_header.destination_address, udp_header.dest_port); - - // if transparent DNS is enabled, any packet arriving at out netif - // address to port 53 is considered a DNS packet -// is_dns = (options.udpgw_transparent_dns && -// ipv4_header.destination_address == netif_ipaddr.ipv4 && -// udp_header.dest_port == hton16(53)); -// is_dns = 0; - } break; - - case 6: { - // ignore if IPv6 support is disabled - if (!options.netif_ip6addr) { - goto fail; - } - - // ignore non-UDP packets - if (data_len < sizeof(struct ipv6_header) || data[offsetof(struct ipv6_header, next_header)] != IPV6_NEXT_UDP) { - goto fail; - } - - // parse IPv6 header - struct ipv6_header ipv6_header; - if (!ipv6_check(data, data_len, &ipv6_header, &data, &data_len)) { - goto fail; - } - - // parse UDP - struct udp_header udp_header; - if (!udp_check(data, data_len, &udp_header, &data, &data_len)) { - goto fail; - } - - // verify UDP checksum - uint16_t checksum_in_packet = udp_header.checksum; - udp_header.checksum = 0; - uint16_t checksum_computed = udp_ip6_checksum(&udp_header, data, data_len, ipv6_header.source_address, ipv6_header.destination_address); - if (checksum_in_packet != checksum_computed) { - goto fail; - } - - BLog(BLOG_INFO, "UDP/IPv6: from device %d bytes", data_len); - - // construct addresses - BAddr_InitIPv6(&local_addr, ipv6_header.source_address, udp_header.source_port); - BAddr_InitIPv6(&remote_addr, ipv6_header.destination_address, udp_header.dest_port); - - // TODO dns - is_dns = 0; - } break; - - default: { - goto fail; - } break; - } - - // check payload length - if (data_len > udp_mtu) { -#ifdef BADVPN_SOCKS_UDP_RELAY - BLog(BLOG_ERROR, "packet is too large, cannot send to udprelay"); -#else - BLog(BLOG_ERROR, "packet is too large, cannot send to udpgw"); -#endif - goto fail; - } - - // submit packet to udpgw - SocksUdpGwClient_SubmitPacket(&udpgw_client, local_addr, remote_addr, is_dns, data, data_len); - - return 1; - -fail: - return 0; -} - -err_t netif_init_func (struct netif *netif) -{ - BLog(BLOG_DEBUG, "netif func init"); - - netif->name[0] = 'h'; - netif->name[1] = 'o'; - netif->output = netif_output_func; -// netif->output_ip6 = netif_output_ip6_func; - netif->mtu = options.mtu; - - return ERR_OK; -} - -err_t netif_output_func (struct netif *netif, struct pbuf *p, ip_addr_t *ipaddr) -{ - return common_netif_output(netif, p); -} - -//err_t netif_output_ip6_func (struct netif *netif, struct pbuf *p, ip6_addr_t *ipaddr) -//{ -// return common_netif_output(netif, p); -//} - -err_t common_netif_output (struct netif *netif, struct pbuf *p) -{ - SYNC_DECL - - BLog(BLOG_DEBUG, "device write: send packet"); - - if (quitting) { - return ERR_OK; - } - - // if there is just one chunk, send it directly, else via buffer - if (!p->next) { - if (p->len > BTap_GetMTU(&device)) { - BLog(BLOG_WARNING, "netif func output: no space left"); - goto out; - } - - SYNC_FROMHERE - BTap_Send(&device, (uint8_t *)p->payload, p->len); - SYNC_COMMIT - } else { - int len = 0; - do { - if (p->len > BTap_GetMTU(&device) - len) { - BLog(BLOG_WARNING, "netif func output: no space left"); - goto out; - } - memcpy(device_write_buf + len, p->payload, p->len); - len += p->len; - } while ((p = p->next) != NULL); - - SYNC_FROMHERE - BTap_Send(&device, device_write_buf, len); - SYNC_COMMIT - } - -out: - return ERR_OK; -} - -err_t netif_input_func (struct pbuf *p, struct netif *inp) -{ - uint8_t ip_version = 0; - if (p->len > 0) { - ip_version = (((uint8_t *)p->payload)[0] >> 4); - } - - switch (ip_version) { - case 4: { - return ip_input(p, inp); - } break; - case 6: { -// if (options.netif_ip6addr) { -// return ip6_input(p, inp); -// } - } break; - } - - pbuf_free(p); - return ERR_OK; -} - -void client_logfunc (struct tcp_client *client) -{ - char local_addr_s[BADDR_MAX_PRINT_LEN]; - BAddr_Print(&client->local_addr, local_addr_s); - char remote_addr_s[BADDR_MAX_PRINT_LEN]; - BAddr_Print(&client->remote_addr, remote_addr_s); - - BLog_Append("%05d (%s %s): ", num_clients, local_addr_s, remote_addr_s); -} - -void client_log (struct tcp_client *client, int level, const char *fmt, ...) -{ - va_list vl; - va_start(vl, fmt); - BLog_LogViaFuncVarArg((BLog_logfunc)client_logfunc, client, BLOG_CURRENT_CHANNEL, level, fmt, vl); - va_end(vl); -} - -err_t listener_accept_func (void *arg, struct tcp_pcb *newpcb, err_t err) -{ - ASSERT(err == ERR_OK) - - // signal accepted - struct tcp_pcb *this_listener = (PCB_ISIPV6(newpcb) ? listener_ip6 : listener); - tcp_accepted(this_listener); - - // allocate client structure - struct tcp_client *client = (struct tcp_client *)malloc(sizeof(*client)); - if (!client) { - BLog(BLOG_ERROR, "listener accept: malloc failed"); - goto fail0; - } - client->socks_username = NULL; - - SYNC_DECL - SYNC_FROMHERE - - // read addresses - client->local_addr = baddr_from_lwip(PCB_ISIPV6(newpcb), &newpcb->local_ip, newpcb->local_port); - client->remote_addr = baddr_from_lwip(PCB_ISIPV6(newpcb), &newpcb->remote_ip, newpcb->remote_port); - - // get destination address - BAddr addr = client->local_addr; -#ifdef OVERRIDE_DEST_ADDR - ASSERT_FORCE(BAddr_Parse2(&addr, OVERRIDE_DEST_ADDR, NULL, 0, 1)) -#endif - - // add source address to username if requested - if (options.username && options.append_source_to_username) { - char addr_str[BADDR_MAX_PRINT_LEN]; - BAddr_Print(&client->remote_addr, addr_str); - client->socks_username = concat_strings(3, options.username, "@", addr_str); - if (!client->socks_username) { - goto fail1; - } - socks_auth_info[1].password.username = client->socks_username; - socks_auth_info[1].password.username_len = strlen(client->socks_username); - } - - // init SOCKS - if (!BSocksClient_Init(&client->socks_client, socks_server_addr, socks_auth_info, socks_num_auth_info, - addr, (BSocksClient_handler)client_socks_handler, client, &ss)) { - BLog(BLOG_ERROR, "listener accept: BSocksClient_Init failed"); - goto fail1; - } - - // init dead vars - DEAD_INIT(client->dead); - DEAD_INIT(client->dead_client); - - // add to linked list - LinkedList1_Append(&tcp_clients, &client->list_node); - - // increment counter - ASSERT(num_clients >= 0) - num_clients++; - - // set pcb - client->pcb = newpcb; - - // set client not closed - client->client_closed = 0; - - // setup handler argument - tcp_arg(client->pcb, client); - - // setup handlers - tcp_err(client->pcb, client_err_func); - tcp_recv(client->pcb, client_recv_func); - - // setup buffer - client->buf_used = 0; - - // set SOCKS not up, not closed - client->socks_up = 0; - client->socks_closed = 0; - - client_log(client, BLOG_INFO, "accepted"); - - DEAD_ENTER(client->dead_client) - SYNC_COMMIT - DEAD_LEAVE2(client->dead_client) - if (DEAD_KILLED) { - return ERR_ABRT; - } - - return ERR_OK; - -fail1: - SYNC_BREAK - free(client->socks_username); - free(client); -fail0: - return ERR_MEM; -} - -void client_handle_freed_client (struct tcp_client *client) -{ - ASSERT(!client->client_closed) - - // pcb was taken care of by the caller - - // kill client dead var - DEAD_KILL(client->dead_client); - - // set client closed - client->client_closed = 1; - - // if we have data to be sent to SOCKS and can send it, keep sending - if (client->buf_used > 0 && !client->socks_closed) { - client_log(client, BLOG_INFO, "waiting untill buffered data is sent to SOCKS"); - } else { - if (!client->socks_closed) { - client_free_socks(client); - } else { - client_dealloc(client); - } - } -} - -void client_free_client (struct tcp_client *client) -{ - ASSERT(!client->client_closed) - - // remove callbacks - tcp_err(client->pcb, NULL); - tcp_recv(client->pcb, NULL); - tcp_sent(client->pcb, NULL); - - // free pcb - err_t err = tcp_close(client->pcb); - if (err != ERR_OK) { - client_log(client, BLOG_ERROR, "tcp_close failed (%d)", err); - tcp_abort(client->pcb); - } - - client_handle_freed_client(client); -} - -void client_abort_client (struct tcp_client *client) -{ - ASSERT(!client->client_closed) - - // remove callbacks - tcp_err(client->pcb, NULL); - tcp_recv(client->pcb, NULL); - tcp_sent(client->pcb, NULL); - - // free pcb - tcp_abort(client->pcb); - - client_handle_freed_client(client); -} - -void client_free_socks (struct tcp_client *client) -{ - ASSERT(!client->socks_closed) - - // stop sending to SOCKS - if (client->socks_up) { - // stop receiving from client - if (!client->client_closed) { - tcp_recv(client->pcb, NULL); - } - } - - // free SOCKS - BSocksClient_Free(&client->socks_client); - - // set SOCKS closed - client->socks_closed = 1; - - // if we have data to be sent to the client and we can send it, keep sending - if (client->socks_up && (client->socks_recv_buf_used >= 0 || client->socks_recv_tcp_pending > 0) && !client->client_closed) { - client_log(client, BLOG_INFO, "waiting until buffered data is sent to client"); - } else { - if (!client->client_closed) { - client_free_client(client); - } else { - client_dealloc(client); - } - } -} - -void client_murder (struct tcp_client *client) -{ - // free client - if (!client->client_closed) { - // remove callbacks - tcp_err(client->pcb, NULL); - tcp_recv(client->pcb, NULL); - tcp_sent(client->pcb, NULL); - - // abort - tcp_abort(client->pcb); - - // kill client dead var - DEAD_KILL(client->dead_client); - - // set client closed - client->client_closed = 1; - } - - // free SOCKS - if (!client->socks_closed) { - // free SOCKS - BSocksClient_Free(&client->socks_client); - - // set SOCKS closed - client->socks_closed = 1; - } - - // dealloc entry - client_dealloc(client); -} - -void client_dealloc (struct tcp_client *client) -{ - ASSERT(client->client_closed) - ASSERT(client->socks_closed) - - // decrement counter - ASSERT(num_clients > 0) - num_clients--; - - // remove client entry - LinkedList1_Remove(&tcp_clients, &client->list_node); - - // kill dead var - DEAD_KILL(client->dead); - - // free memory - free(client->socks_username); - free(client); -} - -void client_err_func (void *arg, err_t err) -{ - struct tcp_client *client = (struct tcp_client *)arg; - ASSERT(!client->client_closed) - - client_log(client, BLOG_INFO, "client_err_func client error (%d)", (int)err); - - // the pcb was taken care of by the caller - client_handle_freed_client(client); -} - -err_t client_recv_func (void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err) -{ - - struct tcp_client *client = (struct tcp_client *)arg; - client_log(client, BLOG_INFO, "client_recv_func client received (%d)", sizeof(client->buf)); - - ASSERT(!client->client_closed) - ASSERT(err == ERR_OK) // checked in lwIP source. Otherwise, I've no idea what should - // be done with the pbuf in case of an error. - - if (!p) { - client_log(client, BLOG_INFO, "client closed"); - client_free_client(client); - return ERR_ABRT; - } - - ASSERT(p->tot_len > 0) - - // check if we have enough buffer - if (p->tot_len > sizeof(client->buf) - client->buf_used) { - client_log(client, BLOG_ERROR, "no buffer for data !?!"); - return ERR_MEM; - } - - // copy data to buffer - ASSERT_EXECUTE(pbuf_copy_partial(p, client->buf + client->buf_used, p->tot_len, 0) == p->tot_len) - client->buf_used += p->tot_len; - - // if there was nothing in the buffer before, and SOCKS is up, start send data - if (client->buf_used == p->tot_len && client->socks_up) { - ASSERT(!client->socks_closed) // this callback is removed when SOCKS is closed - - SYNC_DECL - SYNC_FROMHERE - client_send_to_socks(client); - DEAD_ENTER(client->dead_client) - SYNC_COMMIT - DEAD_LEAVE2(client->dead_client) - if (DEAD_KILLED) { - return ERR_ABRT; - } - } - - // free pbuff - pbuf_free(p); - - return ERR_OK; -} - -void client_socks_handler (struct tcp_client *client, int event) -{ - ASSERT(!client->socks_closed) -#if SOCKS_DATA_LOG_ENABLE - client_log(client, BLOG_DEBUG, "tun2socks client_socks_handler event: %d", event); -#endif - switch (event) { - case BSOCKSCLIENT_EVENT_ERROR: { - client_log(client, BLOG_INFO, "SOCKS error"); - - client_free_socks(client); - } break; - - case BSOCKSCLIENT_EVENT_UP: { - ASSERT(!client->socks_up) - - client_log(client, BLOG_INFO, "tun2socks SOCKS up"); - - // init sending - client->socks_send_if = BSocksClient_GetSendInterface(&client->socks_client); - StreamPassInterface_Sender_Init(client->socks_send_if, (StreamPassInterface_handler_done)client_socks_send_handler_done, client); - client_log(client, BLOG_INFO, "tun2socks SOCKS init 0"); - // init receiving - client->socks_recv_if = BSocksClient_GetRecvInterface(&client->socks_client); - StreamRecvInterface_Receiver_Init(client->socks_recv_if, (StreamRecvInterface_handler_done)client_socks_recv_handler_done, client); - client->socks_recv_buf_used = -1; - client->socks_recv_tcp_pending = 0; - client_log(client, BLOG_INFO, "tun2socks SOCKS init 1"); - if (!client->client_closed) { - client_log(client, BLOG_INFO, "tun2socks SOCKS init 2"); - tcp_sent(client->pcb, client_sent_func); - } - client_log(client, BLOG_INFO, "tun2socks SOCKS init 3"); - // set up - client->socks_up = 1; - - // start sending data if there is any - if (client->buf_used > 0) { - client_log(client, BLOG_INFO, "tun2socks SOCKS init 4"); -// client->buf_used = 0; - client_send_to_socks(client); - } - client_log(client, BLOG_INFO, "tun2socks SOCKS init 5"); - // start receiving data if client is still up - if (!client->client_closed) { - client_log(client, BLOG_INFO, "tun2socks SOCKS init 6"); - client_socks_recv_initiate(client); - } - } break; - - case BSOCKSCLIENT_EVENT_ERROR_CLOSED: { - ASSERT(client->socks_up) - - client_log(client, BLOG_INFO, "SOCKS closed"); - - client_free_socks(client); - } break; - - default: - ASSERT(0); - } -} - -void client_send_to_socks (struct tcp_client *client) -{ - ASSERT(!client->socks_closed) - ASSERT(client->socks_up) - ASSERT(client->buf_used > 0) - -#if SOCKS_DATA_LOG_ENABLE - client_log(client, BLOG_DEBUG, "tun2socks client_send_to_socks data: %@", client->buf_used); -#endif - // schedule sending - StreamPassInterface_Sender_Send(client->socks_send_if, client->buf, client->buf_used); -} - -void client_socks_send_handler_done (struct tcp_client *client, int data_len) -{ - ASSERT(!client->socks_closed) - ASSERT(client->socks_up) - ASSERT(client->buf_used > 0) - ASSERT(data_len > 0) - ASSERT(data_len <= client->buf_used) - - // remove sent data from buffer - memmove(client->buf, client->buf + data_len, client->buf_used - data_len); - client->buf_used -= data_len; - - if (!client->client_closed) { - // confirm sent data - tcp_recved(client->pcb, data_len); - } - - if (client->buf_used > 0) { - // send any further data - StreamPassInterface_Sender_Send(client->socks_send_if, client->buf, client->buf_used); - } - else if (client->client_closed) { - // client was closed we've sent everything we had buffered; we're done with it - client_log(client, BLOG_INFO, "removing after client went down"); - - client_free_socks(client); - } -} - -void client_socks_recv_initiate (struct tcp_client *client) -{ - ASSERT(!client->client_closed) - ASSERT(!client->socks_closed) - ASSERT(client->socks_up) - ASSERT(client->socks_recv_buf_used == -1) - - StreamRecvInterface_Receiver_Recv(client->socks_recv_if, client->socks_recv_buf, sizeof(client->socks_recv_buf)); -} - -void client_socks_recv_handler_done (struct tcp_client *client, int data_len) -{ - ASSERT(data_len > 0) - ASSERT(data_len <= sizeof(client->socks_recv_buf)) - ASSERT(!client->socks_closed) - ASSERT(client->socks_up) - ASSERT(client->socks_recv_buf_used == -1) - - // if client was closed, stop receiving - if (client->client_closed) { - return; - } - - // set amount of data in buffer - client->socks_recv_buf_used = data_len; - client->socks_recv_buf_sent = 0; - client->socks_recv_waiting = 0; - - // send to client - client_log(client, BLOG_INFO, "client_socks_recv_handler_done prepare send to client: %d", data_len); - if (client_socks_recv_send_out(client) < 0) { - client_log(client, BLOG_INFO, "client_socks_recv_send_out error"); - return; - } - - // continue receiving if needed - if (client->socks_recv_buf_used == -1) { - client_log(client, BLOG_INFO, "client_socks_recv_send_out continue receiving"); - client_socks_recv_initiate(client); - }else{ -// client_socks_recv_initiate(client); - client_log(client, BLOG_INFO, "client_socks_recv_send_out continue error"); - } -} - -int client_socks_recv_send_out (struct tcp_client *client) -{ - ASSERT(!client->client_closed) - ASSERT(client->socks_up) - ASSERT(client->socks_recv_buf_used > 0) - ASSERT(client->socks_recv_buf_sent < client->socks_recv_buf_used) - ASSERT(!client->socks_recv_waiting) - - // return value -1 means tcp_abort() was done, - // 0 means it wasn't and the client (pcb) is still up - - do { - int to_write = bmin_int(client->socks_recv_buf_used - client->socks_recv_buf_sent, tcp_sndbuf(client->pcb)); -#if SOCKS_DATA_LOG_ENABLE - client_log(client, BLOG_INFO, "tun2socks client_socks_recv_send_out data", to_write); -#endif - if (to_write == 0) { -#if SOCKS_DATA_LOG_ENABLE - client_log(client, BLOG_INFO, "tun2socks client_socks_recv_send_out to_write zero, break"); -#endif - break; - } - err_t err = tcp_write(client->pcb, client->socks_recv_buf + client->socks_recv_buf_sent, to_write, TCP_WRITE_FLAG_COPY); -#if SOCKS_DATA_LOG_ENABLE - client_log(client, BLOG_INFO, "tun2socks client_socks_recv_send_out tcp write err: %d", err); -#endif - if (err != ERR_OK) { - if (err == ERR_MEM) { -#if SOCKS_DATA_LOG_ENABLE - client_log(client, BLOG_INFO, "tun2socks client_socks_recv_send_out tcp write error error_mem"); -#endif - break; - } -#if SOCKS_DATA_LOG_ENABLE - client_log(client, BLOG_INFO, "tcp_write failed (%d)", (int)err); -#endif - client_abort_client(client); - return -1; - } - - client->socks_recv_buf_sent += to_write; - client->socks_recv_tcp_pending += to_write; - } while (client->socks_recv_buf_sent < client->socks_recv_buf_used); -#if SOCKS_DATA_LOG_ENABLE - client_log(client, BLOG_INFO, "tun2socks client_socks_recv_send_out begin tcp_output"); -#endif - // start sending now - err_t err = tcp_output(client->pcb); -#if SOCKS_DATA_LOG_ENABLE - client_log(client, BLOG_INFO, "tun2socks client_socks_recv_send_out begin tcp_output err: %d", err); -#endif - if (err != ERR_OK) { -#if SOCKS_DATA_LOG_ENABLE - client_log(client, BLOG_INFO, "tcp_output failed (%d)", (int)err); -#endif - client_abort_client(client); - return -1; - } - - // more data to queue? - if (client->socks_recv_buf_sent < client->socks_recv_buf_used) { - if (client->socks_recv_tcp_pending == 0) { - client_log(client, BLOG_ERROR, "can't queue data, but all data was confirmed !?!"); - - client_abort_client(client); - return -1; - } - - // set waiting, continue in client_sent_func - client->socks_recv_waiting = 1; - return 0; - } - - // everything was queued - client->socks_recv_buf_used = -1; -// client->socks_recv_buf_used = 0; - - return 0; -} - -err_t client_sent_func (void *arg, struct tcp_pcb *tpcb, u16_t len) -{ - struct tcp_client *client = (struct tcp_client *)arg; - - ASSERT(!client->client_closed) - ASSERT(client->socks_up) - ASSERT(len > 0) - ASSERT(len <= client->socks_recv_tcp_pending) - - // decrement pending - client->socks_recv_tcp_pending -= len; - - // continue queuing - if (client->socks_recv_buf_used > 0) { - ASSERT(client->socks_recv_waiting) - ASSERT(client->socks_recv_buf_sent < client->socks_recv_buf_used) - - // set not waiting - client->socks_recv_waiting = 0; - - // possibly send more data - if (client_socks_recv_send_out(client) < 0) { - return ERR_ABRT; - } - - // we just queued some data, so it can't have been confirmed yet - ASSERT(client->socks_recv_tcp_pending > 0) - - // continue receiving if needed - if (client->socks_recv_buf_used == -1 && !client->socks_closed) { - SYNC_DECL - SYNC_FROMHERE - client_socks_recv_initiate(client); - DEAD_ENTER(client->dead_client) - SYNC_COMMIT - DEAD_LEAVE2(client->dead_client) - if (DEAD_KILLED) { - return ERR_ABRT; - } - } - - return ERR_OK; - } - - // have we sent everything after SOCKS was closed? - if (client->socks_closed && client->socks_recv_tcp_pending == 0) { - client_log(client, BLOG_INFO, "removing after SOCKS went down"); - client_free_client(client); - return ERR_ABRT; - } - - return ERR_OK; -} - -void udpgw_client_handler_received (void *unused, BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len) -{ - ASSERT(options.udpgw_remote_server_addr) - ASSERT(local_addr.type == BADDR_TYPE_IPV4 || local_addr.type == BADDR_TYPE_IPV6) - ASSERT(local_addr.type == remote_addr.type) - ASSERT(data_len >= 0) - - int packet_length = 0; - - switch (local_addr.type) { - case BADDR_TYPE_IPV4: { -#ifdef BADVPN_SOCKS_UDP_RELAY - BLog(BLOG_INFO, "UDP: from udprelay %d bytes", data_len); -#else - BLog(BLOG_INFO, "UDP: from udpgw %d bytes", data_len); -#endif - - if (data_len > UINT16_MAX - (sizeof(struct ipv4_header) + sizeof(struct udp_header)) || - data_len > BTap_GetMTU(&device) - (int)(sizeof(struct ipv4_header) + sizeof(struct udp_header)) - ) { - BLog(BLOG_ERROR, "UDP: packet is too large"); - return; - } - - // build IP header - struct ipv4_header iph; - iph.version4_ihl4 = IPV4_MAKE_VERSION_IHL(sizeof(iph)); - iph.ds = hton8(0); - iph.total_length = hton16(sizeof(iph) + sizeof(struct udp_header) + data_len); - iph.identification = hton16(0); - iph.flags3_fragmentoffset13 = hton16(0); - iph.ttl = hton8(64); - iph.protocol = hton8(IPV4_PROTOCOL_UDP); - iph.checksum = hton16(0); - iph.source_address = remote_addr.ipv4.ip; - iph.destination_address = local_addr.ipv4.ip; - iph.checksum = ipv4_checksum(&iph, NULL, 0); - - // build UDP header - struct udp_header udph; - udph.source_port = remote_addr.ipv4.port; - udph.dest_port = local_addr.ipv4.port; - udph.length = hton16(sizeof(udph) + data_len); - udph.checksum = hton16(0); - udph.checksum = udp_checksum(&udph, data, data_len, iph.source_address, iph.destination_address); - - // write packet - memcpy(device_write_buf, &iph, sizeof(iph)); - memcpy(device_write_buf + sizeof(iph), &udph, sizeof(udph)); - memcpy(device_write_buf + sizeof(iph) + sizeof(udph), data, data_len); - packet_length = sizeof(iph) + sizeof(udph) + data_len; - } break; - - case BADDR_TYPE_IPV6: { -#ifdef BADVPN_SOCKS_UDP_RELAY - BLog(BLOG_INFO, "UDP/IPv6: from udprelay %d bytes", data_len); -#else - BLog(BLOG_INFO, "UDP/IPv6: from udpgw %d bytes", data_len); -#endif - - if (!options.netif_ip6addr) { -#ifdef BADVPN_SOCKS_UDP_RELAY - BLog(BLOG_ERROR, "got IPv6 packet from udprelay but IPv6 is disabled"); -#else - BLog(BLOG_ERROR, "got IPv6 packet from udpgw but IPv6 is disabled"); -#endif - return; - } - - if (data_len > UINT16_MAX - sizeof(struct udp_header) || - data_len > BTap_GetMTU(&device) - (int)(sizeof(struct ipv6_header) + sizeof(struct udp_header)) - ) { - BLog(BLOG_ERROR, "UDP/IPv6: packet is too large"); - return; - } - - // build IPv6 header - struct ipv6_header iph; - iph.version4_tc4 = hton8((6 << 4)); - iph.tc4_fl4 = hton8(0); - iph.fl = hton16(0); - iph.payload_length = hton16(sizeof(struct udp_header) + data_len); - iph.next_header = hton8(IPV6_NEXT_UDP); - iph.hop_limit = hton8(64); - memcpy(iph.source_address, remote_addr.ipv6.ip, 16); - memcpy(iph.destination_address, local_addr.ipv6.ip, 16); - - // build UDP header - struct udp_header udph; - udph.source_port = remote_addr.ipv6.port; - udph.dest_port = local_addr.ipv6.port; - udph.length = hton16(sizeof(udph) + data_len); - udph.checksum = hton16(0); - udph.checksum = udp_ip6_checksum(&udph, data, data_len, iph.source_address, iph.destination_address); - - // write packet - memcpy(device_write_buf, &iph, sizeof(iph)); - memcpy(device_write_buf + sizeof(iph), &udph, sizeof(udph)); - memcpy(device_write_buf + sizeof(iph) + sizeof(udph), data, data_len); - packet_length = sizeof(iph) + sizeof(udph) + data_len; - } break; - } - - // submit packet - BTap_Send(&device, device_write_buf, packet_length); -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/tun2socks.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/tun2socks.h deleted file mode 100644 index 87bb5374..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tun2socks/tun2socks.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) Ambroz Bizjak - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - - -// name of the program -#define PROGRAM_NAME "tun2socks" - -// size of temporary buffer for passing data from the SOCKS server to TCP for sending -#define CLIENT_SOCKS_RECV_BUF_SIZE 2048 - -// maximum number of udpgw connections -#define DEFAULT_UDPGW_MAX_CONNECTIONS 256 - -// udpgw per-connection send buffer size, in number of packets -#define DEFAULT_UDPGW_CONNECTION_BUFFER_SIZE 8 - -// udpgw reconnect time after connection fails -#define UDPGW_RECONNECT_TIME 5000 - -// udpgw keepalive sending interval -#define UDPGW_KEEPALIVE_TIME 10000 - -// option to override the destination addresses to give the SOCKS server -//#define OVERRIDE_DEST_ADDR "10.111.0.2:2000" - -extern int tun2socks_main (int argc, char **argv, int fd, int mtu); -extern void stop_tun2socks(); \ No newline at end of file diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tuntap/BTap.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tuntap/BTap.h deleted file mode 100644 index 555f3143..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tuntap/BTap.h +++ /dev/null @@ -1,196 +0,0 @@ -/** - * @file BTap.h - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @section DESCRIPTION - * - * TAP device abstraction. - */ - -#ifndef BADVPN_TUNTAP_BTAP_H -#define BADVPN_TUNTAP_BTAP_H - -#if (defined(BADVPN_USE_WINAPI) + defined(BADVPN_LINUX) + defined(BADVPN_FREEBSD)) != 1 -#error Unknown TAP backend or too many TAP backends -#endif - -#include - -#ifdef BADVPN_USE_WINAPI -#else -#include -#endif - -#include "misc/debug.h" -#include "misc/debugerror.h" -#include "base/DebugObject.h" -#include "system/BReactor.h" -#include "flow/PacketRecvInterface.h" - -#define BTAP_ETHERNET_HEADER_LENGTH 14 - -/** - * Handler called when an error occurs on the device. - * The object must be destroyed from the job context of this - * handler, and no further I/O may occur. - * - * @param user as in {@link BTap_Init} - */ -typedef void (*BTap_handler_error) (void *used); - -typedef struct { - BReactor *reactor; - BTap_handler_error handler_error; - void *handler_error_user; - int frame_mtu; - PacketRecvInterface output; - uint8_t *output_packet; - -#ifdef BADVPN_USE_WINAPI - HANDLE device; - BReactorIOCPOverlapped send_olap; - BReactorIOCPOverlapped recv_olap; -#else - int close_fd; - int fd; - BFileDescriptor bfd; - int poll_events; -#endif - - DebugError d_err; - DebugObject d_obj; -} BTap; - -/** - * Initializes the TAP device. - * - * @param o the object - * @param BReactor {@link BReactor} we live in - * @param devname name of the devece to open. - * On Linux: a network interface name. If it is NULL, no - * specific device will be requested, and the operating system - * may create a new device. - * On Windows: a string "component_id:device_name", where - * component_id is a string identifying the driver, and device_name - * is the name of the network interface. If component_id is empty, - * a hardcoded default will be used instead. If device_name is empty, - * the first device found with a matching component_id will be used. - * Specifying a NULL devname is equivalent to specifying ":". - * @param handler_error error handler function - * @param handler_error_user value passed to error handler - * @param tun whether to create a TUN (IP) device or a TAP (Ethernet) device. Must be 0 or 1. - * @return 1 on success, 0 on failure - */ -int BTap_Init (BTap *o, BReactor *reactor, int fd, int mtu, BTap_handler_error handler_error, void *handler_error_user, int tun); - -enum BTap_dev_type {BTAP_DEV_TUN, BTAP_DEV_TAP}; - -enum BTap_init_type { - BTAP_INIT_STRING, -#ifndef BADVPN_USE_WINAPI - BTAP_INIT_FD, -#endif -}; - -struct BTap_init_data { - enum BTap_dev_type dev_type; - enum BTap_init_type init_type; - union { - char *string; - struct { - int fd; - int mtu; - } fd; - } init; -}; - -/** - * Initializes the TAP device. - * - * @param o the object - * @param BReactor {@link BReactor} we live in - * @param init_data struct containing initialization parameters (to allow transparent passing). - * init.data.dev_type must be either BTAP_DEV_TUN for an IP device, or - * BTAP_DEV_TAP for an Ethernet device. - * init_data.init_type must be either BTAP_INIT_STRING or BTAP_INIT_FD. - * For BTAP_INIT_STRING, init_data.init.string specifies the TUN or TAP - * device, as described next. - * On Linux: a network interface name. If it is NULL, no - * specific device will be requested, and the operating system - * may create a new device. - * On Windows: a string "component_id:device_name", where - * component_id is a string identifying the driver, and device_name - * is the name of the network interface. If component_id is empty, - * a hardcoded default will be used instead. If device_name is empty, - * the first device found with a matching component_id will be used. - * Specifying NULL is equivalent to specifying ":". - * For BTAP_INIT_FD, the device is initialized using a file descriptor. - * In this case, init_data.init.fd.fd must be set to the file descriptor, - * and init_data.init.fd.mtu must be set to the largest IP packet or - * Ethernet frame supported, for a TUN or TAP device, respectively. - * File descriptor initialization is not supported on Windows. - * @param handler_error error handler function - * @param handler_error_user value passed to error handler - * @return 1 on success, 0 on failure - */ -int BTap_Init2 (BTap *o, BReactor *reactor, struct BTap_init_data init_data, BTap_handler_error handler_error, void *handler_error_user) WARN_UNUSED; - -/** - * Frees the TAP device. - * - * @param o the object - */ -void BTap_Free (BTap *o); - -/** - * Returns the device's maximum transmission unit (including any protocol headers). - * - * @param o the object - * @return device's MTU - */ -int BTap_GetMTU (BTap *o); - -/** - * Sends a packet to the device. - * Any errors will be reported via a job. - * - * @param o the object - * @param data packet to send - * @param data_len length of packet. Must be >=0 and <=MTU, as reported by {@link BTap_GetMTU}. - */ -void BTap_Send (BTap *o, uint8_t *data, int data_len); - -/** - * Returns a {@link PacketRecvInterface} for reading packets from the device. - * The MTU of the interface will be {@link BTap_GetMTU}. - * - * @param o the object - * @return output interface - */ -PacketRecvInterface * BTap_GetOutput (BTap *o); - -#endif diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tuntap/BTap.m b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tuntap/BTap.m deleted file mode 100644 index 18a17760..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/tuntap/BTap.m +++ /dev/null @@ -1,511 +0,0 @@ -/** - * @file BTap.c - * @author Ambroz Bizjak - * - * @section LICENSE - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#ifdef BADVPN_USE_WINAPI -#include -#include -#include -#include -#include "wintap-common.h" -#include -#else -#include -#include -#include -#include -#include -#include -#include -#include -// #include -#ifdef BADVPN_LINUX -#include -#endif -#ifdef BADVPN_FREEBSD -#ifdef __APPLE__ -#include -// #include -// #include -// #include -#include -#include -#else -#include -#include -#endif -#endif -#endif - -#include "base/BLog.h" - -#include "tuntap/BTap.h" - -#include "generated/blog_channel_BTap.h" -#include "TunnelInterface.h" - -static void report_error (BTap *o); -static void output_handler_recv (BTap *o, uint8_t *data); - -#ifdef BADVPN_USE_WINAPI - -static void recv_olap_handler (BTap *o, int event, DWORD bytes) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->output_packet) - ASSERT(event == BREACTOR_IOCP_EVENT_SUCCEEDED || event == BREACTOR_IOCP_EVENT_FAILED) - - // set no output packet - o->output_packet = NULL; - - if (event == BREACTOR_IOCP_EVENT_FAILED) { - BLog(BLOG_ERROR, "read operation failed"); - report_error(o); - return; - } - - ASSERT(bytes >= 0) - ASSERT(bytes <= o->frame_mtu) - - // done - PacketRecvInterface_Done(&o->output, bytes); -} - -#else - -#ifdef __APPLE__ - -static inline int header_modify_read_write_return (int len) -{ - if (len > 0) { - return len > sizeof (u_int32_t) ? len - sizeof (u_int32_t) : 0; - } else { - return len; - } -} - -static int write_tun_header (int fd, void *buf, size_t len) -{ - u_int32_t type; - struct iovec iv[2]; - struct ip *iph; - - iph = (struct ip *) buf; - - if (iph->ip_v == 6) { - type = htonl(AF_INET6); - } else { - type = htonl(AF_INET); - } - - iv[0].iov_base = &type; - iv[0].iov_len = sizeof(type); - iv[1].iov_base = buf; - iv[1].iov_len = len; - - return header_modify_read_write_return(writev(fd, iv, 2)); -} - -static int read_tun_header (int fd, void *buf, size_t len) -{ - u_int32_t type; - struct iovec iv[2]; - - iv[0].iov_base = &type; - iv[0].iov_len = sizeof(type); - iv[1].iov_base = buf; - iv[1].iov_len = len; - - return header_modify_read_write_return(readv(fd, iv, 2)); -} - -#endif - -static void fd_handler (BTap *o, int events) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - - if (events&(BREACTOR_ERROR|BREACTOR_HUP)) { - BLog(BLOG_WARNING, "device fd reports error?"); - } - - if (events&BREACTOR_READ) do { - ASSERT(o->output_packet) - - // try reading into the buffer -#ifdef __APPLE__ - // int bytes = read_tun_header(o->fd, o->output_packet, o->frame_mtu); - uint8_t data[2]; - int bytes = read(o->fd, data, 2); - if (bytes != 2) { - // Treat zero return value the same as EAGAIN. - // See: https://bugzilla.kernel.org/show_bug.cgi?id=96381 -// if (bytes == 0 || errno == EAGAIN || errno == EWOULDBLOCK) { -// // retry later -// break; -// } -// // report fatal error -// report_error(o); -// return; - break; - } - int data_len = data[0] * 256 + data[1]; - - bytes = read(o->fd, o->output_packet, data_len); -#else - int bytes = read(o->fd, o->output_packet, o->frame_mtu); -#endif - if (bytes != data_len) { - // report fatal error - report_error(o); - return; - } - if (bytes <= 0) { - // Treat zero return value the same as EAGAIN. - // See: https://bugzilla.kernel.org/show_bug.cgi?id=96381 - if (bytes == 0 || errno == EAGAIN || errno == EWOULDBLOCK) { - // retry later - break; - } - // report fatal error - report_error(o); - return; - } - -#if TCP_DATA_LOG_ENABLE - BLog(BLOG_DEBUG, "tun2socks receive from tunnel data", bytes); -#endif - - ASSERT_FORCE(bytes <= o->frame_mtu) - - // set no output packet - o->output_packet = NULL; - - // update events - o->poll_events &= ~BREACTOR_READ; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->poll_events); - - // inform receiver we finished the packet - PacketRecvInterface_Done(&o->output, bytes); - } while (0); -} - -#endif - -void report_error (BTap *o) -{ - DEBUGERROR(&o->d_err, o->handler_error(o->handler_error_user)); -} - -void output_handler_recv (BTap *o, uint8_t *data) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(data) - ASSERT(!o->output_packet) - -#ifdef BADVPN_USE_WINAPI - - memset(&o->recv_olap.olap, 0, sizeof(o->recv_olap.olap)); - - // read - BOOL res = ReadFile(o->device, data, o->frame_mtu, NULL, &o->recv_olap.olap); - if (res == FALSE && GetLastError() != ERROR_IO_PENDING) { - BLog(BLOG_ERROR, "ReadFile failed (%u)", GetLastError()); - report_error(o); - return; - } - - o->output_packet = data; - -#else - - // attempt read -//#ifdef __APPLE__ -// // int bytes = read_tun_header(o->fd, data, o->frame_mtu); -// char msg[2]; -// int bytes = read(o->fd, msg, 2); -// NSLog(@"fd2 bytes: %d", bytes); -// -// if (bytes <= 0) { -// if (bytes == 0 || errno == EAGAIN || errno == EWOULDBLOCK) { -// // See note about zero return in fd_handler. -// // retry later in fd_handler -// // remember packet -// o->output_packet = data; -// // update events -// o->poll_events |= BREACTOR_READ; -// BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->poll_events); -// return; -// } -// // report fatal error -// report_error(o); -// return; -// } -// int len = msg[0] * 256 + msg[1]; -// NSLog(@"fd2 len: %x, %x, len: %d", data[0], data[1], len); -// bytes = read(o->fd, data, len); -//#else -// int bytes = read(o->fd, data, o->frame_mtu); -//#endif -// if (bytes <= 0) { -// if (bytes == 0 || errno == EAGAIN || errno == EWOULDBLOCK) { -// // See note about zero return in fd_handler. -// // retry later in fd_handler -// // remember packet -// o->output_packet = data; -// // update events -// o->poll_events |= BREACTOR_READ; -// BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->poll_events); -// return; -// } -// // report fatal error -// report_error(o); -// return; -// } -// -// NSLog(@"tun2 receive: %@", [[NSData alloc] initWithBytes:data length:bytes]); -// -// ASSERT_FORCE(bytes <= o->frame_mtu) -// -// PacketRecvInterface_Done(&o->output, bytes); - o->output_packet = data; - // update events - o->poll_events |= BREACTOR_READ; - BReactor_SetFileDescriptorEvents(o->reactor, &o->bfd, o->poll_events); - -#endif -} - -int BTap_Init (BTap *o, BReactor *reactor, int fd, int mtu, BTap_handler_error handler_error, void *handler_error_user, int tun) -{ - ASSERT(tun == 0 || tun == 1) - - struct BTap_init_data init_data; - init_data.dev_type = tun ? BTAP_DEV_TUN : BTAP_DEV_TAP; - init_data.init_type = BTAP_INIT_FD; - init_data.init.fd.fd = fd; - init_data.init.fd.mtu = mtu; - - return BTap_Init2(o, reactor, init_data, handler_error, handler_error_user); -} - -int BTap_Init2 (BTap *o, BReactor *reactor, struct BTap_init_data init_data, BTap_handler_error handler_error, void *handler_error_user) -{ - ASSERT(init_data.dev_type == BTAP_DEV_TUN || init_data.dev_type == BTAP_DEV_TAP) - - // init arguments - o->reactor = reactor; - o->handler_error = handler_error; - o->handler_error_user = handler_error_user; - -#if defined(BADVPN_LINUX) || defined(BADVPN_FREEBSD) - - o->close_fd = (init_data.init_type != BTAP_INIT_FD); - - switch (init_data.init_type) { - case BTAP_INIT_FD: { - ASSERT(init_data.init.fd.fd >= 0) - ASSERT(init_data.init.fd.mtu >= 0) - ASSERT(init_data.dev_type != BTAP_DEV_TAP || init_data.init.fd.mtu >= BTAP_ETHERNET_HEADER_LENGTH) - - o->fd = init_data.init.fd.fd; - o->frame_mtu = init_data.init.fd.mtu; - } break; - - case BTAP_INIT_STRING: - break; - - default: ASSERT(0); - } - - // set non-blocking - if (fcntl(o->fd, F_SETFL, O_NONBLOCK) < 0) { - BLog(BLOG_ERROR, "cannot set non-blocking"); - goto fail1; - } - - // init file descriptor object - BFileDescriptor_Init(&o->bfd, o->fd, (BFileDescriptor_handler)fd_handler, o); - if (!BReactor_AddFileDescriptor(o->reactor, &o->bfd)) { - BLog(BLOG_ERROR, "BReactor_AddFileDescriptor failed"); - goto fail1; - } - o->poll_events = 0; - - goto success; - -fail1: - if (o->close_fd) { - ASSERT_FORCE(close(o->fd) == 0) - } -fail0: - return 0; - -#endif - -success: - // init output - PacketRecvInterface_Init(&o->output, o->frame_mtu, (PacketRecvInterface_handler_recv)output_handler_recv, o, BReactor_PendingGroup(o->reactor)); - - // set no output packet - o->output_packet = NULL; - - DebugError_Init(&o->d_err, BReactor_PendingGroup(o->reactor)); - DebugObject_Init(&o->d_obj); - return 1; -} - -void BTap_Free (BTap *o) -{ - DebugObject_Free(&o->d_obj); - DebugError_Free(&o->d_err); - - // free output - PacketRecvInterface_Free(&o->output); - -#ifdef BADVPN_USE_WINAPI - - // cancel I/O - ASSERT_FORCE(CancelIo(o->device)) - - // wait receiving to finish - if (o->output_packet) { - BLog(BLOG_DEBUG, "waiting for receiving to finish"); - BReactorIOCPOverlapped_Wait(&o->recv_olap, NULL, NULL); - } - - // free recv olap - BReactorIOCPOverlapped_Free(&o->recv_olap); - - // free send olap - BReactorIOCPOverlapped_Free(&o->send_olap); - - // close device - ASSERT_FORCE(CloseHandle(o->device)) - -#else - - // free BFileDescriptor - BReactor_RemoveFileDescriptor(o->reactor, &o->bfd); - - if (o->close_fd) { - // close file descriptor - ASSERT_FORCE(close(o->fd) == 0) - } - -#endif -} - -int BTap_GetMTU (BTap *o) -{ - DebugObject_Access(&o->d_obj); - - return o->frame_mtu; -} - -void BTap_Send (BTap *o, uint8_t *data, int data_len) -{ - DebugObject_Access(&o->d_obj); - DebugError_AssertNoError(&o->d_err); - ASSERT(data_len >= 0) - ASSERT(data_len <= o->frame_mtu) - -#ifdef BADVPN_USE_WINAPI - - // ignore frames without an Ethernet header, or we get errors in WriteFile - if (data_len < 14) { - return; - } - - memset(&o->send_olap.olap, 0, sizeof(o->send_olap.olap)); - - // write - BOOL res = WriteFile(o->device, data, data_len, NULL, &o->send_olap.olap); - if (res == FALSE && GetLastError() != ERROR_IO_PENDING) { - BLog(BLOG_ERROR, "WriteFile failed (%u)", GetLastError()); - return; - } - - // wait - int succeeded; - DWORD bytes; - BReactorIOCPOverlapped_Wait(&o->send_olap, &succeeded, &bytes); - - if (!succeeded) { - BLog(BLOG_ERROR, "write operation failed"); - } else { - ASSERT(bytes >= 0) - ASSERT(bytes <= data_len) - - if (bytes < data_len) { - BLog(BLOG_ERROR, "write operation didn't write everything"); - } - } - -#else - -#ifdef __APPLE__ - // int bytes = write_tun_header(o->fd, data, data_len); - NSData *outdata = [[NSData alloc] initWithBytes:data length:data_len]; -#if TCP_DATA_LOG_ENABLE - BLog(BLOG_DEBUG, "tun2socks send to tunnel data", data_len); -#endif - [TunnelInterface writePacket:outdata]; - return; - uint8_t msg[o->frame_mtu+2]; - msg[0] = data_len / 256; - msg[1] = data_len % 256; - memcpy(msg + 2, data, data_len); - - int bytes = write(o->fd, msg, data_len + 2); -#else - int bytes = write(o->fd, data, data_len); -#endif - if (bytes < 0) { - // malformed packets will cause errors, ignore them and act like - // the packet was accepeted - } else { - if (bytes != data_len + 2) { - BLog(BLOG_WARNING, "written %d expected %d", bytes, data_len + 2); - } - } - -#endif -} - -PacketRecvInterface * BTap_GetOutput (BTap *o) -{ - DebugObject_Access(&o->d_obj); - - return &o->output; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw/udpgw.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw/udpgw.c deleted file mode 100644 index 5247574c..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw/udpgw.c +++ /dev/null @@ -1,1473 +0,0 @@ -/* - * Copyright (C) Ambroz Bizjak - * Contributions: - * Transparent DNS: Copyright (C) Kerem Hadimli - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "protocol/udpgw_proto.h" -#include "misc/debug.h" -#include "misc/version.h" -#include "misc/loggers_string.h" -#include "misc/loglevel.h" -#include "misc/offset.h" -#include "misc/byteorder.h" -#include "misc/bsize.h" -#include "misc/open_standard_streams.h" -#include "misc/balloc.h" -#include "misc/compare.h" -#include "misc/print_macros.h" -#include "structure/LinkedList1.h" -#include "structure/BAVL.h" -#include "base/BLog.h" -#include "system/BReactor.h" -#include "system/BNetwork.h" -#include "system/BConnection.h" -#include "system/BDatagram.h" -#include "system/BSignal.h" -#include "flow/PacketProtoDecoder.h" -#include "flow/PacketPassFairQueue.h" -#include "flow/PacketStreamSender.h" -#include "flow/PacketProtoFlow.h" -#include "flow/SinglePacketBuffer.h" - -#ifndef BADVPN_USE_WINAPI -#include "base/BLog_syslog.h" -#include -#include -#endif - -#include "udpgw.h" - -#include "generated/blog_channel_udpgw.h" - -#define LOGGER_STDOUT 1 -#define LOGGER_SYSLOG 2 - -#define DNS_UPDATE_TIME 2000 - -struct client { - BConnection con; - BAddr addr; - BTimer disconnect_timer; - PacketProtoDecoder recv_decoder; - PacketPassInterface recv_if; - PacketPassFairQueue send_queue; - PacketStreamSender send_sender; - BAVL connections_tree; - LinkedList1 connections_list; - int num_connections; - LinkedList1 closing_connections_list; - LinkedList1Node clients_list_node; -}; - -struct connection { - struct client *client; - uint16_t conid; - BAddr addr; - BAddr orig_addr; - const uint8_t *first_data; - int first_data_len; - btime_t last_use_time; - int closing; - BPending first_job; - BufferWriter *send_if; - PacketProtoFlow send_ppflow; - PacketPassFairQueueFlow send_qflow; - union { - struct { - BDatagram udp_dgram; - int local_port_index; - BufferWriter udp_send_writer; - PacketBuffer udp_send_buffer; - SinglePacketBuffer udp_recv_buffer; - PacketPassInterface udp_recv_if; - BAVLNode connections_tree_node; - LinkedList1Node connections_list_node; - }; - struct { - LinkedList1Node closing_connections_list_node; - }; - }; -}; - -// command-line options -struct { - int help; - int version; - int logger; -#ifndef BADVPN_USE_WINAPI - char *logger_syslog_facility; - char *logger_syslog_ident; -#endif - int loglevel; - int loglevels[BLOG_NUM_CHANNELS]; - char *listen_addrs[MAX_LISTEN_ADDRS]; - int num_listen_addrs; - int udp_mtu; - int max_clients; - int max_connections_for_client; - int client_socket_sndbuf; - int local_udp_num_ports; - char *local_udp_addr; - int local_udp_ip6_num_ports; - char *local_udp_ip6_addr; - int unique_local_ports; -} server_options; - -// MTUs -int udpgw_mtu; -int pp_mtu; - -// listen addresses -BAddr listen_addrs[MAX_LISTEN_ADDRS]; -int num_listen_addrs; - -// local UDP port range, if options.local_udp_num_ports>=0 -BAddr local_udp_addr; - -// local UDP/IPv6 port range, if options.local_udp_ip6_num_ports>=0 -BAddr local_udp_ip6_addr; - -// DNS forwarding -BAddr dns_addr; -btime_t last_dns_update_time; - -// reactor -BReactor server_ss; - -// listeners -BListener listeners[MAX_LISTEN_ADDRS]; -int num_listeners; - -// clients -LinkedList1 clients_list; -int server_num_clients; - -static void print_help (const char *name); -static void print_version (void); -static int parse_arguments (int argc, char *argv[]); -static int process_arguments (void); -static void signal_handler (void *unused); -static void listener_handler (BListener *listener); -static void client_free (struct client *client); -static void client_logfunc (struct client *client); -static void client_log (struct client *client, int level, const char *fmt, ...); -static void client_disconnect_timer_handler (struct client *client); -static void client_connection_handler (struct client *client, int event); -static void client_decoder_handler_error (struct client *client); -static void client_recv_if_handler_send (struct client *client, uint8_t *data, int data_len); -static int get_local_num_ports (int addr_type); -static BAddr get_local_addr (int addr_type); -static uint8_t * build_port_usage_array_and_find_least_used_connection (BAddr remote_addr, struct connection **out_con); -static void connection_init (struct client *client, uint16_t conid, BAddr addr, BAddr orig_addr, const uint8_t *data, int data_len); -static void connection_free (struct connection *con); -static void connection_logfunc (struct connection *con); -static void connection_log (struct connection *con, int level, const char *fmt, ...); -static void connection_free_udp (struct connection *con); -static void connection_first_job_handler (struct connection *con); -static void connection_send_to_client (struct connection *con, uint8_t flags, const uint8_t *data, int data_len); -static int connection_send_to_udp (struct connection *con, const uint8_t *data, int data_len); -static void connection_close (struct connection *con); -static void connection_send_qflow_busy_handler (struct connection *con); -static void connection_dgram_handler_event (struct connection *con, int event); -static void connection_udp_recv_if_handler_send (struct connection *con, uint8_t *data, int data_len); -static struct connection * find_connection (struct client *client, uint16_t conid); -static int uint16_comparator (void *unused, uint16_t *v1, uint16_t *v2); -static void maybe_update_dns (void); - -int udpgw_main (int argc, char **argv) -{ - if (argc <= 0) { - return 1; - } - - // open standard streams - open_standard_streams(); - - // parse command-line arguments - if (!parse_arguments(argc, argv)) { - fprintf(stderr, "Failed to parse arguments\n"); - print_help(argv[0]); - goto fail0; - } - - // handle --help and --version - if (server_options.help) { - print_version(); - print_help(argv[0]); - return 0; - } - if (server_options.version) { - print_version(); - return 0; - } - - // initialize logger - switch (server_options.logger) { - case LOGGER_STDOUT: - BLog_InitStdout(); - break; -#ifndef BADVPN_USE_WINAPI - case LOGGER_SYSLOG: - if (!BLog_InitSyslog(server_options.logger_syslog_ident, server_options.logger_syslog_facility)) { - fprintf(stderr, "Failed to initialize syslog logger\n"); - goto fail0; - } - break; -#endif - default: - ASSERT(0); - } - - // configure logger channels - for (int i = 0; i < BLOG_NUM_CHANNELS; i++) { - if (server_options.loglevels[i] >= 0) { - BLog_SetChannelLoglevel(i, server_options.loglevels[i]); - } - else if (server_options.loglevel >= 0) { - BLog_SetChannelLoglevel(i, server_options.loglevel); - } - } - - BLog(BLOG_NOTICE, "initializing "GLOBAL_PRODUCT_NAME" "PROGRAM_NAME" "GLOBAL_VERSION); - - // initialize network - if (!BNetwork_GlobalInit()) { - BLog(BLOG_ERROR, "BNetwork_GlobalInit failed"); - goto fail1; - } - - // process arguments - if (!process_arguments()) { - BLog(BLOG_ERROR, "Failed to process arguments"); - goto fail1; - } - - // compute MTUs - udpgw_mtu = udpgw_compute_mtu(server_options.udp_mtu); - if (udpgw_mtu < 0 || udpgw_mtu > PACKETPROTO_MAXPAYLOAD) { - udpgw_mtu = PACKETPROTO_MAXPAYLOAD; - } - pp_mtu = udpgw_mtu + sizeof(struct packetproto_header); - - // init time - BTime_Init(); - - // init DNS forwarding - BAddr_InitNone(&dns_addr); - last_dns_update_time = INT64_MIN; - maybe_update_dns(); - - // init reactor - if (!BReactor_Init(&server_ss)) { - BLog(BLOG_ERROR, "BReactor_Init failed"); - goto fail1; - } - - // setup signal handler - if (!BSignal_Init(&server_ss, signal_handler, NULL)) { - BLog(BLOG_ERROR, "BSignal_Init failed"); - goto fail2; - } - - // initialize listeners - num_listeners = 0; - while (num_listeners < num_listen_addrs) { - if (!BListener_Init(&listeners[num_listeners], listen_addrs[num_listeners], &server_ss, &listeners[num_listeners], (BListener_handler)listener_handler)) { - BLog(BLOG_ERROR, "Listener_Init failed"); - goto fail3; - } - num_listeners++; - } - - // init clients list - LinkedList1_Init(&clients_list); - server_num_clients = 0; - - // enter event loop - BLog(BLOG_NOTICE, "entering event loop"); - BReactor_Exec(&server_ss); - - // free clients - while (!LinkedList1_IsEmpty(&clients_list)) { - struct client *client = UPPER_OBJECT(LinkedList1_GetFirst(&clients_list), struct client, clients_list_node); - client_free(client); - } -fail3: - // free listeners - while (num_listeners > 0) { - num_listeners--; - BListener_Free(&listeners[num_listeners]); - } - // finish signal handling - BSignal_Finish(); -fail2: - // free reactor - BReactor_Free(&server_ss); -fail1: - // free logger - BLog(BLOG_NOTICE, "exiting"); - BLog_Free(); -fail0: - // finish debug objects - DebugObjectGlobal_Finish(); - - return 1; -} - -void print_help (const char *name) -{ - printf( - "Usage:\n" - " %s\n" - " [--help]\n" - " [--version]\n" - " [--logger <"LOGGERS_STRING">]\n" -#ifndef BADVPN_USE_WINAPI - " (logger=syslog?\n" - " [--syslog-facility ]\n" - " [--syslog-ident ]\n" - " )\n" -#endif - " [--loglevel <0-5/none/error/warning/notice/info/debug>]\n" - " [--channel-loglevel <0-5/none/error/warning/notice/info/debug>] ...\n" - " [--listen-addr ] ...\n" - " [--udp-mtu ]\n" - " [--max-clients ]\n" - " [--max-connections-for-client ]\n" - " [--client-socket-sndbuf ]\n" - " [--local-udp-addrs ]\n" - " [--local-udp-ip6-addrs ]\n" - " [--unique-local-ports]\n" - "Address format is a.b.c.d:port (IPv4) or [addr]:port (IPv6).\n", - name - ); -} - -void print_version (void) -{ - printf(GLOBAL_PRODUCT_NAME" "PROGRAM_NAME" "GLOBAL_VERSION"\n"GLOBAL_COPYRIGHT_NOTICE"\n"); -} - -int parse_arguments (int argc, char *argv[]) -{ - if (argc <= 0) { - return 0; - } - - server_options.help = 0; - server_options.version = 0; - server_options.logger = LOGGER_STDOUT; -#ifndef BADVPN_USE_WINAPI - server_options.logger_syslog_facility = "daemon"; - server_options.logger_syslog_ident = argv[0]; -#endif - server_options.loglevel = -1; - for (int i = 0; i < BLOG_NUM_CHANNELS; i++) { - server_options.loglevels[i] = -1; - } - server_options.num_listen_addrs = 0; - server_options.udp_mtu = DEFAULT_UDP_MTU; - server_options.max_clients = DEFAULT_MAX_CLIENTS; - server_options.max_connections_for_client = DEFAULT_MAX_CONNECTIONS_FOR_CLIENT; - server_options.client_socket_sndbuf = CLIENT_DEFAULT_SOCKET_SEND_BUFFER; - server_options.local_udp_num_ports = -1; - server_options.local_udp_ip6_num_ports = -1; - server_options.unique_local_ports = 0; - - int i; - for (i = 1; i < argc; i++) { - char *arg = argv[i]; - if (!strcmp(arg, "--help")) { - server_options.help = 1; - } - else if (!strcmp(arg, "--version")) { - server_options.version = 1; - } - else if (!strcmp(arg, "--logger")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - char *arg2 = argv[i + 1]; - if (!strcmp(arg2, "stdout")) { - server_options.logger = LOGGER_STDOUT; - } -#ifndef BADVPN_USE_WINAPI - else if (!strcmp(arg2, "syslog")) { - server_options.logger = LOGGER_SYSLOG; - } -#endif - else { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i++; - } -#ifndef BADVPN_USE_WINAPI - else if (!strcmp(arg, "--syslog-facility")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - server_options.logger_syslog_facility = argv[i + 1]; - i++; - } - else if (!strcmp(arg, "--syslog-ident")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - server_options.logger_syslog_ident = argv[i + 1]; - i++; - } -#endif - else if (!strcmp(arg, "--loglevel")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - if ((server_options.loglevel = parse_loglevel(argv[i + 1])) < 0) { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i++; - } - else if (!strcmp(arg, "--channel-loglevel")) { - if (2 >= argc - i) { - fprintf(stderr, "%s: requires two arguments\n", arg); - return 0; - } - int channel = BLogGlobal_GetChannelByName(argv[i + 1]); - if (channel < 0) { - fprintf(stderr, "%s: wrong channel argument\n", arg); - return 0; - } - int loglevel = parse_loglevel(argv[i + 2]); - if (loglevel < 0) { - fprintf(stderr, "%s: wrong loglevel argument\n", arg); - return 0; - } - server_options.loglevels[channel] = loglevel; - i += 2; - } - else if (!strcmp(arg, "--listen-addr")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - if (server_options.num_listen_addrs == MAX_LISTEN_ADDRS) { - fprintf(stderr, "%s: too many\n", arg); - return 0; - } - server_options.listen_addrs[server_options.num_listen_addrs] = argv[i + 1]; - server_options.num_listen_addrs++; - i++; - } - else if (!strcmp(arg, "--udp-mtu")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - if ((server_options.udp_mtu = atoi(argv[i + 1])) < 0) { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i++; - } - else if (!strcmp(arg, "--max-clients")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - if ((server_options.max_clients = atoi(argv[i + 1])) <= 0) { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i++; - } - else if (!strcmp(arg, "--max-connections-for-client")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - if ((server_options.max_connections_for_client = atoi(argv[i + 1])) <= 0) { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i++; - } - else if (!strcmp(arg, "--client-socket-sndbuf")) { - if (1 >= argc - i) { - fprintf(stderr, "%s: requires an argument\n", arg); - return 0; - } - if ((server_options.client_socket_sndbuf = atoi(argv[i + 1])) < 0) { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i++; - } - else if (!strcmp(arg, "--local-udp-addrs")) { - if (2 >= argc - i) { - fprintf(stderr, "%s: requires two arguments\n", arg); - return 0; - } - server_options.local_udp_addr = argv[i + 1]; - if ((server_options.local_udp_num_ports = atoi(argv[i + 2])) < 0) { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i += 2; - } - else if (!strcmp(arg, "--local-udp-ip6-addrs")) { - if (2 >= argc - i) { - fprintf(stderr, "%s: requires two arguments\n", arg); - return 0; - } - server_options.local_udp_ip6_addr = argv[i + 1]; - if ((server_options.local_udp_ip6_num_ports = atoi(argv[i + 2])) < 0) { - fprintf(stderr, "%s: wrong argument\n", arg); - return 0; - } - i += 2; - } - else if (!strcmp(arg, "--unique-local-ports")) { - server_options.unique_local_ports = 1; - } - else { - fprintf(stderr, "unknown option: %s\n", arg); - return 0; - } - } - - if (server_options.help || server_options.version) { - return 1; - } - - return 1; -} - -int process_arguments (void) -{ - // resolve listen addresses - num_listen_addrs = 0; - while (num_listen_addrs < server_options.num_listen_addrs) { - if (!BAddr_Parse(&listen_addrs[num_listen_addrs], server_options.listen_addrs[num_listen_addrs], NULL, 0)) { - BLog(BLOG_ERROR, "listen addr: BAddr_Parse failed"); - return 0; - } - num_listen_addrs++; - } - - // resolve local UDP address - if (server_options.local_udp_num_ports >= 0) { - if (!BAddr_Parse(&local_udp_addr, server_options.local_udp_addr, NULL, 0)) { - BLog(BLOG_ERROR, "local udp addr: BAddr_Parse failed"); - return 0; - } - if (local_udp_addr.type != BADDR_TYPE_IPV4) { - BLog(BLOG_ERROR, "local udp addr: must be an IPv4 address"); - return 0; - } - } - - // resolve local UDP/IPv6 address - if (server_options.local_udp_ip6_num_ports >= 0) { - if (!BAddr_Parse(&local_udp_ip6_addr, server_options.local_udp_ip6_addr, NULL, 0)) { - BLog(BLOG_ERROR, "local udp ip6 addr: BAddr_Parse failed"); - return 0; - } - if (local_udp_ip6_addr.type != BADDR_TYPE_IPV6) { - BLog(BLOG_ERROR, "local udp ip6 addr: must be an IPv6 address"); - return 0; - } - } - - return 1; -} - -void signal_handler (void *unused) -{ - BLog(BLOG_NOTICE, "termination requested"); - - // exit event loop - BReactor_Quit(&server_ss, 1); -} - -void listener_handler (BListener *listener) -{ - if (server_num_clients == server_options.max_clients) { - BLog(BLOG_ERROR, "maximum number of clients reached"); - goto fail0; - } - - // allocate structure - struct client *client = (struct client *)malloc(sizeof(*client)); - if (!client) { - BLog(BLOG_ERROR, "malloc failed"); - goto fail0; - } - - // accept client - if (!BConnection_Init(&client->con, BConnection_source_listener(listener, &client->addr), &server_ss, client, (BConnection_handler)client_connection_handler)) { - BLog(BLOG_ERROR, "BConnection_Init failed"); - goto fail1; - } - - // limit socket send buffer, else our scheduling is pointless - if (server_options.client_socket_sndbuf > 0) { - if (!BConnection_SetSendBuffer(&client->con, server_options.client_socket_sndbuf)) { - BLog(BLOG_WARNING, "BConnection_SetSendBuffer failed"); - } - } - - // init connection interfaces - BConnection_SendAsync_Init(&client->con); - BConnection_RecvAsync_Init(&client->con); - - // init disconnect timer - BTimer_Init(&client->disconnect_timer, CLIENT_DISCONNECT_TIMEOUT, (BTimer_handler)client_disconnect_timer_handler, client); - BReactor_SetTimer(&server_ss, &client->disconnect_timer); - - // init recv interface - PacketPassInterface_Init(&client->recv_if, udpgw_mtu, (PacketPassInterface_handler_send)client_recv_if_handler_send, client, BReactor_PendingGroup(&server_ss)); - - // init recv decoder - if (!PacketProtoDecoder_Init(&client->recv_decoder, BConnection_RecvAsync_GetIf(&client->con), &client->recv_if, BReactor_PendingGroup(&server_ss), client, - (PacketProtoDecoder_handler_error)client_decoder_handler_error - )) { - BLog(BLOG_ERROR, "PacketProtoDecoder_Init failed"); - goto fail2; - } - - // init send sender - PacketStreamSender_Init(&client->send_sender, BConnection_SendAsync_GetIf(&client->con), pp_mtu, BReactor_PendingGroup(&server_ss)); - - // init send queue - if (!PacketPassFairQueue_Init(&client->send_queue, PacketStreamSender_GetInput(&client->send_sender), BReactor_PendingGroup(&server_ss), 0, 1)) { - BLog(BLOG_ERROR, "PacketPassFairQueue_Init failed"); - goto fail3; - } - - // init connections tree - BAVL_Init(&client->connections_tree, OFFSET_DIFF(struct connection, conid, connections_tree_node), (BAVL_comparator)uint16_comparator, NULL); - - // init connections list - LinkedList1_Init(&client->connections_list); - - // set zero connections - client->num_connections = 0; - - // init closing connections list - LinkedList1_Init(&client->closing_connections_list); - - // insert to clients list - LinkedList1_Append(&clients_list, &client->clients_list_node); - server_num_clients++; - - client_log(client, BLOG_INFO, "connected"); - - return; - -fail3: - PacketStreamSender_Free(&client->send_sender); - PacketProtoDecoder_Free(&client->recv_decoder); -fail2: - PacketPassInterface_Free(&client->recv_if); - BReactor_RemoveTimer(&server_ss, &client->disconnect_timer); - BConnection_RecvAsync_Free(&client->con); - BConnection_SendAsync_Free(&client->con); - BConnection_Free(&client->con); -fail1: - free(client); -fail0: - return; -} - -void client_free (struct client *client) -{ - // allow freeing send queue flows - PacketPassFairQueue_PrepareFree(&client->send_queue); - - // free connections - while (!LinkedList1_IsEmpty(&client->connections_list)) { - struct connection *con = UPPER_OBJECT(LinkedList1_GetFirst(&client->connections_list), struct connection, connections_list_node); - connection_free(con); - } - - // free closing connections - while (!LinkedList1_IsEmpty(&client->closing_connections_list)) { - struct connection *con = UPPER_OBJECT(LinkedList1_GetFirst(&client->closing_connections_list), struct connection, closing_connections_list_node); - connection_free(con); - } - - // remove from clients list - LinkedList1_Remove(&clients_list, &client->clients_list_node); - server_num_clients--; - - // free send queue - PacketPassFairQueue_Free(&client->send_queue); - - // free send sender - PacketStreamSender_Free(&client->send_sender); - - // free recv decoder - PacketProtoDecoder_Free(&client->recv_decoder); - - // free recv interface - PacketPassInterface_Free(&client->recv_if); - - // free disconnect timer - BReactor_RemoveTimer(&server_ss, &client->disconnect_timer); - - // free connection interfaces - BConnection_RecvAsync_Free(&client->con); - BConnection_SendAsync_Free(&client->con); - - // free connection - BConnection_Free(&client->con); - - // free structure - free(client); -} - -void client_logfunc (struct client *client) -{ - char addr[BADDR_MAX_PRINT_LEN]; - BAddr_Print(&client->addr, addr); - - BLog_Append("client (%s): ", addr); -} - -void client_log (struct client *client, int level, const char *fmt, ...) -{ - va_list vl; - va_start(vl, fmt); - BLog_LogViaFuncVarArg((BLog_logfunc)client_logfunc, client, BLOG_CURRENT_CHANNEL, level, fmt, vl); - va_end(vl); -} - -void client_disconnect_timer_handler (struct client *client) -{ - client_log(client, BLOG_INFO, "timed out, disconnecting"); - - // free client - client_free(client); -} - -void client_connection_handler (struct client *client, int event) -{ - if (event == BCONNECTION_EVENT_RECVCLOSED) { - client_log(client, BLOG_INFO, "client closed"); - } else { - client_log(client, BLOG_INFO, "client error"); - } - - // free client - client_free(client); -} - -void client_decoder_handler_error (struct client *client) -{ - client_log(client, BLOG_ERROR, "decoder error"); - - // free client - client_free(client); -} - -void client_recv_if_handler_send (struct client *client, uint8_t *data, int data_len) -{ - ASSERT(data_len >= 0) - ASSERT(data_len <= udpgw_mtu) - - // accept packet - PacketPassInterface_Done(&client->recv_if); - - // parse header - if (data_len < sizeof(struct udpgw_header)) { - client_log(client, BLOG_ERROR, "missing header"); - return; - } - struct udpgw_header header; - memcpy(&header, data, sizeof(header)); - data += sizeof(header); - data_len -= sizeof(header); - uint8_t flags = ltoh8(header.flags); - uint16_t conid = ltoh16(header.conid); - - // reset disconnect timer - BReactor_SetTimer(&server_ss, &client->disconnect_timer); - - // if this is keepalive, ignore any payload - if ((flags & UDPGW_CLIENT_FLAG_KEEPALIVE)) { - client_log(client, BLOG_DEBUG, "received keepalive"); - return; - } - - // parse address - BAddr orig_addr; - if ((flags & UDPGW_CLIENT_FLAG_IPV6)) { - if (data_len < sizeof(struct udpgw_addr_ipv6)) { - client_log(client, BLOG_ERROR, "missing ipv6 address"); - return; - } - struct udpgw_addr_ipv6 addr_ipv6; - memcpy(&addr_ipv6, data, sizeof(addr_ipv6)); - data += sizeof(addr_ipv6); - data_len -= sizeof(addr_ipv6); - BAddr_InitIPv6(&orig_addr, addr_ipv6.addr_ip, addr_ipv6.addr_port); - } else { - if (data_len < sizeof(struct udpgw_addr_ipv4)) { - client_log(client, BLOG_ERROR, "missing ipv4 address"); - return; - } - struct udpgw_addr_ipv4 addr_ipv4; - memcpy(&addr_ipv4, data, sizeof(addr_ipv4)); - data += sizeof(addr_ipv4); - data_len -= sizeof(addr_ipv4); - BAddr_InitIPv4(&orig_addr, addr_ipv4.addr_ip, addr_ipv4.addr_port); - } - - // check payload length - if (data_len > server_options.udp_mtu) { - client_log(client, BLOG_ERROR, "too much data"); - return; - } - - // find connection - struct connection *con = find_connection(client, conid); - ASSERT(!con || !con->closing) - - // if connection exists, close it if needed - if (con && ((flags & UDPGW_CLIENT_FLAG_REBIND) || !BAddr_Compare(&con->orig_addr, &orig_addr))) { - connection_log(con, BLOG_DEBUG, "close old"); - connection_close(con); - con = NULL; - } - - // if connection doesn't exists, create it - if (!con) { - // check number of connections - if (client->num_connections == server_options.max_connections_for_client) { - // close least recently used connection - con = UPPER_OBJECT(LinkedList1_GetFirst(&client->connections_list), struct connection, connections_list_node); - connection_close(con); - } - - // if this is DNS, replace actual address, but keep still remember the orig_addr - BAddr addr = orig_addr; - if ((flags & UDPGW_CLIENT_FLAG_DNS)) { - maybe_update_dns(); - if (dns_addr.type == BADDR_TYPE_NONE) { - client_log(client, BLOG_WARNING, "received DNS packet, but no DNS server available"); - } else { - client_log(client, BLOG_DEBUG, "received DNS"); - addr = dns_addr; - } - } - - // create new connection - connection_init(client, conid, addr, orig_addr, data, data_len); - } else { - // submit packet to existing connection - connection_send_to_udp(con, data, data_len); - } -} - -int get_local_num_ports (int addr_type) -{ - switch (addr_type) { - case BADDR_TYPE_IPV4: return server_options.local_udp_num_ports; - case BADDR_TYPE_IPV6: return server_options.local_udp_ip6_num_ports; - default: ASSERT(0); return 0; - } -} - -BAddr get_local_addr (int addr_type) -{ - ASSERT(get_local_num_ports(addr_type) >= 0) - - switch (addr_type) { - case BADDR_TYPE_IPV4: return local_udp_addr; - case BADDR_TYPE_IPV6: return local_udp_ip6_addr; - default: ASSERT(0); return BAddr_MakeNone(); - } -} - -uint8_t * build_port_usage_array_and_find_least_used_connection (BAddr remote_addr, struct connection **out_con) -{ - ASSERT(remote_addr.type == BADDR_TYPE_IPV4 || remote_addr.type == BADDR_TYPE_IPV6) - ASSERT(get_local_num_ports(remote_addr.type) >= 0) - - int local_num_ports = get_local_num_ports(remote_addr.type); - - // allocate port usage array - uint8_t *port_usage = (uint8_t *)BAllocSize(bsize_fromint(local_num_ports)); - if (!port_usage) { - return NULL; - } - - // zero array - memset(port_usage, 0, local_num_ports); - - struct connection *least_con = NULL; - - // flag inappropriate ports (those with the same remote address) - for (LinkedList1Node *ln = LinkedList1_GetFirst(&clients_list); ln; ln = LinkedList1Node_Next(ln)) { - struct client *client = UPPER_OBJECT(ln, struct client, clients_list_node); - - for (LinkedList1Node *ln2 = LinkedList1_GetFirst(&client->connections_list); ln2; ln2 = LinkedList1Node_Next(ln2)) { - struct connection *con = UPPER_OBJECT(ln2, struct connection, connections_list_node); - ASSERT(con->client == client) - ASSERT(!con->closing) - - if (con->addr.type != remote_addr.type || con->local_port_index < 0) { - continue; - } - ASSERT(con->local_port_index < local_num_ports) - - if (server_options.unique_local_ports) { - BIPAddr ip1; - BIPAddr ip2; - BAddr_GetIPAddr(&con->addr, &ip1); - BAddr_GetIPAddr(&remote_addr, &ip2); - if (!BIPAddr_Compare(&ip1, &ip2)) { - continue; - } - } else { - if (!BAddr_Compare(&con->addr, &remote_addr)) { - continue; - } - } - - port_usage[con->local_port_index] = 1; - - if (!PacketPassFairQueueFlow_IsBusy(&con->send_qflow)) { - if (!least_con || con->last_use_time < least_con->last_use_time) { - least_con = con; - } - } - } - } - - *out_con = least_con; - return port_usage; -} - -void connection_init (struct client *client, uint16_t conid, BAddr addr, BAddr orig_addr, const uint8_t *data, int data_len) -{ - ASSERT(client->num_connections < server_options.max_connections_for_client) - ASSERT(!find_connection(client, conid)) - BAddr_Assert(&addr); - ASSERT(addr.type == BADDR_TYPE_IPV4 || addr.type == BADDR_TYPE_IPV6) - ASSERT(orig_addr.type == BADDR_TYPE_IPV4 || orig_addr.type == BADDR_TYPE_IPV6) - ASSERT(data_len >= 0) - ASSERT(data_len <= server_options.udp_mtu) - - // allocate structure - struct connection *con = (struct connection *)malloc(sizeof(*con)); - if (!con) { - client_log(client, BLOG_ERROR, "malloc failed"); - goto fail0; - } - - // init arguments - con->client = client; - con->conid = conid; - con->addr = addr; - con->orig_addr = orig_addr; - con->first_data = data; - con->first_data_len = data_len; - - // set last use time - con->last_use_time = btime_gettime(); - - // set not closing - con->closing = 0; - - // init first job - BPending_Init(&con->first_job, BReactor_PendingGroup(&server_ss), (BPending_handler)connection_first_job_handler, con); - BPending_Set(&con->first_job); - - // init send queue flow - PacketPassFairQueueFlow_Init(&con->send_qflow, &client->send_queue); - - // init send PacketProtoFlow - if (!PacketProtoFlow_Init(&con->send_ppflow, udpgw_mtu, CONNECTION_CLIENT_BUFFER_SIZE, PacketPassFairQueueFlow_GetInput(&con->send_qflow), BReactor_PendingGroup(&server_ss))) { - client_log(client, BLOG_ERROR, "PacketProtoFlow_Init failed"); - goto fail1; - } - con->send_if = PacketProtoFlow_GetInput(&con->send_ppflow); - - // init UDP dgram - if (!BDatagram_Init(&con->udp_dgram, addr.type, &server_ss, con, (BDatagram_handler)connection_dgram_handler_event)) { - client_log(client, BLOG_ERROR, "BDatagram_Init failed"); - goto fail2; - } - - con->local_port_index = -1; - - int local_num_ports = get_local_num_ports(addr.type); - - if (local_num_ports >= 0) { - // build port usage array, find least used connection - struct connection *least_con; - uint8_t *port_usage = build_port_usage_array_and_find_least_used_connection(addr, &least_con); - if (!port_usage) { - client_log(client, BLOG_ERROR, "build_port_usage_array failed"); - goto failed; - } - - // set SO_REUSEADDR - if (!BDatagram_SetReuseAddr(&con->udp_dgram, 1)) { - client_log(client, BLOG_ERROR, "set SO_REUSEADDR failed"); - goto failed; - } - - // get starting local address - BAddr local_addr = get_local_addr(addr.type); - - // try different ports - for (int i = 0; i < local_num_ports; i++) { - // skip inappropriate ports - if (port_usage[i]) { - continue; - } - - BAddr bind_addr = local_addr; - BAddr_SetPort(&bind_addr, hton16(ntoh16(BAddr_GetPort(&bind_addr)) + (uint16_t)i)); - if (BDatagram_Bind(&con->udp_dgram, bind_addr)) { - // remember which port we're using - con->local_port_index = i; - goto cont; - } - } - - // try closing an unused connection with the same remote addr - if (!least_con) { - goto failed; - } - - ASSERT(least_con->addr.type == addr.type) - ASSERT(least_con->local_port_index >= 0) - ASSERT(least_con->local_port_index < local_num_ports) - ASSERT(!PacketPassFairQueueFlow_IsBusy(&least_con->send_qflow)) - - int i = least_con->local_port_index; - - BLog(BLOG_INFO, "closing connection for its remote address"); - - // close the offending connection - connection_close(least_con); - - // try binding to its port - BAddr bind_addr = local_addr; - BAddr_SetPort(&bind_addr, hton16(ntoh16(BAddr_GetPort(&bind_addr)) + (uint16_t)i)); - if (BDatagram_Bind(&con->udp_dgram, bind_addr)) { - // remember which port we're using - con->local_port_index = i; - goto cont; - } - - failed: - client_log(client, BLOG_WARNING, "failed to bind to any local address; proceeding regardless"); - cont:; - BFree(port_usage); - } - - // set UDP dgram send address - BIPAddr ipaddr; - BIPAddr_InitInvalid(&ipaddr); - BDatagram_SetSendAddrs(&con->udp_dgram, addr, ipaddr); - - // init UDP dgram interfaces - BDatagram_SendAsync_Init(&con->udp_dgram, server_options.udp_mtu); - BDatagram_RecvAsync_Init(&con->udp_dgram, server_options.udp_mtu); - - // init UDP writer - BufferWriter_Init(&con->udp_send_writer, server_options.udp_mtu, BReactor_PendingGroup(&server_ss)); - - // init UDP buffer - if (!PacketBuffer_Init(&con->udp_send_buffer, BufferWriter_GetOutput(&con->udp_send_writer), BDatagram_SendAsync_GetIf(&con->udp_dgram), CONNECTION_UDP_BUFFER_SIZE, BReactor_PendingGroup(&server_ss))) { - client_log(client, BLOG_ERROR, "PacketBuffer_Init failed"); - goto fail4; - } - - // init UDP recv interface - PacketPassInterface_Init(&con->udp_recv_if, server_options.udp_mtu, (PacketPassInterface_handler_send)connection_udp_recv_if_handler_send, con, BReactor_PendingGroup(&server_ss)); - - // init UDP recv buffer - if (!SinglePacketBuffer_Init(&con->udp_recv_buffer, BDatagram_RecvAsync_GetIf(&con->udp_dgram), &con->udp_recv_if, BReactor_PendingGroup(&server_ss))) { - client_log(client, BLOG_ERROR, "SinglePacketBuffer_Init failed"); - goto fail5; - } - - // insert to client's connections tree - ASSERT_EXECUTE(BAVL_Insert(&client->connections_tree, &con->connections_tree_node, NULL)) - - // insert to client's connections list - LinkedList1_Append(&client->connections_list, &con->connections_list_node); - - // increment number of connections - client->num_connections++; - - connection_log(con, BLOG_DEBUG, "initialized"); - - return; - -fail5: - PacketPassInterface_Free(&con->udp_recv_if); - PacketBuffer_Free(&con->udp_send_buffer); -fail4: - BufferWriter_Free(&con->udp_send_writer); - BDatagram_RecvAsync_Free(&con->udp_dgram); - BDatagram_SendAsync_Free(&con->udp_dgram); - BDatagram_Free(&con->udp_dgram); -fail2: - PacketProtoFlow_Free(&con->send_ppflow); -fail1: - PacketPassFairQueueFlow_Free(&con->send_qflow); - BPending_Free(&con->first_job); - free(con); -fail0: - return; -} - -void connection_free (struct connection *con) -{ - struct client *client = con->client; - PacketPassFairQueueFlow_AssertFree(&con->send_qflow); - - if (con->closing) { - // remove from client's closing connections list - LinkedList1_Remove(&client->closing_connections_list, &con->closing_connections_list_node); - } else { - // decrement number of connections - client->num_connections--; - - // remove from client's connections list - LinkedList1_Remove(&client->connections_list, &con->connections_list_node); - - // remove from client's connections tree - BAVL_Remove(&client->connections_tree, &con->connections_tree_node); - - // free UDP - connection_free_udp(con); - } - - // free send PacketProtoFlow - PacketProtoFlow_Free(&con->send_ppflow); - - // free send queue flow - PacketPassFairQueueFlow_Free(&con->send_qflow); - - // free first job - BPending_Free(&con->first_job); - - // free structure - free(con); -} - -void connection_logfunc (struct connection *con) -{ - client_logfunc(con->client); - - if (con->closing) { - BLog_Append("old connection %"PRIu16": ", con->conid); - } else { - BLog_Append("connection %"PRIu16": ", con->conid); - } -} - -void connection_log (struct connection *con, int level, const char *fmt, ...) -{ - va_list vl; - va_start(vl, fmt); - BLog_LogViaFuncVarArg((BLog_logfunc)connection_logfunc, con, BLOG_CURRENT_CHANNEL, level, fmt, vl); - va_end(vl); -} - -void connection_free_udp (struct connection *con) -{ - // free UDP receive buffer - SinglePacketBuffer_Free(&con->udp_recv_buffer); - - // free UDP receive interface - PacketPassInterface_Free(&con->udp_recv_if); - - // free UDP buffer - PacketBuffer_Free(&con->udp_send_buffer); - - // free UDP writer - BufferWriter_Free(&con->udp_send_writer); - - // free UDP dgram interfaces - BDatagram_RecvAsync_Free(&con->udp_dgram); - BDatagram_SendAsync_Free(&con->udp_dgram); - - // free UDP dgram - BDatagram_Free(&con->udp_dgram); -} - -void connection_first_job_handler (struct connection *con) -{ - ASSERT(!con->closing) - - connection_send_to_udp(con, con->first_data, con->first_data_len); -} - -void connection_send_to_client (struct connection *con, uint8_t flags, const uint8_t *data, int data_len) -{ - ASSERT(data_len >= 0) - ASSERT(data_len <= server_options.udp_mtu) - - size_t addr_len = (con->orig_addr.type == BADDR_TYPE_IPV6) ? sizeof(struct udpgw_addr_ipv6) : - (con->orig_addr.type == BADDR_TYPE_IPV4) ? sizeof(struct udpgw_addr_ipv4) : 0; - if (data_len > udpgw_mtu - (int)(sizeof(struct udpgw_header) + addr_len)) { - connection_log(con, BLOG_WARNING, "packet is too large, cannot send to client"); - return; - } - - // get buffer location - uint8_t *out; - if (!BufferWriter_StartPacket(con->send_if, &out)) { - connection_log(con, BLOG_ERROR, "out of client buffer"); - return; - } - int out_pos = 0; - - if (con->orig_addr.type == BADDR_TYPE_IPV6) { - flags |= UDPGW_CLIENT_FLAG_IPV6; - } - - // write header - struct udpgw_header header; - header.flags = htol8(flags); - header.conid = htol16(con->conid); - memcpy(out + out_pos, &header, sizeof(header)); - out_pos += sizeof(header); - - // write address - switch (con->orig_addr.type) { - case BADDR_TYPE_IPV4: { - struct udpgw_addr_ipv4 addr_ipv4; - addr_ipv4.addr_ip = con->orig_addr.ipv4.ip; - addr_ipv4.addr_port = con->orig_addr.ipv4.port; - memcpy(out + out_pos, &addr_ipv4, sizeof(addr_ipv4)); - out_pos += sizeof(addr_ipv4); - } break; - case BADDR_TYPE_IPV6: { - struct udpgw_addr_ipv6 addr_ipv6; - memcpy(addr_ipv6.addr_ip, con->orig_addr.ipv6.ip, sizeof(addr_ipv6.addr_ip)); - addr_ipv6.addr_port = con->orig_addr.ipv6.port; - memcpy(out + out_pos, &addr_ipv6, sizeof(addr_ipv6)); - out_pos += sizeof(addr_ipv6); - } break; - } - - // write message - memcpy(out + out_pos, data, data_len); - out_pos += data_len; - - // submit written message - ASSERT(out_pos <= udpgw_mtu) - BufferWriter_EndPacket(con->send_if, out_pos); -} - -int connection_send_to_udp (struct connection *con, const uint8_t *data, int data_len) -{ - struct client *client = con->client; - ASSERT(!con->closing) - ASSERT(data_len >= 0) - ASSERT(data_len <= server_options.udp_mtu) - - connection_log(con, BLOG_DEBUG, "from client %d bytes", data_len); - - // set last use time - con->last_use_time = btime_gettime(); - - // move connection to front - LinkedList1_Remove(&client->connections_list, &con->connections_list_node); - LinkedList1_Append(&client->connections_list, &con->connections_list_node); - - // get buffer location - uint8_t *out; - if (!BufferWriter_StartPacket(&con->udp_send_writer, &out)) { - connection_log(con, BLOG_ERROR, "out of UDP buffer"); - return 0; - } - - // write message - memcpy(out, data, data_len); - - // submit written message - BufferWriter_EndPacket(&con->udp_send_writer, data_len); - - return 1; -} - -void connection_close (struct connection *con) -{ - struct client *client = con->client; - ASSERT(!con->closing) - - // if possible, free connection immediately - if (!PacketPassFairQueueFlow_IsBusy(&con->send_qflow)) { - connection_free(con); - return; - } - - connection_log(con, BLOG_DEBUG, "closing later"); - - // decrement number of connections - client->num_connections--; - - // remove from client's connections list - LinkedList1_Remove(&client->connections_list, &con->connections_list_node); - - // remove from client's connections tree - BAVL_Remove(&client->connections_tree, &con->connections_tree_node); - - // free UDP - connection_free_udp(con); - - // insert to client's closing connections list - LinkedList1_Append(&client->closing_connections_list, &con->closing_connections_list_node); - - // set busy handler - PacketPassFairQueueFlow_SetBusyHandler(&con->send_qflow, (PacketPassFairQueue_handler_busy)connection_send_qflow_busy_handler, con); - - // unset first job - BPending_Unset(&con->first_job); - - // set closing - con->closing = 1; -} - -void connection_send_qflow_busy_handler (struct connection *con) -{ - ASSERT(con->closing) - PacketPassFairQueueFlow_AssertFree(&con->send_qflow); - - connection_log(con, BLOG_DEBUG, "closing finally"); - - // free connection - connection_free(con); -} - -void connection_dgram_handler_event (struct connection *con, int event) -{ - ASSERT(!con->closing) - - connection_log(con, BLOG_INFO, "UDP error"); - - // close connection - connection_close(con); -} - -void connection_udp_recv_if_handler_send (struct connection *con, uint8_t *data, int data_len) -{ - struct client *client = con->client; - ASSERT(!con->closing) - ASSERT(data_len >= 0) - ASSERT(data_len <= server_options.udp_mtu) - - connection_log(con, BLOG_DEBUG, "from UDP %d bytes", data_len); - - // set last use time - con->last_use_time = btime_gettime(); - - // move connection to front - LinkedList1_Remove(&client->connections_list, &con->connections_list_node); - LinkedList1_Append(&client->connections_list, &con->connections_list_node); - - // accept packet - PacketPassInterface_Done(&con->udp_recv_if); - - // send packet to client - connection_send_to_client(con, 0, data, data_len); -} - -struct connection * find_connection (struct client *client, uint16_t conid) -{ - BAVLNode *tree_node = BAVL_LookupExact(&client->connections_tree, &conid); - if (!tree_node) { - return NULL; - } - struct connection *con = UPPER_OBJECT(tree_node, struct connection, connections_tree_node); - ASSERT(con->conid == conid) - ASSERT(!con->closing) - - return con; -} - -int uint16_comparator (void *unused, uint16_t *v1, uint16_t *v2) -{ - return B_COMPARE(*v1, *v2); -} - -void maybe_update_dns (void) -{ -#ifndef BADVPN_USE_WINAPI - btime_t now = btime_gettime(); - if (now < btime_add(last_dns_update_time, DNS_UPDATE_TIME)) { - return; - } - last_dns_update_time = now; - BLog(BLOG_DEBUG, "update dns"); - - if (res_init() != 0) { - BLog(BLOG_ERROR, "res_init failed"); - goto fail; - } - - if (_res.nscount == 0) { - BLog(BLOG_ERROR, "no name servers available"); - goto fail; - } - - BAddr addr; - BAddr_InitIPv4(&addr, _res.nsaddr_list[0].sin_addr.s_addr, hton16(53)); - - if (!BAddr_Compare(&addr, &dns_addr)) { - char str[BADDR_MAX_PRINT_LEN]; - BAddr_Print(&addr, str); - BLog(BLOG_INFO, "using DNS server %s", str); - } - - dns_addr = addr; - return; - -fail: - BAddr_InitNone(&dns_addr); -#endif -} \ No newline at end of file diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw/udpgw.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw/udpgw.h deleted file mode 100644 index 45f2e5e4..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw/udpgw.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) Ambroz Bizjak - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// name of the program -#define PROGRAM_NAME "udpgw" - -// maxiumum listen addresses -#define MAX_LISTEN_ADDRS 16 - -// maximum datagram size -#define DEFAULT_UDP_MTU 65520 - -// connection buffer size for sending to client, in packets -#define CONNECTION_CLIENT_BUFFER_SIZE 1 - -// connection buffer size for sending to UDP, in packets -#define CONNECTION_UDP_BUFFER_SIZE 1 - -// maximum number of clients -#define DEFAULT_MAX_CLIENTS 3 - -// maximum connections for client -#define DEFAULT_MAX_CONNECTIONS_FOR_CLIENT 256 - -// how long after nothing has been received to disconnect a client -#define CLIENT_DISCONNECT_TIMEOUT 20000 - -// SO_SNDBFUF socket option for clients, 0 to not set -#define CLIENT_DEFAULT_SOCKET_SEND_BUFFER 1048576 - -extern int udpgw_main (int argc, char **argv); \ No newline at end of file diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw_client/UdpGwClient.c b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw_client/UdpGwClient.c deleted file mode 100644 index e4e458cc..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw_client/UdpGwClient.c +++ /dev/null @@ -1,597 +0,0 @@ -/* - * Copyright (C) Ambroz Bizjak - * Contributions: - * Transparent DNS: Copyright (C) Kerem Hadimli - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include "misc/offset.h" -#include "misc/byteorder.h" -#include "misc/compare.h" -#include "base/BLog.h" - -#include "udpgw_client/UdpGwClient.h" - -#include "generated/blog_channel_UdpGwClient.h" - -static int uint16_comparator (void *unused, uint16_t *v1, uint16_t *v2); -static int conaddr_comparator (void *unused, struct UdpGwClient_conaddr *v1, struct UdpGwClient_conaddr *v2); -static void free_server (UdpGwClient *o); -static void decoder_handler_error (UdpGwClient *o); -static void recv_interface_handler_send (UdpGwClient *o, uint8_t *data, int data_len); -static void send_monitor_handler (UdpGwClient *o); -static void keepalive_if_handler_done (UdpGwClient *o); -static struct UdpGwClient_connection * find_connection_by_conaddr (UdpGwClient *o, struct UdpGwClient_conaddr conaddr); -static struct UdpGwClient_connection * find_connection_by_conid (UdpGwClient *o, uint16_t conid); -static uint16_t find_unused_conid (UdpGwClient *o); -static void connection_init (UdpGwClient *o, struct UdpGwClient_conaddr conaddr, uint8_t flags, const uint8_t *data, int data_len); -static void connection_free (struct UdpGwClient_connection *con); -static void connection_first_job_handler (struct UdpGwClient_connection *con); -static void connection_send (struct UdpGwClient_connection *con, uint8_t flags, const uint8_t *data, int data_len); -static struct UdpGwClient_connection * reuse_connection (UdpGwClient *o, struct UdpGwClient_conaddr conaddr); - -static int uint16_comparator (void *unused, uint16_t *v1, uint16_t *v2) -{ - return B_COMPARE(*v1, *v2); -} - -static int conaddr_comparator (void *unused, struct UdpGwClient_conaddr *v1, struct UdpGwClient_conaddr *v2) -{ - int r = BAddr_CompareOrder(&v1->remote_addr, &v2->remote_addr); - if (r) { - return r; - } - return BAddr_CompareOrder(&v1->local_addr, &v2->local_addr); -} - -static void free_server (UdpGwClient *o) -{ - // disconnect send connector - PacketPassConnector_DisconnectOutput(&o->send_connector); - - // free send sender - PacketStreamSender_Free(&o->send_sender); - - // free receive decoder - PacketProtoDecoder_Free(&o->recv_decoder); - - // free receive interface - PacketPassInterface_Free(&o->recv_if); -} - -static void decoder_handler_error (UdpGwClient *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->have_server) - - BLog(BLOG_ERROR, "decoder error"); - - // report error - o->handler_servererror(o->user); - return; -} - -static void recv_interface_handler_send (UdpGwClient *o, uint8_t *data, int data_len) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->have_server) - ASSERT(data_len >= 0) - ASSERT(data_len <= o->udpgw_mtu) - - // accept packet - PacketPassInterface_Done(&o->recv_if); - - // check header - if (data_len < sizeof(struct udpgw_header)) { - BLog(BLOG_ERROR, "missing header"); - return; - } - struct udpgw_header header; - memcpy(&header, data, sizeof(header)); - data += sizeof(header); - data_len -= sizeof(header); - uint8_t flags = ltoh8(header.flags); - uint16_t conid = ltoh16(header.conid); - - // parse address - BAddr remote_addr; - if ((flags & UDPGW_CLIENT_FLAG_IPV6)) { - if (data_len < sizeof(struct udpgw_addr_ipv6)) { - BLog(BLOG_ERROR, "missing ipv6 address"); - return; - } - struct udpgw_addr_ipv6 addr_ipv6; - memcpy(&addr_ipv6, data, sizeof(addr_ipv6)); - data += sizeof(addr_ipv6); - data_len -= sizeof(addr_ipv6); - BAddr_InitIPv6(&remote_addr, addr_ipv6.addr_ip, addr_ipv6.addr_port); - } else { - if (data_len < sizeof(struct udpgw_addr_ipv4)) { - BLog(BLOG_ERROR, "missing ipv4 address"); - return; - } - struct udpgw_addr_ipv4 addr_ipv4; - memcpy(&addr_ipv4, data, sizeof(addr_ipv4)); - data += sizeof(addr_ipv4); - data_len -= sizeof(addr_ipv4); - BAddr_InitIPv4(&remote_addr, addr_ipv4.addr_ip, addr_ipv4.addr_port); - } - - // check remaining data - if (data_len > o->udp_mtu) { - BLog(BLOG_ERROR, "too much data"); - return; - } - - // find connection - struct UdpGwClient_connection *con = find_connection_by_conid(o, conid); - if (!con) { - BLog(BLOG_ERROR, "unknown conid"); - return; - } - - // check remote address - if (BAddr_CompareOrder(&con->conaddr.remote_addr, &remote_addr) != 0) { - BLog(BLOG_ERROR, "wrong remote address"); - return; - } - - // move connection to front of the list - LinkedList1_Remove(&o->connections_list, &con->connections_list_node); - LinkedList1_Append(&o->connections_list, &con->connections_list_node); - - // pass packet to user - o->handler_received(o->user, con->conaddr.local_addr, con->conaddr.remote_addr, data, data_len); - return; -} - -static void send_monitor_handler (UdpGwClient *o) -{ - DebugObject_Access(&o->d_obj); - - if (o->keepalive_sending) { - return; - } - - BLog(BLOG_INFO, "keepalive"); - - // send keepalive - PacketPassInterface_Sender_Send(o->keepalive_if, (uint8_t *)&o->keepalive_packet, sizeof(o->keepalive_packet)); - - // set sending keep-alive - o->keepalive_sending = 1; -} - -static void keepalive_if_handler_done (UdpGwClient *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->keepalive_sending) - - // set not sending keepalive - o->keepalive_sending = 0; -} - -static struct UdpGwClient_connection * find_connection_by_conaddr (UdpGwClient *o, struct UdpGwClient_conaddr conaddr) -{ - BAVLNode *tree_node = BAVL_LookupExact(&o->connections_tree_by_conaddr, &conaddr); - if (!tree_node) { - return NULL; - } - - return UPPER_OBJECT(tree_node, struct UdpGwClient_connection, connections_tree_by_conaddr_node); -} - -static struct UdpGwClient_connection * find_connection_by_conid (UdpGwClient *o, uint16_t conid) -{ - BAVLNode *tree_node = BAVL_LookupExact(&o->connections_tree_by_conid, &conid); - if (!tree_node) { - return NULL; - } - - return UPPER_OBJECT(tree_node, struct UdpGwClient_connection, connections_tree_by_conid_node); -} - -static uint16_t find_unused_conid (UdpGwClient *o) -{ - ASSERT(o->num_connections < o->max_connections) - - while (1) { - if (!find_connection_by_conid(o, o->next_conid)) { - return o->next_conid; - } - - if (o->next_conid == o->max_connections - 1) { - o->next_conid = 0; - } else { - o->next_conid++; - } - } -} - -static void connection_init (UdpGwClient *o, struct UdpGwClient_conaddr conaddr, uint8_t flags, const uint8_t *data, int data_len) -{ - ASSERT(o->num_connections < o->max_connections) - ASSERT(!find_connection_by_conaddr(o, conaddr)) - ASSERT(data_len >= 0) - ASSERT(data_len <= o->udp_mtu) - - // allocate structure - struct UdpGwClient_connection *con = (struct UdpGwClient_connection *)malloc(sizeof(*con)); - if (!con) { - BLog(BLOG_ERROR, "malloc failed"); - goto fail0; - } - - // init arguments - con->client = o; - con->conaddr = conaddr; - con->first_flags = flags; - con->first_data = data; - con->first_data_len = data_len; - - // allocate conid - con->conid = find_unused_conid(o); - - // init first job - BPending_Init(&con->first_job, BReactor_PendingGroup(o->reactor), (BPending_handler)connection_first_job_handler, con); - BPending_Set(&con->first_job); - - // init queue flow - PacketPassFairQueueFlow_Init(&con->send_qflow, &o->send_queue); - - // init PacketProtoFlow - if (!PacketProtoFlow_Init(&con->send_ppflow, o->udpgw_mtu, o->send_buffer_size, PacketPassFairQueueFlow_GetInput(&con->send_qflow), BReactor_PendingGroup(o->reactor))) { - BLog(BLOG_ERROR, "PacketProtoFlow_Init failed"); - goto fail1; - } - con->send_if = PacketProtoFlow_GetInput(&con->send_ppflow); - - // insert to connections tree by conaddr - ASSERT_EXECUTE(BAVL_Insert(&o->connections_tree_by_conaddr, &con->connections_tree_by_conaddr_node, NULL)) - - // insert to connections tree by conid - ASSERT_EXECUTE(BAVL_Insert(&o->connections_tree_by_conid, &con->connections_tree_by_conid_node, NULL)) - - // insert to connections list - LinkedList1_Append(&o->connections_list, &con->connections_list_node); - - // increment number of connections - o->num_connections++; - - return; - -fail1: - PacketPassFairQueueFlow_Free(&con->send_qflow); - BPending_Free(&con->first_job); - free(con); -fail0: - return; -} - -static void connection_free (struct UdpGwClient_connection *con) -{ - UdpGwClient *o = con->client; - PacketPassFairQueueFlow_AssertFree(&con->send_qflow); - - // decrement number of connections - o->num_connections--; - - // remove from connections list - LinkedList1_Remove(&o->connections_list, &con->connections_list_node); - - // remove from connections tree by conid - BAVL_Remove(&o->connections_tree_by_conid, &con->connections_tree_by_conid_node); - - // remove from connections tree by conaddr - BAVL_Remove(&o->connections_tree_by_conaddr, &con->connections_tree_by_conaddr_node); - - // free PacketProtoFlow - PacketProtoFlow_Free(&con->send_ppflow); - - // free queue flow - PacketPassFairQueueFlow_Free(&con->send_qflow); - - // free first job - BPending_Free(&con->first_job); - - // free structure - free(con); -} - -static void connection_first_job_handler (struct UdpGwClient_connection *con) -{ - connection_send(con, UDPGW_CLIENT_FLAG_REBIND|con->first_flags, con->first_data, con->first_data_len); -} - -static void connection_send (struct UdpGwClient_connection *con, uint8_t flags, const uint8_t *data, int data_len) -{ - UdpGwClient *o = con->client; - B_USE(o) - ASSERT(data_len >= 0) - ASSERT(data_len <= o->udp_mtu) - - // get buffer location - uint8_t *out; - if (!BufferWriter_StartPacket(con->send_if, &out)) { - BLog(BLOG_ERROR, "out of buffer"); - return; - } - int out_pos = 0; - - if (con->conaddr.remote_addr.type == BADDR_TYPE_IPV6) { - flags |= UDPGW_CLIENT_FLAG_IPV6; - } - - // write header - struct udpgw_header header; - header.flags = ltoh8(flags); - header.conid = ltoh16(con->conid); - memcpy(out + out_pos, &header, sizeof(header)); - out_pos += sizeof(header); - - // write address - switch (con->conaddr.remote_addr.type) { - case BADDR_TYPE_IPV4: { - struct udpgw_addr_ipv4 addr_ipv4; - addr_ipv4.addr_ip = con->conaddr.remote_addr.ipv4.ip; - addr_ipv4.addr_port = con->conaddr.remote_addr.ipv4.port; - memcpy(out + out_pos, &addr_ipv4, sizeof(addr_ipv4)); - out_pos += sizeof(addr_ipv4); - } break; - case BADDR_TYPE_IPV6: { - struct udpgw_addr_ipv6 addr_ipv6; - memcpy(addr_ipv6.addr_ip, con->conaddr.remote_addr.ipv6.ip, sizeof(addr_ipv6.addr_ip)); - addr_ipv6.addr_port = con->conaddr.remote_addr.ipv6.port; - memcpy(out + out_pos, &addr_ipv6, sizeof(addr_ipv6)); - out_pos += sizeof(addr_ipv6); - } break; - } - - // write packet to buffer - memcpy(out + out_pos, data, data_len); - out_pos += data_len; - - // submit packet to buffer - BufferWriter_EndPacket(con->send_if, out_pos); -} - -static struct UdpGwClient_connection * reuse_connection (UdpGwClient *o, struct UdpGwClient_conaddr conaddr) -{ - ASSERT(!find_connection_by_conaddr(o, conaddr)) - ASSERT(o->num_connections > 0) - - // get least recently used connection - struct UdpGwClient_connection *con = UPPER_OBJECT(LinkedList1_GetFirst(&o->connections_list), struct UdpGwClient_connection, connections_list_node); - - // remove from connections tree by conaddr - BAVL_Remove(&o->connections_tree_by_conaddr, &con->connections_tree_by_conaddr_node); - - // set new conaddr - con->conaddr = conaddr; - - // insert to connections tree by conaddr - ASSERT_EXECUTE(BAVL_Insert(&o->connections_tree_by_conaddr, &con->connections_tree_by_conaddr_node, NULL)) - - return con; -} - -int UdpGwClient_Init (UdpGwClient *o, int udp_mtu, int max_connections, int send_buffer_size, btime_t keepalive_time, BReactor *reactor, void *user, - UdpGwClient_handler_servererror handler_servererror, - UdpGwClient_handler_received handler_received) -{ - ASSERT(udp_mtu >= 0) - ASSERT(udpgw_compute_mtu(udp_mtu) >= 0) - ASSERT(udpgw_compute_mtu(udp_mtu) <= PACKETPROTO_MAXPAYLOAD) - ASSERT(max_connections > 0) - ASSERT(send_buffer_size > 0) - - // init arguments - o->udp_mtu = udp_mtu; - o->max_connections = max_connections; - o->send_buffer_size = send_buffer_size; - o->keepalive_time = keepalive_time; - o->reactor = reactor; - o->user = user; - o->handler_servererror = handler_servererror; - o->handler_received = handler_received; - - // limit max connections to number of conid's - if (o->max_connections > UINT16_MAX + 1) { - o->max_connections = UINT16_MAX + 1; - } - - // compute MTUs - o->udpgw_mtu = udpgw_compute_mtu(o->udp_mtu); - o->pp_mtu = o->udpgw_mtu + sizeof(struct packetproto_header); - - // init connections tree by conaddr - BAVL_Init(&o->connections_tree_by_conaddr, OFFSET_DIFF(struct UdpGwClient_connection, conaddr, connections_tree_by_conaddr_node), (BAVL_comparator)conaddr_comparator, NULL); - - // init connections tree by conid - BAVL_Init(&o->connections_tree_by_conid, OFFSET_DIFF(struct UdpGwClient_connection, conid, connections_tree_by_conid_node), (BAVL_comparator)uint16_comparator, NULL); - - // init connections list - LinkedList1_Init(&o->connections_list); - - // set zero connections - o->num_connections = 0; - - // set next conid - o->next_conid = 0; - - // init send connector - PacketPassConnector_Init(&o->send_connector, o->pp_mtu, BReactor_PendingGroup(o->reactor)); - - // init send monitor - PacketPassInactivityMonitor_Init(&o->send_monitor, PacketPassConnector_GetInput(&o->send_connector), o->reactor, o->keepalive_time, (PacketPassInactivityMonitor_handler)send_monitor_handler, o); - - // init send queue - if (!PacketPassFairQueue_Init(&o->send_queue, PacketPassInactivityMonitor_GetInput(&o->send_monitor), BReactor_PendingGroup(o->reactor), 0, 1)) { - goto fail0; - } - - // construct keepalive packet - o->keepalive_packet.pp.len = sizeof(o->keepalive_packet.udpgw); - memset(&o->keepalive_packet.udpgw, 0, sizeof(o->keepalive_packet.udpgw)); - o->keepalive_packet.udpgw.flags = UDPGW_CLIENT_FLAG_KEEPALIVE; - - // init keepalive queue flow - PacketPassFairQueueFlow_Init(&o->keepalive_qflow, &o->send_queue); - o->keepalive_if = PacketPassFairQueueFlow_GetInput(&o->keepalive_qflow); - - // init keepalive output - PacketPassInterface_Sender_Init(o->keepalive_if, (PacketPassInterface_handler_done)keepalive_if_handler_done, o); - - // set not sending keepalive - o->keepalive_sending = 0; - - // set have no server - o->have_server = 0; - - DebugObject_Init(&o->d_obj); - return 1; - -fail0: - PacketPassInactivityMonitor_Free(&o->send_monitor); - PacketPassConnector_Free(&o->send_connector); - return 0; -} - -void UdpGwClient_Free (UdpGwClient *o) -{ - DebugObject_Free(&o->d_obj); - - // allow freeing send queue flows - PacketPassFairQueue_PrepareFree(&o->send_queue); - - // free connections - while (!LinkedList1_IsEmpty(&o->connections_list)) { - struct UdpGwClient_connection *con = UPPER_OBJECT(LinkedList1_GetFirst(&o->connections_list), struct UdpGwClient_connection, connections_list_node); - connection_free(con); - } - - // free server - if (o->have_server) { - free_server(o); - } - - // free keepalive queue flow - PacketPassFairQueueFlow_Free(&o->keepalive_qflow); - - // free send queue - PacketPassFairQueue_Free(&o->send_queue); - - // free send - PacketPassInactivityMonitor_Free(&o->send_monitor); - - // free send connector - PacketPassConnector_Free(&o->send_connector); -} - -void UdpGwClient_SubmitPacket (UdpGwClient *o, BAddr local_addr, BAddr remote_addr, int is_dns, const uint8_t *data, int data_len) -{ - DebugObject_Access(&o->d_obj); - ASSERT(local_addr.type == BADDR_TYPE_IPV4 || local_addr.type == BADDR_TYPE_IPV6) - ASSERT(remote_addr.type == BADDR_TYPE_IPV4 || remote_addr.type == BADDR_TYPE_IPV6) - ASSERT(data_len >= 0) - ASSERT(data_len <= o->udp_mtu) - - // build conaddr - struct UdpGwClient_conaddr conaddr; - conaddr.local_addr = local_addr; - conaddr.remote_addr = remote_addr; - - // lookup connection - struct UdpGwClient_connection *con = find_connection_by_conaddr(o, conaddr); - - uint8_t flags = 0; - - if (is_dns) { - // route to remote DNS server instead of provided address - flags |= UDPGW_CLIENT_FLAG_DNS; - } - - // if no connection and can't create a new one, reuse the least recently used une - if (!con && o->num_connections == o->max_connections) { - con = reuse_connection(o, conaddr); - flags |= UDPGW_CLIENT_FLAG_REBIND; - } - - if (!con) { - // create new connection - connection_init(o, conaddr, flags, data, data_len); - } else { - // move connection to front of the list - LinkedList1_Remove(&o->connections_list, &con->connections_list_node); - LinkedList1_Append(&o->connections_list, &con->connections_list_node); - - // send packet to existing connection - connection_send(con, flags, data, data_len); - } -} - -int UdpGwClient_ConnectServer (UdpGwClient *o, StreamPassInterface *send_if, StreamRecvInterface *recv_if) -{ - DebugObject_Access(&o->d_obj); - ASSERT(!o->have_server) - - // init receive interface - PacketPassInterface_Init(&o->recv_if, o->udpgw_mtu, (PacketPassInterface_handler_send)recv_interface_handler_send, o, BReactor_PendingGroup(o->reactor)); - - // init receive decoder - if (!PacketProtoDecoder_Init(&o->recv_decoder, recv_if, &o->recv_if, BReactor_PendingGroup(o->reactor), o, (PacketProtoDecoder_handler_error)decoder_handler_error)) { - BLog(BLOG_ERROR, "PacketProtoDecoder_Init failed"); - goto fail1; - } - - // init send sender - PacketStreamSender_Init(&o->send_sender, send_if, o->pp_mtu, BReactor_PendingGroup(o->reactor)); - - // connect send connector - PacketPassConnector_ConnectOutput(&o->send_connector, PacketStreamSender_GetInput(&o->send_sender)); - - // set have server - o->have_server = 1; - - return 1; - -fail1: - PacketPassInterface_Free(&o->recv_if); - return 0; -} - -void UdpGwClient_DisconnectServer (UdpGwClient *o) -{ - DebugObject_Access(&o->d_obj); - ASSERT(o->have_server) - - // free server - free_server(o); - - // set have no server - o->have_server = 0; -} diff --git a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw_client/UdpGwClient.h b/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw_client/UdpGwClient.h deleted file mode 100644 index fae257ba..00000000 --- a/client/3rd/PacketProcessor/PacketProcessor/tun2socks-iOS/udpgw_client/UdpGwClient.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) Ambroz Bizjak - * Contributions: - * Transparent DNS: Copyright (C) Kerem Hadimli - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the author nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BADVPN_UDPGW_CLIENT_UDPGWCLIENT_H -#define BADVPN_UDPGW_CLIENT_UDPGWCLIENT_H - -#include - -#include "protocol/udpgw_proto.h" -#include "misc/debug.h" -#include "misc/packed.h" -#include "structure/BAVL.h" -#include "structure/LinkedList1.h" -#include "base/DebugObject.h" -#include "system/BAddr.h" -#include "base/BPending.h" -#include "flow/PacketPassFairQueue.h" -#include "flow/PacketStreamSender.h" -#include "flow/PacketProtoFlow.h" -#include "flow/PacketProtoDecoder.h" -#include "flow/PacketPassConnector.h" -#include "flowextra/PacketPassInactivityMonitor.h" - -typedef void (*UdpGwClient_handler_servererror) (void *user); -typedef void (*UdpGwClient_handler_received) (void *user, BAddr local_addr, BAddr remote_addr, const uint8_t *data, int data_len); - -B_START_PACKED -struct UdpGwClient__keepalive_packet { - struct packetproto_header pp; - struct udpgw_header udpgw; -} B_PACKED; -B_END_PACKED - -typedef struct { - int udp_mtu; - int max_connections; - int send_buffer_size; - btime_t keepalive_time; - BReactor *reactor; - void *user; - UdpGwClient_handler_servererror handler_servererror; - UdpGwClient_handler_received handler_received; - int udpgw_mtu; - int pp_mtu; - BAVL connections_tree_by_conaddr; - BAVL connections_tree_by_conid; - LinkedList1 connections_list; - int num_connections; - int next_conid; - PacketPassFairQueue send_queue; - PacketPassInactivityMonitor send_monitor; - PacketPassConnector send_connector; - struct UdpGwClient__keepalive_packet keepalive_packet; - PacketPassInterface *keepalive_if; - PacketPassFairQueueFlow keepalive_qflow; - int keepalive_sending; - int have_server; - PacketStreamSender send_sender; - PacketProtoDecoder recv_decoder; - PacketPassInterface recv_if; - DebugObject d_obj; -} UdpGwClient; - -struct UdpGwClient_conaddr { - BAddr local_addr; - BAddr remote_addr; -}; - -struct UdpGwClient_connection { - UdpGwClient *client; - struct UdpGwClient_conaddr conaddr; - uint8_t first_flags; - const uint8_t *first_data; - int first_data_len; - uint16_t conid; - BPending first_job; - BufferWriter *send_if; - PacketProtoFlow send_ppflow; - PacketPassFairQueueFlow send_qflow; - BAVLNode connections_tree_by_conaddr_node; - BAVLNode connections_tree_by_conid_node; - LinkedList1Node connections_list_node; -}; - -int UdpGwClient_Init (UdpGwClient *o, int udp_mtu, int max_connections, int send_buffer_size, btime_t keepalive_time, BReactor *reactor, void *user, - UdpGwClient_handler_servererror handler_servererror, - UdpGwClient_handler_received handler_received) WARN_UNUSED; -void UdpGwClient_Free (UdpGwClient *o); -void UdpGwClient_SubmitPacket (UdpGwClient *o, BAddr local_addr, BAddr remote_addr, int is_dns, const uint8_t *data, int data_len); -int UdpGwClient_ConnectServer (UdpGwClient *o, StreamPassInterface *send_if, StreamRecvInterface *recv_if) WARN_UNUSED; -void UdpGwClient_DisconnectServer (UdpGwClient *o); - -#endif diff --git a/client/3rd/QJsonStruct/.gitignore b/client/3rd/QJsonStruct/.gitignore new file mode 100644 index 00000000..da1d64b7 --- /dev/null +++ b/client/3rd/QJsonStruct/.gitignore @@ -0,0 +1,2 @@ +*.user +build/ diff --git a/client/3rd/QJsonStruct/CMakeLists.txt b/client/3rd/QJsonStruct/CMakeLists.txt new file mode 100644 index 00000000..2835cd8f --- /dev/null +++ b/client/3rd/QJsonStruct/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.5) + +project(QJsonStruct LANGUAGES CXX) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +option(BUILD_TESTING ON) + +include(QJsonStruct.cmake) +find_package(Qt5 COMPONENTS Core REQUIRED) + +if(BUILD_TESTING) + include(CTest) + add_subdirectory(test) +endif() diff --git a/client/3rd/QJsonStruct/LICENSE b/client/3rd/QJsonStruct/LICENSE new file mode 100644 index 00000000..80cc88b1 --- /dev/null +++ b/client/3rd/QJsonStruct/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Qv2ray Workgroup + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/client/3rd/QJsonStruct/QJsonIO.hpp b/client/3rd/QJsonStruct/QJsonIO.hpp new file mode 100644 index 00000000..a8faae0a --- /dev/null +++ b/client/3rd/QJsonStruct/QJsonIO.hpp @@ -0,0 +1,190 @@ +#pragma once +#include +#include +#include +#include +#include + +enum class QJsonIOPathType +{ + JSONIO_MODE_ARRAY, + JSONIO_MODE_OBJECT +}; + +typedef QPair QJsonIONodeType; + +struct QJsonIOPath : QList +{ + template + QJsonIOPath(const type1 t1, const type2 t2, const types... ts) + { + AppendPath(t1); + AppendPath(t2); + (AppendPath(ts), ...); + } + + void AppendPath(size_t index) + { + append({ QString::number(index), QJsonIOPathType::JSONIO_MODE_ARRAY }); + } + + void AppendPath(const QString &key) + { + append({ key, QJsonIOPathType::JSONIO_MODE_OBJECT }); + } + + template + QJsonIOPath &operator<<(const t &str) + { + AppendPath(str); + return *this; + } + + template + QJsonIOPath &operator+=(const t &val) + { + AppendPath(val); + return *this; + } + + QJsonIOPath &operator<<(const QJsonIOPath &other) + { + for (const auto &x : other) + this->append(x); + return *this; + } + + template + QJsonIOPath &operator<<(const t &val) const + { + auto _new = *this; + return _new << val; + } + + template + QJsonIOPath operator+(const t &val) const + { + auto _new = *this; + return _new << val; + } + + QJsonIOPath operator+(const QJsonIOPath &other) const + { + auto _new = *this; + for (const auto &x : other) + _new.append(x); + return _new; + } +}; + +class QJsonIO +{ + public: + const static inline QJsonValue Null = QJsonValue::Null; + const static inline QJsonValue Undefined = QJsonValue::Undefined; + + template + static QJsonValue GetValue(const QJsonValue &parent, const current_key_type ¤t, const t_other_types &...other) + { + if constexpr (sizeof...(t_other_types) == 0) + if constexpr (std::is_integral_v) + return parent.toArray()[current]; + else + return parent.toObject()[current]; + else if constexpr (std::is_integral_v) + return GetValue(parent.toArray()[current], other...); + else + return GetValue(parent.toObject()[current], other...); + } + + template + static QJsonValue GetValue(QJsonValue value, const std::tuple &keys, const QJsonValue &defaultValue = Undefined) + { + std::apply([&](auto &&...args) { ((value = value[args]), ...); }, keys); + return value.isUndefined() ? defaultValue : value; + } + + template + static void SetValue(parent_type &parent, const t_value_type &val, const current_key_type ¤t, const t_other_key_types &...other) + { + // If current parent is an array, increase its size to fit the "key" + if constexpr (std::is_integral_v) + for (auto i = parent.size(); i <= current; i++) + parent.insert(i, {}); + + // If the t_other_key_types has nothing.... + // Means we have reached the end of recursion. + if constexpr (sizeof...(t_other_key_types) == 0) + parent[current] = val; + else if constexpr (std::is_integral_v>>) + { + // Means we still have many keys + // So this element is an array. + auto _array = parent[current].toArray(); + SetValue(_array, val, other...); + parent[current] = _array; + } + else + { + auto _object = parent[current].toObject(); + SetValue(_object, val, other...); + parent[current] = _object; + } + } + + static QJsonValue GetValue(const QJsonValue &parent, const QJsonIOPath &path, const QJsonValue &defaultValue = QJsonIO::Undefined) + { + QJsonValue val = parent; + for (const auto &[k, t] : path) + { + if (t == QJsonIOPathType::JSONIO_MODE_ARRAY) + val = val.toArray()[k.toInt()]; + else + val = val.toObject()[k]; + } + return val.isUndefined() ? defaultValue : val; + } + + template + static void SetValue(parent_type &parent, const value_type &t, const QJsonIOPath &path) + { + QList> _stack; + QJsonValue lastNode = parent; + for (const auto &[key, type] : path) + { + _stack.prepend({ key, type, lastNode }); + if (type == QJsonIOPathType::JSONIO_MODE_ARRAY) + lastNode = lastNode.toArray().at(key.toInt()); + else + lastNode = lastNode.toObject()[key]; + } + + lastNode = t; + + for (const auto &[key, type, node] : _stack) + { + if (type == QJsonIOPathType::JSONIO_MODE_ARRAY) + { + const auto index = key.toInt(); + auto nodeArray = node.toArray(); + for (auto i = nodeArray.size(); i <= index; i++) + nodeArray.insert(i, {}); + nodeArray[index] = lastNode; + lastNode = nodeArray; + } + else + { + auto nodeObject = node.toObject(); + nodeObject[key] = lastNode; + lastNode = nodeObject; + } + } + + if constexpr (std::is_same_v) + parent = lastNode.toObject(); + else if constexpr (std::is_same_v) + parent = lastNode.toArray(); + else + Q_UNREACHABLE(); + } +}; diff --git a/client/3rd/QJsonStruct/QJsonStruct.cmake b/client/3rd/QJsonStruct/QJsonStruct.cmake new file mode 100644 index 00000000..7e07cad7 --- /dev/null +++ b/client/3rd/QJsonStruct/QJsonStruct.cmake @@ -0,0 +1,5 @@ +include_directories(${CMAKE_CURRENT_LIST_DIR}) + +set(QJSONSTRUCT_SOURCES + ${CMAKE_CURRENT_LIST_DIR}/QJsonStruct.hpp + ${CMAKE_CURRENT_LIST_DIR}/QJsonIO.hpp) diff --git a/client/3rd/QJsonStruct/QJsonStruct.hpp b/client/3rd/QJsonStruct/QJsonStruct.hpp new file mode 100644 index 00000000..e44f2e5d --- /dev/null +++ b/client/3rd/QJsonStruct/QJsonStruct.hpp @@ -0,0 +1,215 @@ +#pragma once +#include "macroexpansion.hpp" + +#ifndef _X + #include + #include + #include + #include +#endif + +/// macro to define an operator== +#define ___JSONSTRUCT_DEFAULT_COMPARE_IMPL(x) (this->x == ___another___instance__.x) && +#define JSONSTRUCT_COMPARE(CLASS, ...) \ + bool operator==(const CLASS &___another___instance__) const \ + { \ + return FOR_EACH(___JSONSTRUCT_DEFAULT_COMPARE_IMPL, __VA_ARGS__) true; \ + } + +// ============================================================================================ +// Load JSON IMPL +#define ___DESERIALIZE_FROM_JSON_CONVERT_B_FUNC_IMPL(name) name::loadJson(___json_object_); +#define ___DESERIALIZE_FROM_JSON_CONVERT_A_FUNC(name) ___DESERIALIZE_FROM_JSON_CONVERT_F_FUNC(name) +#define ___DESERIALIZE_FROM_JSON_CONVERT_B_FUNC(...) FOREACH_CALL_FUNC_3(___DESERIALIZE_FROM_JSON_CONVERT_B_FUNC_IMPL, __VA_ARGS__) +#define ___DESERIALIZE_FROM_JSON_CONVERT_F_FUNC(name) \ + if (___json_object_.toObject().contains(#name)) \ + { \ + JsonStructHelper::Deserialize(this->name, ___json_object_.toObject()[#name]); \ + } \ + else \ + { \ + this->name = ___qjsonstruct_default_check.name; \ + } + +// ============================================================================================ +// To JSON IMPL +#define ___SERIALIZE_TO_JSON_CONVERT_F_FUNC(name) \ + if (!(___qjsonstruct_default_check.name == this->name)) \ + { \ + ___json_object_.insert(#name, JsonStructHelper::Serialize(name)); \ + } +#define ___SERIALIZE_TO_JSON_CONVERT_A_FUNC(name) ___json_object_.insert(#name, JsonStructHelper::Serialize(name)); +#define ___SERIALIZE_TO_JSON_CONVERT_B_FUNC_IMPL(name) JsonStructHelper::MergeJson(___json_object_, name::toJson()); +#define ___SERIALIZE_TO_JSON_CONVERT_B_FUNC(...) FOREACH_CALL_FUNC_3(___SERIALIZE_TO_JSON_CONVERT_B_FUNC_IMPL, __VA_ARGS__) + +// ============================================================================================ +// Load JSON Wrapper +#define ___DESERIALIZE_FROM_JSON_CONVERT_FUNC_DECL_A(...) FOREACH_CALL_FUNC_2(___DESERIALIZE_FROM_JSON_CONVERT_A_FUNC, __VA_ARGS__) +#define ___DESERIALIZE_FROM_JSON_CONVERT_FUNC_DECL_F(...) FOREACH_CALL_FUNC_2(___DESERIALIZE_FROM_JSON_CONVERT_F_FUNC, __VA_ARGS__) +#define ___DESERIALIZE_FROM_JSON_CONVERT_FUNC_DECL_B(...) FOREACH_CALL_FUNC_2(___DESERIALIZE_FROM_JSON_CONVERT_B_FUNC, __VA_ARGS__) +#define ___DESERIALIZE_FROM_JSON_EXTRACT_B_F(name_option) ___DESERIALIZE_FROM_JSON_CONVERT_FUNC_DECL_##name_option + +// ============================================================================================ +// To JSON Wrapper +#define ___SERIALIZE_TO_JSON_CONVERT_FUNC_DECL_A(...) FOREACH_CALL_FUNC_2(___SERIALIZE_TO_JSON_CONVERT_A_FUNC, __VA_ARGS__) +#define ___SERIALIZE_TO_JSON_CONVERT_FUNC_DECL_F(...) FOREACH_CALL_FUNC_2(___SERIALIZE_TO_JSON_CONVERT_F_FUNC, __VA_ARGS__) +#define ___SERIALIZE_TO_JSON_CONVERT_FUNC_DECL_B(...) FOREACH_CALL_FUNC_2(___SERIALIZE_TO_JSON_CONVERT_B_FUNC, __VA_ARGS__) +#define ___SERIALIZE_TO_JSON_EXTRACT_B_F(name_option) ___SERIALIZE_TO_JSON_CONVERT_FUNC_DECL_##name_option + +// ============================================================================================ +#define JSONSTRUCT_REGISTER_NOCOPYMOVE(___class_type_, ...) \ + void loadJson(const QJsonValue &___json_object_) \ + { \ + ___class_type_ ___qjsonstruct_default_check; \ + FOREACH_CALL_FUNC(___DESERIALIZE_FROM_JSON_EXTRACT_B_F, __VA_ARGS__); \ + } \ + [[nodiscard]] const QJsonObject toJson() const \ + { \ + ___class_type_ ___qjsonstruct_default_check; \ + QJsonObject ___json_object_; \ + FOREACH_CALL_FUNC(___SERIALIZE_TO_JSON_EXTRACT_B_F, __VA_ARGS__); \ + return ___json_object_; \ + } + +#define JSONSTRUCT_REGISTER(___class_type_, ...) \ + JSONSTRUCT_REGISTER_NOCOPYMOVE(___class_type_, __VA_ARGS__); \ + [[nodiscard]] static auto fromJson(const QJsonValue &___json_object_) \ + { \ + ___class_type_ _t; \ + _t.loadJson(___json_object_); \ + return _t; \ + } + +#define ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(type, convert_func) \ + static void Deserialize(type &t, const QJsonValue &d) \ + { \ + t = d.convert_func; \ + } + +class JsonStructHelper +{ + public: + static void MergeJson(QJsonObject &mergeTo, const QJsonObject &mergeIn) + { + for (const auto &key : mergeIn.keys()) + mergeTo[key] = mergeIn.value(key); + } + // + template + static void Deserialize(T &t, const QJsonValue &d) + { + if constexpr (std::is_enum_v) + t = (T) d.toInt(); + else if constexpr (std::is_same_v) + t = d.toObject(); + else if constexpr (std::is_same_v) + t = d.toArray(); + else + t.loadJson(d); + } + + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(QString, toString()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(QChar, toVariant().toChar()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(std::string, toString().toStdString()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(std::wstring, toString().toStdWString()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(bool, toBool()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(double, toDouble()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(float, toVariant().toFloat()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(int, toInt()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(long, toVariant().toLongLong()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(long long, toVariant().toLongLong()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(unsigned int, toVariant().toUInt()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(unsigned long, toVariant().toULongLong()); + ___DECL_JSON_STRUCT_LOAD_SIMPLE_TYPE_FUNC(unsigned long long, toVariant().toULongLong()); + + template + static void Deserialize(QList &t, const QJsonValue &d) + { + t.clear(); + for (const auto &val : d.toArray()) + { + T data; + Deserialize(data, val); + t.push_back(data); + } + } + + template + static void Deserialize(QMap &t, const QJsonValue &d) + { + t.clear(); + const auto &jsonObject = d.toObject(); + TKey keyVal; + TValue valueVal; + for (const auto &key : jsonObject.keys()) + { + Deserialize(keyVal, key); + Deserialize(valueVal, jsonObject.value(key)); + t.insert(keyVal, valueVal); + } + } + + // =========================== Store Json Data =========================== + + template + static QJsonValue Serialize(const T &t) + { + if constexpr (std::is_enum_v) + return (int) t; + else if constexpr (std::is_same_v || std::is_same_v) + return t; + else + return t.toJson(); + } + +#define pure_func(x) (x) +#define ___DECL_JSON_STRUCT_STORE_SIMPLE_TYPE_FUNC(type) \ + static QJsonValue Serialize(const type &t) \ + { \ + return QJsonValue(t); \ + } + ___DECL_JSON_STRUCT_STORE_SIMPLE_TYPE_FUNC(int); + ___DECL_JSON_STRUCT_STORE_SIMPLE_TYPE_FUNC(bool); + ___DECL_JSON_STRUCT_STORE_SIMPLE_TYPE_FUNC(QJsonArray); + ___DECL_JSON_STRUCT_STORE_SIMPLE_TYPE_FUNC(QJsonObject); + ___DECL_JSON_STRUCT_STORE_SIMPLE_TYPE_FUNC(QString); + ___DECL_JSON_STRUCT_STORE_SIMPLE_TYPE_FUNC(long long); + ___DECL_JSON_STRUCT_STORE_SIMPLE_TYPE_FUNC(float); + ___DECL_JSON_STRUCT_STORE_SIMPLE_TYPE_FUNC(double); + +#define ___DECL_JSON_STRUCT_STORE_VARIANT_TYPE_FUNC(type, func) \ + static QJsonValue Serialize(const type &t) \ + { \ + return QJsonValue::fromVariant(func); \ + } + + ___DECL_JSON_STRUCT_STORE_VARIANT_TYPE_FUNC(std::string, QString::fromStdString(t)) + ___DECL_JSON_STRUCT_STORE_VARIANT_TYPE_FUNC(std::wstring, QString::fromStdWString(t)) + ___DECL_JSON_STRUCT_STORE_VARIANT_TYPE_FUNC(long, QVariant::fromValue(t)) + ___DECL_JSON_STRUCT_STORE_VARIANT_TYPE_FUNC(unsigned int, QVariant::fromValue(t)) + ___DECL_JSON_STRUCT_STORE_VARIANT_TYPE_FUNC(unsigned long, QVariant::fromValue(t)) + ___DECL_JSON_STRUCT_STORE_VARIANT_TYPE_FUNC(unsigned long long, QVariant::fromValue(t)) + + template + static QJsonValue Serialize(const QMap &t) + { + QJsonObject mapObject; + for (const auto &key : t.keys()) + { + auto valueVal = Serialize(t.value(key)); + mapObject.insert(key, valueVal); + } + return mapObject; + } + + template + static QJsonValue Serialize(const QList &t) + { + QJsonArray listObject; + for (const auto &item : t) + { + listObject.push_back(Serialize(item)); + } + return listObject; + } +}; diff --git a/client/3rd/QJsonStruct/macroexpansion.hpp b/client/3rd/QJsonStruct/macroexpansion.hpp new file mode 100644 index 00000000..aa9b55f7 --- /dev/null +++ b/client/3rd/QJsonStruct/macroexpansion.hpp @@ -0,0 +1,74 @@ +#pragma once + +#define CONCATENATE1(arg1, arg2) CONCATENATE2(arg1, arg2) +#define CONCATENATE2(arg1, arg2) arg1##arg2 +#define CONCATENATE(x, y) x##y + +#define EXPAND(...) __VA_ARGS__ +#define FOR_EACH_1(what, x, ...) what(x) +#define FOR_EACH_2(what, x, ...) what(x) EXPAND(FOR_EACH_1(what, __VA_ARGS__)) +#define FOR_EACH_3(what, x, ...) what(x) EXPAND(FOR_EACH_2(what, __VA_ARGS__)) +#define FOR_EACH_4(what, x, ...) what(x) EXPAND(FOR_EACH_3(what, __VA_ARGS__)) +#define FOR_EACH_5(what, x, ...) what(x) EXPAND(FOR_EACH_4(what, __VA_ARGS__)) +#define FOR_EACH_6(what, x, ...) what(x) EXPAND(FOR_EACH_5(what, __VA_ARGS__)) +#define FOR_EACH_7(what, x, ...) what(x) EXPAND(FOR_EACH_6(what, __VA_ARGS__)) +#define FOR_EACH_8(what, x, ...) what(x) EXPAND(FOR_EACH_7(what, __VA_ARGS__)) +#define FOR_EACH_9(what, x, ...) what(x) EXPAND(FOR_EACH_8(what, __VA_ARGS__)) +#define FOR_EACH_10(what, x, ...) what(x) EXPAND(FOR_EACH_9(what, __VA_ARGS__)) +#define FOR_EACH_11(what, x, ...) what(x) EXPAND(FOR_EACH_10(what, __VA_ARGS__)) +#define FOR_EACH_12(what, x, ...) what(x) EXPAND(FOR_EACH_11(what, __VA_ARGS__)) +#define FOR_EACH_13(what, x, ...) what(x) EXPAND(FOR_EACH_12(what, __VA_ARGS__)) +#define FOR_EACH_14(what, x, ...) what(x) EXPAND(FOR_EACH_13(what, __VA_ARGS__)) +#define FOR_EACH_15(what, x, ...) what(x) EXPAND(FOR_EACH_14(what, __VA_ARGS__)) +#define FOR_EACH_16(what, x, ...) what(x) EXPAND(FOR_EACH_15(what, __VA_ARGS__)) + +#define FOR_EACH_NARG(...) FOR_EACH_NARG_(__VA_ARGS__, FOR_EACH_RSEQ_N()) +#define FOR_EACH_NARG_(...) EXPAND(FOR_EACH_ARG_N(__VA_ARGS__)) +#define FOR_EACH_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N +#define FOR_EACH_RSEQ_N() 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 + +#define FOR_EACH_(N, what, ...) EXPAND(CONCATENATE(FOR_EACH_, N)(what, __VA_ARGS__)) +#define FOR_EACH(what, ...) FOR_EACH_(FOR_EACH_NARG(__VA_ARGS__), what, __VA_ARGS__) +#define FOREACH_CALL_FUNC(func, ...) FOR_EACH(func, __VA_ARGS__) + +// Bad hack ========================================================================================================================== +#define _2X_FOR_EACH_1(what, x, ...) what(x) +#define _2X_FOR_EACH_2(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_1(what, __VA_ARGS__)) +#define _2X_FOR_EACH_3(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_2(what, __VA_ARGS__)) +#define _2X_FOR_EACH_4(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_3(what, __VA_ARGS__)) +#define _2X_FOR_EACH_5(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_4(what, __VA_ARGS__)) +#define _2X_FOR_EACH_6(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_5(what, __VA_ARGS__)) +#define _2X_FOR_EACH_7(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_6(what, __VA_ARGS__)) +#define _2X_FOR_EACH_8(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_7(what, __VA_ARGS__)) +#define _2X_FOR_EACH_9(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_8(what, __VA_ARGS__)) +#define _2X_FOR_EACH_10(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_9(what, __VA_ARGS__)) +#define _2X_FOR_EACH_11(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_10(what, __VA_ARGS__)) +#define _2X_FOR_EACH_12(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_11(what, __VA_ARGS__)) +#define _2X_FOR_EACH_13(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_12(what, __VA_ARGS__)) +#define _2X_FOR_EACH_14(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_13(what, __VA_ARGS__)) +#define _2X_FOR_EACH_15(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_14(what, __VA_ARGS__)) +#define _2X_FOR_EACH_16(what, x, ...) what(x) EXPAND(_2X_FOR_EACH_15(what, __VA_ARGS__)) +#define _2X_FOR_EACH_(N, what, ...) EXPAND(CONCATENATE(_2X_FOR_EACH_, N)(what, __VA_ARGS__)) +#define _2X_FOR_EACH(what, ...) _2X_FOR_EACH_(FOR_EACH_NARG(__VA_ARGS__), what, __VA_ARGS__) +#define FOREACH_CALL_FUNC_2(func, ...) _2X_FOR_EACH(func, __VA_ARGS__) + +// Bad hack ========================================================================================================================== +#define _3X_FOR_EACH_1(what, x, ...) what(x) +#define _3X_FOR_EACH_2(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_1(what, __VA_ARGS__)) +#define _3X_FOR_EACH_3(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_2(what, __VA_ARGS__)) +#define _3X_FOR_EACH_4(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_3(what, __VA_ARGS__)) +#define _3X_FOR_EACH_5(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_4(what, __VA_ARGS__)) +#define _3X_FOR_EACH_6(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_5(what, __VA_ARGS__)) +#define _3X_FOR_EACH_7(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_6(what, __VA_ARGS__)) +#define _3X_FOR_EACH_8(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_7(what, __VA_ARGS__)) +#define _3X_FOR_EACH_9(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_8(what, __VA_ARGS__)) +#define _3X_FOR_EACH_10(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_9(what, __VA_ARGS__)) +#define _3X_FOR_EACH_11(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_10(what, __VA_ARGS__)) +#define _3X_FOR_EACH_12(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_11(what, __VA_ARGS__)) +#define _3X_FOR_EACH_13(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_12(what, __VA_ARGS__)) +#define _3X_FOR_EACH_14(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_13(what, __VA_ARGS__)) +#define _3X_FOR_EACH_15(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_14(what, __VA_ARGS__)) +#define _3X_FOR_EACH_16(what, x, ...) what(x) EXPAND(_3X_FOR_EACH_15(what, __VA_ARGS__)) +#define _3X_FOR_EACH_(N, what, ...) EXPAND(CONCATENATE(_3X_FOR_EACH_, N)(what, __VA_ARGS__)) +#define _3X_FOR_EACH(what, ...) _3X_FOR_EACH_(FOR_EACH_NARG(__VA_ARGS__), what, __VA_ARGS__) +#define FOREACH_CALL_FUNC_3(func, ...) _3X_FOR_EACH(func, __VA_ARGS__) diff --git a/client/3rd/QJsonStruct/test/CMakeLists.txt b/client/3rd/QJsonStruct/test/CMakeLists.txt new file mode 100644 index 00000000..3934bd52 --- /dev/null +++ b/client/3rd/QJsonStruct/test/CMakeLists.txt @@ -0,0 +1,16 @@ +function(QJSONSTRUCT_ADD_TEST TEST_NAME TEST_SOURCE) + add_executable(${TEST_NAME} ${TEST_SOURCE} catch.hpp ${QJSONSTRUCT_SOURCES}) + target_include_directories(${TEST_NAME} + PRIVATE + $ + ) + target_link_libraries( + ${TEST_NAME} + PRIVATE + Qt::Core + ) + add_test(NAME QJSONSTRUCT_TEST_${TEST_NAME} COMMAND $ -s) +endfunction() + +QJSONSTRUCT_ADD_TEST(serialization serialize/main.cpp) +#QJSONSTRUCT_ADD_TEST(serialize_strings serialize/strings.cpp) diff --git a/client/3rd/QJsonStruct/test/TestIO.hpp b/client/3rd/QJsonStruct/test/TestIO.hpp new file mode 100644 index 00000000..7dd2822c --- /dev/null +++ b/client/3rd/QJsonStruct/test/TestIO.hpp @@ -0,0 +1,45 @@ +#pragma once +#include "QJsonStruct.hpp" +#ifndef _X + #include + #include + #include +#endif + +struct BaseStruct +{ + QString baseStr; + int o; + JSONSTRUCT_REGISTER(BaseStruct, F(baseStr, o)) +}; + +struct BaseStruct2 +{ + QString baseStr2; + int o2; + JSONSTRUCT_REGISTER(BaseStruct, F(baseStr2, o2)) +}; +struct TestInnerStruct + : BaseStruct + , BaseStruct2 +{ + QJsonObject jobj; + QJsonArray jarray; + QString str; + JSONSTRUCT_REGISTER(TestInnerStruct, B(BaseStruct, BaseStruct2), F(str, jobj, jarray)) +}; + +struct JsonIOTest +{ + QString str; + QList listOfNumber; + QList listOfBool; + QList listOfString; + QList> listOfListOfString; + + QMap map; + TestInnerStruct inner; + + JSONSTRUCT_REGISTER(JsonIOTest, F(str, listOfNumber, listOfBool, listOfString, listOfListOfString, map, inner)); + JsonIOTest(){}; +}; diff --git a/client/3rd/QJsonStruct/test/TestOut.hpp b/client/3rd/QJsonStruct/test/TestOut.hpp new file mode 100644 index 00000000..dacbe159 --- /dev/null +++ b/client/3rd/QJsonStruct/test/TestOut.hpp @@ -0,0 +1,19 @@ +#pragma once +#include "QJsonStruct.hpp" + +struct SubData +{ + QString subString; + JSONSTRUCT_REGISTER_TOJSON(subString) +}; + +struct ToJsonOnlyData +{ + QString x; + int y; + int z; + QList ints; + SubData sub; + QMap subs; + JSONSTRUCT_REGISTER_TOJSON(x, y, z, sub, ints, subs) +}; diff --git a/client/3rd/QJsonStruct/test/catch.hpp b/client/3rd/QJsonStruct/test/catch.hpp new file mode 100644 index 00000000..6beb0ead --- /dev/null +++ b/client/3rd/QJsonStruct/test/catch.hpp @@ -0,0 +1,17698 @@ +/* + * Catch v2.12.1 + * Generated: 2020-04-21 19:29:20.964532 + * ---------------------------------------------------------- + * This file has been merged from multiple headers. Please don't edit it directly + * Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED +#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED +// start catch.hpp + + +#define CATCH_VERSION_MAJOR 2 +#define CATCH_VERSION_MINOR 12 +#define CATCH_VERSION_PATCH 1 + +#ifdef __clang__ +# pragma clang system_header +#elif defined __GNUC__ +# pragma GCC system_header +#endif + +// start catch_suppress_warnings.h + +#ifdef __clang__ +# ifdef __ICC // icpc defines the __clang__ macro +# pragma warning(push) +# pragma warning(disable: 161 1682) +# else // __ICC +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpadded" +# pragma clang diagnostic ignored "-Wswitch-enum" +# pragma clang diagnostic ignored "-Wcovered-switch-default" +# endif +#elif defined __GNUC__ + // Because REQUIREs trigger GCC's -Wparentheses, and because still + // supported version of g++ have only buggy support for _Pragmas, + // Wparentheses have to be suppressed globally. +# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details + +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-variable" +# pragma GCC diagnostic ignored "-Wpadded" +#endif +// end catch_suppress_warnings.h +#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) +# define CATCH_IMPL +# define CATCH_CONFIG_ALL_PARTS +#endif + +// In the impl file, we want to have access to all parts of the headers +// Can also be used to sanely support PCHs +#if defined(CATCH_CONFIG_ALL_PARTS) +# define CATCH_CONFIG_EXTERNAL_INTERFACES +# if defined(CATCH_CONFIG_DISABLE_MATCHERS) +# undef CATCH_CONFIG_DISABLE_MATCHERS +# endif +# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +# endif +#endif + +#if !defined(CATCH_CONFIG_IMPL_ONLY) +// start catch_platform.h + +#ifdef __APPLE__ +# include +# if TARGET_OS_OSX == 1 +# define CATCH_PLATFORM_MAC +# elif TARGET_OS_IPHONE == 1 +# define CATCH_PLATFORM_IPHONE +# endif + +#elif defined(linux) || defined(__linux) || defined(__linux__) +# define CATCH_PLATFORM_LINUX + +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) +# define CATCH_PLATFORM_WINDOWS +#endif + +// end catch_platform.h + +#ifdef CATCH_IMPL +# ifndef CLARA_CONFIG_MAIN +# define CLARA_CONFIG_MAIN_NOT_DEFINED +# define CLARA_CONFIG_MAIN +# endif +#endif + +// start catch_user_interfaces.h + +namespace Catch { + unsigned int rngSeed(); +} + +// end catch_user_interfaces.h +// start catch_tag_alias_autoregistrar.h + +// start catch_common.h + +// start catch_compiler_capabilities.h + +// Detect a number of compiler features - by compiler +// The following features are defined: +// +// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? +// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? +// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? +// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? +// **************** +// Note to maintainers: if new toggles are added please document them +// in configuration.md, too +// **************** + +// In general each macro has a _NO_ form +// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. +// Many features, at point of detection, define an _INTERNAL_ macro, so they +// can be combined, en-mass, with the _NO_ forms later. + +#ifdef __cplusplus + +# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) +# define CATCH_CPP14_OR_GREATER +# endif + +# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) +# define CATCH_CPP17_OR_GREATER +# endif + +#endif + +#if defined(__cpp_lib_uncaught_exceptions) +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif + +// We have to avoid both ICC and Clang, because they try to mask themselves +// as gcc, and we want only GCC in this block +#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) + +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) + +#endif + +#if defined(__clang__) + +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) + +// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug +// which results in calls to destructors being emitted for each temporary, +// without a matching initialization. In practice, this can result in something +// like `std::string::~string` being called on an uninitialized value. +// +// For example, this code will likely segfault under IBM XL: +// ``` +// REQUIRE(std::string("12") + "34" == "1234") +// ``` +// +// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. +# if !defined(__ibmxl__) +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg) */ +# endif + +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ + _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") + +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) + +# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ + _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) + +#endif // __clang__ + +//////////////////////////////////////////////////////////////////////////////// +// Assume that non-Windows platforms support posix signals by default +#if !defined(CATCH_PLATFORM_WINDOWS) + #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS +#endif + +//////////////////////////////////////////////////////////////////////////////// +// We know some environments not to support full POSIX signals +#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) + #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +#endif + +#ifdef __OS400__ +# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS +# define CATCH_CONFIG_COLOUR_NONE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Android somehow still does not support std::to_string +#if defined(__ANDROID__) +# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING +# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Not all Windows environments support SEH properly +#if defined(__MINGW32__) +# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH +#endif + +//////////////////////////////////////////////////////////////////////////////// +// PS4 +#if defined(__ORBIS__) +# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Cygwin +#ifdef __CYGWIN__ + +// Required for some versions of Cygwin to declare gettimeofday +// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin +# define _BSD_SOURCE +// some versions of cygwin (most) do not support std::to_string. Use the libstd check. +// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 +# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ + && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) + +# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING + +# endif +#endif // __CYGWIN__ + +//////////////////////////////////////////////////////////////////////////////// +// Visual C++ +#if defined(_MSC_VER) + +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) + +# if _MSC_VER >= 1900 // Visual Studio 2015 or newer +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +# endif + +// Universal Windows platform does not support SEH +// Or console colours (or console at all...) +# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +# define CATCH_CONFIG_COLOUR_NONE +# else +# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH +# endif + +// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ +// _MSVC_TRADITIONAL == 0 means new conformant preprocessor +// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor +# if !defined(__clang__) // Handle Clang masquerading for msvc +# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) +# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +# endif // MSVC_TRADITIONAL +# endif // __clang__ + +#endif // _MSC_VER + +#if defined(_REENTRANT) || defined(_MSC_VER) +// Enable async processing, as -pthread is specified or no additional linking is required +# define CATCH_INTERNAL_CONFIG_USE_ASYNC +#endif // _MSC_VER + +//////////////////////////////////////////////////////////////////////////////// +// Check if we are compiled with -fno-exceptions or equivalent +#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) +# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED +#endif + +//////////////////////////////////////////////////////////////////////////////// +// DJGPP +#ifdef __DJGPP__ +# define CATCH_INTERNAL_CONFIG_NO_WCHAR +#endif // __DJGPP__ + +//////////////////////////////////////////////////////////////////////////////// +// Embarcadero C++Build +#if defined(__BORLANDC__) + #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN +#endif + +//////////////////////////////////////////////////////////////////////////////// + +// Use of __COUNTER__ is suppressed during code analysis in +// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly +// handled by it. +// Otherwise all supported compilers support COUNTER macro, +// but user still might want to turn it off +#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) + #define CATCH_INTERNAL_CONFIG_COUNTER +#endif + +//////////////////////////////////////////////////////////////////////////////// + +// RTX is a special version of Windows that is real time. +// This means that it is detected as Windows, but does not provide +// the same set of capabilities as real Windows does. +#if defined(UNDER_RTSS) || defined(RTX64_BUILD) + #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH + #define CATCH_INTERNAL_CONFIG_NO_ASYNC + #define CATCH_CONFIG_COLOUR_NONE +#endif + +#if !defined(_GLIBCXX_USE_C99_MATH_TR1) +#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER +#endif + +// Various stdlib support checks that require __has_include +#if defined(__has_include) + // Check if string_view is available and usable + #if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW + #endif + + // Check if optional is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) + + // Check if byte is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # define CATCH_INTERNAL_CONFIG_CPP17_BYTE + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) + + // Check if variant is available and usable + # if __has_include() && defined(CATCH_CPP17_OR_GREATER) + # if defined(__clang__) && (__clang_major__ < 8) + // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 + // fix should be in clang 8, workaround in libstdc++ 8.2 + # include + # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # define CATCH_CONFIG_NO_CPP17_VARIANT + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) + # else + # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT + # endif // defined(__clang__) && (__clang_major__ < 8) + # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) +#endif // defined(__has_include) + +#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) +# define CATCH_CONFIG_COUNTER +#endif +#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) +# define CATCH_CONFIG_WINDOWS_SEH +#endif +// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. +#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) +# define CATCH_CONFIG_POSIX_SIGNALS +#endif +// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. +#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) +# define CATCH_CONFIG_WCHAR +#endif + +#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) +# define CATCH_CONFIG_CPP11_TO_STRING +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) +# define CATCH_CONFIG_CPP17_OPTIONAL +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) +# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) +# define CATCH_CONFIG_CPP17_STRING_VIEW +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) +# define CATCH_CONFIG_CPP17_VARIANT +#endif + +#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) +# define CATCH_CONFIG_CPP17_BYTE +#endif + +#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) +# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE +#endif + +#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) +# define CATCH_CONFIG_NEW_CAPTURE +#endif + +#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) +# define CATCH_CONFIG_DISABLE_EXCEPTIONS +#endif + +#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) +# define CATCH_CONFIG_POLYFILL_ISNAN +#endif + +#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) +# define CATCH_CONFIG_USE_ASYNC +#endif + +#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) +# define CATCH_CONFIG_ANDROID_LOGWRITE +#endif + +#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) +# define CATCH_CONFIG_GLOBAL_NEXTAFTER +#endif + +// Even if we do not think the compiler has that warning, we still have +// to provide a macro that can be used by the code. +#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) +# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION +#endif +#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) +# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS +#endif + +// The goal of this macro is to avoid evaluation of the arguments, but +// still have the compiler warn on problems inside... +#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) +# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) +#endif + +#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) +# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#elif defined(__clang__) && (__clang_major__ < 5) +# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif + +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS +#endif + +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) +#define CATCH_TRY if ((true)) +#define CATCH_CATCH_ALL if ((false)) +#define CATCH_CATCH_ANON(type) if ((false)) +#else +#define CATCH_TRY try +#define CATCH_CATCH_ALL catch (...) +#define CATCH_CATCH_ANON(type) catch (type) +#endif + +#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) +#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#endif + +// end catch_compiler_capabilities.h +#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line +#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) +#ifdef CATCH_CONFIG_COUNTER +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) +#else +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) +#endif + +#include +#include +#include + +// We need a dummy global operator<< so we can bring it into Catch namespace later +struct Catch_global_namespace_dummy {}; +std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); + +namespace Catch { + + struct CaseSensitive { enum Choice { + Yes, + No + }; }; + + class NonCopyable { + NonCopyable( NonCopyable const& ) = delete; + NonCopyable( NonCopyable && ) = delete; + NonCopyable& operator = ( NonCopyable const& ) = delete; + NonCopyable& operator = ( NonCopyable && ) = delete; + + protected: + NonCopyable(); + virtual ~NonCopyable(); + }; + + struct SourceLineInfo { + + SourceLineInfo() = delete; + SourceLineInfo( char const* _file, std::size_t _line ) noexcept + : file( _file ), + line( _line ) + {} + + SourceLineInfo( SourceLineInfo const& other ) = default; + SourceLineInfo& operator = ( SourceLineInfo const& ) = default; + SourceLineInfo( SourceLineInfo&& ) noexcept = default; + SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; + + bool empty() const noexcept { return file[0] == '\0'; } + bool operator == ( SourceLineInfo const& other ) const noexcept; + bool operator < ( SourceLineInfo const& other ) const noexcept; + + char const* file; + std::size_t line; + }; + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); + + // Bring in operator<< from global namespace into Catch namespace + // This is necessary because the overload of operator<< above makes + // lookup stop at namespace Catch + using ::operator<<; + + // Use this in variadic streaming macros to allow + // >> +StreamEndStop + // as well as + // >> stuff +StreamEndStop + struct StreamEndStop { + std::string operator+() const; + }; + template + T const& operator + ( T const& value, StreamEndStop ) { + return value; + } +} + +#define CATCH_INTERNAL_LINEINFO \ + ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) + +// end catch_common.h +namespace Catch { + + struct RegistrarForTagAliases { + RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); + }; + +} // end namespace Catch + +#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION + +// end catch_tag_alias_autoregistrar.h +// start catch_test_registry.h + +// start catch_interfaces_testcase.h + +#include + +namespace Catch { + + class TestSpec; + + struct ITestInvoker { + virtual void invoke () const = 0; + virtual ~ITestInvoker(); + }; + + class TestCase; + struct IConfig; + + struct ITestCaseRegistry { + virtual ~ITestCaseRegistry(); + virtual std::vector const& getAllTests() const = 0; + virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; + }; + + bool isThrowSafe( TestCase const& testCase, IConfig const& config ); + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); + std::vector const& getAllTestCasesSorted( IConfig const& config ); + +} + +// end catch_interfaces_testcase.h +// start catch_stringref.h + +#include +#include +#include +#include + +namespace Catch { + + /// A non-owning string class (similar to the forthcoming std::string_view) + /// Note that, because a StringRef may be a substring of another string, + /// it may not be null terminated. + class StringRef { + public: + using size_type = std::size_t; + using const_iterator = const char*; + + private: + static constexpr char const* const s_empty = ""; + + char const* m_start = s_empty; + size_type m_size = 0; + + public: // construction + constexpr StringRef() noexcept = default; + + StringRef( char const* rawChars ) noexcept; + + constexpr StringRef( char const* rawChars, size_type size ) noexcept + : m_start( rawChars ), + m_size( size ) + {} + + StringRef( std::string const& stdString ) noexcept + : m_start( stdString.c_str() ), + m_size( stdString.size() ) + {} + + explicit operator std::string() const { + return std::string(m_start, m_size); + } + + public: // operators + auto operator == ( StringRef const& other ) const noexcept -> bool; + auto operator != (StringRef const& other) const noexcept -> bool { + return !(*this == other); + } + + auto operator[] ( size_type index ) const noexcept -> char { + assert(index < m_size); + return m_start[index]; + } + + public: // named queries + constexpr auto empty() const noexcept -> bool { + return m_size == 0; + } + constexpr auto size() const noexcept -> size_type { + return m_size; + } + + // Returns the current start pointer. If the StringRef is not + // null-terminated, throws std::domain_exception + auto c_str() const -> char const*; + + public: // substrings and searches + // Returns a substring of [start, start + length). + // If start + length > size(), then the substring is [start, size()). + // If start > size(), then the substring is empty. + auto substr( size_type start, size_type length ) const noexcept -> StringRef; + + // Returns the current start pointer. May not be null-terminated. + auto data() const noexcept -> char const*; + + constexpr auto isNullTerminated() const noexcept -> bool { + return m_start[m_size] == '\0'; + } + + public: // iterators + constexpr const_iterator begin() const { return m_start; } + constexpr const_iterator end() const { return m_start + m_size; } + }; + + auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; + auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; + + constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { + return StringRef( rawChars, size ); + } +} // namespace Catch + +constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { + return Catch::StringRef( rawChars, size ); +} + +// end catch_stringref.h +// start catch_preprocessor.hpp + + +#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ +#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) +#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) + +#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ +// MSVC needs more evaluations +#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) +#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) +#else +#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) +#endif + +#define CATCH_REC_END(...) +#define CATCH_REC_OUT + +#define CATCH_EMPTY() +#define CATCH_DEFER(id) id CATCH_EMPTY() + +#define CATCH_REC_GET_END2() 0, CATCH_REC_END +#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 +#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 +#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT +#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) +#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) + +#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) + +#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) +#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) + +// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, +// and passes userdata as the first parameter to each invocation, +// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) +#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) +#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ +#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ +#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) +#else +// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF +#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) +#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ +#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) +#endif + +#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ +#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) + +#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) + +#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) +#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) +#else +#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) +#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) +#endif + +#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ + CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) + +#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) +#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) +#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) +#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) +#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) +#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) +#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _4, _5, _6) +#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) +#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) +#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) +#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) + +#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N + +#define INTERNAL_CATCH_TYPE_GEN\ + template struct TypeList {};\ + template\ + constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ + template class...> struct TemplateTypeList{};\ + template class...Cs>\ + constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ + template\ + struct append;\ + template\ + struct rewrap;\ + template class, typename...>\ + struct create;\ + template class, typename>\ + struct convert;\ + \ + template \ + struct append { using type = T; };\ + template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ + struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ + template< template class L1, typename...E1, typename...Rest>\ + struct append, TypeList, Rest...> { using type = L1; };\ + \ + template< template class Container, template class List, typename...elems>\ + struct rewrap, List> { using type = TypeList>; };\ + template< template class Container, template class List, class...Elems, typename...Elements>\ + struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ + \ + template