diff --git a/.appveyor.yml b/.appveyor.yml
deleted file mode 100644
index a896cb635..000000000
--- a/.appveyor.yml
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# Copyright (c) 2016, The OpenThread Authors.
-# 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 copyright holder 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 COPYRIGHT HOLDER 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.
-#
-
-version: 0.1.{build}
-image: Visual Studio 2015
-configuration:
-- Release
-platform:
-- x64
-- x86
-- arm
-clone_depth: 10
-install:
- - cmd: Bcdedit.exe -set TESTSIGNING ON
- # Configure logging
- - cmd: reg import tools\windows\ThreadEtw.reg
- - ps: Restart-Computer -Force
- - ps: Start-Sleep -s 10
-before_build:
- - cmd: ren "C:\Program Files (x86)\Windows Kits\10\include\00wdf" "wdf"
-build:
- project: etc/visual-studio/openthread.sln
- verbosity: minimal
-after_build:
- - ps: $env:Platform2 = $env:Platform
- - ps: If ($env:Platform2 -eq "x86") { $env:Platform2 = "Win32" }
- # Set up the release directories
- - cmd: .appveyor\make_release.cmd
- # Install driver (only runs on x64)
- - cmd: .appveyor\install_driver.cmd
-test_script:
- # Run the unit tests
- - cmd: .appveyor\run_unit_tests.cmd
- # Run the tests for the driver (only runs on x64)
- #- cmd: .appveyor\test_driver.cmd
-artifacts:
-- path: release
- name: release
-- path: build\bin\AppPackages
- name: app
diff --git a/.appveyor/install_driver.cmd b/.appveyor/install_driver.cmd
deleted file mode 100644
index 73e0742a8..000000000
--- a/.appveyor/install_driver.cmd
+++ /dev/null
@@ -1,43 +0,0 @@
-REM
-REM Copyright (c) 2016, The OpenThread Authors.
-REM All rights reserved.
-REM
-REM Redistribution and use in source and binary forms, with or without
-REM modification, are permitted provided that the following conditions are met:
-REM 1. Redistributions of source code must retain the above copyright
-REM notice, this list of conditions and the following disclaimer.
-REM 2. Redistributions in binary form must reproduce the above copyright
-REM notice, this list of conditions and the following disclaimer in the
-REM documentation and/or other materials provided with the distribution.
-REM 3. Neither the name of the copyright holder nor the
-REM names of its contributors may be used to endorse or promote products
-REM derived from this software without specific prior written permission.
-REM
-REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-REM AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-REM IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-REM ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-REM LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-REM CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-REM SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-REM INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-REM CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-REM ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-REM POSSIBILITY OF SUCH DAMAGE.
-REM
-
-IF NOT "%Platform%"=="x64" GOTO :EOF
-
-pushd %APPVEYOR_BUILD_FOLDER%\build\bin\%Platform2%\%Configuration%\sys
-
-REM Install the certifications to the cert stores
-certutil -addstore root otLwf.cer
-certutil -addstore TrustedPublisher otLwf.cer
-
-cd otLwf
-
-REM Install the NDIS LWF driver, otLwf.sys
-
-netcfg.exe -v -l otlwf.inf -c s -i otLwf
-
-popd
\ No newline at end of file
diff --git a/.appveyor/make_release.cmd b/.appveyor/make_release.cmd
deleted file mode 100644
index 8ecf68c33..000000000
--- a/.appveyor/make_release.cmd
+++ /dev/null
@@ -1,87 +0,0 @@
-REM
-REM Copyright (c) 2016, The OpenThread Authors.
-REM All rights reserved.
-REM
-REM Redistribution and use in source and binary forms, with or without
-REM modification, are permitted provided that the following conditions are met:
-REM 1. Redistributions of source code must retain the above copyright
-REM notice, this list of conditions and the following disclaimer.
-REM 2. Redistributions in binary form must reproduce the above copyright
-REM notice, this list of conditions and the following disclaimer in the
-REM documentation and/or other materials provided with the distribution.
-REM 3. Neither the name of the copyright holder nor the
-REM names of its contributors may be used to endorse or promote products
-REM derived from this software without specific prior written permission.
-REM
-REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-REM AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-REM IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-REM ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-REM LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-REM CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-REM SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-REM INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-REM CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-REM ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-REM POSSIBILITY OF SUCH DAMAGE.
-REM
-
-pushd %APPVEYOR_BUILD_FOLDER%
-
-REM Make the release directories
-mkdir release
-mkdir release\include
-mkdir release\include\openthread\
-mkdir release\include\openthread\missing
-mkdir release\include\openthread\platform
-mkdir release\libs
-mkdir release\symbols
-mkdir release\symbols\TraceFormat
-
-REM Copy the relavant include headers
-
-copy include\openthread\commissioner.h release\include\openthread
-copy include\openthread\dataset.h release\include\openthread
-copy include\openthread\error.h release\include\openthread
-copy include\openthread\instance.h release\include\openthread
-copy include\openthread\ip6.h release\include\openthread
-copy include\openthread\joiner.h release\include\openthread
-copy include\openthread\link.h release\include\openthread
-copy include\openthread\message.h release\include\openthread
-copy include\openthread\netdata.h release\include\openthread
-copy include\openthread\thread.h release\include\openthread
-copy include\openthread\types.h release\include\openthread
-copy include\openthread\platform\toolchain.h release\include\openthread\platform
-copy src\missing\stdbool\stdbool.h release\include\openthread\missing
-copy src\missing\stdint\stdint.h release\include\openthread\missing
-
-REM Copy the relavant binaries
-
-copy build\bin\%Platform2%\%Configuration%\sys\otlwf\* release
-copy build\bin\%Platform2%\%Configuration%\sys\otlwf.cer release
-copy build\bin\%Platform2%\%Configuration%\sys\otlwf.pdb release\symbols
-copy build\bin\%Platform2%\%Configuration%\sys\ottmp\* release
-copy build\bin\%Platform2%\%Configuration%\sys\ottmp.cer release
-copy build\bin\%Platform2%\%Configuration%\sys\ottmp.pdb release\symbols
-copy build\bin\%Platform2%\%Configuration%\dll\otApi.dll release
-copy build\bin\%Platform2%\%Configuration%\dll\otApi.lib release\libs
-copy build\bin\%Platform2%\%Configuration%\dll\otApi.pdb release\symbols
-copy build\bin\%Platform2%\%Configuration%\dll\otNodeApi.dll release
-copy build\bin\%Platform2%\%Configuration%\dll\otNodeApi.lib release\libs
-copy build\bin\%Platform2%\%Configuration%\dll\otNodeApi.pdb release\symbols
-copy build\bin\%Platform2%\%Configuration%\exe\otCli.exe release
-copy build\bin\%Platform2%\%Configuration%\exe\otCli.pdb release\symbols
-copy build\bin\%Platform2%\%Configuration%\exe\otTestRunner.exe release
-copy build\bin\%Platform2%\%Configuration%\exe\otTestRunner.pdb release\symbols
-
-REM Copy the tools
-
-copy tools\windows\* release
-copy tools\windows\%Platform%\otInstall.exe release
-copy "C:\Program Files (x86)\Windows Kits\10\Tools\%Platform%\devcon.exe" release
-
-REM Generate the trace format files to decode the WPP logs
-
-"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\x64\TracePdb.exe" -f release\symbols\*.pdb -p release\symbols\TraceFormat
-
-popd
\ No newline at end of file
diff --git a/.appveyor/run_unit_tests.cmd b/.appveyor/run_unit_tests.cmd
deleted file mode 100644
index c4f496c06..000000000
--- a/.appveyor/run_unit_tests.cmd
+++ /dev/null
@@ -1,31 +0,0 @@
-REM
-REM Copyright (c) 2016, The OpenThread Authors.
-REM All rights reserved.
-REM
-REM Redistribution and use in source and binary forms, with or without
-REM modification, are permitted provided that the following conditions are met:
-REM 1. Redistributions of source code must retain the above copyright
-REM notice, this list of conditions and the following disclaimer.
-REM 2. Redistributions in binary form must reproduce the above copyright
-REM notice, this list of conditions and the following disclaimer in the
-REM documentation and/or other materials provided with the distribution.
-REM 3. Neither the name of the copyright holder nor the
-REM names of its contributors may be used to endorse or promote products
-REM derived from this software without specific prior written permission.
-REM
-REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-REM AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-REM IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-REM ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-REM LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-REM CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-REM SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-REM INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-REM CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-REM ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-REM POSSIBILITY OF SUCH DAMAGE.
-REM
-
-IF "%Platform%"=="arm" GOTO :EOF
-
-vstest.console /logger:Appveyor /inIsolation /platform:%Platform% build\bin\%Platform2%\%Configuration%\dll\UnitTests.dll
\ No newline at end of file
diff --git a/.appveyor/test_driver.cmd b/.appveyor/test_driver.cmd
deleted file mode 100644
index 74254195a..000000000
--- a/.appveyor/test_driver.cmd
+++ /dev/null
@@ -1,47 +0,0 @@
-REM
-REM Copyright (c) 2016, The OpenThread Authors.
-REM All rights reserved.
-REM
-REM Redistribution and use in source and binary forms, with or without
-REM modification, are permitted provided that the following conditions are met:
-REM 1. Redistributions of source code must retain the above copyright
-REM notice, this list of conditions and the following disclaimer.
-REM 2. Redistributions in binary form must reproduce the above copyright
-REM notice, this list of conditions and the following disclaimer in the
-REM documentation and/or other materials provided with the distribution.
-REM 3. Neither the name of the copyright holder nor the
-REM names of its contributors may be used to endorse or promote products
-REM derived from this software without specific prior written permission.
-REM
-REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-REM AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-REM IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-REM ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-REM LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-REM CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-REM SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-REM INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-REM CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-REM ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-REM POSSIBILITY OF SUCH DAMAGE.
-REM
-
-IF NOT "%Platform%"=="x64" GOTO :EOF
-
-pushd %APPVEYOR_BUILD_FOLDER%\release
-
-REM Query the driver state
-
-sc query otlwf
-
-REM Run the basic driver test
-
-otTestRunner.exe ..\tests\scripts\thread-cert Test_otLwf* appveyor
-
-REM Grab the logs
-
-mkdir logs
-logman stop Thread -ets
-copy %SystemRoot%\System32\LogFiles\WMI\Thread.* logs
-
-popd
\ No newline at end of file
diff --git a/.gitattributes b/.gitattributes
index eaad68cbe..a8c7a5efc 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -36,10 +36,3 @@ configure.ac eol=lf
Makefile.am eol=lf
Makefile.in eol=lf
Makefile eol=lf
-
-# Files normalized to always keep Windows line endings
-*.vcxproj eol=crlf
-*.vcxproj.filters eol=crlf
-*.sln eol=crlf
-*.rc text eol=crlf
-*.inf text eol=crlf
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index dcb76ee4c..71b7c2c0b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -37,7 +37,7 @@ The OpenThread Project follows the "Fork-and-Pull" model for accepting contribut
Setup your GitHub fork and continuous-integration services:
1. Fork the [OpenThread repository](https://github.com/openthread/openthread) by clicking "Fork" on the web UI.
-2. Enable [Travis CI](https://travis-ci.org/) and [AppVeyor](https://ci.appveyor.com/) by logging in the respective services with your GitHub account and enabling your newly created fork. We use Travis CI for Linux-based continuous integration checks and AppVeyor for Windows-based continuous integration checks. All contributions must pass these checks to be accepted.
+2. Enable [Travis CI](https://travis-ci.org/) by logging in the respective service with your GitHub account and enabling your newly created fork. We use Travis CI for Linux-based continuous integration checks. All contributions must pass these checks to be accepted.
Setup your local development environment:
diff --git a/README.md b/README.md
index feb262ad1..4366ebf83 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,5 @@
[![OpenThread][ot-logo]][ot-repo]
[![Build Status][ot-travis-svg]][ot-travis]
-[![Build Status][ot-appveyor-svg]][ot-appveyor]
[![Coverage Status][ot-codecov-svg]][ot-codecov]
[![Build Status][ot-docker-dev-svg]][ot-docker-dev]
@@ -26,8 +25,6 @@ More information about Thread can be found at [threadgroup.org](http://threadgro
[ot-logo]: doc/images/openthread_logo.png
[ot-travis]: https://travis-ci.org/openthread/openthread
[ot-travis-svg]: https://travis-ci.org/openthread/openthread.svg?branch=master
-[ot-appveyor]: https://ci.appveyor.com/project/jwhui/openthread
-[ot-appveyor-svg]: https://ci.appveyor.com/api/projects/status/r5qwyhn9p26nmfk3?svg=true
[ot-codecov]: https://codecov.io/gh/openthread/openthread
[ot-codecov-svg]: https://codecov.io/gh/openthread/openthread/branch/master/graph/badge.svg
[ot-docker-dev]: https://hub.docker.com/r/openthread/environment
@@ -35,7 +32,7 @@ More information about Thread can be found at [threadgroup.org](http://threadgro
# Who supports OpenThread?
-
+
# Getting started
diff --git a/doc/images/windows-app-details.png b/doc/images/windows-app-details.png
deleted file mode 100644
index a2977c1c1..000000000
Binary files a/doc/images/windows-app-details.png and /dev/null differ
diff --git a/doc/images/windows-app-interface-list.png b/doc/images/windows-app-interface-list.png
deleted file mode 100644
index 922b5f289..000000000
Binary files a/doc/images/windows-app-interface-list.png and /dev/null differ
diff --git a/doc/images/windows-app-talk-client.png b/doc/images/windows-app-talk-client.png
deleted file mode 100644
index b40c9a4ee..000000000
Binary files a/doc/images/windows-app-talk-client.png and /dev/null differ
diff --git a/doc/images/windows-app-talk-server.png b/doc/images/windows-app-talk-server.png
deleted file mode 100644
index 165689bc7..000000000
Binary files a/doc/images/windows-app-talk-server.png and /dev/null differ
diff --git a/doc/images/windows_design.png b/doc/images/windows_design.png
deleted file mode 100644
index c5fa3438e..000000000
Binary files a/doc/images/windows_design.png and /dev/null differ
diff --git a/etc/visual-studio/Assets/LockScreenLogo.scale-200.png b/etc/visual-studio/Assets/LockScreenLogo.scale-200.png
deleted file mode 100644
index 2dedc71cf..000000000
Binary files a/etc/visual-studio/Assets/LockScreenLogo.scale-200.png and /dev/null differ
diff --git a/etc/visual-studio/Assets/SplashScreen.scale-200.png b/etc/visual-studio/Assets/SplashScreen.scale-200.png
deleted file mode 100644
index af038b0b0..000000000
Binary files a/etc/visual-studio/Assets/SplashScreen.scale-200.png and /dev/null differ
diff --git a/etc/visual-studio/Assets/Square150x150Logo.scale-200.png b/etc/visual-studio/Assets/Square150x150Logo.scale-200.png
deleted file mode 100644
index 5ae239d1b..000000000
Binary files a/etc/visual-studio/Assets/Square150x150Logo.scale-200.png and /dev/null differ
diff --git a/etc/visual-studio/Assets/Square44x44Logo.scale-200.png b/etc/visual-studio/Assets/Square44x44Logo.scale-200.png
deleted file mode 100644
index 4e020dfbf..000000000
Binary files a/etc/visual-studio/Assets/Square44x44Logo.scale-200.png and /dev/null differ
diff --git a/etc/visual-studio/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/etc/visual-studio/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
deleted file mode 100644
index 8b6f2df98..000000000
Binary files a/etc/visual-studio/Assets/Square44x44Logo.targetsize-24_altform-unplated.png and /dev/null differ
diff --git a/etc/visual-studio/Assets/StoreLogo.png b/etc/visual-studio/Assets/StoreLogo.png
deleted file mode 100644
index 7fa37c289..000000000
Binary files a/etc/visual-studio/Assets/StoreLogo.png and /dev/null differ
diff --git a/etc/visual-studio/Assets/Wide310x150Logo.scale-200.png b/etc/visual-studio/Assets/Wide310x150Logo.scale-200.png
deleted file mode 100644
index 25b80bbe4..000000000
Binary files a/etc/visual-studio/Assets/Wide310x150Logo.scale-200.png and /dev/null differ
diff --git a/etc/visual-studio/OpenThread.vcxproj b/etc/visual-studio/OpenThread.vcxproj
deleted file mode 100644
index ebdced03b..000000000
--- a/etc/visual-studio/OpenThread.vcxproj
+++ /dev/null
@@ -1,159 +0,0 @@
-
-
-
-
- {f8c22844-9b93-4978-80df-8af2b37a7abb}
- ot
- en-US
- 14.0
- true
- Windows Store
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- Application
- true
- v140
-
-
- Application
- false
- true
- v140
- true
-
-
-
-
-
-
-
-
- ..\..\examples\apps\windows\OpenThread_TemporaryKey.pfx
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\app\
- True
- ..\..\build\bin\AppPackages\
- Never
-
-
-
-
- %(PreprocessorDefinitions);
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
-
- /bigobj %(AdditionalOptions)
- 4453;28204
-
- %(AdditionalIncludeDirectories);
- ..\..\examples\apps\windows;
- ..\..\include;
-
-
-
-
- %(AdditionalDependencies);
- ..\..\build\bin\$(Platform)\$(Configuration)\dll\otApi.lib;
-
-
-
-
-
-
- ..\..\examples\apps\windows\ClientControl.xaml
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ..\..\examples\apps\windows\App.xaml
-
-
- ..\..\examples\apps\windows\MainPage.xaml
-
-
- ..\..\examples\apps\windows\ServerControl.xaml
-
-
-
-
-
- ..\..\examples\apps\windows\TalkGrid.xaml
-
-
-
-
-
- Designer
-
-
- Designer
-
-
- Designer
-
-
- Designer
-
-
- Designer
-
-
-
-
- Designer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ..\..\examples\apps\windows\App.xaml
-
-
- ..\..\examples\apps\windows\ClientControl.xaml
-
-
-
-
-
- ..\..\examples\apps\windows\MainPage.xaml
-
-
- Create
-
-
- ..\..\examples\apps\windows\ServerControl.xaml
-
-
-
-
- ..\..\examples\apps\windows\TalkGrid.xaml
-
-
-
-
-
-
diff --git a/etc/visual-studio/OpenThread.vcxproj.filters b/etc/visual-studio/OpenThread.vcxproj.filters
deleted file mode 100644
index 5fb431551..000000000
--- a/etc/visual-studio/OpenThread.vcxproj.filters
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
- f8c22844-9b93-4978-80df-8af2b37a7abb
-
-
- cf539bf1-44af-4a06-be13-5941f6ac2623
- bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Assets
-
-
- Assets
-
-
- Assets
-
-
- Assets
-
-
- Assets
-
-
- Assets
-
-
- Assets
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/UnitTests.vcxproj b/etc/visual-studio/UnitTests.vcxproj
deleted file mode 100644
index dd13dd6c7..000000000
--- a/etc/visual-studio/UnitTests.vcxproj
+++ /dev/null
@@ -1,102 +0,0 @@
-
-
-
-
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}
- Win32Proj
- ot
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- DynamicLibrary
- true
- v140
-
-
- DynamicLibrary
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\dll\
-
-
-
-
- %(AdditionalIncludeDirectories);
- $(VCInstallDir)UnitTest\include;
- ..\..\include;
- ..\..\src;
- ..\..\src\core;
- ..\..\third_party\mbedtls;
- ..\..\third_party\mbedtls\repo\include;
-
-
- %(PreprocessorDefinitions)
- MBEDTLS_CONFIG_FILE="mbedtls-config.h";
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_FTD=1;
-
- Level3
- true
-
-
- Windows
-
- %(AdditionalLibraryDirectories);
- $(VCInstallDir)UnitTest\lib;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {d94867d2-6dae-47e2-962a-5e8e658134d1}
-
-
- {dd5018be-54c6-4fd4-9f8d-08d52fc0cd40}
-
-
- {4111c8bb-d354-4348-ad3c-eb6832e84831}
-
-
-
-
-
-
diff --git a/etc/visual-studio/UnitTests.vcxproj.filters b/etc/visual-studio/UnitTests.vcxproj.filters
deleted file mode 100644
index 1c728f6fd..000000000
--- a/etc/visual-studio/UnitTests.vcxproj.filters
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
-
diff --git a/etc/visual-studio/libopenthread-cli-windows.vcxproj b/etc/visual-studio/libopenthread-cli-windows.vcxproj
deleted file mode 100644
index e62e29f13..000000000
--- a/etc/visual-studio/libopenthread-cli-windows.vcxproj
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
- {28834498-3837-44A5-8F67-249ABAB7B97D}
- StaticLibrary
- ot
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- StaticLibrary
- true
- v140
-
-
- StaticLibrary
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\lib\
-
-
-
-
- %(PreprocessorDefinitions);
- MBEDTLS_CONFIG_FILE="mbedtls-config.h";
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OTDLL;
- OTBUILD;
- OPENTHREAD_FTD=1;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\include;
- ..\..\src;
- ..\..\src\core;
- ..\..\third_party\mbedtls;
- ..\..\third_party\mbedtls\repo\include;
-
- Level3
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/etc/visual-studio/libopenthread-cli-windows.vcxproj.filters b/etc/visual-studio/libopenthread-cli-windows.vcxproj.filters
deleted file mode 100644
index 7832b5237..000000000
--- a/etc/visual-studio/libopenthread-cli-windows.vcxproj.filters
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/libopenthread-cli.vcxproj b/etc/visual-studio/libopenthread-cli.vcxproj
deleted file mode 100644
index 4fd882d4d..000000000
--- a/etc/visual-studio/libopenthread-cli.vcxproj
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
- {41B32069-632E-4578-855B-A36EBFA80B56}
- StaticLibrary
- ot
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- StaticLibrary
- true
- v140
-
-
- StaticLibrary
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\lib\
-
-
-
-
- %(PreprocessorDefinitions);
- MBEDTLS_CONFIG_FILE="mbedtls-config.h";
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_FTD=1;
- OTBUILD;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\include;
- ..\..\src;
- ..\..\src\core;
- ..\..\third_party\mbedtls;
- ..\..\third_party\mbedtls\repo\include;
-
- Level3
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/libopenthread-cli.vcxproj.filters b/etc/visual-studio/libopenthread-cli.vcxproj.filters
deleted file mode 100644
index 687e25b6f..000000000
--- a/etc/visual-studio/libopenthread-cli.vcxproj.filters
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/libopenthread-ncp-spi.vcxproj b/etc/visual-studio/libopenthread-ncp-spi.vcxproj
deleted file mode 100644
index 3770cd51a..000000000
--- a/etc/visual-studio/libopenthread-ncp-spi.vcxproj
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}
- StaticLibrary
- ot
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- StaticLibrary
- true
- v140
-
-
- StaticLibrary
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\lib\
-
-
-
-
- %(PreprocessorDefinitions);
- MBEDTLS_CONFIG_FILE="mbedtls-config.h";
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_FTD=1;
- OPENTHREAD_ENABLE_NCP_SPI=1;
- OPENTHREAD_ENABLE_NCP_UART=0;
- OTBUILD;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\include;
- ..\..\src;
- ..\..\src\core;
- ..\..\third_party\mbedtls;
- ..\..\third_party\mbedtls\repo\include;
-
- Level3
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/etc/visual-studio/libopenthread-ncp-spi.vcxproj.filters b/etc/visual-studio/libopenthread-ncp-spi.vcxproj.filters
deleted file mode 100644
index 7082eee17..000000000
--- a/etc/visual-studio/libopenthread-ncp-spi.vcxproj.filters
+++ /dev/null
@@ -1,75 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
-
diff --git a/etc/visual-studio/libopenthread-ncp-uart.vcxproj b/etc/visual-studio/libopenthread-ncp-uart.vcxproj
deleted file mode 100644
index 61d63a766..000000000
--- a/etc/visual-studio/libopenthread-ncp-uart.vcxproj
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}
- StaticLibrary
- ot
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- StaticLibrary
- true
- v140
-
-
- StaticLibrary
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\lib\
-
-
-
-
- %(PreprocessorDefinitions);
- MBEDTLS_CONFIG_FILE="mbedtls-config.h";
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_FTD=1;
- OPENTHREAD_ENABLE_NCP_SPI=0;
- OPENTHREAD_ENABLE_NCP_UART=1;
- OTBUILD;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\include;
- ..\..\src;
- ..\..\src\core;
- ..\..\third_party\mbedtls;
- ..\..\third_party\mbedtls\repo\include;
-
- Level3
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/etc/visual-studio/libopenthread-ncp-uart.vcxproj.filters b/etc/visual-studio/libopenthread-ncp-uart.vcxproj.filters
deleted file mode 100644
index ab01236f6..000000000
--- a/etc/visual-studio/libopenthread-ncp-uart.vcxproj.filters
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
-
diff --git a/etc/visual-studio/libopenthread-windows.vcxproj b/etc/visual-studio/libopenthread-windows.vcxproj
deleted file mode 100644
index 58001381d..000000000
--- a/etc/visual-studio/libopenthread-windows.vcxproj
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
-
-
- {30723C38-BA3B-44C9-8D64-C5861A26934F}
- StaticLibrary
- ot
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- StaticLibrary
- true
- v140
-
-
- StaticLibrary
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\lib\
-
-
-
- Level3
-
- %(PreprocessorDefinitions);
- _CRT_SECURE_NO_WARNINGS;
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_FTD=1;
- OPENTHREAD_ENABLE_NCP_SPI=1;
- OTBUILD;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\include;
- ..\..\examples\platforms;
- ..\..\src\core;
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/libopenthread-windows.vcxproj.filters b/etc/visual-studio/libopenthread-windows.vcxproj.filters
deleted file mode 100644
index 99d35fcee..000000000
--- a/etc/visual-studio/libopenthread-windows.vcxproj.filters
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {af2a0e04-134d-40b3-84d4-82c8c622f9ae}
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
-
diff --git a/etc/visual-studio/libopenthread.vcxproj b/etc/visual-studio/libopenthread.vcxproj
deleted file mode 100644
index cf9067a0f..000000000
--- a/etc/visual-studio/libopenthread.vcxproj
+++ /dev/null
@@ -1,268 +0,0 @@
-
-
-
-
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}
- StaticLibrary
- ot
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- StaticLibrary
- true
- v140
-
-
- StaticLibrary
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\lib\
-
-
-
-
- %(PreprocessorDefinitions);
- MBEDTLS_CONFIG_FILE="mbedtls-config.h";
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_FTD=1;
- OTBUILD;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\include;
- ..\..\src\core;
- ..\..\third_party\mbedtls;
- ..\..\third_party\mbedtls\repo\include;
-
- Level3
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/etc/visual-studio/libopenthread.vcxproj.filters b/etc/visual-studio/libopenthread.vcxproj.filters
deleted file mode 100644
index 69b3ab7fd..000000000
--- a/etc/visual-studio/libopenthread.vcxproj.filters
+++ /dev/null
@@ -1,654 +0,0 @@
-
-
-
-
- {c09c2d1c-85fb-4081-8235-925b45ed3c4b}
-
-
- {CE77AA98-FC98-4FC6-BB52-8A886378AB5E}
-
-
- {a59636b8-d046-46b7-992b-76572ca72bd1}
-
-
- {7c989f53-480b-42d4-a2dc-454adafda818}
-
-
- {444ab8c6-6b83-4a5b-9059-67f469da1331}
-
-
- {a49a9cc3-6a37-48a6-8049-b10c9cecd193}
-
-
- {0e7f4f58-a115-4ce8-8e3b-1094fb79af52}
-
-
- {9a61353a-8613-4496-9ee8-c3d2800c5ac6}
-
-
- {c14a7a3f-089f-47ee-80db-1caf1b47ab6b}
-
-
- {A0D2E990-DC5E-4B56-A552-888F97214A17}
-
-
- {F0DDA90-D13F-4B56-A552-328F97124A81}
-
-
- {b4905c15-9702-4ff0-8d57-e7926337d50f}
-
-
- {c2f72132-0df1-4dba-b24f-0ab683874538}
-
-
- {92f20ce7-8f87-4a1c-bc0b-d7fa3dfd3b60}
-
-
- {c618ddc9-5c66-485f-a0ff-ebabb3508568}
-
-
- {90294598-e94b-4c07-a531-93335a8955d9}
-
-
- {0c76d116-0b4d-4fec-a0d8-5ca127913124}
-
-
- {702145f9-0e66-4e45-b3d4-d43f2cf17e10}
-
-
- {635aaabf-80f0-40e2-9218-22ff75bc0e32}
-
-
- {5ac96cb9-6257-4387-9238-27649915463a}
-
-
- {25a5662d-0709-4698-8fd9-3abfde8f0fc6}
-
-
- {971969f2-f6ec-50b4-806a-97965c934cef}
-
-
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\coap
-
-
- Source Files\coap
-
-
- Source Files\coap
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\crypto
-
-
- Source Files\mac
-
-
- Source Files\api
-
-
- Source Files\mac
-
-
- Source Files\mac
-
-
- Source Files\mac
-
-
- Source Files\mac
-
-
- Source Files\mac
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\phy
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\net
-
-
- Source Files\meshcop
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\crypto
-
-
- Source Files\crypto
-
-
- Source Files\crypto
-
-
- Source Files\crypto
-
-
- Source Files\crypto
-
-
- Source Files\utils
-
-
- Source Files\utils
-
-
- Source Files\utils
-
-
- Source Files\utils
-
-
- Source Files\utils
-
-
- Source Files\utils
-
-
- Source Files\utils
-
-
- Source Files\meshcop
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\common
-
-
- Source Files\thread
-
-
-
-
- Header Files\coap
-
-
- Header Files\coap
-
-
- Header Files\coap
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\crypto
-
-
- Header Files\mac
-
-
- Header Files\mac
-
-
- Header Files\mac
-
-
- Header Files\mac
-
-
- Header Files\mac
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\phy
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\meshcop
-
-
- Header Files\meshcop
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\meshcop
-
-
- Header Files\meshcop
-
-
- Header Files\meshcop
-
-
- Header Files\meshcop
-
-
- Header Files\meshcop
-
-
- Header Files\meshcop
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\crypto
-
-
- Header Files\crypto
-
-
- Header Files\crypto
-
-
- Header Files\crypto
-
-
- Header Files\crypto
-
-
- Header Files\utils
-
-
- Header Files\utils
-
-
- Header Files\utils
-
-
- Header Files\utils
-
-
- Header Files\utils
-
-
- Header Files\utils
-
-
- Header Files\utils
-
-
- Header Files\common
-
-
- Header Files\api
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
-
diff --git a/etc/visual-studio/libopenthread_k.vcxproj b/etc/visual-studio/libopenthread_k.vcxproj
deleted file mode 100644
index 720101778..000000000
--- a/etc/visual-studio/libopenthread_k.vcxproj
+++ /dev/null
@@ -1,299 +0,0 @@
-
-
-
-
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}
- {8c0e3d8b-df43-455b-815a-4a0e72973bc6}
- v4.5
- 12.0
- Debug
- Win32
- ot
- KMDF
- Universal
-
-
- WindowsKernelModeDriver10.0
- StaticLibrary
-
-
-
- Windows10
- true
-
-
- Windows10
- false
-
-
-
-
-
-
-
- ..\..\build\bin\$(Platform)\$(Configuration)\lib\
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
-
-
-
-
- %(PreprocessorDefinitions);
- MBEDTLS_CONFIG_FILE="mbedtls-config.h";
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-windows-config.h";
- WINDOWS_LOGGING;
- OPENTHREAD_FTD=1;
- HAVE_STDBOOL_H=1;
- HAVE_STDINT_H=1;
- OT_STRING_WINDOWS_WORKAROUND=1;
- OTBUILD;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\include;
- ..\..\examples\drivers\windows\include;
- ..\..\src\core;
- ..\..\third_party\mbedtls;
- ..\..\third_party\mbedtls\repo\include;
- ..\..\examples\drivers\windows\include_c99;
-
- 4100;4706;4748;%(DisableSpecificWarnings)
- true
- true
- ..\..\include\openthread\platform\logging-windows.h
- -km %(WppAdditionalOptions)
- otCore
- WPP_INIT_TRACING
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/etc/visual-studio/libopenthread_k.vcxproj.filters b/etc/visual-studio/libopenthread_k.vcxproj.filters
deleted file mode 100644
index 8a8a9bad8..000000000
--- a/etc/visual-studio/libopenthread_k.vcxproj.filters
+++ /dev/null
@@ -1,714 +0,0 @@
-
-
-
-
- {c09c2d1c-85fb-4081-8235-925b45ed3c4b}
-
-
- {B78747A9-11C2-4784-B825-D48FD388FE2F}
-
-
- {a59636b8-d046-46b7-992b-76572ca72bd1}
-
-
- {7c989f53-480b-42d4-a2dc-454adafda818}
-
-
- {444ab8c6-6b83-4a5b-9059-67f469da1331}
-
-
- {a49a9cc3-6a37-48a6-8049-b10c9cecd193}
-
-
- {50a39acc-fab6-4e2a-85b7-d764be5299f5}
-
-
- {9a61353a-8613-4496-9ee8-c3d2800c5ac6}
-
-
- {c14a7a3f-089f-47ee-80db-1caf1b47ab6b}
-
-
- {A0D2E990-DC5E-4B56-A552-888F97214A17}
-
-
- {F0DDA90-D13F-4B56-A552-328F97124A81}
-
-
- {b4905c15-9702-4ff0-8d57-e7926337d50f}
-
-
- {c2f72132-0df1-4dba-b24f-0ab683874538}
-
-
- {92f20ce7-8f87-4a1c-bc0b-d7fa3dfd3b60}
-
-
- {c618ddc9-5c66-485f-a0ff-ebabb3508568}
-
-
- {90294598-e94b-4c07-a531-93335a8955d9}
-
-
- {8f54e8b3-d8fb-4fed-88ce-42b39f171d0b}
-
-
- {0c76d116-0b4d-4fec-a0d8-5ca127913124}
-
-
- {702145f9-0e66-4e45-b3d4-d43f2cf17e10}
-
-
- {5ac96cb9-6257-4387-9238-27649915463a}
-
-
- {63a27d20-b039-46b4-aff9-63ace2010b9b}
-
-
- {2b66635d-fb09-421b-9942-8c43df5c8c77}
-
-
- {971969f2-f6ec-50b4-806a-97965c934cef}
-
-
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\api
-
-
- Source Files\coap
-
-
- Source Files\coap
-
-
- Source Files\coap
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\common
-
-
- Source Files\crypto
-
-
- Source Files\mac
-
-
- Source Files\mac
-
-
- Source Files\mac
-
-
- Source Files\mac
-
-
- Source Files\mac
-
-
- Source Files\mac
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\net
-
-
- Source Files\phy
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\net
-
-
- Source Files\meshcop
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\meshcop
-
-
- Source Files\crypto
-
-
- Source Files\crypto
-
-
- Source Files\crypto
-
-
- Source Files\crypto
-
-
- Source Files\utils
-
-
- Source Files\utils
-
-
- Source Files\utils
-
-
- Source Files\utils
-
-
- Source Files\thread
-
-
- Source Files\thread
-
-
- Source Files\meshcop
-
-
- Source Files\common
-
-
- Source Files\missing
-
-
- Source Files\missing
-
-
- Source Files\missing
-
-
-
-
- Header Files
-
-
- Header Files\coap
-
-
- Header Files\coap
-
-
- Header Files\coap
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\common
-
-
- Header Files\crypto
-
-
- Header Files\mac
-
-
- Header Files\mac
-
-
- Header Files\mac
-
-
- Header Files\mac
-
-
- Header Files\mac
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\net
-
-
- Header Files\phy
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\meshcop
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\meshcop
-
-
- Header Files\meshcop
-
-
- Header Files\meshcop
-
-
- Header Files\meshcop
-
-
- Header Files\meshcop
-
-
- Header Files\meshcop
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\crypto
-
-
- Header Files\crypto
-
-
- Header Files\crypto
-
-
- Header Files\crypto
-
-
- Header Files\crypto
-
-
- Header Files\utils
-
-
- Header Files\utils
-
-
- Header Files\utils
-
-
- Header Files\utils
-
-
- Header Files\thread
-
-
- Header Files\thread
-
-
- Header Files\meshcop
-
-
- Header Files\common
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\openthread
-
-
- Header Files\api
-
-
- Header Files\missing
-
-
- Header Files\missing
-
-
- Header Files\missing
-
-
-
diff --git a/etc/visual-studio/mbedtls.vcxproj b/etc/visual-studio/mbedtls.vcxproj
deleted file mode 100644
index 8b077cfd2..000000000
--- a/etc/visual-studio/mbedtls.vcxproj
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
-
- {4111C8BB-D354-4348-AD3C-EB6832E84831}
- Win32Proj
- mbedtls
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- StaticLibrary
- true
- v140
-
-
- StaticLibrary
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\lib\
-
-
-
-
- ;%(PreprocessorDefinitions);
- MBEDTLS_CONFIG_FILE="mbedtls-config.h";
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
-
-
- ..\..\include;
- ..\..\src\core;
- ..\..\third_party\mbedtls;
- ..\..\third_party\mbedtls\repo\include;
- ..\..\third_party\mbedtls\repo\include\mbedtls
-
- Level3
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/etc/visual-studio/mbedtls.vcxproj.filters b/etc/visual-studio/mbedtls.vcxproj.filters
deleted file mode 100644
index c03e1ab5d..000000000
--- a/etc/visual-studio/mbedtls.vcxproj.filters
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {0a2ce77e-dccf-408c-aea0-7a781284a936}
-
-
- {859819dc-e84e-4854-ad32-2819d60da38b}
-
-
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
-
diff --git a/etc/visual-studio/mbedtls_k.vcxproj b/etc/visual-studio/mbedtls_k.vcxproj
deleted file mode 100644
index a0cc2801e..000000000
--- a/etc/visual-studio/mbedtls_k.vcxproj
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}
- {8c0e3d8b-df43-455b-815a-4a0e72973bc6}
- v4.5
- 12.0
- Debug
- Win32
- ot
- KMDF
- Universal
-
-
- WindowsKernelModeDriver10.0
- StaticLibrary
-
-
-
- Windows10
- true
-
-
- Windows10
- false
-
-
-
-
-
-
-
- ..\..\build\bin\$(Platform)\$(Configuration)\lib\
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
-
-
-
-
- ..\..\include;
- ..\..\src\core;
- ..\..\third_party\mbedtls;
- ..\..\third_party\mbedtls\repo\include;
- ..\..\third_party\mbedtls\repo\include\mbedtls;
- ..\..\examples\drivers\windows\include_c99;
-
-
- %(PreprocessorDefinitions);
- MBEDTLS_CONFIG_FILE="mbedtls-config.h";
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- HAVE_STDBOOL_H=1;
- HAVE_STDINT_H=1;
-
- 4132;4242;4245;4603;4627;4986;4987;4996;%(DisableSpecificWarnings)
- Level3
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/etc/visual-studio/mbedtls_k.vcxproj.filters b/etc/visual-studio/mbedtls_k.vcxproj.filters
deleted file mode 100644
index 2ca617131..000000000
--- a/etc/visual-studio/mbedtls_k.vcxproj.filters
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {0a2ce77e-dccf-408c-aea0-7a781284a936}
-
-
- {87ec68b3-5bec-4c60-b764-c2daf3ffcfb2}
-
-
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
- Source Files\repo\library
-
-
-
diff --git a/etc/visual-studio/openthread.configuration.props b/etc/visual-studio/openthread.configuration.props
deleted file mode 100644
index 12a29dc1e..000000000
--- a/etc/visual-studio/openthread.configuration.props
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
- Debug
- ARM
-
-
- Release
- ARM
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/openthread.sln b/etc/visual-studio/openthread.sln
deleted file mode 100644
index 7b75be6c8..000000000
--- a/etc/visual-studio/openthread.sln
+++ /dev/null
@@ -1,383 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config files", "config files", "{53F4EEF6-B96D-4887-B9CF-CD21E8BECD15}"
- ProjectSection(SolutionItems) = preProject
- ..\..\.appveyor.yml = ..\..\.appveyor.yml
- ..\..\.codecov.yml = ..\..\.codecov.yml
- ..\..\.travis.yml = ..\..\.travis.yml
- EndProjectSection
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{76EA541E-CAB1-4DB5-A39F-E3DB2A78CDDD}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{95BD0669-04C8-4EEB-B3CC-0535B03F4468}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{35F6AB71-5BD2-4D53-8A51-D75CCD4CCC3D}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "third_party", "third_party", "{873E9D16-2A08-41FC-B301-79C95B3A8F98}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenthread", "libopenthread.vcxproj", "{DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenthread_k", "libopenthread_k.vcxproj", "{9B33C190-5D07-40BF-9536-68843DC5D7AF}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbedtls", "mbedtls.vcxproj", "{4111C8BB-D354-4348-AD3C-EB6832E84831}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mbedtls_k", "mbedtls_k.vcxproj", "{69BE8E8C-CF1E-46D6-932B-DB435F47059B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTests", "UnitTests.vcxproj", "{FD64BF17-8D36-4578-8D13-77B123BE30D3}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenthread-windows", "libopenthread-windows.vcxproj", "{30723C38-BA3B-44C9-8D64-C5861A26934F}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenthread-cli", "libopenthread-cli.vcxproj", "{41B32069-632E-4578-855B-A36EBFA80B56}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ot-cli", "ot-cli.vcxproj", "{91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenthread-ncp-spi", "libopenthread-ncp-spi.vcxproj", "{B92F449E-0FD9-44FC-ACFA-6521A3240CA2}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenthread-ncp-uart", "libopenthread-ncp-uart.vcxproj", "{D94867D2-6DAE-47E2-962A-5E8E658134D1}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ot-ncp-spi", "ot-ncp-spi.vcxproj", "{B4C744EC-B662-46C6-A076-FB58FA8FDF1B}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ot-ncp-uart", "ot-ncp-uart.vcxproj", "{9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "drivers", "drivers", "{61E8A4A0-8138-49DB-97B4-3BEC87C8E133}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otLwf", "otLwf.vcxproj", "{3F1F7F6C-2A33-4635-9880-08FC5BC4E435}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otApi", "otApi.vcxproj", "{ED0EA262-C222-42C7-98D3-E70C72978ED2}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenthread-cli-windows", "libopenthread-cli-windows.vcxproj", "{28834498-3837-44A5-8F67-249ABAB7B97D}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otCli", "otCli.vcxproj", "{CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "otNodeApi", "otNodeApi.vcxproj", "{B7C6F344-7287-4930-AF38-223622BD8CBB}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "otTestRunner", "otTestRunner.csproj", "{D5577E51-FA31-4802-8669-1DB32805935E}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "spinel_k", "spinel_k.vcxproj", "{A55766B5-58B6-4519-835E-5A4B7C164B5A}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ottmp", "ottmp.vcxproj", "{1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|ARM = Debug|ARM
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|ARM = Release|ARM
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Debug|ARM.ActiveCfg = Debug|ARM
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Debug|ARM.Build.0 = Debug|ARM
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Debug|x64.ActiveCfg = Debug|x64
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Debug|x64.Build.0 = Debug|x64
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Debug|x86.ActiveCfg = Debug|Win32
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Debug|x86.Build.0 = Debug|Win32
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Release|ARM.ActiveCfg = Release|ARM
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Release|ARM.Build.0 = Release|ARM
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Release|x64.ActiveCfg = Release|x64
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Release|x64.Build.0 = Release|x64
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Release|x86.ActiveCfg = Release|Win32
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40}.Release|x86.Build.0 = Release|Win32
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Debug|ARM.ActiveCfg = Debug|ARM
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Debug|ARM.Build.0 = Debug|ARM
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Debug|ARM.Deploy.0 = Debug|ARM
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Debug|x64.ActiveCfg = Debug|x64
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Debug|x64.Build.0 = Debug|x64
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Debug|x86.ActiveCfg = Debug|Win32
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Debug|x86.Build.0 = Debug|Win32
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Debug|x86.Deploy.0 = Debug|Win32
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Release|ARM.ActiveCfg = Release|ARM
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Release|ARM.Build.0 = Release|ARM
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Release|ARM.Deploy.0 = Release|ARM
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Release|x64.ActiveCfg = Release|x64
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Release|x64.Build.0 = Release|x64
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Release|x86.ActiveCfg = Release|Win32
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Release|x86.Build.0 = Release|Win32
- {9B33C190-5D07-40BF-9536-68843DC5D7AF}.Release|x86.Deploy.0 = Release|Win32
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Debug|ARM.ActiveCfg = Debug|ARM
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Debug|ARM.Build.0 = Debug|ARM
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Debug|x64.ActiveCfg = Debug|x64
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Debug|x64.Build.0 = Debug|x64
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Debug|x86.ActiveCfg = Debug|Win32
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Debug|x86.Build.0 = Debug|Win32
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Release|ARM.ActiveCfg = Release|ARM
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Release|ARM.Build.0 = Release|ARM
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Release|x64.ActiveCfg = Release|x64
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Release|x64.Build.0 = Release|x64
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Release|x86.ActiveCfg = Release|Win32
- {4111C8BB-D354-4348-AD3C-EB6832E84831}.Release|x86.Build.0 = Release|Win32
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Debug|ARM.ActiveCfg = Debug|ARM
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Debug|ARM.Build.0 = Debug|ARM
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Debug|ARM.Deploy.0 = Debug|ARM
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Debug|x64.ActiveCfg = Debug|x64
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Debug|x64.Build.0 = Debug|x64
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Debug|x86.ActiveCfg = Debug|Win32
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Debug|x86.Build.0 = Debug|Win32
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Debug|x86.Deploy.0 = Debug|Win32
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Release|ARM.ActiveCfg = Release|ARM
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Release|ARM.Build.0 = Release|ARM
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Release|ARM.Deploy.0 = Release|ARM
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Release|x64.ActiveCfg = Release|x64
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Release|x64.Build.0 = Release|x64
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Release|x86.ActiveCfg = Release|Win32
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Release|x86.Build.0 = Release|Win32
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B}.Release|x86.Deploy.0 = Release|Win32
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Debug|ARM.ActiveCfg = Debug|ARM
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Debug|ARM.Build.0 = Debug|ARM
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Debug|x64.ActiveCfg = Debug|x64
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Debug|x64.Build.0 = Debug|x64
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Debug|x86.ActiveCfg = Debug|Win32
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Debug|x86.Build.0 = Debug|Win32
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Release|ARM.ActiveCfg = Release|ARM
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Release|ARM.Build.0 = Release|ARM
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Release|x64.ActiveCfg = Release|x64
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Release|x64.Build.0 = Release|x64
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Release|x86.ActiveCfg = Release|Win32
- {FD64BF17-8D36-4578-8D13-77B123BE30D3}.Release|x86.Build.0 = Release|Win32
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Debug|ARM.ActiveCfg = Debug|ARM
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Debug|ARM.Build.0 = Debug|ARM
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Debug|x64.ActiveCfg = Debug|x64
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Debug|x64.Build.0 = Debug|x64
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Debug|x86.ActiveCfg = Debug|Win32
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Debug|x86.Build.0 = Debug|Win32
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Release|ARM.ActiveCfg = Release|ARM
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Release|ARM.Build.0 = Release|ARM
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Release|x64.ActiveCfg = Release|x64
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Release|x64.Build.0 = Release|x64
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Release|x86.ActiveCfg = Release|Win32
- {30723C38-BA3B-44C9-8D64-C5861A26934F}.Release|x86.Build.0 = Release|Win32
- {41B32069-632E-4578-855B-A36EBFA80B56}.Debug|ARM.ActiveCfg = Debug|ARM
- {41B32069-632E-4578-855B-A36EBFA80B56}.Debug|ARM.Build.0 = Debug|ARM
- {41B32069-632E-4578-855B-A36EBFA80B56}.Debug|x64.ActiveCfg = Debug|x64
- {41B32069-632E-4578-855B-A36EBFA80B56}.Debug|x64.Build.0 = Debug|x64
- {41B32069-632E-4578-855B-A36EBFA80B56}.Debug|x86.ActiveCfg = Debug|Win32
- {41B32069-632E-4578-855B-A36EBFA80B56}.Debug|x86.Build.0 = Debug|Win32
- {41B32069-632E-4578-855B-A36EBFA80B56}.Release|ARM.ActiveCfg = Release|ARM
- {41B32069-632E-4578-855B-A36EBFA80B56}.Release|ARM.Build.0 = Release|ARM
- {41B32069-632E-4578-855B-A36EBFA80B56}.Release|x64.ActiveCfg = Release|x64
- {41B32069-632E-4578-855B-A36EBFA80B56}.Release|x64.Build.0 = Release|x64
- {41B32069-632E-4578-855B-A36EBFA80B56}.Release|x86.ActiveCfg = Release|Win32
- {41B32069-632E-4578-855B-A36EBFA80B56}.Release|x86.Build.0 = Release|Win32
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Debug|ARM.ActiveCfg = Debug|ARM
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Debug|ARM.Build.0 = Debug|ARM
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Debug|x64.ActiveCfg = Debug|x64
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Debug|x64.Build.0 = Debug|x64
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Debug|x86.ActiveCfg = Debug|Win32
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Debug|x86.Build.0 = Debug|Win32
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Release|ARM.ActiveCfg = Release|ARM
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Release|ARM.Build.0 = Release|ARM
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Release|x64.ActiveCfg = Release|x64
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Release|x64.Build.0 = Release|x64
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Release|x86.ActiveCfg = Release|Win32
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}.Release|x86.Build.0 = Release|Win32
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Debug|ARM.ActiveCfg = Debug|ARM
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Debug|ARM.Build.0 = Debug|ARM
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Debug|x64.ActiveCfg = Debug|x64
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Debug|x64.Build.0 = Debug|x64
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Debug|x86.ActiveCfg = Debug|Win32
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Debug|x86.Build.0 = Debug|Win32
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Release|ARM.ActiveCfg = Release|ARM
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Release|ARM.Build.0 = Release|ARM
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Release|x64.ActiveCfg = Release|x64
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Release|x64.Build.0 = Release|x64
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Release|x86.ActiveCfg = Release|Win32
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2}.Release|x86.Build.0 = Release|Win32
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Debug|ARM.ActiveCfg = Debug|ARM
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Debug|ARM.Build.0 = Debug|ARM
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Debug|x64.ActiveCfg = Debug|x64
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Debug|x64.Build.0 = Debug|x64
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Debug|x86.ActiveCfg = Debug|Win32
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Debug|x86.Build.0 = Debug|Win32
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Release|ARM.ActiveCfg = Release|ARM
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Release|ARM.Build.0 = Release|ARM
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Release|x64.ActiveCfg = Release|x64
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Release|x64.Build.0 = Release|x64
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Release|x86.ActiveCfg = Release|Win32
- {D94867D2-6DAE-47E2-962A-5E8E658134D1}.Release|x86.Build.0 = Release|Win32
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Debug|ARM.ActiveCfg = Debug|ARM
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Debug|ARM.Build.0 = Debug|ARM
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Debug|x64.ActiveCfg = Debug|x64
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Debug|x64.Build.0 = Debug|x64
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Debug|x86.ActiveCfg = Debug|Win32
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Debug|x86.Build.0 = Debug|Win32
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Release|ARM.ActiveCfg = Release|ARM
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Release|ARM.Build.0 = Release|ARM
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Release|x64.ActiveCfg = Release|x64
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Release|x64.Build.0 = Release|x64
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Release|x86.ActiveCfg = Release|Win32
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}.Release|x86.Build.0 = Release|Win32
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Debug|ARM.ActiveCfg = Debug|ARM
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Debug|ARM.Build.0 = Debug|ARM
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Debug|x64.ActiveCfg = Debug|x64
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Debug|x64.Build.0 = Debug|x64
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Debug|x86.ActiveCfg = Debug|Win32
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Debug|x86.Build.0 = Debug|Win32
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Release|ARM.ActiveCfg = Release|ARM
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Release|ARM.Build.0 = Release|ARM
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Release|x64.ActiveCfg = Release|x64
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Release|x64.Build.0 = Release|x64
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Release|x86.ActiveCfg = Release|Win32
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}.Release|x86.Build.0 = Release|Win32
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Debug|ARM.ActiveCfg = Debug|ARM
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Debug|ARM.Build.0 = Debug|ARM
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Debug|ARM.Deploy.0 = Debug|ARM
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Debug|x64.ActiveCfg = Debug|x64
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Debug|x64.Build.0 = Debug|x64
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Debug|x64.Deploy.0 = Debug|x64
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Debug|x86.ActiveCfg = Debug|Win32
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Debug|x86.Build.0 = Debug|Win32
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Debug|x86.Deploy.0 = Debug|Win32
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Release|ARM.ActiveCfg = Release|ARM
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Release|ARM.Build.0 = Release|ARM
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Release|ARM.Deploy.0 = Release|ARM
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Release|x64.ActiveCfg = Release|x64
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Release|x64.Build.0 = Release|x64
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Release|x64.Deploy.0 = Release|x64
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Release|x86.ActiveCfg = Release|Win32
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Release|x86.Build.0 = Release|Win32
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}.Release|x86.Deploy.0 = Release|Win32
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Debug|ARM.ActiveCfg = Debug|ARM
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Debug|ARM.Build.0 = Debug|ARM
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Debug|x64.ActiveCfg = Debug|x64
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Debug|x64.Build.0 = Debug|x64
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Debug|x86.ActiveCfg = Debug|Win32
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Debug|x86.Build.0 = Debug|Win32
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Release|ARM.ActiveCfg = Release|ARM
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Release|ARM.Build.0 = Release|ARM
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Release|x64.ActiveCfg = Release|x64
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Release|x64.Build.0 = Release|x64
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Release|x86.ActiveCfg = Release|Win32
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}.Release|x86.Build.0 = Release|Win32
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Debug|ARM.ActiveCfg = Debug|ARM
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Debug|ARM.Build.0 = Debug|ARM
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Debug|x64.ActiveCfg = Debug|x64
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Debug|x64.Build.0 = Debug|x64
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Debug|x86.ActiveCfg = Debug|Win32
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Debug|x86.Build.0 = Debug|Win32
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Release|ARM.ActiveCfg = Release|ARM
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Release|ARM.Build.0 = Release|ARM
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Release|x64.ActiveCfg = Release|x64
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Release|x64.Build.0 = Release|x64
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Release|x86.ActiveCfg = Release|Win32
- {28834498-3837-44A5-8F67-249ABAB7B97D}.Release|x86.Build.0 = Release|Win32
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Debug|ARM.ActiveCfg = Debug|ARM
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Debug|ARM.Build.0 = Debug|ARM
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Debug|x64.ActiveCfg = Debug|x64
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Debug|x64.Build.0 = Debug|x64
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Debug|x86.ActiveCfg = Debug|Win32
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Debug|x86.Build.0 = Debug|Win32
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Release|ARM.ActiveCfg = Release|ARM
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Release|ARM.Build.0 = Release|ARM
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Release|x64.ActiveCfg = Release|x64
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Release|x64.Build.0 = Release|x64
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Release|x86.ActiveCfg = Release|Win32
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}.Release|x86.Build.0 = Release|Win32
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Debug|ARM.ActiveCfg = Debug|ARM
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Debug|ARM.Build.0 = Debug|ARM
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Debug|x64.ActiveCfg = Debug|x64
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Debug|x64.Build.0 = Debug|x64
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Debug|x86.ActiveCfg = Debug|Win32
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Debug|x86.Build.0 = Debug|Win32
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Release|ARM.ActiveCfg = Release|ARM
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Release|ARM.Build.0 = Release|ARM
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Release|x64.ActiveCfg = Release|x64
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Release|x64.Build.0 = Release|x64
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Release|x86.ActiveCfg = Release|Win32
- {B7C6F344-7287-4930-AF38-223622BD8CBB}.Release|x86.Build.0 = Release|Win32
- {D5577E51-FA31-4802-8669-1DB32805935E}.Debug|ARM.ActiveCfg = Debug|Any CPU
- {D5577E51-FA31-4802-8669-1DB32805935E}.Debug|ARM.Build.0 = Debug|Any CPU
- {D5577E51-FA31-4802-8669-1DB32805935E}.Debug|x64.ActiveCfg = Debug|x64
- {D5577E51-FA31-4802-8669-1DB32805935E}.Debug|x64.Build.0 = Debug|x64
- {D5577E51-FA31-4802-8669-1DB32805935E}.Debug|x86.ActiveCfg = Debug|Win32
- {D5577E51-FA31-4802-8669-1DB32805935E}.Debug|x86.Build.0 = Debug|Win32
- {D5577E51-FA31-4802-8669-1DB32805935E}.Release|ARM.ActiveCfg = Release|Any CPU
- {D5577E51-FA31-4802-8669-1DB32805935E}.Release|ARM.Build.0 = Release|Any CPU
- {D5577E51-FA31-4802-8669-1DB32805935E}.Release|x64.ActiveCfg = Release|x64
- {D5577E51-FA31-4802-8669-1DB32805935E}.Release|x64.Build.0 = Release|x64
- {D5577E51-FA31-4802-8669-1DB32805935E}.Release|x86.ActiveCfg = Release|Win32
- {D5577E51-FA31-4802-8669-1DB32805935E}.Release|x86.Build.0 = Release|Win32
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Debug|ARM.ActiveCfg = Debug|ARM
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Debug|ARM.Build.0 = Debug|ARM
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Debug|ARM.Deploy.0 = Debug|ARM
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Debug|x64.ActiveCfg = Debug|x64
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Debug|x64.Build.0 = Debug|x64
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Debug|x64.Deploy.0 = Debug|x64
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Debug|x86.ActiveCfg = Debug|Win32
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Debug|x86.Build.0 = Debug|Win32
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Debug|x86.Deploy.0 = Debug|Win32
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Release|ARM.ActiveCfg = Release|ARM
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Release|ARM.Build.0 = Release|ARM
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Release|ARM.Deploy.0 = Release|ARM
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Release|x64.ActiveCfg = Release|x64
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Release|x64.Build.0 = Release|x64
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Release|x64.Deploy.0 = Release|x64
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Release|x86.ActiveCfg = Release|Win32
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Release|x86.Build.0 = Release|Win32
- {F8C22844-9B93-4978-80DF-8AF2B37A7ABB}.Release|x86.Deploy.0 = Release|Win32
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Debug|ARM.ActiveCfg = Debug|ARM
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Debug|ARM.Build.0 = Debug|ARM
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Debug|ARM.Deploy.0 = Debug|ARM
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Debug|x64.ActiveCfg = Debug|x64
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Debug|x64.Build.0 = Debug|x64
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Debug|x64.Deploy.0 = Debug|x64
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Debug|x86.ActiveCfg = Debug|Win32
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Debug|x86.Build.0 = Debug|Win32
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Debug|x86.Deploy.0 = Debug|Win32
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Release|ARM.ActiveCfg = Release|ARM
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Release|ARM.Build.0 = Release|ARM
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Release|ARM.Deploy.0 = Release|ARM
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Release|x64.ActiveCfg = Release|x64
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Release|x64.Build.0 = Release|x64
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Release|x64.Deploy.0 = Release|x64
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Release|x86.ActiveCfg = Release|Win32
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Release|x86.Build.0 = Release|Win32
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}.Release|x86.Deploy.0 = Release|Win32
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Debug|ARM.ActiveCfg = Debug|ARM
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Debug|ARM.Build.0 = Debug|ARM
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Debug|ARM.Deploy.0 = Debug|ARM
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Debug|x64.ActiveCfg = Debug|x64
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Debug|x64.Build.0 = Debug|x64
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Debug|x64.Deploy.0 = Debug|x64
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Debug|x86.ActiveCfg = Debug|Win32
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Debug|x86.Build.0 = Debug|Win32
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Debug|x86.Deploy.0 = Debug|Win32
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Release|ARM.ActiveCfg = Release|ARM
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Release|ARM.Build.0 = Release|ARM
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Release|ARM.Deploy.0 = Release|ARM
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Release|x64.ActiveCfg = Release|x64
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Release|x64.Build.0 = Release|x64
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Release|x64.Deploy.0 = Release|x64
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Release|x86.ActiveCfg = Release|Win32
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Release|x86.Build.0 = Release|Win32
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}.Release|x86.Deploy.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {DD5018BE-54C6-4FD4-9F8D-08D52FC0CD40} = {95BD0669-04C8-4EEB-B3CC-0535B03F4468}
- {9B33C190-5D07-40BF-9536-68843DC5D7AF} = {95BD0669-04C8-4EEB-B3CC-0535B03F4468}
- {4111C8BB-D354-4348-AD3C-EB6832E84831} = {873E9D16-2A08-41FC-B301-79C95B3A8F98}
- {69BE8E8C-CF1E-46D6-932B-DB435F47059B} = {873E9D16-2A08-41FC-B301-79C95B3A8F98}
- {FD64BF17-8D36-4578-8D13-77B123BE30D3} = {35F6AB71-5BD2-4D53-8A51-D75CCD4CCC3D}
- {30723C38-BA3B-44C9-8D64-C5861A26934F} = {76EA541E-CAB1-4DB5-A39F-E3DB2A78CDDD}
- {41B32069-632E-4578-855B-A36EBFA80B56} = {95BD0669-04C8-4EEB-B3CC-0535B03F4468}
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF} = {76EA541E-CAB1-4DB5-A39F-E3DB2A78CDDD}
- {B92F449E-0FD9-44FC-ACFA-6521A3240CA2} = {95BD0669-04C8-4EEB-B3CC-0535B03F4468}
- {D94867D2-6DAE-47E2-962A-5E8E658134D1} = {95BD0669-04C8-4EEB-B3CC-0535B03F4468}
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B} = {76EA541E-CAB1-4DB5-A39F-E3DB2A78CDDD}
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324} = {76EA541E-CAB1-4DB5-A39F-E3DB2A78CDDD}
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435} = {61E8A4A0-8138-49DB-97B4-3BEC87C8E133}
- {ED0EA262-C222-42C7-98D3-E70C72978ED2} = {61E8A4A0-8138-49DB-97B4-3BEC87C8E133}
- {28834498-3837-44A5-8F67-249ABAB7B97D} = {95BD0669-04C8-4EEB-B3CC-0535B03F4468}
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB} = {61E8A4A0-8138-49DB-97B4-3BEC87C8E133}
- {B7C6F344-7287-4930-AF38-223622BD8CBB} = {61E8A4A0-8138-49DB-97B4-3BEC87C8E133}
- {D5577E51-FA31-4802-8669-1DB32805935E} = {35F6AB71-5BD2-4D53-8A51-D75CCD4CCC3D}
- {A55766B5-58B6-4519-835E-5A4B7C164B5A} = {95BD0669-04C8-4EEB-B3CC-0535B03F4468}
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D} = {61E8A4A0-8138-49DB-97B4-3BEC87C8E133}
- EndGlobalSection
-EndGlobal
diff --git a/etc/visual-studio/ot-cli.vcxproj b/etc/visual-studio/ot-cli.vcxproj
deleted file mode 100644
index 6d669f422..000000000
--- a/etc/visual-studio/ot-cli.vcxproj
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
- {91D3ADEA-F1FE-4433-95B6-F8F6A7CF7BAF}
- Win32Proj
- ot
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- Application
- true
- v140
-
-
- Application
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\exe\
-
-
-
-
- %(PreprocessorDefinitions);
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_FTD=1;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\examples\platforms;
- ..\..\include;
- ..\..\src\core;
-
- Level3
- true
-
-
- Console
-
- mincore.lib;
-
-
-
-
-
- {41b32069-632e-4578-855b-a36ebfa80b56}
-
-
- {dd5018be-54c6-4fd4-9f8d-08d52fc0cd40}
-
-
- {4111c8bb-d354-4348-ad3c-eb6832e84831}
-
-
- {30723c38-ba3b-44c9-8d64-c5861a26934f}
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/ot-cli.vcxproj.filters b/etc/visual-studio/ot-cli.vcxproj.filters
deleted file mode 100644
index 5d735b3db..000000000
--- a/etc/visual-studio/ot-cli.vcxproj.filters
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/ot-ncp-spi.vcxproj b/etc/visual-studio/ot-ncp-spi.vcxproj
deleted file mode 100644
index af117a4bb..000000000
--- a/etc/visual-studio/ot-ncp-spi.vcxproj
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
- {B4C744EC-B662-46C6-A076-FB58FA8FDF1B}
- Win32Proj
- ot
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- Application
- true
- v140
-
-
- Application
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\exe\
-
-
-
-
- %(PreprocessorDefinitions);
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_FTD=1;
- OPENTHREAD_ENABLE_NCP_SPI=1;
- OPENTHREAD_ENABLE_NCP_UART=0;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\examples\platforms;
- ..\..\include;
- ..\..\src\core;
-
- true
- Level3
-
-
- Console
-
- mincore.lib;
-
-
-
-
-
-
-
-
- {dd5018be-54c6-4fd4-9f8d-08d52fc0cd40}
-
-
- {b92f449e-0fd9-44fc-acfa-6521a3240ca2}
-
-
- {4111c8bb-d354-4348-ad3c-eb6832e84831}
-
-
- {30723c38-ba3b-44c9-8d64-c5861a26934f}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/ot-ncp-spi.vcxproj.filters b/etc/visual-studio/ot-ncp-spi.vcxproj.filters
deleted file mode 100644
index 3cfd287ac..000000000
--- a/etc/visual-studio/ot-ncp-spi.vcxproj.filters
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/ot-ncp-uart.vcxproj b/etc/visual-studio/ot-ncp-uart.vcxproj
deleted file mode 100644
index e000631c9..000000000
--- a/etc/visual-studio/ot-ncp-uart.vcxproj
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-
- {9EEF9DCD-EA8F-4154-BD02-AB2B31CEC324}
- Win32Proj
- ot
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- Application
- true
- v140
-
-
- Application
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\exe\
-
-
-
-
- %(PreprocessorDefinitions);
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_FTD=1;
- OPENTHREAD_ENABLE_NCP_SPI=0;
- OPENTHREAD_ENABLE_NCP_UART=1;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\examples\platforms;
- ..\..\include;
- ..\..\src\core;
-
- true
- Level3
-
-
- Console
-
- mincore.lib;
-
-
-
-
-
-
-
-
- {dd5018be-54c6-4fd4-9f8d-08d52fc0cd40}
-
-
- {d94867d2-6dae-47e2-962a-5e8e658134d1}
-
-
- {4111c8bb-d354-4348-ad3c-eb6832e84831}
-
-
- {30723c38-ba3b-44c9-8d64-c5861a26934f}
-
-
-
-
-
-
diff --git a/etc/visual-studio/ot-ncp-uart.vcxproj.filters b/etc/visual-studio/ot-ncp-uart.vcxproj.filters
deleted file mode 100644
index 3cfd287ac..000000000
--- a/etc/visual-studio/ot-ncp-uart.vcxproj.filters
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/otApi.vcxproj b/etc/visual-studio/otApi.vcxproj
deleted file mode 100644
index 4430c57d1..000000000
--- a/etc/visual-studio/otApi.vcxproj
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
- {ED0EA262-C222-42C7-98D3-E70C72978ED2}
- Win32Proj
- ot
- 12.0
- Universal
-
-
-
- DynamicLibrary
- true
- WindowsApplicationForDrivers10.0
-
-
- DynamicLibrary
- false
- WindowsApplicationForDrivers10.0
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\dll\
- C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\NativeRecommendedRules.ruleset
- true
- false
-
-
-
- Level3
-
- %(PreprocessorDefinitions);
- OPENTHREAD_FTD=1;
- OTAPI_EXPORTS;
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
-
- true
-
- %(AdditionalIncludeDirectories);
- ..\..\examples\drivers\windows\include;
- ..\..\examples\drivers\windows\otApi;
- ..\..\include;
-
- true
- ..\..\include\openthread\platform\logging-windows.h
- otApi
- true
- Sync
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/etc/visual-studio/otApi.vcxproj.filters b/etc/visual-studio/otApi.vcxproj.filters
deleted file mode 100644
index ce2de0616..000000000
--- a/etc/visual-studio/otApi.vcxproj.filters
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Header Files
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/otCli.vcxproj b/etc/visual-studio/otCli.vcxproj
deleted file mode 100644
index 327e779c2..000000000
--- a/etc/visual-studio/otCli.vcxproj
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
- {CAC8A00E-C6C8-4CF0-BA5A-C9A9A601C6DB}
- Win32Proj
- ot
- Windows Store
- 14.0
- 10.0.10586.0
- 10.0.10240.0
- 10.0
-
-
-
- Application
- true
- v140
-
-
- Application
- false
- v140
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\exe\
-
-
-
-
- %(PreprocessorDefinitions);
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_FTD=1;
- OTDLL;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\include;
-
- Level3
- true
-
-
- Console
-
-
-
-
-
-
-
- {28834498-3837-44a5-8f67-249abab7b97d}
-
-
- {ed0ea262-c222-42c7-98d3-e70c72978ed2}
-
-
-
-
-
-
diff --git a/etc/visual-studio/otCli.vcxproj.filters b/etc/visual-studio/otCli.vcxproj.filters
deleted file mode 100644
index 203d16a0d..000000000
--- a/etc/visual-studio/otCli.vcxproj.filters
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/otLwf.vcxproj b/etc/visual-studio/otLwf.vcxproj
deleted file mode 100644
index 46af170f8..000000000
--- a/etc/visual-studio/otLwf.vcxproj
+++ /dev/null
@@ -1,134 +0,0 @@
-
-
-
-
- {3F1F7F6C-2A33-4635-9880-08FC5BC4E435}
- {8b1800b9-d017-4029-9785-13ef5e5b328e}
- v4.5
- 12.0
- ot
- KMDF
- Universal
-
-
- WindowsKernelModeDriver10.0
- Driver
-
-
-
- Windows10
- true
-
-
- Windows10
- false
-
-
-
-
-
-
-
- ..\..\build\bin\$(Platform)\$(Configuration)\sys\
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- AllRules.ruleset
- true
-
-
-
-
- %(PreProcessorDefinitions);
- NDIS_WDM=1;
- NDIS630=1;
- OPENTHREAD_FTD=1;
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-windows-config.h";
-
-
- %(AdditionalIncludeDirectories);
- ..\..\include;
- ..\..\examples\drivers\windows\include;
- ..\..\examples\drivers\windows\include_c99;
- ..\..\examples\drivers\windows\otLwf;
- ..\..\src;
- ..\..\src\core;
-
- Level4
- true
- %(DisableSpecificWarnings);4201;4214
- precomp.h
- Use
- true
- ..\..\include\openthread\platform\logging-windows.h
- -km %(WppAdditionalOptions)
- otLwf
- WPP_INIT_TRACING
- true
-
-
- %(AdditionalIncludeDirectories);..;.;
-
-
-
- %(AdditionalDependencies);
- ndis.lib;
- wdmsec.lib;
- netio.lib;
- uuid.lib;
- cng.lib;
-
-
-
- inf2cat /driver:$(TargetDir) /os:8_ARM
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ..;.;%(AdditionalIncludeDirectories)
- %(PreProcessorDefinitions);NDIS_WDM=1
- precomp.h
- Create
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {9b33c190-5d07-40bf-9536-68843dc5d7af}
-
-
- {69be8e8c-cf1e-46d6-932b-db435f47059b}
-
-
- {a55766b5-58b6-4519-835e-5a4b7c164b5a}
-
-
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/otLwf.vcxproj.filters b/etc/visual-studio/otLwf.vcxproj.filters
deleted file mode 100644
index 8b540e324..000000000
--- a/etc/visual-studio/otLwf.vcxproj.filters
+++ /dev/null
@@ -1,107 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
- {8E41214B-6785-4CFE-B992-037D68949A14}
- inf;inv;inx;mof;mc;
-
-
-
-
- Driver Files
-
-
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Resource Files
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/otNodeApi.vcxproj b/etc/visual-studio/otNodeApi.vcxproj
deleted file mode 100644
index dc06757e7..000000000
--- a/etc/visual-studio/otNodeApi.vcxproj
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
-
- {B7C6F344-7287-4930-AF38-223622BD8CBB}
- Win32Proj
- ot
- 12.0
- Universal
-
-
-
- DynamicLibrary
- true
- WindowsApplicationForDrivers10.0
-
-
- DynamicLibrary
- false
- WindowsApplicationForDrivers10.0
- true
-
-
-
-
-
-
-
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- ..\..\build\bin\$(Platform)\$(Configuration)\dll\
- true
- false
-
-
-
-
- %(PreprocessorDefinitions);
- OPENTHREAD_FTD=1;
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OTAPI_EXPORTS;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\examples\drivers\windows\include;
- ..\..\examples\drivers\windows\otApi;
- ..\..\include;
-
- Level3
- true
- true
- ..\..\include\openthread\platform\logging-windows.h
- otNodeApi
- true
- Sync
-
-
-
- ntdll.lib;
-
-
-
-
-
-
-
-
-
-
-
-
- {ed0ea262-c222-42c7-98d3-e70c72978ed2}
-
-
-
-
-
-
diff --git a/etc/visual-studio/otNodeApi.vcxproj.filters b/etc/visual-studio/otNodeApi.vcxproj.filters
deleted file mode 100644
index 8e527aeea..000000000
--- a/etc/visual-studio/otNodeApi.vcxproj.filters
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
- Source Files
-
-
-
-
- Header Files
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/otTestRunner.csproj b/etc/visual-studio/otTestRunner.csproj
deleted file mode 100644
index 958403786..000000000
--- a/etc/visual-studio/otTestRunner.csproj
+++ /dev/null
@@ -1,112 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {D5577E51-FA31-4802-8669-1DB32805935E}
- Exe
- Properties
- otTestRunner
- otTestRunner
- v4.5.2
- 512
- true
-
-
- AnyCPU
- true
- full
- false
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\bin\$(Platform)\$(Configuration)\exe\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\bin\$(Platform)\$(Configuration)\exe\
- TRACE
- prompt
- 4
-
-
- true
- DEBUG;TRACE
- full
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\bin\$(Platform)\$(Configuration)\exe\
- x64
- prompt
- MinimumRecommendedRules.ruleset
- true
-
-
- TRACE
- true
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\bin\$(Platform)\$(Configuration)\exe\
- pdbonly
- x64
- prompt
- MinimumRecommendedRules.ruleset
- true
-
-
- true
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\bin\$(Platform)\$(Configuration)\exe\
- DEBUG;TRACE
- full
- x86
- prompt
- MinimumRecommendedRules.ruleset
- true
-
-
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\obj\$(Platform)\$(Configuration)\otTestRunner\
- ..\..\build\bin\$(Platform)\$(Configuration)\exe\
- TRACE
- true
- pdbonly
- x86
- prompt
- MinimumRecommendedRules.ruleset
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/ottmp.vcxproj b/etc/visual-studio/ottmp.vcxproj
deleted file mode 100644
index 96a5e5596..000000000
--- a/etc/visual-studio/ottmp.vcxproj
+++ /dev/null
@@ -1,102 +0,0 @@
-
-
-
-
- {1EAFF7C8-8215-4EDA-83B2-EEB56CECE84D}
- {497e31cb-056b-4f31-abb8-447fd55ee5a5}
- v4.5
- 12.0
- ot
- Windows10
- WindowsKernelModeDriver10.0
- Driver
- KMDF
- Universal
-
-
-
- true
-
-
- false
-
-
-
-
-
-
-
- ..\..\build\bin\$(Platform)\$(Configuration)\sys\
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
- AllRules.ruleset
- true
-
-
-
-
- %(PreProcessorDefinitions);
- NDIS_MINIPORT_DRIVER=1;
- NDIS_WDM=1;
- NDIS650_MINIPORT=1;
- OTTMP_LEGACY=1;
-
-
- %(AdditionalIncludeDirectories);
- ..\..\include;
- ..\..\examples\drivers\windows\include;
- ..\..\examples\drivers\windows\ottmp;
-
- Level4
- true
- %(DisableSpecificWarnings);4200;4201;4214
- true
- ..\..\include\openthread\platform\logging-windows.h
- -km %(WppAdditionalOptions)
- ottmp
- WPP_INIT_TRACING
- true
-
-
-
- %(PreProcessorDefinitions);
- NDIS_MINIPORT_DRIVER=1;
- NDIS_WDM=1;
- NDIS650_MINIPORT=1;
- OTTMP_LEGACY=1;
-
- %(AdditionalIncludeDirectories);..;.;
-
-
-
- %(AdditionalDependencies);
- ndis.lib;
-
-
-
- inf2cat /driver:$(TargetDir) /os:8_ARM
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/ottmp.vcxproj.filters b/etc/visual-studio/ottmp.vcxproj.filters
deleted file mode 100644
index 64ba1d03c..000000000
--- a/etc/visual-studio/ottmp.vcxproj.filters
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
- {BED10704-BFDA-427C-BB01-B08F20AB1718}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {A6C61B28-961C-4B63-892B-A7E5EB2A4B3E}
- h;hpp;hxx;hm;inl;inc;xsd
-
-
- {0CBFC63C-11CB-4E5F-95F1-187BE3F6DA44}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
- {6C2BAFD4-E244-4FF2-A002-FBCCF14AFA9D}
- inf;inv;inx;mof;mc;
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/spinel_k.vcxproj b/etc/visual-studio/spinel_k.vcxproj
deleted file mode 100644
index ed09929a4..000000000
--- a/etc/visual-studio/spinel_k.vcxproj
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
-
- {A55766B5-58B6-4519-835E-5A4B7C164B5A}
- {8c0e3d8b-df43-455b-815a-4a0e72973bc6}
- v4.5
- 12.0
- Debug
- Win32
- ot
- KMDF
- Universal
-
-
- WindowsKernelModeDriver10.0
- StaticLibrary
-
-
-
- Windows10
- true
-
-
- Windows10
- false
-
-
-
-
-
-
-
- ..\..\build\bin\$(Platform)\$(Configuration)\lib\
- ..\..\build\obj\$(Platform)\$(Configuration)\$(ProjectName)\
-
-
-
-
- %(PreprocessorDefinitions);
- HAVE_STRNLEN=1;
- OPENTHREAD_FTD=1;
- HAVE_STDBOOL_H=1;
- HAVE_STDINT_H=1;
- SPINEL_PLATFORM_DOESNT_IMPLEMENT_ERRNO_VAR=1;
- OPENTHREAD_CONFIG_FILE="openthread-windows-config.h";
- OPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-windows-config.h";
-
-
- %(AdditionalIncludeDirectories);
- ..\..\include;
- ..\..\src\core;
- ..\..\examples\drivers\windows\include_c99;
-
- 4100;4706;4748;%(DisableSpecificWarnings)
- true
- true
- ..\..\include\openthread\platform\logging-windows.h
- -km %(WppAdditionalOptions)
- otCore
- WPP_INIT_TRACING
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/etc/visual-studio/spinel_k.vcxproj.filters b/etc/visual-studio/spinel_k.vcxproj.filters
deleted file mode 100644
index 24312b902..000000000
--- a/etc/visual-studio/spinel_k.vcxproj.filters
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
- {C034F7F4-3CBD-4B9A-A033-0D76A195B581}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {7A95885E-AD23-439A-B283-9BDE0E39D84E}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {1E1DF93E-9746-4688-A1F0-7B59378CF28F}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Source Files
-
-
-
-
- Header Files
-
-
-
\ No newline at end of file
diff --git a/examples/Makefile.am b/examples/Makefile.am
index cee5b62c1..d25b86c07 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -35,10 +35,6 @@ DIST_SUBDIRS = \
apps \
$(NULL)
-EXTRA_DIST = \
- drivers \
- $(NULL)
-
# Always build (e.g. for 'make all') these subdirectories.
SUBDIRS = \
diff --git a/examples/apps/windows/App.xaml b/examples/apps/windows/App.xaml
deleted file mode 100644
index 10b02c406..000000000
--- a/examples/apps/windows/App.xaml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
diff --git a/examples/apps/windows/App.xaml.cpp b/examples/apps/windows/App.xaml.cpp
deleted file mode 100644
index cf33b5432..000000000
--- a/examples/apps/windows/App.xaml.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.h"
-#include "MainPage.xaml.h"
-
-using namespace ot;
-
-using namespace Platform;
-using namespace Windows::ApplicationModel;
-using namespace Windows::ApplicationModel::Activation;
-using namespace Windows::Foundation;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::UI::Xaml;
-using namespace Windows::UI::Xaml::Controls;
-using namespace Windows::UI::Xaml::Controls::Primitives;
-using namespace Windows::UI::Xaml::Data;
-using namespace Windows::UI::Xaml::Input;
-using namespace Windows::UI::Xaml::Interop;
-using namespace Windows::UI::Xaml::Media;
-using namespace Windows::UI::Xaml::Navigation;
-
-///
-/// Initializes the singleton application object. This is the first line of authored code
-/// executed, and as such is the logical equivalent of main() or WinMain().
-///
-App::App()
-{
- InitializeComponent();
- Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
-}
-
-///
-/// Invoked when the application is launched normally by the end user. Other entry points
-/// will be used such as when the application is launched to open a specific file.
-///
-/// Details about the launch request and process.
-void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e)
-{
-#if _DEBUG
- // Show graphics profiling information while debugging.
- if (IsDebuggerPresent())
- {
- // Display the current frame rate counters
- DebugSettings->EnableFrameRateCounter = true;
- }
-#endif
- auto rootFrame = dynamic_cast(Window::Current->Content);
-
- // Do not repeat app initialization when the Window already has content,
- // just ensure that the window is active
- if (rootFrame == nullptr)
- {
- // Create a Frame to act as the navigation context and associate it with
- // a SuspensionManager key
- rootFrame = ref new Frame();
-
- rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed);
-
- if (e->PreviousExecutionState == ApplicationExecutionState::Terminated)
- {
- // TODO: Restore the saved session state only when appropriate, scheduling the
- // final launch steps after the restore is complete
- }
-
- if (e->PrelaunchActivated == false)
- {
- if (rootFrame->Content == nullptr)
- {
- // When the navigation stack isn't restored navigate to the first page,
- // configuring the new page by passing required information as a navigation
- // parameter
- rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments);
- }
- // Place the frame in the current Window
- Window::Current->Content = rootFrame;
- // Ensure the current window is active
- Window::Current->Activate();
- }
- }
- else
- {
- if (e->PrelaunchActivated == false)
- {
- if (rootFrame->Content == nullptr)
- {
- // When the navigation stack isn't restored navigate to the first page,
- // configuring the new page by passing required information as a navigation
- // parameter
- rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments);
- }
- // Ensure the current window is active
- Window::Current->Activate();
- }
- }
-}
-
-///
-/// Invoked when application execution is being suspended. Application state is saved
-/// without knowing whether the application will be terminated or resumed with the contents
-/// of memory still intact.
-///
-/// The source of the suspend request.
-/// Details about the suspend request.
-void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
-{
- (void) sender; // Unused parameter
- (void) e; // Unused parameter
-
- //TODO: Save application state and stop any background activity
-}
-
-///
-/// Invoked when Navigation to a certain page fails
-///
-/// The Frame which failed navigation
-/// Details about the navigation failure
-void App::OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e)
-{
- throw ref new FailureException("Failed to load Page " + e->SourcePageType.Name);
-}
diff --git a/examples/apps/windows/App.xaml.h b/examples/apps/windows/App.xaml.h
deleted file mode 100644
index 0449c8953..000000000
--- a/examples/apps/windows/App.xaml.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#include "App.g.h"
-
-namespace ot
-{
- ///
- /// Provides application-specific behavior to supplement the default Application class.
- ///
- ref class App sealed
- {
- protected:
- virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override;
-
- internal:
- App();
-
- private:
- void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e);
- void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e);
- };
-}
diff --git a/examples/apps/windows/ClientArgs.h b/examples/apps/windows/ClientArgs.h
deleted file mode 100644
index 3943a11b2..000000000
--- a/examples/apps/windows/ClientArgs.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-namespace ot
-{
-
-public ref class ClientArgs sealed
-{
-public:
- property Windows::Networking::HostName^ ServerHostName;
- property Platform::String^ ServerPort;
- property Windows::Networking::HostName^ ClientHostName;
- property Platform::String^ ClientPort;
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/ClientControl.xaml b/examples/apps/windows/ClientControl.xaml
deleted file mode 100644
index 4f00fbbb2..000000000
--- a/examples/apps/windows/ClientControl.xaml
+++ /dev/null
@@ -1,142 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/apps/windows/ClientControl.xaml.cpp b/examples/apps/windows/ClientControl.xaml.cpp
deleted file mode 100644
index cc8f40bf7..000000000
--- a/examples/apps/windows/ClientControl.xaml.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.h"
-#include
-#include
-#include "ClientControl.xaml.h"
-#include "Factory.h"
-#include "TalkHelper.h"
-
-using namespace ot;
-
-using namespace Concurrency;
-using namespace Platform;
-using namespace Windows::ApplicationModel::Core;
-using namespace Windows::Foundation;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::UI;
-using namespace Windows::UI::Xaml;
-using namespace Windows::UI::Xaml::Controls;
-using namespace Windows::UI::Xaml::Controls::Primitives;
-using namespace Windows::UI::Xaml::Data;
-using namespace Windows::UI::Xaml::Input;
-using namespace Windows::UI::Xaml::Media;
-using namespace Windows::UI::Xaml::Navigation;
-
-// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
-
-std::atomic ClientControl::_clientPort{ TalkConsts::DEF_CLIENT_PORT_INIT };
-
-ClientControl::ClientControl()
-{
- InitializeComponent();
-
- ServerPort->Text = DEF_SERVER_PORT.ToString();
- auto clientPort = _clientPort.load();
- ClientPort->Text = clientPort.ToString();
-}
-
-void
-ClientControl::Init(
- IAsyncThreadNotify^ notify,
- IMainPageUIElements^ mainPageUIElements)
-{
- _notify = std::move(notify);
- _mainPageUIElements = std::move(mainPageUIElements);
-}
-
-void
-ClientControl::ProtocolChanged(
- Protocol protocol)
-{
- _protocol = protocol;
-}
-
-void
-ClientControl::Connect_Click(
- Object^ sender,
- RoutedEventArgs^ e)
-{
- try
- {
- auto clientArgs = ref new ClientArgs();
-
- auto serverIP = ServerIP->Text;
- if (serverIP->IsEmpty())
- {
- throw Exception::CreateException(E_INVALIDARG, "No Server IP");
- }
-
- // check valid chars of Ipv6 Address
- if (!TalkHelper::AllValidIpv6Chars(serverIP->Data(), serverIP->Data() + serverIP->Length()))
- {
- throw Exception::CreateException(E_INVALIDARG, "Not a valid Server IPv6 address");
- }
-
- clientArgs->ServerHostName = ref new HostName(serverIP);
-
- if (ServerPort->Text->IsEmpty())
- {
- throw Exception::CreateException(E_INVALIDARG, "No Server Port");
- }
- clientArgs->ServerPort = ServerPort->Text;
-
- auto clientIP = ClientIP->Text;
- if (clientIP->IsEmpty())
- {
- throw Exception::CreateException(E_INVALIDARG, "No Client IP");
- }
-
- // check valid chars of Ipv6 Address
- if (!TalkHelper::AllValidIpv6Chars(clientIP->Data(), clientIP->Data() + clientIP->Length()))
- {
- throw Exception::CreateException(E_INVALIDARG, "Not a valid client IPv6 address");
- }
-
- clientArgs->ClientHostName = ref new HostName(clientIP);
-
- if (ClientPort->Text->IsEmpty())
- {
- throw Exception::CreateException(E_INVALIDARG, "No Client Port");
- }
- clientArgs->ClientPort = ClientPort->Text;
-
- auto cleintContext = Factory::CreateClientContext(_notify, clientArgs, _protocol);
- cleintContext->Connect_Click(sender, e);
-
- // fix Only usage of each socket address (protocol/network address/port)
- // is normally permitted.
- auto clientPort = ++_clientPort;
- ClientPort->Text = clientPort.ToString();
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread(
- "Connecting failed with input error: " + ex->Message,
- NotifyType::Error);
- }
-}
-
-void
-ClientControl::Send_Click(
- Object^ sender,
- RoutedEventArgs^ e)
-{
- try
- {
- auto input = Input->Text;
- if (input->IsEmpty())
- {
- throw Exception::CreateException(E_INVALIDARG, "No Input");
- }
-
- if (!CoreApplication::Properties->HasKey("clientContext"))
- {
- throw Exception::CreateException(E_UNEXPECTED, "Not Connected");
- }
-
- auto clientContext = dynamic_cast(
- CoreApplication::Properties->Lookup("clientContext"));
- if (clientContext == nullptr)
- {
- throw Exception::CreateException(E_UNEXPECTED, "No clientContext");
- }
-
- clientContext->Send_Click(sender, e, input);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread(
- "Sending message failed with error: " + ex->Message,
- NotifyType::Error);
- }
-}
-
-void
-ClientControl::Exit_Click(
- Object^ sender,
- RoutedEventArgs^ e)
-{
- _mainPageUIElements->TalkGrid->Visibility = Xaml::Visibility::Collapsed;
- _mainPageUIElements->ThreadGrid->Visibility = Xaml::Visibility::Visible;
-}
diff --git a/examples/apps/windows/ClientControl.xaml.h b/examples/apps/windows/ClientControl.xaml.h
deleted file mode 100644
index 8c247af2c..000000000
--- a/examples/apps/windows/ClientControl.xaml.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#include
-#include "ClientControl.g.h"
-#include "TalkConsts.h"
-#include "IAsyncThreadNotify.h"
-#include "IMainPageUIElements.h"
-#include "Protocol.h"
-
-namespace ot
-{
-
-[Windows::Foundation::Metadata::WebHostHidden]
-public ref class ClientControl sealed
-{
-public:
- ClientControl();
-
- void Init(IAsyncThreadNotify^ notify, IMainPageUIElements^ mainPageUIElements);
-
- void ProtocolChanged(Protocol protocol);
-
-private:
- static constexpr unsigned short DEF_SERVER_PORT = TalkConsts::DEF_SERVER_PORT;
-
- void Connect_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- void Send_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- void Exit_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- IAsyncThreadNotify^ _notify;
- IMainPageUIElements^ _mainPageUIElements;
- Protocol _protocol;
- static std::atomic _clientPort;
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/DatagramClientContext.cpp b/examples/apps/windows/DatagramClientContext.cpp
deleted file mode 100644
index eb23b0dbc..000000000
--- a/examples/apps/windows/DatagramClientContext.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.h"
-#include
-#include "DatagramClientContext.h"
-
-using namespace ot;
-
-using namespace Concurrency;
-using namespace Platform;
-using namespace Windows::ApplicationModel::Core;
-using namespace Windows::Foundation;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::Networking::Sockets;
-using namespace Windows::UI::Xaml;
-using namespace Windows::UI::Xaml::Controls;
-using namespace Windows::UI::Xaml::Controls::Primitives;
-using namespace Windows::UI::Xaml::Data;
-using namespace Windows::UI::Xaml::Input;
-using namespace Windows::UI::Xaml::Media;
-using namespace Windows::UI::Xaml::Navigation;
-
-DatagramClientContext::DatagramClientContext(
- IAsyncThreadNotify^ notify,
- DatagramSocket^ client,
- ClientArgs^ args) :
- _notify{ std::move(notify) },
- _client{ std::move(client) },
- _args{ std::move(args) }
-{
-}
-
-DatagramClientContext::~DatagramClientContext()
-{
- // A Client can be closed in two ways:
- // - explicitly: using the 'delete' keyword (client is closed even if there are outstanding references to it).
- // - implicitly: removing the last reference to it (i.e., falling out-of-scope).
- //
- // When a Socket is closed implicitly, it can take several seconds for the local port being used
- // by it to be freed/reclaimed by the lower networking layers. During that time, other sockets on the machine
- // will not be able to use the port. Thus, it is strongly recommended that Socket instances be explicitly
- // closed before they go out of scope(e.g., before application exit). The call below explicitly closes the socket.
- if (_client != nullptr)
- {
- delete _client;
- _client = nullptr;
- }
-}
-
-void
-DatagramClientContext::Connect_Click(
- Object^ sender,
- RoutedEventArgs^ e)
-{
- task removeContext;
-
- if (CoreApplication::Properties->HasKey("clientContext"))
- {
- auto clientContext = dynamic_cast(
- CoreApplication::Properties->Lookup("clientContext"));
- if (clientContext == nullptr)
- {
- throw ref new FailureException(L"No clientContext");
- }
-
- removeContext = create_task(clientContext->CancelIO()).then(
- []()
- {
- CoreApplication::Properties->Remove("clientContext");
- });
- }
- else
- {
- removeContext = create_task([]() {});
- }
-
- _client->MessageReceived += ref new MessageHandler(
- this, &DatagramClientContext::OnMessage);
-
- removeContext.then([this](task prevTask)
- {
- try
- {
- // Try getting an exception.
- prevTask.get();
-
- // Events cannot be hooked up directly to the ScenarioInput2 object, as the object can fall out-of-scope and be
- // deleted. This would render any event hooked up to the object ineffective. The ClientContext guarantees that
- // both the socket and object that serves its events have the same lifetime.
- CoreApplication::Properties->Insert("clientContext", this);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread(
- "Remove clientContext error: " + ex->Message,
- NotifyType::Error);
- }
- catch (task_canceled&)
- {
- }
- }).then([this]()
- {
- auto endpointPair = ref new EndpointPair(_args->ClientHostName, _args->ClientPort,
- _args->ServerHostName, _args->ServerPort);
-
- _notify->NotifyFromAsyncThread("Start connecting", NotifyType::Status);
-
- create_task(_client->ConnectAsync(endpointPair)).then(
- [this, endpointPair](task prevTask)
- {
- try
- {
- // Try getting an exception.
- prevTask.get();
- _notify->NotifyFromAsyncThread(
- "Connect from " + endpointPair->LocalHostName->CanonicalName +
- " to " + endpointPair->RemoteHostName->CanonicalName,
- NotifyType::Status);
- SetConnected(true);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread(
- "Start binding failed with error: " + ex->Message,
- NotifyType::Error);
- CoreApplication::Properties->Remove("clientContext");
- }
- catch (task_canceled&)
- {
- CoreApplication::Properties->Remove("clientContext");
- }
- });
- });
-}
-
-void
-DatagramClientContext::Send_Click(
- Object^ sender,
- RoutedEventArgs^ e,
- String^ input)
-{
- SendMessage(GetDataWriter(), input);
-}
-
-IAsyncAction^
-DatagramClientContext::CancelIO()
-{
- return _client->CancelIOAsync();
-}
-
-void
-DatagramClientContext::SetConnected(
- bool connected)
-{
- _connected = connected;
-}
-
-bool
-ot::DatagramClientContext::IsConnected() const
-{
- return _connected;
-}
-
-void
-ot::DatagramClientContext::OnMessage(
- DatagramSocket^ socket,
- MessageReceivedEventArgs^ eventArgs)
-{
- try
- {
- auto dataReader = eventArgs->GetDataReader();
- Receive(dataReader, dataReader->UnconsumedBufferLength);
- }
- catch (Exception^ ex)
- {
- auto socketError = SocketError::GetStatus(ex->HResult);
- if (socketError == SocketErrorStatus::ConnectionResetByPeer)
- {
- // This error would indicate that a previous send operation resulted in an ICMP "Port Unreachable" message.
- _notify->NotifyFromAsyncThread(
- "Peer does not listen on the specific port. Please make sure that you run step 1 first "
- "or you have a server properly working on a remote server.",
- NotifyType::Error);
- }
- else if (socketError != SocketErrorStatus::Unknown)
- {
- _notify->NotifyFromAsyncThread(
- "Error happened when receiving a datagram: " + socketError.ToString(),
- NotifyType::Error);
- }
- else
- {
- throw;
- }
- }
-}
-
-void
-DatagramClientContext::Receive(
- DataReader^ dataReader,
- unsigned int strLen)
-{
- if (!strLen)
- {
- return;
- }
-
- auto msg = dataReader->ReadString(strLen);
- _notify->NotifyFromAsyncThread("Received data from server: \"" + msg + "\"",
- NotifyType::Status);
-}
-
-void
-DatagramClientContext::SendMessage(
- DataWriter^ dataWriter,
- String^ msg)
-{
- if (!IsConnected())
- {
- _notify->NotifyFromAsyncThread("This socket is not yet connected.", NotifyType::Error);
- return;
- }
-
- try
- {
- dataWriter->WriteString(msg);
- _notify->NotifyFromAsyncThread("Sending - " + msg, NotifyType::Status);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread("Sending failed with error: " + ex->Message, NotifyType::Error);
- }
-
- // Write the locally buffered data to the network. Please note that write operation will succeed
- // even if the server is not listening.
- create_task(dataWriter->StoreAsync()).then(
- [this](task writeTask)
- {
- try
- {
- // Try getting an exception.
- writeTask.get();
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread("Send failed with error: " + ex->Message, NotifyType::Error);
- }
- });
-}
-
-Windows::Storage::Streams::DataWriter^
-DatagramClientContext::GetDataWriter()
-{
- if (_dataWriter == nullptr)
- {
- _dataWriter = ref new DataWriter(_client->OutputStream);
- }
-
- return _dataWriter;
-}
diff --git a/examples/apps/windows/DatagramClientContext.h b/examples/apps/windows/DatagramClientContext.h
deleted file mode 100644
index 6591801bc..000000000
--- a/examples/apps/windows/DatagramClientContext.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#include "IClientContext.h"
-#include "IAsyncThreadNotify.h"
-#include "ClientArgs.h"
-
-namespace ot
-{
-
-[Windows::Foundation::Metadata::WebHostHidden]
-public ref class DatagramClientContext sealed : public IClientContext
-{
-public:
- using DatagramSocket = Windows::Networking::Sockets::DatagramSocket;
-
- DatagramClientContext(IAsyncThreadNotify^ notify, DatagramSocket^ client, ClientArgs^ args);
- virtual ~DatagramClientContext();
-
- virtual void Connect_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- virtual void Send_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e, Platform::String^ input);
-
- virtual Windows::Foundation::IAsyncAction^ CancelIO();
-
-private:
- using MessageReceivedEventArgs = Windows::Networking::Sockets::DatagramSocketMessageReceivedEventArgs;
- using MessageHandler = Windows::Foundation::TypedEventHandler;
- using DataReader = Windows::Storage::Streams::DataReader;
- using DataWriter = Windows::Storage::Streams::DataWriter;
- using Args = ClientArgs;
-
- void SetConnected(bool connected);
- bool IsConnected() const;
-
- void OnMessage(DatagramSocket^ socket, MessageReceivedEventArgs^ eventArgs);
- void Receive(DataReader^, unsigned int strLen);
-
- void SendMessage(DataWriter^, String^ msg);
-
- DataWriter^ GetDataWriter();
-
- IAsyncThreadNotify^ _notify;
- DatagramSocket^ _client;
- Args^ _args;
- bool _connected = false;
- DataReader^ _dataReader;
- DataWriter^ _dataWriter;
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/DatagramListenerContext.cpp b/examples/apps/windows/DatagramListenerContext.cpp
deleted file mode 100644
index 339e8c67a..000000000
--- a/examples/apps/windows/DatagramListenerContext.cpp
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.h"
-#include
-#include "DatagramListenerContext.h"
-
-using namespace ot;
-
-using namespace Concurrency;
-using namespace Platform;
-using namespace Windows::ApplicationModel::Core;
-using namespace Windows::Foundation;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::Networking::Sockets;
-using namespace Windows::UI::Xaml;
-using namespace Windows::UI::Xaml::Controls;
-using namespace Windows::UI::Xaml::Controls::Primitives;
-using namespace Windows::UI::Xaml::Data;
-using namespace Windows::UI::Xaml::Input;
-using namespace Windows::UI::Xaml::Media;
-using namespace Windows::UI::Xaml::Navigation;
-
-DatagramListenerContext::DatagramListenerContext(
- IAsyncThreadNotify^ notify,
- DatagramSocket^ listener,
- ListenerArgs^ args) :
- _notify{ std::move(notify) },
- _listener{ std::move(listener) },
- _args{ std::move(args) }
-{
-}
-
-DatagramListenerContext::~DatagramListenerContext()
-{
- // A Listener can be closed in two ways:
- // - explicitly: using the 'delete' keyword (listener is closed even if there are outstanding references to it).
- // - implicitly: removing the last reference to it (i.e., falling out-of-scope).
- //
- // When a Socket is closed implicitly, it can take several seconds for the local port being used
- // by it to be freed/reclaimed by the lower networking layers. During that time, other sockets on the machine
- // will not be able to use the port. Thus, it is strongly recommended that Socket instances be explicitly
- // closed before they go out of scope(e.g., before application exit). The call below explicitly closes the socket.
- if (_listener != nullptr)
- {
- delete _listener;
- _listener = nullptr;
- }
-}
-
-void
-DatagramListenerContext::Listen_Click(
- Object^ sender,
- RoutedEventArgs^ e)
-{
- task removeContext;
-
- if (CoreApplication::Properties->HasKey("listenerContext"))
- {
- auto listenerContext = dynamic_cast(
- CoreApplication::Properties->Lookup("listenerContext"));
- if (listenerContext == nullptr)
- {
- throw ref new FailureException(L"No listenerContext");
- }
-
- removeContext = create_task(listenerContext->CancelIO()).then(
- []()
- {
- CoreApplication::Properties->Remove("listenerContext");
- });
- }
- else
- {
- removeContext = create_task([]() {});
- }
-
- _listener->MessageReceived += ref new MessageHandler(
- this, &DatagramListenerContext::OnMessage);
-
- removeContext.then([this](task prevTask)
- {
- try
- {
- // Try getting an exception.
- prevTask.get();
-
- // Events cannot be hooked up directly to the ScenarioInput1 object, as the object can fall out-of-scope and be
- // deleted. This would render any event hooked up to the object ineffective. The ListenerContext guarantees that
- // both the listener and object that serves its events have the same lifetime.
- CoreApplication::Properties->Insert("listenerContext", this);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread(
- "Remove listenerContext error: " + ex->Message,
- NotifyType::Error);
- }
- catch (task_canceled&)
- {
- }
- }).then([this]()
- {
- _notify->NotifyFromAsyncThread("Start listening", NotifyType::Status);
-
- create_task(_listener->BindEndpointAsync(_args->ServerHostName, _args->ServerPort)).then(
- [this](task prevTask)
- {
- try
- {
- // Try getting an exception.
- prevTask.get();
- _notify->NotifyFromAsyncThread(
- "Listening on address " + _args->ServerHostName->CanonicalName,
- NotifyType::Status);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread(
- "Start listening failed with error: " + ex->Message,
- NotifyType::Error);
- CoreApplication::Properties->Remove("listenerContext");
- }
- });
- });
-}
-
-IAsyncAction^
-DatagramListenerContext::CancelIO()
-{
- return _listener->CancelIOAsync();
-}
-
-void
-DatagramListenerContext::OnMessage(
- DatagramSocket^ socket,
- MessageReceivedEventArgs^ eventArgs)
-{
- if (_outputStream != nullptr)
- {
- auto dataReader = eventArgs->GetDataReader();
- Receive(dataReader, dataReader->UnconsumedBufferLength, GetDataWriter());
- return;
- }
-
- // We do not have an output stream yet so create one.
- create_task(socket->GetOutputStreamAsync(eventArgs->RemoteAddress, eventArgs->RemotePort)).then(
- [this, socket, eventArgs](IOutputStream^ stream)
- {
- {
- std::lock_guard lock(_mtx);
-
- // It might happen that the OnMessage was invoked more than once before the GetOutputStreamAsync call
- // completed. In this case we will end up with multiple streams - just keep one of them.
- if (_outputStream == nullptr)
- {
- _outputStream = stream;
- }
- }
-
- auto dataReader = eventArgs->GetDataReader();
- Receive(dataReader, dataReader->UnconsumedBufferLength, GetDataWriter());
- }).then([this](task prevTask)
- {
- try
- {
- // Try getting all exceptions from the continuation chain above this point.
- prevTask.get();
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread("On message with an error: " + ex->Message,
- NotifyType::Error);
- }
- catch (task_canceled&)
- {
- // Do not print anything here - this will usually happen because user closed the client socket.
- }
- });
-}
-
-void
-DatagramListenerContext::Receive(
- DataReader^ dataReader,
- unsigned int strLen,
- DataWriter^ dataWriter)
-{
- if (!strLen)
- {
- return;
- }
-
- auto msg = dataReader->ReadString(strLen);
- _notify->NotifyFromAsyncThread("Received data from client: \"" + msg + "\"",
- NotifyType::Status);
- auto echo = CreateEchoMessage(msg);
- EchoMessage(dataWriter, echo);
-}
-
-String^
-DatagramListenerContext::CreateEchoMessage(
- String^ msg)
-{
- wchar_t buf[256];
- auto len = swprintf_s(buf, L"Server%s received data from client : \"%s\"",
- _args->ServerName->IsEmpty() ? L"" : (" " + _args->ServerName)->Data(), msg->Data());
-
- len += swprintf_s(&buf[len], _countof(buf) - len, L" - got %d chars",
- msg->Length());
- return ref new String(buf);
-}
-
-void
-DatagramListenerContext::EchoMessage(
- DataWriter^ dataWriter,
- String^ echo)
-{
- try
- {
- dataWriter->WriteString(echo);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread("Echoing failed with error: " + ex->Message,
- NotifyType::Error);
- }
-
- create_task(dataWriter->StoreAsync()).then(
- [this](task writeTask)
- {
- try
- {
- // Try getting all exceptions from the continuation chain above this point.
- writeTask.get();
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread("Echo message with an error: " + ex->Message,
- NotifyType::Error);
- }
- });
-}
-
-Windows::Storage::Streams::DataWriter^
-DatagramListenerContext::GetDataWriter()
-{
- if (_dataWriter == nullptr)
- {
- _dataWriter = ref new DataWriter(_outputStream);
- }
-
- return _dataWriter;
-}
diff --git a/examples/apps/windows/DatagramListenerContext.h b/examples/apps/windows/DatagramListenerContext.h
deleted file mode 100644
index ff8699a5e..000000000
--- a/examples/apps/windows/DatagramListenerContext.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#include
-#include "IListenerContext.h"
-#include "IAsyncThreadNotify.h"
-#include "ListenerArgs.h"
-
-namespace ot
-{
-
-[Windows::Foundation::Metadata::WebHostHidden]
-public ref class DatagramListenerContext sealed : public IListenerContext
-{
-public:
- using DatagramSocket = Windows::Networking::Sockets::DatagramSocket;
-
- DatagramListenerContext(IAsyncThreadNotify^ notify, DatagramSocket^ listener, ListenerArgs^ args);
- virtual ~DatagramListenerContext();
-
- virtual void Listen_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- virtual Windows::Foundation::IAsyncAction^ CancelIO();
-
-private:
- using MessageReceivedEventArgs = Windows::Networking::Sockets::DatagramSocketMessageReceivedEventArgs;
- using MessageHandler = Windows::Foundation::TypedEventHandler;
- using DataReader = Windows::Storage::Streams::DataReader;
- using DataWriter = Windows::Storage::Streams::DataWriter;
- using IOutputStream = Windows::Storage::Streams::IOutputStream;
- using Listener = DatagramSocket;
- using Args = ListenerArgs;
- using mutex_t = std::mutex;
-
- void OnMessage(DatagramSocket^ socket, MessageReceivedEventArgs^ eventArgs);
- void Receive(DataReader^, unsigned int strLen, DataWriter^);
- String^ CreateEchoMessage(String^ msg);
- void EchoMessage(DataWriter^, String^ echo);
-
- DataWriter^ GetDataWriter();
-
- IAsyncThreadNotify^ _notify;
- Listener^ _listener;
- Args^ _args;
- DataWriter^ _dataWriter;
-
- mutable mutex_t _mtx;
- // mutex protected data
- IOutputStream^ _outputStream;
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/Factory.cpp b/examples/apps/windows/Factory.cpp
deleted file mode 100644
index b047ab7a3..000000000
--- a/examples/apps/windows/Factory.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.h"
-#include "Factory.h"
-#include "StreamListenerContext.h"
-#include "DatagramListenerContext.h"
-#include "StreamClientContext.h"
-#include "DatagramClientContext.h"
-
-using namespace ot;
-
-using namespace Concurrency;
-using namespace Platform;
-using namespace Windows::ApplicationModel::Core;
-using namespace Windows::Foundation;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::Networking::Sockets;
-using namespace Windows::UI::Xaml;
-using namespace Windows::UI::Xaml::Controls;
-using namespace Windows::UI::Xaml::Controls::Primitives;
-using namespace Windows::UI::Xaml::Data;
-using namespace Windows::UI::Xaml::Input;
-using namespace Windows::UI::Xaml::Media;
-using namespace Windows::UI::Xaml::Navigation;
-
-IListenerContext^
-Factory::CreateListenerContext(
- IAsyncThreadNotify^ notify,
- ListenerArgs^ listenerArgs,
- Protocol protocol)
-{
- if (protocol == Protocol::TCP)
- {
- auto listener = ref new StreamSocketListener();
- return ref new StreamListenerContext(notify, listener, listenerArgs);
- }
- else
- {
- auto listener = ref new DatagramSocket();
- return ref new DatagramListenerContext(notify, listener, listenerArgs);
- }
-}
-
-IClientContext^
-Factory::CreateClientContext(
- IAsyncThreadNotify^ notify,
- ClientArgs^ clientArgs,
- Protocol protocol)
-{
- if (protocol == Protocol::TCP)
- {
- auto client = ref new StreamSocket();
- return ref new StreamClientContext(notify, client, clientArgs);
- }
- else
- {
- auto client = ref new DatagramSocket();
- return ref new DatagramClientContext(notify, client, clientArgs);
- }
-}
diff --git a/examples/apps/windows/Factory.h b/examples/apps/windows/Factory.h
deleted file mode 100644
index 6cdeaf851..000000000
--- a/examples/apps/windows/Factory.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#include "IAsyncThreadNotify.h"
-#include "ListenerArgs.h"
-#include "IListenerContext.h"
-#include "ClientArgs.h"
-#include "IClientContext.h"
-#include "Protocol.h"
-
-namespace ot
-{
-
-class Factory
-{
-public:
- static IListenerContext^ CreateListenerContext(IAsyncThreadNotify^, ListenerArgs^, Protocol);
-
- static IClientContext^ CreateClientContext(IAsyncThreadNotify^, ClientArgs^, Protocol);
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/IAsyncThreadNotify.h b/examples/apps/windows/IAsyncThreadNotify.h
deleted file mode 100644
index dc3c900a0..000000000
--- a/examples/apps/windows/IAsyncThreadNotify.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-namespace ot
-{
-
-public enum class NotifyType
-{
- Status,
- Error,
-};
-
-public interface struct IAsyncThreadNotify
-{
- void NotifyFromAsyncThread(Platform::String^ message, NotifyType type);
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/IClientContext.h b/examples/apps/windows/IClientContext.h
deleted file mode 100644
index f8c948b21..000000000
--- a/examples/apps/windows/IClientContext.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-namespace ot
-{
-
-public interface struct IClientContext
-{
- void Connect_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- void Send_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e, Platform::String^ input);
-
- Windows::Foundation::IAsyncAction^ CancelIO();
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/IListenerContext.h b/examples/apps/windows/IListenerContext.h
deleted file mode 100644
index b5cb89a92..000000000
--- a/examples/apps/windows/IListenerContext.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-namespace ot
-{
-
-public interface struct IListenerContext
-{
- void Listen_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- Windows::Foundation::IAsyncAction^ CancelIO();
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/IMainPageUIElements.h b/examples/apps/windows/IMainPageUIElements.h
deleted file mode 100644
index c7cd46f2e..000000000
--- a/examples/apps/windows/IMainPageUIElements.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-namespace ot
-{
-
-public interface struct IMainPageUIElements
-{
- property Windows::UI::Xaml::UIElement^ ThreadGrid
- {
- Windows::UI::Xaml::UIElement^ get();
- }
-
- property Windows::UI::Xaml::UIElement^ TalkGrid
- {
- Windows::UI::Xaml::UIElement^ get();
- }
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/ListenerArgs.h b/examples/apps/windows/ListenerArgs.h
deleted file mode 100644
index 510c01612..000000000
--- a/examples/apps/windows/ListenerArgs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-namespace ot
-{
-
-public ref class ListenerArgs sealed
-{
-public:
- property Platform::String^ ServerName;
- property Windows::Networking::HostName^ ServerHostName;
- property Platform::String^ ServerPort;
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/MainPage.xaml b/examples/apps/windows/MainPage.xaml
deleted file mode 100644
index 03b1e9bee..000000000
--- a/examples/apps/windows/MainPage.xaml
+++ /dev/null
@@ -1,307 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/apps/windows/MainPage.xaml.cpp b/examples/apps/windows/MainPage.xaml.cpp
deleted file mode 100644
index 55732de39..000000000
--- a/examples/apps/windows/MainPage.xaml.cpp
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.h"
-#include "MainPage.xaml.h"
-#include "TalkGrid.xaml.h"
-
-using namespace ot;
-
-using namespace Platform;
-using namespace Windows::Foundation;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::UI::Xaml;
-using namespace Windows::UI::Xaml::Controls;
-using namespace Windows::UI::Xaml::Controls::Primitives;
-using namespace Windows::UI::Xaml::Data;
-using namespace Windows::UI::Xaml::Input;
-using namespace Windows::UI::Xaml::Media;
-using namespace Windows::UI::Xaml::Navigation;
-
-#define GUID_FORMAT L"{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}"
-#define GUID_ARG(guid) guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]
-
-void otLog(PCSTR aFormat, ...)
-{
- va_list args;
- va_start(args, aFormat);
-
- CHAR logString[512] = { 0 };
- int charsWritten = vsprintf_s(logString, sizeof(logString), aFormat, args);
- if (charsWritten > 0) OutputDebugStringA(logString);
-
- va_end(args);
-}
-
-MainPage::MainPage() : _otApi(nullptr)
-{
- InitializeComponent();
-
- InterfaceConfigCancelButton->Click +=
- ref new RoutedEventHandler(
- [=](Platform::Object^, RoutedEventArgs^) {
- this->InterfaceConfiguration->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
- this->_curAdapter = nullptr;
- }
- );
- InterfaceConfigOkButton->Click +=
- ref new RoutedEventHandler(
- [=](Platform::Object^, RoutedEventArgs^) {
- this->InterfaceConfiguration->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
- this->ConnectNetwork(_curAdapter);
- this->_curAdapter = nullptr;
- }
- );
- InterfaceDetailsCloseButton->Click +=
- ref new RoutedEventHandler(
- [=](Platform::Object^, RoutedEventArgs^) {
- this->InterfaceDetails->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
- }
- );
- Talk->Click +=
- ref new RoutedEventHandler(
- [=](Platform::Object^, RoutedEventArgs^) {
- this->ThreadGrid->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
- this->TalkGrid->Visibility = Windows::UI::Xaml::Visibility::Visible;
- }
- );
-
- TlkGrid->Init(this);
-}
-
-void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
-{
- Loaded += ref new RoutedEventHandler(this, &MainPage::OnLoaded);
- Unloaded += ref new RoutedEventHandler(this, &MainPage::OnUnloaded);
-}
-
-void MainPage::OnLoaded(Object^ sender, RoutedEventArgs^ e)
-{
- try
- {
- // Initialize api handle
- _otApi = ref new otApi();
-
- // Register for state changes
- _adapterArrivalToken =
- _otApi->AdapterArrival +=
- ref new otAdapterArrivalDelegate(
- [=](otAdapter^ adapter) {
- // Update on the UI thread
- this->Dispatcher->RunAsync(
- Windows::UI::Core::CoreDispatcherPriority::Normal,
- ref new Windows::UI::Core::DispatchedHandler(
- [=]() {
- this->AddAdapterToList(adapter);
- }));
- });
-
- // Enumerate the adapter list
- auto adapters = _otApi->GetAdapters();
- for (auto&& adapter : adapters) {
- AddAdapterToList(adapter);
- }
- }
- catch (Exception^)
- {
- }
-}
-
-void MainPage::OnUnloaded(Object^ sender, RoutedEventArgs^ e)
-{
- if (_otApi)
- {
- // Unregister
- _otApi->AdapterArrival -= _adapterArrivalToken;
-
- // Clear current adapter
- _curAdapter = nullptr;
-
- // Remove the adapter list
- auto adapters = _otApi->GetAdapters();
- for (auto&& adapter : adapters) {
- adapter->InvokeAdapterRemoval();
- }
-
- // Free the api handle
- _otApi = nullptr;
- }
-}
-
-void MainPage::OnResuming()
-{
-}
-
-void MainPage::ShowInterfaceDetails(otAdapter^ adapter)
-{
- try
- {
- InterfaceMacAddress->Text = otApi::MacToString(adapter->ExtendedAddress);
- InterfaceML_EID->Text = adapter->MeshLocalEid->ToString();
- InterfaceRLOC->Text = otApi::Rloc16ToString(adapter->Rloc16);
-
- if (adapter->State > otThreadState::Child)
- {
- uint8_t index = 0;
- otChildInfo childInfo;
- while (OT_ERROR_NONE == otThreadGetChildInfoByIndex((otInstance*)(void*)adapter->RawHandle, index, &childInfo))
- {
- index++;
- }
-
- WCHAR szText[64] = { 0 };
- swprintf_s(szText, 64, L"%d", index);
- InterfaceChildren->Text = ref new String(szText);
-
- InterfaceNeighbors->Text = L"unknown";
-
- InterfaceNeighbors->Visibility = Windows::UI::Xaml::Visibility::Visible;
- InterfaceNeighborsText->Visibility = Windows::UI::Xaml::Visibility::Visible;
- InterfaceChildren->Visibility = Windows::UI::Xaml::Visibility::Visible;
- InterfaceChildrenText->Visibility = Windows::UI::Xaml::Visibility::Visible;
- }
-
- // Show the details
- InterfaceDetails->Visibility = Windows::UI::Xaml::Visibility::Visible;
- }
- catch (Exception^)
- {
-
- }
-}
-
-void MainPage::AddAdapterToList(otAdapter^ adapter)
-{
- try
- {
- GUID interfaceGuid = adapter->InterfaceGuid;
- WCHAR szName[256] = { 0 };
- swprintf_s(szName, 256, GUID_FORMAT, GUID_ARG(interfaceGuid));
-
- auto InterfaceStackPanel = ref new StackPanel();
- InterfaceStackPanel->Name = ref new String(szName);
- InterfaceStackPanel->Orientation = Orientation::Horizontal;
-
- otLog("%S arrival!\n", InterfaceStackPanel->Name->Data());
-
- // Basic description text
- auto InterfaceTextBlock = ref new TextBlock();
- InterfaceTextBlock->Text = ref new String(L"openthread interface");
- InterfaceTextBlock->FontSize = 16;
- InterfaceTextBlock->Margin = Thickness(10);
- InterfaceTextBlock->TextWrapping = TextWrapping::Wrap;
- InterfaceStackPanel->Children->Append(InterfaceTextBlock);
-
- // Connect button
- auto ConnectButton = ref new Button();
- ConnectButton->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
- ConnectButton->Content = ref new String(L"Connect");
- ConnectButton->Click +=
- ref new RoutedEventHandler(
- [=](Platform::Object^, RoutedEventArgs^) {
- this->_curAdapter = adapter;
- this->InterfaceConfiguration->Visibility = Windows::UI::Xaml::Visibility::Visible;
- }
- );
- InterfaceStackPanel->Children->Append(ConnectButton);
-
- // Details button
- auto DetailsButton = ref new Button();
- DetailsButton->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
- DetailsButton->Content = ref new String(L"Details");
- DetailsButton->Click +=
- ref new RoutedEventHandler(
- [=](Platform::Object^, RoutedEventArgs^) {
- this->ShowInterfaceDetails(adapter);
- }
- );
- InterfaceStackPanel->Children->Append(DetailsButton);
-
- // Disconnect button
- auto DisconnectButton = ref new Button();
- DisconnectButton->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
- DisconnectButton->Content = ref new String(L"Disconnect");
- DisconnectButton->Click +=
- ref new RoutedEventHandler(
- [=](Platform::Object^, RoutedEventArgs^) {
- this->DisconnectNetwork(adapter);
- }
- );
- InterfaceStackPanel->Children->Append(DisconnectButton);
-
- // Delegate for handling role changes
- auto OnAdapterRoleChanged =
- [=]() {
- GUID interfaceGuid = adapter->InterfaceGuid;
- auto state = adapter->State;
- auto stateStr = otApi::ThreadStateToString(adapter->State);
-
- WCHAR szText[256] = { 0 };
- swprintf_s(szText, 256, GUID_FORMAT L"\r\n\t%s\r\n\t%s",
- GUID_ARG(interfaceGuid),
- stateStr->Data(),
- state >= otThreadState::Child ?
- adapter->MeshLocalEid->ToString()->Data() :
- L"");
-
- InterfaceTextBlock->Text = ref new String(szText);
-
- otLog("%S state = %S\n", InterfaceStackPanel->Name->Data(), stateStr->Data());
-
- if (state == otThreadState::Disabled)
- {
- ConnectButton->Visibility = Windows::UI::Xaml::Visibility::Visible;
- DetailsButton->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
- DisconnectButton->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
- }
- else
- {
- ConnectButton->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
- DetailsButton->Visibility = Windows::UI::Xaml::Visibility::Visible;
- DisconnectButton->Visibility = Windows::UI::Xaml::Visibility::Visible;
- }
- };
-
- // Register for role change callbacks
- auto adapterRoleChangedToken =
- adapter->NetRoleChanged +=
- ref new otNetRoleChangedDelegate(
- [=](auto sender) {
- // Update the text on the UI thread
- this->Dispatcher->RunAsync(
- Windows::UI::Core::CoreDispatcherPriority::Normal,
- ref new Windows::UI::Core::DispatchedHandler(
- [=]() {
- OnAdapterRoleChanged();
- }
- )
- );
- }
- );
-
- // Register for address change callbacks
- auto adapterMeshLocalAddresChangedToken =
- adapter->IpMeshLocalAddresChanged +=
- ref new otIpMeshLocalAddresChangedDelegate(
- [=](auto sender) {
- // Update the text on the UI thread
- this->Dispatcher->RunAsync(
- Windows::UI::Core::CoreDispatcherPriority::Normal,
- ref new Windows::UI::Core::DispatchedHandler(
- [=]() {
- OnAdapterRoleChanged();
- }
- )
- );
- }
- );
-
- // Register for adapter removal callbacks
- Windows::Foundation::EventRegistrationToken adapterRemovalToken;
- adapterRemovalToken =
- adapter->AdapterRemoval +=
- ref new otAdapterRemovalDelegate(
- [=](otAdapter^ adapter) {
- // Unregister
- adapter->NetRoleChanged -= adapterRoleChangedToken;
- adapter->IpMeshLocalAddresChanged -= adapterMeshLocalAddresChangedToken;
- adapter->AdapterRemoval -= adapterRemovalToken;
-
- // Remove the item on the UI thread
- this->Dispatcher->RunAsync(
- Windows::UI::Core::CoreDispatcherPriority::Normal,
- ref new Windows::UI::Core::DispatchedHandler(
- [=]() {
- for (uint32_t i = 0; i < this->InterfaceList->Items->Size; i++)
- {
- auto Item = dynamic_cast(this->InterfaceList->Items->GetAt(i));
- if (Item == InterfaceStackPanel)
- {
- otLog("%S removal!\n", InterfaceStackPanel->Name->Data());
- this->InterfaceList->Items->RemoveAt(i);
- break;
- }
- }
- }));
- });
-
- // Trigger the initial role change
- OnAdapterRoleChanged();
-
- // Add the interface to the list
- InterfaceList->Items->Append(InterfaceStackPanel);
- }
- catch (Exception^)
- {
- }
-}
-
-void MainPage::ConnectNetwork(otAdapter^ adapter)
-{
- try
- {
- GUID interfaceGuid = adapter->InterfaceGuid;
- WCHAR szName[256] = { 0 };
- swprintf_s(szName, 256, GUID_FORMAT, GUID_ARG(interfaceGuid));
- otLog("%S starting connection...\n", szName);
-
- // Configure
- adapter->NetworkName = InterfaceConfigName->Text;
- adapter->MasterKey = InterfaceConfigKey->Text;
- adapter->Channel = (uint8_t)InterfaceConfigChannel->Value;
- adapter->MaxAllowedChildren = (uint8_t)InterfaceConfigMaxChildren->Value;
- adapter->PanId = 0x4567;
-
- // Bring up the interface and start the Thread logic
- adapter->IpEnabled = true;
- adapter->ThreadEnabled = true;
- }
- catch (Exception^)
- {
-
- }
-}
-
-void MainPage::DisconnectNetwork(otAdapter^ adapter)
-{
- try
- {
- GUID interfaceGuid = adapter->InterfaceGuid;
- WCHAR szName[256] = { 0 };
- swprintf_s(szName, 256, GUID_FORMAT, GUID_ARG(interfaceGuid));
- otLog("%S disconnecting...\n", szName);
-
- // Stop the Thread network and bring down the interface
- adapter->ThreadEnabled = false;
- adapter->IpEnabled = false;
- }
- catch (Exception^)
- {
-
- }
-}
-
-Windows::UI::Xaml::UIElement^
-MainPage::ThreadGrid::get()
-{
- return ThrdGrid;
-}
-
-Windows::UI::Xaml::UIElement^
-MainPage::TalkGrid::get()
-{
- return TlkGrid;
-}
diff --git a/examples/apps/windows/MainPage.xaml.h b/examples/apps/windows/MainPage.xaml.h
deleted file mode 100644
index 40d3e7b38..000000000
--- a/examples/apps/windows/MainPage.xaml.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#include "MainPage.g.h"
-#include "IMainPageUIElements.h"
-
-namespace ot
-{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
- public ref class MainPage sealed : public IMainPageUIElements
- {
- public:
- MainPage();
-
- void OnResuming();
-
- void ConnectNetwork(otAdapter^ adapter);
- void ShowInterfaceDetails(otAdapter^ adapter);
- void DisconnectNetwork(otAdapter^ adapter);
-
- property Windows::UI::Xaml::UIElement^ ThreadGrid
- {
- virtual Windows::UI::Xaml::UIElement^ get();
- }
-
- property Windows::UI::Xaml::UIElement^ TalkGrid
- {
- virtual Windows::UI::Xaml::UIElement^ get();
- }
-
- protected:
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
-
- private:
-
- void OnLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- void OnUnloaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- void AddAdapterToList(otAdapter^ adapter);
-
- otApi^ _otApi;
-
- Windows::Foundation::EventRegistrationToken _adapterArrivalToken;
-
- otAdapter^ _curAdapter;
-
- };
-}
diff --git a/examples/apps/windows/OpenThread_TemporaryKey.pfx b/examples/apps/windows/OpenThread_TemporaryKey.pfx
deleted file mode 100644
index 46b475578..000000000
Binary files a/examples/apps/windows/OpenThread_TemporaryKey.pfx and /dev/null differ
diff --git a/examples/apps/windows/Package.appxmanifest b/examples/apps/windows/Package.appxmanifest
deleted file mode 100644
index f336f667c..000000000
--- a/examples/apps/windows/Package.appxmanifest
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
- OpenThread
- OpenThread
- Assets\StoreLogo.png
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/examples/apps/windows/Protocol.h b/examples/apps/windows/Protocol.h
deleted file mode 100644
index c325e4b6a..000000000
--- a/examples/apps/windows/Protocol.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-namespace ot
-{
-
-public enum class Protocol
-{
- TCP,
- UDP,
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/README.md b/examples/apps/windows/README.md
deleted file mode 100644
index d3b2e8fd0..000000000
--- a/examples/apps/windows/README.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# OpenThread App for Windows #
-
-This sample app provides an example of how to interface with the OpenThread API and talk to each other in a
-[Universal Windows App](https://developer.microsoft.com/en-us/windows/apps). The app is written in C++ /CX
-and provides a simple wrapper around the OpenThread API, hiding the raw C/C++ interface.
-
-The main page of the App is a list of the available interfaces, their current connection state,
-their current ML-EID IPv6 address, and buttons to connect/disconnect and to view some more details.
-
-![Interface List](../../../doc/images/windows-app-interface-list.png)
-
-The details list provides some more information, including extended MAC address, RLOC16 and information
-about the current children.
-
-![Interface List](../../../doc/images/windows-app-details.png)
-
-The "Talk" button of main page switches the user interface to the talk fuctionality. This app acts
-either as a server or a client role and talks to each other over a TCP or a UDP protocol.
-
-The server listens to the clients.
-
-![Talk Functionality](../../../doc/images/windows-app-talk-server.png)
-
-The client sends a message to the server and the server echos that message back to the client.
-
-![Talk Functionality](../../../doc/images/windows-app-talk-client.png)
diff --git a/examples/apps/windows/ServerControl.xaml b/examples/apps/windows/ServerControl.xaml
deleted file mode 100644
index 5408b2eb9..000000000
--- a/examples/apps/windows/ServerControl.xaml
+++ /dev/null
@@ -1,106 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/apps/windows/ServerControl.xaml.cpp b/examples/apps/windows/ServerControl.xaml.cpp
deleted file mode 100644
index 37545bd85..000000000
--- a/examples/apps/windows/ServerControl.xaml.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.h"
-#include
-#include
-#include "ServerControl.xaml.h"
-#include "Factory.h"
-#include "TalkHelper.h"
-
-using namespace ot;
-
-using namespace Platform;
-using namespace Windows::Foundation;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::UI;
-using namespace Windows::UI::Xaml;
-using namespace Windows::UI::Xaml::Controls;
-using namespace Windows::UI::Xaml::Controls::Primitives;
-using namespace Windows::UI::Xaml::Data;
-using namespace Windows::UI::Xaml::Input;
-using namespace Windows::UI::Xaml::Media;
-using namespace Windows::UI::Xaml::Navigation;
-
-// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
-
-ServerControl::ServerControl()
-{
- InitializeComponent();
-
- ServerPort->Text = DEF_PORT.ToString();
-}
-
-void
-ServerControl::Init(
- IAsyncThreadNotify^ notify,
- IMainPageUIElements^ mainPageUIElements)
-{
- _notify = std::move(notify);
- _mainPageUIElements = std::move(mainPageUIElements);
-}
-
-void
-ServerControl::ProtocolChanged(
- Protocol protocol)
-{
- _protocol = protocol;
-}
-
-void
-ServerControl::Listen_Click(
- Object^ sender,
- RoutedEventArgs^ e)
-{
- try
- {
- auto listenerArgs = ref new ListenerArgs();
-
- listenerArgs->ServerName = ServerName->Text;
-
- auto serverIP = ServerIP->Text;
- if (serverIP->IsEmpty())
- {
- throw Exception::CreateException(E_INVALIDARG, "No Server IP");
- }
-
- // check valid chars of Ipv6 Address
- if (!TalkHelper::AllValidIpv6Chars(serverIP->Data(), serverIP->Data() + serverIP->Length()))
- {
- throw Exception::CreateException(E_INVALIDARG, "Not a valid Server IPv6 address");
- }
-
- listenerArgs->ServerHostName = ref new HostName(serverIP);
-
- if (ServerPort->Text->IsEmpty())
- {
- throw Exception::CreateException(E_INVALIDARG, "No Server Port");
- }
- listenerArgs->ServerPort = ServerPort->Text;
-
- auto listenerContext = Factory::CreateListenerContext(_notify, listenerArgs, _protocol);
- listenerContext->Listen_Click(sender, e);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread(
- "Listening failed with input error: " + ex->Message,
- NotifyType::Error);
- }
-}
-
-void
-ServerControl::Exit_Click(
- Object^ sender,
- RoutedEventArgs^ e)
-{
- _mainPageUIElements->TalkGrid->Visibility = Xaml::Visibility::Collapsed;
- _mainPageUIElements->ThreadGrid->Visibility = Xaml::Visibility::Visible;
-}
diff --git a/examples/apps/windows/ServerControl.xaml.h b/examples/apps/windows/ServerControl.xaml.h
deleted file mode 100644
index 6284f4aac..000000000
--- a/examples/apps/windows/ServerControl.xaml.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#include "ServerControl.g.h"
-#include "TalkConsts.h"
-#include "IAsyncThreadNotify.h"
-#include "IMainPageUIElements.h"
-#include "Protocol.h"
-
-namespace ot
-{
-
-[Windows::Foundation::Metadata::WebHostHidden]
-public ref class ServerControl sealed
-{
-public:
- ServerControl();
-
- void Init(IAsyncThreadNotify^ notify, IMainPageUIElements^ mainPageUIElements);
-
- void ProtocolChanged(Protocol protocol);
-
-private:
- static constexpr unsigned short DEF_PORT = TalkConsts::DEF_SERVER_PORT;
-
- void Listen_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- void Exit_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- IAsyncThreadNotify^ _notify;
- IMainPageUIElements^ _mainPageUIElements;
- Protocol _protocol;
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/StreamClientContext.cpp b/examples/apps/windows/StreamClientContext.cpp
deleted file mode 100644
index f209e9ccf..000000000
--- a/examples/apps/windows/StreamClientContext.cpp
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.h"
-#include
-#include "StreamClientContext.h"
-
-using namespace ot;
-
-using namespace Concurrency;
-using namespace Platform;
-using namespace Windows::ApplicationModel::Core;
-using namespace Windows::Foundation;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::Networking::Sockets;
-using namespace Windows::UI::Xaml;
-using namespace Windows::UI::Xaml::Controls;
-using namespace Windows::UI::Xaml::Controls::Primitives;
-using namespace Windows::UI::Xaml::Data;
-using namespace Windows::UI::Xaml::Input;
-using namespace Windows::UI::Xaml::Media;
-using namespace Windows::UI::Xaml::Navigation;
-
-StreamClientContext::StreamClientContext(
- IAsyncThreadNotify^ notify,
- StreamSocket^ client,
- ClientArgs^ args) :
- _notify{ std::move(notify) },
- _client{ std::move(client) },
- _args{ std::move(args) }
-{
-}
-
-StreamClientContext::~StreamClientContext()
-{
- // A Client can be closed in two ways:
- // - explicitly: using the 'delete' keyword (client is closed even if there are outstanding references to it).
- // - implicitly: removing the last reference to it (i.e., falling out-of-scope).
- //
- // When a Socket is closed implicitly, it can take several seconds for the local port being used
- // by it to be freed/reclaimed by the lower networking layers. During that time, other sockets on the machine
- // will not be able to use the port. Thus, it is strongly recommended that Socket instances be explicitly
- // closed before they go out of scope(e.g., before application exit). The call below explicitly closes the socket.
- if (_client != nullptr)
- {
- delete _client;
- _client = nullptr;
- }
-}
-
-void
-StreamClientContext::Connect_Click(
- Object^ sender,
- RoutedEventArgs^ e)
-{
- task removeContext;
-
- if (CoreApplication::Properties->HasKey("clientContext"))
- {
- auto clientContext = dynamic_cast(
- CoreApplication::Properties->Lookup("clientContext"));
- if (clientContext == nullptr)
- {
- throw ref new FailureException(L"No clientContext");
- }
-
- removeContext = create_task(clientContext->CancelIO()).then(
- []()
- {
- CoreApplication::Properties->Remove("clientContext");
- });
- }
- else
- {
- removeContext = create_task([]() {});
- }
-
- removeContext.then([this](task prevTask)
- {
- try
- {
- // Try getting an exception.
- prevTask.get();
-
- // Events cannot be hooked up directly to the ScenarioInput2 object, as the object can fall out-of-scope and be
- // deleted. This would render any event hooked up to the object ineffective. The ClientContext guarantees that
- // both the socket and object that serves its events have the same lifetime.
- CoreApplication::Properties->Insert("clientContext", this);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread(
- "Remove clientContext error: " + ex->Message,
- NotifyType::Error);
- }
- catch (task_canceled&)
- {
- }
- }).then([this]()
- {
- auto endpointPair = ref new EndpointPair(_args->ClientHostName, _args->ClientPort,
- _args->ServerHostName, _args->ServerPort);
-
- _notify->NotifyFromAsyncThread("Start connecting", NotifyType::Status);
-
- create_task(_client->ConnectAsync(endpointPair)).then(
- [this, endpointPair](task prevTask)
- {
- try
- {
- // Try getting an exception.
- prevTask.get();
- _notify->NotifyFromAsyncThread(
- "Connect from " + endpointPair->LocalHostName->CanonicalName +
- " to " + endpointPair->RemoteHostName->CanonicalName,
- NotifyType::Status);
- OnConnection(_client);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread(
- "Start binding failed with error: " + ex->Message,
- NotifyType::Error);
- CoreApplication::Properties->Remove("clientContext");
- }
- catch (task_canceled&)
- {
- CoreApplication::Properties->Remove("clientContext");
- }
- });
- });
-}
-
-void
-ot::StreamClientContext::Send_Click(
- Platform::Object^ sender,
- Windows::UI::Xaml::RoutedEventArgs^ e,
- Platform::String^ input)
-{
- SendMessage(GetDataWriter(), input);
-}
-
-IAsyncAction^
-ot::StreamClientContext::CancelIO()
-{
- return _client->CancelIOAsync();
-}
-
-void
-StreamClientContext::OnConnection(
- StreamSocket^ streamSocket)
-{
- SetConnected(true);
- ReceiveLoop(streamSocket, GetDataReader());
-}
-
-void
-StreamClientContext::SetConnected(
- bool connected)
-{
- _connected = connected;
-}
-
-bool
-StreamClientContext::IsConnected() const
-{
- return _connected;
-}
-
-void
-StreamClientContext::ReceiveLoop(
- StreamSocket^ streamSocket,
- DataReader^ dataReader)
-{
- // Read first 4 bytes (length of the subsequent string).
- create_task(dataReader->LoadAsync(sizeof(UINT32))).then(
- [this, dataReader](unsigned int size)
- {
- if (size < sizeof(UINT32))
- {
- // The underlying socket was closed before we were able to read the whole data.
- cancel_current_task();
- }
-
- auto strLen = dataReader->ReadUInt32();
- return create_task(dataReader->LoadAsync(strLen)).then(
- [this, dataReader, strLen](unsigned int actualStrLen)
- {
- if (actualStrLen != strLen)
- {
- // The underlying socket was closed before we were able to read the whole data.
- cancel_current_task();
- }
-
- Receive(dataReader, strLen);
- });
- }).then([this, streamSocket, dataReader](task previousTask)
- {
- try
- {
- // Try getting all exceptions from the continuation chain above this point.
- previousTask.get();
-
- // Everything went ok, so try to receive another string. The receive will continue until the stream is
- // broken (i.e. peer closed the socket).
- ReceiveLoop(streamSocket, dataReader);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread("Read stream failed with error: " + ex->Message,
- NotifyType::Error);
-
- // Explicitly close the socket.
- delete streamSocket;
- }
- catch (task_canceled&)
- {
- // Do not print anything here - this will usually happen because user closed the client socket.
-
- // Explicitly close the socket.
- delete streamSocket;
- }
- });
-}
-
-void
-StreamClientContext::Receive(
- DataReader^ dataReader,
- unsigned int strLen)
-{
- if (!strLen)
- {
- return;
- }
-
- auto msg = dataReader->ReadString(strLen);
- _notify->NotifyFromAsyncThread("Received data from server: \"" + msg + "\"",
- NotifyType::Status);
-}
-
-void
-StreamClientContext::SendMessage(
- DataWriter^ dataWriter,
- String^ msg)
-{
- if (!IsConnected())
- {
- _notify->NotifyFromAsyncThread("This socket is not yet connected.", NotifyType::Error);
- return;
- }
-
- try
- {
- dataWriter->WriteUInt32(msg->Length());
- dataWriter->WriteString(msg);
- _notify->NotifyFromAsyncThread("Sending - " + msg, NotifyType::Status);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread("Sending failed with error: " + ex->Message, NotifyType::Error);
- }
-
- // Write the locally buffered data to the network. Please note that write operation will succeed
- // even if the server is not listening.
- create_task(dataWriter->StoreAsync()).then(
- [this](task writeTask)
- {
- try
- {
- // Try getting an exception.
- writeTask.get();
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread("Send failed with error: " + ex->Message, NotifyType::Error);
- }
- });
-}
-
-Windows::Storage::Streams::DataReader^
-StreamClientContext::GetDataReader()
-{
- if (_dataReader == nullptr)
- {
- _dataReader = ref new DataReader(_client->InputStream);
- }
-
- return _dataReader;
-}
-
-Windows::Storage::Streams::DataWriter^
-StreamClientContext::GetDataWriter()
-{
- if (_dataWriter == nullptr)
- {
- _dataWriter = ref new DataWriter(_client->OutputStream);
- }
-
- return _dataWriter;
-}
diff --git a/examples/apps/windows/StreamClientContext.h b/examples/apps/windows/StreamClientContext.h
deleted file mode 100644
index 111182300..000000000
--- a/examples/apps/windows/StreamClientContext.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#include "IClientContext.h"
-#include "IAsyncThreadNotify.h"
-#include "ClientArgs.h"
-
-namespace ot
-{
-
-[Windows::Foundation::Metadata::WebHostHidden]
-public ref class StreamClientContext sealed : public IClientContext
-{
-public:
- using StreamSocket = Windows::Networking::Sockets::StreamSocket;
-
- StreamClientContext(IAsyncThreadNotify^ notify, StreamSocket^ client, ClientArgs^ args);
- virtual ~StreamClientContext();
-
- virtual void Connect_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- virtual void Send_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e, Platform::String^ input);
-
- virtual Windows::Foundation::IAsyncAction^ CancelIO();
-
-private:
- using DataReader = Windows::Storage::Streams::DataReader;
- using DataWriter = Windows::Storage::Streams::DataWriter;
- using Args = ClientArgs;
-
- void OnConnection(StreamSocket^);
-
- void SetConnected(bool connected);
- bool IsConnected() const;
-
- void ReceiveLoop(StreamSocket^, DataReader^);
- void Receive(DataReader^, unsigned int strLen);
-
- void SendMessage(DataWriter^, String^ msg);
-
- DataReader^ GetDataReader();
- DataWriter^ GetDataWriter();
-
- IAsyncThreadNotify^ _notify;
- StreamSocket^ _client;
- Args^ _args;
- bool _connected = false;
- DataReader^ _dataReader;
- DataWriter^ _dataWriter;
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/StreamListenerContext.cpp b/examples/apps/windows/StreamListenerContext.cpp
deleted file mode 100644
index 78520294a..000000000
--- a/examples/apps/windows/StreamListenerContext.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.h"
-#include
-#include "StreamListenerContext.h"
-
-using namespace ot;
-
-using namespace Concurrency;
-using namespace Platform;
-using namespace Windows::ApplicationModel::Core;
-using namespace Windows::Foundation;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::Networking::Sockets;
-using namespace Windows::UI::Xaml;
-using namespace Windows::UI::Xaml::Controls;
-using namespace Windows::UI::Xaml::Controls::Primitives;
-using namespace Windows::UI::Xaml::Data;
-using namespace Windows::UI::Xaml::Input;
-using namespace Windows::UI::Xaml::Media;
-using namespace Windows::UI::Xaml::Navigation;
-
-StreamListenerContext::StreamListenerContext(
- IAsyncThreadNotify^ notify,
- StreamSocketListener^ listener,
- ListenerArgs^ args) :
- _notify{ std::move(notify) },
- _listener{ std::move(listener) },
- _args{ std::move(args) }
-{
-}
-
-StreamListenerContext::~StreamListenerContext()
-{
- // A Listener can be closed in two ways:
- // - explicitly: using the 'delete' keyword (listener is closed even if there are outstanding references to it).
- // - implicitly: removing the last reference to it (i.e., falling out-of-scope).
- //
- // When a Socket is closed implicitly, it can take several seconds for the local port being used
- // by it to be freed/reclaimed by the lower networking layers. During that time, other sockets on the machine
- // will not be able to use the port. Thus, it is strongly recommended that Socket instances be explicitly
- // closed before they go out of scope(e.g., before application exit). The call below explicitly closes the socket.
- if (_listener != nullptr)
- {
- delete _listener;
- _listener = nullptr;
- }
-}
-
-void
-StreamListenerContext::Listen_Click(
- Object^ sender,
- RoutedEventArgs^ e)
-{
- task removeContext;
-
- if (CoreApplication::Properties->HasKey("listenerContext"))
- {
- auto listenerContext = dynamic_cast(
- CoreApplication::Properties->Lookup("listenerContext"));
- if (listenerContext == nullptr)
- {
- throw ref new FailureException(L"No listenerContext");
- }
-
- removeContext = create_task(listenerContext->CancelIO()).then(
- []()
- {
- CoreApplication::Properties->Remove("listenerContext");
- });
- }
- else
- {
- removeContext = create_task([]() {});
- }
-
- _listener->ConnectionReceived += ref new ConnectionHandler(
- this, &StreamListenerContext::OnConnection);
-
- removeContext.then([this](task prevTask)
- {
- try
- {
- // Try getting an exception.
- prevTask.get();
-
- // Events cannot be hooked up directly to the ScenarioInput1 object, as the object can fall out-of-scope and be
- // deleted. This would render any event hooked up to the object ineffective. The ListenerContext guarantees that
- // both the listener and object that serves its events have the same lifetime.
- CoreApplication::Properties->Insert("listenerContext", this);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread(
- "Remove listenerContext error: " + ex->Message,
- NotifyType::Error);
- }
- catch (task_canceled&)
- {
- }
- }).then([this]()
- {
- _notify->NotifyFromAsyncThread("Start listening", NotifyType::Status);
-
- create_task(_listener->BindEndpointAsync(_args->ServerHostName, _args->ServerPort)).then(
- [this](task prevTask)
- {
- try
- {
- // Try getting an exception.
- prevTask.get();
- _notify->NotifyFromAsyncThread(
- "Listening on address " + _args->ServerHostName->CanonicalName,
- NotifyType::Status);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread(
- "Start listening failed with error: " + ex->Message,
- NotifyType::Error);
- CoreApplication::Properties->Remove("listenerContext");
- }
- });
- });
-}
-
-IAsyncAction^
-StreamListenerContext::CancelIO()
-{
- return _listener->CancelIOAsync();
-}
-
-void
-StreamListenerContext::OnConnection(
- StreamSocketListener^ listener,
- ConnectionReceivedEventArgs^ args)
-{
- auto dataReader = ref new DataReader(args->Socket->InputStream);
- auto dataWriter = ref new DataWriter(args->Socket->OutputStream);
-
- ReceiveLoop(args->Socket, dataReader, dataWriter);
-}
-
-void
-StreamListenerContext::ReceiveLoop(
- StreamSocket^ streamSocket,
- DataReader^ dataReader,
- DataWriter^ dataWriter)
-{
- // Read first 4 bytes (length of the subsequent string).
- create_task(dataReader->LoadAsync(sizeof(UINT32))).then(
- [this, streamSocket, dataReader, dataWriter](unsigned int size)
- {
- if (size < sizeof(UINT32))
- {
- // The underlying socket was closed before we were able to read the whole data.
- cancel_current_task();
- }
-
- unsigned int strLen = dataReader->ReadUInt32();
- return create_task(dataReader->LoadAsync(strLen)).then(
- [this, dataReader, dataWriter, strLen](unsigned int actualStrLen)
- {
- if (actualStrLen != strLen)
- {
- // The underlying socket was closed before we were able to read the whole data.
- cancel_current_task();
- }
-
- Receive(dataReader, strLen, dataWriter);
- });
- }).then([this, streamSocket, dataReader, dataWriter](task previousTask)
- {
- try
- {
- // Try getting all exceptions from the continuation chain above this point.
- previousTask.get();
-
- // Everything went ok, so try to receive another string. The receive will continue until the stream is
- // broken (i.e. peer closed the socket).
- ReceiveLoop(streamSocket, dataReader, dataWriter);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread("Read stream failed with error: " + ex->Message,
- NotifyType::Error);
-
- // Explicitly close the socket.
- delete streamSocket;
- }
- catch (task_canceled&)
- {
- // Do not print anything here - this will usually happen because user closed the client socket.
-
- // Explicitly close the socket.
- delete streamSocket;
- }
- });
-}
-
-void
-StreamListenerContext::Receive(
- DataReader^ dataReader,
- unsigned int strLen,
- DataWriter^ dataWriter)
-{
- if (!strLen)
- {
- return;
- }
-
- auto msg = dataReader->ReadString(strLen);
- _notify->NotifyFromAsyncThread("Received data from client: \"" + msg + "\"",
- NotifyType::Status);
- auto echo = CreateEchoMessage(msg);
- EchoMessage(dataWriter, echo);
-}
-
-String^
-StreamListenerContext::CreateEchoMessage(
- String^ msg)
-{
- wchar_t buf[256];
- auto len = swprintf_s(buf, L"Server%s received data from client : \"%s\"",
- _args->ServerName->IsEmpty() ? L"" : (" " + _args->ServerName)->Data(), msg->Data());
-
- len += swprintf_s(&buf[len], _countof(buf) - len, L" - got %d chars",
- msg->Length());
- return ref new String(buf);
-}
-
-void
-StreamListenerContext::EchoMessage(
- DataWriter^ dataWriter,
- String^ echo)
-{
- try
- {
- dataWriter->WriteUInt32(echo->Length());
- dataWriter->WriteString(echo);
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread("Echoing failed with error: " + ex->Message,
- NotifyType::Error);
- }
-
- create_task(dataWriter->StoreAsync()).then(
- [this](task writeTask)
- {
- try
- {
- // Try getting all exceptions from the continuation chain above this point.
- writeTask.get();
- }
- catch (Exception^ ex)
- {
- _notify->NotifyFromAsyncThread("Echo message with an error: " + ex->Message,
- NotifyType::Error);
- }
- });
-}
diff --git a/examples/apps/windows/StreamListenerContext.h b/examples/apps/windows/StreamListenerContext.h
deleted file mode 100644
index ab9affdc5..000000000
--- a/examples/apps/windows/StreamListenerContext.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#include "IListenerContext.h"
-#include "IAsyncThreadNotify.h"
-#include "ListenerArgs.h"
-
-namespace ot
-{
-
-[Windows::Foundation::Metadata::WebHostHidden]
-public ref class StreamListenerContext sealed : public IListenerContext
-{
-public:
- using StreamSocketListener = Windows::Networking::Sockets::StreamSocketListener;
-
- StreamListenerContext(IAsyncThreadNotify^ notify, StreamSocketListener^ listener, ListenerArgs^ args);
- virtual ~StreamListenerContext();
-
- virtual void Listen_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- virtual Windows::Foundation::IAsyncAction^ CancelIO();
-
-private:
- using ConnectionReceivedEventArgs = Windows::Networking::Sockets::StreamSocketListenerConnectionReceivedEventArgs;
- using ConnectionHandler = Windows::Foundation::TypedEventHandler;
- using DataReader = Windows::Storage::Streams::DataReader;
- using DataWriter = Windows::Storage::Streams::DataWriter;
- using Listener = StreamSocketListener;
- using StreamSocket = Windows::Networking::Sockets::StreamSocket;
- using Args = ListenerArgs;
-
- void OnConnection(StreamSocketListener^ listener, ConnectionReceivedEventArgs^ args);
- void ReceiveLoop(StreamSocket^, DataReader^, DataWriter^);
- void Receive(DataReader^, unsigned int strLen, DataWriter^);
- String^ CreateEchoMessage(String^ msg);
- void EchoMessage(DataWriter^, String^ echo);
-
- IAsyncThreadNotify^ _notify;
- Listener^ _listener;
- Args^ _args;
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/TalkConsts.h b/examples/apps/windows/TalkConsts.h
deleted file mode 100644
index 100faf55d..000000000
--- a/examples/apps/windows/TalkConsts.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-namespace ot
-{
-
-struct TalkConsts
-{
- static constexpr unsigned short DEF_SERVER_PORT = 51000;
- static constexpr unsigned short DEF_CLIENT_PORT_INIT = 51100;
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/TalkGrid.xaml b/examples/apps/windows/TalkGrid.xaml
deleted file mode 100644
index 5d8aa2ed9..000000000
--- a/examples/apps/windows/TalkGrid.xaml
+++ /dev/null
@@ -1,108 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/apps/windows/TalkGrid.xaml.cpp b/examples/apps/windows/TalkGrid.xaml.cpp
deleted file mode 100644
index 632c26daf..000000000
--- a/examples/apps/windows/TalkGrid.xaml.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.h"
-#include "TalkGrid.xaml.h"
-#include "ClientControl.xaml.h"
-#include "ServerControl.xaml.h"
-
-using namespace ot;
-
-using namespace Platform;
-using namespace Windows::Foundation;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::UI;
-using namespace Windows::UI::Core;
-using namespace Windows::UI::Xaml;
-using namespace Windows::UI::Xaml::Controls;
-using namespace Windows::UI::Xaml::Controls::Primitives;
-using namespace Windows::UI::Xaml::Data;
-using namespace Windows::UI::Xaml::Input;
-using namespace Windows::UI::Xaml::Media;
-using namespace Windows::UI::Xaml::Navigation;
-
-// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
-
-TalkGrid::TalkGrid()
-{
- InitializeComponent();
-
- TcpRadio->IsChecked = true;
- ServerRadio->IsChecked = true;
-}
-
-
-void
-TalkGrid::Init(
- IMainPageUIElements^ mainPageUIElements)
-{
- ServerRole->Init(this, mainPageUIElements);
- ClientRole->Init(this, mainPageUIElements);
-}
-
-void
-TalkGrid::NotifyFromAsyncThread(
- String^ message,
- NotifyType type)
-{
- Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
- ref new DispatchedHandler([this, message, type]()
- {
- Notify(message, type);
- }));
-}
-
-void
-TalkGrid::Notify(
- String^ message,
- NotifyType type)
-{
- switch (type)
- {
- case NotifyType::Status:
- StatusBorder->Background = ref new SolidColorBrush(Colors::Green);
- break;
- case NotifyType::Error:
- StatusBorder->Background = ref new SolidColorBrush(Colors::Red);
- break;
- default:
- break;
- }
-
- StatusBlock->Text = message;
-
- // Collapse the StatusBlock if it has no text to conserve real estate.
- if (StatusBlock->Text != "")
- {
- StatusBorder->Visibility = Xaml::Visibility::Visible;
- }
- else
- {
- StatusBorder->Visibility = Xaml::Visibility::Collapsed;
- }
-}
-
-void
-TalkGrid::Protocol_Changed(
- Object^ sender,
- RoutedEventArgs^ e)
-{
- auto radioBtn = dynamic_cast(sender);
- if (!radioBtn)
- {
- return;
- }
-
- auto protocol = (radioBtn == TcpRadio) ? Protocol::TCP : Protocol::UDP;
-
- ServerRole->ProtocolChanged(protocol);
- ClientRole->ProtocolChanged(protocol);
-}
-
-void
-TalkGrid::Role_Changed(
- Object^ sender,
- RoutedEventArgs^ e)
-{
- auto radioBtn = dynamic_cast(sender);
- if (!radioBtn)
- {
- return;
- }
-
- if (radioBtn == ServerRadio)
- {
- // switch to server role UI
- ClientRole->Visibility = Xaml::Visibility::Collapsed;
- ServerRole->Visibility = Xaml::Visibility::Visible;
- }
- else
- {
- // switch to client role UI
- ServerRole->Visibility = Xaml::Visibility::Collapsed;
- ClientRole->Visibility = Xaml::Visibility::Visible;
- }
-}
diff --git a/examples/apps/windows/TalkGrid.xaml.h b/examples/apps/windows/TalkGrid.xaml.h
deleted file mode 100644
index e387095d1..000000000
--- a/examples/apps/windows/TalkGrid.xaml.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#include "TalkGrid.g.h"
-#include "IAsyncThreadNotify.h"
-#include "IMainPageUIElements.h"
-#include "Protocol.h"
-
-namespace ot
-{
-
-[Windows::Foundation::Metadata::WebHostHidden]
-public ref class TalkGrid sealed : public IAsyncThreadNotify
-{
-public:
- TalkGrid();
-
- void Init(IMainPageUIElements^ mainPageUIElements);
-
- // IAsyncThreadMessage
- virtual void NotifyFromAsyncThread(String^ message, NotifyType type);
-
- void Notify(String^ message, NotifyType type);
-
-private:
- // change protocol
- // TCP <-> UDP
- void Protocol_Changed(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-
- // change role from server client (or vice versa)
- void Role_Changed(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/TalkHelper.h b/examples/apps/windows/TalkHelper.h
deleted file mode 100644
index d6fb84910..000000000
--- a/examples/apps/windows/TalkHelper.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-namespace ot
-{
-ref class ClientControl;
-ref class ServerControl;
-
-class TalkHelper
-{
-private:
- friend ref class ClientControl;
- friend ref class ServerControl;
-
- // this is a private method for specific usage, not a general purpose one
- // checks all chars are valid Ipv6 chars in the range [begin, end)
- static bool AllValidIpv6Chars(const wchar_t* begin, const wchar_t* end)
- {
- for (auto it = begin; it != end; ++it)
- {
- auto c = *it;
-
- if ((c >= '0' && c <= '9') || (c == ':') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))
- {
- }
- else
- {
- return false;
- }
- }
-
- return true;
- }
-};
-
-}
diff --git a/examples/apps/windows/otAdapter.h b/examples/apps/windows/otAdapter.h
deleted file mode 100644
index ead05432f..000000000
--- a/examples/apps/windows/otAdapter.h
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#define OTDLL 1
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-using namespace Platform;
-using namespace Platform::Collections;
-using namespace Platform::Metadata;
-using namespace Windows::Foundation::Collections;
-using namespace Windows::Networking;
-
-namespace ot
-{
-
-ref class otAdapter;
-
-public delegate void otAdapterRemovalDelegate(otAdapter^ sender);
-
-public delegate void otIpAddressAddedDelegate(otAdapter^ sender);
-public delegate void otIpAddressRemovedDelegate(otAdapter^ sender);
-public delegate void otIpRlocAddedDelegate(otAdapter^ sender);
-public delegate void otIpRlocRemovedDelegate(otAdapter^ sender);
-public delegate void otIpLinkLocalAddresChangedDelegate(otAdapter^ sender);
-public delegate void otIpMeshLocalAddresChangedDelegate(otAdapter^ sender);
-
-public delegate void otNetRoleChangedDelegate(otAdapter^ sender);
-public delegate void otNetPartitionIdChangedDelegate(otAdapter^ sender);
-public delegate void otNetKeySequenceCounterChangedDelegate(otAdapter^ sender);
-
-public delegate void otThreadChildAddedDelegate(otAdapter^ sender);
-public delegate void otThreadChildRemovedDelegate(otAdapter^ sender);
-public delegate void otThreadNetDataUpdatedDelegate(otAdapter^ sender);
-
-[Flags]
-public enum class otLinkModeFlags : unsigned int
-{
- None = 0,
- RxOnWhenIdle = 0x1, /* 1, if the sender has its receiver on when not transmitting. 0, otherwise. */
- SecureDataRequests = 0x2, /* 1, if the sender will use IEEE 802.15.4 to secure all data requests. 0, otherwise. */
- DeviceType = 0x4, /* 1, if the sender is an FTD. 0, otherwise. */
- NetworkData = 0x8 /* 1, if the sender requires the full Network Data. 0, otherwise. */
-};
-
-public enum class otThreadState
-{
- Offline,
- Disabled,
- Detached,
- Child,
- Router,
- Leader
-};
-
-// Helper class for OpenThread Interface/Adapter specific APIs
-public ref class otAdapter sealed
-{
-private:
-
- void *_Instance;
- #define DeviceInstance ((otInstance*)_Instance)
-
- #define ThrowOnFailure(exp) \
- do { \
- auto res = exp; \
- if (res != 0) \
- throw Exception::CreateException(TheadErrorToHResult(res), #exp); \
- } while (false)
-
-public:
-
-#pragma region Events
-
- event otAdapterRemovalDelegate^ AdapterRemoval;
-
- event otIpAddressAddedDelegate^ IpAddressAdded;
- event otIpAddressRemovedDelegate^ IpAddressRemoved;
- event otIpRlocAddedDelegate^ IpRlocAdded;
- event otIpRlocRemovedDelegate^ IpRlocRemoved;
- event otIpLinkLocalAddresChangedDelegate^ IpLinkLocalAddresChanged;
- event otIpMeshLocalAddresChangedDelegate^ IpMeshLocalAddresChanged;
-
- event otNetRoleChangedDelegate^ NetRoleChanged;
- event otNetPartitionIdChangedDelegate^ NetPartitionIdChanged;
- event otNetKeySequenceCounterChangedDelegate^ NetKeySequenceCounterChanged;
-
- event otThreadChildAddedDelegate^ ThreadChildAdded;
- event otThreadChildRemovedDelegate^ ThreadChildRemoved;
- event otThreadNetDataUpdatedDelegate^ ThreadNetDataUpdated;
-
-#pragma endregion
-
-#pragma region Properties
-
- property IntPtr RawHandle
- {
- IntPtr get() { return _Instance; }
- }
-
- property Guid InterfaceGuid
- {
- Guid get() { return otGetDeviceGuid(DeviceInstance); }
- }
-
- property uint32_t IfIndex
- {
- uint32_t get() { return otGetDeviceIfIndex(DeviceInstance); }
- }
-
- property uint32_t CompartmentId
- {
- uint32_t get() { return otGetCompartmentId(DeviceInstance); }
- }
-
-#pragma region Link Layer
-
- property signed int /*int8_t*/ TransmitPower
- {
- signed int get() {
- int8_t value;
- ThrowOnFailure(otPlatRadioGetTransmitPower(DeviceInstance, &value));
- return value;
- }
- void set(signed int value)
- {
- if (value > 127) throw Exception::CreateException(E_INVALIDARG);
- ThrowOnFailure(otPlatRadioSetTransmitPower(DeviceInstance, (int8_t)value);
- }
- }
-
- property uint32_t PollPeriod
- {
- uint32_t get() { return otLinkGetPollPeriod(DeviceInstance); }
- void set(uint32_t value) { ThrowOnFailure(otLinkSetPollPeriod(DeviceInstance, value)); }
- }
-
- property uint8_t Channel
- {
- uint8_t get() { return otLinkGetChannel(DeviceInstance); }
- void set(uint8_t value) { ThrowOnFailure(otLinkSetChannel(DeviceInstance, value)); }
- }
-
- property uint16_t PanId
- {
- uint16_t get() { return otLinkGetPanId(DeviceInstance); }
- void set(uint16_t value) { ThrowOnFailure(otLinkSetPanId(DeviceInstance, value)); }
- }
-
- property uint16_t ShortAddress
- {
- uint16_t get() { return otLinkGetShortAddress(DeviceInstance); }
- }
-
- property uint64_t ExtendedAddress
- {
- uint64_t get()
- {
- auto addr = otLinkGetExtendedAddress(DeviceInstance);
- auto ret = *(uint64_t*)addr;
- otFreeMemory(addr);
- return ret;
- }
- void set(uint64_t value)
- {
- ThrowOnFailure(otLinkSetExtendedAddress(DeviceInstance, (otExtAddress*)&value));
- }
- }
-
- property uint64_t FactoryAssignedIeeeEui64
- {
- uint64_t get()
- {
- uint64_t addr;
- otLinkGetFactoryAssignedIeeeEui64(DeviceInstance, (otExtAddress*)&addr);
- return addr;
- }
- }
-
- property uint64_t JoinerId
- {
- uint64_t get()
- {
- uint64_t addr;
- otJoinerGetId(DeviceInstance, (otExtAddress*)&addr);
- return addr;
- }
- }
-
-#pragma endregion
-
-#pragma region IP Layer
-
- property bool IpEnabled
- {
- bool get() { return otIp6IsEnabled(DeviceInstance); }
- void set(bool value) { ThrowOnFailure(otIp6SetEnabled(DeviceInstance, value)); }
- }
-
-#pragma endregion
-
-#pragma region Thread Layer
-
- property uint64_t ExtendedPanId
- {
- uint64_t get()
- {
- auto panid = otThreadGetExtendedPanId(DeviceInstance);
- auto ret = *(uint64_t*)panid;
- otFreeMemory(panid);
- return ret;
- }
- void set(uint64_t value)
- {
- otThreadSetExtendedPanId(DeviceInstance, (uint8_t*)&value);
- }
- }
-
- property otLinkModeFlags LinkMode
- {
- otLinkModeFlags get()
- {
- auto linkmode = otThreadGetLinkMode(DeviceInstance);
- otLinkModeFlags flags = otLinkModeFlags::None;
- if (linkmode.mRxOnWhenIdle) flags = flags | otLinkModeFlags::RxOnWhenIdle;
- if (linkmode.mSecureDataRequests) flags = flags | otLinkModeFlags::SecureDataRequests;
- if (linkmode.mDeviceType) flags = flags | otLinkModeFlags::DeviceType;
- if (linkmode.mNetworkData) flags = flags | otLinkModeFlags::NetworkData;
- return flags;
- }
- void set(otLinkModeFlags value)
- {
- otLinkModeConfig linkmode = { 0 };
- if ((value & otLinkModeFlags::RxOnWhenIdle) != otLinkModeFlags::None)
- linkmode.mRxOnWhenIdle = true;
- if ((value & otLinkModeFlags::SecureDataRequests) != otLinkModeFlags::None)
- linkmode.mSecureDataRequests = true;
- if ((value & otLinkModeFlags::DeviceType) != otLinkModeFlags::None)
- linkmode.mDeviceType = true;
- if ((value & otLinkModeFlags::NetworkData) != otLinkModeFlags::None)
- linkmode.mNetworkData = true;
- ThrowOnFailure(otThreadSetLinkMode(DeviceInstance, linkmode));
- }
- }
-
- static uint32_t charToValue(wchar_t c)
- {
- if (c >= L'a' && c <= L'f')
- {
- return c - L'a';
- }
- else if (c >= L'A' && c <= L'F')
- {
- return c - L'A';
- }
- else if (c >= L'0' && c <= L'9')
- {
- return c - L'0';
- }
- else
- {
- throw Exception::CreateException(E_INVALIDARG);
- }
- }
-
- property String^ MasterKey
- {
- String^ get()
- {
- constexpr char hexmap[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
- auto key = otThreadGetMasterKey(DeviceInstance);
- WCHAR szKey[OT_MASTER_KEY_SIZE * 2 + 1] = { 0 };
- for (uint8_t i = 0; i < OT_MASTER_KEY_SIZE; i++)
- {
- szKey[2 * i] = hexmap[(key->m8[i] & 0xF0) >> 4];
- szKey[2 * i + 1] = hexmap[key->m8[i] & 0x0F];
- }
- otFreeMemory(key);
- return ref new String(szKey);
- }
- void set(String^ value)
- {
- otMasterKey key;
- uint8_t keyLen = 0;
- for (uint32_t i = 0; i < value->Length() - 1; i+=2)
- {
- key.m8[keyLen++] = (uint8_t)((charToValue(value->Data()[i]) << 4) |
- charToValue(value->Data()[i + 1]));
- }
- if (keyLen * 2 == value->Length() - 1)
- {
- key.m8[keyLen++] = (uint8_t)(charToValue(value->Data()[value->Length()-1])) << 4;
- }
- memset(key.m8 + keyLen, 0, sizeof(key) - keyLen);
- ThrowOnFailure(otThreadSetMasterKey(DeviceInstance, &key));
- }
- }
-
- property String^ NetworkName
- {
- String^ get()
- {
- auto _name = otThreadGetNetworkName(DeviceInstance);
- WCHAR name[OT_NETWORK_NAME_MAX_SIZE + 1];
- MultiByteToWideChar(CP_UTF8, 0, _name, -1, name, ARRAYSIZE(name));
- otFreeMemory(_name);
- return ref new String(name);
- }
- void set(String^ value)
- {
- char name[OT_NETWORK_NAME_MAX_SIZE + 1];
- auto len = WideCharToMultiByte(CP_UTF8, 0, value->Data(), -1, name, ARRAYSIZE(name), nullptr, nullptr);
- if (len <= 0) throw Exception::CreateException(E_INVALIDARG);
- ThrowOnFailure(otThreadSetNetworkName(DeviceInstance, name));
- }
- }
-
- property uint8_t MaxAllowedChildren
- {
- uint8_t get() { return otThreadGetMaxAllowedChildren(DeviceInstance); }
- void set(uint8_t value) { ThrowOnFailure(otThreadSetMaxAllowedChildren(DeviceInstance, value)); }
- }
-
- property uint32_t ChildTimeout
- {
- uint32_t get() { return otThreadGetChildTimeout(DeviceInstance); }
- void set(uint32_t value) { otThreadSetChildTimeout(DeviceInstance, value); }
- }
-
- property bool ThreadEnabled
- {
- //bool get() { return otIsThreadStarted(DeviceInstance); }
- void set(bool value) { ThrowOnFailure(otThreadSetEnabled(DeviceInstance, value)); }
- }
-
- property bool AutoStart
- {
- bool get() { return otThreadGetAutoStart(DeviceInstance); }
- void set(bool value) { ThrowOnFailure(otThreadSetAutoStart(DeviceInstance, value)); }
- }
-
- property bool Singleton
- {
- bool get() { return otThreadIsSingleton(DeviceInstance); }
- }
-
- property bool RouterRoleEnabled
- {
- bool get() { return otThreadIsRouterRoleEnabled(DeviceInstance); }
- void set(bool value) { otThreadSetRouterRoleEnabled(DeviceInstance, value); }
- }
-
- property uint8_t PreferredRouterId
- {
- void set(uint8_t value) { ThrowOnFailure(otThreadSetPreferredRouterId(DeviceInstance, value)); }
- }
-
- property HostName^ MeshLocalEid
- {
- HostName^ get()
- {
- auto addr = otThreadGetMeshLocalEid(DeviceInstance);
- WCHAR szAddr[46];
- RtlIpv6AddressToString((IN6_ADDR*)addr, szAddr);
- otFreeMemory(addr);
- return ref new HostName(ref new String(szAddr));
- }
- }
-
- property HostName^ LeaderRloc
- {
- HostName^ get()
- {
- IN6_ADDR addr;
- ThrowOnFailure(otThreadGetLeaderRloc(DeviceInstance, (otIp6Address*)&addr));
- WCHAR szAddr[46];
- RtlIpv6AddressToString(&addr, szAddr);
- return ref new HostName(ref new String(szAddr));
- }
- }
-
- property uint8_t LocalLeaderWeight
- {
- uint8_t get() { return otThreadGetLocalLeaderWeight(DeviceInstance); }
- void set(uint8_t value) { otThreadSetLocalLeaderWeight(DeviceInstance, value); }
- }
-
- property uint32_t LocalLeaderPartitionId
- {
- uint32_t get() { return otThreadGetLocalLeaderPartitionId(DeviceInstance); }
- void set(uint32_t value) { otThreadSetLocalLeaderPartitionId(DeviceInstance, value); }
- }
-
- property uint8_t LeaderWeight
- {
- uint8_t get() { return otThreadGetLeaderWeight(DeviceInstance); }
- }
-
- property uint32_t LeaderRouterId
- {
- uint32_t get() { return otThreadGetLeaderRouterId(DeviceInstance); }
- }
-
- property uint32_t PartitionId
- {
- uint32_t get() { return otThreadGetPartitionId(DeviceInstance); }
- }
-
- property uint16_t Rloc16
- {
- uint16_t get() { return otThreadGetRloc16(DeviceInstance); }
- }
-
- property otThreadState State
- {
- otThreadState get()
- {
- return (otThreadState)otThreadGetDeviceRole(DeviceInstance);
- }
- }
-
-#pragma endregion
-
-#pragma endregion
-
-#pragma region Constructor/Destructor
-
- otAdapter(_In_ IntPtr /*otInstance**/ aInstance)
- {
- _Instance = (void*)aInstance;
-
- IInspectable* pInspectable = reinterpret_cast(this);
-
- // Register for device availability callbacks
- otSetStateChangedCallback(DeviceInstance, ThreadStateChangeCallback, pInspectable);
- }
-
- virtual ~otAdapter()
- {
- // Unregister for callbacks for the device
- otSetStateChangedCallback(DeviceInstance, nullptr, nullptr);
-
- // Free the device
- otFreeMemory(DeviceInstance);
- }
-
-#pragma endregion
-
-#pragma region Functions
-
- void PlatformReset()
- {
- otInstanceReset(DeviceInstance);
- }
-
- void FactoryReset()
- {
- otInstanceFactoryReset(DeviceInstance);
- }
-
- void BecomeRouter()
- {
- ThrowOnFailure(otThreadBecomeRouter(DeviceInstance));
- }
-
- void BecomeLeader()
- {
- ThrowOnFailure(otThreadBecomeLeader(DeviceInstance));
- }
-
-#pragma endregion
-
-internal:
-
- void InvokeAdapterRemoval()
- {
- AdapterRemoval(this);
- }
-
-private:
-
- friend ref class otApi;
-
- static void OTCALL
- ThreadStateChangeCallback(
- uint32_t aFlags,
- _In_ void* aContext
- )
- {
- IInspectable* pInspectable = (IInspectable*)aContext;
- otAdapter^ pThis = reinterpret_cast(pInspectable);
-
- if (aFlags & OT_CHANGED_IP6_ADDRESS_ADDED)
- {
- pThis->IpAddressAdded(pThis);
- }
-
- if (aFlags & OT_CHANGED_IP6_ADDRESS_REMOVED)
- {
- pThis->IpAddressRemoved(pThis);
- }
-
- if (aFlags & OT_CHANGED_THREAD_RLOC_ADDED)
- {
- pThis->IpRlocAdded(pThis);
- }
-
- if (aFlags & OT_CHANGED_THREAD_RLOC_REMOVED)
- {
- pThis->IpRlocRemoved(pThis);
- }
-
- if (aFlags & OT_CHANGED_THREAD_LL_ADDR)
- {
- pThis->IpLinkLocalAddresChanged(pThis);
- }
-
- if (aFlags & OT_CHANGED_THREAD_ML_ADDR)
- {
- pThis->IpMeshLocalAddresChanged(pThis);
- }
-
- if (aFlags & OT_CHANGED_THREAD_ROLE)
- {
- pThis->NetRoleChanged(pThis);
- }
-
- if (aFlags & OT_CHANGED_THREAD_PARTITION_ID)
- {
- pThis->NetPartitionIdChanged(pThis);
- }
-
- if (aFlags & OT_CHANGED_THREAD_KEY_SEQUENCE_COUNTER)
- {
- pThis->NetKeySequenceCounterChanged(pThis);
- }
-
- if (aFlags & OT_CHANGED_THREAD_CHILD_ADDED)
- {
- pThis->ThreadChildAdded(pThis);
- }
-
- if (aFlags & OT_CHANGED_THREAD_CHILD_REMOVED)
- {
- pThis->ThreadChildRemoved(pThis);
- }
-
- if (aFlags & OT_CHANGED_THREAD_NETDATA)
- {
- pThis->ThreadNetDataUpdated(pThis);
- }
- }
-
- static HRESULT
- TheadErrorToHResult(
- int /* otError */ error
- )
- {
- switch (error)
- {
- case OT_ERROR_NO_BUFS: return E_OUTOFMEMORY;
- case OT_ERROR_DROP:
- case OT_ERROR_NO_ROUTE: return HRESULT_FROM_WIN32(ERROR_NETWORK_UNREACHABLE);
- case OT_ERROR_INVALID_ARGS: return E_INVALIDARG;
- case OT_ERROR_SECURITY: return E_ACCESSDENIED;
- case OT_ERROR_NOT_CAPABLE:
- case OT_ERROR_NOT_IMPLEMENTED: return E_NOTIMPL;
- case OT_ERROR_INVALID_STATE: return E_NOT_VALID_STATE;
- case OT_ERROR_NOT_FOUND: return HRESULT_FROM_WIN32(ERROR_NOT_FOUND);
- case OT_ERROR_ALREADY: return HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS);
- case OT_ERROR_RESPONSE_TIMEOUT: return HRESULT_FROM_WIN32(ERROR_TIMEOUT);
- default: return E_FAIL;
- }
- }
-};
-
-} // namespace ot
-
diff --git a/examples/apps/windows/otApi.h b/examples/apps/windows/otApi.h
deleted file mode 100644
index 3a0a001c8..000000000
--- a/examples/apps/windows/otApi.h
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
-* Copyright (c) 2016, The OpenThread Authors.
-* 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 copyright holder 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 COPYRIGHT HOLDER 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.
-*/
-
-#pragma once
-
-#include "otAdapter.h"
-#include
-
-using namespace Platform;
-using namespace Platform::Collections;
-using namespace Windows::Foundation::Collections;
-
-#define MAC8_FORMAT L"%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X"
-#define MAC8_ARG(mac) mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], mac[6], mac[7]
-
-namespace ot
-{
-
-public delegate void otAdapterArrivalDelegate(otAdapter^ aAdapter);
-
-// Helper class for OpenThread API
-public ref class otApi sealed
-{
-private:
-
- void *_apiInstance;
- #define ApiInstance ((otApiInstance*)_apiInstance)
-
- CRITICAL_SECTION _cs;
- Vector^ _adapters;
-
-public:
-
- // Event for device availability changes
- event otAdapterArrivalDelegate^ AdapterArrival;
-
- property IntPtr RawHandle
- {
- IntPtr get() { return _apiInstance; }
- }
-
- // Constructor
- otApi() :
- _adapters(ref new Vector())
- {
- // Initialize the API handle
- _apiInstance = otApiInit();
- if (_apiInstance == nullptr)
- {
- throw Exception::CreateException(E_UNEXPECTED, L"otApiInit failed.");
- }
-
- InitializeCriticalSection(&_cs);
-
- IInspectable* pInspectable = reinterpret_cast(this);
-
- // Register for device availability callbacks
- otSetDeviceAvailabilityChangedCallback(ApiInstance, ThreadDeviceAvailabilityCallback, pInspectable);
-
- // Query list of devices
- auto deviceList = otEnumerateDevices(ApiInstance);
- if (deviceList)
- {
- EnterCriticalSection(&_cs);
-
- // Add each adapter to our cache unless it already was inserted from a notification
- for (DWORD i = 0; i < deviceList->aDevicesLength; i++)
- {
- if (GetAdapter(deviceList->aDevices[i]) == nullptr)
- {
- auto deviceInstance = otInstanceInit(ApiInstance, &deviceList->aDevices[i]);
- if (deviceInstance)
- {
- _adapters->Append(ref new otAdapter(deviceInstance));
- }
- }
- }
-
- LeaveCriticalSection(&_cs);
-
- otFreeMemory(deviceList);
- }
- }
-
- // Destructor
- virtual ~otApi()
- {
- // Clear registration for callbacks
- otSetDeviceAvailabilityChangedCallback(ApiInstance, nullptr, nullptr);
-
- DeleteCriticalSection(&_cs);
-
- // Clean up api
- otApiFinalize(ApiInstance);
- _apiInstance = nullptr;
- }
-
- // Returns the entire list of adapters
- IVectorView^ GetAdapters()
- {
- IVectorView^ adapters;
- EnterCriticalSection(&_cs);
- adapters = _adapters->GetView(); // TODO - Need to copy
- LeaveCriticalSection(&_cs);
- return adapters;
- }
-
- // Helper to get an adapter, given its device guid
- otAdapter^ GetAdapter(Guid aDeviceGuid)
- {
- otAdapter^ ret = nullptr;
-
- EnterCriticalSection(&_cs);
-
- for (auto&& adapter : _adapters)
- {
- if (adapter->InterfaceGuid == aDeviceGuid)
- {
- ret = adapter;
- break;
- }
- }
-
- LeaveCriticalSection(&_cs);
-
- return ret;
- }
-
- // Helper function to convert mac address to string
- static String^ MacToString(uint64_t mac)
- {
- WCHAR szMac[64] = { 0 };
- swprintf_s(szMac, 64, MAC8_FORMAT, MAC8_ARG(((UCHAR*)&mac)));
- return ref new String(szMac);
- }
-
- // Helper function to convert RLOC16/PANID to string
- static String^ Rloc16ToString(uint16_t rloc)
- {
- WCHAR szRloc[16] = { 0 };
- swprintf_s(szRloc, 16, L"0x%X", rloc);
- return ref new String(szRloc);
- }
-
- // Helper function to convert state to string
- static String^ ThreadStateToString(otThreadState state)
- {
- switch (state)
- {
- default:
- case otThreadState::Offline: return L"Offline";
- case otThreadState::Disabled: return L"Disabled";
- case otThreadState::Detached: return L"Disconnected";
- case otThreadState::Child: return L"Connected - Child";
- case otThreadState::Router: return L"Connected - Router";
- case otThreadState::Leader: return L"Connected - Leader";
- }
- }
-
-private:
-
- // Callback from OpenThread indicating arrival or removal of interfaces
- static void OTCALL
- ThreadDeviceAvailabilityCallback(
- bool aAdded,
- const GUID* aDeviceGuid,
- _In_ void* aContext
- )
- {
- IInspectable* pInspectable = (IInspectable*)aContext;
- otApi^ pThis = reinterpret_cast(pInspectable);
-
- if (aAdded)
- {
- otAdapter^ adapter = nullptr;
-
- // Add the device to the list, if it isn't already there
- EnterCriticalSection(&pThis->_cs);
-
- if (pThis->GetAdapter(*aDeviceGuid) == nullptr)
- {
- auto deviceInstance = otInstanceInit((otApiInstance*)pThis->_apiInstance, aDeviceGuid);
- if (deviceInstance)
- {
- pThis->_adapters->Append(adapter = ref new otAdapter(deviceInstance));
- }
- }
-
- LeaveCriticalSection(&pThis->_cs);
-
- if (adapter)
- {
- // Send a notification of arrival
- pThis->AdapterArrival(adapter);
- }
- }
- else
- {
- otAdapter^ ret = nullptr;
- Guid guid = *aDeviceGuid;
-
- EnterCriticalSection(&pThis->_cs);
-
- // Look up in the cached list of adapters to remove it
- uint32_t i = 0;
- for (auto&& adapter : pThis->_adapters)
- {
- if (adapter->InterfaceGuid == guid)
- {
- ret = adapter;
- pThis->_adapters->RemoveAt(i);
- break;
- }
- i++;
- }
-
- LeaveCriticalSection(&pThis->_cs);
-
- if (ret)
- {
- ret->InvokeAdapterRemoval();
- }
- }
- }
-};
-
-} // namespace ot
diff --git a/examples/apps/windows/pch.cpp b/examples/apps/windows/pch.cpp
deleted file mode 100644
index 34894818c..000000000
--- a/examples/apps/windows/pch.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.h"
diff --git a/examples/apps/windows/pch.h b/examples/apps/windows/pch.h
deleted file mode 100644
index af044ab1f..000000000
--- a/examples/apps/windows/pch.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#define _CRT_SECURE_NO_WARNINGS
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include "otApi.h"
-
-#include "App.xaml.h"
diff --git a/examples/drivers/windows/README.md b/examples/drivers/windows/README.md
deleted file mode 100644
index 165a2392c..000000000
--- a/examples/drivers/windows/README.md
+++ /dev/null
@@ -1,169 +0,0 @@
-# OpenThread on Windows #
-
-OpenThread includes Windows 10 drivers necessary for interfacing with UART NCP devices. The design allows for support of both simple radio devices and devices running the complete OpenThread stack.
-
-> **NOTE:** OpenThread's Windows integration has not been actively maintained for some time. While Windows builds are still a part of OpenThread's continuous integration (CI), the Windows CI only tests basic compilation.
-
-## Architecture ##
-
-Details on the architecture can be found [here](https://openthread.io/platforms/windows10).
-
-## Building OpenThread using Windows
-
-To build locally using the Windows platform, use Visual Studio 2015. To build for the POSIX and TI CC2538 platforms, use Bash on Ubuntu on Windows.
-
-All the following steps assume you have already cloned and checked out a branch.
-
-### Visual Studio 2015
-
-To build OpenThread on Windows you need to install the following:
-
-* Any Visual Studio 2015 edition. The [Community](https://www.microsoft.com/en-us/download/details.aspx?id=48146) edition is free. Generally most of the optional features will be required.
-* The [Windows 10 Driver Kit](https://go.microsoft.com/fwlink/p/?LinkId=526733).
-
-Once all these are installed, open the Solution file `etc/visual-studio/openthread.sln`. Select the Configuration and Platform (i.e. Release/x64) and then Build All (F6).
-
-### Bash on Ubuntu on Windows
-
-[Bash on Ubuntu on Windows](https://msdn.microsoft.com/en-us/commandline/wsl/about) is a new feature to Windows 10. To set it up, follow the steps [here](https://msdn.microsoft.com/commandline/wsl/install_guide). Other FAQs can be found [here](https://msdn.microsoft.com/en-us/commandline/wsl/faq).
-
-Once installed, open the "Bash on Ubuntu on Windows" app. Do the following to install everything necessary to build OpenThread.
-
-Make sure line ending are UNIX style:
-
-```
-git config core.autocrlf false
-git rm --cached -r . && git reset --hard
-```
-
-Install the compilers:
-
-```
-apt install gcc
-apt install g++
-```
-
-Install Python (with pexpect):
-
-```
-apt install python
-apt install python-pip
-pip install pexpect
-```
-
-To build the TI CC2538 platform, you need to install the correct toolchain:
-
-```
-add-apt-repository ppa:team-gcc-arm-embedded/ppa
-apt-get update
-apt-get install gcc-arm-embedded
-```
-
-Set up the build environment:
-
-```
-./bootstrap
-```
-
-### Platforms
-
-Before building, manually configure features as desired. For example:
-
-```
-./configure --enable-cli --enable-diag --enable-commissioner --enable-joiner --with-examples=posix
-make
-```
-
-Or clean and build with desired features enabled:
-
-```
-make -f examples/Makefile- clean
-COMMISSIONER=1 JOINER=1 make -f examples/Makefile-
-```
-
-For detailed instructions on building and creating binaries for Windows-supported platforms, see each platform's respective README:
-
-* [POSIX](https://github.com/openthread/openthread/tree/master/examples/platforms/posix)
-* [TI CC2538](https://github.com/openthread/openthread/tree/master/examples/platforms/cc2538)
-* [Nordic nRF52840](https://github.com/openthread/openthread/tree/master/examples/platforms/nrf52840)
-
-## Installing OpenThread on Windows
-
-Microsoft has made available a test VHD specifically modified for virtually testing OpenThread. To get access, please email `nibanks` via his `@microsoft.com` email address.
-
-Once the Windows VHD is loaded and you have gone through OOBE, see `C:\OpenThread\readme.txt` for additional instructions on how to set everything up.
-
-> **Note:** Since none of the binaries mentioned below are production signed; you need to enable test signing on the machine: `bcdedit /set testsigning on`. All these binaries require Windows 10 at a minimum.
-
-Since most of these drivers are still under development, it is recommended to also have a kernel debugger configured for the test machine.
-
-### otlwf.sys & otapi.dll
-
-The filter driver `otlwf.sys` exposes the IOCTL interface that `otapi.dll` uses and houses the bulk of the actual Thread logic. `otapi.dll` exposes the C interface for user mode applications to use to control the Thread interfaces.
-
-1. Download the latest platform binary on AppVeyor:
- 1. Go to the [latest build](https://ci.appveyor.com/project/jwhui/openthread) page
- 1. Select the desired platform (x64, x86, arm)
- 1. On the platform page, select **ARTIFACTS**
- 1. Download the release.zip file for that platform
-1. Extract the files to a temporary location
-1. Open an admin command prompt in the temporary location
-1. Run the `install_otlwf.cmd` file
-1. On **non-IoT platforms**, install the [Visual C++ Redistributable for Visual Studio 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48145)
-1. **Note:** A reboot is required, but can be done after all installation is complete.
-
-### ottmp.sys (Miniport for Serial Devices)
-
-The miniport driver `ottmp.sys` binds to serial devices on the machine and exposes them to `otlwf.sys`. It is only needed if you are connecting to an actual device (such as the TI CC2538 or Nordic Semiconductor nRF52840 device).
-
-1. Open an admin command prompt (same location as above).
-1. Run the install_ottmp.cmd file.
-1. **Note:** A reboot is required, but can be done after all installation is complete.
-1. Once the test machine boots and the serial device is connected, manually restart the miniport so that it can find the serial device. **This will have to be done for every reboot**:
-```
-devcon.exe restart *ottmp*
-```
-
-### Command Line Tool Usage
-
-The command line tool `otCli.exe` exposes many of the APIs in `otApi.dll` via the command line. It is included with the same release binaries downloaded above. See the [CLI example README](https://github.com/openthread/openthread/blob/master/examples/apps/cli/README.md) for more details.
-
-The main differences between `otCli.exe` on Windows and the `ot-cli` on Linux, are the following:
-
-* On Linux, the CLI runs the actual OpenThread stack in-proc. On Windows, it just provides an interface to control the OpenThread stack running either in the installed driver or on the physical device.
-* On Windows, the CLI supports multiple interfaces simultaneously via the `instance` and `instancelist` commands.
-
-The `instance` command allows for getting/setting the current instance that the rest of the commands act on.
-
-```
-> instance 0
-Done
-> instance
-[0] {01234567-89AB-CDEF-0123-4567890ABCDE} (Compartment 1)
-```
-
-The `instancelist` command queries for all available instances/interfaces on the machine.
-
-```
-> instancelist
-1 instances found:
-[0] {01234567-89AB-CDEF-0123-4567890ABCDE} (Compartment 1)
-```
-
-### Sample Universal App
-
-The latest builds of the sample universal app can be downloaded from the [latest AppVeyor build](https://ci.appveyor.com/project/jwhui/openthread).
-
-### Running Python Certification Tests
-
-The Python certification tests approximate the testing done for real certification. On Windows they are run using virtual OpenThread devices. To set up the environment:
-
-1. Install Python 3.6 to `C:\Python36` for all users. Make sure to add the install path to `PATH`.
-1. Install the Python crypto libraries: `python.exe C:\Python36\Scripts\pip.exe install pycryptodome==3.4.3`
-1. Copy Python cert scripts to the machine (to a 'scripts' folder)
-
-To run all the tests:
-
-```
-otTestRunner.exe scripts Cert_* parallel:4 retry:2
-```
\ No newline at end of file
diff --git a/examples/drivers/windows/include/openthread-core-windows-config.h b/examples/drivers/windows/include/openthread-core-windows-config.h
deleted file mode 100644
index c0af32a10..000000000
--- a/examples/drivers/windows/include/openthread-core-windows-config.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * This file includes Windows compile-time configuration constants
- * for OpenThread.
- */
-
-#ifndef OPENTHREAD_CORE_WINDOWS_CONFIG_H_
-#define OPENTHREAD_CORE_WINDOWS_CONFIG_H_
-
-/**
- * @def OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS
- *
- * The number of message buffers in the buffer pool.
- *
- */
-#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 2048
-
-/**
- * @def OPENTHREAD_CONFIG_MAX_CHILDREN
- *
- * The maximum number of children.
- *
- */
-#define OPENTHREAD_CONFIG_MAX_CHILDREN 32
-
-/**
- * @def OPENTHREAD_CONFIG_IP_ADDRS_PER_CHILD
- *
- * The minimum number of supported IPv6 address registrations per child.
- *
- */
-#define OPENTHREAD_CONFIG_IP_ADDRS_PER_CHILD 6
-
-/**
- * @def OPENTHREAD_CONFIG_MAX_JOINER_ENTRIES
- *
- * The maximum number of Joiner entries maintained by the Commissioner.
- *
- */
-#define OPENTHREAD_CONFIG_MAX_JOINER_ENTRIES 16
-
-/**
- * @def OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
- *
- * The message pool is managed by platform defined logic when this flag is set.
- * This feature would typically be used when operating in a multi-threaded system
- * and multiple threads need to access the message pool.
- *
- */
-#define OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT 1
-
-/**
- * @def OPENTHREAD_CONFIG_LOG_LEVEL
- *
- * The log level.
- *
- */
-#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG
-
- /**
- * @def OPENTHREAD_CONFIG_LOG_PKT_DUMP
- *
- * Define to enable log content of packets.
- *
- */
-#define OPENTHREAD_CONFIG_LOG_PKT_DUMP 0
-
-#endif // OPENTHREAD_CORE_WINDOWS_CONFIG_H_
-
diff --git a/examples/drivers/windows/include/otLwfIoctl.h b/examples/drivers/windows/include/otLwfIoctl.h
deleted file mode 100644
index ae2a18769..000000000
--- a/examples/drivers/windows/include/otLwfIoctl.h
+++ /dev/null
@@ -1,748 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines the IOCTL interface for otLwf.sys.
- */
-
-#ifndef __OTLWFIOCTL_H__
-#define __OTLWFIOCTL_H__
-
-__inline LONG ThreadErrorToNtstatus(otError error) { return (LONG)-((int)error); }
-
-// User-mode IOCTL path for CreateFile
-#define OTLWF_IOCLT_PATH TEXT("\\\\.\\\\otlwf")
-
-//
-// IOCLTs and Data Types
-//
-
-#define OTLWF_CTL_CODE(request, method, access) \
- CTL_CODE(FILE_DEVICE_NETWORK, request, method, access)
-
-// Different possible notification types
-typedef enum _OTLWF_NOTIF_TYPE
-{
- OTLWF_NOTIF_UNSPECIFIED,
- OTLWF_NOTIF_DEVICE_AVAILABILITY,
- OTLWF_NOTIF_STATE_CHANGE,
- OTLWF_NOTIF_DISCOVER,
- OTLWF_NOTIF_ACTIVE_SCAN,
- OTLWF_NOTIF_ENERGY_SCAN,
- OTLWF_NOTIF_COMMISSIONER_ENERGY_REPORT,
- OTLWF_NOTIF_COMMISSIONER_PANID_QUERY,
- OTLWF_NOTIF_JOINER_COMPLETE
-
-} OTLWF_NOTIF_TYPE;
-
-#define MAX_ENERGY_REPORT_LENGTH 64
-
-//
-// Queries (async) the next notification in the queue
-//
-#define IOCTL_OTLWF_QUERY_NOTIFICATION \
- OTLWF_CTL_CODE(0, METHOD_BUFFERED, FILE_READ_DATA)
- typedef struct _OTLWF_NOTIFICATION {
- GUID InterfaceGuid;
- OTLWF_NOTIF_TYPE NotifType;
- union
- {
- // Payload for OTLWF_NOTIF_DEVICE_AVAILABILITY
- struct
- {
- BOOLEAN Available;
- } DeviceAvailabilityPayload;
-
- // Payload for OTLWF_NOTIF_STATE_CHANGE
- struct
- {
- uint32_t Flags;
- } StateChangePayload;
-
- // Payload for OTLWF_NOTIF_DISCOVER
- struct
- {
- BOOLEAN Valid;
- otActiveScanResult Results;
- } DiscoverPayload;
-
- // Payload for OTLWF_NOTIF_ACTIVE_SCAN
- struct
- {
- BOOLEAN Valid;
- otActiveScanResult Results;
- } ActiveScanPayload;
-
- // Payload for OTLWF_NOTIF_ENERGY_SCAN
- struct
- {
- BOOLEAN Valid;
- otEnergyScanResult Results;
- } EnergyScanPayload;
-
- // Payload for OTLWF_NOTIF_COMMISSIONER_ENERGY_REPORT
- struct
- {
- uint32_t ChannelMask;
- uint8_t EnergyListLength;
- uint8_t EnergyList[MAX_ENERGY_REPORT_LENGTH];
-
- } CommissionerEnergyReportPayload;
-
- // Payload for OTLWF_NOTIF_COMMISSIONER_PANID_QUERY
- struct
- {
- uint16_t PanId;
- uint32_t ChannelMask;
- } CommissionerPanIdQueryPayload;
-
- // Payload for OTLWF_NOTIF_JOINER_COMPLETE
- struct
- {
- otError Error;
- } JoinerCompletePayload;
- };
- } OTLWF_NOTIFICATION, *POTLWF_NOTIFICATION;
-
-//
-// Enumerates all the Thread interfaces guids
-//
-#define IOCTL_OTLWF_ENUMERATE_DEVICES \
- OTLWF_CTL_CODE(1, METHOD_BUFFERED, FILE_READ_DATA)
- typedef struct _OTLWF_INTERFACE_LIST
- {
- uint16_t cInterfaceGuids;
- GUID InterfaceGuids[1];
- } OTLWF_INTERFACE_LIST, *POTLWF_INTERFACE_LIST;
-
-//
-// Queries the detials of a given device Thread interfaces
-//
-#define IOCTL_OTLWF_QUERY_DEVICE \
- OTLWF_CTL_CODE(2, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid (in)
- typedef struct _OTLWF_DEVICE {
- ULONG CompartmentID;
- } OTLWF_DEVICE, *POTLWF_DEVICE;
-
-//
-// Proxies to ot* APIs in otLwf.sys
-//
-
-/* REMOVED
-#define IOCTL_OTLWF_OT_ENABLED \
- OTLWF_CTL_CODE(100, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // BOOLEAN - aEnabled
-*/
-#define IOCTL_OTLWF_OT_INTERFACE \
- OTLWF_CTL_CODE(101, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // BOOLEAN - aUp
-
-#define IOCTL_OTLWF_OT_THREAD \
- OTLWF_CTL_CODE(102, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // BOOLEAN - aStarted
-
-#define IOCTL_OTLWF_OT_ACTIVE_SCAN \
- OTLWF_CTL_CODE(103, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aScanChannels
- // uint16_t - aScanDuration
-
-#define IOCTL_OTLWF_OT_DISCOVER \
- OTLWF_CTL_CODE(104, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aScanChannels
- // uint16_t - aScanDuration
- // uint16_t - aPanid
-
-#define IOCTL_OTLWF_OT_CHANNEL \
- OTLWF_CTL_CODE(105, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aChannel
-
-#define IOCTL_OTLWF_OT_CHILD_TIMEOUT \
- OTLWF_CTL_CODE(106, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aTimeout
-
-#define IOCTL_OTLWF_OT_EXTENDED_ADDRESS \
- OTLWF_CTL_CODE(107, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otExtAddress - aExtAddress
-
-#define IOCTL_OTLWF_OT_EXTENDED_PANID \
- OTLWF_CTL_CODE(108, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otExtendedPanId - aExtendedPanId
-
-#define IOCTL_OTLWF_OT_LEADER_RLOC \
- OTLWF_CTL_CODE(109, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // otIp6Address - aLeaderRloc
-
-#define IOCTL_OTLWF_OT_LINK_MODE \
- OTLWF_CTL_CODE(110, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otLinkModeConfig - aConfig
-
-#define IOCTL_OTLWF_OT_MASTER_KEY \
- OTLWF_CTL_CODE(111, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otMasterKey - aKey
- // uint8_t - aKeyLength
-
-#define IOCTL_OTLWF_OT_MESH_LOCAL_EID \
- OTLWF_CTL_CODE(112, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // otIp6Address - aMeshLocalEid
-
-#define IOCTL_OTLWF_OT_MESH_LOCAL_PREFIX \
- OTLWF_CTL_CODE(113, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otMeshLocalPrefix - aPrefix
-
-#define IOCTL_OTLWF_OT_NETWORK_DATA_LEADER \
- OTLWF_CTL_CODE(114, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t[] - aData
-
-#define IOCTL_OTLWF_OT_NETWORK_DATA_LOCAL \
- OTLWF_CTL_CODE(115, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t[] - aData
-
-#define IOCTL_OTLWF_OT_NETWORK_NAME \
- OTLWF_CTL_CODE(116, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otNetworkName - aNetworkName
-
-#define IOCTL_OTLWF_OT_PAN_ID \
- OTLWF_CTL_CODE(117, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otPanId - aPanId
-
-#define IOCTL_OTLWF_OT_ROUTER_ROLL_ENABLED \
- OTLWF_CTL_CODE(118, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // BOOLEAN - aEnabled
-
-#define IOCTL_OTLWF_OT_SHORT_ADDRESS \
- OTLWF_CTL_CODE(119, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // otShortAddress - aShortAddress
-
-/* NOT USED
-#define IOCTL_OTLWF_OT_UNICAST_ADDRESSES \
- OTLWF_CTL_CODE(120, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // otNetifAddress[] - aAddresses
-*/
-
-#define IOCTL_OTLWF_OT_ACTIVE_DATASET \
- OTLWF_CTL_CODE(121, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otOperationalDataset - aDataset
-
-#define IOCTL_OTLWF_OT_PENDING_DATASET \
- OTLWF_CTL_CODE(122, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otOperationalDataset - aDataset
-
-#define IOCTL_OTLWF_OT_LOCAL_LEADER_WEIGHT \
- OTLWF_CTL_CODE(123, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aWeight
-
-#define IOCTL_OTLWF_OT_ADD_BORDER_ROUTER \
- OTLWF_CTL_CODE(124, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otBorderRouterConfig - aConfig
-
-#define IOCTL_OTLWF_OT_REMOVE_BORDER_ROUTER \
- OTLWF_CTL_CODE(125, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otIp6Prefix - aPrefix
-
-#define IOCTL_OTLWF_OT_ADD_EXTERNAL_ROUTE \
- OTLWF_CTL_CODE(126, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otExternalRouteConfig - aConfig
-
-#define IOCTL_OTLWF_OT_REMOVE_EXTERNAL_ROUTE \
- OTLWF_CTL_CODE(127, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otIp6Prefix - aPrefix
-
-#define IOCTL_OTLWF_OT_SEND_SERVER_DATA \
- OTLWF_CTL_CODE(128, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
-
-#define IOCTL_OTLWF_OT_CONTEXT_ID_REUSE_DELAY \
- OTLWF_CTL_CODE(129, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aDelay
-
-#define IOCTL_OTLWF_OT_KEY_SEQUENCE_COUNTER \
- OTLWF_CTL_CODE(130, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aKeySequenceCounter
-
-#define IOCTL_OTLWF_OT_NETWORK_ID_TIMEOUT \
- OTLWF_CTL_CODE(131, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aTimeout
-
-#define IOCTL_OTLWF_OT_ROUTER_UPGRADE_THRESHOLD \
- OTLWF_CTL_CODE(132, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aThreshold
-
-#define IOCTL_OTLWF_OT_RELEASE_ROUTER_ID \
- OTLWF_CTL_CODE(133, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aRouterId
-
-#define IOCTL_OTLWF_OT_MAC_WHITELIST_ENABLED \
- OTLWF_CTL_CODE(134, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // BOOLEAN - aEnabled
-
-#define IOCTL_OTLWF_OT_ADD_MAC_WHITELIST \
- OTLWF_CTL_CODE(135, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otExtAddress - aExtAddr
- // int8_t - aRssi (optional)
-
-#define IOCTL_OTLWF_OT_REMOVE_MAC_WHITELIST \
- OTLWF_CTL_CODE(136, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otExtAddress - aExtAddr
-
-#define IOCTL_OTLWF_OT_NEXT_MAC_WHITELIST \
- OTLWF_CTL_CODE(137, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aIterator (input)
- // uint8_t - aNewIterator (output)
- // otMacFilterEntry - aEntry (output)
-
-#define IOCTL_OTLWF_OT_CLEAR_MAC_WHITELIST \
- OTLWF_CTL_CODE(138, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
-
-#define IOCTL_OTLWF_OT_DEVICE_ROLE \
- OTLWF_CTL_CODE(139, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otDeviceRole - aRole
- // otMleAttachFilter - aFilter (only for OT_DEVICE_ROLE_CHILD)
-
-#define IOCTL_OTLWF_OT_CHILD_INFO_BY_ID \
- OTLWF_CTL_CODE(140, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint16_t - aChildId (input)
- // otChildInfo - aChildInfo (output)
-
-#define IOCTL_OTLWF_OT_CHILD_INFO_BY_INDEX \
- OTLWF_CTL_CODE(141, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aChildIndex (input)
- // otChildInfo - aChildInfo (output)
-
-#define IOCTL_OTLWF_OT_EID_CACHE_ENTRY \
- OTLWF_CTL_CODE(142, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aIndex (input)
- // otEidCacheEntry - aEntry (output)
-
-#define IOCTL_OTLWF_OT_LEADER_DATA \
- OTLWF_CTL_CODE(143, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // otLeaderData - aLeaderData
-
-#define IOCTL_OTLWF_OT_LEADER_ROUTER_ID \
- OTLWF_CTL_CODE(144, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aRouterID
-
-#define IOCTL_OTLWF_OT_LEADER_WEIGHT \
- OTLWF_CTL_CODE(145, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aWeight
-
-#define IOCTL_OTLWF_OT_NETWORK_DATA_VERSION \
- OTLWF_CTL_CODE(146, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aVersion
-
-#define IOCTL_OTLWF_OT_PARTITION_ID \
- OTLWF_CTL_CODE(147, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aPartition
-
-#define IOCTL_OTLWF_OT_RLOC16 \
- OTLWF_CTL_CODE(148, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint16_t - aRloc16
-
-#define IOCTL_OTLWF_OT_ROUTER_ID_SEQUENCE \
- OTLWF_CTL_CODE(149, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aIdSequence
-
-#define IOCTL_OTLWF_OT_ROUTER_INFO \
- OTLWF_CTL_CODE(150, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint16_t - aRouterId (input)
- // otRouterInfo - aRouterInfo (output)
-
-#define IOCTL_OTLWF_OT_STABLE_NETWORK_DATA_VERSION \
- OTLWF_CTL_CODE(151, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aVersion
-
-#define IOCTL_OTLWF_OT_MAC_BLACKLIST_ENABLED \
- OTLWF_CTL_CODE(152, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // BOOLEAN - aEnabled
-
-#define IOCTL_OTLWF_OT_ADD_MAC_BLACKLIST \
- OTLWF_CTL_CODE(153, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otExtAddress - aExtAddr
-
-#define IOCTL_OTLWF_OT_REMOVE_MAC_BLACKLIST \
- OTLWF_CTL_CODE(154, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otExtAddress - aExtAddr
-
-#define IOCTL_OTLWF_OT_NEXT_MAC_BLACKLIST \
- OTLWF_CTL_CODE(155, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aIterator (input)
- // uint8_t - aNewIterator (output)
- // otMacFilterEntry - aEntry (output)
-
-#define IOCTL_OTLWF_OT_CLEAR_MAC_BLACKLIST \
- OTLWF_CTL_CODE(156, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
-
-//#define IOCTL_OTLWF_OT_TRANSMIT_POWER \
-// OTLWF_CTL_CODE(157, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // int8_t - aPower
-
-#define IOCTL_OTLWF_OT_NEXT_ON_MESH_PREFIX \
- OTLWF_CTL_CODE(158, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // BOOLEAN - aLocal (input)
- // uint8_t - aIterator (input)
- // uint8_t - aNewIterator (output)
- // otBorderRouterConfig - aConfig (output)
-
-#define IOCTL_OTLWF_OT_POLL_PERIOD \
- OTLWF_CTL_CODE(159, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aPollPeriod
-
-#define IOCTL_OTLWF_OT_LOCAL_LEADER_PARTITION_ID \
- OTLWF_CTL_CODE(160, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aPartitionId
-
-#define IOCTL_OTLWF_OT_PLATFORM_RESET \
- OTLWF_CTL_CODE(162, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
-
-#define IOCTL_OTLWF_OT_PARENT_INFO \
- OTLWF_CTL_CODE(163, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // otRouterInfo - aParentInfo
-
-#define IOCTL_OTLWF_OT_SINGLETON \
- OTLWF_CTL_CODE(164, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // BOOLEAN - aSingleton
-
-#define IOCTL_OTLWF_OT_MAC_COUNTERS \
- OTLWF_CTL_CODE(165, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // otMacCounters - aCounters
-
-#define IOCTL_OTLWF_OT_MAX_CHILDREN \
- OTLWF_CTL_CODE(166, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aMaxChildren
-
-#define IOCTL_OTLWF_OT_COMMISIONER_START \
- OTLWF_CTL_CODE(167, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
-
-#define IOCTL_OTLWF_OT_COMMISIONER_STOP \
- OTLWF_CTL_CODE(168, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
-
-#define OPENTHREAD_PSK_MAX_LENGTH 32
-#define OPENTHREAD_PROV_URL_MAX_LENGTH 64
-#define OPENTHREAD_VENDOR_NAME_MAX_LENGTH 32
-#define OPENTHREAD_VENDOR_MODEL_MAX_LENGTH 32
-#define OPENTHREAD_VENDOR_SW_VERSION_MAX_LENGTH 16
-#define OPENTHREAD_VENDOR_DATA_MAX_LENGTH 64
-typedef struct otCommissionConfig
-{
- char PSKd[OPENTHREAD_PSK_MAX_LENGTH + 1];
- char ProvisioningUrl[OPENTHREAD_PROV_URL_MAX_LENGTH + 1];
- char VendorName[OPENTHREAD_VENDOR_NAME_MAX_LENGTH + 1];
- char VendorModel[OPENTHREAD_VENDOR_MODEL_MAX_LENGTH + 1];
- char VendorSwVersion[OPENTHREAD_VENDOR_SW_VERSION_MAX_LENGTH + 1];
- char VendorData[OPENTHREAD_VENDOR_DATA_MAX_LENGTH + 1];
-} otCommissionConfig;
-
-#define IOCTL_OTLWF_OT_JOINER_START \
- OTLWF_CTL_CODE(169, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otCommissionConfig - aConfig
-
-#define IOCTL_OTLWF_OT_JOINER_STOP \
- OTLWF_CTL_CODE(170, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
-
-#define IOCTL_OTLWF_OT_FACTORY_EUI64 \
- OTLWF_CTL_CODE(171, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // otExtAddress - aEui64
-
-#define IOCTL_OTLWF_OT_JOINER_ID \
- OTLWF_CTL_CODE(172, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // otExtAddress - aEui64
-
-#define IOCTL_OTLWF_OT_ROUTER_DOWNGRADE_THRESHOLD \
- OTLWF_CTL_CODE(173, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aThreshold
-
-#define IOCTL_OTLWF_OT_COMMISSIONER_PANID_QUERY \
- OTLWF_CTL_CODE(174, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint16_t - aPanId
- // uint32_t - aChannekMask
- // otIp6Address - aAddress
-
-#define IOCTL_OTLWF_OT_COMMISSIONER_ENERGY_SCAN \
- OTLWF_CTL_CODE(175, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aChannekMask
- // uint8_t - aCount
- // uint16_t - aPeriod
- // uint16_t - aScanDuration
- // otIp6Address - aAddress
-
-#define IOCTL_OTLWF_OT_ROUTER_SELECTION_JITTER \
- OTLWF_CTL_CODE(176, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aRouterJitter
-
-#define IOCTL_OTLWF_OT_JOINER_UDP_PORT \
- OTLWF_CTL_CODE(177, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint16_t - aJoinerUdpPort
-
-#define IOCTL_OTLWF_OT_SEND_DIAGNOSTIC_GET \
- OTLWF_CTL_CODE(178, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otIp6Address - aDestination
- // uint8_t - aCount
- // uint8_t[aCount] - aTlvTypes
-
-#define IOCTL_OTLWF_OT_SEND_DIAGNOSTIC_RESET \
- OTLWF_CTL_CODE(179, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otIp6Address - aDestination
- // uint8_t - aCount
- // uint8_t[aCount] - aTlvTypes
-
-#define IOCTL_OTLWF_OT_COMMISIONER_ADD_JOINER \
- OTLWF_CTL_CODE(180, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aExtAddressValid
- // otExtAddress - aExtAddress (optional)
- // char[OPENTHREAD_PSK_MAX_LENGTH + 1] - aPSKd
- // uint32_t - aTimeout
-
-#define IOCTL_OTLWF_OT_COMMISIONER_REMOVE_JOINER \
- OTLWF_CTL_CODE(181, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aExtAddressValid
- // otExtAddress - aExtAddress (optional)
-
-#define IOCTL_OTLWF_OT_COMMISIONER_PROVISIONING_URL \
- OTLWF_CTL_CODE(182, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // char[OPENTHREAD_PROV_URL_MAX_LENGTH + 1] - aProvisioningUrl (optional)
-
-#define IOCTL_OTLWF_OT_COMMISIONER_ANNOUNCE_BEGIN \
- OTLWF_CTL_CODE(183, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aChannelMask
- // uint8_t - aCount
- // uint16_t - aPeriod
- // otIp6Address - aAddress
-
-#define IOCTL_OTLWF_OT_ENERGY_SCAN \
- OTLWF_CTL_CODE(184, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aScanChannels
- // uint16_t - aScanDuration
-
-#define IOCTL_OTLWF_OT_SEND_ACTIVE_GET \
- OTLWF_CTL_CODE(185, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aLength
- // uint8_t[aLength] - aTlvTypes
- // otIp6Address - aAddress (optional)
-
-#define IOCTL_OTLWF_OT_SEND_ACTIVE_SET \
- OTLWF_CTL_CODE(186, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otOperationalDataset - aDataset
- // uint8_t - aLength
- // uint8_t[aLength] - aTlvTypes
-
-#define IOCTL_OTLWF_OT_SEND_PENDING_GET \
- OTLWF_CTL_CODE(187, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aLength
- // uint8_t[aLength] - aTlvTypes
- // otIp6Address - aAddress (optional)
-
-#define IOCTL_OTLWF_OT_SEND_PENDING_SET \
- OTLWF_CTL_CODE(188, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otOperationalDataset - aDataset
- // uint8_t - aLength
- // uint8_t[aLength] - aTlvTypes
-
-#define IOCTL_OTLWF_OT_SEND_MGMT_COMMISSIONER_GET \
- OTLWF_CTL_CODE(189, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aLength
- // uint8_t[aLength] - aTlvs
-
-#define IOCTL_OTLWF_OT_SEND_MGMT_COMMISSIONER_SET \
- OTLWF_CTL_CODE(190, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otOperationalDataset - aDataset
- // uint8_t - aLength
- // uint8_t[aLength] - aTlvs
-
-#define IOCTL_OTLWF_OT_KEY_SWITCH_GUARDTIME \
- OTLWF_CTL_CODE(191, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint32_t - aKeySwitchGuardTime
-
-#define IOCTL_OTLWF_OT_FACTORY_RESET \
- OTLWF_CTL_CODE(192, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
-
-#define IOCTL_OTLWF_OT_THREAD_AUTO_START \
- OTLWF_CTL_CODE(193, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // BOOLEAN - aAutoStart
-
-#define IOCTL_OTLWF_OT_PREFERRED_ROUTER_ID \
- OTLWF_CTL_CODE(194, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aRouterId
-
-#define IOCTL_OTLWF_OT_PSKC \
- OTLWF_CTL_CODE(195, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otPSKc - aPSKc
-
-#define IOCTL_OTLWF_OT_PARENT_PRIORITY \
- OTLWF_CTL_CODE(196, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // int8_t - aParentPriority
-
-#define IOCTL_OTLWF_OT_ADD_MAC_FIXED_RSS \
- OTLWF_CTL_CODE(197, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otExtAddress - aExtAddr (optional)
- // int8_t - aRssi
-
-#define IOCTL_OTLWF_OT_REMOVE_MAC_FIXED_RSS \
- OTLWF_CTL_CODE(198, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
- // otExtAddress - aExtAddr (optional)
-
-#define IOCTL_OTLWF_OT_NEXT_MAC_FIXED_RSS \
- OTLWF_CTL_CODE(199, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aIterator (input)
- // uint8_t - aNewIterator (output)
- // otMacFilterEntry - aEntry (output)
-
-#define IOCTL_OTLWF_OT_CLEAR_MAC_FIXED_RSS \
- OTLWF_CTL_CODE(200, METHOD_BUFFERED, FILE_WRITE_DATA)
- // GUID - InterfaceGuid
-
-#define IOCTL_OTLWF_OT_NEXT_ROUTE \
- OTLWF_CTL_CODE(201, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // BOOLEAN - aLocal (input)
- // uint8_t - aIterator (input)
- // uint8_t - aNewIterator (output)
- // otExternalRouteConfig - aConfig (output)
-
-#define IOCTL_OTLWF_OT_MAX_ROUTER_ID \
- OTLWF_CTL_CODE(202, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // uint8_t - aMaxRouterId
-
-#define IOCTL_OTLWF_OT_MLE_COUNTERS \
- OTLWF_CTL_CODE(203, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
- // otMleCounters - aCounters
-
-#define IOCTL_OTLWF_OT_LINK_LOCAL_ADDRESS \
- OTLWF_CTL_CODE(204, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
-
-#define IOCTL_OTLWF_OT_RLOC \
- OTLWF_CTL_CODE(205, METHOD_BUFFERED, FILE_READ_DATA)
- // GUID - InterfaceGuid
-
-// OpenThread function IOCTL codes
-#define MIN_OTLWF_IOCTL_FUNC_CODE 100
-#define MAX_OTLWF_IOCTL_FUNC_CODE 205
-
-#endif //__OTLWFIOCTL_H__
diff --git a/examples/drivers/windows/include/otNBLContext.h b/examples/drivers/windows/include/otNBLContext.h
deleted file mode 100644
index b5204f25b..000000000
--- a/examples/drivers/windows/include/otNBLContext.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines the context structure for NBLs send between otLwf and it's miniport.
- */
-
-#ifndef __OT_NBL_CONTEXT_H__
-#define __OT_NBL_CONTEXT_H__
-
-#ifndef _NDIS_
-#define NET_BUFFER_LIST_INFO(_NBL, _Id) ((_NBL)->NetBufferListInfo[(_Id)])
-#endif
-
-// Flag that indicates the ACK received had the Frame pending flag
-#define OT_NBL_FLAG_ACK_FRAME_PENDING 0x01
-
-// Represents the data necessary for the MAC layer to send out the NetBufferList
-// Must be saved in: NET_BUFFER_LIST_INFO(NetBufferList, MediaSpecificInformationEx)
-typedef struct _OT_NBL_CONTEXT
-{
- // Flags
- UCHAR Flags;
-
- // Channel used to transmit/receive the frame.
- UCHAR Channel;
-
- // Transmit/receive power in dBm.
- CHAR Power;
-
- // Link Quality Indicator for received frames.
- UCHAR Lqi;
-
-} OT_NBL_CONTEXT, *POT_NBL_CONTEXT;
-
-// OT_NBL_CONTEXT must fit in the pointer used for MediaSpecificInformationEx in the NBL
-C_ASSERT(sizeof(OT_NBL_CONTEXT) <= sizeof(PVOID));
-
-// Helper to set the OT_NBL_CONTEXT attached to the NetBufferList
-__forceinline VOID SetNBLContext(_In_ PNET_BUFFER_LIST NetBufferList, _In_ POT_NBL_CONTEXT Context)
-{
- *(POT_NBL_CONTEXT)(&NET_BUFFER_LIST_INFO(NetBufferList, MediaSpecificInformationEx)) = *Context;
-}
-
-// Helper to return the OT_NBL_CONTEXT attached to the NetBufferList
-__forceinline POT_NBL_CONTEXT GetNBLContext(_In_ PNET_BUFFER_LIST NetBufferList)
-{
- return (POT_NBL_CONTEXT)(&NET_BUFFER_LIST_INFO(NetBufferList, MediaSpecificInformationEx));
-}
-
-#endif //__OT_NBL_CONTEXT_H__
diff --git a/examples/drivers/windows/include/otNode.h b/examples/drivers/windows/include/otNode.h
deleted file mode 100644
index 4c3014925..000000000
--- a/examples/drivers/windows/include/otNode.h
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines a node interface for openthread to be used for certification tests
- */
-
-#ifndef OTNODE_H_
-#define OTNODE_H_
-
-#ifndef OTNODEAPI
-#define OTNODEAPI __declspec(dllimport)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * Represents a virtual node for an openthread interface
- */
-typedef struct otNode otNode;
-
-/**
- * Logs a WPP message
- */
-OTNODEAPI int32_t OTCALL otNodeLog(const char *aMessage);
-
-/**
- * Allocates a new virtual node
- */
-OTNODEAPI otNode* OTCALL otNodeInit(uint32_t id);
-
-/**
- * Frees a node
- */
-OTNODEAPI int32_t OTCALL otNodeFinalize(otNode* aNode);
-
-/**
- * Sets the link mode
- */
-OTNODEAPI int32_t OTCALL otNodeSetMode(otNode* aNode, const char *aMode);
-
-/**
- * Starts the thread interface
- */
-OTNODEAPI int32_t OTCALL otNodeInterfaceUp(otNode* aNode);
-
-/**
- * Stops the thread interface
- */
-OTNODEAPI int32_t OTCALL otNodeInterfaceDown(otNode* aNode);
-
-/**
- * Starts the thread logic
- */
-OTNODEAPI int32_t OTCALL otNodeThreadStart(otNode* aNode);
-
-/**
- * Stops the thread logic
- */
-OTNODEAPI int32_t OTCALL otNodeThreadStop(otNode* aNode);
-
-/**
- * Starts the commissioner logic
- */
-OTNODEAPI int32_t OTCALL otNodeCommissionerStart(otNode* aNode);
-
-/**
- * Adds a new joiner to the list for commissioning
- */
-OTNODEAPI int32_t OTCALL otNodeCommissionerJoinerAdd(otNode* aNode, const char *aExtAddr, const char *aPSKd);
-
-/**
- * Stops the commissioner logic
- */
-OTNODEAPI int32_t OTCALL otNodeCommissionerStop(otNode* aNode);
-
-/**
- * Starts the joiner logic
- */
-OTNODEAPI int32_t OTCALL otNodeJoinerStart(otNode* aNode, const char *aPSKd, const char *aProvisioningUrl);
-
-/**
- * Clears the node's whitelist
- */
-OTNODEAPI int32_t OTCALL otNodeClearWhitelist(otNode* aNode);
-
-/**
- * Enables the node's whitelist
- */
-OTNODEAPI int32_t OTCALL otNodeEnableWhitelist(otNode* aNode);
-
-/**
- * Disables the node's whitelist
- */
-OTNODEAPI int32_t OTCALL otNodeDisableWhitelist(otNode* aNode);
-
-/**
- * Adds an entry to the node's whitelist
- */
-OTNODEAPI int32_t OTCALL otNodeAddWhitelist(otNode* aNode, const char *aExtAddr, int8_t aRssi);
-
-/**
- * Removes an entry to the node's whitelist
- */
-OTNODEAPI int32_t OTCALL otNodeRemoveWhitelist(otNode* aNode, const char *aExtAddr);
-
-/**
- * Gets the node's short mac address (Rloc16)
- */
-OTNODEAPI uint16_t OTCALL otNodeGetAddr16(otNode* aNode);
-
-/**
- * Gets the node's extended mac address
- */
-OTNODEAPI const char* OTCALL otNodeGetAddr64(otNode* aNode);
-
-/**
- * Gets the node's eui-64 address
- */
-OTNODEAPI const char* OTCALL otNodeGetEui64(otNode* aNode);
-
-/**
- * Gets the node's joiner id
- */
-OTNODEAPI const char* OTCALL otNodeGetJoinerId(otNode* aNode);
-
-/**
- * Sets the channel for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetChannel(otNode* aNode, uint8_t aChannel);
-
-/**
- * Gets the channel for the node
- */
-OTNODEAPI uint8_t OTCALL otNodeGetChannel(otNode* aNode);
-
-/**
- * sets the node's master key
- */
-OTNODEAPI int32_t OTCALL otNodeSetMasterkey(otNode* aNode, const char *aMasterkey);
-
-/**
- * Gets the node's master key
- */
-OTNODEAPI const char* OTCALL otNodeGetMasterkey(otNode* aNode);
-
-/**
- * Gets the key sequence counter for the node
- */
-OTNODEAPI uint32_t OTCALL otNodeGetKeySequenceCounter(otNode* aNode);
-
-/**
- * Sets the key sequence counter for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetKeySequenceCounter(otNode* aNode, uint32_t aSequence);
-
-/**
- * Sets the key switch guard time for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetKeySwitchGuardTime(otNode* aNode, uint32_t aSequence);
-
-/**
- * Sets the network id timeout for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetNetworkIdTimeout(otNode* aNode, uint8_t aTimeout);
-
-/**
- * Gets the network name for the node
- */
-OTNODEAPI const char* OTCALL otNodeGetNetworkName(otNode* aNode);
-
-/**
- * Sets the network name for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetNetworkName(otNode* aNode, const char *aName);
-
-/**
- * Gets the pan id for the node
- */
-OTNODEAPI uint16_t OTCALL otNodeGetPanId(otNode* aNode);
-
-/**
- * Sets the pan id for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetPanId(otNode* aNode, uint16_t aPanId);
-
-/**
- * Gets the partition id for the node
- */
-OTNODEAPI uint32_t OTCALL otNodeGetPartitionId(otNode* aNode);
-
-/**
- * Sets the partition id for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetPartitionId(otNode* aNode, uint32_t aPartitionId);
-
-/**
- * Sets the router upgrade threshold for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetRouterUpgradeThreshold(otNode* aNode, uint8_t aThreshold);
-
-/**
- * Sets the router downgrade threshold for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetRouterDowngradeThreshold(otNode* aNode, uint8_t aThreshold);
-
-/**
- * Releases a router id for the node
- */
-OTNODEAPI int32_t OTCALL otNodeReleaseRouterId(otNode* aNode, uint8_t aRouterId);
-
-/**
- * Gets the node's state
- */
-OTNODEAPI const char* OTCALL otNodeGetState(otNode* aNode);
-
-/**
- * Sets the node's state
- */
-OTNODEAPI int32_t OTCALL otNodeSetState(otNode* aNode, const char *aState);
-
-/**
- * Gets the child timeout for the node
- */
-OTNODEAPI uint32_t OTCALL otNodeGetTimeout(otNode* aNode);
-
-/**
- * Sets the child timeout for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetTimeout(otNode* aNode, uint32_t aTimeout);
-
-/**
- * Gets the leader weight for the node
- */
-OTNODEAPI uint8_t OTCALL otNodeGetWeight(otNode* aNode);
-
-/**
- * Sets the leader weight for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetWeight(otNode* aNode, uint8_t aWeight);
-
-/**
- * Adds an IP address for the node
- */
-OTNODEAPI int32_t OTCALL otNodeAddIpAddr(otNode* aNode, const char *aAddr);
-
-/**
- * Gets the IP address for the node
- */
-OTNODEAPI const char* OTCALL otNodeGetAddrs(otNode* aNode);
-
-/**
- * Gets the context reuse delay for the node
- */
-OTNODEAPI uint32_t OTCALL otNodeGetContextReuseDelay(otNode* aNode);
-
-/**
- * Sets the context reuse delay for the node
- */
-OTNODEAPI int32_t OTCALL otNodeSetContextReuseDelay(otNode* aNode, uint32_t aDelay);
-
-/**
- * Adds an IP prefix for the node
- */
-OTNODEAPI int32_t OTCALL otNodeAddPrefix(otNode* aNode, const char *aPrefix, const char *aFlags, const char *aPreference);
-
-/**
- * Removes an IP prefix from the node
- */
-OTNODEAPI int32_t OTCALL otNodeRemovePrefix(otNode* aNode, const char *aPrefix);
-
-/**
- * Adds an IP route for the node
- */
-OTNODEAPI int32_t OTCALL otNodeAddRoute(otNode* aNode, const char *aPrefix, const char *aPreference);
-
-/**
- * Removes an IP route from the node
- */
-OTNODEAPI int32_t OTCALL otNodeRemoveRoute(otNode* aNode, const char *aPrefix);
-
-/**
- * Registers the net data for the node
- */
-OTNODEAPI int32_t OTCALL otNodeRegisterNetdata(otNode* aNode);
-
-/**
- * Performs an energy scan for the node
- */
-OTNODEAPI int32_t OTCALL otNodeEnergyScan(otNode* aNode, uint32_t aMask, uint8_t aCount, uint16_t aPeriod, uint16_t aDuration, const char *aAddr);
-
-/**
- * Performs a panid query for the node
- */
-OTNODEAPI int32_t OTCALL otNodePanIdQuery(otNode* aNode, uint16_t aPanId, uint32_t aMask, const char *aAddr);
-
-/**
- * Performs an scan for the node
- */
-OTNODEAPI const char* OTCALL otNodeScan(otNode* aNode);
-
-/**
- * Performs an scan for the node
- */
-OTNODEAPI uint32_t OTCALL otNodePing(otNode* aNode, const char *aAddr, uint16_t aSize, uint32_t aMinReplies, uint16_t aTimeout);
-
-/**
- * Sets the router selection jitter value for a node
- */
-OTNODEAPI int32_t OTCALL otNodeSetRouterSelectionJitter(otNode* aNode, uint8_t aRouterJitter);
-
-/**
- * Sends the announce message for a node
- */
-OTNODEAPI int32_t OTCALL otNodeCommissionerAnnounceBegin(otNode* aNode, uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod, const char *aAddr);
-
-/**
- * Sets the active dataset for a node
- */
-OTNODEAPI int32_t OTCALL otNodeSetActiveDataset(otNode* aNode, uint64_t aTimestamp, uint16_t aPanId, uint16_t aChannel, uint32_t aChannelMask, const char *aMasterKey);
-
-/**
- * Sets the pending dataset for a node
- */
-OTNODEAPI int32_t OTCALL otNodeSetPendingDataset(otNode* aNode, uint64_t aActiveTimestamp, uint64_t aPendingTimestamp, uint16_t aPanId, uint16_t aChannel);
-
-/**
- * Sends a pending set for a node
- */
-OTNODEAPI int32_t OTCALL otNodeSendPendingSet(otNode* aNode, uint64_t aActiveTimestamp, uint64_t aPendingTimestamp, uint32_t aDelayTimer, uint16_t aPanId, uint16_t aChannel, const char *aMasterKey, const char *aMeshLocal, const char *aNetworkName);
-
-/**
- * Sends a active set for a node
- */
-OTNODEAPI int32_t OTCALL otNodeSendActiveSet(otNode* aNode, uint64_t aActiveTimestamp, uint16_t aPanId, uint16_t aChannel, uint32_t aChannelMask, const char *aExtPanId, const char *aMasterKey, const char *aMeshLocal, const char *aNetworkName, const char *aBinary);
-
-/**
- * Sets the maximum number of children for a node
- */
-OTNODEAPI int32_t OTCALL otNodeSetMaxChildren(otNode* aNode, uint8_t aMaxChildren);
-
-/**
- * The interface used to listen in on virtual nodes' MAC frames
- */
-
-typedef struct otListener otListener;
-
-/**
- * Creates and starts a new listener
- */
-OTNODEAPI otListener* OTCALL otListenerInit(uint32_t nodeid);
-
-/**
- * Frees a listener
- */
-OTNODEAPI int32_t OTCALL otListenerFinalize(otListener* aListener);
-
-/**
- * Structure that represents a received MAC frame from the listener
- */
-typedef struct otMacFrame
-{
- uint8_t buffer[128];
- uint8_t length;
- uint32_t nodeid;
-} otMacFrame;
-
-/**
- * Reads the next MAC frame from the listener
- */
-OTNODEAPI int32_t OTCALL otListenerRead(otListener* aListener, otMacFrame *aFrame);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // OTNODE_H_
diff --git a/examples/drivers/windows/include/otOID.h b/examples/drivers/windows/include/otOID.h
deleted file mode 100644
index 348268dd9..000000000
--- a/examples/drivers/windows/include/otOID.h
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines the OID interface between otLwf and it's miniport.
- */
-
-#ifndef __OTOID_H__
-#define __OTOID_H__
-
-#pragma once
-
-//
-// Macros for defining native OpenThread OIDs
-//
-
-#define OT_OPERATIONAL_OID (0x01U)
-#define OT_STATISTICS_OID (0x02U)
-
-#define OT_MANDATORY_OID (0x01U)
-#define OT_OPTIONAL_OID (0x02U)
-
-#define OT_DEFINE_OID(Seq,o,m) ((0xD0000000U) | ((o) << 16) | ((m) << 8) | (Seq))
-
-//
-// OpenThread Status Indication codes (and associated payload types)
-//
-
-#define NDIS_STATUS_OT_ENERGY_SCAN_RESULT ((NDIS_STATUS)0x40050000L)
- typedef struct _OT_ENERGY_SCAN_RESULT
- {
- NDIS_STATUS Status;
- CHAR MaxRssi;
- } OT_ENERGY_SCAN_RESULT, * POT_ENERGY_SCAN_RESULT;
-
-//
-// General OID Definitions
-//
-
-// Used to query initial constants of the miniport
-#define OID_OT_CAPABILITIES OT_DEFINE_OID(0, OT_OPERATIONAL_OID, OT_MANDATORY_OID)
- typedef enum OT_MP_MODE
- {
- OT_MP_MODE_RADIO, // Supports the physical radio layer
- OT_MP_MODE_THREAD // Supports the full Thread stack
- } OT_MP_MODE;
- typedef enum OT_RADIO_CAPABILITY
- {
- // Radio supports Ack timeouts internally
- OT_RADIO_CAP_ACK_TIMEOUT = 1 << 0,
- // Radio supports MAC retry logic and timers; as well as collision avoidance.
- OT_RADIO_CAP_MAC_RETRY_AND_COLLISION_AVOIDANCE = 1 << 1,
- // Radio supports sleeping. If the device supports sleeping, it is assumed to
- // default to the sleep state on bring up.
- OT_RADIO_CAP_SLEEP = 1 << 2,
- } OT_RADIO_CAPABILITY;
- typedef struct _OT_CAPABILITIES
- {
- #define OT_CAPABILITIES_REVISION_1 1
- NDIS_OBJECT_HEADER Header;
- OT_MP_MODE MiniportMode;
- USHORT RadioCapabilities; // OT_RADIO_CAPABILITY flags
- } OT_CAPABILITIES, * POT_CAPABILITIES;
-
-#define SIZEOF_OT_CAPABILITIES_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(OT_CAPABILITIES, RadioCapabilities)
-
-//
-// Radio Mode OIDs
-//
-
-// Used to query/set sleep mode; only used if RadioCapabilities
-// indicates support for OT_RADIO_CAP_SLEEP.
-#define OID_OT_SLEEP_MODE OT_DEFINE_OID(100, OT_OPERATIONAL_OID, OT_OPTIONAL_OID)
- typedef struct _OT_SLEEP_MODE
- {
- #define OT_SLEEP_MODE_REVISION_1 1
- NDIS_OBJECT_HEADER Header;
- BOOLEAN InSleepMode;
- } OT_SLEEP_MODE, * POT_SLEEP_MODE;
-
-#define SIZEOF_OT_SLEEP_MODE_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(OT_SLEEP_MODE, InSleepMode)
-
-// Used to query/set promiscuous mode
-#define OID_OT_PROMISCUOUS_MODE OT_DEFINE_OID(101, OT_OPERATIONAL_OID, OT_MANDATORY_OID)
- typedef struct _OT_PROMISCUOUS_MODE
- {
- #define OT_PROMISCUOUS_MODE_REVISION_1 1
- NDIS_OBJECT_HEADER Header;
- BOOLEAN InPromiscuousMode;
- } OT_PROMISCUOUS_MODE, * POT_PROMISCUOUS_MODE;
-
-#define SIZEOF_OT_PROMISCUOUS_MODE_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(OT_PROMISCUOUS_MODE, InPromiscuousMode)
-
-// Used to query the factory Extended Address
-#define OID_OT_FACTORY_EXTENDED_ADDRESS OT_DEFINE_OID(102, OT_OPERATIONAL_OID, OT_MANDATORY_OID)
- typedef struct _OT_FACTORY_EXTENDED_ADDRESS
- {
- #define OT_FACTORY_EXTENDED_ADDRESS_REVISION_1 1
- NDIS_OBJECT_HEADER Header;
- ULONGLONG ExtendedAddress;
- } OT_FACTORY_EXTENDED_ADDRESS, * POT_FACTORY_EXTENDED_ADDRESS;
-
-#define SIZEOF_OT_FACTORY_EXTENDED_ADDRESS_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(OT_FACTORY_EXTENDED_ADDRESS, ExtendedAddress)
-
-// Used to query/set the Pan ID
-#define OID_OT_PAND_ID OT_DEFINE_OID(103, OT_OPERATIONAL_OID, OT_MANDATORY_OID)
- typedef struct _OT_PAND_ID
- {
- #define OT_PAND_ID_REVISION_1 1
- NDIS_OBJECT_HEADER Header;
- USHORT PanID;
- } OT_PAND_ID, * POT_PAND_ID;
-
-#define SIZEOF_OT_PAND_ID_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(OT_PAND_ID, PanID)
-
-// Used to query/set the Short Address
-#define OID_OT_SHORT_ADDRESS OT_DEFINE_OID(104, OT_OPERATIONAL_OID, OT_MANDATORY_OID)
- typedef struct _OT_SHORT_ADDRESS
- {
- #define OT_SHORT_ADDRESS_REVISION_1 1
- NDIS_OBJECT_HEADER Header;
- USHORT ShortAddress;
- } OT_SHORT_ADDRESS, * POT_SHORT_ADDRESS;
-
-#define SIZEOF_OT_SHORT_ADDRESS_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(OT_SHORT_ADDRESS, ShortAddress)
-
-// Used to query/set the Extended Address
-#define OID_OT_EXTENDED_ADDRESS OT_DEFINE_OID(105, OT_OPERATIONAL_OID, OT_MANDATORY_OID)
- typedef struct _OT_EXTENDED_ADDRESS
- {
- #define OT_EXTENDED_ADDRESS_REVISION_1 1
- NDIS_OBJECT_HEADER Header;
- ULONGLONG ExtendedAddress;
- } OT_EXTENDED_ADDRESS, * POT_EXTENDED_ADDRESS;
-
-#define SIZEOF_OT_EXTENDED_ADDRESS_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(OT_EXTENDED_ADDRESS, ExtendedAddress)
-
-// Used to query/set the current listening channel
-#define OID_OT_CURRENT_CHANNEL OT_DEFINE_OID(106, OT_OPERATIONAL_OID, OT_MANDATORY_OID)
- typedef struct _OT_CURRENT_CHANNEL
- {
- #define OT_CURRENT_CHANNEL_REVISION_1 1
- NDIS_OBJECT_HEADER Header;
- UCHAR Channel;
- } OT_CURRENT_CHANNEL, * POT_CURRENT_CHANNEL;
-
-#define SIZEOF_OT_CURRENT_CHANNEL_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(OT_CURRENT_CHANNEL, Channel)
-
-// Used to query the current RSSI for the current channel
-#define OID_OT_RSSI OT_DEFINE_OID(107, OT_OPERATIONAL_OID, OT_MANDATORY_OID)
- typedef struct _OT_RSSI
- {
- #define OT_RSSI_REVISION_1 1
- NDIS_OBJECT_HEADER Header;
- CHAR Rssi;
- } OT_RSSI, * POT_RSSI;
-
-#define SIZEOF_OT_RSSI_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(OT_RSSI, Rssi)
-
-// The maximum of each type (short or extended) of MAC address to pend
-#define MAX_PENDING_MAC_SIZE 32
-
-// Used to set the list of MAC addresses for SEDs we currently have packets pending
-#define OID_OT_PENDING_MAC_OFFLOAD OT_DEFINE_OID(108, OT_OPERATIONAL_OID, OT_MANDATORY_OID)
- typedef struct _OT_PENDING_MAC_OFFLOAD
- {
- #define OT_PENDING_MAC_OFFLOAD_REVISION_1 1
- NDIS_OBJECT_HEADER Header;
- UCHAR ShortAddressCount;
- UCHAR ExtendedAddressCount;
- // Dynamic array of USHORT ShortAddresses of count ShortAddressCount
- // Dynamic array of ULONGLONG ExtendedAddresses of count ExtendedAddressCount
- } OT_PENDING_MAC_OFFLOAD, * POT_PENDING_MAC_OFFLOAD;
-
-#define SIZEOF_OT_PENDING_MAC_OFFLOAD_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(OT_PENDING_MAC_OFFLOAD, ExtendedAddressCount)
-
-#define COMPLETE_SIZEOF_OT_PENDING_MAC_OFFLOAD_REVISION_1(ShortAddressCount, ExtendedAddressCount) \
- (SIZEOF_OT_PENDING_MAC_OFFLOAD_REVISION_1 + sizeof(USHORT) * ShortAddressCount + sizeof(ULONGLONG) * ExtendedAddressCount)
-
-// Used to issue an energy scan request for the given channel
-#define OID_OT_ENERGY_SCAN OT_DEFINE_OID(109, OT_OPERATIONAL_OID, OT_MANDATORY_OID)
- typedef struct _OT_ENERGY_SCAN
- {
- #define OT_ENERGY_SCAN_REVISION_1 1
- NDIS_OBJECT_HEADER Header;
- UCHAR Channel;
- USHORT DurationMs;
- } OT_ENERGY_SCAN, * POT_ENERGY_SCAN;
-
-#define SIZEOF_OT_ENERGY_SCAN_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(OT_ENERGY_SCAN, DurationMs)
-
-//
-// Thread Mode OIDs
-//
-
-// TODO ...
-
-#endif //__OTOID_H__
diff --git a/examples/drivers/windows/include/rtlrefcount.h b/examples/drivers/windows/include/rtlrefcount.h
deleted file mode 100644
index 4819bc50f..000000000
--- a/examples/drivers/windows/include/rtlrefcount.h
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This module contains routines and type definitions for managing reference
- * counts.
- *
- * N.B. The functions defined here use the minimum fencing required for correct
- * management of the reference count contract. No additional memory
- * ordering should be assumed.
- */
-
-#pragma once
-
-//
-// Architecture support macros.
-// (Undefined at the bottom to avoid global namespace pollution)
-//
-
-#if defined(_WIN64)
-
-#define RtlIncrementLongPtrNoFence InterlockedIncrementNoFence64
-#define RtlDecrementLongPtrRelease InterlockedDecrementRelease64
-#define RtlExchangeAddLongPtrNoFence InterlockedExchangeAddNoFence64
-#define RtlExchangeAddLongPtrRelease InterlockedExchangeAddRelease64
-#define RtlCompareExchangeLongPtrNoFence InterlockedCompareExchangeNoFence64
-#define RtlCompareExchangeLongPtrRelease InterlockedCompareExchangeRelease64
-
-#else
-
-#define RtlIncrementLongPtrNoFence InterlockedIncrementNoFence
-#define RtlDecrementLongPtrRelease InterlockedDecrementRelease
-#define RtlExchangeAddLongPtrNoFence InterlockedExchangeAddNoFence
-#define RtlExchangeAddLongPtrRelease InterlockedExchangeAddRelease
-#define RtlCompareExchangeLongPtrNoFence InterlockedCompareExchangeNoFence
-#define RtlCompareExchangeLongPtrRelease InterlockedCompareExchangeRelease
-
-#endif
-
-#if defined(_X86_) || defined(_AMD64_)
-
-#define RtlBarrierAfterInterlock()
-
-#elif defined(_ARM64_)
-
-#define RtlBarrierAfterInterlock() __dmb(_ARM64_BARRIER_ISH)
-
-#elif defined(_ARM_)
-
-#define RtlBarrierAfterInterlock() __dmb(_ARM_BARRIER_ISH)
-
-#else
-
-#define Unsupported architecture.
-
-#endif
-
-#define RTL_REF_COUNT_INIT 1
-
-FORCEINLINE
-VOID
-RtlInitializeReferenceCount (
- _Out_ PRTL_REFERENCE_COUNT RefCount
- )
-
-/*++
-
-Routine Description:
-
- This function initializes a reference count to 1.
-
-Arguments:
-
- RefCount - Supplies a pointer to a reference count to initialize.
-
-Return Value:
-
- None.
-
---*/
-
-{
-
- *RefCount = RTL_REF_COUNT_INIT;
- return;
-}
-
-FORCEINLINE
-VOID
-RtlInitializeReferenceCountEx (
- _Out_ PRTL_REFERENCE_COUNT RefCount,
- _In_ ULONG Bias
- )
-
-/*++
-
-Routine Description:
-
- This function initializes a reference count to a positive value.
-
-Arguments:
-
- RefCount - Supplies a pointer to a reference count to initialize.
-
- Bias - Supplies an initial reference count (must be positive).
-
-Return Value:
-
- None.
-
---*/
-
-{
-
- *RefCount = Bias;
- return;
-}
-
-FORCEINLINE
-VOID
-RtlIncrementReferenceCount (
- _Inout_ PRTL_REFERENCE_COUNT RefCount
- )
-
-/*++
-
-Routine Description:
-
- This function increments the specified reference count, preventing object
- deletion.
-
-Arguments:
-
- RefCount - Supplies a pointer to a reference count.
-
-Return Value:
-
- None.
-
---*/
-
-{
-
- if (RtlIncrementLongPtrNoFence(RefCount) > 1) {
- return;
- }
-
- __fastfail(FAST_FAIL_INVALID_REFERENCE_COUNT);
-}
-
-FORCEINLINE
-VOID
-RtlIncrementReferenceCountEx (
- _Inout_ PRTL_REFERENCE_COUNT RefCount,
- _In_ ULONG Bias
- )
-
-/*++
-
-Routine Description:
-
- This function increases the specified reference count by the specified bias,
- preventing object deletion.
-
-Arguments:
-
- RefCount - Supplies a pointer to a reference count.
-
- Bias - Supplies a reference bias amount.
-
-Return Value:
-
- None.
-
---*/
-
-{
-
- if (RtlExchangeAddLongPtrNoFence(RefCount, Bias) > 0) {
- return;
- }
-
- __fastfail(FAST_FAIL_INVALID_REFERENCE_COUNT);
-}
-
-FORCEINLINE
-BOOLEAN
-RtlIncrementReferenceCountNonZero (
- _Inout_ volatile RTL_REFERENCE_COUNT *RefCount,
- _In_ ULONG Bias
- )
-
-/*++
-
-Routine Description:
-
- This function increases the specified reference count by the specified bias,
- unless the reference count was previously zero.
-
-Arguments:
-
- RefCount - Supplies a pointer to a reference count.
-
- Bias - Supplies a reference bias amount.
-
-Return Value:
-
- TRUE if the reference count was incremented, FALSE otherwise.
-
---*/
-
-{
-
- RTL_REFERENCE_COUNT NewValue;
- RTL_REFERENCE_COUNT OldValue;
-
- PrefetchForWrite(RefCount);
- OldValue = ReadLongPtrNoFence(RefCount);
- for (;;) {
- NewValue = OldValue + Bias;
- if ((ULONG_PTR)NewValue > Bias) {
- NewValue = RtlCompareExchangeLongPtrNoFence(RefCount,
- NewValue,
- OldValue);
-
- if (NewValue == OldValue) {
- return TRUE;
- }
-
- OldValue = NewValue;
-
- } else if ((ULONG_PTR)NewValue == Bias) {
- return FALSE;
-
- } else {
- __fastfail(FAST_FAIL_INVALID_REFERENCE_COUNT);
- }
- }
-}
-
-FORCEINLINE
-BOOLEAN
-RtlDecrementReferenceCount (
- _Inout_ PRTL_REFERENCE_COUNT RefCount
- )
-
-/*++
-
-Routine Description:
-
- This function reduces the specified reference count, potentially triggering
- the destruction of the guarded object.
-
-Arguments:
-
- RefCount - Supplies a pointer to a reference count.
-
-Return Value:
-
- TRUE if the object should be destroyed, FALSE otherwise.
-
---*/
-
-{
-
- RTL_REFERENCE_COUNT NewValue;
-
- //
- // A release fence is required to ensure all guarded memory accesses are
- // complete before any thread can begin destroying the object.
- //
-
- NewValue = RtlDecrementLongPtrRelease(RefCount);
- if (NewValue > 0) {
- return FALSE;
-
- } else if (NewValue == 0) {
-
- //
- // An acquire fence is required before object destruction to ensure
- // that the destructor cannot observe values changing on other threads.
- //
-
- RtlBarrierAfterInterlock();
- return TRUE;
- }
-
- __fastfail(FAST_FAIL_INVALID_REFERENCE_COUNT);
- return FALSE;
-}
-
-FORCEINLINE
-BOOLEAN
-RtlDecrementReferenceCountEx (
- _Inout_ PRTL_REFERENCE_COUNT RefCount,
- _In_ ULONG Bias
- )
-
-/*++
-
-Routine Description:
-
- This function reduces the specified reference count by the specified amount,
- potentially triggering the destruction of the guarded object.
-
-Arguments:
-
- RefCount - Supplies a pointer to a reference count.
-
- Bias - Supplies a reference bias amount.
-
-Return Value:
-
- TRUE if the object should be destroyed, FALSE otherwise.
-
---*/
-
-{
-
- RTL_REFERENCE_COUNT NewValue;
-
- //
- // A release fence is required to ensure all guarded memory accesses are
- // complete before any thread can begin destroying the object.
- //
-
- NewValue = RtlExchangeAddLongPtrRelease(RefCount, -(LONG)Bias) - Bias;
- if (NewValue > 0) {
- return FALSE;
-
- } else if (NewValue == 0) {
-
- //
- // An acquire fence is required before object destruction to ensure
- // that the destructor cannot observe values changing on other threads.
- //
-
- RtlBarrierAfterInterlock();
- return TRUE;
- }
-
- __fastfail(FAST_FAIL_INVALID_REFERENCE_COUNT);
- return FALSE;
-}
-
-FORCEINLINE
-BOOLEAN
-RtlDecrementReferenceCountNonZero (
- _Inout_ volatile RTL_REFERENCE_COUNT *RefCount,
- _In_ ULONG Bias
- )
-
-/*++
-
-Routine Description:
-
- This function reduces the specified reference count by the specified amount,
- unless doing so would result in a zero value.
-
-Arguments:
-
- RefCount - Supplies a pointer to a reference count.
-
- Bias - Supplies a reference bias amount.
-
-Return Value:
-
- TRUE if the reference count would be zero, FALSE otherwise.
-
---*/
-
-{
-
- RTL_REFERENCE_COUNT NewValue;
- RTL_REFERENCE_COUNT OldValue;
-
- PrefetchForWrite(RefCount);
- OldValue = ReadLongPtrNoFence(RefCount);
- for (;;) {
- NewValue = OldValue - Bias;
- if (NewValue > 0) {
-
- //
- // A release fence is required to ensure all guarded memory
- // accesses are complete before any thread can begin destroying
- // the object.
- //
-
- NewValue = RtlCompareExchangeLongPtrRelease(RefCount,
- NewValue,
- OldValue);
-
- if (NewValue == OldValue) {
- return FALSE;
- }
-
- OldValue = NewValue;
-
- } else if (NewValue == 0) {
- return TRUE;
-
- } else {
- __fastfail(FAST_FAIL_INVALID_REFERENCE_COUNT);
- }
- }
-}
-
-#undef RtlIncrementLongPtrNoFence
-#undef RtlDecrementLongPtrRelease
-#undef RtlExchangeAddLongPtrNoFence
-#undef RtlExchangeAddLongPtrRelease
-#undef RtlCompareExchangeLongPtrNoFence
-#undef RtlCompareExchangeLongPtrRelease
-#undef RtlBarrierAfterInterlock
diff --git a/examples/drivers/windows/include_c99/stdbool.h b/examples/drivers/windows/include_c99/stdbool.h
deleted file mode 100644
index e28121c5f..000000000
--- a/examples/drivers/windows/include_c99/stdbool.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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 _STDBOOL_H_
-#define _STDBOOL_H_
-
-#ifndef __cplusplus
-
-typedef _Bool bool;
-#define false 0
-#define true 1
-
-#endif // __cplusplus
-
-#endif // _STDBOOL_H_
diff --git a/examples/drivers/windows/include_c99/stdint.h b/examples/drivers/windows/include_c99/stdint.h
deleted file mode 100644
index 8e2dac8a5..000000000
--- a/examples/drivers/windows/include_c99/stdint.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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 _STDINT_H_
-#define _STDINT_H_
-
-typedef signed char int8_t;
-typedef short int16_t;
-typedef int int32_t;
-typedef long long int64_t;
-typedef unsigned char uint8_t;
-typedef unsigned short uint16_t;
-typedef unsigned int uint32_t;
-typedef unsigned long long uint64_t;
-
-#endif // _STDINT_H_
diff --git a/examples/drivers/windows/otApi/dllmain.cpp b/examples/drivers/windows/otApi/dllmain.cpp
deleted file mode 100644
index 63d2326c1..000000000
--- a/examples/drivers/windows/otApi/dllmain.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "precomp.h"
-#include "dllmain.tmh"
-
-BOOL
-__stdcall
-DllMain(
- HINSTANCE hinstDll,
- DWORD dwReason,
- LPVOID /* lpvReserved */
- )
-{
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls(hinstDll);
- WPP_INIT_TRACING(L"otApi");
- break;
-
- case DLL_PROCESS_DETACH:
- WPP_CLEANUP();
- break;
-
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- break;
- }
-
- return TRUE;
-}
-
diff --git a/examples/drivers/windows/otApi/otApi.cpp b/examples/drivers/windows/otApi/otApi.cpp
deleted file mode 100644
index be161a9ae..000000000
--- a/examples/drivers/windows/otApi/otApi.cpp
+++ /dev/null
@@ -1,4061 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "precomp.h"
-#include "otApi.tmh"
-
-//#define DEBUG_ASYNC_IO
-
-using namespace std;
-
-// The maximum time we will wait for an overlapped result. Essentially, the maximum
-// amount of time each synchronous IOCTL should take.
-const DWORD c_MaxOverlappedWaitTimeMS = 5 * 1000;
-
-// Version string returned by the API
-const char c_Version[] = "Windows"; // TODO - What should we really put here?
-
-template
-class otCallback
-{
-public:
- RTL_REFERENCE_COUNT CallbackRefCount;
- HANDLE CallbackCompleteEvent;
- GUID InterfaceGuid;
- CallbackT Callback;
- PVOID CallbackContext;
-
- otCallback(
- CallbackT _Callback,
- PVOID _CallbackContext
- ) :
- CallbackRefCount(1),
- CallbackCompleteEvent(CreateEvent(nullptr, FALSE, FALSE, nullptr)),
- Callback(_Callback),
- CallbackContext(_CallbackContext)
- {
- }
-
- otCallback(
- const GUID& _InterfaceGuid,
- CallbackT _Callback,
- PVOID _CallbackContext
- ) :
- CallbackRefCount(1),
- CallbackCompleteEvent(CreateEvent(nullptr, FALSE, FALSE, nullptr)),
- InterfaceGuid(_InterfaceGuid),
- Callback(_Callback),
- CallbackContext(_CallbackContext)
- {
- }
-
- ~otCallback()
- {
- if (CallbackCompleteEvent) CloseHandle(CallbackCompleteEvent);
- }
-
- void AddRef()
- {
- RtlIncrementReferenceCount(&CallbackRefCount);
- }
-
- void Release(bool waitForShutdown = false)
- {
- if (RtlDecrementReferenceCount(&CallbackRefCount))
- {
- // Set completion event if there are no more refs
- SetEvent(CallbackCompleteEvent);
- }
-
- if (waitForShutdown)
- {
- WaitForSingleObject(CallbackCompleteEvent, INFINITE);
- }
- }
-};
-
-typedef otCallback otApiDeviceAvailabilityCallback;
-typedef otCallback otApiActiveScanCallback;
-typedef otCallback otApiEnergyScanCallback;
-typedef otCallback otApiStateChangeCallback;
-typedef otCallback otApiCommissionerEnergyReportCallback;
-typedef otCallback otApiCommissionerPanIdConflictCallback;
-typedef otCallback otApiJoinerCallback;
-
-typedef struct otApiInstance
-{
- // Handle to the driver
- HANDLE DeviceHandle;
-
- // Async IO variables
- OVERLAPPED Overlapped;
- PTP_WAIT ThreadpoolWait;
-
- // Notification variables
- CRITICAL_SECTION CallbackLock;
- OTLWF_NOTIFICATION NotificationBuffer;
-
- // Callbacks
- otApiDeviceAvailabilityCallback* DeviceAvailabilityCallbacks;
- vector ActiveScanCallbacks;
- vector EnergyScanCallbacks;
- vector DiscoverCallbacks;
- vector StateChangedCallbacks;
- vector CommissionerEnergyReportCallbacks;
- vector CommissionerPanIdConflictCallbacks;
- vector JoinerCallbacks;
-
- // Constructor
- otApiInstance() :
- DeviceHandle(INVALID_HANDLE_VALUE),
- Overlapped({0}),
- ThreadpoolWait(nullptr),
- DeviceAvailabilityCallbacks(nullptr)
- {
- InitializeCriticalSection(&CallbackLock);
- }
-
- ~otApiInstance()
- {
- DeleteCriticalSection(&CallbackLock);
- }
-
- // Helper function to set a callback
- template
- bool
- SetCallback(
- vector*> &Callbacks,
- const GUID& InterfaceGuid,
- CallbackT Callback,
- PVOID CallbackContext
- )
- {
- bool alreadyExists = false;
- otCallback* CallbackToRelease = nullptr;
-
- EnterCriticalSection(&CallbackLock);
-
- if (Callback == nullptr)
- {
- for (size_t i = 0; i < Callbacks.size(); i++)
- {
- if (Callbacks[i]->InterfaceGuid == InterfaceGuid)
- {
- CallbackToRelease = Callbacks[i];
- Callbacks.erase(Callbacks.begin() + i);
- break;
- }
- }
- }
- else
- {
- for (size_t i = 0; i < Callbacks.size(); i++)
- {
- if (Callbacks[i]->InterfaceGuid == InterfaceGuid)
- {
- alreadyExists = true;
- break;
- }
- }
-
- if (!alreadyExists)
- {
- Callbacks.push_back(new otCallback(InterfaceGuid, Callback, CallbackContext));
- }
- }
-
- LeaveCriticalSection(&CallbackLock);
-
- if (CallbackToRelease)
- {
- CallbackToRelease->Release(true);
- delete CallbackToRelease;
- }
-
- return !alreadyExists;
- }
-
-} otApiInstance;
-
-typedef struct otInstance
-{
- otApiInstance *ApiHandle; // Pointer to the Api handle
- NET_IFINDEX InterfaceIndex; // Interface Index
- NET_LUID InterfaceLuid; // Interface Luid
- GUID InterfaceGuid; // Interface guid
- ULONG CompartmentID; // Interface Compartment ID
-
-} otInstance;
-
-// otpool wait callback for async IO completion
-VOID CALLBACK
-otIoComplete(
- _Inout_ PTP_CALLBACK_INSTANCE Instance,
- _Inout_opt_ PVOID Context,
- _Inout_ PTP_WAIT Wait,
- _In_ TP_WAIT_RESULT WaitResult
- );
-
-OTAPI
-otApiInstance *
-OTCALL
-otApiInit(
- )
-{
- DWORD dwError = ERROR_SUCCESS;
- otApiInstance *aApitInstance = nullptr;
-
- LogFuncEntry(API_DEFAULT);
-
- aApitInstance = new(std::nothrow)otApiInstance();
- if (aApitInstance == nullptr)
- {
- dwError = GetLastError();
- LogWarning(API_DEFAULT, "Failed to allocate otApiInstance");
- goto error;
- }
-
- // Open the pipe to the OpenThread driver
- aApitInstance->DeviceHandle =
- CreateFile(
- OTLWF_IOCLT_PATH,
- GENERIC_READ | GENERIC_WRITE,
- 0,
- nullptr, // no SECURITY_ATTRIBUTES structure
- OPEN_EXISTING, // No special create flags
- FILE_FLAG_OVERLAPPED, // Allow asynchronous requests
- nullptr
- );
- if (aApitInstance->DeviceHandle == INVALID_HANDLE_VALUE)
- {
- dwError = GetLastError();
- LogError(API_DEFAULT, "CreateFile failed, %!WINERROR!", dwError);
- goto error;
- }
-
- // Create event for completion of async IO
- aApitInstance->Overlapped.hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
- if (aApitInstance->Overlapped.hEvent == nullptr)
- {
- dwError = GetLastError();
- LogError(API_DEFAULT, "CreateEvent (Overlapped.hEvent) failed, %!WINERROR!", dwError);
- goto error;
- }
-
- // Create the otpool wait
- aApitInstance->ThreadpoolWait =
- CreateThreadpoolWait(
- otIoComplete,
- aApitInstance,
- nullptr
- );
- if (aApitInstance->ThreadpoolWait == nullptr)
- {
- dwError = GetLastError();
- LogError(API_DEFAULT, "CreateThreadpoolWait failed, %!WINERROR!", dwError);
- goto error;
- }
-
- // Start the otpool waiting on the overlapped event
- SetThreadpoolWait(aApitInstance->ThreadpoolWait, aApitInstance->Overlapped.hEvent, nullptr);
-
-#ifdef DEBUG_ASYNC_IO
- LogVerbose(API_DEFAULT, "Querying for 1st notification");
-#endif
-
- // Request first notification asynchronously
- if (!DeviceIoControl(
- aApitInstance->DeviceHandle,
- IOCTL_OTLWF_QUERY_NOTIFICATION,
- nullptr, 0,
- &aApitInstance->NotificationBuffer, sizeof(OTLWF_NOTIFICATION),
- nullptr,
- &aApitInstance->Overlapped))
- {
- dwError = GetLastError();
- if (dwError != ERROR_IO_PENDING)
- {
- LogError(API_DEFAULT, "DeviceIoControl for first notification failed, %!WINERROR!", dwError);
- goto error;
- }
- dwError = ERROR_SUCCESS;
- }
-
-error:
-
- if (dwError != ERROR_SUCCESS)
- {
- otApiFinalize(aApitInstance);
- aApitInstance = nullptr;
- }
-
- LogFuncExit(API_DEFAULT);
-
- return aApitInstance;
-}
-
-OTAPI
-void
-OTCALL
-otApiFinalize(
- _In_ otApiInstance *aApitInstance
-)
-{
- if (aApitInstance == nullptr) return;
-
- LogFuncEntry(API_DEFAULT);
-
- // If we never got the handle, nothing left to clean up
- if (aApitInstance->DeviceHandle != INVALID_HANDLE_VALUE)
- {
- //
- // Make sure we unregister callbacks
- //
-
- EnterCriticalSection(&aApitInstance->CallbackLock);
-
- otApiDeviceAvailabilityCallback* DeviceAvailabilityCallbacks = aApitInstance->DeviceAvailabilityCallbacks;
- aApitInstance->DeviceAvailabilityCallbacks = nullptr;
-
- vector ActiveScanCallbacks(aApitInstance->ActiveScanCallbacks);
- aApitInstance->ActiveScanCallbacks.clear();
-
- vector EnergyScanCallbacks(aApitInstance->EnergyScanCallbacks);
- aApitInstance->EnergyScanCallbacks.clear();
-
- vector DiscoverCallbacks(aApitInstance->DiscoverCallbacks);
- aApitInstance->DiscoverCallbacks.clear();
-
- vector StateChangedCallbacks(aApitInstance->StateChangedCallbacks);
- aApitInstance->StateChangedCallbacks.clear();
-
- vector CommissionerEnergyReportCallbacks(aApitInstance->CommissionerEnergyReportCallbacks);
- aApitInstance->CommissionerEnergyReportCallbacks.clear();
-
- vector CommissionerPanIdConflictCallbacks(aApitInstance->CommissionerPanIdConflictCallbacks);
- aApitInstance->CommissionerPanIdConflictCallbacks.clear();
-
- vector JoinerCallbacks(aApitInstance->JoinerCallbacks);
- aApitInstance->JoinerCallbacks.clear();
-
- #ifdef DEBUG_ASYNC_IO
- LogVerbose(API_DEFAULT, "Clearing Threadpool Wait");
- #endif
-
- // Clear the threadpool wait to prevent further waits from being scheduled
- PTP_WAIT tpWait = aApitInstance->ThreadpoolWait;
- aApitInstance->ThreadpoolWait = nullptr;
-
- LeaveCriticalSection(&aApitInstance->CallbackLock);
-
- // Clear all callbacks
- if (DeviceAvailabilityCallbacks)
- {
- DeviceAvailabilityCallbacks->Release(true);
- delete DeviceAvailabilityCallbacks;
- }
- for (size_t i = 0; i < ActiveScanCallbacks.size(); i++)
- {
- ActiveScanCallbacks[i]->Release(true);
- delete ActiveScanCallbacks[i];
- }
- for (size_t i = 0; i < EnergyScanCallbacks.size(); i++)
- {
- EnergyScanCallbacks[i]->Release(true);
- delete EnergyScanCallbacks[i];
- }
- for (size_t i = 0; i < DiscoverCallbacks.size(); i++)
- {
- DiscoverCallbacks[i]->Release(true);
- delete DiscoverCallbacks[i];
- }
- for (size_t i = 0; i < StateChangedCallbacks.size(); i++)
- {
- StateChangedCallbacks[i]->Release(true);
- delete StateChangedCallbacks[i];
- }
- for (size_t i = 0; i < CommissionerEnergyReportCallbacks.size(); i++)
- {
- CommissionerEnergyReportCallbacks[i]->Release(true);
- delete CommissionerEnergyReportCallbacks[i];
- }
- for (size_t i = 0; i < CommissionerPanIdConflictCallbacks.size(); i++)
- {
- CommissionerPanIdConflictCallbacks[i]->Release(true);
- delete CommissionerPanIdConflictCallbacks[i];
- }
- for (size_t i = 0; i < JoinerCallbacks.size(); i++)
- {
- JoinerCallbacks[i]->Release(true);
- delete JoinerCallbacks[i];
- }
-
- // Clean up threadpool wait
- if (tpWait)
- {
- #ifdef DEBUG_ASYNC_IO
- LogVerbose(API_DEFAULT, "Waiting for outstanding threadpool callbacks to compelte");
- #endif
-
- // Cancel any queued waits and wait for any outstanding calls to compelte
- WaitForThreadpoolWaitCallbacks(tpWait, TRUE);
-
- #ifdef DEBUG_ASYNC_IO
- LogVerbose(API_DEFAULT, "Cancelling any pending IO");
- #endif
-
- // Cancel any async IO
- CancelIoEx(aApitInstance->DeviceHandle, &aApitInstance->Overlapped);
-
- // Free the threadpool wait
- CloseThreadpoolWait(tpWait);
- }
-
- // Clean up overlapped event
- if (aApitInstance->Overlapped.hEvent)
- {
- CloseHandle(aApitInstance->Overlapped.hEvent);
- }
-
- // Close the device handle
- CloseHandle(aApitInstance->DeviceHandle);
- }
-
- delete aApitInstance;
-
- LogFuncExit(API_DEFAULT);
-}
-
-OTAPI
-void
-OTCALL
-otFreeMemory(
- _In_ const void *mem
- )
-{
- free((void*)mem);
-}
-
-// Handles cleanly invoking the register callback
-VOID
-ProcessNotification(
- _In_ otApiInstance *aApitInstance,
- _In_ POTLWF_NOTIFICATION Notif
- )
-{
- if (Notif->NotifType == OTLWF_NOTIF_DEVICE_AVAILABILITY)
- {
- otCallback* Callback = nullptr;
-
- EnterCriticalSection(&aApitInstance->CallbackLock);
-
- if (aApitInstance->DeviceAvailabilityCallbacks != nullptr)
- {
- aApitInstance->DeviceAvailabilityCallbacks->AddRef();
- Callback = aApitInstance->DeviceAvailabilityCallbacks;
- }
-
- LeaveCriticalSection(&aApitInstance->CallbackLock);
-
- // Invoke the callback outside the lock and release ref when done
- if (Callback)
- {
- Callback->Callback(
- Notif->DeviceAvailabilityPayload.Available != FALSE,
- &Notif->InterfaceGuid,
- Callback->CallbackContext);
-
- Callback->Release();
- }
- }
- else if (Notif->NotifType == OTLWF_NOTIF_STATE_CHANGE)
- {
- otCallback* Callback = nullptr;
-
- EnterCriticalSection(&aApitInstance->CallbackLock);
-
- for (size_t i = 0; i < aApitInstance->StateChangedCallbacks.size(); i++)
- {
- if (aApitInstance->StateChangedCallbacks[i]->InterfaceGuid == Notif->InterfaceGuid)
- {
- aApitInstance->StateChangedCallbacks[i]->AddRef();
- Callback = aApitInstance->StateChangedCallbacks[i];
- break;
- }
- }
-
- LeaveCriticalSection(&aApitInstance->CallbackLock);
-
- // Invoke the callback outside the lock and release ref when done
- if (Callback)
- {
- Callback->Callback(
- Notif->StateChangePayload.Flags,
- Callback->CallbackContext);
-
- Callback->Release();
- }
- }
- else if (Notif->NotifType == OTLWF_NOTIF_DISCOVER)
- {
- otCallback* Callback = nullptr;
-
- EnterCriticalSection(&aApitInstance->CallbackLock);
-
- for (size_t i = 0; i < aApitInstance->DiscoverCallbacks.size(); i++)
- {
- if (aApitInstance->DiscoverCallbacks[i]->InterfaceGuid == Notif->InterfaceGuid)
- {
- aApitInstance->DiscoverCallbacks[i]->AddRef();
- Callback = aApitInstance->DiscoverCallbacks[i];
- break;
- }
- }
-
- LeaveCriticalSection(&aApitInstance->CallbackLock);
-
- // Invoke the callback outside the lock and release ref when done
- if (Callback)
- {
- Callback->Callback(
- Notif->DiscoverPayload.Valid ? &Notif->DiscoverPayload.Results : nullptr,
- Callback->CallbackContext);
-
- Callback->Release();
- }
- }
- else if (Notif->NotifType == OTLWF_NOTIF_ACTIVE_SCAN)
- {
- otCallback* Callback = nullptr;
-
- EnterCriticalSection(&aApitInstance->CallbackLock);
-
- for (size_t i = 0; i < aApitInstance->ActiveScanCallbacks.size(); i++)
- {
- if (aApitInstance->ActiveScanCallbacks[i]->InterfaceGuid == Notif->InterfaceGuid)
- {
- aApitInstance->ActiveScanCallbacks[i]->AddRef();
- Callback = aApitInstance->ActiveScanCallbacks[i];
- break;
- }
- }
-
- LeaveCriticalSection(&aApitInstance->CallbackLock);
-
- // Invoke the callback outside the lock and release ref when done
- if (Callback)
- {
- Callback->Callback(
- Notif->ActiveScanPayload.Valid ? &Notif->ActiveScanPayload.Results : nullptr,
- Callback->CallbackContext);
-
- Callback->Release();
- }
- }
- else if (Notif->NotifType == OTLWF_NOTIF_ENERGY_SCAN)
- {
- otCallback* Callback = nullptr;
-
- EnterCriticalSection(&aApitInstance->CallbackLock);
-
- for (size_t i = 0; i < aApitInstance->EnergyScanCallbacks.size(); i++)
- {
- if (aApitInstance->EnergyScanCallbacks[i]->InterfaceGuid == Notif->InterfaceGuid)
- {
- aApitInstance->EnergyScanCallbacks[i]->AddRef();
- Callback = aApitInstance->EnergyScanCallbacks[i];
- break;
- }
- }
-
- LeaveCriticalSection(&aApitInstance->CallbackLock);
-
- // Invoke the callback outside the lock and release ref when done
- if (Callback)
- {
- Callback->Callback(
- Notif->EnergyScanPayload.Valid ? &Notif->EnergyScanPayload.Results : nullptr,
- Callback->CallbackContext);
-
- Callback->Release();
- }
- }
- else if (Notif->NotifType == OTLWF_NOTIF_COMMISSIONER_ENERGY_REPORT)
- {
- otCallback* Callback = nullptr;
-
- EnterCriticalSection(&aApitInstance->CallbackLock);
-
- for (size_t i = 0; i < aApitInstance->CommissionerEnergyReportCallbacks.size(); i++)
- {
- if (aApitInstance->CommissionerEnergyReportCallbacks[i]->InterfaceGuid == Notif->InterfaceGuid)
- {
- aApitInstance->CommissionerEnergyReportCallbacks[i]->AddRef();
- Callback = aApitInstance->CommissionerEnergyReportCallbacks[i];
- break;
- }
- }
-
- LeaveCriticalSection(&aApitInstance->CallbackLock);
-
- // Invoke the callback outside the lock and release ref when done
- if (Callback)
- {
- Callback->Callback(
- Notif->CommissionerEnergyReportPayload.ChannelMask,
- Notif->CommissionerEnergyReportPayload.EnergyList,
- Notif->CommissionerEnergyReportPayload.EnergyListLength,
- Callback->CallbackContext);
-
- Callback->Release();
- }
- }
- else if (Notif->NotifType == OTLWF_NOTIF_COMMISSIONER_PANID_QUERY)
- {
- otCallback* Callback = nullptr;
-
- EnterCriticalSection(&aApitInstance->CallbackLock);
-
- for (size_t i = 0; i < aApitInstance->CommissionerPanIdConflictCallbacks.size(); i++)
- {
- if (aApitInstance->CommissionerPanIdConflictCallbacks[i]->InterfaceGuid == Notif->InterfaceGuid)
- {
- aApitInstance->CommissionerPanIdConflictCallbacks[i]->AddRef();
- Callback = aApitInstance->CommissionerPanIdConflictCallbacks[i];
- break;
- }
- }
-
- LeaveCriticalSection(&aApitInstance->CallbackLock);
-
- // Invoke the callback outside the lock and release ref when done
- if (Callback)
- {
- Callback->Callback(
- Notif->CommissionerPanIdQueryPayload.PanId,
- Notif->CommissionerPanIdQueryPayload.ChannelMask,
- Callback->CallbackContext);
-
- Callback->Release();
- }
- }
- else if (Notif->NotifType == OTLWF_NOTIF_JOINER_COMPLETE)
- {
- otCallback* Callback = nullptr;
-
- EnterCriticalSection(&aApitInstance->CallbackLock);
-
- for (size_t i = 0; i < aApitInstance->JoinerCallbacks.size(); i++)
- {
- if (aApitInstance->JoinerCallbacks[i]->InterfaceGuid == Notif->InterfaceGuid)
- {
- aApitInstance->JoinerCallbacks[i]->AddRef();
- Callback = aApitInstance->JoinerCallbacks[i];
- break;
- }
- }
-
- LeaveCriticalSection(&aApitInstance->CallbackLock);
-
- // Invoke the callback outside the lock and release ref when done
- if (Callback)
- {
- aApitInstance->SetCallback(
- aApitInstance->JoinerCallbacks,
- Notif->InterfaceGuid, (otJoinerCallback)nullptr, (PVOID)nullptr
- );
-
- Callback->Callback(
- Notif->JoinerCompletePayload.Error,
- Callback->CallbackContext);
-
- Callback->Release();
- }
- }
- else
- {
- // Unexpected notif type
- }
-}
-
-// Threadpool wait callback for async IO completion
-VOID CALLBACK
-otIoComplete(
- _Inout_ PTP_CALLBACK_INSTANCE /* Instance */,
- _Inout_opt_ PVOID Context,
- _Inout_ PTP_WAIT /* Wait */,
- _In_ TP_WAIT_RESULT /* WaitResult */
- )
-{
-#ifdef DEBUG_ASYNC_IO
- LogFuncEntry(API_DEFAULT);
-#endif
-
- otApiInstance *aApitInstance = (otApiInstance*)Context;
- if (aApitInstance == nullptr) return;
-
- // Get the result of the IO operation
- DWORD dwBytesTransferred = 0;
- if (!GetOverlappedResult(
- aApitInstance->DeviceHandle,
- &aApitInstance->Overlapped,
- &dwBytesTransferred,
- FALSE))
- {
- DWORD dwError = GetLastError();
- LogError(API_DEFAULT, "GetOverlappedResult for notification failed, %!WINERROR!", dwError);
- }
- else
- {
- LogVerbose(API_DEFAULT, "Received successful callback for notification, type=%d",
- aApitInstance->NotificationBuffer.NotifType);
-
- // Invoke the callback if set
- ProcessNotification(aApitInstance, &aApitInstance->NotificationBuffer);
-
- // Try to get the threadpool wait to see if we are allowed to continue processing notifications
- EnterCriticalSection(&aApitInstance->CallbackLock);
- PTP_WAIT tpWait = aApitInstance->ThreadpoolWait;
- LeaveCriticalSection(&aApitInstance->CallbackLock);
-
- if (tpWait)
- {
- // Start waiting for next notification
- SetThreadpoolWait(tpWait, aApitInstance->Overlapped.hEvent, nullptr);
-
-#ifdef DEBUG_ASYNC_IO
- LogVerbose(API_DEFAULT, "Querying for next notification");
-#endif
-
- // Request next notification
- if (!DeviceIoControl(
- aApitInstance->DeviceHandle,
- IOCTL_OTLWF_QUERY_NOTIFICATION,
- nullptr, 0,
- &aApitInstance->NotificationBuffer, sizeof(OTLWF_NOTIFICATION),
- nullptr,
- &aApitInstance->Overlapped))
- {
- DWORD dwError = GetLastError();
- if (dwError != ERROR_IO_PENDING)
- {
- LogError(API_DEFAULT, "DeviceIoControl for new notification failed, %!WINERROR!", dwError);
- }
- }
- }
- }
-
-#ifdef DEBUG_ASYNC_IO
- LogFuncExit(API_DEFAULT);
-#endif
-}
-
-DWORD
-SendIOCTL(
- _In_ otApiInstance *aApitInstance,
- _In_ DWORD dwIoControlCode,
- _In_reads_bytes_opt_(nInBufferSize) LPVOID lpInBuffer,
- _In_ DWORD nInBufferSize,
- _Out_writes_bytes_opt_(nOutBufferSize) LPVOID lpOutBuffer,
- _In_ DWORD nOutBufferSize
- )
-{
- DWORD dwError = ERROR_SUCCESS;
- OVERLAPPED Overlapped = { 0 };
- DWORD dwBytesReturned = 0;
-
- Overlapped.hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
- if (Overlapped.hEvent == nullptr)
- {
- dwError = GetLastError();
- LogError(API_DEFAULT, "CreateEvent (Overlapped.hEvent) failed, %!WINERROR!", dwError);
- goto error;
- }
-
- // Send the IOCTL the OpenThread driver
- if (!DeviceIoControl(
- aApitInstance->DeviceHandle,
- dwIoControlCode,
- lpInBuffer, nInBufferSize,
- lpOutBuffer, nOutBufferSize,
- nullptr,
- &Overlapped))
- {
- dwError = GetLastError();
- if (dwError != ERROR_IO_PENDING)
- {
- LogError(API_DEFAULT, "DeviceIoControl(0x%x) failed, %!WINERROR!", dwIoControlCode, dwError);
- goto error;
- }
- dwError = ERROR_SUCCESS;
- }
-
- // Get the result of the IO operation
- if (!GetOverlappedResultEx(
- aApitInstance->DeviceHandle,
- &Overlapped,
- &dwBytesReturned,
- c_MaxOverlappedWaitTimeMS,
- FALSE
- ))
- {
- dwError = GetLastError();
- if (dwError == WAIT_TIMEOUT)
- {
- dwError = ERROR_TIMEOUT;
- CancelIoEx(aApitInstance->DeviceHandle, &Overlapped);
- }
- LogError(API_DEFAULT, "GetOverlappedResult failed, %!WINERROR!", dwError);
- goto error;
- }
-
- if (dwBytesReturned != nOutBufferSize)
- {
- dwError = ERROR_INVALID_DATA;
- LogError(API_DEFAULT, "GetOverlappedResult returned invalid output size, expected=%u actual=%u",
- nOutBufferSize, dwBytesReturned);
- goto error;
- }
-
-error:
-
- if (Overlapped.hEvent)
- {
- CloseHandle(Overlapped.hEvent);
- }
-
- return dwError;
-}
-
-__pragma(pack(push,1))
-template
-struct PackedBuffer2
-{
- T1 data1; T2 data2;
- PackedBuffer2(const T1 &d1, const T2 &d2) : data1(d1), data2(d2) { }
-};
-template
-struct PackedBuffer3
-{
- T1 data1; T2 data2; T3 data3;
- PackedBuffer3(const T1 &d1, const T2 &d2, const T3 &d3) : data1(d1), data2(d2), data3(d3) { }
-};
-template
-struct PackedBuffer4
-{
- T1 data1; T2 data2; T3 data3; T4 data4;
- PackedBuffer4(const T1 &d1, const T2 &d2, const T3 &d3, const T4 &d4) : data1(d1), data2(d2), data3(d3), data4(d4) { }
-};
-template
-struct PackedBuffer5
-{
- T1 data1; T2 data2; T3 data3; T4 data4; T5 data5;
- PackedBuffer5(const T1 &d1, const T2 &d2, const T3 &d3, const T4 &d4, const T5 &d5) : data1(d1), data2(d2), data3(d3), data4(d4), data5(d5) { }
-};
-template
-struct PackedBuffer6
-{
- T1 data1; T2 data2; T3 data3; T4 data4; T5 data5; T6 data6;
- PackedBuffer6(const T1 &d1, const T2 &d2, const T3 &d3, const T4 &d4, const T5 &d5, const T6 &d6) : data1(d1), data2(d2), data3(d3), data4(d4), data5(d5), data6(d6) { }
-};
- __pragma(pack(pop))
-
-template
-DWORD
-QueryIOCTL(
- _In_ otInstance *aInstance,
- _In_ DWORD dwIoControlCode,
- _In_ const in *input,
- _Out_ out* output
- )
-{
- PackedBuffer2 Buffer(aInstance->InterfaceGuid, *input);
- return SendIOCTL(aInstance->ApiHandle, dwIoControlCode, &Buffer, sizeof(Buffer), output, sizeof(out));
-}
-
-template
-DWORD
-QueryIOCTL(
- _In_ otInstance *aInstance,
- _In_ DWORD dwIoControlCode,
- _Out_ out* output
- )
-{
- return SendIOCTL(aInstance->ApiHandle, dwIoControlCode, &aInstance->InterfaceGuid, sizeof(GUID), output, sizeof(out));
-}
-
-template
-DWORD
-SetIOCTL(
- _In_ otInstance *aInstance,
- _In_ DWORD dwIoControlCode,
- _In_ const in* input
- )
-{
- PackedBuffer2 Buffer(aInstance->InterfaceGuid, *input);
- return SendIOCTL(aInstance->ApiHandle, dwIoControlCode, &Buffer, sizeof(Buffer), nullptr, 0);
-}
-
-template
-DWORD
-SetIOCTL(
- _In_ otInstance *aInstance,
- _In_ DWORD dwIoControlCode,
- _In_ const in input
- )
-{
- PackedBuffer2 Buffer(aInstance->InterfaceGuid, input);
- return SendIOCTL(aInstance->ApiHandle, dwIoControlCode, &Buffer, sizeof(Buffer), nullptr, 0);
-}
-
-DWORD
-SetIOCTL(
- _In_ otInstance *aInstance,
- _In_ DWORD dwIoControlCode
- )
-{
- return SendIOCTL(aInstance->ApiHandle, dwIoControlCode, &aInstance->InterfaceGuid, sizeof(GUID), nullptr, 0);
-}
-
-otError
-DwordToThreadError(
- DWORD dwError
- )
-{
- if (((int)dwError) > 0)
- {
- return OT_ERROR_GENERIC;
- }
- else
- {
- return (otError)(-(int)dwError);
- }
-}
-
-OTAPI
-void
-OTCALL
-otSetDeviceAvailabilityChangedCallback(
- _In_ otApiInstance *aApitInstance,
- _In_ otDeviceAvailabilityChangedCallback aCallback,
- _In_ void *aCallbackContext
- )
-{
- otApiDeviceAvailabilityCallback* CallbackToRelease = nullptr;
-
- EnterCriticalSection(&aApitInstance->CallbackLock);
-
- if (aApitInstance->DeviceAvailabilityCallbacks != nullptr)
- {
- CallbackToRelease = aApitInstance->DeviceAvailabilityCallbacks;
- aApitInstance->DeviceAvailabilityCallbacks = nullptr;
- }
-
- if (aCallback != nullptr)
- {
- aApitInstance->DeviceAvailabilityCallbacks =
- new otApiDeviceAvailabilityCallback(aCallback, aCallbackContext);
- }
-
- LeaveCriticalSection(&aApitInstance->CallbackLock);
-
- if (CallbackToRelease)
- {
- CallbackToRelease->Release(true);
- delete CallbackToRelease;
- }
-}
-
-OTAPI
-otDeviceList*
-OTCALL
-otEnumerateDevices(
- _In_ otApiInstance *aApitInstance
- )
-{
- DWORD dwError = ERROR_SUCCESS;
- OVERLAPPED Overlapped = { 0 };
- DWORD dwBytesReturned = 0;
- otDeviceList* pDeviceList = nullptr;
- DWORD cbDeviceList = sizeof(otDeviceList);
-
- LogFuncEntry(API_DEFAULT);
-
- Overlapped.hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
- if (Overlapped.hEvent == nullptr)
- {
- dwError = GetLastError();
- LogError(API_DEFAULT, "CreateEvent (Overlapped.hEvent) failed, %!WINERROR!", dwError);
- goto error;
- }
-
- pDeviceList = (otDeviceList*)malloc(cbDeviceList);
- if (pDeviceList == nullptr)
- {
- LogWarning(API_DEFAULT, "Failed to allocate otDeviceList of %u bytes.", cbDeviceList);
- dwError = ERROR_NOT_ENOUGH_MEMORY;
- goto error;
- }
- RtlZeroMemory(pDeviceList, cbDeviceList);
-
- // Query in a loop to account for it changing between calls
- while (true)
- {
- // Send the IOCTL to query the interfaces
- if (!DeviceIoControl(
- aApitInstance->DeviceHandle,
- IOCTL_OTLWF_ENUMERATE_DEVICES,
- nullptr, 0,
- pDeviceList, cbDeviceList,
- nullptr,
- &Overlapped))
- {
- dwError = GetLastError();
- if (dwError != ERROR_IO_PENDING)
- {
- LogError(API_DEFAULT, "DeviceIoControl(IOCTL_OTLWF_ENUMERATE_DEVICES) failed, %!WINERROR!", dwError);
- goto error;
- }
- dwError = ERROR_SUCCESS;
- }
-
- // Get the result of the IO operation
- if (!GetOverlappedResultEx(
- aApitInstance->DeviceHandle,
- &Overlapped,
- &dwBytesReturned,
- c_MaxOverlappedWaitTimeMS,
- TRUE))
- {
- dwError = GetLastError();
- if (dwError == WAIT_TIMEOUT)
- {
- dwError = ERROR_TIMEOUT;
- CancelIoEx(aApitInstance->DeviceHandle, &Overlapped);
- }
- LogError(API_DEFAULT, "GetOverlappedResult for notification failed, %!WINERROR!", dwError);
- goto error;
- }
-
- // Calculate the expected size of the full buffer
- cbDeviceList =
- FIELD_OFFSET(otDeviceList, aDevices) +
- pDeviceList->aDevicesLength * sizeof(otDeviceList::aDevices);
-
- // Make sure they returned a complete buffer
- if (dwBytesReturned != sizeof(otDeviceList::aDevicesLength)) break;
-
- // If we get here that means we didn't have a big enough buffer
- // Reallocate a new buffer
- free(pDeviceList);
- pDeviceList = (otDeviceList*)malloc(cbDeviceList);
- if (pDeviceList == nullptr)
- {
- LogError(API_DEFAULT, "Failed to allocate otDeviceList of %u bytes.", cbDeviceList);
- dwError = ERROR_NOT_ENOUGH_MEMORY;
- goto error;
- }
- RtlZeroMemory(pDeviceList, cbDeviceList);
- }
-
-error:
-
- if (dwError != ERROR_SUCCESS)
- {
- free(pDeviceList);
- pDeviceList = nullptr;
- }
-
- if (Overlapped.hEvent)
- {
- CloseHandle(Overlapped.hEvent);
- }
-
- LogFuncExitMsg(API_DEFAULT, "%d devices", pDeviceList == nullptr ? -1 : (int)pDeviceList->aDevicesLength);
-
- return pDeviceList;
-}
-
-OTAPI
-otInstance *
-OTCALL
-otInstanceInit(
- _In_ otApiInstance *aApitInstance,
- _In_ const GUID *aDeviceGuid
- )
-{
- otInstance *aInstance = nullptr;
-
- OTLWF_DEVICE Result = {0};
- if (aApitInstance &&
- SendIOCTL(
- aApitInstance,
- IOCTL_OTLWF_QUERY_DEVICE,
- (LPVOID)aDeviceGuid,
- sizeof(GUID),
- &Result,
- sizeof(Result)
- ) == ERROR_SUCCESS)
- {
- aInstance = (otInstance*)malloc(sizeof(otInstance));
- if (aInstance)
- {
- aInstance->ApiHandle = aApitInstance;
- aInstance->InterfaceGuid = *aDeviceGuid;
- aInstance->CompartmentID = Result.CompartmentID;
-
- if (ConvertInterfaceGuidToLuid(aDeviceGuid, &aInstance->InterfaceLuid) != ERROR_SUCCESS ||
- ConvertInterfaceLuidToIndex(&aInstance->InterfaceLuid, &aInstance->InterfaceIndex) != ERROR_SUCCESS)
- {
- LogError(API_DEFAULT, "Failed to convert interface guid to index!");
- free(aInstance);
- aInstance = nullptr;
- }
- }
- }
-
- return aInstance;
-}
-
-OTAPI
-GUID
-OTCALL
-otGetDeviceGuid(
- otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return {};
- return aInstance->InterfaceGuid;
-}
-
-OTAPI
-uint32_t
-OTCALL
-otGetDeviceIfIndex(
- otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return (uint32_t)-1;
- return aInstance->InterfaceIndex;
-}
-
-OTAPI
-uint32_t
-OTCALL
-otGetCompartmentId(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return (uint32_t)-1;
- return aInstance->CompartmentID;
-}
-
-OTAPI
-const char *
-OTCALL
-otGetVersionString()
-{
- char* szVersion = (char*)malloc(sizeof(c_Version));
- if (szVersion)
- {
- memcpy_s(szVersion, sizeof(c_Version), c_Version, sizeof(c_Version));
- }
- return szVersion;
-}
-
-OTAPI
-otError
-OTCALL
-otIp6SetEnabled(
- _In_ otInstance *aInstance,
- bool aEnabled
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_INTERFACE, (BOOLEAN)aEnabled));
-}
-
-OTAPI
-bool
-OTCALL
-otIp6IsEnabled(
- _In_ otInstance *aInstance
- )
-{
- BOOLEAN Result = FALSE;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_INTERFACE, &Result);
- return Result != FALSE;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetEnabled(
- _In_ otInstance *aInstance,
- bool aEnabled
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_THREAD, (BOOLEAN)aEnabled));
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetAutoStart(
- _In_ otInstance *aInstance,
- bool aStartAutomatically
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_THREAD_AUTO_START, (BOOLEAN)(aStartAutomatically ? TRUE : FALSE)));
-}
-
-OTAPI
-bool
-OTCALL
-otThreadGetAutoStart(
- otInstance *aInstance
- )
-{
- BOOLEAN Result = FALSE;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_THREAD_AUTO_START, &Result);
- return Result != FALSE;
-}
-
-OTAPI
-bool
-OTCALL
-otThreadIsSingleton(
- _In_ otInstance *aInstance
- )
-{
- BOOLEAN Result = FALSE;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_SINGLETON, &Result);
- return Result != FALSE;
-}
-
-OTAPI
-otError
-OTCALL
-otLinkActiveScan(
- _In_ otInstance *aInstance,
- uint32_t aScanChannels,
- uint16_t aScanDuration,
- otHandleActiveScanResult aCallback,
- _In_ void *aCallbackContext
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- aInstance->ApiHandle->SetCallback(
- aInstance->ApiHandle->ActiveScanCallbacks,
- aInstance->InterfaceGuid, aCallback, aCallbackContext
- );
-
- PackedBuffer3 Buffer(aInstance->InterfaceGuid, aScanChannels, aScanDuration);
- return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_ACTIVE_SCAN, &Buffer, sizeof(Buffer), nullptr, 0));
-}
-
-OTAPI
-bool
-OTCALL
-otLinkIsActiveScanInProgress(
- _In_ otInstance *aInstance
- )
-{
- BOOLEAN Result = FALSE;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_ACTIVE_SCAN, &Result);
- return Result != FALSE;
-}
-
-OTAPI
-otError
-OTCALL
-otLinkEnergyScan(
- _In_ otInstance *aInstance,
- uint32_t aScanChannels,
- uint16_t aScanDuration,
- _In_ otHandleEnergyScanResult aCallback,
- _In_ void *aCallbackContext
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- aInstance->ApiHandle->SetCallback(
- aInstance->ApiHandle->EnergyScanCallbacks,
- aInstance->InterfaceGuid, aCallback, aCallbackContext
- );
-
- PackedBuffer3 Buffer(aInstance->InterfaceGuid, aScanChannels, aScanDuration);
- return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_ENERGY_SCAN, &Buffer, sizeof(Buffer), nullptr, 0));
-}
-
-OTAPI
-bool
-OTCALL
-otLinkIsEnergyScanInProgress(
- _In_ otInstance *aInstance
- )
-{
- BOOLEAN Result = FALSE;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_ENERGY_SCAN, &Result);
- return Result != FALSE;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadDiscover(
- _In_ otInstance *aInstance,
- uint32_t aScanChannels,
- uint16_t aPanid,
- bool aJoiner,
- bool aEnableEui64Filtering,
- otHandleActiveScanResult aCallback,
- void *aCallbackContext
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- aInstance->ApiHandle->SetCallback(
- aInstance->ApiHandle->DiscoverCallbacks,
- aInstance->InterfaceGuid, aCallback, aCallbackContext
- );
-
- PackedBuffer5 Buffer(aInstance->InterfaceGuid, aScanChannels, aPanid, aJoiner, aEnableEui64Filtering);
- return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_DISCOVER, &Buffer, sizeof(Buffer), nullptr, 0));
-}
-
-OTAPI
-bool
-OTCALL
-otIsDiscoverInProgress(
- _In_ otInstance *aInstance
- )
-{
- BOOLEAN Result = FALSE;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_DISCOVER, &Result);
- return Result != FALSE;
-}
-
-OTAPI
-otError
-OTCALL
-otLinkSendDataRequest(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- UNREFERENCED_PARAMETER(aInstance);
- return OT_ERROR_NOT_IMPLEMENTED; // TODO
-}
-
-OTAPI
-uint8_t
-OTCALL
-otLinkGetChannel(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0xFF;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_CHANNEL, &Result);
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otLinkSetChannel(
- _In_ otInstance *aInstance,
- uint8_t aChannel
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_CHANNEL, aChannel));
-}
-
-OTAPI
-otError
-OTCALL
-otDatasetSetDelayTimerMinimal(
- _In_ otInstance *aInstance,
- uint32_t aDelayTimerMinimal
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- // TODO
- UNREFERENCED_PARAMETER(aDelayTimerMinimal);
- return OT_ERROR_NOT_IMPLEMENTED;
-}
-
-OTAPI
-otError
-OTCALL
-otDatasetCreateNewNetwork(
- _In_ otInstance *aInstance,
- _Out_ otOperationalDataset *aDataset
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- // TODO
- UNREFERENCED_PARAMETER(aDataset);
- return OT_ERROR_NOT_IMPLEMENTED;
-}
-
-OTAPI
-uint32_t
-OTCALL
-otDatasetGetDelayTimerMinimal(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return 0;
- // TODO
- return 0;
-}
-
-OTAPI
-uint8_t
-OTCALL
-otThreadGetMaxAllowedChildren(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAX_CHILDREN, &Result);
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetMaxAllowedChildren(
- _In_ otInstance *aInstance,
- uint8_t aMaxChildren
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_MAX_CHILDREN, aMaxChildren));
-}
-
-OTAPI
-uint32_t
-OTCALL
-otThreadGetChildTimeout(
- _In_ otInstance *aInstance
- )
-{
- uint32_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_CHILD_TIMEOUT, &Result);
- return Result;
-}
-
-OTAPI
-void
-OTCALL
-otThreadSetChildTimeout(
- _In_ otInstance *aInstance,
- uint32_t aTimeout
- )
-{
- if (aInstance == nullptr) return;
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_CHILD_TIMEOUT, aTimeout);
-}
-
-OTAPI
-const
-otExtAddress *
-OTCALL
-otLinkGetExtendedAddress(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return nullptr;
-
- otExtAddress *Result = (otExtAddress*)malloc(sizeof(otExtAddress));
- if (Result && QueryIOCTL(aInstance, IOCTL_OTLWF_OT_EXTENDED_ADDRESS, Result) != ERROR_SUCCESS)
- {
- free(Result);
- Result = nullptr;
- }
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otLinkSetExtendedAddress(
- _In_ otInstance *aInstance,
- const otExtAddress *aExtAddress
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_EXTENDED_ADDRESS, aExtAddress));
-}
-
-OTAPI
-const otExtendedPanId *
-OTCALL
-otThreadGetExtendedPanId(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return nullptr;
-
- otExtendedPanId *Result = (otExtendedPanId*)malloc(sizeof(otExtendedPanId));
- if (Result == nullptr) return nullptr;
- if (QueryIOCTL(aInstance, IOCTL_OTLWF_OT_EXTENDED_PANID, Result) != ERROR_SUCCESS)
- {
- free(Result);
- Result = nullptr;
- }
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetExtendedPanId(
- _In_ otInstance *aInstance,
- const otExtendedPanId *aExtendedPanId
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_EXTENDED_PANID, aExtendedPanId));
-}
-
-OTAPI
-void
-OTCALL
-otLinkGetFactoryAssignedIeeeEui64(
- _In_ otInstance *aInstance,
- _Out_ otExtAddress *aEui64
-)
-{
- if (aInstance == nullptr) return;
- (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_FACTORY_EUI64, aEui64);
-}
-
-OTAPI
-otError
-OTCALL
-otThreadGetLeaderRloc(
- _In_ otInstance *aInstance,
- _Out_ otIp6Address *aLeaderRloc
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_LEADER_RLOC, aLeaderRloc));
-}
-
-OTAPI
-otLinkModeConfig
-OTCALL
-otThreadGetLinkMode(
- _In_ otInstance *aInstance
- )
-{
- otLinkModeConfig Result = {0};
- static_assert(sizeof(otLinkModeConfig) == 4, "The size of otLinkModeConfig should be 4 bytes");
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_LINK_MODE, &Result);
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetLinkMode(
- _In_ otInstance *aInstance,
- otLinkModeConfig aConfig
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- static_assert(sizeof(otLinkModeConfig) == 4, "The size of otLinkModeConfig should be 4 bytes");
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_LINK_MODE, aConfig));
-}
-
-OTAPI
-const otMasterKey *
-OTCALL
-otThreadGetMasterKey(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return nullptr;
-
- otMasterKey *Result = (otMasterKey*)malloc(sizeof(otMasterKey));
- if (Result == nullptr) return nullptr;
- if (QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MASTER_KEY, Result) != ERROR_SUCCESS)
- {
- free(Result);
- return nullptr;
- }
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetMasterKey(
- _In_ otInstance *aInstance,
- const otMasterKey *aKey
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_MASTER_KEY, aKey));
-}
-
-OTAPI
-const otPSKc *
-OTCALL
-otThreadGetPSKc(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return nullptr;
-
- otPSKc *Result = (otPSKc*)malloc(sizeof(otPSKc));
- if (Result == nullptr) return nullptr;
- if (QueryIOCTL(aInstance, IOCTL_OTLWF_OT_PSKC, Result) != ERROR_SUCCESS)
- {
- free(Result);
- return nullptr;
- }
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetPSKc(
- _In_ otInstance *aInstance,
- const otPSKc *aPSKc
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_PSKC, aPSKc));
-}
-
-OTAPI
-const otIp6Address *
-OTCALL
-otThreadGetLinkLocalIp6Address(
- _In_ otInstance *aInstance
- )
-{
- otIp6Address *Result = (otIp6Address*)malloc(sizeof(otIp6Address));
- if (Result && QueryIOCTL(aInstance, IOCTL_OTLWF_OT_LINK_LOCAL_ADDRESS, Result) != ERROR_SUCCESS)
- {
- free(Result);
- Result = nullptr;
- }
- return Result;
-}
-
-OTAPI
-const otIp6Address *
-OTCALL
-otThreadGetRloc(
- _In_ otInstance *aInstance
- )
-{
- otIp6Address *Result = (otIp6Address*)malloc(sizeof(otIp6Address));
- if (Result && QueryIOCTL(aInstance, IOCTL_OTLWF_OT_RLOC, Result) != ERROR_SUCCESS)
- {
- free(Result);
- Result = nullptr;
- }
- return Result;
-}
-
-OTAPI
-const otIp6Address *
-OTCALL
-otThreadGetMeshLocalEid(
- _In_ otInstance *aInstance
- )
-{
- otIp6Address *Result = (otIp6Address*)malloc(sizeof(otIp6Address));
- if (Result && QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MESH_LOCAL_EID, Result) != ERROR_SUCCESS)
- {
- free(Result);
- Result = nullptr;
- }
- return Result;
-}
-
-OTAPI
-const otMeshLocalPrefix *
-OTCALL
-otThreadGetMeshLocalPrefix(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return nullptr;
-
- otMeshLocalPrefix *Result = (otMeshLocalPrefix*)malloc(sizeof(otMeshLocalPrefix));
- if (Result && QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MESH_LOCAL_PREFIX, Result) != ERROR_SUCCESS)
- {
- free(Result);
- Result = nullptr;
- }
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetMeshLocalPrefix(
- _In_ otInstance *aInstance,
- const otMeshLocalPrefix *aMeshLocalPrefix
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_MESH_LOCAL_PREFIX, aMeshLocalPrefix));
-}
-
-OTAPI
-otError
-OTCALL
-otThreadGetNetworkDataLeader(
- _In_ otInstance *aInstance,
- bool aStable,
- _Out_ uint8_t *aData,
- _Out_ uint8_t *aDataLength
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- UNREFERENCED_PARAMETER(aInstance);
- UNREFERENCED_PARAMETER(aStable);
- UNREFERENCED_PARAMETER(aData);
- UNREFERENCED_PARAMETER(aDataLength);
- return OT_ERROR_NOT_IMPLEMENTED; // TODO
-}
-
-OTAPI
-otError
-OTCALL
-otThreadGetNetworkDataLocal(
- _In_ otInstance *aInstance,
- bool aStable,
- _Out_ uint8_t *aData,
- _Out_ uint8_t *aDataLength
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- UNREFERENCED_PARAMETER(aInstance);
- UNREFERENCED_PARAMETER(aStable);
- UNREFERENCED_PARAMETER(aData);
- UNREFERENCED_PARAMETER(aDataLength);
- return OT_ERROR_NOT_IMPLEMENTED; // TODO
-}
-
-OTAPI
-const char *
-OTCALL
-otThreadGetNetworkName(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return nullptr;
-
- otNetworkName *Result = (otNetworkName*)malloc(sizeof(otNetworkName));
- if (Result && QueryIOCTL(aInstance, IOCTL_OTLWF_OT_NETWORK_NAME, Result) != ERROR_SUCCESS)
- {
- free(Result);
- Result = nullptr;
- }
- return (char*)Result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetNetworkName(
- _In_ otInstance *aInstance,
- _In_ const char *aNetworkName
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- otNetworkName Buffer = {0};
- strcpy_s(Buffer.m8, sizeof(Buffer), aNetworkName);
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_NETWORK_NAME, (const otNetworkName*)&Buffer));
-}
-
-OTAPI
-otError
-OTCALL
-otNetDataGetNextOnMeshPrefix(
- _In_ otInstance *aInstance,
- _Inout_ otNetworkDataIterator *aIterator,
- _Out_ otBorderRouterConfig *aConfig
- )
-{
- if (aInstance == nullptr || aConfig == nullptr) return OT_ERROR_INVALID_ARGS;
-
- BOOLEAN aLocal = FALSE;
- PackedBuffer3 InBuffer(aInstance->InterfaceGuid, aLocal, *aIterator);
- BYTE OutBuffer[sizeof(uint8_t) + sizeof(otBorderRouterConfig)];
-
- otError aError =
- DwordToThreadError(
- SendIOCTL(
- aInstance->ApiHandle,
- IOCTL_OTLWF_OT_NEXT_ON_MESH_PREFIX,
- &InBuffer, sizeof(InBuffer),
- OutBuffer, sizeof(OutBuffer)));
-
- if (aError == OT_ERROR_NONE)
- {
- memcpy(aIterator, OutBuffer, sizeof(uint8_t));
- memcpy(aConfig, OutBuffer + sizeof(uint8_t), sizeof(otBorderRouterConfig));
- }
- else
- {
- ZeroMemory(aConfig, sizeof(otBorderRouterConfig));
- }
-
- return aError;
-}
-
-OTAPI
-otError
-OTCALL
-otBorderRouterGetNextOnMeshPrefix(
- _In_ otInstance *aInstance,
- _Inout_ otNetworkDataIterator *aIterator,
- _Out_ otBorderRouterConfig *aConfig
- )
-{
- if (aInstance == nullptr || aConfig == nullptr) return OT_ERROR_INVALID_ARGS;
-
- BOOLEAN aLocal = TRUE;
- PackedBuffer3 InBuffer(aInstance->InterfaceGuid, aLocal, *aIterator);
- BYTE OutBuffer[sizeof(uint8_t) + sizeof(otBorderRouterConfig)];
-
- otError aError =
- DwordToThreadError(
- SendIOCTL(
- aInstance->ApiHandle,
- IOCTL_OTLWF_OT_NEXT_ON_MESH_PREFIX,
- &InBuffer, sizeof(InBuffer),
- OutBuffer, sizeof(OutBuffer)));
-
- if (aError == OT_ERROR_NONE)
- {
- memcpy(aIterator, OutBuffer, sizeof(uint8_t));
- memcpy(aConfig, OutBuffer + sizeof(uint8_t), sizeof(otBorderRouterConfig));
- }
- else
- {
- ZeroMemory(aConfig, sizeof(otBorderRouterConfig));
- }
-
- return aError;
-}
-
-OTAPI
-otError
-OTCALL
-otBorderRouterGetNextRoute(
- _In_ otInstance *aInstance,
- _Inout_ otNetworkDataIterator *aIterator,
- _Out_ otExternalRouteConfig *aConfig
- )
-{
- if (aInstance == nullptr || aConfig == nullptr) return OT_ERROR_INVALID_ARGS;
-
- BOOLEAN aLocal = TRUE;
- PackedBuffer3 InBuffer(aInstance->InterfaceGuid, aLocal, *aIterator);
- BYTE OutBuffer[sizeof(uint8_t) + sizeof(otExternalRouteConfig)];
-
- otError aError =
- DwordToThreadError(
- SendIOCTL(
- aInstance->ApiHandle,
- IOCTL_OTLWF_OT_NEXT_ROUTE,
- &InBuffer, sizeof(InBuffer),
- OutBuffer, sizeof(OutBuffer)));
-
- if (aError == OT_ERROR_NONE)
- {
- memcpy(aIterator, OutBuffer, sizeof(uint8_t));
- memcpy(aConfig, OutBuffer + sizeof(uint8_t), sizeof(otExternalRouteConfig));
- }
- else
- {
- ZeroMemory(aConfig, sizeof(otExternalRouteConfig));
- }
-
- return aError;
-}
-
-OTAPI
-otPanId
-OTCALL
-otLinkGetPanId(
- _In_ otInstance *aInstance
- )
-{
- otPanId Result = {0};
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_PAN_ID, &Result);
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otLinkSetPanId(
- _In_ otInstance *aInstance,
- otPanId aPanId
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_PAN_ID, aPanId));
-}
-
-OTAPI
-bool
-OTCALL
-otThreadIsRouterRoleEnabled(
- _In_ otInstance *aInstance
- )
-{
- BOOLEAN Result = {0};
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_ROUTER_ROLL_ENABLED, &Result);
- return Result != FALSE;
-}
-
-OTAPI
-void
-OTCALL
-otThreadSetRouterRoleEnabled(
- _In_ otInstance *aInstance,
- bool aEnabled
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_ROUTER_ROLL_ENABLED, (BOOLEAN)aEnabled);
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetPreferredRouterId(
- _In_ otInstance *aInstance,
- uint8_t aRouterId
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_PAN_ID, aRouterId));
-}
-
-OTAPI
-otShortAddress
-OTCALL
-otLinkGetShortAddress(
- _In_ otInstance *aInstance
- )
-{
- otShortAddress Result = {0};
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_SHORT_ADDRESS, &Result);
- return Result;
-}
-
-BOOL
-GetAdapterAddresses(
- PIP_ADAPTER_ADDRESSES * ppIAA
-)
-{
- PIP_ADAPTER_ADDRESSES pIAA = NULL;
- DWORD len = 0;
- DWORD flags;
-
- flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER;
- if (GetAdaptersAddresses(AF_INET6, flags, NULL, NULL, &len) != ERROR_BUFFER_OVERFLOW)
- return FALSE;
-
- pIAA = (PIP_ADAPTER_ADDRESSES)malloc(len);
- if (pIAA) {
- GetAdaptersAddresses(AF_INET6, flags, NULL, pIAA, &len);
- *ppIAA = pIAA;
- return TRUE;
- }
- return FALSE;
-}
-
-OTAPI
-const otNetifAddress *
-OTCALL
-otIp6GetUnicastAddresses(
- _In_ otInstance *aInstance
- )
-{
- LogFuncEntry(API_DEFAULT);
- if (aInstance == nullptr)
- {
- LogFuncExit(API_DEFAULT);
- return nullptr;
- }
-
- // Put the current thead in the correct compartment
- bool RevertCompartmentOnExit = false;
- ULONG OriginalCompartmentID = GetCurrentThreadCompartmentId();
- if (OriginalCompartmentID != aInstance->CompartmentID)
- {
- DWORD dwError = ERROR_SUCCESS;
- if ((dwError = SetCurrentThreadCompartmentId(aInstance->CompartmentID)) != ERROR_SUCCESS)
- {
- LogError(API_DEFAULT, "SetCurrentThreadCompartmentId failed, %!WINERROR!", dwError);
- return nullptr;
- }
- RevertCompartmentOnExit = true;
- }
-
- otNetifAddress *addrs = nullptr;
- ULONG AddrCount = 0;
-
- // Query the current adapter addresses and format them in the proper output format
- PIP_ADAPTER_ADDRESSES pIAAList;
- if (GetAdapterAddresses(&pIAAList))
- {
- // Loop through all the interfaces
- for (auto pIAA = pIAAList; pIAA != nullptr; pIAA = pIAA->Next)
- {
- // Look for the right interface
- if (pIAA->Ipv6IfIndex != aInstance->InterfaceIndex) continue;
-
- // Look through all unicast addresses
- for (auto pUnicastAddr = pIAA->FirstUnicastAddress;
- pUnicastAddr != nullptr;
- pUnicastAddr = pUnicastAddr->Next)
- {
- AddrCount++;
- }
-
- break;
- }
-
- // If we didn't find any addresses, just break out
- if (AddrCount == 0) goto error;
-
- // Allocate the addresses
- addrs = (otNetifAddress*)malloc(AddrCount * sizeof(otNetifAddress));
- if (addrs == nullptr)
- {
- LogWarning(API_DEFAULT, "Not enough memory to alloc otNetifAddress array");
- goto error;
- }
- ZeroMemory(addrs, AddrCount * sizeof(otNetifAddress));
-
- // Initialize the next pointers
- for (ULONG i = 0; i < AddrCount; i++)
- {
- addrs[i].mNext = (i + 1 == AddrCount) ? nullptr : &addrs[i + 1];
- }
-
- AddrCount = 0;
-
- // Loop through all the interfaces
- for (auto pIAA = pIAAList; pIAA != nullptr; pIAA = pIAA->Next)
- {
- // Look for the right interface
- if (pIAA->Ipv6IfIndex != aInstance->InterfaceIndex) continue;
-
- // Look through all unicast addresses
- for (auto pUnicastAddr = pIAA->FirstUnicastAddress;
- pUnicastAddr != nullptr;
- pUnicastAddr = pUnicastAddr->Next)
- {
- LPSOCKADDR_IN6 pAddr = (LPSOCKADDR_IN6)pUnicastAddr->Address.lpSockaddr;
-
- // Copy the necessary parameters
- memcpy(&addrs[AddrCount].mAddress, &pAddr->sin6_addr, sizeof(pAddr->sin6_addr));
- addrs[AddrCount].mPreferred = pUnicastAddr->PreferredLifetime != 0;
- addrs[AddrCount].mValid = pUnicastAddr->ValidLifetime != 0;
- addrs[AddrCount].mPrefixLength = pUnicastAddr->OnLinkPrefixLength;
-
- AddrCount++;
- }
-
- break;
- }
-
- error:
- free(pIAAList);
- }
- else
- {
- LogError(API_DEFAULT, "GetAdapterAddresses failed!");
- }
-
- // Revert the comparment if necessary
- if (RevertCompartmentOnExit)
- {
- (VOID)SetCurrentThreadCompartmentId(OriginalCompartmentID);
- }
-
- LogFuncExitMsg(API_DEFAULT, "%d addrs", AddrCount);
- return addrs;
-}
-
-OTAPI
-otError
-OTCALL
-otIp6AddUnicastAddress(
- _In_ otInstance *aInstance,
- const otNetifAddress *aAddress
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- // Put the current thead in the correct compartment
- bool RevertCompartmentOnExit = false;
- ULONG OriginalCompartmentID = GetCurrentThreadCompartmentId();
- if (OriginalCompartmentID != aInstance->CompartmentID)
- {
- DWORD dwError = ERROR_SUCCESS;
- if ((dwError = SetCurrentThreadCompartmentId(aInstance->CompartmentID)) != ERROR_SUCCESS)
- {
- LogError(API_DEFAULT, "SetCurrentThreadCompartmentId failed, %!WINERROR!", dwError);
- return OT_ERROR_FAILED;
- }
- RevertCompartmentOnExit = true;
- }
-
- MIB_UNICASTIPADDRESS_ROW newRow;
- InitializeUnicastIpAddressEntry(&newRow);
-
- newRow.InterfaceIndex = aInstance->InterfaceIndex;
- newRow.InterfaceLuid = aInstance->InterfaceLuid;
- newRow.Address.si_family = AF_INET6;
- newRow.Address.Ipv6.sin6_family = AF_INET6;
-
- static_assert(sizeof(IN6_ADDR) == sizeof(otIp6Address), "Windows and OpenThread IPv6 Addr Structs must be same size");
-
- memcpy(&newRow.Address.Ipv6.sin6_addr, &aAddress->mAddress, sizeof(IN6_ADDR));
- newRow.OnLinkPrefixLength = aAddress->mPrefixLength;
- newRow.PreferredLifetime = aAddress->mPreferred ? 0xffffffff : 0;
- newRow.ValidLifetime = aAddress->mValid ? 0xffffffff : 0;
- newRow.PrefixOrigin = IpPrefixOriginOther; // Derived from network XPANID
- newRow.SkipAsSource = FALSE; // Allow automatic binding to this address (default)
-
- if (IN6_IS_ADDR_LINKLOCAL(&newRow.Address.Ipv6.sin6_addr))
- {
- newRow.SuffixOrigin = IpSuffixOriginLinkLayerAddress; // Derived from Extended MAC address
- }
- else
- {
- newRow.SuffixOrigin = IpSuffixOriginRandom; // Was created randomly
- }
-
- DWORD dwError = CreateUnicastIpAddressEntry(&newRow);
-
- // Revert the comparment if necessary
- if (RevertCompartmentOnExit)
- {
- (VOID)SetCurrentThreadCompartmentId(OriginalCompartmentID);
- }
-
- if (dwError != ERROR_SUCCESS)
- {
- LogError(API_DEFAULT, "CreateUnicastIpAddressEntry failed %!WINERROR!", dwError);
- return OT_ERROR_FAILED;
- }
-
- return OT_ERROR_NONE;
-}
-
-OTAPI
-otError
-OTCALL
-otIp6RemoveUnicastAddress(
- _In_ otInstance *aInstance,
- const otIp6Address *aAddress
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- // Put the current thead in the correct compartment
- bool RevertCompartmentOnExit = false;
- ULONG OriginalCompartmentID = GetCurrentThreadCompartmentId();
- if (OriginalCompartmentID != aInstance->CompartmentID)
- {
- DWORD dwError = ERROR_SUCCESS;
- if ((dwError = SetCurrentThreadCompartmentId(aInstance->CompartmentID)) != ERROR_SUCCESS)
- {
- LogError(API_DEFAULT, "SetCurrentThreadCompartmentId failed, %!WINERROR!", dwError);
- return OT_ERROR_FAILED;
- }
- RevertCompartmentOnExit = true;
- }
-
- MIB_UNICASTIPADDRESS_ROW deleteRow;
- InitializeUnicastIpAddressEntry(&deleteRow);
-
- deleteRow.InterfaceIndex = aInstance->InterfaceIndex;
- deleteRow.InterfaceLuid = aInstance->InterfaceLuid;
- deleteRow.Address.si_family = AF_INET6;
-
- memcpy(&deleteRow.Address.Ipv6.sin6_addr, aAddress, sizeof(IN6_ADDR));
-
- DWORD dwError = DeleteUnicastIpAddressEntry(&deleteRow);
-
- // Revert the comparment if necessary
- if (RevertCompartmentOnExit)
- {
- (VOID)SetCurrentThreadCompartmentId(OriginalCompartmentID);
- }
-
- if (dwError != ERROR_SUCCESS)
- {
- LogError(API_DEFAULT, "DeleteUnicastIpAddressEntry failed %!WINERROR!", dwError);
- return OT_ERROR_FAILED;
- }
-
- return OT_ERROR_NONE;
-}
-
-OTAPI
-otError
-OTCALL
-otSetStateChangedCallback(
- _In_ otInstance *aInstance,
- _In_ otStateChangedCallback aCallback,
- _In_ void *aContext
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- bool success =
- aInstance->ApiHandle->SetCallback(
- aInstance->ApiHandle->StateChangedCallbacks,
- aInstance->InterfaceGuid, aCallback, aContext
- );
- return success ? OT_ERROR_NONE : OT_ERROR_ALREADY;
-}
-
-OTAPI
-void
-OTCALL
-otRemoveStateChangeCallback(
- _In_ otInstance *aInstance,
- _In_ otStateChangedCallback /* aCallback */,
- _In_ void *aContext
- )
-{
- if (aInstance == nullptr) return;
- aInstance->ApiHandle->SetCallback(
- aInstance->ApiHandle->StateChangedCallbacks,
- aInstance->InterfaceGuid, (otStateChangedCallback)nullptr, aContext
- );
-}
-
-OTAPI
-otError
-OTCALL
-otDatasetGetActive(
- _In_ otInstance *aInstance,
- _Out_ otOperationalDataset *aDataset
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_ACTIVE_DATASET, aDataset));
-}
-
-OTAPI
-otError
-OTCALL
-otDatasetSetActive(
- _In_ otInstance *aInstance,
- const otOperationalDataset *aDataset
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_ACTIVE_DATASET, aDataset));
-}
-
-OTAPI
-otError
-OTCALL
-otDatasetGetPending(
- _In_ otInstance *aInstance,
- _Out_ otOperationalDataset *aDataset
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_PENDING_DATASET, aDataset));
-}
-
-OTAPI
-otError
-OTCALL
-otDatasetSetPending(
- _In_ otInstance *aInstance,
- const otOperationalDataset *aDataset
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_PENDING_DATASET, aDataset));
-}
-
-OTAPI
-otError
-OTCALL
-otDatasetSendMgmtActiveGet(
- _In_ otInstance *aInstance,
- const otOperationalDatasetComponents *aDatasetComponents,
- const uint8_t *aTlvTypes,
- uint8_t aLength,
- _In_opt_ const otIp6Address *aAddress
- )
-{
- if (aInstance == nullptr || aDatasetComponents == nullptr) return OT_ERROR_INVALID_ARGS;
- if (aTlvTypes == nullptr && aLength != 0) return OT_ERROR_INVALID_ARGS;
-
- DWORD BufferSize = sizeof(GUID) + sizeof(uint8_t) + aLength;
- if (aAddress) BufferSize += sizeof(otIp6Address);
- PBYTE Buffer = (PBYTE)malloc(BufferSize);
- if (Buffer == nullptr) return OT_ERROR_NO_BUFS;
-
- memcpy_s(Buffer, BufferSize, &aInstance->InterfaceGuid, sizeof(GUID));
- memcpy_s(Buffer + sizeof(GUID), BufferSize - sizeof(GUID), aDatasetComponents, sizeof(otOperationalDatasetComponents));
- memcpy_s(Buffer + sizeof(GUID), BufferSize - sizeof(GUID), &aLength, sizeof(aLength));
- if (aLength > 0)
- memcpy_s(Buffer + sizeof(GUID) + sizeof(uint8_t), BufferSize - sizeof(GUID) - sizeof(uint8_t), aTlvTypes, aLength);
- if (aAddress)
- memcpy_s(Buffer + sizeof(GUID) + sizeof(uint8_t) + aLength, BufferSize - sizeof(GUID) - sizeof(uint8_t) - aLength, aAddress, sizeof(otIp6Address));
-
- otError result =
- DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_SEND_ACTIVE_GET, Buffer, BufferSize, nullptr, 0));
-
- free(Buffer);
- return result;
-}
-
-OTAPI
-otError
-OTCALL
-otDatasetSendMgmtActiveSet(
- _In_ otInstance *aInstance,
- const otOperationalDataset *aDataset,
- const uint8_t *aTlvs,
- uint8_t aLength
- )
-{
- if (aInstance == nullptr || aDataset == nullptr) return OT_ERROR_INVALID_ARGS;
- if (aTlvs == nullptr && aLength != 0) return OT_ERROR_INVALID_ARGS;
-
- DWORD BufferSize = sizeof(GUID) + sizeof(otOperationalDataset) + sizeof(uint8_t) + aLength;
- PBYTE Buffer = (PBYTE)malloc(BufferSize);
- if (Buffer == nullptr) return OT_ERROR_NO_BUFS;
-
- memcpy_s(Buffer, BufferSize, &aInstance->InterfaceGuid, sizeof(GUID));
- memcpy_s(Buffer + sizeof(GUID), BufferSize - sizeof(GUID), aDataset, sizeof(otOperationalDataset));
- memcpy_s(Buffer + sizeof(GUID) + sizeof(otOperationalDataset), BufferSize - sizeof(GUID) - sizeof(otOperationalDataset), &aLength, sizeof(aLength));
- if (aLength > 0)
- memcpy_s(Buffer + sizeof(GUID) + sizeof(otOperationalDataset) + sizeof(uint8_t), BufferSize - sizeof(GUID) - sizeof(otOperationalDataset) - sizeof(uint8_t), aTlvs, aLength);
-
- otError result =
- DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_SEND_ACTIVE_SET, Buffer, BufferSize, nullptr, 0));
-
- free(Buffer);
- return result;
-}
-
-OTAPI
-otError
-OTCALL
-otDatasetSendMgmtPendingGet(
- _In_ otInstance *aInstance,
- const otOperationalDatasetComponents *aDatasetComponents,
- const uint8_t *aTlvTypes,
- uint8_t aLength,
- _In_opt_ const otIp6Address *aAddress
- )
-{
- if (aInstance == nullptr || aDatasetComponents == nullptr) return OT_ERROR_INVALID_ARGS;
- if (aTlvTypes == nullptr && aLength != 0) return OT_ERROR_INVALID_ARGS;
-
- DWORD BufferSize = sizeof(GUID) + sizeof(uint8_t) + aLength;
- if (aAddress) BufferSize += sizeof(otIp6Address);
- PBYTE Buffer = (PBYTE)malloc(BufferSize);
- if (Buffer == nullptr) return OT_ERROR_NO_BUFS;
-
- memcpy_s(Buffer, BufferSize, &aInstance->InterfaceGuid, sizeof(GUID));
- memcpy_s(Buffer + sizeof(GUID), BufferSize - sizeof(GUID), aDatasetComponents, sizeof(otOperationalDatasetComponents));
- memcpy_s(Buffer + sizeof(GUID), BufferSize - sizeof(GUID), &aLength, sizeof(aLength));
- if (aLength > 0)
- memcpy_s(Buffer + sizeof(GUID) + sizeof(uint8_t), BufferSize - sizeof(GUID) - sizeof(uint8_t), aTlvTypes, aLength);
- if (aAddress)
- memcpy_s(Buffer + sizeof(GUID) + sizeof(uint8_t) + aLength, BufferSize - sizeof(GUID) - sizeof(uint8_t) - aLength, aAddress, sizeof(otIp6Address));
-
- otError result =
- DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_SEND_PENDING_GET, Buffer, BufferSize, nullptr, 0));
-
- free(Buffer);
- return result;
-}
-
-OTAPI
-otError
-OTCALL
-otDatasetSendMgmtPendingSet(
- _In_ otInstance *aInstance,
- const otOperationalDataset *aDataset,
- const uint8_t *aTlvs,
- uint8_t aLength
- )
-{
- if (aInstance == nullptr || aDataset == nullptr) return OT_ERROR_INVALID_ARGS;
- if (aTlvs == nullptr && aLength != 0) return OT_ERROR_INVALID_ARGS;
-
- DWORD BufferSize = sizeof(GUID) + sizeof(otOperationalDataset) + sizeof(uint8_t) + aLength;
- PBYTE Buffer = (PBYTE)malloc(BufferSize);
- if (Buffer == nullptr) return OT_ERROR_NO_BUFS;
-
- memcpy_s(Buffer, BufferSize, &aInstance->InterfaceGuid, sizeof(GUID));
- memcpy_s(Buffer + sizeof(GUID), BufferSize - sizeof(GUID), aDataset, sizeof(otOperationalDataset));
- memcpy_s(Buffer + sizeof(GUID) + sizeof(otOperationalDataset), BufferSize - sizeof(GUID) - sizeof(otOperationalDataset), &aLength, sizeof(aLength));
- if (aLength > 0)
- memcpy_s(Buffer + sizeof(GUID) + sizeof(otOperationalDataset) + sizeof(uint8_t), BufferSize - sizeof(GUID) - sizeof(otOperationalDataset) - sizeof(uint8_t), aTlvs, aLength);
-
- otError result =
- DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_SEND_PENDING_SET, Buffer, BufferSize, nullptr, 0));
-
- free(Buffer);
- return result;
-}
-
-OTAPI
-uint32_t
-OTCALL
-otLinkGetPollPeriod(
- _In_ otInstance *aInstance
- )
-{
- uint32_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_POLL_PERIOD, &Result);
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otLinkSetPollPeriod(
- _In_ otInstance *aInstance,
- uint32_t aPollPeriod
- )
-{
- otError result = OT_ERROR_INVALID_ARGS;
-
- if (aInstance) result = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_POLL_PERIOD, aPollPeriod));
-
- return result;
-}
-
-OTAPI
-uint8_t
-OTCALL
-otThreadGetLocalLeaderWeight(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_LOCAL_LEADER_WEIGHT, &Result);
- return Result;
-}
-
-OTAPI
-void
-OTCALL
-otThreadSetLocalLeaderWeight(
- _In_ otInstance *aInstance,
- uint8_t aWeight
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_LOCAL_LEADER_WEIGHT, aWeight);
-}
-
-OTAPI
-uint32_t
-OTCALL
-otThreadGetLocalLeaderPartitionId(
- _In_ otInstance *aInstance
- )
-{
- uint32_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_LOCAL_LEADER_PARTITION_ID, &Result);
- return Result;
-}
-
-OTAPI
-void
-OTCALL
-otThreadSetLocalLeaderPartitionId(
- _In_ otInstance *aInstance,
- uint32_t aPartitionId
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_LOCAL_LEADER_PARTITION_ID, aPartitionId);
-}
-
-OTAPI
-uint16_t
-OTCALL
-otThreadGetJoinerUdpPort(
- _In_ otInstance *aInstance
-)
-{
- uint16_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_JOINER_UDP_PORT, &Result);
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetJoinerUdpPort(
- _In_ otInstance *aInstance,
- uint16_t aJoinerUdpPort
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_JOINER_UDP_PORT, aJoinerUdpPort));
-}
-
-OTAPI
-otError
-OTCALL
-otBorderRouterAddOnMeshPrefix(
- _In_ otInstance *aInstance,
- const otBorderRouterConfig *aConfig
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_ADD_BORDER_ROUTER, aConfig));
-}
-
-OTAPI
-otError
-OTCALL
-otBorderRouterRemoveOnMeshPrefix(
- _In_ otInstance *aInstance,
- const otIp6Prefix *aPrefix
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_REMOVE_BORDER_ROUTER, aPrefix));
-}
-
-OTAPI
-otError
-OTCALL
-otBorderRouterAddRoute(
- _In_ otInstance *aInstance,
- const otExternalRouteConfig *aConfig
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_ADD_EXTERNAL_ROUTE, aConfig));
-}
-
-OTAPI
-otError
-OTCALL
-otBorderRouterRemoveRoute(
- _In_ otInstance *aInstance,
- const otIp6Prefix *aPrefix
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_REMOVE_EXTERNAL_ROUTE, aPrefix));
-}
-
-OTAPI
-otError
-OTCALL
-otBorderRouterRegister(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_SEND_SERVER_DATA));
-}
-
-OTAPI
-uint32_t
-OTCALL
-otThreadGetContextIdReuseDelay(
- _In_ otInstance *aInstance
- )
-{
- uint32_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_CONTEXT_ID_REUSE_DELAY, &Result);
- return Result;
-}
-
-OTAPI
-void
-OTCALL
-otThreadSetContextIdReuseDelay(
- _In_ otInstance *aInstance,
- uint32_t aDelay
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_CONTEXT_ID_REUSE_DELAY, aDelay);
-}
-
-OTAPI
-uint32_t
-OTCALL
-otThreadGetKeySequenceCounter(
- _In_ otInstance *aInstance
- )
-{
- uint32_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_KEY_SEQUENCE_COUNTER, &Result);
- return Result;
-}
-
-OTAPI
-void
-OTCALL
-otThreadSetKeySequenceCounter(
- _In_ otInstance *aInstance,
- uint32_t aKeySequenceCounter
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_KEY_SEQUENCE_COUNTER, aKeySequenceCounter);
-}
-
-OTAPI
-uint32_t
-OTCALL
-otThreadGetKeySwitchGuardTime(
- _In_ otInstance *aInstance
- )
-{
- uint32_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_KEY_SWITCH_GUARDTIME, &Result);
- return Result;
-}
-
-OTAPI
-void
-OTCALL
-otThreadSetKeySwitchGuardTime(
- _In_ otInstance *aInstance,
- uint32_t aKeySwitchGuardTime
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_KEY_SWITCH_GUARDTIME, aKeySwitchGuardTime);
-}
-
-OTAPI
-uint8_t
-OTCALL
-otThreadGetNetworkIdTimeout(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_NETWORK_ID_TIMEOUT, &Result);
- return Result;
-}
-
-OTAPI
-void
-OTCALL
-otThreadSetNetworkIdTimeout(
- _In_ otInstance *aInstance,
- uint8_t aTimeout
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_NETWORK_ID_TIMEOUT, aTimeout);
-}
-
-OTAPI
-uint8_t
-OTCALL
-otThreadGetRouterUpgradeThreshold(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_ROUTER_UPGRADE_THRESHOLD, &Result);
- return Result;
-}
-
-OTAPI
-void
-OTCALL
-otThreadSetRouterUpgradeThreshold(
- _In_ otInstance *aInstance,
- uint8_t aThreshold
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_ROUTER_UPGRADE_THRESHOLD, aThreshold);
-}
-
-OTAPI
-uint8_t
-OTCALL
-otThreadGetRouterDowngradeThreshold(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_ROUTER_DOWNGRADE_THRESHOLD, &Result);
- return Result;
-}
-
-OTAPI
-void
-OTCALL
-otThreadSetRouterDowngradeThreshold(
- _In_ otInstance *aInstance,
- uint8_t aThreshold
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_ROUTER_DOWNGRADE_THRESHOLD, aThreshold);
-}
-
-OTAPI
-uint8_t
-OTCALL
-otThreadGetRouterSelectionJitter(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_ROUTER_SELECTION_JITTER, &Result);
- return Result;
-}
-
-OTAPI
-void
-OTCALL
-otThreadSetRouterSelectionJitter(
- _In_ otInstance *aInstance,
- uint8_t aRouterJitter
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_ROUTER_SELECTION_JITTER, aRouterJitter);
-}
-
-OTAPI
-otError
-OTCALL
-otThreadReleaseRouterId(
- _In_ otInstance *aInstance,
- uint8_t aRouterId
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_RELEASE_ROUTER_ID, aRouterId));
-}
-
-OTAPI
-otError
-OTCALL
-otThreadBecomeDetached(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)OT_DEVICE_ROLE_DETACHED));
-}
-
-OTAPI
-otError
-OTCALL
-otThreadBecomeChild(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)OT_DEVICE_ROLE_CHILD));
-}
-
-OTAPI
-otError
-OTCALL
-otThreadBecomeRouter(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)OT_DEVICE_ROLE_ROUTER));
-}
-
-OTAPI
-otError
-OTCALL
-otThreadBecomeLeader(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, (uint8_t)OT_DEVICE_ROLE_LEADER));
-}
-
-OTAPI
-otMacFilterAddressMode
-OTCALL
-otLinkFilterGetAddressMode(
- _In_ otInstance *aInstance
- )
-{
- otMacFilterAddressMode mode = OT_MAC_FILTER_ADDRESS_MODE_DISABLED;
- BOOLEAN enabled = 0;
-
- if (aInstance)
- {
- (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_WHITELIST_ENABLED, &enabled);
-
- if (enabled)
- {
- mode = OT_MAC_FILTER_ADDRESS_MODE_WHITELIST;
- }
- else
- {
- (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_BLACKLIST_ENABLED, &enabled);
-
- if (enabled)
- {
- mode = OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST;
- }
- }
- }
-
- return mode;
-}
-
-OTAPI
-otError
-OTCALL
-otLinkFilterSetAddressMode(
- _In_ otInstance *aInstance,
- otMacFilterAddressMode aMode
- )
-{
- otError error = OT_ERROR_NONE;
-
- if (aInstance == nullptr)
- {
- error = OT_ERROR_INVALID_ARGS;
- }
- else
- {
- bool enabled = false;
-
- if (aMode == OT_MAC_FILTER_ADDRESS_MODE_WHITELIST)
- {
- enabled = true;
- error = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_WHITELIST_ENABLED, (BOOLEAN)enabled));
- }
- else if (aMode == OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST)
- {
- enabled = true;
- error = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_BLACKLIST_ENABLED, (BOOLEAN)enabled));
- }
- else
- {
- error = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_WHITELIST_ENABLED, (BOOLEAN)enabled));
- }
- }
- return error;
-}
-
-OTAPI
-otError
-OTCALL
-otLinkFilterAddAddress(
- _In_ otInstance *aInstance,
- const otExtAddress *aExtAddr
- )
-{
- otError error = OT_ERROR_NONE;
-
- if (aInstance == nullptr || aExtAddr == nullptr)
- {
- error = OT_ERROR_INVALID_ARGS;
- }
- else
- {
- // same effect to add an address to the address filter with IOCTL_OTLWF_OT_ADD_MAC_WHITELIST or
- // IOCTL_OTLWF_OT_ADD_MAC_BLACKLIST.
- error = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_ADD_MAC_WHITELIST, aExtAddr));
- }
-
- return error;
-}
-
-
-OTAPI
-otError
-OTCALL
-otLinkFilterRemoveAddress(
- _In_ otInstance *aInstance,
- const otExtAddress *aExtAddr
- )
-{
- otError error = OT_ERROR_NONE;
-
- if (aInstance == nullptr || aExtAddr == nullptr)
- {
- error = OT_ERROR_INVALID_ARGS;
- }
- else
- {
- // same effect to remove an address from the address filter with IOCTL_OTLWF_OT_REMOVE_MAC_WHITELIST or
- // IOCTL_OTLWF_OT_REMOVE_MAC_BLACKLIST.
- error = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_REMOVE_MAC_WHITELIST, aExtAddr));
- }
-
- return error;
-}
-
-OTAPI
-void
-OTCALL
-otLinkFilterClearAddresses(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance)
- {
- // same effect to clear the addresses from the address filter with IOCTL_OTLWF_OT_CLEAR_MAC_WHITELIST or
- // IOCTL_OTLWF_OT_CLEAR_MAC_BLACKLIST.
- (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_CLEAR_MAC_WHITELIST);
- }
-}
-
-OTAPI
-otError
-OTCALL
-otLinkFilterGetNextAddress(
- _In_ otInstance *aInstance,
- _Inout_ otMacFilterIterator *aIterator,
- _Out_ otMacFilterEntry *aEntry
- )
-{
- otError error = OT_ERROR_NONE;
-
- if (aInstance == nullptr || aIterator == nullptr|| aEntry == nullptr)
- {
- error = OT_ERROR_INVALID_ARGS;
- }
- else
- {
- // same effect to get an in-use address filter entry with IOCTL_OTLWF_OT_NEXT_MAC_WHITELIST or
- // IOCTL_OTLWF_OT_NEXT_MAC_BLACKLIST.
- return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_NEXT_MAC_WHITELIST, aIterator, aEntry));
- }
- return OT_ERROR_NOT_FOUND;
-}
-
-
-OTAPI
-otError
-OTCALL
-otLinkFilterAddRssIn(
- _In_ otInstance *aInstance,
- const otExtAddress *aExtAddr,
- int8_t aRss
- )
-{
- otError error = OT_ERROR_NONE;
-
- if (aInstance == nullptr)
- {
- error = OT_ERROR_INVALID_ARGS;
- }
- else
- {
- if (aExtAddr == nullptr)
- {
- PackedBuffer2 Buffer(aInstance->InterfaceGuid, aRss);
-
- error = DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_ADD_MAC_FIXED_RSS,
- &Buffer, sizeof(Buffer), nullptr, 0));
- }
- else
- {
- PackedBuffer3 Buffer(aInstance->InterfaceGuid, *aExtAddr, aRss);
-
- error = DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_ADD_MAC_FIXED_RSS,
- &Buffer, sizeof(Buffer), nullptr, 0));
- }
-
- }
- return error;
-}
-
-OTAPI
-otError
-OTCALL
-otLinkFilterRemoveRssIn(
- _In_ otInstance *aInstance,
- const otExtAddress *aExtAddr
- )
-{
- otError error = OT_ERROR_NONE;
-
- if (aInstance == nullptr)
- {
- error = OT_ERROR_INVALID_ARGS;
- }
- else
- {
- if (aExtAddr == nullptr)
- {
- error = DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_REMOVE_MAC_FIXED_RSS,
- nullptr, 0, nullptr, 0));
- }
- else
- {
- PackedBuffer2 Buffer(aInstance->InterfaceGuid, *aExtAddr);
- error = DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_REMOVE_MAC_FIXED_RSS,
- &Buffer, sizeof(Buffer), nullptr, 0));
- }
- }
- return error;
-}
-
-OTAPI
-void
-OTCALL
-otLinkFilterClearRssIn(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance)
- {
- (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_CLEAR_MAC_FIXED_RSS);
- }
-}
-
-OTAPI
-otError
-OTCALL
-otLinkFilterGetNextRssIn(
- _In_ otInstance *aInstance,
- _Inout_ otMacFilterIterator *aIterator,
- _Out_ otMacFilterEntry *aEntry
- )
-{
- otError error = OT_ERROR_NONE;
-
- if (aInstance == nullptr || aIterator == nullptr|| aEntry == nullptr)
- {
- error = OT_ERROR_INVALID_ARGS;
- }
- else
- {
- return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_NEXT_MAC_FIXED_RSS, aIterator, aEntry));
- }
- return OT_ERROR_NOT_FOUND;
-}
-
-OTAPI
-void
-OTCALL
-otInstanceReset(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_PLATFORM_RESET);
-}
-
-OTAPI
-void
-OTCALL
-otInstanceFactoryReset(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance) (void)SetIOCTL(aInstance, IOCTL_OTLWF_OT_FACTORY_RESET);
-}
-
-OTAPI
-otError
-OTCALL
-otThreadGetChildInfoById(
- _In_ otInstance *aInstance,
- uint16_t aChildId,
- _Out_ otChildInfo *aChildInfo
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_CHILD_INFO_BY_ID, &aChildId, aChildInfo));
-}
-
-OTAPI
-otError
-OTCALL
-otThreadGetChildInfoByIndex(
- _In_ otInstance *aInstance,
- uint8_t aChildIndex,
- _Out_ otChildInfo *aChildInfo
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_CHILD_INFO_BY_INDEX, &aChildIndex, aChildInfo));
-}
-
-OTAPI
-otError
-OTCALL
-otThreadGetChildNextIp6Address(
- _In_ otInstance *aInstance,
- uint8_t aChildIndex,
- _Inout_ otChildIp6AddressIterator *aIterator,
- _Out_ otIp6Address *aAddress)
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- UNREFERENCED_PARAMETER(aChildIndex);
- UNREFERENCED_PARAMETER(aIterator);
- UNREFERENCED_PARAMETER(aAddress);
- return OT_ERROR_NOT_IMPLEMENTED; // TODO
-}
-
-OTAPI
-otError
-OTCALL
-otThreadGetNextNeighborInfo(
- _In_ otInstance *aInstance,
- _Inout_ otNeighborInfoIterator *aIterator,
- _Out_ otNeighborInfo *aInfo
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- UNREFERENCED_PARAMETER(aIterator);
- UNREFERENCED_PARAMETER(aInfo);
- return OT_ERROR_NOT_IMPLEMENTED; // TODO
-}
-
-OTAPI
-otDeviceRole
-OTCALL
-otThreadGetDeviceRole(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = OT_DEVICE_ROLE_DISABLED;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_DEVICE_ROLE, &Result);
- return (otDeviceRole)Result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadGetEidCacheEntry(
- _In_ otInstance *aInstance,
- uint8_t aIndex,
- _Out_ otEidCacheEntry *aEntry
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_EID_CACHE_ENTRY, &aIndex, aEntry));
-}
-
-OTAPI
-otError
-OTCALL
-otThreadGetLeaderData(
- _In_ otInstance *aInstance,
- _Out_ otLeaderData *aLeaderData
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_LEADER_DATA, aLeaderData));
-}
-
-OTAPI
-uint8_t
-OTCALL
-otThreadGetLeaderRouterId(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0xFF;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_LEADER_ROUTER_ID, &Result);
- return Result;
-}
-
-OTAPI
-uint8_t
-OTCALL
-otThreadGetLeaderWeight(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0xFF;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_LEADER_WEIGHT, &Result);
- return Result;
-}
-
-OTAPI
-uint8_t
-OTCALL
-otNetDataGetVersion(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0xFF;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_NETWORK_DATA_VERSION, &Result);
- return Result;
-}
-
-OTAPI
-uint32_t
-OTCALL
-otThreadGetPartitionId(
- _In_ otInstance *aInstance
- )
-{
- uint32_t Result = 0xFFFFFFFF;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_PARTITION_ID, &Result);
- return Result;
-}
-
-OTAPI
-uint16_t
-OTCALL
-otThreadGetRloc16(
- _In_ otInstance *aInstance
- )
-{
- uint16_t Result = 0xFFFF;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_RLOC16, &Result);
- return Result;
-}
-
-OTAPI
-uint8_t
-OTCALL
-otThreadGetRouterIdSequence(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0xFF;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_ROUTER_ID_SEQUENCE, &Result);
- return Result;
-}
-
-OTAPI
-uint8_t
-OTCALL
-otThreadGetMaxRouterId(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAX_ROUTER_ID, &Result);
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadGetRouterInfo(
- _In_ otInstance *aInstance,
- uint16_t aRouterId,
- _Out_ otRouterInfo *aRouterInfo
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_ROUTER_INFO, &aRouterId, aRouterInfo));
-}
-
-OTAPI
-otError
-OTCALL
-otThreadGetParentInfo(
- _In_ otInstance *aInstance,
- _Out_ otRouterInfo *aParentInfo
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- static_assert(sizeof(otRouterInfo) == 20, "The size of otRouterInfo should be 20 bytes");
- return DwordToThreadError(QueryIOCTL(aInstance, IOCTL_OTLWF_OT_PARENT_INFO, aParentInfo));
-}
-
-OTAPI
-uint8_t
-OTCALL
-otNetDataGetStableVersion(
- _In_ otInstance *aInstance
- )
-{
- uint8_t Result = 0xFF;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_STABLE_NETWORK_DATA_VERSION, &Result);
- return Result;
-}
-
-OTAPI
-const otMacCounters*
-OTCALL
-otLinkGetCounters(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return nullptr;
-
- otMacCounters* aCounters = (otMacCounters*)malloc(sizeof(otMacCounters));
- if (aCounters)
- {
- if (ERROR_SUCCESS != QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MAC_COUNTERS, aCounters))
- {
- free(aCounters);
- aCounters = nullptr;
- }
- }
- return aCounters;
-}
-
-OTAPI
-void
-OTCALL
-otMessageGetBufferInfo(
- _In_ otInstance *,
- _Out_ otBufferInfo *aBufferInfo
- )
-{
- // Not supported on Windows
- ZeroMemory(aBufferInfo, sizeof(otBufferInfo));
-}
-
-OTAPI
-bool
-OTCALL
-otIsIp6AddressEqual(
- const otIp6Address *a,
- const otIp6Address *b
- )
-{
- return memcmp(a->mFields.m8, b->mFields.m8, sizeof(otIp6Address)) == 0;
-}
-
-OTAPI
-otError
-OTCALL
-otIp6AddressFromString(
- const char *str,
- otIp6Address *address
- )
-{
- otError error = OT_ERROR_NONE;
- uint8_t *dst = reinterpret_cast(address->mFields.m8);
- uint8_t *endp = reinterpret_cast(address->mFields.m8 + 15);
- uint8_t *colonp = NULL;
- uint16_t val = 0;
- uint8_t count = 0;
- bool first = true;
- char ch;
- uint8_t d;
-
- memset(address->mFields.m8, 0, 16);
-
- dst--;
-
- for (;;)
- {
- ch = *str++;
- d = ch & 0xf;
-
- if (('a' <= ch && ch <= 'f') || ('A' <= ch && ch <= 'F'))
- {
- d += 9;
- }
- else if (ch == ':' || ch == '\0' || ch == ' ')
- {
- if (count)
- {
- if (dst + 2 > endp)
- {
- error = OT_ERROR_PARSE;
- goto exit;
- }
- *(dst + 1) = static_cast(val >> 8);
- *(dst + 2) = static_cast(val);
- dst += 2;
- count = 0;
- val = 0;
- }
- else if (ch == ':')
- {
- if (!(colonp == nullptr || first))
- {
- error = OT_ERROR_PARSE;
- goto exit;
- }
- colonp = dst;
- }
-
- if (ch == '\0' || ch == ' ')
- {
- break;
- }
-
- continue;
- }
- else
- {
- if (!('0' <= ch && ch <= '9'))
- {
- error = OT_ERROR_PARSE;
- goto exit;
- }
- }
-
- first = false;
- val = static_cast((val << 4) | d);
- if (!(++count <= 4))
- {
- error = OT_ERROR_PARSE;
- goto exit;
- }
- }
-
- while (colonp && dst > colonp)
- {
- *endp-- = *dst--;
- }
-
- while (endp > dst)
- {
- *endp-- = 0;
- }
-
-exit:
- return error;
-}
-
-OTAPI
-uint8_t
-OTCALL
-otIp6PrefixMatch(
- const otIp6Address *aFirst,
- const otIp6Address *aSecond
- )
-{
- uint8_t rval = 0;
- uint8_t diff;
-
- for (uint8_t i = 0; i < sizeof(otIp6Address); i++)
- {
- diff = aFirst->mFields.m8[i] ^ aSecond->mFields.m8[i];
-
- if (diff == 0)
- {
- rval += 8;
- }
- else
- {
- while ((diff & 0x80) == 0)
- {
- rval++;
- diff <<= 1;
- }
-
- break;
- }
- }
-
- return rval;
-}
-
-OTAPI
-const char *
-OTCALL
-otThreadErrorToString(
- otError aError
- )
-{
- const char *retval;
-
- switch (aError)
- {
- case OT_ERROR_NONE:
- retval = "OK";
- break;
-
- case OT_ERROR_FAILED:
- retval = "Failed";
- break;
-
- case OT_ERROR_DROP:
- retval = "Drop";
- break;
-
- case OT_ERROR_NO_BUFS:
- retval = "NoBufs";
- break;
-
- case OT_ERROR_NO_ROUTE:
- retval = "NoRoute";
- break;
-
- case OT_ERROR_BUSY:
- retval = "Busy";
- break;
-
- case OT_ERROR_PARSE:
- retval = "Parse";
- break;
-
- case OT_ERROR_INVALID_ARGS:
- retval = "InvalidArgs";
- break;
-
- case OT_ERROR_SECURITY:
- retval = "Security";
- break;
-
- case OT_ERROR_ADDRESS_QUERY:
- retval = "AddressQuery";
- break;
-
- case OT_ERROR_NO_ADDRESS:
- retval = "NoAddress";
- break;
-
- case OT_ERROR_ABORT:
- retval = "Abort";
- break;
-
- case OT_ERROR_NOT_IMPLEMENTED:
- retval = "NotImplemented";
- break;
-
- case OT_ERROR_INVALID_STATE:
- retval = "InvalidState";
- break;
-
- case OT_ERROR_NO_ACK:
- retval = "NoAck";
- break;
-
- case OT_ERROR_CHANNEL_ACCESS_FAILURE:
- retval = "ChannelAccessFailure";
- break;
-
- case OT_ERROR_DETACHED:
- retval = "Detached";
- break;
-
- case OT_ERROR_FCS:
- retval = "FcsErr";
- break;
-
- case OT_ERROR_NO_FRAME_RECEIVED:
- retval = "NoFrameReceived";
- break;
-
- case OT_ERROR_UNKNOWN_NEIGHBOR:
- retval = "UnknownNeighbor";
- break;
-
- case OT_ERROR_INVALID_SOURCE_ADDRESS:
- retval = "InvalidSourceAddress";
- break;
-
- case OT_ERROR_ADDRESS_FILTERED:
- retval = "AddressFiltered";
- break;
-
- case OT_ERROR_DESTINATION_ADDRESS_FILTERED:
- retval = "DestinationAddressFiltered";
- break;
-
- case OT_ERROR_NOT_FOUND:
- retval = "NotFound";
- break;
-
- case OT_ERROR_ALREADY:
- retval = "Already";
- break;
-
- case OT_ERROR_IP6_ADDRESS_CREATION_FAILURE:
- retval = "Ipv6AddressCreationFailure";
- break;
-
- case OT_ERROR_NOT_CAPABLE:
- retval = "NotCapable";
- break;
-
- case OT_ERROR_RESPONSE_TIMEOUT:
- retval = "ResponseTimeout";
- break;
-
- case OT_ERROR_DUPLICATED:
- retval = "Duplicated";
- break;
-
- case OT_ERROR_GENERIC:
- retval = "GenericError";
- break;
-
- default:
- retval = "UnknownErrorType";
- break;
- }
-
- return retval;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSendDiagnosticGet(
- _In_ otInstance *aInstance,
- const otIp6Address *aDestination,
- const uint8_t aTlvTypes[],
- uint8_t aCount
- )
-{
- if (aInstance == nullptr || aDestination == nullptr) return OT_ERROR_INVALID_ARGS;
- if (aTlvTypes == nullptr && aCount != 0) return OT_ERROR_INVALID_ARGS;
-
- DWORD BufferSize = sizeof(GUID) + sizeof(otIp6Address) + sizeof(uint8_t) + aCount;
- PBYTE Buffer = (PBYTE)malloc(BufferSize);
- if (Buffer == nullptr) return OT_ERROR_NO_BUFS;
-
- memcpy_s(Buffer, BufferSize, &aInstance->InterfaceGuid, sizeof(GUID));
- memcpy_s(Buffer + sizeof(GUID), BufferSize - sizeof(GUID), aDestination, sizeof(otIp6Address));
- memcpy_s(Buffer + sizeof(GUID) + sizeof(otIp6Address), BufferSize - sizeof(GUID) - sizeof(otIp6Address), &aCount, sizeof(aCount));
- memcpy_s(Buffer + sizeof(GUID) + sizeof(otIp6Address) + sizeof(uint8_t), BufferSize - sizeof(GUID) - sizeof(otIp6Address) - sizeof(uint8_t), aTlvTypes, aCount);
-
- otError result =
- DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_SEND_DIAGNOSTIC_GET, Buffer, BufferSize, nullptr, 0));
-
- free(Buffer);
- return result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSendDiagnosticReset(
- _In_ otInstance *aInstance,
- const otIp6Address *aDestination,
- const uint8_t aTlvTypes[],
- uint8_t aCount
- )
-{
- if (aInstance == nullptr || aDestination == nullptr) return OT_ERROR_INVALID_ARGS;
- if (aTlvTypes == nullptr && aCount != 0) return OT_ERROR_INVALID_ARGS;
-
- DWORD BufferSize = sizeof(GUID) + sizeof(otIp6Address) + sizeof(uint8_t) + aCount;
- PBYTE Buffer = (PBYTE)malloc(BufferSize);
- if (Buffer == nullptr) return OT_ERROR_NO_BUFS;
-
- memcpy_s(Buffer, BufferSize, &aInstance->InterfaceGuid, sizeof(GUID));
- memcpy_s(Buffer + sizeof(GUID), BufferSize - sizeof(GUID), aDestination, sizeof(otIp6Address));
- memcpy_s(Buffer + sizeof(GUID) + sizeof(otIp6Address), BufferSize - sizeof(GUID) - sizeof(otIp6Address), &aCount, sizeof(aCount));
- memcpy_s(Buffer + sizeof(GUID) + sizeof(otIp6Address) + sizeof(uint8_t), BufferSize - sizeof(GUID) - sizeof(otIp6Address) - sizeof(uint8_t), aTlvTypes, aCount);
-
- otError result =
- DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_SEND_DIAGNOSTIC_RESET, Buffer, BufferSize, nullptr, 0));
-
- free(Buffer);
- return result;
-}
-
-OTAPI
-otError
-OTCALL
-otCommissionerStart(
- _In_ otInstance *aInstance,
- _In_ otCommissionerStateCallback aStateCallback,
- _In_ otCommissionerJoinerCallback aJoinerCallback,
- _In_ void *aContext
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_COMMISIONER_START));
-}
-
-OTAPI
-otError
-OTCALL
-otCommissionerAddJoiner(
- _In_ otInstance *aInstance,
- const otExtAddress *aExtAddress,
- const char *aPSKd,
- uint32_t aTimeout
- )
-{
- if (aInstance == nullptr || aPSKd == nullptr) return OT_ERROR_INVALID_ARGS;
-
- size_t aPSKdLength = strnlen(aPSKd, OPENTHREAD_PSK_MAX_LENGTH + 1);
- if (aPSKdLength > OPENTHREAD_PSK_MAX_LENGTH)
- {
- return OT_ERROR_INVALID_ARGS;
- }
-
- uint8_t aExtAddressValid = aExtAddress ? 1 : 0;
-
- const ULONG BufferLength = sizeof(GUID) + sizeof(uint8_t) + sizeof(otExtAddress) + (ULONG)aPSKdLength + 1 + sizeof(aTimeout);
- BYTE Buffer[sizeof(GUID) + sizeof(uint8_t) + sizeof(otExtAddress) + OPENTHREAD_PSK_MAX_LENGTH + 1 + sizeof(aTimeout)] = {0};
- memcpy_s(Buffer, sizeof(Buffer), &aInstance->InterfaceGuid, sizeof(GUID));
- memcpy_s(Buffer + sizeof(GUID), sizeof(Buffer) - sizeof(GUID), &aExtAddressValid, sizeof(aExtAddressValid));
- if (aExtAddressValid)
- memcpy_s(Buffer + sizeof(GUID) + sizeof(uint8_t), sizeof(Buffer) - sizeof(GUID) - sizeof(uint8_t), aExtAddress, sizeof(otExtAddress));
- memcpy_s(Buffer + sizeof(GUID) + sizeof(uint8_t) + sizeof(otExtAddress), sizeof(Buffer) - sizeof(GUID) - sizeof(uint8_t) - sizeof(otExtAddress), aPSKd, aPSKdLength);
- memcpy_s(Buffer + sizeof(GUID) + sizeof(uint8_t) + sizeof(otExtAddress) + aPSKdLength + 1, sizeof(Buffer) - sizeof(GUID) - sizeof(uint8_t) - sizeof(otExtAddress) - aPSKdLength - 1, &aTimeout, sizeof(aTimeout));
-
- return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_COMMISIONER_ADD_JOINER, Buffer, BufferLength, nullptr, 0));
-}
-
-OTAPI
-otError
-OTCALL
-otCommissionerRemoveJoiner(
- _In_ otInstance *aInstance,
- const otExtAddress *aExtAddress
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- uint8_t aExtAddressValid = aExtAddress ? 1 : 0;
-
- BYTE Buffer[sizeof(GUID) + sizeof(uint8_t) + sizeof(otExtAddress)] = {0};
- memcpy_s(Buffer, sizeof(Buffer), &aInstance->InterfaceGuid, sizeof(GUID));
- memcpy_s(Buffer + sizeof(GUID), sizeof(Buffer) - sizeof(GUID), &aExtAddressValid, sizeof(aExtAddressValid));
- if (aExtAddressValid)
- memcpy_s(Buffer + sizeof(GUID) + sizeof(uint8_t), sizeof(Buffer) - sizeof(GUID) - sizeof(uint8_t), aExtAddress, sizeof(otExtAddress));
-
- return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_COMMISIONER_REMOVE_JOINER, Buffer, sizeof(Buffer), nullptr, 0));
-}
-
-OTAPI
-otError
-OTCALL
-otCommissionerSetProvisioningUrl(
- _In_ otInstance *aInstance,
- const char *aProvisioningUrl
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- size_t aProvisioningUrlLength = aProvisioningUrl ? strnlen(aProvisioningUrl, OPENTHREAD_PROV_URL_MAX_LENGTH + 1) : 0;
- if (aProvisioningUrlLength > OPENTHREAD_PROV_URL_MAX_LENGTH)
- {
- return OT_ERROR_INVALID_ARGS;
- }
-
- const ULONG BufferLength = sizeof(GUID) + (ULONG)aProvisioningUrlLength + 1;
- BYTE Buffer[sizeof(GUID) + OPENTHREAD_PROV_URL_MAX_LENGTH + 1] = {0};
- memcpy_s(Buffer, sizeof(Buffer), &aInstance->InterfaceGuid, sizeof(GUID));
- if (aProvisioningUrlLength > 0)
- memcpy_s(Buffer + sizeof(GUID), sizeof(Buffer) - sizeof(GUID), aProvisioningUrl, aProvisioningUrlLength);
-
- return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_COMMISIONER_PROVISIONING_URL, Buffer, BufferLength, nullptr, 0));
-}
-
-OTAPI
-otError
-OTCALL
-otCommissionerAnnounceBegin(
- otInstance *aInstance,
- uint32_t aChannelMask,
- uint8_t aCount,
- uint16_t aPeriod,
- const otIp6Address *aAddress
- )
-{
- if (aInstance == nullptr || aAddress == nullptr) return OT_ERROR_INVALID_ARGS;
-
- PackedBuffer5 Buffer(aInstance->InterfaceGuid, aChannelMask, aCount, aPeriod, *aAddress);
- return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_COMMISIONER_ANNOUNCE_BEGIN, &Buffer, sizeof(Buffer), nullptr, 0));
-}
-
-OTAPI
-otError
-OTCALL
-otCommissionerStop(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_COMMISIONER_STOP));
-}
-
-OTAPI
-otError
-OTCALL
-otCommissionerEnergyScan(
- _In_ otInstance *aInstance,
- uint32_t aChannelMask,
- uint8_t aCount,
- uint16_t aPeriod,
- uint16_t aScanDuration,
- const otIp6Address *aAddress,
- _In_ otCommissionerEnergyReportCallback aCallback,
- _In_ void *aContext
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- aInstance->ApiHandle->SetCallback(
- aInstance->ApiHandle->CommissionerEnergyReportCallbacks,
- aInstance->InterfaceGuid, aCallback, aContext
- );
-
- PackedBuffer6 Buffer(aInstance->InterfaceGuid, aChannelMask, aCount, aPeriod, aScanDuration, *aAddress);
- return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_COMMISSIONER_ENERGY_SCAN, &Buffer, sizeof(Buffer), nullptr, 0));
-}
-
-OTAPI
-otError
-OTCALL
-otCommissionerPanIdQuery(
- _In_ otInstance *aInstance,
- uint16_t aPanId,
- uint32_t aChannelMask,
- const otIp6Address *aAddress,
- _In_ otCommissionerPanIdConflictCallback aCallback,
- _In_ void *aContext
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
-
- aInstance->ApiHandle->SetCallback(
- aInstance->ApiHandle->CommissionerPanIdConflictCallbacks,
- aInstance->InterfaceGuid, aCallback, aContext
- );
-
- PackedBuffer4 Buffer(aInstance->InterfaceGuid, aPanId, aChannelMask, *aAddress);
- return DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_COMMISSIONER_PANID_QUERY, &Buffer, sizeof(Buffer), nullptr, 0));
-}
-
-OTAPI
-otError
-OTCALL
-otCommissionerSendMgmtGet(
- _In_ otInstance *aInstance,
- const uint8_t *aTlvs,
- uint8_t aLength
-)
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- if (aTlvs == nullptr && aLength != 0) return OT_ERROR_INVALID_ARGS;
-
- DWORD BufferSize = sizeof(GUID) + sizeof(uint8_t) + aLength;
- PBYTE Buffer = (PBYTE)malloc(BufferSize);
- if (Buffer == nullptr) return OT_ERROR_NO_BUFS;
-
- memcpy_s(Buffer, BufferSize, &aInstance->InterfaceGuid, sizeof(GUID));
- memcpy_s(Buffer + sizeof(GUID), BufferSize - sizeof(GUID), &aLength, sizeof(aLength));
- if (aLength > 0)
- memcpy_s(Buffer + sizeof(GUID) + sizeof(uint8_t), BufferSize - sizeof(GUID) - sizeof(uint8_t), aTlvs, aLength);
-
- otError result =
- DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_SEND_MGMT_COMMISSIONER_GET, Buffer, BufferSize, nullptr, 0));
-
- free(Buffer);
- return result;
-}
-
-OTAPI
-otError
-OTCALL
-otCommissionerSendMgmtSet(
- _In_ otInstance *aInstance,
- const otCommissioningDataset *aDataset,
- const uint8_t *aTlvs,
- uint8_t aLength
- )
-{
- if (aInstance == nullptr || aDataset == nullptr) return OT_ERROR_INVALID_ARGS;
- if (aTlvs == nullptr && aLength != 0) return OT_ERROR_INVALID_ARGS;
-
- DWORD BufferSize = sizeof(GUID) + sizeof(otCommissioningDataset) + sizeof(uint8_t) + aLength;
- PBYTE Buffer = (PBYTE)malloc(BufferSize);
- if (Buffer == nullptr) return OT_ERROR_NO_BUFS;
-
- memcpy_s(Buffer, BufferSize, &aInstance->InterfaceGuid, sizeof(GUID));
- memcpy_s(Buffer + sizeof(GUID), BufferSize - sizeof(GUID), aDataset, sizeof(otCommissioningDataset));
- memcpy_s(Buffer + sizeof(GUID) + sizeof(otCommissioningDataset), BufferSize - sizeof(GUID) - sizeof(otCommissioningDataset), &aLength, sizeof(aLength));
- if (aLength > 0)
- memcpy_s(Buffer + sizeof(GUID) + sizeof(otCommissioningDataset) + sizeof(uint8_t), BufferSize - sizeof(GUID) - sizeof(otCommissioningDataset) - sizeof(uint8_t), aTlvs, aLength);
-
- otError result =
- DwordToThreadError(SendIOCTL(aInstance->ApiHandle, IOCTL_OTLWF_OT_SEND_MGMT_COMMISSIONER_SET, Buffer, BufferSize, nullptr, 0));
-
- free(Buffer);
- return result;
-}
-
-OTAPI
-uint16_t
-OTCALL
-otCommissionerGetSessionId(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return 0;
- // TODO
- return 0;
-}
-
-OTAPI
-otError
-OTCALL
-otJoinerStart(
- _In_ otInstance *aInstance,
- _Null_terminated_ const char *aPSKd,
- _Null_terminated_ const char *aProvisioningUrl,
- _Null_terminated_ const char *aVendorName,
- _Null_terminated_ const char *aVendorModel,
- _Null_terminated_ const char *aVendorSwVersion,
- _Null_terminated_ const char *aVendorData,
- _In_ otJoinerCallback aCallback,
- _In_ void *aCallbackContext
- )
-{
- if (aInstance == nullptr || aPSKd == nullptr) return OT_ERROR_INVALID_ARGS;
-
- otCommissionConfig config = {0};
-
- size_t aPSKdLength = strlen(aPSKd);
- size_t aProvisioningUrlLength = aProvisioningUrl == nullptr ? 0 : strlen(aProvisioningUrl);
- size_t aVendorNameLength = aVendorName == nullptr ? 0 : strlen(aVendorName);
- size_t aVendorModelLength = aVendorModel == nullptr ? 0 : strlen(aVendorModel);
- size_t aVendorSwVersionLength = aVendorSwVersion == nullptr ? 0 : strlen(aVendorSwVersion);
- size_t aVendorDataLength = aVendorData == nullptr ? 0 : strlen(aVendorData);
-
- if (aPSKdLength > OPENTHREAD_PSK_MAX_LENGTH ||
- aProvisioningUrlLength > OPENTHREAD_PROV_URL_MAX_LENGTH ||
- aVendorNameLength > OPENTHREAD_VENDOR_NAME_MAX_LENGTH ||
- aVendorModelLength > OPENTHREAD_VENDOR_MODEL_MAX_LENGTH ||
- aVendorSwVersionLength > OPENTHREAD_VENDOR_SW_VERSION_MAX_LENGTH ||
- aVendorDataLength > OPENTHREAD_VENDOR_DATA_MAX_LENGTH)
- {
- return OT_ERROR_INVALID_ARGS;
- }
-
- memcpy_s(config.PSKd, sizeof(config.PSKd), aPSKd, aPSKdLength);
- memcpy_s(config.ProvisioningUrl, sizeof(config.ProvisioningUrl), aProvisioningUrl, aProvisioningUrlLength);
- memcpy_s(config.VendorName, sizeof(config.VendorName), aVendorName, aVendorNameLength);
- memcpy_s(config.VendorModel, sizeof(config.VendorModel), aVendorModel, aVendorModelLength);
- memcpy_s(config.VendorSwVersion, sizeof(config.VendorSwVersion), aVendorSwVersion, aVendorSwVersionLength);
- memcpy_s(config.VendorData, sizeof(config.VendorData), aVendorData, aVendorDataLength);
-
- aInstance->ApiHandle->SetCallback(
- aInstance->ApiHandle->JoinerCallbacks,
- aInstance->InterfaceGuid, aCallback, aCallbackContext
- );
-
- auto ret = DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_JOINER_START, (const otCommissionConfig*)&config));
-
- if (ret != OT_ERROR_NONE)
- {
- aInstance->ApiHandle->SetCallback(
- aInstance->ApiHandle->JoinerCallbacks,
- aInstance->InterfaceGuid, (otJoinerCallback)nullptr, (PVOID)nullptr
- );
- }
-
- return ret;
-}
-
-OTAPI
-otError
-OTCALL
-otJoinerStop(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_JOINER_STOP));
-}
-
-OTAPI
-otError
-OTCALL
-otJoinerGetId(
- _In_ otInstance *aInstance,
- _Out_ otExtAddress *aJoinerId
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- ZeroMemory(aJoinerId, sizeof(otExtAddress));
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_JOINER_ID, aJoinerId));
-}
-
-OTAPI
-int8_t
-OTCALL
-otThreadGetParentPriority(
- _In_ otInstance *aInstance
-)
-{
- int8_t Result = 0;
- if (aInstance) (void)QueryIOCTL(aInstance, IOCTL_OTLWF_OT_PARENT_PRIORITY, &Result);
- return Result;
-}
-
-OTAPI
-otError
-OTCALL
-otThreadSetParentPriority(
- _In_ otInstance *aInstance,
- int8_t aParentPriority
- )
-{
- if (aInstance == nullptr) return OT_ERROR_INVALID_ARGS;
- return DwordToThreadError(SetIOCTL(aInstance, IOCTL_OTLWF_OT_PARENT_PRIORITY, aParentPriority));
-}
-
-OTAPI
-const otMleCounters*
-OTCALL
-otThreadGetMleCounters(
- _In_ otInstance *aInstance
- )
-{
- if (aInstance == nullptr) return nullptr;
-
- otMleCounters* aCounters = (otMleCounters*)malloc(sizeof(otMleCounters));
- if (aCounters)
- {
- if (ERROR_SUCCESS != QueryIOCTL(aInstance, IOCTL_OTLWF_OT_MLE_COUNTERS, aCounters))
- {
- free(aCounters);
- aCounters = nullptr;
- }
- }
- return aCounters;
-}
diff --git a/examples/drivers/windows/otApi/precomp.h b/examples/drivers/windows/otApi/precomp.h
deleted file mode 100644
index 4bed0c1b1..000000000
--- a/examples/drivers/windows/otApi/precomp.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#pragma once
-
-#pragma warning(disable:28301) // No annotations for first declaration of *
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-// Define to export necessary functions
-#define OTDLL
-#define OTAPI EXTERN_C __declspec(dllexport)
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
diff --git a/examples/drivers/windows/otCli/main.cpp b/examples/drivers/windows/otCli/main.cpp
deleted file mode 100644
index c2ad1fe96..000000000
--- a/examples/drivers/windows/otCli/main.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include
-#include
-
-#include
-#include
-#include
-
-bool skipNextLine = false;
-
-int main(int argc, char *argv[])
-{
- otCliUartInit(NULL);
-
- char cmd[1024] = "\n";
- otPlatUartReceived((uint8_t*)cmd, 1);
-
- for (;;)
- {
- cmd[0] = 0;
- if (NULL == fgets(cmd, sizeof(cmd), stdin))
- continue;
-
- size_t cmdLen = strlen(cmd);
- if (cmdLen >= sizeof(cmd)) cmdLen = sizeof(cmd);
-
- if (strncmp(cmd, "exit", 4) == 0)
- break;
-
- skipNextLine = true;
- otPlatUartReceived((uint8_t*)cmd, (uint16_t)cmdLen);
- }
-
- return NO_ERROR;
-}
-
-EXTERN_C otError otPlatUartEnable(void)
-{
- return OT_ERROR_NONE;
-}
-
-EXTERN_C otError otPlatUartSend(const uint8_t *aBuf, uint16_t aBufLength)
-{
- otError error = OT_ERROR_NONE;
-
- if (!skipNextLine)
- {
- for (uint16_t i = 0; i < aBufLength; i++)
- fputc(aBuf[i], stdout);
- }
-
- if (aBuf[aBufLength - 1] == '\n')
- skipNextLine = false;
-
- otPlatUartSendDone();
-
- return error;
-}
-
-EXTERN_C void otPlatWakeHost(void)
-{
-
-}
diff --git a/examples/drivers/windows/otLwf/address.c b/examples/drivers/windows/otLwf/address.c
deleted file mode 100644
index 98abaa13b..000000000
--- a/examples/drivers/windows/otLwf/address.c
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "precomp.h"
-#include "address.tmh"
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-BOOLEAN
-otLwfOnAddressAdded(
- _In_ PMS_FILTER pFilter,
- _In_ const otNetifAddress* Addr,
- _In_ BOOLEAN UpdateWindows
- )
-{
- if (pFilter->otCachedAddrCount >= OT_MAX_ADDRESSES)
- {
- LogError(DRIVER_DEFAULT, "Failing to add new address as we have reached our max!");
- return FALSE;
- }
-
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! adding address: %!IPV6ADDR! (%u-bit prefix)",
- &pFilter->InterfaceGuid,
- (PIN6_ADDR)&Addr->mAddress,
- Addr->mPrefixLength
- );
-
- // Update local cache
- memcpy(pFilter->otCachedAddr + pFilter->otCachedAddrCount, Addr, sizeof(IN6_ADDR));
- pFilter->otCachedAddrCount++;
-
- // If this is link local, cache it as our link local address
- if (IN6_IS_ADDR_LINKLOCAL((PIN6_ADDR)&Addr->mAddress))
- {
- memcpy(&pFilter->otLinkLocalAddr, Addr, sizeof(IN6_ADDR));
- }
-
- // Update Windows if necessary
- if (UpdateWindows)
- {
- NTSTATUS status;
- MIB_UNICASTIPADDRESS_ROW newRow;
- MIB_IPFORWARD_ROW2 newRouteRow;
- COMPARTMENT_ID OriginalCompartmentID;
- InitializeUnicastIpAddressEntry(&newRow);
- InitializeIpForwardEntry(&newRouteRow);
-
- newRow.InterfaceIndex = pFilter->InterfaceIndex;
- newRow.InterfaceLuid = pFilter->InterfaceLuid;
- newRow.Address.si_family = AF_INET6;
- newRow.Address.Ipv6.sin6_family = AF_INET6;
-
- static_assert(sizeof(IN6_ADDR) == sizeof(otIp6Address), "Windows and OpenThread IPv6 Addr Structs must be same size");
-
- memcpy(&newRow.Address.Ipv6.sin6_addr, &Addr->mAddress, sizeof(IN6_ADDR));
- newRow.OnLinkPrefixLength = Addr->mPrefixLength;
- newRow.PreferredLifetime = Addr->mPreferred ? 0xffffffff : 0;
- newRow.ValidLifetime = Addr->mValid ? 0xffffffff : 0;
- newRow.PrefixOrigin = IpPrefixOriginOther; // Derived from network XPANID
- newRow.SkipAsSource = FALSE; // Allow automatic binding to this address (default)
-
- if (IN6_IS_ADDR_LINKLOCAL(&newRow.Address.Ipv6.sin6_addr))
- {
- newRow.SuffixOrigin = IpSuffixOriginLinkLayerAddress; // Derived from Extended MAC address
- }
- else
- {
- newRow.SuffixOrigin = IpSuffixOriginRandom; // Was created randomly
- }
-
- // Make sure we are in the right compartment
- (VOID)otLwfSetCompartment(pFilter, &OriginalCompartmentID);
-
- status = CreateUnicastIpAddressEntry(&newRow);
- //NT_ASSERT(NT_SUCCESS(status));
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "CreateUnicastIpAddressEntry failed %!STATUS!", status);
- }
-
- newRouteRow.InterfaceIndex = pFilter->InterfaceIndex;
- newRouteRow.InterfaceLuid = pFilter->InterfaceLuid;
- newRouteRow.DestinationPrefix.Prefix.si_family = AF_INET6;
- newRouteRow.DestinationPrefix.PrefixLength = 0;
-
- status = CreateIpForwardEntry2(&newRouteRow);
- if (!NT_SUCCESS(status) && status != STATUS_DUPLICATE_OBJECTID)
- {
- LogVerbose(DRIVER_DEFAULT, "CreateIpForwardEntry2 failed %!STATUS!", status);
- }
-
- // Revert back to original compartment
- otLwfRevertCompartment(OriginalCompartmentID);
- }
-
- return TRUE;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfOnAddressRemoved(
- _In_ PMS_FILTER pFilter,
- _In_ ULONG CachedIndex,
- _In_ BOOLEAN UpdateWindows
- )
-{
- // Cache address before we delete local cache
- IN6_ADDR Addr = pFilter->otCachedAddr[CachedIndex];
-
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! removing address: %!IPV6ADDR!", &pFilter->InterfaceGuid, &Addr);
-
- NT_ASSERT(pFilter->otCachedAddrCount != 0);
- NT_ASSERT(CachedIndex < pFilter->otCachedAddrCount);
-
- // Remove the cached entry
- if (CachedIndex + 1 != pFilter->otCachedAddrCount)
- memmove(pFilter->otCachedAddr + CachedIndex,
- pFilter->otCachedAddr + CachedIndex + 1,
- (pFilter->otCachedAddrCount - CachedIndex - 1) * sizeof(IN6_ADDR)
- );
- pFilter->otCachedAddrCount--;
-
- // Update Windows if necessary
- if (UpdateWindows)
- {
- MIB_UNICASTIPADDRESS_ROW deleteRow;
- COMPARTMENT_ID OriginalCompartmentID;
- InitializeUnicastIpAddressEntry(&deleteRow);
-
- deleteRow.InterfaceIndex = pFilter->InterfaceIndex;
- deleteRow.InterfaceLuid = pFilter->InterfaceLuid;
- deleteRow.Address.si_family = AF_INET6;
-
- deleteRow.Address.Ipv6.sin6_addr = Addr;
-
- // Make sure we are in the right compartment
- (VOID)otLwfSetCompartment(pFilter, &OriginalCompartmentID);
-
- // Best effort remove address from TCPIP
- (VOID)DeleteUnicastIpAddressEntry(&deleteRow);
-
- // Revert back to original compartment
- otLwfRevertCompartment(OriginalCompartmentID);
- }
-}
-
-int
-otLwfFindCachedAddrIndex(
- _In_ PMS_FILTER pFilter,
- _In_ PIN6_ADDR addr
- )
-{
- for (ULONG i = 0; i < pFilter->otCachedAddrCount; i++)
- if (memcmp(pFilter->otCachedAddr + i, addr, sizeof(IN6_ADDR)) == 0)
- return (int)i;
- return -1;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfInitializeAddresses(
- _In_ PMS_FILTER pFilter
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- PMIB_UNICASTIPADDRESS_TABLE pMibUnicastAddressTable = NULL;
- COMPARTMENT_ID OriginalCompartmentID;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- pFilter->otCachedAddrCount = 0;
-
- // Make sure we are in the right compartment
- (VOID)otLwfSetCompartment(pFilter, &OriginalCompartmentID);
-
- // Query the table for the current compartment
- status = GetUnicastIpAddressTable(AF_INET6, &pMibUnicastAddressTable);
-
- // Revert the compartment, now that we have the table
- otLwfRevertCompartment(OriginalCompartmentID);
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "GetUnicastIpAddressTable failed, %!STATUS!", status);
- goto error;
- }
-
- // Iterate through the addresses and delete (best effort) the ones for our interface
- for (ULONG Index = 0; Index < pMibUnicastAddressTable->NumEntries; Index++)
- {
- MIB_UNICASTIPADDRESS_ROW* row = &pMibUnicastAddressTable->Table[Index];
-
- if ((0 == memcmp(&row->InterfaceLuid, &pFilter->InterfaceLuid, sizeof(NET_LUID))))
- {
- LogInfo(DRIVER_DEFAULT, "Caching initial address: %!IPV6ADDR!", &row->Address.Ipv6.sin6_addr);
- memcpy(pFilter->otCachedAddr + pFilter->otCachedAddrCount, &row->Address.Ipv6.sin6_addr, sizeof(IN6_ADDR));
- pFilter->otCachedAddrCount++;
- }
- }
-
-error:
-
- if (NULL != pMibUnicastAddressTable)
- {
- FreeMibTable(pMibUnicastAddressTable);
- }
-
- LogFuncExitNT(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-// Callback from Windows TCPIP stack when an address change occurs
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-NETIOAPI_API_
-otLwfAddressChangeCallback(
- _In_ PVOID CallerContext,
- _In_opt_ PMIB_UNICASTIPADDRESS_ROW Row,
- _In_ MIB_NOTIFICATION_TYPE NotificationType
- )
-{
- PMS_FILTER pFilter = (PMS_FILTER)CallerContext;
- if (Row == NULL || pFilter == NULL) return;
-
- // Ignore notifications that aren't for our interface
- if (Row->InterfaceIndex != pFilter->InterfaceIndex) return;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "%p (%u) %!IPV6ADDR!", pFilter, NotificationType, &Row->Address.Ipv6.sin6_addr);
-
- // Since we don't pass in the initial flag, we shouldn't get this type
- NT_ASSERT(NotificationType != MibInitialNotification);
-
- // Make sure we can reference the interface
- if (ExAcquireRundownProtection(&pFilter->ExternalRefs))
- {
- if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE)
- {
- // Queue up the event for processing
- otLwfEventProcessingIndicateAddressChange(
- pFilter,
- NotificationType,
- &Row->Address.Ipv6.sin6_addr
- );
- }
- else
- {
- NT_ASSERT(FALSE); // Need to add support for this in tunnel mode
- }
-
- // Release reference on the interface
- ExReleaseRundownProtection(&pFilter->ExternalRefs);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-// Callback on the OpenThread thread for processing an address change
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingAddressChanged(
- _In_ PMS_FILTER pFilter,
- _In_ MIB_NOTIFICATION_TYPE NotificationType,
- _In_ PIN6_ADDR pAddr
- )
-{
- LogFuncEntryMsg(DRIVER_DEFAULT, "%p (%u)", pFilter, NotificationType);
-
- if (NotificationType == MibAddInstance ||
- NotificationType == MibParameterNotification)
- {
- MIB_UNICASTIPADDRESS_ROW Row;
- InitializeUnicastIpAddressEntry(&Row);
-
- Row.Address.si_family = AF_INET6;
- Row.Address.Ipv6.sin6_addr = *pAddr;
- Row.InterfaceIndex = pFilter->InterfaceIndex;
- Row.InterfaceLuid = pFilter->InterfaceLuid;
-
- NTSTATUS status = GetUnicastIpAddressEntry(&Row);
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "GetUnicastIpAddressEntry failed, %!STATUS!", status);
- }
- else
- {
- otNetifAddress otAddr = {0};
- memcpy(&otAddr.mAddress, pAddr, sizeof(IN6_ADDR));
- otAddr.mPreferred = Row.PreferredLifetime != 0;
- otAddr.mPrefixLength = Row.OnLinkPrefixLength;
- otAddr.mValid = Row.ValidLifetime != 0;
-
- BOOLEAN ShouldDelete = FALSE;
- BOOLEAN AddedToCache = FALSE;
- BOOLEAN IsCached = otLwfFindCachedAddrIndex(pFilter, pAddr) != -1;
-
- // Ignore link local addresses
- if (IN6_IS_ADDR_LINKLOCAL(pAddr) && !IsCached)
- {
- ShouldDelete = TRUE;
- goto add_complete;
- }
-
- // Add to the cache if this is a new address
- if (NotificationType == MibAddInstance && !IsCached)
- {
- AddedToCache = otLwfOnAddressAdded(pFilter, &otAddr, FALSE);
- if (AddedToCache == FALSE)
- {
- ShouldDelete = TRUE;
- goto add_complete;
- }
- }
-
- // Update OpenThread if we don't have this cached or it is being updated
- if (!IsCached/* || NotificationType == MibParameterNotification*/)
- {
- LogInfo(DRIVER_DEFAULT, "Filter %p trying to add/update address: %!IPV6ADDR!", pFilter, pAddr);
-
- // Add (or update) the address to OpenThread
- otError otError = otIp6AddUnicastAddress(pFilter->otCtx, &otAddr);
- if (otError != OT_ERROR_NONE)
- {
- LogError(DRIVER_DEFAULT, "otIp6AddUnicastAddress failed, %!otError!", otError);
- ShouldDelete = otError == OT_ERROR_NO_BUFS ? TRUE : FALSE;
- }
- }
-
- add_complete:
-
- // Remove it from TCPIP if necessary
- if (ShouldDelete)
- {
- LogInfo(DRIVER_DEFAULT, "Filter %p deleting recently added address: %!IPV6ADDR!", pFilter, pAddr);
-
- // Best effort remove address from TCPIP
- (VOID)DeleteUnicastIpAddressEntry(&Row);
- }
- }
- }
- else if (NotificationType == MibDeleteInstance)
- {
- // Look for the address in our cache
- int index = otLwfFindCachedAddrIndex(pFilter, pAddr);
-
- // If it's not already deleted from our cache, then Windows
- // is deleting the adddress and we need to update OpenThread.
- if (index != -1)
- {
- // Update our cache
- otLwfOnAddressRemoved(pFilter, (ULONG)index, FALSE);
-
- LogInfo(DRIVER_DEFAULT, "Filter %p trying to remove address: %!IPV6ADDR!", pFilter, pAddr);
-
- // Find the correct address from OpenThread to remove (best effort)
- (void)otIp6RemoveUnicastAddress(pFilter->otCtx, (otIp6Address*)pAddr);
- }
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfRadioAddressesUpdated(
- _In_ PMS_FILTER pFilter
- )
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- ULONG FoundInOpenThread = 0; // Bit field
- ULONG OriginalCacheLength = pFilter->otCachedAddrCount;
-
- NT_ASSERT(pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE);
-
- const otNetifAddress* addr = otIp6GetUnicastAddresses(pFilter->otCtx);
-
- // Process the addresses
- while (addr)
- {
- int index = otLwfFindCachedAddrIndex(pFilter, (PIN6_ADDR)&addr->mAddress);
- if (index == -1)
- {
- otLwfOnAddressAdded(pFilter, addr, TRUE);
- }
- else
- {
- NT_ASSERT(index < 8 * sizeof(FoundInOpenThread));
- FoundInOpenThread |= 1 << index;
- }
- addr = addr->mNext;
- }
-
- // Look for missing addresses and mark them as removed
- for (int i = OriginalCacheLength - 1; i >= 0; i--)
- {
- if ((FoundInOpenThread & (1 << i)) == 0)
- {
- otLwfOnAddressRemoved(pFilter, (ULONG)i, TRUE);
- }
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfTunAddressesUpdated(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(value_data_len) const uint8_t* value_data_ptr,
- _In_ spinel_size_t value_data_len,
- _Out_ uint32_t *aNotifFlags
- )
-{
- ULONG FoundInOpenThread = 0; // Bit field
- ULONG OriginalCacheLength = pFilter->otCachedAddrCount;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- NT_ASSERT (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_THREAD_MODE);
-
- *aNotifFlags = 0;
-
- while (value_data_len > 0)
- {
- const uint8_t *entry_ptr = NULL;
- spinel_size_t entry_len = 0;
-
- spinel_ssize_t len = spinel_datatype_unpack(value_data_ptr, value_data_len, "d", &entry_ptr, &entry_len);
- if (len < 1) break;
-
- {
- PIN6_ADDR pAddr = NULL;
- otNetifAddress addr = { { 0 }, 0, 1, 1, 0, 0, 0, NULL };
- uint32_t preferredLifetime = 0xFFFFFFFF;
- uint32_t validLifetime = 0xFFFFFFFF;
-
- spinel_datatype_unpack(
- entry_ptr,
- entry_len,
- "6CLL",
- &pAddr,
- &addr.mPrefixLength,
- &validLifetime,
- &preferredLifetime);
-
- addr.mPreferred = preferredLifetime != 0;
- addr.mValid = validLifetime != 0;
-
- if (pAddr)
- {
- int index = otLwfFindCachedAddrIndex(pFilter, pAddr);
- if (index == -1)
- {
- memcpy_s(&addr.mAddress, sizeof(addr.mAddress), pAddr, sizeof(IN6_ADDR));
- otLwfOnAddressAdded(pFilter, &addr, TRUE);
- *aNotifFlags |= OT_CHANGED_IP6_ADDRESS_ADDED;
- }
- else
- {
- NT_ASSERT(index < 8 * sizeof(FoundInOpenThread));
- FoundInOpenThread |= 1 << index;
- }
- }
- }
-
- value_data_len -= len;
- value_data_ptr += len;
- }
-
- // Look for missing addresses and mark them as removed
- for (int i = OriginalCacheLength - 1; i >= 0; i--)
- {
- if ((FoundInOpenThread & (1 << i)) == 0)
- {
- otLwfOnAddressRemoved(pFilter, (ULONG)i, TRUE);
- *aNotifFlags |= OT_CHANGED_IP6_ADDRESS_REMOVED;
- }
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
diff --git a/examples/drivers/windows/otLwf/alarm.c b/examples/drivers/windows/otLwf/alarm.c
deleted file mode 100644
index dfff301e2..000000000
--- a/examples/drivers/windows/otLwf/alarm.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file implements the alarm functions required for the OpenThread library.
- */
-
-#include "precomp.h"
-#include "alarm.tmh"
-
-uint32_t
-otPlatAlarmMilliGetNow()
-{
- // Return number of 'ticks'
- LARGE_INTEGER PerformanceCounter = KeQueryPerformanceCounter(NULL);
-
- // Multiply by 1000 ms/sec and divide by 'ticks'/sec to get ms
- return (uint32_t)(PerformanceCounter.QuadPart * 1000 / FilterPerformanceFrequency.QuadPart);
-}
-
-void
-otPlatAlarmMilliStop(
- _In_ otInstance *otCtx
- )
-{
- LogVerbose(DRIVER_DEFAULT, "otPlatAlarmMilliStop");
- otLwfEventProcessingIndicateNewWaitTime(otCtxToFilter(otCtx), (ULONG)(-1));
-}
-
-void
-otPlatAlarmMilliStartAt(
- _In_ otInstance *otCtx,
- uint32_t now,
- uint32_t waitTime
- )
-{
- UNREFERENCED_PARAMETER(now);
- LogVerbose(DRIVER_DEFAULT, "otPlatAlarmMilliStartAt %u ms", waitTime);
- otLwfEventProcessingIndicateNewWaitTime(otCtxToFilter(otCtx), waitTime);
-}
diff --git a/examples/drivers/windows/otLwf/command.c b/examples/drivers/windows/otLwf/command.c
deleted file mode 100644
index 3b0226acf..000000000
--- a/examples/drivers/windows/otLwf/command.c
+++ /dev/null
@@ -1,1426 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file implements the functions for sending/receiving Spinel commands to the miniport.
- */
-
-#include "precomp.h"
-#include "command.tmh"
-
-typedef struct _SPINEL_CMD_HANDLER_ENTRY
-{
- LIST_ENTRY Link;
- volatile LONG RefCount;
- SPINEL_CMD_HANDLER *Handler;
- PVOID Context;
- spinel_tid_t TransactionId;
-} SPINEL_CMD_HANDLER_ENTRY;
-
-void AddEntryRef(SPINEL_CMD_HANDLER_ENTRY *pEntry) { InterlockedIncrement(&pEntry->RefCount); }
-void ReleaseEntryRef(SPINEL_CMD_HANDLER_ENTRY *pEntry)
-{
- if (InterlockedDecrement(&pEntry->RefCount) == 0)
- {
- FILTER_FREE_MEM(pEntry);
- }
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NDIS_STATUS
-otLwfCmdInitialize(
- _In_ PMS_FILTER pFilter
- )
-{
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- NTSTATUS NtStatus = STATUS_SUCCESS;
- uint32_t MajorVersion = 0;
- uint32_t MinorVersion = 0;
- uint32_t InterfaceType = 0;
-
- NET_BUFFER_LIST_POOL_PARAMETERS PoolParams =
- {
- { NDIS_OBJECT_TYPE_DEFAULT, NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1, NDIS_SIZEOF_NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1 },
- NDIS_PROTOCOL_ID_DEFAULT,
- TRUE,
- 0,
- 'lbNC', // CNbl
- 0
- };
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- do
- {
- pFilter->cmdTIDsInUse = 0;
- pFilter->cmdNextTID = 1;
- pFilter->cmdResetReason = OT_PLAT_RESET_REASON_POWER_ON;
-
- NdisAllocateSpinLock(&pFilter->cmdLock);
- InitializeListHead(&pFilter->cmdHandlers);
-
- KeInitializeEvent(
- &pFilter->cmdResetCompleteEvent,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
-
- // Enable rundown protection
- ExReInitializeRundownProtection(&pFilter->cmdRundown);
-
- // Create the NDIS pool for creating the SendNetBufferList
- pFilter->cmdNblPool = NdisAllocateNetBufferListPool(pFilter->FilterHandle, &PoolParams);
- if (pFilter->cmdNblPool == NULL)
- {
- Status = NDIS_STATUS_RESOURCES;
- LogWarning(DRIVER_DEFAULT, "Failed to create NetBufferList pool for Spinel commands");
- break;
- }
-
- // Query the interface type to make sure it is a Thread device
-#ifdef COMMAND_INIT_RETRY
- pFilter->cmdInitTryCount = 0;
- while (pFilter->cmdInitTryCount < 10)
- {
- NtStatus = otLwfCmdGetProp(pFilter, NULL, SPINEL_PROP_PROTOCOL_VERSION, "ii", &MajorVersion, &MinorVersion);
- if (!NT_SUCCESS(NtStatus))
- {
- pFilter->cmdInitTryCount++;
- NdisMSleep(100);
- continue;
- }
- break;
- }
- if (pFilter->cmdInitTryCount >= 10)
- {
-#else
- NtStatus = otLwfCmdGetProp(pFilter, NULL, SPINEL_PROP_PROTOCOL_VERSION, "ii", &MajorVersion, &MinorVersion);
- if (!NT_SUCCESS(NtStatus))
- {
-#endif
- Status = NDIS_STATUS_NOT_SUPPORTED;
- LogError(DRIVER_DEFAULT, "Failed to query SPINEL_PROP_PROTOCOL_VERSION, %!STATUS!", NtStatus);
- break;
- }
- if (MajorVersion != SPINEL_PROTOCOL_VERSION_THREAD_MAJOR ||
- MinorVersion < 3) // TODO - Remove this minor version check with the next major version update
- {
- Status = NDIS_STATUS_NOT_SUPPORTED;
- LogError(DRIVER_DEFAULT, "Protocol Version Mismatch! OsVer: %d.%d DeviceVer: %d.%d",
- SPINEL_PROTOCOL_VERSION_THREAD_MAJOR, SPINEL_PROTOCOL_VERSION_THREAD_MINOR,
- MajorVersion, MinorVersion);
- break;
- }
-
- NtStatus = otLwfCmdGetProp(pFilter, NULL, SPINEL_PROP_INTERFACE_TYPE, SPINEL_DATATYPE_UINT_PACKED_S, &InterfaceType);
- if (!NT_SUCCESS(NtStatus))
- {
- Status = NDIS_STATUS_NOT_SUPPORTED;
- LogError(DRIVER_DEFAULT, "Failed to query SPINEL_PROP_INTERFACE_TYPE, %!STATUS!", NtStatus);
- break;
- }
- if (InterfaceType != SPINEL_PROTOCOL_TYPE_THREAD)
- {
- Status = NDIS_STATUS_NOT_SUPPORTED;
- LogError(DRIVER_DEFAULT, "SPINEL_PROP_INTERFACE_TYPE is invalid, %d", InterfaceType);
- break;
- }
-
- NtStatus = otLwfCmdResetDevice(pFilter, FALSE);
- if (!NT_SUCCESS(NtStatus))
- {
- Status = NDIS_STATUS_FAILURE;
- break;
- }
-
- } while (FALSE);
-
- LogFuncExitNDIS(DRIVER_DEFAULT, Status);
-
- // Clean up on failure
- if (Status != NDIS_STATUS_SUCCESS)
- {
- otLwfCmdUninitialize(pFilter);
- }
-
- return Status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void
-otLwfCmdUninitialize(
- _In_ PMS_FILTER pFilter
- )
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- // Release and wait for run down. This will block waiting for any pending sends to complete
- ExWaitForRundownProtectionRelease(&pFilter->cmdRundown);
-
- // Use the NBL Pool variable as a flag for initialization
- if (pFilter->cmdNblPool)
- {
- // Clean up any pending handlers
- PLIST_ENTRY Link = pFilter->cmdHandlers.Flink;
- while (Link != &pFilter->cmdHandlers)
- {
- SPINEL_CMD_HANDLER_ENTRY* pEntry = CONTAINING_RECORD(Link, SPINEL_CMD_HANDLER_ENTRY, Link);
- Link = Link->Flink;
-
- if (pEntry->Handler)
- {
- pEntry->Handler(pFilter, pEntry->Context, 0, 0, NULL, 0);
- }
-
- ReleaseEntryRef(pEntry);
- }
- InitializeListHead(&pFilter->cmdHandlers);
-
- // Free NBL Pool
- NdisFreeNetBufferPool(pFilter->cmdNblPool);
- pFilter->cmdNblPool = NULL;
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-//
-// Receive Spinel Encoded Command
-//
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfCmdProcess(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ UINT command,
- _In_reads_bytes_(cmd_data_len) const uint8_t* cmd_data_ptr,
- _In_ spinel_size_t cmd_data_len
- )
-{
- uint8_t Header;
- spinel_prop_key_t key;
- uint8_t* value_data_ptr = NULL;
- spinel_size_t value_data_len = 0;
-
- // Make sure it's an expected command
- if (command < SPINEL_CMD_PROP_VALUE_IS || command > SPINEL_CMD_PROP_VALUE_REMOVED)
- {
- LogVerbose(DRIVER_DEFAULT, "Recieved unhandled command, %u", command);
- return;
- }
-
- // Decode the key and data
- if (spinel_datatype_unpack(cmd_data_ptr, cmd_data_len, "CiiD", &Header, NULL, &key, &value_data_ptr, &value_data_len) == -1)
- {
- LogVerbose(DRIVER_DEFAULT, "Failed to unpack command key & data");
- return;
- }
-
- // Get the transaction ID
- if (SPINEL_HEADER_GET_TID(Header) == 0)
- {
- // Handle out of band last status locally
- if (command == SPINEL_CMD_PROP_VALUE_IS && key == SPINEL_PROP_LAST_STATUS)
- {
- // Check if this is a reset
- spinel_status_t status = SPINEL_STATUS_OK;
- spinel_datatype_unpack(value_data_ptr, value_data_len, "i", &status);
-
- if ((status >= SPINEL_STATUS_RESET__BEGIN) && (status <= SPINEL_STATUS_RESET__END))
- {
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! was reset (status %d).", &pFilter->InterfaceGuid, status);
- pFilter->cmdResetReason = status - SPINEL_STATUS_RESET__BEGIN;
- KeSetEvent(&pFilter->cmdResetCompleteEvent, IO_NO_INCREMENT, FALSE);
-
- // TODO - Should this be passed on to Thread or Tunnel logic?
- }
- }
- else if (ExAcquireRundownProtection(&pFilter->ExternalRefs))
- {
- // If this is a 'Value Is' command, process it for notification of state changes.
- if (command == SPINEL_CMD_PROP_VALUE_IS)
- {
- if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE)
- {
- otLwfThreadValueIs(pFilter, DispatchLevel, key, value_data_ptr, value_data_len);
- }
- else if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_THREAD_MODE)
- {
- otLwfTunValueIs(pFilter, DispatchLevel, key, value_data_ptr, value_data_len);
- }
- }
- else if (command == SPINEL_CMD_PROP_VALUE_INSERTED)
- {
- if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE)
- {
- otLwfThreadValueInserted(pFilter, DispatchLevel, key, value_data_ptr, value_data_len);
- }
- else if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_THREAD_MODE)
- {
- otLwfTunValueInserted(pFilter, DispatchLevel, key, value_data_ptr, value_data_len);
- }
- }
-
- ExReleaseRundownProtection(&pFilter->ExternalRefs);
- }
- }
- // If there was a transaction ID, then look for the corresponding command handler
- else
- {
- PLIST_ENTRY Link;
- SPINEL_CMD_HANDLER_ENTRY* Handler = NULL;
-
- FILTER_ACQUIRE_LOCK(&pFilter->cmdLock, DispatchLevel);
-
- // Search for matching handlers for this command
- Link = pFilter->cmdHandlers.Flink;
- while (Link != &pFilter->cmdHandlers)
- {
- SPINEL_CMD_HANDLER_ENTRY* pEntry = CONTAINING_RECORD(Link, SPINEL_CMD_HANDLER_ENTRY, Link);
- Link = Link->Flink;
-
- if (SPINEL_HEADER_GET_TID(Header) == pEntry->TransactionId)
- {
- // Remove from the main list
- RemoveEntryList(&pEntry->Link);
-
- // Cache the handler
- Handler = pEntry;
-
- // Remove the transaction ID from the 'in use' bit field
- pFilter->cmdTIDsInUse &= ~(1 << pEntry->TransactionId);
-
- break;
- }
- }
-
- FILTER_RELEASE_LOCK(&pFilter->cmdLock, DispatchLevel);
-
- // TODO - Set event
-
- // Process the handler we found, outside the lock
- if (Handler)
- {
- // Call the handler function
- Handler->Handler(pFilter, Handler->Context, command, key, value_data_ptr, value_data_len);
-
- // Free the entry
- ReleaseEntryRef(Handler);
- }
- }
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfCmdRecveive(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_reads_bytes_(BufferLength) const PUCHAR Buffer,
- _In_ ULONG BufferLength
- )
-{
- uint8_t Header;
- UINT Command;
-
- // Unpack the header from the buffer
- if (spinel_datatype_unpack(Buffer, BufferLength, "Ci", &Header, &Command) <= 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Failed to unpack header and command");
- return;
- }
-
- // Validate the header
- if ((Header & SPINEL_HEADER_FLAG) != SPINEL_HEADER_FLAG)
- {
- LogVerbose(DRIVER_DEFAULT, "Recieved unrecognized frame, header=0x%x", Header);
- return;
- }
-
- // We only support IID zero for now
- if (SPINEL_HEADER_GET_IID(Header) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Recieved unsupported IID, %u", SPINEL_HEADER_GET_IID(Header));
- return;
- }
-
- // Process the received command
- otLwfCmdProcess(pFilter, DispatchLevel, Command, Buffer, BufferLength);
-}
-
-//
-// Send Async Spinel Encoded Command
-//
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-spinel_tid_t
-otLwfCmdGetNextTID(
- _In_ PMS_FILTER pFilter
- )
-{
- spinel_tid_t TID = 0;
- while (TID == 0)
- {
- NdisAcquireSpinLock(&pFilter->cmdLock);
-
- if (((1 << pFilter->cmdNextTID) & pFilter->cmdTIDsInUse) == 0)
- {
- TID = pFilter->cmdNextTID;
- pFilter->cmdNextTID = SPINEL_GET_NEXT_TID(pFilter->cmdNextTID);
- pFilter->cmdTIDsInUse |= (1 << TID);
- }
-
- NdisReleaseSpinLock(&pFilter->cmdLock);
-
- if (TID == 0)
- {
- // TODO - Wait for event
- }
- }
- return TID;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void
-otLwfCmdAddHandler(
- _In_ PMS_FILTER pFilter,
- _In_ SPINEL_CMD_HANDLER_ENTRY *pEntry
- )
-{
- // Get the next transaction ID. This call will block if there are
- // none currently available.
- pEntry->TransactionId = otLwfCmdGetNextTID(pFilter);
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "tid=%u", (ULONG)pEntry->TransactionId);
-
- NdisAcquireSpinLock(&pFilter->cmdLock);
-
- // Add to the handlers list
- AddEntryRef(pEntry);
- InsertTailList(&pFilter->cmdHandlers, &pEntry->Link);
-
- NdisReleaseSpinLock(&pFilter->cmdLock);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdEncodeAndSendAsync(
- _In_ PMS_FILTER pFilter,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_ spinel_tid_t tid,
- _In_ ULONG MaxDataLength,
- _In_opt_ const char *pack_format,
- _In_opt_ va_list args
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- PNET_BUFFER_LIST NetBufferList = NULL;
- PNET_BUFFER NetBuffer = NULL;
- ULONG NetBufferLength = 0;
- PUCHAR DataBuffer = NULL;
- spinel_ssize_t PackedLength;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Cmd=%u Key=%u tid=%u", (ULONG)Command, (ULONG)Key, (ULONG)tid);
-
- NetBufferList =
- NdisAllocateNetBufferAndNetBufferList(
- pFilter->cmdNblPool, // PoolHandle
- 0, // ContextSize
- 0, // ContextBackFill
- NULL, // MdlChain
- 0, // DataOffset
- 0 // DataLength
- );
- if (NetBufferList == NULL)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- LogWarning(DRIVER_DEFAULT, "Failed to create command NetBufferList");
- goto exit;
- }
-
- // Initialize NetBuffer fields
- NetBuffer = NET_BUFFER_LIST_FIRST_NB(NetBufferList);
- NET_BUFFER_CURRENT_MDL(NetBuffer) = NULL;
- NET_BUFFER_CURRENT_MDL_OFFSET(NetBuffer) = 0;
- NET_BUFFER_DATA_LENGTH(NetBuffer) = 0;
- NET_BUFFER_DATA_OFFSET(NetBuffer) = 0;
- NET_BUFFER_FIRST_MDL(NetBuffer) = NULL;
-
- // Calculate length of NetBuffer
- NetBufferLength = 16 + MaxDataLength;
- if (NetBufferLength < 64) NetBufferLength = 64;
-
- // Allocate the NetBuffer for NetBufferList
- if (NdisRetreatNetBufferDataStart(NetBuffer, NetBufferLength, 0, NULL) != NDIS_STATUS_SUCCESS)
- {
- NetBuffer = NULL;
- status = STATUS_INSUFFICIENT_RESOURCES;
- LogError(DRIVER_DEFAULT, "Failed to allocate NB for command NetBufferList, %u bytes", NetBufferLength);
- goto exit;
- }
-
- // Get the pointer to the data buffer
- DataBuffer = (PUCHAR)NdisGetDataBuffer(NetBuffer, NetBufferLength, NULL, 1, 0);
- NT_ASSERT(DataBuffer);
-
- // Save the true NetBuffer length in the protocol reserved
- NetBuffer->ProtocolReserved[0] = (PVOID)NetBufferLength;
- NetBuffer->DataLength = 0;
-
- // Save the transaction ID in the protocol reserved
- NetBuffer->ProtocolReserved[1] = (PVOID)tid;
-
- // Pack the header, command and key
- PackedLength =
- spinel_datatype_pack(
- DataBuffer,
- NetBufferLength,
- "Cii",
- SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0 | tid,
- Command,
- Key);
- if (PackedLength < 0 || PackedLength + NetBuffer->DataLength > NetBufferLength)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto exit;
- }
-
- NetBuffer->DataLength += (ULONG)PackedLength;
-
- // Pack the data (if any)
- if (pack_format)
- {
- PackedLength =
- spinel_datatype_vpack(
- DataBuffer + NetBuffer->DataLength,
- NetBufferLength - NetBuffer->DataLength,
- pack_format,
- args);
- if (PackedLength < 0 || PackedLength + NetBuffer->DataLength > NetBufferLength)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto exit;
- }
-
- NetBuffer->DataLength += (ULONG)PackedLength;
- }
-
- // Grab a ref for rundown protection
- if (!ExAcquireRundownProtection(&pFilter->cmdRundown))
- {
- status = STATUS_DEVICE_NOT_READY;
- LogWarning(DRIVER_DEFAULT, "Failed to acquire rundown protection");
- goto exit;
- }
-
- // Send the NBL down
- NdisFSendNetBufferLists(
- pFilter->FilterHandle,
- NetBufferList,
- NDIS_DEFAULT_PORT_NUMBER,
- 0);
-
- // Clear local variable because we don't own the NBL any more
- NetBufferList = NULL;
-
-exit:
-
- if (NetBufferList)
- {
- if (NetBuffer)
- {
- NetBuffer->DataLength = (ULONG)(ULONG_PTR)NetBuffer->ProtocolReserved[0];
- NdisAdvanceNetBufferDataStart(NetBuffer, NetBuffer->DataLength, TRUE, NULL);
- }
- NdisFreeNetBufferList(NetBufferList);
- }
-
- LogFuncExitNT(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdResetDevice(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN fAsync
- )
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- KeResetEvent(&pFilter->cmdResetCompleteEvent);
-
- NTSTATUS status = otLwfCmdEncodeAndSendAsync(pFilter, SPINEL_CMD_RESET, 0, 0, 0, NULL, NULL);
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Failed to send SPINEL_CMD_RESET, %!STATUS!", status);
- }
- else if (!fAsync)
- {
- // Create the relative (negative) time to wait for 5 seconds
- LARGE_INTEGER Timeout;
- Timeout.QuadPart = -5000 * 10000;
-
- status = KeWaitForSingleObject(&pFilter->cmdResetCompleteEvent, Executive, KernelMode, FALSE, &Timeout);
- if (status != STATUS_SUCCESS)
- {
- LogError(DRIVER_DEFAULT, "Failed waiting for reset complete, %!STATUS!", status);
- status = STATUS_DEVICE_BUSY;
- }
- }
-
- LogFuncExitNT(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdSendAsyncV(
- _In_ PMS_FILTER pFilter,
- _In_opt_ SPINEL_CMD_HANDLER *Handler,
- _In_opt_ PVOID HandlerContext,
- _Out_opt_ spinel_tid_t *pTid,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_ ULONG MaxDataLength,
- _In_opt_ const char *pack_format,
- _In_opt_ va_list args
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- SPINEL_CMD_HANDLER_ENTRY *pEntry = NULL;
-
- if (pTid) *pTid = 0;
-
- // Create the handler entry and add it to the list
- if (Handler)
- {
- pEntry = FILTER_ALLOC_MEM(pFilter->FilterHandle, sizeof(SPINEL_CMD_HANDLER_ENTRY));
- if (pEntry == NULL)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- LogWarning(DRIVER_DEFAULT, "Failed to allocate handler entry");
- goto exit;
- }
-
- pEntry->RefCount = 1;
- pEntry->Handler = Handler;
- pEntry->Context = HandlerContext;
-
- otLwfCmdAddHandler(pFilter, pEntry);
-
- if (pTid) *pTid = pEntry->TransactionId;
- }
-
- status = otLwfCmdEncodeAndSendAsync(pFilter, Command, Key, pEntry ? pEntry->TransactionId : 0, MaxDataLength, pack_format, args);
-
- // Remove the handler entry from the list
- if (!NT_SUCCESS(status) && pEntry)
- {
- NdisAcquireSpinLock(&pFilter->cmdLock);
-
- // Remove from the main list
- RemoveEntryList(&pEntry->Link);
-
- // Remove the transaction ID from the 'in use' bit field
- pFilter->cmdTIDsInUse &= ~(1 << pEntry->TransactionId);
-
- NdisReleaseSpinLock(&pFilter->cmdLock);
-
- // TODO - Set event
-
- ReleaseEntryRef(pEntry);
- }
-
-exit:
-
- if (pEntry) ReleaseEntryRef(pEntry);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdSendAsync(
- _In_ PMS_FILTER pFilter,
- _In_opt_ SPINEL_CMD_HANDLER *Handler,
- _In_opt_ PVOID HandlerContext,
- _Out_opt_ spinel_tid_t *pTid,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_ ULONG MaxDataLength,
- _In_opt_ const char *pack_format,
- ...
- )
-{
- va_list args;
- va_start(args, pack_format);
- NTSTATUS status =
- otLwfCmdSendAsyncV(pFilter, Handler, HandlerContext, pTid, Command, Key, MaxDataLength, pack_format, args);
- va_end(args);
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-BOOLEAN
-otLwfCmdCancel(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ spinel_tid_t tid
- )
-{
- PLIST_ENTRY Link;
- SPINEL_CMD_HANDLER_ENTRY* Handler = NULL;
- BOOLEAN Found = FALSE;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "tid=%u", (ULONG)tid);
-
- FILTER_ACQUIRE_LOCK(&pFilter->cmdLock, DispatchLevel);
-
- // Search for matching handlers for this transaction ID
- Link = pFilter->cmdHandlers.Flink;
- while (Link != &pFilter->cmdHandlers)
- {
- SPINEL_CMD_HANDLER_ENTRY* pEntry = CONTAINING_RECORD(Link, SPINEL_CMD_HANDLER_ENTRY, Link);
- Link = Link->Flink;
-
- if (tid == pEntry->TransactionId)
- {
- // Remove from the main list
- RemoveEntryList(&pEntry->Link);
-
- // Save handler to cancel outside lock
- Handler = pEntry;
- Found = TRUE;
-
- // Remove the transaction ID from the 'in use' bit field
- pFilter->cmdTIDsInUse &= ~(1 << pEntry->TransactionId);
-
- break;
- }
- }
-
- FILTER_RELEASE_LOCK(&pFilter->cmdLock, DispatchLevel);
-
- if (Handler)
- {
- // Call the handler function
- Handler->Handler(pFilter, Handler->Context, 0, 0, NULL, 0);
-
- // Free the entry
- ReleaseEntryRef(Handler);
- }
-
- LogFuncExitMsg(DRIVER_DEFAULT, "Found=%u", Found);
-
- return Found;
-}
-
-//
-// Send Packet/Frame
-//
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfCmdSendIp6PacketAsync(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ PNET_BUFFER IpNetBuffer,
- _In_ BOOLEAN Secured
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- PNET_BUFFER_LIST NetBufferList = NULL;
- PNET_BUFFER NetBuffer = NULL;
- ULONG NetBufferLength = 0;
- PUCHAR DataBuffer = NULL;
- PUCHAR IpDataBuffer = NULL;
- spinel_ssize_t PackedLength;
- IPV6_HEADER* v6Header;
-
- NetBufferList =
- NdisAllocateNetBufferAndNetBufferList(
- pFilter->cmdNblPool, // PoolHandle
- 0, // ContextSize
- 0, // ContextBackFill
- NULL, // MdlChain
- 0, // DataOffset
- 0 // DataLength
- );
- if (NetBufferList == NULL)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- LogWarning(DRIVER_DEFAULT, "Failed to create command NetBufferList");
- goto exit;
- }
-
- // Initialize NetBuffer fields
- NetBuffer = NET_BUFFER_LIST_FIRST_NB(NetBufferList);
- NET_BUFFER_CURRENT_MDL(NetBuffer) = NULL;
- NET_BUFFER_CURRENT_MDL_OFFSET(NetBuffer) = 0;
- NET_BUFFER_DATA_LENGTH(NetBuffer) = 0;
- NET_BUFFER_DATA_OFFSET(NetBuffer) = 0;
- NET_BUFFER_FIRST_MDL(NetBuffer) = NULL;
-
- // Calculate length of NetBuffer
- NetBufferLength = 20 + IpNetBuffer->DataLength;
- if (NetBufferLength < 64) NetBufferLength = 64;
-
- // Allocate the NetBuffer for NetBufferList
- if (NdisRetreatNetBufferDataStart(NetBuffer, NetBufferLength, 0, NULL) != NDIS_STATUS_SUCCESS)
- {
- NetBuffer = NULL;
- status = STATUS_INSUFFICIENT_RESOURCES;
- LogError(DRIVER_DEFAULT, "Failed to allocate NB for command NetBufferList, %u bytes", NetBufferLength);
- goto exit;
- }
-
- // Get the pointer to the data buffer for the header data
- DataBuffer = (PUCHAR)NdisGetDataBuffer(NetBuffer, NetBufferLength, NULL, 1, 0);
- NT_ASSERT(DataBuffer);
-
- // Save the true NetBuffer length in the protocol reserved
- NetBuffer->ProtocolReserved[0] = (PVOID)NetBufferLength;
- NetBuffer->DataLength = 0;
-
- // Pack the header, command and key
- PackedLength =
- spinel_datatype_pack(
- DataBuffer,
- NetBufferLength,
- "Cii",
- (spinel_tid_t)(SPINEL_HEADER_FLAG | SPINEL_HEADER_IID_0),
- (UINT)SPINEL_CMD_PROP_VALUE_SET,
- (Secured ? SPINEL_PROP_STREAM_NET : SPINEL_PROP_STREAM_NET_INSECURE));
- if (PackedLength < 0 || PackedLength + NetBuffer->DataLength > NetBufferLength)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto exit;
- }
-
- NT_ASSERT(PackedLength >= 3);
- NetBuffer->DataLength += (ULONG)PackedLength;
-
- // Copy over the data length
- DataBuffer[NetBuffer->DataLength+1] = (((USHORT)IpNetBuffer->DataLength) >> 8) & 0xff;
- DataBuffer[NetBuffer->DataLength] = (((USHORT)IpNetBuffer->DataLength) >> 0) & 0xff;
- NetBuffer->DataLength += 2;
-
- v6Header = (IPV6_HEADER*)(DataBuffer + NetBuffer->DataLength);
-
- // Copy the IP packet data
- IpDataBuffer = (PUCHAR)NdisGetDataBuffer(IpNetBuffer, IpNetBuffer->DataLength, v6Header, 1, 0);
- if (IpDataBuffer != (PUCHAR)v6Header)
- {
- RtlCopyMemory(v6Header, IpDataBuffer, IpNetBuffer->DataLength);
- }
-
- NetBuffer->DataLength += IpNetBuffer->DataLength;
-
- // Grab a ref for rundown protection
- if (!ExAcquireRundownProtection(&pFilter->cmdRundown))
- {
- status = STATUS_DEVICE_NOT_READY;
- LogWarning(DRIVER_DEFAULT, "Failed to acquire rundown protection");
- goto exit;
- }
-
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, IP6_SEND: %p : %!IPV6ADDR! => %!IPV6ADDR! (%u bytes)",
- pFilter, NetBufferList, &v6Header->SourceAddress, &v6Header->DestinationAddress,
- NET_BUFFER_DATA_LENGTH(IpNetBuffer));
-
- // Send the NBL down
- NdisFSendNetBufferLists(
- pFilter->FilterHandle,
- NetBufferList,
- NDIS_DEFAULT_PORT_NUMBER,
- DispatchLevel ? NDIS_SEND_FLAGS_DISPATCH_LEVEL : 0);
-
- // Clear local variable because we don't own the NBL any more
- NetBufferList = NULL;
-
-exit:
-
- if (NetBufferList)
- {
- if (NetBuffer)
- {
- NetBuffer->DataLength = (ULONG)(ULONG_PTR)NetBuffer->ProtocolReserved[0];
- NdisAdvanceNetBufferDataStart(NetBuffer, NetBuffer->DataLength, TRUE, NULL);
- }
- NdisFreeNetBufferList(NetBufferList);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfCmdSendMacFrameComplete(
- _In_ PMS_FILTER pFilter,
- _In_ PVOID Context,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength
- )
-{
- UNREFERENCED_PARAMETER(Context);
-
- pFilter->otLastTransmitError = OT_ERROR_ABORT;
-
- if (Data && Command == SPINEL_CMD_PROP_VALUE_IS)
- {
- if (Key == SPINEL_PROP_LAST_STATUS)
- {
- spinel_status_t spinel_status = SPINEL_STATUS_OK;
- spinel_ssize_t packed_len = spinel_datatype_unpack(Data, DataLength, "i", &spinel_status);
- if (packed_len > 0)
- {
- if (spinel_status == SPINEL_STATUS_OK)
- {
- pFilter->otLastTransmitError = OT_ERROR_NONE;
- (void)spinel_datatype_unpack(
- Data + packed_len,
- DataLength - (spinel_size_t)packed_len,
- "b",
- &pFilter->otLastTransmitFramePending);
- }
- else
- {
- pFilter->otLastTransmitError = SpinelStatusToThreadError(spinel_status);
- }
- }
- }
- }
-
- // Set the completion event
- KeSetEvent(&pFilter->SendNetBufferListComplete, IO_NO_INCREMENT, FALSE);
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfCmdSendMacFrameAsync(
- _In_ PMS_FILTER pFilter,
- _In_ otRadioFrame* Packet
- )
-{
- // Reset the completion event
- KeResetEvent(&pFilter->SendNetBufferListComplete);
- pFilter->SendPending = TRUE;
-
- NTSTATUS status =
- otLwfCmdSendAsync(
- pFilter,
- otLwfCmdSendMacFrameComplete,
- NULL,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_STREAM_RAW,
- Packet->mLength + 20,
- SPINEL_DATATYPE_DATA_WLEN_S
- SPINEL_DATATYPE_UINT8_S
- SPINEL_DATATYPE_INT8_S,
- Packet->mPsdu,
- (uint32_t)Packet->mLength,
- Packet->mChannel,
- Packet->mInfo.mRxInfo.mRssi
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_STREAM_RAW failed, %!STATUS!", status);
- pFilter->otLastTransmitError = OT_ERROR_ABORT;
- KeSetEvent(&pFilter->SendNetBufferListComplete, IO_NO_INCREMENT, FALSE);
- }
-}
-
-//
-// Send Synchronous Spinel Encoded Command
-//
-
-typedef struct _SPINEL_GET_PROP_CONTEXT
-{
- KEVENT CompletionEvent;
- spinel_prop_key_t Key;
- PVOID *DataBuffer;
- const char* Format;
- va_list Args;
- NTSTATUS Status;
-} SPINEL_GET_PROP_CONTEXT;
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfGetPropHandler(
- _In_ PMS_FILTER pFilter,
- _In_ PVOID Context,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength
- )
-{
- SPINEL_GET_PROP_CONTEXT* CmdContext = (SPINEL_GET_PROP_CONTEXT*)Context;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Key=%u", (ULONG)Key);
-
- UNREFERENCED_PARAMETER(pFilter);
-
- if (Data == NULL)
- {
- CmdContext->Status = STATUS_CANCELLED;
- }
- else if (Command != SPINEL_CMD_PROP_VALUE_IS)
- {
- CmdContext->Status = STATUS_INVALID_PARAMETER;
- }
- else if (Key == SPINEL_PROP_LAST_STATUS)
- {
- spinel_status_t spinel_status = SPINEL_STATUS_OK;
- spinel_ssize_t packed_len = spinel_datatype_unpack(Data, DataLength, "i", &spinel_status);
- if (packed_len < 0 || (ULONG)packed_len > DataLength)
- {
- CmdContext->Status = STATUS_INSUFFICIENT_RESOURCES;
- }
- else
- {
- otError errorCode = SpinelStatusToThreadError(spinel_status);
- LogVerbose(DRIVER_DEFAULT, "Get key=%u failed with %!otError!", CmdContext->Key, errorCode);
- CmdContext->Status = ThreadErrorToNtstatus(errorCode);
- }
- }
- else if (Key == CmdContext->Key)
- {
- if (CmdContext->DataBuffer)
- {
- *CmdContext->DataBuffer = FILTER_ALLOC_MEM(pFilter->FilterHandle, DataLength);
- if (*CmdContext->DataBuffer == NULL)
- {
- CmdContext->Status = STATUS_INSUFFICIENT_RESOURCES;
- DataLength = 0;
- }
- else
- {
- memcpy(*CmdContext->DataBuffer, Data, DataLength);
- Data = (uint8_t*)*CmdContext->DataBuffer;
- }
- }
-
- spinel_ssize_t packed_len = spinel_datatype_vunpack(Data, DataLength, CmdContext->Format, CmdContext->Args);
- if (packed_len < 0 || (ULONG)packed_len > DataLength)
- {
- CmdContext->Status = STATUS_INSUFFICIENT_RESOURCES;
- }
- else
- {
- CmdContext->Status = STATUS_SUCCESS;
- }
- }
- else
- {
- CmdContext->Status = STATUS_INVALID_PARAMETER;
- }
-
- // Set the completion event
- KeSetEvent(&CmdContext->CompletionEvent, 0, FALSE);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdGetProp(
- _In_ PMS_FILTER pFilter,
- _Out_opt_ PVOID *DataBuffer,
- _In_ spinel_prop_key_t Key,
- _In_ const char *pack_format,
- ...
- )
-{
- NTSTATUS status;
- LARGE_INTEGER WaitTimeout;
- spinel_tid_t tid;
-
- // Create the context structure
- SPINEL_GET_PROP_CONTEXT Context;
- KeInitializeEvent(&Context.CompletionEvent, SynchronizationEvent, FALSE);
- Context.Key = Key;
- Context.DataBuffer = DataBuffer;
- Context.Format = pack_format;
- Context.Status = STATUS_SUCCESS;
- va_start(Context.Args, pack_format);
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Key=%u", (ULONG)Key);
-
- // Send the request transaction
- status =
- otLwfCmdSendAsyncV(
- pFilter,
- otLwfGetPropHandler,
- &Context,
- &tid,
- SPINEL_CMD_PROP_VALUE_GET,
- Key,
- 0,
- NULL,
- NULL);
- if (NT_SUCCESS(status))
- {
- // Set a 1 second wait timeout
- WaitTimeout.QuadPart = -1000 * 10000;
-
- // Wait for the response
- if (KeWaitForSingleObject(
- &Context.CompletionEvent,
- Executive,
- KernelMode,
- FALSE,
- &WaitTimeout) != STATUS_SUCCESS)
- {
- if (!otLwfCmdCancel(pFilter, FALSE, tid))
- {
- KeWaitForSingleObject(
- &Context.CompletionEvent,
- Executive,
- KernelMode,
- FALSE,
- NULL);
- }
- }
- }
- else
- {
- Context.Status = status;
- }
-
- va_end(Context.Args);
-
- LogFuncExitNT(DRIVER_DEFAULT, Context.Status);
-
- return Context.Status;
-}
-
-typedef struct _SPINEL_SET_PROP_CONTEXT
-{
- KEVENT CompletionEvent;
- UINT ExpectedResultCommand;
- spinel_prop_key_t Key;
- NTSTATUS Status;
-} SPINEL_SET_PROP_CONTEXT;
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfSetPropHandler(
- _In_ PMS_FILTER pFilter,
- _In_ PVOID Context,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength
- )
-{
- SPINEL_SET_PROP_CONTEXT* CmdContext = (SPINEL_SET_PROP_CONTEXT*)Context;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Key=%u", (ULONG)Key);
-
- UNREFERENCED_PARAMETER(pFilter);
-
- if (Data == NULL)
- {
- CmdContext->Status = STATUS_CANCELLED;
- }
- else if (Command == SPINEL_CMD_PROP_VALUE_IS && Key == SPINEL_PROP_LAST_STATUS)
- {
- spinel_status_t spinel_status = SPINEL_STATUS_OK;
- spinel_ssize_t packed_len = spinel_datatype_unpack(Data, DataLength, "i", &spinel_status);
- if (packed_len < 0 || (ULONG)packed_len > DataLength)
- {
- CmdContext->Status = STATUS_INSUFFICIENT_RESOURCES;
- }
- else
- {
- otError errorCode = SpinelStatusToThreadError(spinel_status);
- LogVerbose(DRIVER_DEFAULT, "Set key=%u failed with %!otError!", CmdContext->Key, errorCode);
- CmdContext->Status = ThreadErrorToNtstatus(errorCode);
- }
- }
- else if (Command != CmdContext->ExpectedResultCommand)
- {
- NT_ASSERT(FALSE);
- CmdContext->Status = STATUS_INVALID_PARAMETER;
- }
- else if (Key == CmdContext->Key)
- {
- CmdContext->Status = STATUS_SUCCESS;
- }
- else
- {
- NT_ASSERT(FALSE);
- CmdContext->Status = STATUS_INVALID_PARAMETER;
- }
-
- // Set the completion event
- KeSetEvent(&CmdContext->CompletionEvent, 0, FALSE);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdSetPropV(
- _In_ PMS_FILTER pFilter,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_opt_ const char *pack_format,
- _In_opt_ va_list args
- )
-{
- NTSTATUS status;
- LARGE_INTEGER WaitTimeout;
- spinel_tid_t tid;
-
- // Create the context structure
- SPINEL_SET_PROP_CONTEXT Context;
- KeInitializeEvent(&Context.CompletionEvent, SynchronizationEvent, FALSE);
- Context.Key = Key;
- Context.Status = STATUS_SUCCESS;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Cmd=%u Key=%u", Command, (ULONG)Key);
-
- if (Command == SPINEL_CMD_PROP_VALUE_SET)
- {
- Context.ExpectedResultCommand = SPINEL_CMD_PROP_VALUE_IS;
- }
- else if (Command == SPINEL_CMD_PROP_VALUE_INSERT)
- {
- Context.ExpectedResultCommand = SPINEL_CMD_PROP_VALUE_INSERTED;
- }
- else if (Command == SPINEL_CMD_PROP_VALUE_REMOVE)
- {
- Context.ExpectedResultCommand = SPINEL_CMD_PROP_VALUE_REMOVED;
- }
- else
- {
- ASSERT(FALSE);
- }
-
- // Send the request transaction
- status =
- otLwfCmdSendAsyncV(
- pFilter,
- otLwfSetPropHandler,
- &Context,
- &tid,
- Command,
- Key,
- 8,
- pack_format,
- args);
- if (NT_SUCCESS(status))
- {
- // Set a 1 second wait timeout
- WaitTimeout.QuadPart = -1000 * 10000;
-
- // Wait for the response
- if (KeWaitForSingleObject(
- &Context.CompletionEvent,
- Executive,
- KernelMode,
- FALSE,
- &WaitTimeout) != STATUS_SUCCESS)
- {
- if (!otLwfCmdCancel(pFilter, FALSE, tid))
- {
- KeWaitForSingleObject(
- &Context.CompletionEvent,
- Executive,
- KernelMode,
- FALSE,
- NULL);
- }
- }
- }
- else
- {
- Context.Status = status;
- }
-
- LogFuncExitNT(DRIVER_DEFAULT, Context.Status);
-
- return Context.Status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdSetProp(
- _In_ PMS_FILTER pFilter,
- _In_ spinel_prop_key_t Key,
- _In_opt_ const char *pack_format,
- ...
- )
-{
- va_list args;
- va_start(args, pack_format);
- NTSTATUS status = otLwfCmdSetPropV(pFilter, SPINEL_CMD_PROP_VALUE_SET, Key, pack_format, args);
- va_end(args);
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdInsertProp(
- _In_ PMS_FILTER pFilter,
- _In_ spinel_prop_key_t Key,
- _In_opt_ const char *pack_format,
- ...
- )
-{
- va_list args;
- va_start(args, pack_format);
- NTSTATUS status = otLwfCmdSetPropV(pFilter, SPINEL_CMD_PROP_VALUE_INSERT, Key, pack_format, args);
- va_end(args);
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdRemoveProp(
- _In_ PMS_FILTER pFilter,
- _In_ spinel_prop_key_t Key,
- _In_opt_ const char *pack_format,
- ...
- )
-{
- va_list args;
- va_start(args, pack_format);
- NTSTATUS status = otLwfCmdSetPropV(pFilter, SPINEL_CMD_PROP_VALUE_REMOVE, Key, pack_format, args);
- va_end(args);
- return status;
-}
-
-//
-// General Spinel Helpers
-//
-
-otError
-SpinelStatusToThreadError(
- spinel_status_t error
- )
-{
- otError ret;
-
- switch (error)
- {
- case SPINEL_STATUS_OK:
- ret = OT_ERROR_NONE;
- break;
-
- case SPINEL_STATUS_FAILURE:
- ret = OT_ERROR_FAILED;
- break;
-
- case SPINEL_STATUS_DROPPED:
- ret = OT_ERROR_DROP;
- break;
-
- case SPINEL_STATUS_NOMEM:
- ret = OT_ERROR_NO_BUFS;
- break;
-
- case SPINEL_STATUS_BUSY:
- ret = OT_ERROR_BUSY;
- break;
-
- case SPINEL_STATUS_PARSE_ERROR:
- ret = OT_ERROR_PARSE;
- break;
-
- case SPINEL_STATUS_INVALID_ARGUMENT:
- ret = OT_ERROR_INVALID_ARGS;
- break;
-
- case SPINEL_STATUS_UNIMPLEMENTED:
- ret = OT_ERROR_NOT_IMPLEMENTED;
- break;
-
- case SPINEL_STATUS_INVALID_STATE:
- ret = OT_ERROR_INVALID_STATE;
- break;
-
- case SPINEL_STATUS_NO_ACK:
- ret = OT_ERROR_NO_ACK;
- break;
-
- case SPINEL_STATUS_CCA_FAILURE:
- ret = OT_ERROR_CHANNEL_ACCESS_FAILURE;
- break;
-
- case SPINEL_STATUS_ALREADY:
- ret = OT_ERROR_ALREADY;
- break;
-
- case SPINEL_STATUS_ITEM_NOT_FOUND:
- ret = OT_ERROR_NOT_FOUND;
- break;
-
- default:
- if (error >= SPINEL_STATUS_STACK_NATIVE__BEGIN && error <= SPINEL_STATUS_STACK_NATIVE__END)
- {
- ret = (otError)(error - SPINEL_STATUS_STACK_NATIVE__BEGIN);
- }
- else
- {
- ret = OT_ERROR_FAILED;
- }
- break;
- }
-
- return ret;
-}
-
-BOOLEAN
-try_spinel_datatype_unpack(
- const uint8_t *data_in,
- spinel_size_t data_len,
- const char *pack_format,
- ...
- )
-{
- va_list args;
- va_start(args, pack_format);
- spinel_ssize_t packed_len = spinel_datatype_vunpack(data_in, data_len, pack_format, args);
- va_end(args);
-
- return !(packed_len < 0 || (spinel_size_t)packed_len > data_len);
-}
diff --git a/examples/drivers/windows/otLwf/command.h b/examples/drivers/windows/otLwf/command.h
deleted file mode 100644
index 2a73d8d11..000000000
--- a/examples/drivers/windows/otLwf/command.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines the functions for sending/receiving Spinel commands to the miniport.
- */
-
-#ifndef _COMMAND_H_
-#define _COMMAND_H_
-
-//
-// Initialization
-//
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NDIS_STATUS
-otLwfCmdInitialize(
- _In_ PMS_FILTER pFilter
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void
-otLwfCmdUninitialize(
- _In_ PMS_FILTER pFilter
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdResetDevice(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN fAsync
- );
-
-//
-// Receive Spinel Encoded Command
-//
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfCmdRecveive(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_reads_bytes_(BufferLength) const PUCHAR Buffer,
- _In_ ULONG BufferLength
- );
-
-//
-// Send Async Spinel Encoded Command
-//
-
-typedef
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-(SPINEL_CMD_HANDLER)(
- _In_ PMS_FILTER pFilter,
- _In_ PVOID Context,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdSendAsyncV(
- _In_ PMS_FILTER pFilter,
- _In_opt_ SPINEL_CMD_HANDLER *Handler,
- _In_opt_ PVOID HandlerContext,
- _Out_opt_ spinel_tid_t *pTid,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_ ULONG MaxDataLength,
- _In_opt_ const char *pack_format,
- _In_opt_ va_list args
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdSendAsync(
- _In_ PMS_FILTER pFilter,
- _In_opt_ SPINEL_CMD_HANDLER *Handler,
- _In_opt_ PVOID HandlerContext,
- _Out_opt_ spinel_tid_t *pTid,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_ ULONG MaxDataLength,
- _In_opt_ const char *pack_format,
- ...
- );
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-BOOLEAN
-otLwfCmdCancel(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ spinel_tid_t tid
- );
-
-//
-// Send Packet/Frame
-//
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfCmdSendIp6PacketAsync(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ PNET_BUFFER IpNetBuffer,
- _In_ BOOLEAN Secured
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfCmdSendMacFrameAsync(
- _In_ PMS_FILTER pFilter,
- _In_ otRadioFrame* Packet
- );
-
-//
-// Send Synchronous Spinel Encoded Command
-//
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdGetProp(
- _In_ PMS_FILTER pFilter,
- _Out_opt_ PVOID *DataBuffer,
- _In_ spinel_prop_key_t Key,
- _In_ const char *pack_format,
- ...
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdSetProp(
- _In_ PMS_FILTER pFilter,
- _In_ spinel_prop_key_t Key,
- _In_opt_ const char *pack_format,
- ...
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdInsertProp(
- _In_ PMS_FILTER pFilter,
- _In_ spinel_prop_key_t Key,
- _In_opt_ const char *pack_format,
- ...
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfCmdRemoveProp(
- _In_ PMS_FILTER pFilter,
- _In_ spinel_prop_key_t Key,
- _In_opt_ const char *pack_format,
- ...
- );
-
-//
-// General Spinel Helpers
-//
-
-otError
-SpinelStatusToThreadError(
- spinel_status_t error
- );
-
-BOOLEAN
-try_spinel_datatype_unpack(
- const uint8_t *data_in,
- spinel_size_t data_len,
- const char *pack_format,
- ...
- );
-
-#endif //_COMMAND_H_
diff --git a/examples/drivers/windows/otLwf/datapath.c b/examples/drivers/windows/otLwf/datapath.c
deleted file mode 100644
index 82ab6c690..000000000
--- a/examples/drivers/windows/otLwf/datapath.c
+++ /dev/null
@@ -1,672 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file implements the functions required for handling NetBufferLists in
- * the data path.
- */
-
-#include "precomp.h"
-#include "datapath.tmh"
-
-#ifdef LOG_BUFFERS
-
-__forceinline CHAR ToHex(CHAR n)
-{
- if (n > 9) return 'A' + (n - 10);
- else return '0' + n;
-}
-
-#define otLogLineLength 32
-
-// Helper to log a buffer
-void
-otLogBuffer(
- _In_reads_bytes_(BufferLength) PUCHAR Buffer,
- _In_ ULONG BufferLength
- )
-{
- ULONG index = 0;
- while (index < BufferLength)
- {
- CHAR szBuffer[otLogLineLength * 4] = " ";
- PCHAR buf = szBuffer + 2;
- for (ULONG i = 0; i < otLogLineLength && i + index < BufferLength; i++)
- {
- buf[0] = ToHex(Buffer[i + index] >> 4);
- buf[1] = ToHex(Buffer[i + index] & 0x0F);
- buf[2] = ' ';
- buf += 3;
- }
- buf[0] = 0;
-
- LogVerbose(DRIVER_DATA_PATH, "%s", szBuffer);
- index += otLogLineLength;
- }
-}
-
-#endif
-
-_Use_decl_annotations_
-VOID
-FilterSendNetBufferListsComplete(
- NDIS_HANDLE FilterModuleContext,
- PNET_BUFFER_LIST NetBufferLists,
- ULONG SendCompleteFlags
- )
-/*++
-
-Routine Description:
-
- Send complete handler
-
- This routine is invoked whenever the lower layer is finished processing
- sent NET_BUFFER_LISTs. If the filter does not need to be involved in the
- send path, you should remove this routine and the FilterSendNetBufferLists
- routine. NDIS will pass along send packets on behalf of your filter more
- efficiently than the filter can.
-
-Arguments:
-
- FilterModuleContext - our filter context
- NetBufferLists - a chain of NBLs that are being returned to you
- SendCompleteFlags - flags (see documentation)
-
---*/
-{
- PMS_FILTER pFilter = (PMS_FILTER)FilterModuleContext;
-
- LogFuncEntryMsg(DRIVER_DATA_PATH, "Filter: %p, NBL: %p %!STATUS!", FilterModuleContext, NetBufferLists, NetBufferLists->Status);
-
- PNET_BUFFER_LIST NBL = NetBufferLists;
- while (NBL)
- {
- PNET_BUFFER_LIST NextNBL = NBL->Next;
- PNET_BUFFER NetBuffer = NET_BUFFER_LIST_FIRST_NB(NBL);
-
- // Cancel command if we failed to send the NBL
- if (!NT_SUCCESS(NBL->Status))
- {
- spinel_tid_t tid = (spinel_tid_t)(ULONG_PTR)NetBuffer->ProtocolReserved[1];
- if (tid != 0)
- {
-#ifdef COMMAND_INIT_RETRY
- NT_ASSERT(pFilter->cmdInitTryCount < 9 || NBL->Status != NDIS_STATUS_PAUSED);
-#endif
- otLwfCmdCancel(pFilter, NDIS_TEST_SEND_COMPLETE_AT_DISPATCH_LEVEL(SendCompleteFlags), tid);
- }
- }
-
- NetBuffer->DataLength = (ULONG)(ULONG_PTR)NetBuffer->ProtocolReserved[0];
- NdisAdvanceNetBufferDataStart(NetBuffer, NetBuffer->DataLength, TRUE, NULL);
- NdisFreeNetBufferList(NBL);
-
- // Release the command rundown protection
- ExReleaseRundownProtection(&pFilter->cmdRundown);
-
- NBL = NextNBL;
- }
-
- LogFuncExit(DRIVER_DATA_PATH);
-}
-
-_Use_decl_annotations_
-VOID
-FilterSendNetBufferLists(
- NDIS_HANDLE FilterModuleContext,
- PNET_BUFFER_LIST NetBufferLists,
- NDIS_PORT_NUMBER PortNumber,
- ULONG SendFlags
- )
-/*++
-
-Routine Description:
-
- Send Net Buffer List handler
- This function is an optional function for filter drivers. If provided, NDIS
- will call this function to transmit a linked list of NetBuffers, described by a
- NetBufferList, over the network. If this handler is NULL, NDIS will skip calling
- this filter when sending a NetBufferList and will call the next lower
- driver in the stack. A filter that doesn't provide a FilerSendNetBufferList
- handler can not originate a send on its own.
-
-Arguments:
-
- FilterModuleContext - our filter context area
- NetBufferLists - a List of NetBufferLists to send
- PortNumber - Port Number to which this send is targeted
- SendFlags - specifies if the call is at DISPATCH_LEVEL
-
---*/
-{
- PMS_FILTER pFilter = (PMS_FILTER)FilterModuleContext;
- BOOLEAN DispatchLevel = NDIS_TEST_SEND_AT_DISPATCH_LEVEL(SendFlags);
-
- UNREFERENCED_PARAMETER(PortNumber);
-
- LogFuncEntryMsg(DRIVER_DATA_PATH, "Filter: %p, NBL: %p", FilterModuleContext, NetBufferLists);
-
- // Try to grab a ref on the data path first, to make sure we are allowed
- if (!ExAcquireRundownProtection(&pFilter->ExternalRefs))
- {
- LogVerbose(DRIVER_DEFAULT, "Failing SendNetBufferLists because data path isn't active.");
-
- // Ignore any NBLs we get if we aren't active (can't get a ref)
- PNET_BUFFER_LIST CurrNbl = NetBufferLists;
- while (CurrNbl)
- {
- NET_BUFFER_LIST_STATUS(CurrNbl) = NDIS_STATUS_PAUSED;
- CurrNbl = NET_BUFFER_LIST_NEXT_NBL(CurrNbl);
- }
- NdisFSendNetBufferListsComplete(
- pFilter->FilterHandle,
- NetBufferLists,
- DispatchLevel ? NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL : 0
- );
- }
- else
- {
- if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE)
- {
- // Indicate a new NBL to process on our worker thread
- otLwfEventProcessingIndicateNewNetBufferLists(
- pFilter,
- DispatchLevel,
- NetBufferLists
- );
- }
- else
- {
- PNET_BUFFER_LIST CurrNbl = NetBufferLists;
- while (CurrNbl)
- {
- PNET_BUFFER CurrNb = NET_BUFFER_LIST_FIRST_NB(CurrNbl);
- while (CurrNb)
- {
- otLwfCmdSendIp6PacketAsync(pFilter, DispatchLevel, CurrNb, TRUE);
- CurrNb = NET_BUFFER_NEXT_NB(CurrNb);
- }
-
- NET_BUFFER_LIST_STATUS(CurrNbl) = NDIS_STATUS_SUCCESS;
- CurrNbl = NET_BUFFER_LIST_NEXT_NBL(CurrNbl);
- }
-
- NdisFSendNetBufferListsComplete(
- pFilter->FilterHandle,
- NetBufferLists,
- DispatchLevel ? NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL : 0
- );
- }
-
- // Release the data path ref now
- ExReleaseRundownProtection(&pFilter->ExternalRefs);
- }
-
- LogFuncExit(DRIVER_DATA_PATH);
-}
-
-_Use_decl_annotations_
-VOID
-FilterCancelSendNetBufferLists(
- NDIS_HANDLE FilterModuleContext,
- PVOID CancelId
- )
-/*++
-
-Routine Description:
-
- This function cancels any NET_BUFFER_LISTs pended in the filter and then
- calls the NdisFCancelSendNetBufferLists to propagate the cancel operation.
-
- If your driver does not queue any send NBLs, you may omit this routine.
- NDIS will propagate the cancelation on your behalf more efficiently.
-
-Arguments:
-
- FilterModuleContext - our filter context area.
- CancelId - an identifier for all NBLs that should be dequeued
-
-*/
-{
- PMS_FILTER pFilter = (PMS_FILTER)FilterModuleContext;
-
- LogFuncEntryMsg(DRIVER_DATA_PATH, "Filter: %p, CancelId: %p", FilterModuleContext, CancelId);
-
- // Only cancel if we are 'Thread on Host', otherwise we do everything inline
- if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE)
- {
- otLwfEventProcessingIndicateNetBufferListsCancelled(pFilter, CancelId);
- }
-
- LogFuncExit(DRIVER_DATA_PATH);
-}
-
-_Use_decl_annotations_
-VOID
-FilterReturnNetBufferLists(
- NDIS_HANDLE FilterModuleContext,
- PNET_BUFFER_LIST NetBufferLists,
- ULONG ReturnFlags
- )
-/*++
-
-Routine Description:
-
- FilterReturnNetBufferLists handler.
- FilterReturnNetBufferLists is an optional function. If provided, NDIS calls
- FilterReturnNetBufferLists to return the ownership of one or more NetBufferLists
- and their embedded NetBuffers to the filter driver. If this handler is NULL, NDIS
- will skip calling this filter when returning NetBufferLists to the underlying
- miniport and will call the next lower driver in the stack. A filter that doesn't
- provide a FilterReturnNetBufferLists handler cannot originate a receive indication
- on its own.
-
-Arguments:
-
- FilterInstanceContext - our filter context area
- NetBufferLists - a linked list of NetBufferLists that this
- filter driver indicated in a previous call to
- NdisFIndicateReceiveNetBufferLists
- ReturnFlags - flags specifying if the caller is at DISPATCH_LEVEL
-
---*/
-{
- PMS_FILTER pFilter = (PMS_FILTER)FilterModuleContext;
-
- UNREFERENCED_PARAMETER(ReturnFlags);
-
- LogFuncEntryMsg(DRIVER_DATA_PATH, "Filter: %p, NBL: %p", pFilter, NetBufferLists);
-
- PNET_BUFFER_LIST CurrNbl = NetBufferLists;
- while (CurrNbl)
- {
- if (!NT_SUCCESS(CurrNbl->Status))
- {
- LogVerbose(DRIVER_DATA_PATH, "NBL failed on return: %!STATUS!", CurrNbl->Status);
- }
-
- PNET_BUFFER_LIST NblToFree = CurrNbl;
- PNET_BUFFER NbToFree = NET_BUFFER_LIST_FIRST_NB(NblToFree);
-
- CurrNbl = NET_BUFFER_LIST_NEXT_NBL(CurrNbl);
- NET_BUFFER_LIST_NEXT_NBL(NblToFree) = NULL;
-
- NdisAdvanceNetBufferDataStart(NbToFree, NET_BUFFER_DATA_LENGTH(NbToFree), TRUE, NULL);
- NdisFreeNetBufferList(NblToFree);
- }
-
- LogFuncExit(DRIVER_DATA_PATH);
-}
-
-_Use_decl_annotations_
-VOID
-FilterReceiveNetBufferLists(
- NDIS_HANDLE FilterModuleContext,
- PNET_BUFFER_LIST NetBufferLists,
- NDIS_PORT_NUMBER PortNumber,
- ULONG NumberOfNetBufferLists,
- ULONG ReceiveFlags
- )
-/*++
-
-Routine Description:
-
- FilerReceiveNetBufferLists is an optional function for filter drivers.
- If provided, this function processes receive indications made by underlying
- NIC or lower level filter drivers. This function can also be called as a
- result of loopback. If this handler is NULL, NDIS will skip calling this
- filter when processing a receive indication and will call the next higher
- driver in the stack. A filter that doesn't provide a
- FilterReceiveNetBufferLists handler cannot provide a
- FilterReturnNetBufferLists handler and cannot a initiate an original receive
- indication on its own.
-
-Arguments:
-
- FilterModuleContext - our filter context area.
- NetBufferLists - a linked list of NetBufferLists
- PortNumber - Port on which the receive is indicated
- ReceiveFlags -
-
-N.B.: It is important to check the ReceiveFlags in NDIS_TEST_RECEIVE_CANNOT_PEND.
- This controls whether the receive indication is an synchronous or
- asynchronous function call.
-
---*/
-{
-
- PMS_FILTER pFilter = (PMS_FILTER)FilterModuleContext;
- BOOLEAN DispatchLevel = NDIS_TEST_RECEIVE_AT_DISPATCH_LEVEL(ReceiveFlags);
-
- UNREFERENCED_PARAMETER(PortNumber);
- UNREFERENCED_PARAMETER(NumberOfNetBufferLists);
-
- LogFuncEntryMsg(DRIVER_DATA_PATH, "Filter: %p, NBL: %p", FilterModuleContext, NetBufferLists);
-
- // Iterate through each NBL/NB and grab the data as a contiguous buffer to
- // indicate to the Spinel command layer.
- PNET_BUFFER_LIST CurrNbl = NetBufferLists;
- while (CurrNbl)
- {
- PNET_BUFFER CurrNb = NET_BUFFER_LIST_FIRST_NB(CurrNbl);
- while (CurrNb)
- {
- PUCHAR Buffer = (PUCHAR)NdisGetDataBuffer(CurrNb, CurrNb->DataLength, NULL, 1, 0);
- if (Buffer == NULL)
- {
- Buffer = (PUCHAR)FILTER_ALLOC_MEM(pFilter->FilterHandle, CurrNb->DataLength);
- if (Buffer != NULL)
- {
- PUCHAR _Buffer = (PUCHAR)NdisGetDataBuffer(CurrNb, CurrNb->DataLength, Buffer, 1, 0);
- NT_ASSERT(_Buffer == Buffer);
- if (_Buffer)
- {
- otLwfCmdRecveive(pFilter, DispatchLevel, Buffer, CurrNb->DataLength);
- }
- FILTER_FREE_MEM(Buffer);
- }
- }
- else
- {
- otLwfCmdRecveive(pFilter, DispatchLevel, Buffer, CurrNb->DataLength);
- }
- CurrNb = NET_BUFFER_NEXT_NB(CurrNb);
- }
-
- NET_BUFFER_LIST_STATUS(CurrNbl) = NDIS_STATUS_SUCCESS;
- CurrNbl = NET_BUFFER_LIST_NEXT_NBL(CurrNbl);
- }
-
- if (NDIS_TEST_RECEIVE_CAN_PEND(ReceiveFlags))
- {
- NdisFReturnNetBufferLists(
- pFilter->FilterHandle,
- NetBufferLists,
- DispatchLevel ? NDIS_RETURN_FLAGS_DISPATCH_LEVEL : 0
- );
- }
-
- LogFuncExit(DRIVER_DATA_PATH);
-}
-
-// Callback received from OpenThread when it has an IPv6 packet ready for
-// delivery to TCPIP.
-void
-otLwfReceiveIp6DatagramCallback(
- _In_ otMessage *aMessage,
- _In_ void *aContext
- )
-{
- PMS_FILTER pFilter = (PMS_FILTER)aContext;
- uint16_t messageLength = otMessageGetLength(aMessage);
- PNET_BUFFER_LIST NetBufferList = NULL;
- PNET_BUFFER NetBuffer = NULL;
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- PUCHAR DataBuffer = NULL;
- int BytesRead = 0;
- IPV6_HEADER* v6Header;
-
-#ifdef FORCE_SYNCHRONOUS_RECEIVE
- KIRQL irql;
-#endif
-
- // Create the NetBufferList
- NetBufferList =
- NdisAllocateNetBufferAndNetBufferList(
- pFilter->cmdNblPool, // PoolHandle
- 0, // ContextSize
- 0, // ContextBackFill
- NULL, // MdlChain
- 0, // DataOffset
- 0 // DataLength
- );
- if (NetBufferList == NULL)
- {
- LogWarning(DRIVER_DEFAULT, "Failed to create Recv NetBufferList");
- goto error;
- }
-
- // Set the flag to indicate its a IPv6 packet
- NdisSetNblFlag(NetBufferList, NDIS_NBL_FLAGS_IS_IPV6);
- NET_BUFFER_LIST_INFO(NetBufferList, NetBufferListFrameType) =
- UlongToPtr(RtlUshortByteSwap(ETHERNET_TYPE_IPV6));
-
- // Initialize NetBuffer fields
- NetBuffer = NET_BUFFER_LIST_FIRST_NB(NetBufferList);
- NET_BUFFER_CURRENT_MDL(NetBuffer) = NULL;
- NET_BUFFER_CURRENT_MDL_OFFSET(NetBuffer) = 0;
- NET_BUFFER_DATA_LENGTH(NetBuffer) = 0;
- NET_BUFFER_DATA_OFFSET(NetBuffer) = 0;
- NET_BUFFER_FIRST_MDL(NetBuffer) = NULL;
-
- // Allocate the NetBuffer for SendNetBufferList
- Status = NdisRetreatNetBufferDataStart(NetBuffer, messageLength, 0, NULL);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- NdisFreeNetBufferList(NetBufferList);
- LogError(DRIVER_DEFAULT, "Failed to allocate NB for Recv NetBufferList, %!NDIS_STATUS!", Status);
- goto error;
- }
-
- // Get the data buffer to write to
- DataBuffer = NdisGetDataBuffer(NetBuffer, messageLength, NULL, 1, 0);
- NT_ASSERT(DataBuffer);
- if (DataBuffer == NULL)
- {
- NdisAdvanceNetBufferDataStart(NetBuffer, messageLength, TRUE, NULL);
- NdisFreeNetBufferList(NetBufferList);
- LogError(DRIVER_DEFAULT, "Failed to get contiguous data buffer for Recv NetBufferList");
- goto error;
- }
-
- // Read the bytes to the buffer
- BytesRead = otMessageRead(aMessage, 0, DataBuffer, messageLength);
- NT_ASSERT(BytesRead == (int)messageLength);
- if (BytesRead != (int)messageLength)
- {
- NdisAdvanceNetBufferDataStart(NetBuffer, messageLength, TRUE, NULL);
- NdisFreeNetBufferList(NetBufferList);
- LogError(DRIVER_DEFAULT, "Failed to read message buffer for Recv NetBufferList");
- goto error;
- }
-
- v6Header = (IPV6_HEADER*)DataBuffer;
-
- // Filter messages to addresses we expose
- if (!IN6_IS_ADDR_MULTICAST(&v6Header->DestinationAddress) &&
- otLwfFindCachedAddrIndex(pFilter, &v6Header->DestinationAddress) == -1)
- {
- NdisAdvanceNetBufferDataStart(NetBuffer, messageLength, TRUE, NULL);
- NdisFreeNetBufferList(NetBufferList);
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p dropping internal address message.", pFilter);
- goto error;
- }
-
- // Filter internal Thread messages
- if (v6Header->NextHeader == IPPROTO_UDP &&
- messageLength >= sizeof(IPV6_HEADER) + sizeof(UDPHeader) &&
- memcmp(&pFilter->otLinkLocalAddr, &v6Header->DestinationAddress, sizeof(IN6_ADDR)) == 0)
- {
- // Check for MLE message
- UDPHeader* UdpHeader = (UDPHeader*)(v6Header + 1);
- if (UdpHeader->DestinationPort == UdpHeader->SourcePort &&
- UdpHeader->DestinationPort == RtlUshortByteSwap(19788)) // MLE Port
- {
- NdisAdvanceNetBufferDataStart(NetBuffer, messageLength, TRUE, NULL);
- NdisFreeNetBufferList(NetBufferList);
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p dropping MLE message.", pFilter);
- goto error;
- }
- }
-
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, IP6_RECV: %p : %!IPV6ADDR! => %!IPV6ADDR! (%u bytes)",
- pFilter, NetBufferList, &v6Header->SourceAddress, &v6Header->DestinationAddress,
- messageLength);
-
-#ifdef LOG_BUFFERS
- otLogBuffer(DataBuffer, messageLength);
-#endif
-
-#ifdef FORCE_SYNCHRONOUS_RECEIVE
- irql = KfRaiseIrql(DISPATCH_LEVEL);
-
- if (messageLength == 248) // Magic length used for TAEF test packets
- {
- DbgBreakPoint();
- }
-#endif
-
- // Indicate the NBL up
- NdisFIndicateReceiveNetBufferLists(
- pFilter->FilterHandle,
- NetBufferList,
- NDIS_DEFAULT_PORT_NUMBER,
- 1,
-#ifdef FORCE_SYNCHRONOUS_RECEIVE
- NDIS_RECEIVE_FLAGS_RESOURCES | NDIS_RECEIVE_FLAGS_DISPATCH_LEVEL
-#else
- 0
-#endif
- );
-
-#ifdef FORCE_SYNCHRONOUS_RECEIVE
- KeLowerIrql(irql);
- FilterReturnNetBufferLists(pFilter, NetBufferList, 0);
-#endif
-
-error:
-
- otMessageFree(aMessage);
-}
-
-// Called in response to receiving a Spinel Ip6 packet command
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfTunReceiveIp6Packet(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ BOOLEAN Secure,
- _In_reads_bytes_(BufferLength) const uint8_t* Buffer,
- _In_ UINT BufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- PNET_BUFFER_LIST NetBufferList = NULL;
- PNET_BUFFER NetBuffer = NULL;
- PUCHAR DataBuffer = NULL;
- IPV6_HEADER* v6Header;
-
- UNREFERENCED_PARAMETER(Secure); // TODO - What should we do with unsecured packets?
-
- NetBufferList =
- NdisAllocateNetBufferAndNetBufferList(
- pFilter->cmdNblPool, // PoolHandle
- 0, // ContextSize
- 0, // ContextBackFill
- NULL, // MdlChain
- 0, // DataOffset
- 0 // DataLength
- );
- if (NetBufferList == NULL)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- LogWarning(DRIVER_DEFAULT, "Failed to create command NetBufferList");
- goto exit;
- }
-
- // Set the flag to indicate its a IPv6 packet
- NdisSetNblFlag(NetBufferList, NDIS_NBL_FLAGS_IS_IPV6);
- NET_BUFFER_LIST_INFO(NetBufferList, NetBufferListFrameType) =
- UlongToPtr(RtlUshortByteSwap(ETHERNET_TYPE_IPV6));
-
- // Initialize NetBuffer fields
- NetBuffer = NET_BUFFER_LIST_FIRST_NB(NetBufferList);
- NET_BUFFER_CURRENT_MDL(NetBuffer) = NULL;
- NET_BUFFER_CURRENT_MDL_OFFSET(NetBuffer) = 0;
- NET_BUFFER_DATA_LENGTH(NetBuffer) = 0;
- NET_BUFFER_DATA_OFFSET(NetBuffer) = 0;
- NET_BUFFER_FIRST_MDL(NetBuffer) = NULL;
-
- // Allocate the NetBuffer for NetBufferList
- if (NdisRetreatNetBufferDataStart(NetBuffer, BufferLength, 0, NULL) != NDIS_STATUS_SUCCESS)
- {
- NetBuffer = NULL;
- status = STATUS_INSUFFICIENT_RESOURCES;
- LogError(DRIVER_DEFAULT, "Failed to allocate NB for command NetBufferList, %u bytes", BufferLength);
- goto exit;
- }
-
- // Get the pointer to the data buffer for the header data
- DataBuffer = (PUCHAR)NdisGetDataBuffer(NetBuffer, BufferLength, NULL, 1, 0);
- NT_ASSERT(DataBuffer);
-
- // Copy the data over
- RtlCopyMemory(DataBuffer, Buffer, BufferLength);
-
- v6Header = (IPV6_HEADER*)DataBuffer;
-
- // Filter messages to addresses we expose
- if (!IN6_IS_ADDR_MULTICAST(&v6Header->DestinationAddress) &&
- otLwfFindCachedAddrIndex(pFilter, &v6Header->DestinationAddress) == -1)
- {
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p dropping internal address message.", pFilter);
- goto exit;
- }
-
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, IP6_RECV: %p : %!IPV6ADDR! => %!IPV6ADDR! (%u bytes)",
- pFilter, NetBufferList, &v6Header->SourceAddress, &v6Header->DestinationAddress,
- BufferLength);
-
-#ifdef LOG_BUFFERS
- otLogBuffer(DataBuffer, BufferLength);
-#endif
-
- // Send the NBL down
- NdisFIndicateReceiveNetBufferLists(
- pFilter->FilterHandle,
- NetBufferList,
- NDIS_DEFAULT_PORT_NUMBER,
- 1,
- DispatchLevel ? NDIS_RECEIVE_FLAGS_DISPATCH_LEVEL : 0);
-
- // Clear local variable because we don't own the NBL any more
- NetBufferList = NULL;
-
-exit:
-
- if (NetBufferList)
- {
- if (NetBuffer)
- {
- NdisAdvanceNetBufferDataStart(NetBuffer, NetBuffer->DataLength, TRUE, NULL);
- }
- NdisFreeNetBufferList(NetBufferList);
- }
-}
diff --git a/examples/drivers/windows/otLwf/device.c b/examples/drivers/windows/otLwf/device.c
deleted file mode 100644
index 81188b1ba..000000000
--- a/examples/drivers/windows/otLwf/device.c
+++ /dev/null
@@ -1,690 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "precomp.h"
-#include "device.tmh"
-
-// IoControl Device Object from IoCreateDeviceSecure
-PDEVICE_OBJECT IoDeviceObject = NULL;
-
-// Global context for device control callbacks
-POTLWF_DEVICE_EXTENSION FilterDeviceExtension = NULL;
-
-/*
-
-Powershell script to generate security desciptors:
-
-$sddl = "D:P(A;;GA;;;SY)(A;;GA;;;NS)(A;;GA;;;BA)(A;;GA;;;WD)(A;;GA;;;S-1-15-3-3)"
-$blob = ([wmiclass]"Win32_SecurityDescriptorHelper").SDDLToBinarySD($sddl).BinarySD
-$string = [BitConverter]::ToString($blob)
-$string = $string -replace '-', ''
-$string = $string -replace '(..)(..)(..)(..)', '0x$4$3$2$1, '
-$string -replace '(.{10}, .{10}, .{10}, .{10},) ', "$&`n"
-
-*/
-const unsigned long c_sdThreadLwf[] =
-{
- 0x90040001, 0x00000000, 0x00000000, 0x00000000,
- 0x00000014, 0x00740002, 0x00000005, 0x00140000,
- 0x10000000, 0x00000101, 0x05000000, 0x00000012,
- 0x00140000, 0x10000000, 0x00000101, 0x05000000,
- 0x00000014, 0x00180000, 0x10000000, 0x00000201,
- 0x05000000, 0x00000020, 0x00000220, 0x00140000,
- 0x10000000, 0x00000101, 0x01000000, 0x00000000,
- 0x00180000, 0x10000000, 0x00000201, 0x0F000000,
- 0x00000003, 0x00000003
-};
-
-_No_competing_thread_
-INITCODE
-NDIS_STATUS
-otLwfRegisterDevice(
- VOID
- )
-{
- NTSTATUS Status = NDIS_STATUS_SUCCESS;
- UNICODE_STRING DeviceName;
- UNICODE_STRING DeviceLinkUnicodeString;
- PDEVICE_OBJECT DeviceObject;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- NT_ASSERT(FilterDeviceExtension == NULL);
-
- NdisInitUnicodeString(&DeviceName, NTDEVICE_STRING);
- NdisInitUnicodeString(&DeviceLinkUnicodeString, LINKNAME_STRING);
-
- Status = IoCreateDeviceSecure(FilterDriverObject, // DriverObject
- sizeof(OTLWF_DEVICE_EXTENSION), // DeviceExtension
- &DeviceName, // DeviceName
- FILE_DEVICE_NETWORK, // DeviceType
- FILE_DEVICE_SECURE_OPEN, // DeviceCharacteristics
- FALSE, // Exclusive
- &SDDL_DEVOBJ_KERNEL_ONLY, // security attributes
- NULL, // security override device class
- &DeviceObject); // DeviceObject
-
- if (NT_SUCCESS(Status))
- {
- DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
- Status = IoCreateSymbolicLink(&DeviceLinkUnicodeString, &DeviceName);
-
- if (!NT_SUCCESS(Status))
- {
- LogError(DRIVER_DEFAULT, "IoCreateSymbolicLink failed, %!STATUS!", Status);
- IoDeleteDevice(DeviceObject);
- }
- else
- {
- FilterDeviceExtension = (POTLWF_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- RtlZeroMemory(FilterDeviceExtension, sizeof(OTLWF_DEVICE_EXTENSION));
-
- FilterDeviceExtension->Signature = 'FTDR';
- FilterDeviceExtension->Handle = FilterDriverHandle;
-
- NdisAllocateSpinLock(&FilterDeviceExtension->Lock);
- InitializeListHead(&FilterDeviceExtension->ClientList);
-
- #pragma push
- #pragma warning(disable:28168) // The function 'otLwfDispatch' does not have a _Dispatch_type_ annotation matching dispatch table position *
- FilterDriverObject->MajorFunction[IRP_MJ_CREATE] = otLwfDispatch;
- FilterDriverObject->MajorFunction[IRP_MJ_CLEANUP] = otLwfDispatch;
- FilterDriverObject->MajorFunction[IRP_MJ_CLOSE] = otLwfDispatch;
- FilterDriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = otLwfDeviceIoControl;
- #pragma pop
-
- HANDLE fileHandle;
- Status = ObOpenObjectByPointer(DeviceObject,
- OBJ_KERNEL_HANDLE,
- NULL,
- WRITE_DAC,
- 0,
- KernelMode,
- &fileHandle);
- if (NT_SUCCESS(Status))
- {
- Status = ZwSetSecurityObject(fileHandle,
- DACL_SECURITY_INFORMATION,
- (PSECURITY_DESCRIPTOR)c_sdThreadLwf);
-
- if (!NT_SUCCESS(Status))
- {
- LogError(DRIVER_DEFAULT, "ZwSetSecurityObject failed, %!STATUS!", Status);
- }
-
- ZwClose(fileHandle);
- }
- else
- {
- LogError(DRIVER_DEFAULT, "ObOpenObjectByPointer failed, %!STATUS!", Status);
- }
-
- IoDeviceObject = DeviceObject;
- }
- }
- else
- {
- LogError(DRIVER_DEFAULT, "IoCreateDeviceSecure failed, %!STATUS!", Status);
- }
-
- LogFuncExitNT(DRIVER_DEFAULT, Status);
-
- return (NDIS_STATUS)Status;
-}
-
-PIRP
-otLwfDeviceClientCleanup(
- POTLWF_DEVICE_CLIENT DeviceClient
- )
-{
- PIRP IrpToCancel = NULL;
-
- // Clean the FileObject context
- DeviceClient->FileObject->FsContext2 = NULL;
-
- // Release pending IRP
- if (DeviceClient->PendingNotificationIRP)
- {
- IrpToCancel = DeviceClient->PendingNotificationIRP;
- DeviceClient->PendingNotificationIRP = NULL;
- }
-
- // Free all pending notifications
- NT_ASSERT(DeviceClient->NotificationSize <= OTLWF_MAX_PENDING_NOTIFICATIONS_PER_CLIENT);
- for (UCHAR i = 0; i < DeviceClient->NotificationSize; i++)
- {
- UCHAR index = (DeviceClient->NotificationOffset + i) % OTLWF_MAX_PENDING_NOTIFICATIONS_PER_CLIENT;
- otLwfReleaseNotification(DeviceClient->PendingNotifications[index]);
- }
-
- return IrpToCancel;
-}
-
-_No_competing_thread_
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfDeregisterDevice(
- VOID
- )
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- if (IoDeviceObject != NULL)
- {
- NT_ASSERT(FilterDeviceExtension);
- NdisFreeSpinLock(&FilterDeviceExtension->Lock);
-
- // Clean up all pending clients
- PLIST_ENTRY Link = FilterDeviceExtension->ClientList.Flink;
- while (Link != &FilterDeviceExtension->ClientList)
- {
- POTLWF_DEVICE_CLIENT DeviceClient = CONTAINING_RECORD(Link, OTLWF_DEVICE_CLIENT, Link);
- PIRP IrpToCancel = NULL;
-
- // Set next link
- Link = Link->Flink;
-
- // Make sure to clean up any left overs from the device client
- IrpToCancel = otLwfDeviceClientCleanup(DeviceClient);
-
- // Complete the pending IRP since we are shutting down
- if (IrpToCancel)
- {
- // Before we are allowed to complete the pending IRP, we must remove the cancel routine
- KIRQL irql;
- IoAcquireCancelSpinLock(&irql);
- IoSetCancelRoutine(IrpToCancel, NULL);
- IoReleaseCancelSpinLock(irql);
-
- IrpToCancel->IoStatus.Status = STATUS_CANCELLED;
- IrpToCancel->IoStatus.Information = 0;
- IoCompleteRequest(IrpToCancel, IO_NO_INCREMENT);
- }
-
- // Remove the device client from the list
- RemoveEntryList(&DeviceClient->Link);
-
- // Delete the device client
- NdisFreeMemory(DeviceClient, 0, 0);
- }
-
- IoDeleteDevice(IoDeviceObject);
- }
-
- IoDeviceObject = NULL;
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_Use_decl_annotations_
-NTSTATUS
-otLwfDispatch(
- PDEVICE_OBJECT DeviceObject,
- PIRP Irp
- )
-{
- PIO_STACK_LOCATION IrpStack;
- NTSTATUS Status = STATUS_SUCCESS;
- PIRP IrpToCancel = NULL;
- POTLWF_DEVICE_CLIENT DeviceClient = NULL;
-
- UNREFERENCED_PARAMETER(DeviceObject);
-
- LogFuncEntry(DRIVER_IOCTL);
-
- IrpStack = IoGetCurrentIrpStackLocation(Irp);
-
- NdisAcquireSpinLock(&FilterDeviceExtension->Lock);
-
- switch (IrpStack->MajorFunction)
- {
- case IRP_MJ_CREATE:
- LogInfo(DRIVER_IOCTL, "Client %p attached.", IrpStack->FileObject);
-
- if (FilterDeviceExtension->ClientListSize >= OTLWF_MAX_CLIENTS)
- {
- LogError(DRIVER_IOCTL, "Already have max clients!");
- Status = STATUS_TOO_MANY_SESSIONS;
- break;
- }
-
- DeviceClient = FILTER_ALLOC_DEVICE_CLIENT();
- if (DeviceClient)
- {
- RtlZeroMemory(DeviceClient, sizeof(OTLWF_DEVICE_CLIENT));
- DeviceClient->FileObject = IrpStack->FileObject;
-
- NT_ASSERT(IrpStack->FileObject->FsContext2 == NULL);
- IrpStack->FileObject->FsContext2 = DeviceClient;
-
- // Insert into the client list
- InsertTailList(&FilterDeviceExtension->ClientList, &DeviceClient->Link);
- FilterDeviceExtension->ClientListSize++;
- }
- else
- {
- Status = STATUS_INSUFFICIENT_RESOURCES;
- }
- break;
-
- case IRP_MJ_CLEANUP:
- LogInfo(DRIVER_IOCTL, "Client %p cleaning up.", IrpStack->FileObject);
-
- DeviceClient = (POTLWF_DEVICE_CLIENT)IrpStack->FileObject->FsContext2;
-
- // Make sure to clean up any left overs from the device client
- IrpToCancel = otLwfDeviceClientCleanup(DeviceClient);
-
- // Remove the device client from the list
- RemoveEntryList(&DeviceClient->Link);
- FilterDeviceExtension->ClientListSize--;
-
- // Delete the device client
- NdisFreeMemory(DeviceClient, 0, 0);
- break;
-
- case IRP_MJ_CLOSE:
- LogInfo(DRIVER_IOCTL, "Client %p detatched.", IrpStack->FileObject);
- break;
-
- default:
- break;
- }
-
- NdisReleaseSpinLock(&FilterDeviceExtension->Lock);
-
- // Cancel the pending notification IRP if set
- if (IrpToCancel)
- {
- // Complete the pending IRP
- IrpToCancel->IoStatus.Status = STATUS_CANCELLED;
- IrpToCancel->IoStatus.Information = 0;
- IoCompleteRequest(IrpToCancel, IO_NO_INCREMENT);
- }
-
- Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- LogFuncExitNT(DRIVER_IOCTL, Status);
-
- return Status;
-}
-
-_Use_decl_annotations_
-NTSTATUS
-otLwfDeviceIoControl(
- PDEVICE_OBJECT DeviceObject,
- PIRP Irp
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- BOOLEAN CompleteIRP = TRUE;
-
- PVOID IoBuffer = Irp->AssociatedIrp.SystemBuffer;
-
- PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
- ULONG InputBufferLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength;
- ULONG OutputBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
- ULONG IoControlCode = IrpSp->Parameters.DeviceIoControl.IoControlCode;
-
- ULONG FuncCode = (IoControlCode >> 2) & 0xFFF;
-
- LogFuncEntryMsg(DRIVER_IOCTL, "%p", IrpSp->FileObject);
-
-#if DBG
- ASSERT(((POTLWF_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->Signature == 'FTDR');
-#else
- UNREFERENCED_PARAMETER(DeviceObject);
-#endif
-
- // We only allow PASSIVE_LEVEL calls
- if (KeGetCurrentIrql() > PASSIVE_LEVEL)
- {
- LogWarning(DRIVER_IOCTL, "FilterDeviceIoControl called higher than PASSIVE.");
- status = STATUS_NOT_SUPPORTED;
- RtlZeroMemory(IoBuffer, OutputBufferLength);
- OutputBufferLength = 0;
- goto error;
- }
-
- if (FuncCode >= MIN_OTLWF_IOCTL_FUNC_CODE && FuncCode <= MAX_OTLWF_IOCTL_FUNC_CODE)
- {
- CompleteIRP = FALSE;
- status = otLwfIoCtlOpenThreadControl(Irp);
- goto error;
- }
-
- // Check the IoControlCode to determine which IOCTL we are processing
- switch (IoControlCode)
- {
- case IOCTL_OTLWF_QUERY_NOTIFICATION:
- CompleteIRP = FALSE;
- status = otLwfQueryNextNotification(Irp);
- break;
-
- case IOCTL_OTLWF_ENUMERATE_DEVICES:
- status =
- otLwfIoCtlEnumerateInterfaces(
- IoBuffer, InputBufferLength,
- IoBuffer, &OutputBufferLength
- );
- break;
-
- case IOCTL_OTLWF_QUERY_DEVICE:
- status =
- otLwfIoCtlQueryInterface(
- IoBuffer, InputBufferLength,
- IoBuffer, &OutputBufferLength
- );
- break;
-
- default:
- status = STATUS_NOT_IMPLEMENTED;
- RtlZeroMemory(IoBuffer, OutputBufferLength);
- OutputBufferLength = 0;
- break;
- }
-
-error:
-
- if (CompleteIRP)
- {
- Irp->IoStatus.Status = status;
- Irp->IoStatus.Information = OutputBufferLength;
-
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- }
-
- LogFuncExitNT(DRIVER_IOCTL, status);
-
- return status;
-}
-
-_Use_decl_annotations_
-PMS_FILTER
-otLwfFindAndRefInterface(
- _In_ PGUID InterfaceGuid
- )
-{
- PMS_FILTER pOutput = NULL;
-
- NdisAcquireSpinLock(&FilterListLock);
-
- for (PLIST_ENTRY Link = FilterModuleList.Flink; Link != &FilterModuleList; Link = Link->Flink)
- {
- PMS_FILTER pFilter = CONTAINING_RECORD(Link, MS_FILTER, FilterModuleLink);
-
- if (pFilter->State == FilterRunning &&
- memcmp(InterfaceGuid, &pFilter->InterfaceGuid, sizeof(GUID)) == 0)
- {
- if (ExAcquireRundownProtection(&pFilter->ExternalRefs))
- {
- pOutput = pFilter;
- }
- break;
- }
- }
-
- NdisReleaseSpinLock(&FilterListLock);
-
- return pOutput;
-}
-
-//
-// Notification Functions
-//
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfReleaseNotification(
- _In_ PFILTER_NOTIFICATION_ENTRY NotifEntry
- )
-{
- if (RtlDecrementReferenceCount(&NotifEntry->RefCount))
- {
- NdisFreeMemory(NotifEntry, 0, 0);
- }
-}
-
-// Indicates a new notification
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfIndicateNotification(
- _In_ PFILTER_NOTIFICATION_ENTRY NotifEntry
- )
-{
- PIRP IrpsToComplete[OTLWF_MAX_CLIENTS] = {0};
- UCHAR IrpOffset = 0;
-
- LogFuncEntry(DRIVER_IOCTL);
-
- // Initialize with a local ref
- NotifEntry->RefCount = 1;
-
- if (FilterDeviceExtension == NULL) goto error;
-
- NdisAcquireSpinLock(&FilterDeviceExtension->Lock);
-
- // Pend the notification for each client
- PLIST_ENTRY Link = FilterDeviceExtension->ClientList.Flink;
- while (Link != &FilterDeviceExtension->ClientList)
- {
- POTLWF_DEVICE_CLIENT DeviceClient = CONTAINING_RECORD(Link, OTLWF_DEVICE_CLIENT, Link);
-
- // Set next link
- Link = Link->Flink;
-
- KIRQL irql;
- IoAcquireCancelSpinLock(&irql);
-
- // If there are other pending notifications or we don't have a pending IRP saved
- // then just go ahead and add the notification to the list
- NT_ASSERT(DeviceClient->NotificationSize <= OTLWF_MAX_PENDING_NOTIFICATIONS_PER_CLIENT);
- if (DeviceClient->NotificationSize != 0 ||
- DeviceClient->PendingNotificationIRP == NULL
- )
- {
- // Calculate the next index
- UCHAR Index = (DeviceClient->NotificationOffset + DeviceClient->NotificationSize) % OTLWF_MAX_PENDING_NOTIFICATIONS_PER_CLIENT;
-
- // Add additional ref to the notif
- RtlIncrementReferenceCount(&NotifEntry->RefCount);
-
- // If we are at the max already, release the oldest
- if (DeviceClient->NotificationSize == OTLWF_MAX_PENDING_NOTIFICATIONS_PER_CLIENT)
- {
- LogWarning(DRIVER_IOCTL, "Dropping old notification!");
- otLwfReleaseNotification(DeviceClient->PendingNotifications[DeviceClient->NotificationOffset]);
- DeviceClient->NotificationOffset = (DeviceClient->NotificationOffset + 1) % OTLWF_MAX_PENDING_NOTIFICATIONS_PER_CLIENT;
- }
- else
- {
- DeviceClient->NotificationSize++;
- }
-
- // Copy the notification to the next space
- DeviceClient->PendingNotifications[Index] = NotifEntry;
- }
- else
- {
- // Before we are allowed to complete the pending IRP, we must remove the cancel routine
- IoSetCancelRoutine(DeviceClient->PendingNotificationIRP, NULL);
-
- IrpsToComplete[IrpOffset] = DeviceClient->PendingNotificationIRP;
- IrpOffset++;
-
- DeviceClient->PendingNotificationIRP = NULL;
- }
-
- // Release the cancel spin lock
- IoReleaseCancelSpinLock(irql);
- }
-
- NdisReleaseSpinLock(&FilterDeviceExtension->Lock);
-
- // Complete any IRPs now, outside the lock
- for (UCHAR i = 0; i < IrpOffset; i++)
- {
- PIRP IrpToComplete = IrpsToComplete[i];
-
- // Copy the notification payload
- PVOID IoBuffer = IrpToComplete->AssociatedIrp.SystemBuffer;
- memcpy(IoBuffer, &NotifEntry->Notif, sizeof(OTLWF_NOTIFICATION));
- IrpToComplete->IoStatus.Information = sizeof(OTLWF_NOTIFICATION);
-
- // Complete the IRP
- IrpToComplete->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(IrpToComplete, IO_NO_INCREMENT);
- }
-
-error:
-
- // Release local ref on the notification
- otLwfReleaseNotification(NotifEntry);
-
- LogFuncExit(DRIVER_IOCTL);
-}
-
-DRIVER_CANCEL otLwfQueryNotificationCancelled;
-
-_Use_decl_annotations_
-VOID
-otLwfQueryNotificationCancelled(
- _Inout_ PDEVICE_OBJECT DeviceObject,
- _Inout_ _IRQL_uses_cancel_ struct _IRP *Irp
-)
-{
- UNREFERENCED_PARAMETER(DeviceObject);
-
- LogFuncEntry(DRIVER_IOCTL);
-
- PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
- POTLWF_DEVICE_CLIENT DeviceClient = (POTLWF_DEVICE_CLIENT)IrpSp->FileObject->FsContext2;
-
- if (DeviceClient)
- {
- DeviceClient->PendingNotificationIRP = NULL;
- }
-
- IoReleaseCancelSpinLock(Irp->CancelIrql);
-
- Irp->IoStatus.Status = STATUS_CANCELLED;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- LogFuncExit(DRIVER_IOCTL);
-}
-
-// Queries the next notification
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfQueryNextNotification(
- _In_ PIRP Irp
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- POTLWF_DEVICE_CLIENT DeviceClient = NULL;
- PFILTER_NOTIFICATION_ENTRY NotifEntry = NULL;
-
- LogFuncEntry(DRIVER_IOCTL);
-
- PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
- ULONG OutputBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
-
- // Validate we have a big enough buffer
- if (OutputBufferLength < sizeof(OTLWF_NOTIFICATION))
- {
- RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer, OutputBufferLength);
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto error;
- }
-
- DeviceClient = (POTLWF_DEVICE_CLIENT)IrpSp->FileObject->FsContext2;
- if (DeviceClient == NULL)
- {
- status = STATUS_DEVICE_NOT_READY;
- goto error;
- }
-
- NdisAcquireSpinLock(&FilterDeviceExtension->Lock);
-
- // Check to see if there are any notifications available
- if (DeviceClient->NotificationSize == 0)
- {
- // Set the cancel routine
- IoSetCancelRoutine(Irp, otLwfQueryNotificationCancelled);
-
- // Mark the Irp as pending
- IoMarkIrpPending(Irp);
-
- // Save the IRP to complete later, when we have a notification
- DeviceClient->PendingNotificationIRP = Irp;
- }
- else
- {
- // Get the notification
- NotifEntry = DeviceClient->PendingNotifications[DeviceClient->NotificationOffset];
- DeviceClient->PendingNotifications[DeviceClient->NotificationOffset] = NULL;
-
- // Increment the offset and decrement the size
- DeviceClient->NotificationOffset = (DeviceClient->NotificationOffset + 1) % OTLWF_MAX_PENDING_NOTIFICATIONS_PER_CLIENT;
- DeviceClient->NotificationSize--;
- }
-
- NdisReleaseSpinLock(&FilterDeviceExtension->Lock);
-
- // If we found a notification, complete the IRP with it
- if (NotifEntry)
- {
- // Copy the notification payload
- PVOID IoBuffer = Irp->AssociatedIrp.SystemBuffer;
- memcpy(IoBuffer, &NotifEntry->Notif, sizeof(OTLWF_NOTIFICATION));
- Irp->IoStatus.Information = sizeof(OTLWF_NOTIFICATION);
-
- // Free the notification
- otLwfReleaseNotification(NotifEntry);
- }
- else
- {
- // Otherwise, set status to indicate we are pending the IRP
- status = STATUS_PENDING;
- }
-
-error:
-
- // Complete the IRP if we aren't pending
- if (status != STATUS_PENDING)
- {
- Irp->IoStatus.Status = status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- }
-
- LogFuncExitNT(DRIVER_IOCTL, status);
-
- return status;
-}
diff --git a/examples/drivers/windows/otLwf/device.h b/examples/drivers/windows/otLwf/device.h
deleted file mode 100644
index 5bba716a4..000000000
--- a/examples/drivers/windows/otLwf/device.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines the functions for managing the device IOCTL interface.
- */
-
-#ifndef _DEVICE_H
-#define _DEVICE_H
-
-//
-// The filter needs to handle IOCTRLs
-//
-#define LINKNAME_STRING L"\\DosDevices\\otLwf"
-#define NTDEVICE_STRING L"\\Device\\otLwf"
-
-// The maximum number of simultaneous clients supported
-#define OTLWF_MAX_CLIENTS 10
-
-// The maximum number of notifications allowed to be pended, per client
-#define OTLWF_MAX_PENDING_NOTIFICATIONS_PER_CLIENT 100
-
-// Context for IO Device Control callbacks
-typedef struct _OTLWF_DEVICE_EXTENSION
-{
- ULONG Signature;
- NDIS_HANDLE Handle;
-
- NDIS_SPIN_LOCK Lock;
- _Guarded_by_(Lock)
- LIST_ENTRY ClientList;
- ULONG ClientListSize;
-
-} OTLWF_DEVICE_EXTENSION, *POTLWF_DEVICE_EXTENSION;
-
-// Notification structure
-typedef struct _FILTER_NOTIFICATION_ENTRY
-{
- RTL_REFERENCE_COUNT RefCount;
- OTLWF_NOTIFICATION Notif;
-
-} FILTER_NOTIFICATION_ENTRY, *PFILTER_NOTIFICATION_ENTRY;
-
-// Tag for allocating notification structures 'TNtf
-#define FILTER_NOTIF_ALLOC_TAG 'ftNT'
-
-// Helper to allocate a new notification entry
-#define FILTER_ALLOC_NOTIF(_pFilter) \
- (PFILTER_NOTIFICATION_ENTRY)NdisAllocateMemoryWithTagPriority(_pFilter->FilterHandle, sizeof(FILTER_NOTIFICATION_ENTRY), FILTER_NOTIF_ALLOC_TAG, NormalPoolPriority)
-
-// Context for IO Device Control clients
-typedef struct _OTLWF_DEVICE_CLIENT
-{
- LIST_ENTRY Link;
- PFILE_OBJECT FileObject;
- PIRP PendingNotificationIRP;
- PFILTER_NOTIFICATION_ENTRY PendingNotifications[OTLWF_MAX_PENDING_NOTIFICATIONS_PER_CLIENT];
- UCHAR NotificationOffset;
- UCHAR NotificationSize;
-
-} OTLWF_DEVICE_CLIENT, *POTLWF_DEVICE_CLIENT;
-
-// Helper to allocate a new Device Control client
-#define FILTER_ALLOC_DEVICE_CLIENT() \
- (POTLWF_DEVICE_CLIENT)NdisAllocateMemoryWithTagPriority(FilterDeviceExtension->Handle, sizeof(OTLWF_DEVICE_CLIENT), FILTER_NOTIF_ALLOC_TAG, NormalPoolPriority)
-
-static_assert(
- (1 << (sizeof(UCHAR) * 8)) > OTLWF_MAX_PENDING_NOTIFICATIONS_PER_CLIENT,
- "Type of NotificationOffset must be big enough for OTLWF_MAX_PENDING_NOTIFICATIONS_PER_CLIENT"
- );
-
-// Global context for device control callbacks
-extern POTLWF_DEVICE_EXTENSION FilterDeviceExtension;
-
-//
-// Function prototypes
-//
-
-// Registers for Io Control callbacks
-_No_competing_thread_
-INITCODE
-NDIS_STATUS
-otLwfRegisterDevice(
- VOID
- );
-
-// Unregisters for Io Control Callbacks
-_No_competing_thread_
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfDeregisterDevice(
- VOID
- );
-
-// Callback for general control IRPs
-DRIVER_DISPATCH otLwfDispatch;
-
-// Callback for IOCTLs
-DRIVER_DISPATCH otLwfDeviceIoControl;
-
-// Attempts to find and add a reference to the Thread interface
-_IRQL_requires_max_(PASSIVE_LEVEL)
-PMS_FILTER
-otLwfFindAndRefInterface(
- _In_ PGUID InterfaceGuid
- );
-
-//
-// Notification Type and Functions
-//
-
-// Indicates a new notification
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfIndicateNotification(
- _In_ PFILTER_NOTIFICATION_ENTRY NotifEntry
- );
-
-// Queries the next notification
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfQueryNextNotification(
- _In_ PIRP Irp
- );
-
-// Release a ref on the notification
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfReleaseNotification(
- _In_ PFILTER_NOTIFICATION_ENTRY NotifEntry
- );
-
-#endif // _DEVICE_H
diff --git a/examples/drivers/windows/otLwf/driver.c b/examples/drivers/windows/otLwf/driver.c
deleted file mode 100644
index f4210e139..000000000
--- a/examples/drivers/windows/otLwf/driver.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "precomp.h"
-#include "driver.tmh"
-
-//
-// Global variables
-//
-
-// Global Driver Object from DriverEntry
-PDRIVER_OBJECT FilterDriverObject = NULL;
-
-// NDIS Filter handle from NdisFRegisterFilterDriver
-NDIS_HANDLE FilterDriverHandle = NULL;
-
-// Global list of THREAD_FILTER instances
-NDIS_SPIN_LOCK FilterListLock;
-LIST_ENTRY FilterModuleList;
-
-// Cached performance frequency of the system
-LARGE_INTEGER FilterPerformanceFrequency;
-
-INITCODE
-_Use_decl_annotations_
-NTSTATUS
-DriverEntry(
- _In_ PDRIVER_OBJECT DriverObject,
- _In_ PUNICODE_STRING RegistryPath
- )
-/*++
-
-Routine Description:
-
- First entry point to be called, when this driver is loaded.
- Register with NDIS as a filter driver and create a device
- for communication with user-mode.
-
-Arguments:
-
- DriverObject - pointer to the system's driver object structure
- for this driver
-
- RegistryPath - system's registry path for this driver
-
-Return Value:
-
- STATUS_SUCCESS if all initialization is successful, STATUS_XXX
- error code if not.
-
---*/
-{
- NDIS_STATUS Status;
-
- // Initialize WPP logging
- WPP_INIT_TRACING(DriverObject, RegistryPath);
-
- // Save global DriverObject
- FilterDriverObject = DriverObject;
-
- // Set the driver unload handler
- DriverObject->DriverUnload = DriverUnload;
-
- // Cache performance counter frequency
- (VOID)KeQueryPerformanceCounter(&FilterPerformanceFrequency);
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Registry: %S", RegistryPath->Buffer);
-
- do
- {
- NDIS_FILTER_DRIVER_CHARACTERISTICS FChars =
- {
- {
- NDIS_OBJECT_TYPE_FILTER_DRIVER_CHARACTERISTICS,
-#if NDIS_SUPPORT_NDIS61
- NDIS_FILTER_CHARACTERISTICS_REVISION_2,
-#else
- NDIS_FILTER_CHARACTERISTICS_REVISION_1,
-#endif
- sizeof(NDIS_FILTER_DRIVER_CHARACTERISTICS)
- },
- NDIS_FILTER_MAJOR_VERSION,
- NDIS_FILTER_MINOR_VERSION,
- 1,
- 0,
- 0,
- RTL_CONSTANT_STRING(FILTER_FRIENDLY_NAME),
- RTL_CONSTANT_STRING(FILTER_UNIQUE_NAME),
- RTL_CONSTANT_STRING(FILTER_SERVICE_NAME),
-
- NULL,
- NULL,
- FilterAttach,
- FilterDetach,
- FilterRestart,
- FilterPause,
- FilterSendNetBufferLists,
- FilterSendNetBufferListsComplete,
- FilterCancelSendNetBufferLists,
- FilterReceiveNetBufferLists,
- FilterReturnNetBufferLists,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- FilterStatus,
-#if (NDIS_SUPPORT_NDIS61)
- NULL,
- NULL,
- NULL,
-#endif
- };
-
- //
- // Initialize global variables
- //
- NdisAllocateSpinLock(&FilterListLock);
- InitializeListHead(&FilterModuleList);
-
- //
- // Register the filter with NDIS
- //
- Status =
- NdisFRegisterFilterDriver(
- DriverObject,
- (NDIS_HANDLE)FilterDriverObject,
- &FChars,
- &FilterDriverHandle
- );
- if (Status != NDIS_STATUS_SUCCESS)
- {
- LogError(DRIVER_DEFAULT, "Register filter driver failed, %!NDIS_STATUS!", Status);
- break;
- }
-
- //
- // Register the device IOCTL interface
- //
- Status = otLwfRegisterDevice();
- if (Status != NDIS_STATUS_SUCCESS)
- {
- LogError(DRIVER_DEFAULT, "Register device for the filter driver failed, %!NDIS_STATUS!", Status);
- break;
- }
-
- } while (FALSE);
-
- LogFuncExitNDIS(DRIVER_DEFAULT, Status);
-
- if (Status != NDIS_STATUS_SUCCESS)
- {
- if (FilterDriverHandle)
- {
- NdisFDeregisterFilterDriver(FilterDriverHandle);
- FilterDriverHandle = NULL;
- }
- WPP_CLEANUP(DriverObject);
- }
-
- return Status;
-}
-
-PAGEDX
-_Use_decl_annotations_
-VOID
-DriverUnload(
- _In_ PDRIVER_OBJECT DriverObject
- )
-/*++
-
-Routine Description:
-
- Filter driver's unload routine.
- Deregister the driver from NDIS.
-
-Arguments:
-
- DriverObject - pointer to the system's driver object structure
- for this driver
-
-Return Value:
-
- NONE
-
---*/
-{
- PAGED_CODE();
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- //
- // Clean up the device IOCTL interface
- //
- otLwfDeregisterDevice();
-
- //
- // Deregister the NDIS filter
- //
- NdisFDeregisterFilterDriver(FilterDriverHandle);
- FilterDriverHandle = NULL;
-
- // Validate we have no outstanding filter instances
- NT_ASSERT(IsListEmpty(&FilterModuleList));
-
- //
- // Clean up global variables
- //
- NdisFreeSpinLock(&FilterListLock);
-
- LogFuncExit(DRIVER_DEFAULT);
-
- //
- // Clean up WPP logging
- //
- WPP_CLEANUP(DriverObject);
-}
diff --git a/examples/drivers/windows/otLwf/driver.h b/examples/drivers/windows/otLwf/driver.h
deleted file mode 100644
index ddc1cd09d..000000000
--- a/examples/drivers/windows/otLwf/driver.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines the top-level functions and variables for driver initialization
- * and clean up.
- */
-
-#ifndef _DRIVER_H
-#define _DRIVER_H
-
-// Legal values include:
-// 6.0 Available starting with Windows Vista RTM
-// 6.1 Available starting with Windows Vista SP1 / Windows Server 2008
-// 6.20 Available starting with Windows 7 / Windows Server 2008 R2
-// 6.30 Available starting with Windows 8 / Windows Server "8"
-#define FILTER_MAJOR_NDIS_VERSION 6
-
-#if defined(NDIS60)
-#define FILTER_MINOR_NDIS_VERSION 0
-#elif defined(NDIS620)
-#define FILTER_MINOR_NDIS_VERSION 20
-#elif defined(NDIS630)
-#define FILTER_MINOR_NDIS_VERSION 30
-#endif
-
-//
-// Global variables
-//
-
-// Global Driver Object from DriverEntry
-extern PDRIVER_OBJECT FilterDriverObject;
-
-// NDIS Filter handle from NdisFRegisterFilterDriver
-extern NDIS_HANDLE FilterDriverHandle;
-
-// IoControl Device Object from IoCreateDeviceSecure
-extern PDEVICE_OBJECT IoDeviceObject;
-
-// Global list of THREAD_FILTER instances
-extern NDIS_SPIN_LOCK FilterListLock;
-extern LIST_ENTRY FilterModuleList;
-
-// Cached performance frequency of the system
-extern LARGE_INTEGER FilterPerformanceFrequency;
-
-#define FILTER_FRIENDLY_NAME L"OpenThread NDIS LightWeight Filter"
-#define FILTER_UNIQUE_NAME L"{B3A3845A-164E-4727-B12E-32B8DCE1F6CD}" //unique name, quid name
-#define FILTER_SERVICE_NAME L"OTLWF"
-
-//
-// Function prototypes
-//
-INITCODE DRIVER_INITIALIZE DriverEntry;
-
-PAGEDX DRIVER_UNLOAD DriverUnload;
-
-#endif // _DRIVER_H
diff --git a/examples/drivers/windows/otLwf/eventprocessing.c b/examples/drivers/windows/otLwf/eventprocessing.c
deleted file mode 100644
index 9bbc743b2..000000000
--- a/examples/drivers/windows/otLwf/eventprocessing.c
+++ /dev/null
@@ -1,1114 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file implements the functions for creating new notifications for IOCTL clients.
- */
-
-#include "precomp.h"
-#include "eventprocessing.tmh"
-
-typedef struct _OTLWF_ADDR_EVENT
-{
- LIST_ENTRY Link;
- MIB_NOTIFICATION_TYPE NotificationType;
- IN6_ADDR Address;
-
-} OTLWF_ADDR_EVENT, *POTLWF_ADDR_EVENT;
-
-typedef struct _OTLWF_NBL_EVENT
-{
- LIST_ENTRY Link;
- PNET_BUFFER_LIST NetBufferLists;
-
-} OTLWF_NBL_EVENT, *POTLWF_NBL_EVENT;
-
-typedef struct _OTLWF_MAC_FRAME_EVENT
-{
- LIST_ENTRY Link;
- uint8_t BufferLength;
- uint8_t Buffer[0];
-
-} OTLWF_MAC_FRAME_EVENT, *POTLWF_MAC_FRAME_EVENT;
-
-
-KSTART_ROUTINE otLwfEventWorkerThread;
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfCompleteNBLs(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ PNET_BUFFER_LIST NetBufferLists,
- _In_ NTSTATUS Status
- );
-
-// Starts the event queue processing
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfEventProcessingStart(
- _In_ PMS_FILTER pFilter
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- HANDLE threadHandle = NULL;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Filter: %p, TimeIncrement = %u", pFilter, KeQueryTimeIncrement());
-
- pFilter->NextAlarmTickCount.QuadPart = 0;
-
- NT_ASSERT(pFilter->EventWorkerThread == NULL);
- if (pFilter->EventWorkerThread != NULL)
- {
- status = STATUS_ALREADY_REGISTERED;
- goto error;
- }
-
- // Make sure to reset the necessary events
- KeResetEvent(&pFilter->EventWorkerThreadStopEvent);
- KeResetEvent(&pFilter->SendNetBufferListComplete);
- KeResetEvent(&pFilter->EventWorkerThreadEnergyScanComplete);
-
- // Start the worker thread
- status = PsCreateSystemThread(
- &threadHandle, // ThreadHandle
- THREAD_ALL_ACCESS, // DesiredAccess
- NULL, // ObjectAttributes
- NULL, // ProcessHandle
- NULL, // ClientId
- otLwfEventWorkerThread, // StartRoutine
- pFilter // StartContext
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "PsCreateSystemThread failed, %!STATUS!", status);
- goto error;
- }
-
- // Grab the object reference to the worker thread
- status = ObReferenceObjectByHandle(
- threadHandle,
- THREAD_ALL_ACCESS,
- *PsThreadType,
- KernelMode,
- &pFilter->EventWorkerThread,
- NULL
- );
- if (!NT_VERIFYMSG("ObReferenceObjectByHandle can't fail with a valid kernel handle", NT_SUCCESS(status)))
- {
- LogError(DRIVER_DEFAULT, "ObReferenceObjectByHandle failed, %!STATUS!", status);
- KeSetEvent(&pFilter->EventWorkerThreadStopEvent, IO_NO_INCREMENT, FALSE);
- }
-
- ZwClose(threadHandle);
-
-error:
-
- if (!NT_SUCCESS(status))
- {
- ExSetTimerResolution(0, FALSE);
- }
-
- LogFuncExitNT(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-// Stops the event queue processing
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingStop(
- _In_ PMS_FILTER pFilter
- )
-{
- PLIST_ENTRY Link = NULL;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Filter: %p", pFilter);
-
- // By this point, we have disabled the Data Path, so no more
- // NBLs should be queued up.
-
- // Clean up worker thread
- if (pFilter->EventWorkerThread)
- {
- LogInfo(DRIVER_DEFAULT, "Stopping event processing worker thread and waiting for it to complete.");
-
- // Send event to shutdown worker thread
- KeSetEvent(&pFilter->EventWorkerThreadStopEvent, 0, FALSE);
-
- // Wait for worker thread to finish
- KeWaitForSingleObject(
- pFilter->EventWorkerThread,
- Executive,
- KernelMode,
- FALSE,
- NULL
- );
-
- // Free worker thread
- ObDereferenceObject(pFilter->EventWorkerThread);
- pFilter->EventWorkerThread = NULL;
-
- LogInfo(DRIVER_DEFAULT, "Event processing worker thread cleaned up.");
- }
-
- // Clean up any left over events
- if (pFilter->AddressChangesHead.Flink)
- {
- Link = pFilter->AddressChangesHead.Flink;
- while (Link != &pFilter->AddressChangesHead)
- {
- POTLWF_ADDR_EVENT Event = CONTAINING_RECORD(Link, OTLWF_ADDR_EVENT, Link);
- Link = Link->Flink;
-
- // Delete the event
- NdisFreeMemory(Event, 0, 0);
- }
- }
-
- // Clean up any left over events
- if (pFilter->NBLsHead.Flink)
- {
- Link = pFilter->NBLsHead.Flink;
- while (Link != &pFilter->NBLsHead)
- {
- POTLWF_NBL_EVENT Event = CONTAINING_RECORD(Link, OTLWF_NBL_EVENT, Link);
- Link = Link->Flink;
-
- otLwfCompleteNBLs(pFilter, FALSE, Event->NetBufferLists, STATUS_CANCELLED);
-
- // Delete the event
- NdisFreeMemory(Event, 0, 0);
- }
- }
-
- // Clean up any left over events
- if (pFilter->MacFramesHead.Flink)
- {
- Link = pFilter->MacFramesHead.Flink;
- while (Link != &pFilter->MacFramesHead)
- {
- POTLWF_MAC_FRAME_EVENT Event = CONTAINING_RECORD(Link, OTLWF_MAC_FRAME_EVENT, Link);
- Link = Link->Flink;
-
- // Delete the event
- NdisFreeMemory(Event, 0, 0);
- }
- }
-
- // Reinitialize the list head
- InitializeListHead(&pFilter->AddressChangesHead);
- InitializeListHead(&pFilter->NBLsHead);
- InitializeListHead(&pFilter->MacFramesHead);
-
- if (pFilter->EventIrpListHead.Flink)
- {
- FILTER_ACQUIRE_LOCK(&pFilter->EventsLock, FALSE);
-
- // Clean up any left over IRPs
- Link = pFilter->EventIrpListHead.Flink;
- while (Link != &pFilter->EventIrpListHead)
- {
- PIRP Irp = CONTAINING_RECORD(Link, IRP, Tail.Overlay.ListEntry);
- Link = Link->Flink;
-
- // Before we are allowed to complete the pending IRP, we must remove the cancel routine
- KIRQL irql;
- IoAcquireCancelSpinLock(&irql);
- IoSetCancelRoutine(Irp, NULL);
- IoReleaseCancelSpinLock(irql);
-
- Irp->IoStatus.Status = STATUS_CANCELLED;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- }
-
- // Reinitialize the list head
- InitializeListHead(&pFilter->EventIrpListHead);
-
- FILTER_RELEASE_LOCK(&pFilter->EventsLock, FALSE);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-// Updates the wait time for the alarm
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingIndicateNewWaitTime(
- _In_ PMS_FILTER pFilter,
- _In_ ULONG waitTime
- )
-{
- BOOLEAN FireUpdateEvent = TRUE;
-
- // Cancel previous timer
- if (ExCancelTimer(pFilter->EventHighPrecisionTimer, NULL))
- {
- pFilter->EventTimerState = OT_EVENT_TIMER_NOT_RUNNING;
- }
-
- if (waitTime == (ULONG)(-1))
- {
- // Ignore if we are already stopped
- if (pFilter->NextAlarmTickCount.QuadPart == 0) return;
- pFilter->NextAlarmTickCount.QuadPart = 0;
- }
- else
- {
- if (waitTime == 0)
- {
-#ifdef DEBUG_TIMING
- LogInfo(DRIVER_DEFAULT, "Event processing updating to fire timer immediately.");
-#endif
- pFilter->EventTimerState = OT_EVENT_TIMER_FIRED;
- pFilter->NextAlarmTickCount.QuadPart = 0;
- }
- else if (waitTime * 10000ll < (KeQueryTimeIncrement() - 30000))
- {
-#ifdef DEBUG_TIMING
- LogInfo(DRIVER_DEFAULT, "Event processing starting high precision timer for %u ms.", waitTime);
-#endif
- pFilter->EventTimerState = OT_EVENT_TIMER_RUNNING;
- pFilter->NextAlarmTickCount.QuadPart = 0;
- FireUpdateEvent = FALSE;
- ExSetTimer(pFilter->EventHighPrecisionTimer, waitTime * -10000ll, 0, NULL);
- }
- else
- {
-
- ULONG TickWaitTime = (waitTime * 10000ll) / KeQueryTimeIncrement();
- if (TickWaitTime == 0) TickWaitTime = 1;
-#ifdef DEBUG_TIMING
- LogInfo(DRIVER_DEFAULT, "Event processing updating wait ticks to %u.", TickWaitTime);
-#endif
-
- // Update the time to be 'waitTime' ms from 'now', saved in TickCounts
- KeQueryTickCount(&pFilter->NextAlarmTickCount);
- pFilter->NextAlarmTickCount.QuadPart += TickWaitTime;
- }
- }
-
- // Indicate event to worker thread to update the wait time
- KeSetEvent(&pFilter->EventWorkerThreadWaitTimeUpdated, 0, FALSE);
-}
-
-// Indicates another tasklet needs to be processed
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingIndicateNewTasklet(
- _In_ PMS_FILTER pFilter
- )
-{
- KeSetEvent(&pFilter->EventWorkerThreadProcessTasklets, 0, FALSE);
-}
-
-// Called to indicate that we have an Address change to process
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingIndicateAddressChange(
- _In_ PMS_FILTER pFilter,
- _In_ MIB_NOTIFICATION_TYPE NotificationType,
- _In_ PIN6_ADDR pAddr
- )
-{
- LogFuncEntryMsg(DRIVER_DEFAULT, "Filter: %p", pFilter);
-
- NT_ASSERT(pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE);
-
- POTLWF_ADDR_EVENT Event = FILTER_ALLOC_MEM(pFilter->FilterHandle, sizeof(OTLWF_ADDR_EVENT));
- if (Event == NULL)
- {
- LogWarning(DRIVER_DEFAULT, "Failed to alloc new OTLWF_ADDR_EVENT");
- }
- else
- {
- Event->NotificationType = NotificationType;
- Event->Address = *pAddr;
-
- // Add the event to the queue
- NdisAcquireSpinLock(&pFilter->EventsLock);
- InsertTailList(&pFilter->AddressChangesHead, &Event->Link);
- NdisReleaseSpinLock(&pFilter->EventsLock);
-
- // Set the event to indicate we have a new address to process
- KeSetEvent(&pFilter->EventWorkerThreadProcessAddressChanges, 0, FALSE);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-// Called to indicate that we have a NetBufferLists to process
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfEventProcessingIndicateNewNetBufferLists(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ PNET_BUFFER_LIST NetBufferLists
- )
-{
- POTLWF_NBL_EVENT Event = FILTER_ALLOC_MEM(pFilter->FilterHandle, sizeof(OTLWF_NBL_EVENT));
- if (Event == NULL)
- {
- LogWarning(DRIVER_DATA_PATH, "Failed to alloc new OTLWF_NBL_EVENT");
- otLwfCompleteNBLs(pFilter, DispatchLevel, NetBufferLists, STATUS_INSUFFICIENT_RESOURCES);
- return;
- }
-
- Event->NetBufferLists = NetBufferLists;
-
- // Add the event to the queue
- FILTER_ACQUIRE_LOCK(&pFilter->EventsLock, DispatchLevel);
- InsertTailList(&pFilter->NBLsHead, &Event->Link);
- FILTER_RELEASE_LOCK(&pFilter->EventsLock, DispatchLevel);
-
- // Set the event to indicate we have a new NBL to process
- KeSetEvent(&pFilter->EventWorkerThreadProcessNBLs, 0, FALSE);
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfEventProcessingIndicateNewMacFrameCommand(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_reads_bytes_(BufferLength)
- const uint8_t* Buffer,
- _In_ uint8_t BufferLength
- )
-{
- POTLWF_MAC_FRAME_EVENT Event = FILTER_ALLOC_MEM(pFilter->FilterHandle, FIELD_OFFSET(OTLWF_MAC_FRAME_EVENT, Buffer) + BufferLength);
- if (Event == NULL)
- {
- LogWarning(DRIVER_DATA_PATH, "Failed to alloc new OTLWF_MAC_FRAME_EVENT");
- return;
- }
-
- Event->BufferLength = BufferLength;
- memcpy(Event->Buffer, Buffer, BufferLength);
-
- // Add the event to the queue
- FILTER_ACQUIRE_LOCK(&pFilter->EventsLock, DispatchLevel);
- InsertTailList(&pFilter->MacFramesHead, &Event->Link);
- FILTER_RELEASE_LOCK(&pFilter->EventsLock, DispatchLevel);
-
- // Set the event to indicate we have a new Mac Frame to process
- KeSetEvent(&pFilter->EventWorkerThreadProcessMacFrames, 0, FALSE);
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfEventProcessingIndicateNetBufferListsCancelled(
- _In_ PMS_FILTER pFilter,
- _In_ PVOID CancelId
- )
-{
- PLIST_ENTRY Link = NULL;
- LIST_ENTRY CancelList = {0};
- InitializeListHead(&CancelList);
-
- // Build up a local list of all NBLs that need to be cancelled
- NdisAcquireSpinLock(&pFilter->EventsLock);
- Link = pFilter->NBLsHead.Flink;
- while (Link != &pFilter->NBLsHead)
- {
- POTLWF_NBL_EVENT Event = CONTAINING_RECORD(Link, OTLWF_NBL_EVENT, Link);
- Link = Link->Flink;
-
- if (NDIS_GET_NET_BUFFER_LIST_CANCEL_ID(Event->NetBufferLists) == CancelId)
- {
- RemoveEntryList(&Event->Link);
- InsertTailList(&CancelList, &Event->Link);
- }
- }
- NdisReleaseSpinLock(&pFilter->EventsLock);
-
- // Cancel all the NBLs
- Link = CancelList.Flink;
- while (Link != &CancelList)
- {
- POTLWF_NBL_EVENT Event = CONTAINING_RECORD(Link, OTLWF_NBL_EVENT, Link);
- Link = Link->Flink;
-
- otLwfCompleteNBLs(pFilter, FALSE, Event->NetBufferLists, STATUS_CANCELLED);
-
- // Delete the event
- NdisFreeMemory(Event, 0, 0);
- }
-}
-
-// Completes the NetBufferLists in the event
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfCompleteNBLs(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ PNET_BUFFER_LIST NetBufferLists,
- _In_ NTSTATUS Status
- )
-{
- LogVerbose(DRIVER_DATA_PATH, "otLwfCompleteNBLs, Filter:%p, NBL:%p, Status:%!STATUS!", pFilter, NetBufferLists, Status);
-
- // Set the status for all the NBLs
- PNET_BUFFER_LIST CurrNbl = NetBufferLists;
- while (CurrNbl)
- {
- NET_BUFFER_LIST_STATUS(CurrNbl) = Status;
- CurrNbl = NET_BUFFER_LIST_NEXT_NBL(CurrNbl);
- }
-
- NT_ASSERT(NetBufferLists);
-
- // Indicate the completion
- NdisFSendNetBufferListsComplete(
- pFilter->FilterHandle,
- NetBufferLists,
- DispatchLevel ? NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL : 0
- );
-}
-
-_Function_class_(DRIVER_CANCEL)
-_Requires_lock_held_(_Global_cancel_spin_lock_)
-_Releases_lock_(_Global_cancel_spin_lock_)
-_IRQL_requires_min_(DISPATCH_LEVEL)
-_IRQL_requires_(DISPATCH_LEVEL)
-VOID
-otLwfEventProcessingCancelIrp(
- _Inout_ struct _DEVICE_OBJECT *DeviceObject,
- _Inout_ _IRQL_uses_cancel_ struct _IRP *Irp
- )
-{
- PIRP IrpToCancel = NULL;
-
- UNREFERENCED_PARAMETER(DeviceObject);
-
- LogFuncEntryMsg(DRIVER_IOCTL, "Irp=%p", Irp);
-
- IoReleaseCancelSpinLock(Irp->CancelIrql);
-
- //
- // Search for a queued up Irp and cancel it if we find it
- //
-
- NdisAcquireSpinLock(&FilterListLock);
-
- // Iterate through each filter instance
- for (PLIST_ENTRY Link = FilterModuleList.Flink; Link != &FilterModuleList; Link = Link->Flink)
- {
- PMS_FILTER pFilter = CONTAINING_RECORD(Link, MS_FILTER, FilterModuleLink);
-
- FILTER_ACQUIRE_LOCK(&pFilter->EventsLock, TRUE);
-
- // Iterate through all queued IRPs for the filter
- PLIST_ENTRY IrpLink = pFilter->EventIrpListHead.Flink;
- while (IrpLink != &pFilter->EventIrpListHead)
- {
- PIRP QueuedIrp = CONTAINING_RECORD(IrpLink, IRP, Tail.Overlay.ListEntry);
- IrpLink = IrpLink->Flink;
-
- // If we find it, remove from the and prepare to complete it
- if (QueuedIrp == Irp)
- {
- RemoveEntryList(&QueuedIrp->Tail.Overlay.ListEntry);
- IrpToCancel = QueuedIrp;
- break;
- }
- }
-
- FILTER_RELEASE_LOCK(&pFilter->EventsLock, TRUE);
-
- if (IrpToCancel) break;
- }
-
- NdisReleaseSpinLock(&FilterListLock);
-
- if (IrpToCancel)
- {
- IrpToCancel->IoStatus.Status = STATUS_CANCELLED;
- IrpToCancel->IoStatus.Information = 0;
- IoCompleteRequest(IrpToCancel, IO_NO_INCREMENT);
- }
-
- LogFuncExit(DRIVER_IOCTL);
-}
-
-// Queues an Irp for processing
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingIndicateIrp(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP Irp
- )
-{
- LogFuncEntryMsg(DRIVER_IOCTL, "Irp=%p", Irp);
-
- // Mark the Irp as pending
- IoMarkIrpPending(Irp);
-
- FILTER_ACQUIRE_LOCK(&pFilter->EventsLock, FALSE);
-
- // Set the cancel routine for the Irp
- IoSetCancelRoutine(Irp, otLwfEventProcessingCancelIrp);
-
- // Queue the Irp up for processing
- InsertTailList(&pFilter->EventIrpListHead, &Irp->Tail.Overlay.ListEntry);
-
- FILTER_RELEASE_LOCK(&pFilter->EventsLock, FALSE);
-
- // Set the event to indicate we have an Irp to process
- KeSetEvent(&pFilter->EventWorkerThreadProcessIrp, 0, FALSE);
-
- LogFuncExit(DRIVER_IOCTL);
-}
-
-// Processes the next OpenThread IoCtl Irp
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingNextIrp(
- _In_ PMS_FILTER pFilter
- )
-{
- PIRP Irp = NULL;
-
- LogFuncEntry(DRIVER_IOCTL);
-
- do
- {
- // Reset pointer
- Irp = NULL;
-
- // Get the next Irp in the queue
- FILTER_ACQUIRE_LOCK(&pFilter->EventsLock, FALSE);
- if (!IsListEmpty(&pFilter->EventIrpListHead))
- {
- PLIST_ENTRY Link = RemoveHeadList(&pFilter->EventIrpListHead);
- Irp = CONTAINING_RECORD(Link, IRP, Tail.Overlay.ListEntry);
-
- // Clear the cancel routine since we are processing this now
- KIRQL irql;
- IoAcquireCancelSpinLock(&irql);
- IoSetCancelRoutine(Irp, NULL);
- IoReleaseCancelSpinLock(irql);
- }
- FILTER_RELEASE_LOCK(&pFilter->EventsLock, FALSE);
-
- if (Irp)
- {
- otLwfCompleteOpenThreadIrp(pFilter, Irp);
- }
-
- } while (Irp);
-
- LogFuncExit(DRIVER_IOCTL);
-}
-
-// Indicates a energy scan was completed
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfEventProcessingIndicateEnergyScanResult(
- _In_ PMS_FILTER pFilter,
- _In_ CHAR MaxRssi
- )
-{
- LogFuncEntry(DRIVER_IOCTL);
-
- // Cache the Rssi
- pFilter->otLastEnergyScanMaxRssi = MaxRssi;
-
- // Set the event to indicate we should indicate the state back to OpenThread
- KeSetEvent(&pFilter->EventWorkerThreadEnergyScanComplete, 0, FALSE);
-
- LogFuncExit(DRIVER_IOCTL);
-}
-
-// Helper function to copy data out of a NET_BUFFER
-__forceinline
-NTSTATUS
-CopyDataBuffer(
- _In_ PNET_BUFFER NetBuffer,
- _In_ ULONG Size,
- _Out_writes_bytes_all_(Size)
- PVOID Destination
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- // Read the data out of the NetBuffer
- PVOID mem = NdisGetDataBuffer(NetBuffer, Size, Destination, 1, 0);
- if (mem == NULL)
- {
- NT_ASSERT(FALSE);
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto error;
- }
-
- // If we get a different output memory address, then copy that data to Destination;
- // otherwise, it was already copied there
- if (mem != Destination)
- {
- RtlCopyMemory(Destination, mem, Size);
- }
-
-error:
-
- return status;
-}
-
-_Function_class_(EXT_CALLBACK)
-_IRQL_requires_(DISPATCH_LEVEL)
-_IRQL_requires_same_
-VOID
-otLwfEventProcessingTimer(
- _In_ PEX_TIMER Timer,
- _In_opt_ PVOID Context
- )
-{
- if (Context == NULL) return;
-
- PMS_FILTER pFilter = (PMS_FILTER)Context;
- UNREFERENCED_PARAMETER(Timer);
-
-#ifdef DEBUG_TIMING
- LogInfo(DRIVER_DEFAULT, "Event processing high precision timer fired.");
-#endif
-
- pFilter->EventTimerState = OT_EVENT_TIMER_FIRED;
-
- // Indicate event to worker thread to update the wait time
- KeSetEvent(&pFilter->EventWorkerThreadWaitTimeUpdated, 0, FALSE);
-}
-
-// Worker thread for processing all events
-_Use_decl_annotations_
-VOID
-otLwfEventWorkerThread(
- PVOID Context
- )
-{
- PMS_FILTER pFilter = (PMS_FILTER)Context;
- NT_ASSERT(pFilter);
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PKEVENT WaitEvents[] =
- {
- &pFilter->EventWorkerThreadStopEvent,
- &pFilter->EventWorkerThreadProcessNBLs,
- &pFilter->EventWorkerThreadProcessMacFrames,
- &pFilter->EventWorkerThreadWaitTimeUpdated,
- &pFilter->EventWorkerThreadProcessTasklets,
- &pFilter->SendNetBufferListComplete,
- &pFilter->EventWorkerThreadProcessIrp,
- &pFilter->EventWorkerThreadProcessAddressChanges,
- &pFilter->EventWorkerThreadEnergyScanComplete
- };
-
- KWAIT_BLOCK WaitBlocks[ARRAYSIZE(WaitEvents)] = { 0 };
-
- // Space to processing buffers
- const ULONG MessageBufferSize = 1280;
- PUCHAR MessageBuffer = FILTER_ALLOC_MEM(pFilter->FilterHandle, MessageBufferSize);
- if (MessageBuffer == NULL)
- {
- LogError(DRIVER_DATA_PATH, "Failed to allocate 1280 bytes for MessageBuffer!");
- return;
- }
-
-#if DEBUG_ALLOC
- // Initialize the list head for allocations
- InitializeListHead(&pFilter->otOutStandingAllocations);
-
- // Cache the Thread ID
- pFilter->otThreadId = PsGetCurrentThreadId();
-#endif
-
- // Initialize the radio layer
- otLwfRadioInit(pFilter);
-
- // Calculate the size of the otInstance and allocate it
- pFilter->otInstanceSize = 0;
- (VOID)otInstanceInit(NULL, &pFilter->otInstanceSize);
- NT_ASSERT(pFilter->otInstanceSize != 0);
-
- // Add space for a pointer back to the filter
- pFilter->otInstanceSize += sizeof(PMS_FILTER);
-
- // Allocate the buffer
- pFilter->otInstanceBuffer = (PUCHAR)FILTER_ALLOC_MEM(pFilter->FilterHandle, (ULONG)pFilter->otInstanceSize);
- if (pFilter == NULL)
- {
- LogWarning(DRIVER_DEFAULT, "Failed to allocate otInstance buffer, 0x%x bytes", (ULONG)pFilter->otInstanceSize);
- goto exit;
- }
- RtlZeroMemory(pFilter->otInstanceBuffer, pFilter->otInstanceSize);
-
- // Store the pointer and decrement the size
- memcpy(pFilter->otInstanceBuffer, &pFilter, sizeof(PMS_FILTER));
- pFilter->otInstanceSize -= sizeof(PMS_FILTER);
-
- // Initialize the OpenThread library
- pFilter->otCachedRole = OT_DEVICE_ROLE_DISABLED;
- pFilter->otCtx = otInstanceInit(pFilter->otInstanceBuffer + sizeof(PMS_FILTER), &pFilter->otInstanceSize);
- NT_ASSERT(pFilter->otCtx);
- if (pFilter->otCtx == NULL)
- {
- LogError(DRIVER_DEFAULT, "otInstanceInit failed, otInstanceSize = %u bytes", (ULONG)pFilter->otInstanceSize);
- goto exit;
- }
-
- // Make sure our helper function returns the right pointer for the filter, given the openthread instance
- NT_ASSERT(otCtxToFilter(pFilter->otCtx) == pFilter);
-
- // Disable Icmp (ping) handling
- otIcmp6SetEchoMode(pFilter->otCtx, OT_ICMP6_ECHO_HANDLER_DISABLED);
-
- // Register callbacks with OpenThread
- otSetStateChangedCallback(pFilter->otCtx, otLwfStateChangedCallback, pFilter);
- otIp6SetReceiveCallback(pFilter->otCtx, otLwfReceiveIp6DatagramCallback, pFilter);
-
- // Query the current addresses from TCPIP and cache them
- (void)otLwfInitializeAddresses(pFilter);
-
- // Initialze media connect state to disconnected
- otLwfIndicateLinkState(pFilter, MediaConnectStateDisconnected);
-
- for (;;)
- {
- NTSTATUS status = STATUS_SUCCESS;
-
- if (pFilter->NextAlarmTickCount.QuadPart == 0)
- {
-#ifdef DEBUG_TIMING
- LogVerbose(DRIVER_DEFAULT, "Event Processing waiting for next event.");
-#endif
-
- // Wait for event to stop or process event to fire
- status = KeWaitForMultipleObjects(ARRAYSIZE(WaitEvents), (PVOID*)WaitEvents, WaitAny, Executive, KernelMode, FALSE, NULL, WaitBlocks);
- }
- else
- {
- LARGE_INTEGER SystemTickCount;
- KeQueryTickCount(&SystemTickCount);
-
- if (pFilter->NextAlarmTickCount.QuadPart > SystemTickCount.QuadPart)
- {
- // Create the relative (negative) time to wait on
- LARGE_INTEGER Timeout;
- Timeout.QuadPart = (SystemTickCount.QuadPart - pFilter->NextAlarmTickCount.QuadPart) * KeQueryTimeIncrement();
-
-#ifdef DEBUG_TIMING
- LogVerbose(DRIVER_DEFAULT, "Event Processing waiting for next event, with timeout, %d ms.", (int)(Timeout.QuadPart / -10000));
-#endif
-
- // Wait for event to stop or process event to fire or timeout
- status = KeWaitForMultipleObjects(ARRAYSIZE(WaitEvents), (PVOID*)WaitEvents, WaitAny, Executive, KernelMode, FALSE, &Timeout, WaitBlocks);
- }
- else
- {
-#ifdef DEBUG_TIMING
- LogInfo(DRIVER_DEFAULT, "Event Processing running immediately.");
-#endif
-
- // No need to wait
- status = STATUS_TIMEOUT;
- }
- }
-
- // If it is the first event, then we are shutting down. Exit loop and terminate thread
- if (status == STATUS_WAIT_0)
- {
- LogInfo(DRIVER_DEFAULT, "Received event worker thread shutdown event.");
- break;
- }
-
-#ifdef DEBUG_TIMING
- LogVerbose(DRIVER_DEFAULT, "Event Processing status=0x%x", status);
-#endif
-
- //
- // Event fired to process events
- //
-
- if (status == STATUS_TIMEOUT ||
- (pFilter->EventTimerState == OT_EVENT_TIMER_FIRED && status == STATUS_WAIT_0 + 3))
- {
- // Reset the wait timeout
- pFilter->NextAlarmTickCount.QuadPart = 0;
- pFilter->EventTimerState = OT_EVENT_TIMER_NOT_RUNNING;
-
- // Indicate to OpenThread that the alarm has fired
- otPlatAlarmMilliFired(pFilter->otCtx);
- }
- else if (status == STATUS_WAIT_0 + 1) // EventWorkerThreadProcessNBLs fired
- {
- // Go through the queue until there are no more items
- for (;;)
- {
- POTLWF_NBL_EVENT Event = NULL;
- NdisAcquireSpinLock(&pFilter->EventsLock);
-
- // Just get the first item, if available
- if (!IsListEmpty(&pFilter->NBLsHead))
- {
- PLIST_ENTRY Link = RemoveHeadList(&pFilter->NBLsHead);
- Event = CONTAINING_RECORD(Link, OTLWF_NBL_EVENT, Link);
- }
-
- NdisReleaseSpinLock(&pFilter->EventsLock);
-
- // Break out of the loop if we have emptied the queue
- if (Event == NULL) break;
-
- NT_ASSERT(Event->NetBufferLists);
- NTSTATUS NblStatus = STATUS_INSUFFICIENT_RESOURCES;
-
- // Process the event
- PNET_BUFFER_LIST CurrNbl = Event->NetBufferLists;
- while (CurrNbl != NULL)
- {
- PNET_BUFFER CurrNb = NET_BUFFER_LIST_FIRST_NB(CurrNbl);
- while (CurrNb != NULL)
- {
- NT_ASSERT(NET_BUFFER_DATA_LENGTH(CurrNb) <= MessageBufferSize);
- if (NET_BUFFER_DATA_LENGTH(CurrNb) <= MessageBufferSize)
- {
- // Copy NB data into message
- if (NT_SUCCESS(CopyDataBuffer(CurrNb, NET_BUFFER_DATA_LENGTH(CurrNb), MessageBuffer)))
- {
- otError error = OT_ERROR_NONE;
-
- // Create a new message
- otMessage *message = otIp6NewMessage(pFilter->otCtx, NULL);
- if (message)
- {
- // Write to the message
- error = otMessageAppend(message, MessageBuffer, (uint16_t)NET_BUFFER_DATA_LENGTH(CurrNb));
- if (error != OT_ERROR_NONE)
- {
- LogError(DRIVER_DATA_PATH, "otAppendMessage failed with %!otError!", error);
- otMessageFree(message);
- }
- else
- {
- IPV6_HEADER* v6Header = (IPV6_HEADER*)MessageBuffer;
-
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, IP6_SEND: %p : %!IPV6ADDR! => %!IPV6ADDR! (%u bytes)",
- pFilter, CurrNbl, &v6Header->SourceAddress, &v6Header->DestinationAddress,
- NET_BUFFER_DATA_LENGTH(CurrNb));
-
-#ifdef LOG_BUFFERS
- otLogBuffer(MessageBuffer, NET_BUFFER_DATA_LENGTH(CurrNb));
-#endif
-
- // Send message (it will free 'message')
- error = otIp6Send(pFilter->otCtx, message);
- if (error != OT_ERROR_NONE)
- {
- LogError(DRIVER_DATA_PATH, "otSendIp6Datagram failed with %!otError!", error);
- }
- else
- {
- NblStatus = STATUS_SUCCESS;
- }
- }
- }
- else
- {
- LogError(DRIVER_DATA_PATH, "otNewIPv6Message failed!");
- }
- }
- }
-
- CurrNb = NET_BUFFER_NEXT_NB(CurrNb);
- }
-
- CurrNbl = NET_BUFFER_LIST_NEXT_NBL(CurrNbl);
- }
-
- if (Event->NetBufferLists)
- {
- // Complete the NBLs
- otLwfCompleteNBLs(pFilter, FALSE, Event->NetBufferLists, NblStatus);
- }
-
- // Free the event
- NdisFreeMemory(Event, 0, 0);
- }
- }
- else if (status == STATUS_WAIT_0 + 2) // EventWorkerThreadProcessMacFrames fired
- {
- // Go through the queue until there are no more items
- for (;;)
- {
- POTLWF_MAC_FRAME_EVENT Event = NULL;
- NdisAcquireSpinLock(&pFilter->EventsLock);
-
- // Just get the first item, if available
- if (!IsListEmpty(&pFilter->MacFramesHead))
- {
- PLIST_ENTRY Link = RemoveHeadList(&pFilter->MacFramesHead);
- Event = CONTAINING_RECORD(Link, OTLWF_MAC_FRAME_EVENT, Link);
- }
-
- NdisReleaseSpinLock(&pFilter->EventsLock);
-
- // Break out of the loop if we have emptied the queue
- if (Event == NULL) break;
-
- // Read the initial length value and validate
- uint16_t packetLength = 0;
- if (try_spinel_datatype_unpack(
- Event->Buffer,
- Event->BufferLength,
- SPINEL_DATATYPE_UINT16_S,
- &packetLength) &&
- packetLength <= sizeof(pFilter->otReceiveMessage) &&
- Event->BufferLength > sizeof(uint16_t) + packetLength)
- {
- pFilter->otReceiveFrame.mLength = (uint8_t)packetLength;
-
- uint8_t offset = 2;
- uint8_t length = Event->BufferLength - 2;
-
- if (packetLength != 0)
- {
- memcpy(&pFilter->otReceiveMessage, Event->Buffer + offset, packetLength);
- offset += pFilter->otReceiveFrame.mLength;
- length -= pFilter->otReceiveFrame.mLength;
- }
-
- otError errorCode;
- int8_t noiseFloor = -128;
- uint16_t flags = 0;
- if (try_spinel_datatype_unpack(
- Event->Buffer + offset,
- length,
- SPINEL_DATATYPE_INT8_S
- SPINEL_DATATYPE_INT8_S
- SPINEL_DATATYPE_UINT16_S
- SPINEL_DATATYPE_STRUCT_S( // PHY-data
- SPINEL_DATATYPE_UINT8_S // 802.15.4 channel
- SPINEL_DATATYPE_UINT8_S // 802.15.4 LQI
- )
- SPINEL_DATATYPE_STRUCT_S( // Vendor-data
- SPINEL_DATATYPE_UINT_PACKED_S
- ),
- &pFilter->otReceiveFrame.mInfo.mRxInfo.mRssi,
- &noiseFloor,
- &flags,
- &pFilter->otReceiveFrame.mChannel,
- &pFilter->otReceiveFrame.mInfo.mRxInfo.mLqi,
- &errorCode))
- {
- otLwfRadioReceiveFrame(pFilter, errorCode);
- }
- }
-
- // Free the event
- NdisFreeMemory(Event, 0, 0);
- }
- }
- else if (status == STATUS_WAIT_0 + 3) // EventWorkerThreadWaitTimeUpdated fired
- {
- // Nothing to do, the next time we wait, we will be using the updated time
- }
- else if (status == STATUS_WAIT_0 + 4) // EventWorkerThreadProcessTasklets fired
- {
- // Process all tasklets that were indicated to us from OpenThread
- otTaskletsProcess(pFilter->otCtx);
- }
- else if (status == STATUS_WAIT_0 + 5) // SendNetBufferListComplete fired
- {
- // Handle the completion of the NBL send
- otLwfRadioTransmitFrameDone(pFilter);
- }
- else if (status == STATUS_WAIT_0 + 6) // EventWorkerThreadProcessIrp fired
- {
- // Process any IRPs that were pended
- otLwfEventProcessingNextIrp(pFilter);
- }
- else if (status == STATUS_WAIT_0 + 7) // EventWorkerThreadProcessAddressChanges fired
- {
- // Go through the queue until there are no more items
- for (;;)
- {
- POTLWF_ADDR_EVENT Event = NULL;
- NdisAcquireSpinLock(&pFilter->EventsLock);
-
- // Get the next item, if available
- if (!IsListEmpty(&pFilter->AddressChangesHead))
- {
- PLIST_ENTRY Link = RemoveHeadList(&pFilter->AddressChangesHead);
- Event = CONTAINING_RECORD(Link, OTLWF_ADDR_EVENT, Link);
- }
-
- NdisReleaseSpinLock(&pFilter->EventsLock);
-
- // Break out of the loop if we have emptied the queue
- if (Event == NULL) break;
-
- // Process the address change on the Openthread thread
- otLwfEventProcessingAddressChanged(pFilter, Event->NotificationType, &Event->Address);
-
- // Free the event
- NdisFreeMemory(Event, 0, 0);
- }
- }
- else if (status == STATUS_WAIT_0 + 8) // EventWorkerThreadEnergyScanComplete fired
- {
- // Indicate energy scan complete
- otPlatRadioEnergyScanDone(pFilter->otCtx, pFilter->otLastEnergyScanMaxRssi);
- }
- else
- {
- LogWarning(DRIVER_DEFAULT, "Unexpected wait result, %!STATUS!", status);
- }
-
- // If we have a frame ready to transmit, do it now if we are allowed to transmit
- if (pFilter->otRadioState == OT_RADIO_STATE_TRANSMIT && !pFilter->SendPending)
- {
- otLwfRadioTransmitFrame(pFilter);
- }
- }
-
-exit:
-
- otLwfReleaseInstance(pFilter);
-
- if (pFilter->otInstanceBuffer != NULL)
- {
- NdisFreeMemory(pFilter->otInstanceBuffer, 0, 0);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-
- FILTER_FREE_MEM(MessageBuffer);
-
- PsTerminateSystemThread(STATUS_SUCCESS);
-}
diff --git a/examples/drivers/windows/otLwf/filter.c b/examples/drivers/windows/otLwf/filter.c
deleted file mode 100644
index 25d32fd17..000000000
--- a/examples/drivers/windows/otLwf/filter.c
+++ /dev/null
@@ -1,848 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "precomp.h"
-#include "filter.tmh"
-
-// Helper function to query the CompartmentID of a Network Interface
-COMPARTMENT_ID
-GetInterfaceCompartmentID(
- _In_ PIF_LUID pNetLuid
- )
-{
- COMPARTMENT_ID CompartmentID = UNSPECIFIED_COMPARTMENT_ID;
-
- NTSTATUS Status =
- NsiGetParameter(
- NsiActive,
- &NPI_MS_NDIS_MODULEID,
- NdisNsiObjectInterfaceInformation,
- pNetLuid, sizeof(*pNetLuid),
- NsiStructRoDynamic,
- &CompartmentID, sizeof(CompartmentID),
- FIELD_OFFSET(NDIS_NSI_INTERFACE_INFORMATION_ROD, CompartmentId)
- );
-
- return (NT_SUCCESS(Status) ? CompartmentID : DEFAULT_COMPARTMENT_ID);
-}
-
-_Use_decl_annotations_
-NDIS_STATUS
-FilterAttach(
- NDIS_HANDLE NdisFilterHandle,
- NDIS_HANDLE FilterDriverContext,
- PNDIS_FILTER_ATTACH_PARAMETERS AttachParameters
- )
-/*++
-
-Routine Description:
-
- Filter attach routine.
- Create filter's context, allocate NetBufferLists and NetBuffer pools and any
- other resources, and read configuration if needed.
-
-Arguments:
-
- NdisFilterHandle - Specify a handle identifying this instance of the filter. FilterAttach
- should save this handle. It is a required parameter in subsequent calls
- to NdisFxxx functions.
- FilterDriverContext - Filter driver context passed to NdisFRegisterFilterDriver.
-
- AttachParameters - attach parameters
-
-Return Value:
-
- NDIS_STATUS_SUCCESS: FilterAttach successfully allocated and initialize data structures
- for this filter instance.
- NDIS_STATUS_RESOURCES: FilterAttach failed due to insufficient resources.
- NDIS_STATUS_FAILURE: FilterAttach could not set up this instance of this filter and it has called
- NdisWriteErrorLogEntry with parameters specifying the reason for failure.
-
-N.B.: FILTER can use NdisRegisterDeviceEx to create a device, so the upper
- layer can send Irps to the filter.
-
---*/
-{
- PMS_FILTER pFilter = NULL;
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- NTSTATUS NtStatus;
- NDIS_FILTER_ATTRIBUTES FilterAttributes;
- ULONG Size;
- COMPARTMENT_ID OriginalCompartmentID;
- OBJECT_ATTRIBUTES ObjectAttributes = {0};
-
- const ULONG RegKeyOffset = ARRAYSIZE(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\otlwf\\Parameters\\NdisAdapters\\") - 1;
- DECLARE_CONST_UNICODE_STRING(RegKeyPath, L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\otlwf\\Parameters\\NdisAdapters\\{00000000-0000-0000-0000-000000000000}");
- RtlCopyMemory(RegKeyPath.Buffer + RegKeyOffset, AttachParameters->BaseMiniportName->Buffer + 8, sizeof(L"{00000000-0000-0000-0000-000000000000}"));
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- do
- {
- ASSERT(FilterDriverContext == (NDIS_HANDLE)FilterDriverObject);
- if (FilterDriverContext != (NDIS_HANDLE)FilterDriverObject)
- {
- Status = NDIS_STATUS_INVALID_PARAMETER;
- break;
- }
-
- // Verify the media type is supported. This is a last resort; the
- // the filter should never have been bound to an unsupported miniport
- // to begin with.
- if (AttachParameters->MiniportMediaType != NdisMediumIP)
- {
- LogError(DRIVER_DEFAULT, "Unsupported media type, 0x%x.", (ULONG)AttachParameters->MiniportMediaType);
- Status = NDIS_STATUS_INVALID_PARAMETER;
- break;
- }
-
- Size = sizeof(MS_FILTER) + AttachParameters->BaseMiniportInstanceName->Length;
-
- pFilter = (PMS_FILTER)FILTER_ALLOC_MEM(NdisFilterHandle, Size);
- if (pFilter == NULL)
- {
- LogWarning(DRIVER_DEFAULT, "Failed to allocate context structure, 0x%x bytes", Size);
- Status = NDIS_STATUS_RESOURCES;
- break;
- }
-
- NdisZeroMemory(pFilter, sizeof(MS_FILTER));
-
- LogVerbose(DRIVER_DEFAULT, "Opening interface registry key %S", RegKeyPath.Buffer);
-
- InitializeObjectAttributes(
- &ObjectAttributes,
- (PUNICODE_STRING)&RegKeyPath,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- NULL,
- NULL);
-
- // Open the registry key
- NtStatus = ZwOpenKey(&pFilter->InterfaceRegKey, KEY_ALL_ACCESS, &ObjectAttributes);
- if (!NT_SUCCESS(NtStatus))
- {
- LogError(DRIVER_DEFAULT, "ZwOpenKey failed to open %S, %!STATUS!", RegKeyPath.Buffer, NtStatus);
- Status = NDIS_STATUS_FAILURE;
- break;
- }
-
- // Format of "\DEVICE\{5BA90C49-0D7E-455B-8D3B-614F6714A212}"
- AttachParameters->BaseMiniportName->Buffer += 8;
- AttachParameters->BaseMiniportName->Length -= 8 * sizeof(WCHAR);
- NtStatus = RtlGUIDFromString(AttachParameters->BaseMiniportName, &pFilter->InterfaceGuid);
- AttachParameters->BaseMiniportName->Buffer -= 8;
- AttachParameters->BaseMiniportName->Length += 8 * sizeof(WCHAR);
- if (!NT_SUCCESS(NtStatus))
- {
- LogError(DRIVER_DEFAULT, "Failed to convert FilterModuleGuidName to a GUID, %!STATUS!", NtStatus);
- Status = NDIS_STATUS_FAILURE;
- break;
- }
-
- pFilter->InterfaceFriendlyName.Length = pFilter->InterfaceFriendlyName.MaximumLength = AttachParameters->BaseMiniportInstanceName->Length;
- pFilter->InterfaceFriendlyName.Buffer = (PWSTR)((PUCHAR)pFilter + sizeof(MS_FILTER));
- NdisMoveMemory(pFilter->InterfaceFriendlyName.Buffer,
- AttachParameters->BaseMiniportInstanceName->Buffer,
- pFilter->InterfaceFriendlyName.Length);
-
- pFilter->InterfaceIndex = AttachParameters->BaseMiniportIfIndex;
- pFilter->InterfaceLuid = AttachParameters->BaseMiniportNetLuid;
- pFilter->InterfaceCompartmentID = UNSPECIFIED_COMPARTMENT_ID;
- pFilter->FilterHandle = NdisFilterHandle;
-
- NdisZeroMemory(&FilterAttributes, sizeof(NDIS_FILTER_ATTRIBUTES));
- FilterAttributes.Header.Revision = NDIS_FILTER_ATTRIBUTES_REVISION_1;
- FilterAttributes.Header.Size = sizeof(NDIS_FILTER_ATTRIBUTES);
- FilterAttributes.Header.Type = NDIS_OBJECT_TYPE_FILTER_ATTRIBUTES;
- FilterAttributes.Flags = 0;
-
- NDIS_DECLARE_FILTER_MODULE_CONTEXT(MS_FILTER);
- Status = NdisFSetAttributes(NdisFilterHandle, pFilter, &FilterAttributes);
- if (Status != NDIS_STATUS_SUCCESS)
- {
- LogError(DRIVER_DEFAULT, "Failed to set attributes, %!NDIS_STATUS!", Status);
- break;
- }
-
- // Filter initially in Paused state
- pFilter->State = FilterPaused;
-
- // Initialize rundowns to disabled with no active references
- pFilter->ExternalRefs.Count = EX_RUNDOWN_ACTIVE;
- pFilter->cmdRundown.Count = EX_RUNDOWN_ACTIVE;
-
- // Query the compartment ID for this interface to use for the IP stack
- pFilter->InterfaceCompartmentID = GetInterfaceCompartmentID(&pFilter->InterfaceLuid);
- LogVerbose(DRIVER_DEFAULT, "Interface %!GUID! is in Compartment %u", &pFilter->InterfaceGuid, (ULONG)pFilter->InterfaceCompartmentID);
-
- // Make sure we are in the right compartment
- (VOID)otLwfSetCompartment(pFilter, &OriginalCompartmentID);
-
- // Register for address changed notifications
- NtStatus =
- NotifyUnicastIpAddressChange(
- AF_INET6,
- otLwfAddressChangeCallback,
- pFilter,
- FALSE,
- &pFilter->AddressChangeHandle
- );
-
- // Revert the compartment, now that we have the table
- otLwfRevertCompartment(OriginalCompartmentID);
-
- if (!NT_SUCCESS(NtStatus))
- {
- LogError(DRIVER_DEFAULT, "NotifyUnicastIpAddressChange failed, %!STATUS!", NtStatus);
- Status = NDIS_STATUS_FAILURE;
- break;
- }
-
- // Add Filter to global list of Thread Filters
- NdisAcquireSpinLock(&FilterListLock);
- InsertTailList(&FilterModuleList, &pFilter->FilterModuleLink);
- NdisReleaseSpinLock(&FilterListLock);
-
- LogVerbose(DRIVER_DEFAULT, "Created Filter: %p", pFilter);
-
- } while (FALSE);
-
- // Clean up on failure
- if (Status != NDIS_STATUS_SUCCESS)
- {
- if (pFilter != NULL)
- {
- if (pFilter->AddressChangeHandle != NULL)
- {
- CancelMibChangeNotify2(pFilter->AddressChangeHandle);
- pFilter->AddressChangeHandle = NULL;
- }
-
- NdisFreeMemory(pFilter, 0, 0);
- }
- }
-
- LogFuncExitNDIS(DRIVER_DEFAULT, Status);
-
- return Status;
-}
-
-_Use_decl_annotations_
-VOID
-FilterDetach(
- NDIS_HANDLE FilterModuleContext
- )
-/*++
-
-Routine Description:
-
- Filter detach routine.
- This is a required function that will deallocate all the resources allocated during
- FilterAttach. NDIS calls FilterAttach to remove a filter instance from a filter stack.
-
-Arguments:
-
- FilterModuleContext - pointer to the filter context area.
-
-Return Value:
- None.
-
-NOTE: Called at PASSIVE_LEVEL and the filter is in paused state
-
---*/
-{
- PMS_FILTER pFilter = (PMS_FILTER)FilterModuleContext;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Filter: %p", FilterModuleContext);
-
- // Filter must be in paused state and pretty much inactive
- NT_ASSERT(pFilter->State == FilterPaused);
- NT_ASSERT(pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_UNINTIALIZED);
-
- //
- // Detach must not fail, so do not put any code here that can possibly fail.
- //
-
- // Remove this Filter from the global list
- NdisAcquireSpinLock(&FilterListLock);
- RemoveEntryList(&pFilter->FilterModuleLink);
- NdisReleaseSpinLock(&FilterListLock);
-
- // Unregister from address change notifications
- CancelMibChangeNotify2(pFilter->AddressChangeHandle);
- pFilter->AddressChangeHandle = NULL;
-
- // Close the registry key
- if (pFilter->InterfaceRegKey)
- {
- ZwClose(pFilter->InterfaceRegKey);
- pFilter->InterfaceRegKey = NULL;
- }
-
- // Free the memory allocated
- NdisFreeMemory(pFilter, 0, 0);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-// Indicates an interface state change has taken place (used for interface arrival/removal)
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfNotifyDeviceAvailabilityChange(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN fAvailable
- )
-{
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_DEVICE_AVAILABILITY;
- NotifEntry->Notif.DeviceAvailabilityPayload.Available = fAvailable;
-
- otLwfIndicateNotification(NotifEntry);
- }
-}
-
-PAGED
-NTSTATUS
-GetRegDWORDValue(
- _In_ PMS_FILTER pFilter,
- _In_ PCWSTR ValueName,
- _Out_ PULONG ValueData
-)
-{
- NTSTATUS status;
- ULONG resultLength;
- UCHAR keybuf[128] = {0};
- UNICODE_STRING UValueName;
-
- PAGED_CODE();
-
- RtlInitUnicodeString(&UValueName, ValueName);
-
- status = ZwQueryValueKey(
- pFilter->InterfaceRegKey,
- &UValueName,
- KeyValueFullInformation,
- keybuf,
- sizeof(keybuf),
- &resultLength);
-
- if (NT_SUCCESS(status))
- {
- PKEY_VALUE_FULL_INFORMATION keyInfo = (PKEY_VALUE_FULL_INFORMATION)keybuf;
-
- if (keyInfo->Type != REG_DWORD)
- {
- status = STATUS_INVALID_PARAMETER_MIX;
- }
- else
- {
- *ValueData = *((ULONG UNALIGNED *)(keybuf + keyInfo->DataOffset));
- }
- }
-
- return status;
-}
-
-PAGED
-NTSTATUS
-SetRegDWORDValue(
- _In_ PMS_FILTER pFilter,
- _In_ PCWSTR ValueName,
- _In_ ULONG ValueData
-)
-{
- NTSTATUS status;
- UNICODE_STRING UValueName;
-
- PAGED_CODE();
-
- RtlInitUnicodeString(&UValueName, ValueName);
-
- status = ZwSetValueKey(
- pFilter->InterfaceRegKey,
- &UValueName,
- 0,
- REG_DWORD,
- (PVOID)&ValueData,
- sizeof(ValueData));
-
- return status;
-}
-
-_Use_decl_annotations_
-NDIS_STATUS
-FilterRestart(
- NDIS_HANDLE FilterModuleContext,
- PNDIS_FILTER_RESTART_PARAMETERS RestartParameters
- )
-/*++
-
-Routine Description:
-
- Filter restart routine.
- Start the datapath - begin sending and receiving NBLs.
-
-Arguments:
-
- FilterModuleContext - pointer to the filter context stucture.
- RestartParameters - additional information about the restart operation.
-
-Return Value:
-
- NDIS_STATUS_SUCCESS: if filter restarts successfully
- NDIS_STATUS_XXX: Otherwise.
-
---*/
-{
- NTSTATUS NtStatus = STATUS_SUCCESS;
- NDIS_STATUS NdisStatus = NDIS_STATUS_SUCCESS;
- PMS_FILTER pFilter = (PMS_FILTER)FilterModuleContext;
- PVOID SpinelCapsDataBuffer = NULL;
- const uint8_t* SpinelCapsPtr = NULL;
- spinel_size_t SpinelCapsLen = 0;
- NL_INTERFACE_KEY key = {0};
- NL_INTERFACE_RW interfaceRw;
- ULONG ThreadOnHost = TRUE;
-
- PNDIS_RESTART_GENERAL_ATTRIBUTES NdisGeneralAttributes;
- PNDIS_RESTART_ATTRIBUTES NdisRestartAttributes;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Filter: %p", FilterModuleContext);
-
- NT_ASSERT(pFilter->State == FilterPaused);
-
- NdisRestartAttributes = RestartParameters->RestartAttributes;
-
- //
- // If NdisRestartAttributes is not NULL, then the filter can modify generic
- // attributes and add new media specific info attributes at the end.
- // Otherwise, if NdisRestartAttributes is NULL, the filter should not try to
- // modify/add attributes.
- //
- if (NdisRestartAttributes != NULL)
- {
- ASSERT(NdisRestartAttributes->Oid == OID_GEN_MINIPORT_RESTART_ATTRIBUTES);
-
- NdisGeneralAttributes = (PNDIS_RESTART_GENERAL_ATTRIBUTES)NdisRestartAttributes->Data;
-
- //
- // Check to see if we need to change any attributes. For example, the
- // driver can change the current MAC address here. Or the driver can add
- // media specific info attributes.
- //
- NdisGeneralAttributes->LookaheadSize = 128;
- }
-
- // Initialize the Spinel command processing
- NdisStatus = otLwfCmdInitialize(pFilter);
- if (NdisStatus != NDIS_STATUS_SUCCESS)
- {
- LogError(DRIVER_DEFAULT, "otLwfCmdInitialize failed, %!NDIS_STATUS!", NdisStatus);
- goto exit;
- }
-
- // Query the device capabilities
- NtStatus = otLwfCmdGetProp(pFilter, &SpinelCapsDataBuffer, SPINEL_PROP_CAPS, SPINEL_DATATYPE_DATA_S, &SpinelCapsPtr, &SpinelCapsLen);
- if (!NT_SUCCESS(NtStatus))
- {
- NdisStatus = NDIS_STATUS_NOT_SUPPORTED;
- LogError(DRIVER_DEFAULT, "Failed to query SPINEL_PROP_CAPS, %!STATUS!", NtStatus);
- goto exit;
- }
-
- // Iterate and process returned capabilities
- NT_ASSERT(SpinelCapsDataBuffer);
- while (SpinelCapsLen > 0)
- {
- ULONG SpinelCap = 0;
- spinel_ssize_t len = spinel_datatype_unpack(SpinelCapsPtr, SpinelCapsLen, SPINEL_DATATYPE_UINT_PACKED_S, &SpinelCap);
- if (len < 1) break;
- SpinelCapsLen -= (spinel_size_t)len;
- SpinelCapsPtr += len;
-
- switch (SpinelCap)
- {
- case SPINEL_CAP_MAC_RAW:
- pFilter->DeviceCapabilities |= OTLWF_DEVICE_CAP_RADIO;
- pFilter->DeviceCapabilities |= OTLWF_DEVICE_CAP_RADIO_ACK_TIMEOUT;
- pFilter->DeviceCapabilities |= OTLWF_DEVICE_CAP_RADIO_MAC_RETRY_AND_COLLISION_AVOIDANCE;
- pFilter->DeviceCapabilities |= OTLWF_DEVICE_CAP_RADIO_ENERGY_SCAN;
- break;
- case SPINEL_CAP_NET_THREAD_1_0:
- pFilter->DeviceCapabilities |= OTLWF_DEVICE_CAP_THREAD_1_0;
- break;
- default:
- break;
- }
- }
-
- // Set the state indicating where we should be running the Thread logic (Host or Device).
- if (!NT_SUCCESS(GetRegDWORDValue(pFilter, L"RunOnHost", &ThreadOnHost)))
- {
- // Default to running on the host if the key isn't present
- ThreadOnHost = TRUE;
- SetRegDWORDValue(pFilter, L"RunOnHost", ThreadOnHost);
- }
-
- LogInfo(DRIVER_DEFAULT, "Filter: %p initializing ThreadOnHost=%d", FilterModuleContext, ThreadOnHost);
-
- // Initialize the processing logic
- if (ThreadOnHost)
- {
- // Ensure the device has the capabilities to support raw radio commands
- if ((pFilter->DeviceCapabilities & OTLWF_DEVICE_CAP_RADIO) == 0)
- {
- LogError(DRIVER_DEFAULT, "Failed to start because device doesn't support raw radio commands");
- NdisStatus = NDIS_STATUS_NOT_SUPPORTED;
- goto exit;
- }
-
- pFilter->DeviceStatus = OTLWF_DEVICE_STATUS_RADIO_MODE;
- NtStatus = otLwfInitializeThreadMode(pFilter);
- if (!NT_SUCCESS(NtStatus))
- {
- LogError(DRIVER_DEFAULT, "otLwfInitializeThreadMode failed, %!STATUS!", NtStatus);
- NdisStatus = NDIS_STATUS_FAILURE;
- pFilter->DeviceStatus = OTLWF_DEVICE_STATUS_UNINTIALIZED;
- goto exit;
- }
- }
- else
- {
- // Ensure the device has the capabilities to support Thread commands
- if ((pFilter->DeviceCapabilities & OTLWF_DEVICE_CAP_THREAD_1_0) == 0)
- {
- LogError(DRIVER_DEFAULT, "Failed to start because device doesn't support thread commands");
- NdisStatus = NDIS_STATUS_NOT_SUPPORTED;
- goto exit;
- }
-
- pFilter->DeviceStatus = OTLWF_DEVICE_STATUS_THREAD_MODE;
- NtStatus = otLwfTunInitialize(pFilter);
- if (!NT_SUCCESS(NtStatus))
- {
- LogError(DRIVER_DEFAULT, "otLwfInitializeTunnelMode failed, %!STATUS!", NtStatus);
- NdisStatus = NDIS_STATUS_FAILURE;
- pFilter->DeviceStatus = OTLWF_DEVICE_STATUS_UNINTIALIZED;
- goto exit;
- }
- }
-
- //
- // Disable DAD and Neighbor advertisements
- //
- key.Luid = pFilter->InterfaceLuid;
- NlInitializeInterfaceRw(&interfaceRw);
- interfaceRw.DadTransmits = 0;
- interfaceRw.SendUnsolicitedNeighborAdvertisementOnDad = FALSE;
-
- NtStatus =
- NsiSetAllParameters(
- NsiActive,
- NsiSetDefault,
- &NPI_MS_IPV6_MODULEID,
- NlInterfaceObject,
- &key,
- sizeof(key),
- &interfaceRw,
- sizeof(interfaceRw));
- if (!NT_SUCCESS(NtStatus))
- {
- LogError(DRIVER_DEFAULT, "NsiSetAllParameters (NlInterfaceObject) failed, %!STATUS!", NtStatus);
- NdisStatus = NDIS_STATUS_FAILURE;
- goto exit;
- }
-
- //
- // Enable the external references to the filter
- //
- ExReInitializeRundownProtection(&pFilter->ExternalRefs);
-
- //
- // If everything is OK, set the filter in running state.
- //
- pFilter->State = FilterRunning; // when successful
- otLwfNotifyDeviceAvailabilityChange(pFilter, TRUE);
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! arrival, Filter=%p", &pFilter->InterfaceGuid, pFilter);
-
-exit:
-
- //
- // Ensure the state is Paused if restart failed.
- //
- if (NdisStatus != NDIS_STATUS_SUCCESS)
- {
- pFilter->State = FilterPaused;
-
- if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE)
- {
- otLwfUninitializeThreadMode(pFilter);
- }
- else if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_THREAD_MODE)
- {
- otLwfTunUninitialize(pFilter);
- }
-
- pFilter->DeviceStatus = OTLWF_DEVICE_STATUS_UNINTIALIZED;
-
- // Clean up Spinel command processing
- otLwfCmdUninitialize(pFilter);
- }
-
- // Free the buffer for the capabilities we queried
- if (SpinelCapsDataBuffer != NULL)
- {
- FILTER_FREE_MEM(SpinelCapsDataBuffer);
- }
-
- LogFuncExitNDIS(DRIVER_DEFAULT, NdisStatus);
- return NdisStatus;
-}
-
-_Use_decl_annotations_
-NDIS_STATUS
-FilterPause(
- NDIS_HANDLE FilterModuleContext,
- PNDIS_FILTER_PAUSE_PARAMETERS PauseParameters
- )
-/*++
-
-Routine Description:
-
- Filter pause routine.
- Complete all the outstanding sends and queued sends,
- wait for all the outstanding recvs to be returned
- and return all the queued receives.
-
-Arguments:
-
- FilterModuleContext - pointer to the filter context stucture
- PauseParameters - additional information about the pause
-
-Return Value:
-
- NDIS_STATUS_SUCCESS if filter pauses successfully, NDIS_STATUS_PENDING
- if not. No other return value is allowed (pause must succeed, eventually).
-
-N.B.: When the filter is in Pausing state, it can still process OID requests,
- complete sending, and returning packets to NDIS, and also indicate status.
- After this function completes, the filter must not attempt to send or
- receive packets, but it may still process OID requests and status
- indications.
-
---*/
-{
- PMS_FILTER pFilter = (PMS_FILTER)(FilterModuleContext);
- NDIS_STATUS Status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(PauseParameters);
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Filter: %p", FilterModuleContext);
-
- //
- // Set the flag that the filter is going to pause
- //
- NT_ASSERT(pFilter->State == FilterRunning);
- NdisAcquireSpinLock(&FilterListLock);
- pFilter->State = FilterPausing;
- NdisReleaseSpinLock(&FilterListLock);
-
- //
- // Send final notification of interface removal
- //
- otLwfNotifyDeviceAvailabilityChange(pFilter, FALSE);
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! removal.", &pFilter->InterfaceGuid);
-
- //
- // Disable external references and wait for existing calls to complete
- //
- LogInfo(DRIVER_DEFAULT, "Disabling and waiting for external references to release");
- ExWaitForRundownProtectionRelease(&pFilter->ExternalRefs);
- LogInfo(DRIVER_DEFAULT, "External references released.");
-
- //
- // Clean up based on the device mode
- //
- if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE)
- {
- otLwfUninitializeThreadMode(pFilter);
- }
- else if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_THREAD_MODE)
- {
- otLwfTunUninitialize(pFilter);
- }
-
- pFilter->DeviceStatus = OTLWF_DEVICE_STATUS_UNINTIALIZED;
-
- //
- // Clean up the Spinel command processing
- //
- otLwfCmdUninitialize(pFilter);
-
- //
- // Set the state back to Paused now that we are done
- //
- pFilter->State = FilterPaused;
-
- LogFuncExitNDIS(DRIVER_DEFAULT, Status);
- return Status;
-}
-
-_Use_decl_annotations_
-VOID
-FilterStatus(
- NDIS_HANDLE FilterModuleContext,
- PNDIS_STATUS_INDICATION StatusIndication
- )
-/*++
-
-Routine Description:
-
- Status indication handler
-
-Arguments:
-
- FilterModuleContext - our filter context
- StatusIndication - the status being indicated
-
-NOTE: called at <= DISPATCH_LEVEL
-
- FILTER driver may call NdisFIndicateStatus to generate a status indication to
- all higher layer modules.
-
---*/
-{
- PMS_FILTER pFilter = (PMS_FILTER)FilterModuleContext;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "Filter: %p, IndicateStatus: %8x", FilterModuleContext, StatusIndication->StatusCode);
-
- if (StatusIndication->StatusCode == NDIS_STATUS_LINK_STATE)
- {
- PNDIS_LINK_STATE LinkState = (PNDIS_LINK_STATE)StatusIndication->StatusBuffer;
-
- LogInfo(DRIVER_DEFAULT, "Filter: %p, MediaConnectState: %u", FilterModuleContext, LinkState->MediaConnectState);
-
- // Cache the link state from the miniport
- memcpy(&pFilter->MiniportLinkState, LinkState, sizeof(NDIS_LINK_STATE));
- }
-
- NdisFIndicateStatus(pFilter->FilterHandle, StatusIndication);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-// Indicate a change of the link state
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfIndicateLinkState(
- _In_ PMS_FILTER pFilter,
- _In_ NDIS_MEDIA_CONNECT_STATE MediaState
- )
-{
- // If we are already in the correct state, just return
- if (pFilter->MiniportLinkState.MediaConnectState == MediaState)
- {
- return;
- }
-
- NDIS_STATUS_INDICATION StatusIndication = {0};
-
- StatusIndication.Header.Type = NDIS_OBJECT_TYPE_STATUS_INDICATION;
- StatusIndication.Header.Revision = NDIS_STATUS_INDICATION_REVISION_1;
- StatusIndication.Header.Size = sizeof(NDIS_STATUS_INDICATION);
- StatusIndication.SourceHandle = pFilter->FilterHandle;
-
- StatusIndication.StatusCode = NDIS_STATUS_LINK_STATE;
- StatusIndication.StatusBuffer = &pFilter->MiniportLinkState;
- StatusIndication.StatusBufferSize = sizeof(pFilter->MiniportLinkState);
-
- pFilter->MiniportLinkState.MediaConnectState = MediaState;
-
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! new media state: %u", &pFilter->InterfaceGuid, MediaState);
-
- NdisFIndicateStatus(pFilter->FilterHandle, &StatusIndication);
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfSetCompartment(
- _In_ PMS_FILTER pFilter,
- _Out_ COMPARTMENT_ID* pOriginalCompartment
- )
-/*++
-
-Routine Description:
-
- Sets the current thread's compartment ID to match the filter instance.
-
---*/
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- // Make sure we are in the right compartment
- *pOriginalCompartment = NdisGetCurrentThreadCompartmentId();
- if (*pOriginalCompartment != pFilter->InterfaceCompartmentID)
- {
- status = NdisSetCurrentThreadCompartmentId(pFilter->InterfaceCompartmentID);
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "NdisSetCurrentThreadCompartmentId failed, %!STATUS!", status);
- *pOriginalCompartment = 0;
- }
- }
- else
- {
- *pOriginalCompartment = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfRevertCompartment(
- _In_ COMPARTMENT_ID OriginalCompartment
- )
-/*++
-
-Routine Description:
-
- Resets the current thread's compartment ID.
-
---*/
-{
- // Revert the compartment if it is set
- if (OriginalCompartment != 0)
- {
- (VOID)NdisSetCurrentThreadCompartmentId(OriginalCompartment);
- }
-}
diff --git a/examples/drivers/windows/otLwf/filter.h b/examples/drivers/windows/otLwf/filter.h
deleted file mode 100644
index 49d9b27d5..000000000
--- a/examples/drivers/windows/otLwf/filter.h
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines the structures and functions for the otLwf Filter instance.
- */
-
-#ifndef _FILT_H
-#define _FILT_H
-
-// The maximum allowed addresses an OpenThread interface
-#if (OPENTHREAD_ENABLE_DHCP6_CLIENT && OPENTHREAD_ENABLE_DHCP6_SERVER)
-#define OT_MAX_ADDRESSES (4 + OPENTHREAD_CONFIG_NUM_SLAAC_ADDRESSES + 2 * OPENTHREAD_CONFIG_NUM_DHCP_PREFIXES)
-#elif (OPENTHREAD_ENABLE_DHCP6_CLIENT || OPENTHREAD_ENABLE_DHCP6_SERVER)
-#define OT_MAX_ADDRESSES (4 + OPENTHREAD_CONFIG_NUM_SLAAC_ADDRESSES + OPENTHREAD_CONFIG_NUM_DHCP_PREFIXES)
-#else
-#define OT_MAX_ADDRESSES (4 + OPENTHREAD_CONFIG_NUM_SLAAC_ADDRESSES)
-#endif
-
-#define OTLWF_ALLOC_TAG 'mFto' // otFm
-
-#define FILTER_ALLOC_MEM(_NdisHandle, _Size) \
- NdisAllocateMemoryWithTagPriority(_NdisHandle, _Size, OTLWF_ALLOC_TAG, LowPoolPriority)
-#define FILTER_FREE_MEM(_pMem) NdisFreeMemory(_pMem, 0, 0)
-#define FILTER_INIT_LOCK(_pLock) NdisAllocateSpinLock(_pLock)
-#define FILTER_FREE_LOCK(_pLock) NdisFreeSpinLock(_pLock)
-
-// Helper for locking an NDIS lock
-#define FILTER_ACQUIRE_LOCK(_pLock, DispatchLevel) \
-{ \
- if (DispatchLevel) { NdisDprAcquireSpinLock(_pLock); } \
- else { NdisAcquireSpinLock(_pLock); } \
-}
-
-// Helper for releasing an NDIS lock
-#define FILTER_RELEASE_LOCK(_pLock, DispatchLevel) \
-{ \
- if (DispatchLevel) { NdisDprReleaseSpinLock(_pLock); } \
- else { NdisReleaseSpinLock(_pLock); } \
-}
-
-//
-// Enum of filter's states
-// Filter can only be in one state at one time
-//
-typedef enum _FILTER_STATE
-{
- FilterStateUnspecified,
- FilterPausing,
- FilterPaused,
- FilterRunning,
-} FILTER_STATE;
-
-// Flags for the different device capabilities
-typedef enum OTLWF_DEVICE_CAPABILITY
-{
- // Device supports raw Radio commands
- OTLWF_DEVICE_CAP_RADIO = 1 << 0,
-
- // Device supports Ack timeouts internally
- OTLWF_DEVICE_CAP_RADIO_ACK_TIMEOUT = 1 << 1,
-
- // Device supports MAC retry logic and timers; as well as collision avoidance.
- OTLWF_DEVICE_CAP_RADIO_MAC_RETRY_AND_COLLISION_AVOIDANCE = 1 << 2,
-
- // Device supports the energy scan command.
- OTLWF_DEVICE_CAP_RADIO_ENERGY_SCAN = 1 << 3,
-
- // Device support Net & Thread commands.
- OTLWF_DEVICE_CAP_THREAD_1_0 = 1 << 16,
-
-} OTLWF_DEVICE_CAPABILITY;
-
-// Flags for the different device capabilities
-typedef enum OTLWF_DEVICE_STATUS
-{
- OTLWF_DEVICE_STATUS_UNINTIALIZED, // Not yet initialzied.
- OTLWF_DEVICE_STATUS_RADIO_MODE, // The device is just operating as a simple radio.
- OTLWF_DEVICE_STATUS_THREAD_MODE // The device is managing the Thread stack.
-
-} OTLWF_DEVICE_STATUS;
-
-#define OT_EVENT_TIMER_NOT_RUNNING 0
-#define OT_EVENT_TIMER_RUNNING 1
-#define OT_EVENT_TIMER_FIRED 2
-
-#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
-
-typedef struct BufferPool
-{
- struct BufferPool* Next;
- uint8_t Buffers[0];
-
-} BufferPool;
-
-enum
-{
- kPageSize = PAGE_SIZE,
- kPagesPerBufferPool = 1,
- kMaxPagesForBufferPools = 64,
- kMaxBytesForBufferPools = kPageSize * kMaxPagesForBufferPools,
-
- kEstimatedBufferSize = 128, // sizeof(ot::Buffer)
- kEstimatedBufferPoolSize = ((kPageSize * kPagesPerBufferPool) - sizeof(BufferPool)) / kEstimatedBufferSize,
- kEstimatedMaxBuffers = kMaxPagesForBufferPools * kEstimatedBufferPoolSize
-};
-
-#endif
-
-//
-// Define the filter struct
-//
-typedef struct _MS_FILTER
-{
- // Entry in the global list of Filter instances
- LIST_ENTRY FilterModuleLink;
-
- // NDIS Handle for the Filter instance
- NDIS_HANDLE FilterHandle;
-
- // Current state (Running or not) of the Filter instance
- FILTER_STATE State;
-
- // Handle for unicast IP address notifications
- HANDLE AddressChangeHandle;
-
- //
- // Interface variables
- //
- GUID InterfaceGuid;
- NET_IFINDEX InterfaceIndex;
- NET_LUID InterfaceLuid;
- COMPARTMENT_ID InterfaceCompartmentID;
- NDIS_STRING InterfaceFriendlyName;
- HANDLE InterfaceRegKey;
-
- //
- // Miniport Link State
- //
- NDIS_LINK_STATE MiniportLinkState;
-
- //
- // External references management
- // Used for IOCTLs, SendNBLs, and Address Changed callbacks
- //
- EX_RUNDOWN_REF ExternalRefs;
-
- //
- // Spinel Command State
- //
- EX_RUNDOWN_REF cmdRundown;
- NDIS_SPIN_LOCK cmdLock;
- LIST_ENTRY cmdHandlers;
- USHORT cmdTIDsInUse;
- spinel_tid_t cmdNextTID;
- NDIS_HANDLE cmdNblPool;
-#ifdef COMMAND_INIT_RETRY
- ULONG cmdInitTryCount;
-#endif
- otPlatResetReason cmdResetReason;
- KEVENT cmdResetCompleteEvent;
-
- //
- // Device Capabilities / State
- //
- OTLWF_DEVICE_CAPABILITY DeviceCapabilities;
- OTLWF_DEVICE_STATUS DeviceStatus;
-
- //
- // OpenThread addresses
- //
- IN6_ADDR otCachedAddr[OT_MAX_ADDRESSES];
- ULONG otCachedAddrCount;
- IN6_ADDR otLinkLocalAddr;
-
- union
- {
- struct // Thread Mode Variables
- {
- //
- // OpenThread Event processing
- //
- PVOID EventWorkerThread;
- KEVENT EventWorkerThreadStopEvent;
- KEVENT EventWorkerThreadProcessAddressChanges;
- KEVENT EventWorkerThreadProcessNBLs;
- KEVENT EventWorkerThreadProcessMacFrames;
- NDIS_SPIN_LOCK EventsLock;
- LIST_ENTRY AddressChangesHead;
- LIST_ENTRY NBLsHead;
- LIST_ENTRY MacFramesHead;
- LARGE_INTEGER NextAlarmTickCount;
- KEVENT EventWorkerThreadWaitTimeUpdated;
- KEVENT EventWorkerThreadProcessTasklets;
- PEX_TIMER EventHighPrecisionTimer;
- UCHAR EventTimerState;
- LIST_ENTRY EventIrpListHead;
- KEVENT EventWorkerThreadProcessIrp;
- KEVENT EventWorkerThreadEnergyScanComplete;
-
- //
- // OpenThread Settings Management
- //
- HANDLE otSettingsRegKey;
-
- //
- // OpenThread state management
- //
- otDeviceRole otCachedRole;
-
- //
- // OpenThread data path state
- //
- BOOLEAN SendPending;
- KEVENT SendNetBufferListComplete;
-
- //
- // OpenThread radio variables
- //
- otRadioCaps otRadioCapabilities;
- otRadioState otRadioState;
- uint8_t otCurrentListenChannel;
- uint8_t otReceiveMessage[OT_RADIO_FRAME_MAX_SIZE];
- uint8_t otTransmitMessage[OT_RADIO_FRAME_MAX_SIZE];
- otRadioFrame otReceiveFrame;
- otRadioFrame otTransmitFrame;
- otError otLastTransmitError;
- BOOLEAN otLastTransmitFramePending;
- CHAR otLastEnergyScanMaxRssi;
-
- BOOLEAN otPromiscuous;
- uint16_t otPanID;
- uint64_t otFactoryAddress;
- uint64_t otExtendedAddress;
- uint16_t otShortAddress;
-
- BOOLEAN otPendingMacOffloadEnabled;
-
-#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
- uint16_t otBufferSize; // Bytes in a single buffer
- uint16_t otBufferPoolByteSize; // Bytes in a buffer pool
- uint16_t otBufferPoolBufferCount; // Number of buffers in a pool
- uint16_t otBuffersLeft; // Number of buffers left to return
- BufferPool* otBufferPoolHead; // List of buffer pools
- otMessage* otFreeBuffers; // List of buffers to return
-#endif
-
-#if DEBUG_ALLOC
- // Used for tracking memory allocations
- HANDLE otThreadId;
- volatile LONG otOutstandingAllocationCount;
- volatile LONG otOutstandingMemoryAllocated;
- LIST_ENTRY otOutStandingAllocations;
- ULONG otAllocationID;
-#endif
-
- //
- // OpenThread Joiner Vendor Info
- //
- char otVendorName[OPENTHREAD_VENDOR_NAME_MAX_LENGTH + 1];
- char otVendorModel[OPENTHREAD_VENDOR_MODEL_MAX_LENGTH + 1];
- char otVendorSwVersion[OPENTHREAD_VENDOR_SW_VERSION_MAX_LENGTH + 1];
- char otVendorData[OPENTHREAD_VENDOR_DATA_MAX_LENGTH + 1];
-
- //
- // OpenThread context buffer
- //
- otInstance* otCtx;
- size_t otInstanceSize;
- PUCHAR otInstanceBuffer;
- };
- struct // Tunnel Mode Variables
- {
- PVOID TunWorkerThread;
- KEVENT TunWorkerThreadStopEvent;
- KEVENT TunWorkerThreadAddressChangedEvent;
- };
- };
-
-} MS_FILTER, * PMS_FILTER;
-
-//
-// NDIS Filter Functions
-//
-
-FILTER_ATTACH FilterAttach;
-FILTER_DETACH FilterDetach;
-FILTER_RESTART FilterRestart;
-FILTER_PAUSE FilterPause;
-FILTER_STATUS FilterStatus;
-FILTER_SEND_NET_BUFFER_LISTS FilterSendNetBufferLists;
-FILTER_RETURN_NET_BUFFER_LISTS FilterReturnNetBufferLists;
-FILTER_SEND_NET_BUFFER_LISTS_COMPLETE FilterSendNetBufferListsComplete;
-FILTER_RECEIVE_NET_BUFFER_LISTS FilterReceiveNetBufferLists;
-FILTER_CANCEL_SEND_NET_BUFFER_LISTS FilterCancelSendNetBufferLists;
-
-//
-// Link State Functions
-//
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfIndicateLinkState(
- _In_ PMS_FILTER pFilter,
- _In_ NDIS_MEDIA_CONNECT_STATE MediaState
- );
-
-//
-// Compartment Functions
-//
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfSetCompartment(
- _In_ PMS_FILTER pFilter,
- _Out_ COMPARTMENT_ID* pOriginalCompartment
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfRevertCompartment(
- _In_ COMPARTMENT_ID OriginalCompartment
- );
-
-//
-// Address Functions
-//
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-NETIOAPI_API_
-otLwfAddressChangeCallback(
- _In_ PVOID CallerContext,
- _In_opt_ PMIB_UNICASTIPADDRESS_ROW Row,
- _In_ MIB_NOTIFICATION_TYPE NotificationType
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingAddressChanged(
- _In_ PMS_FILTER pFilter,
- _In_ MIB_NOTIFICATION_TYPE NotificationType,
- _In_ PIN6_ADDR pAddr
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfInitializeAddresses(
- _In_ PMS_FILTER pFilter
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfRadioAddressesUpdated(
- _In_ PMS_FILTER pFilter
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfTunAddressesUpdated(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(value_data_len) const uint8_t* value_data_ptr,
- _In_ spinel_size_t value_data_len,
- _Out_ uint32_t *aNotifFlags
- );
-
-int
-otLwfFindCachedAddrIndex(
- _In_ PMS_FILTER pFilter,
- _In_ PIN6_ADDR addr
- );
-
-//
-// Tunnel Logic Functions
-//
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NDIS_STATUS
-otLwfInitializeTunnelMode(
- _In_ PMS_FILTER pFilter
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void
-otLwfUninitializeTunnelMode(
- _In_ PMS_FILTER pFilter
- );
-
-//
-// Logging Helper
-//
-
-#ifdef LOG_BUFFERS
-void
-otLogBuffer(
- _In_reads_bytes_(BufferLength) PUCHAR Buffer,
- _In_ ULONG BufferLength
- );
-#endif
-
-//
-// Debug Helpers
-//
-
-#if DEBUG_ALLOC
-
-typedef struct _OT_ALLOC
-{
- LIST_ENTRY Link;
- LONG Length;
- ULONG ID;
-} OT_ALLOC;
-
-PMS_FILTER
-otLwfFindFromCurrentThread();
-
-#endif
-
-#endif //_FILT_H
diff --git a/examples/drivers/windows/otLwf/filter.rc b/examples/drivers/windows/otLwf/filter.rc
deleted file mode 100644
index 1a9ad2c70..000000000
--- a/examples/drivers/windows/otLwf/filter.rc
+++ /dev/null
@@ -1,40 +0,0 @@
-#include
-#include
-
-/*-----------------------------------------------*/
-/* the following lines are specific to this file */
-/*-----------------------------------------------*/
-
-/* VER_FILETYPE, VER_FILESUBTYPE, VER_FILEDESCRIPTION_STR
- * and VER_INTERNALNAME_STR must be defined before including COMMON.VER
- * The strings don't need a '\0', since common.ver has them.
- */
-#define VER_FILETYPE VFT_DRV
-/* possible values: VFT_UNKNOWN
- VFT_APP
- VFT_DLL
- VFT_DRV
- VFT_FONT
- VFT_VXD
- VFT_STATIC_LIB
-*/
-#define VER_FILESUBTYPE VFT2_DRV_NETWORK
-/* possible values VFT2_UNKNOWN
- VFT2_DRV_PRINTER
- VFT2_DRV_KEYBOARD
- VFT2_DRV_LANGUAGE
- VFT2_DRV_DISPLAY
- VFT2_DRV_MOUSE
- VFT2_DRV_NETWORK
- VFT2_DRV_SYSTEM
- VFT2_DRV_INSTALLABLE
- VFT2_DRV_SOUND
- VFT2_DRV_COMM
-*/
-#define VER_FILEDESCRIPTION_STR "otLwf NDIS 6.0 Filter Driver"
-#define VER_INTERNALNAME_STR "otLwf.sys"
-#define VER_ORIGINALFILENAME_STR "otLwf.sys"
-#define VER_LANGNEUTRAL
-
-#include "common.ver"
-
diff --git a/examples/drivers/windows/otLwf/iocontrol.c b/examples/drivers/windows/otLwf/iocontrol.c
deleted file mode 100644
index 772383936..000000000
--- a/examples/drivers/windows/otLwf/iocontrol.c
+++ /dev/null
@@ -1,6686 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "precomp.h"
-#include "iocontrol.tmh"
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP Irp
- );
-
-typedef struct _OTLWF_IOCTL_HANDLER
-{
- const char* Name;
- OTLWF_OT_IOCTL_FUNC* otFunc;
- OTLWF_TUN_IOCTL_FUNC* tunFunc;
-} OTLWF_IOCTL_HANDLER;
-
-OTLWF_IOCTL_HANDLER IoCtls[] =
-{
- { "IOCTL_OTLWF_OT_ENABLED", NULL },
- { "IOCTL_OTLWF_OT_INTERFACE", REF_IOCTL_FUNC_WITH_TUN(otInterface) },
- { "IOCTL_OTLWF_OT_THREAD", REF_IOCTL_FUNC_WITH_TUN(otThread) },
- { "IOCTL_OTLWF_OT_ACTIVE_SCAN", REF_IOCTL_FUNC_WITH_TUN(otActiveScan) },
- { "IOCTL_OTLWF_OT_DISCOVER", REF_IOCTL_FUNC(otDiscover) },
- { "IOCTL_OTLWF_OT_CHANNEL", REF_IOCTL_FUNC_WITH_TUN(otChannel) },
- { "IOCTL_OTLWF_OT_CHILD_TIMEOUT", REF_IOCTL_FUNC_WITH_TUN(otChildTimeout) },
- { "IOCTL_OTLWF_OT_EXTENDED_ADDRESS", REF_IOCTL_FUNC_WITH_TUN(otExtendedAddress) },
- { "IOCTL_OTLWF_OT_EXTENDED_PANID", REF_IOCTL_FUNC_WITH_TUN(otExtendedPanId) },
- { "IOCTL_OTLWF_OT_LEADER_RLOC", REF_IOCTL_FUNC_WITH_TUN(otLeaderRloc) },
- { "IOCTL_OTLWF_OT_LINK_MODE", REF_IOCTL_FUNC_WITH_TUN(otLinkMode) },
- { "IOCTL_OTLWF_OT_MASTER_KEY", REF_IOCTL_FUNC_WITH_TUN(otMasterKey) },
- { "IOCTL_OTLWF_OT_MESH_LOCAL_EID", REF_IOCTL_FUNC_WITH_TUN(otMeshLocalEid) },
- { "IOCTL_OTLWF_OT_MESH_LOCAL_PREFIX", REF_IOCTL_FUNC_WITH_TUN(otMeshLocalPrefix) },
- { "IOCTL_OTLWF_OT_NETWORK_DATA_LEADER", NULL },
- { "IOCTL_OTLWF_OT_NETWORK_DATA_LOCAL", NULL },
- { "IOCTL_OTLWF_OT_NETWORK_NAME", REF_IOCTL_FUNC_WITH_TUN(otNetworkName) },
- { "IOCTL_OTLWF_OT_PAN_ID", REF_IOCTL_FUNC_WITH_TUN(otPanId) },
- { "IOCTL_OTLWF_OT_ROUTER_ROLL_ENABLED", REF_IOCTL_FUNC_WITH_TUN(otRouterRollEnabled) },
- { "IOCTL_OTLWF_OT_SHORT_ADDRESS", REF_IOCTL_FUNC_WITH_TUN(otShortAddress) },
- { "IOCTL_OTLWF_OT_UNICAST_ADDRESSES", NULL },
- { "IOCTL_OTLWF_OT_ACTIVE_DATASET", REF_IOCTL_FUNC(otActiveDataset) },
- { "IOCTL_OTLWF_OT_PENDING_DATASET", REF_IOCTL_FUNC(otPendingDataset) },
- { "IOCTL_OTLWF_OT_LOCAL_LEADER_WEIGHT", REF_IOCTL_FUNC_WITH_TUN(otLocalLeaderWeight) },
- { "IOCTL_OTLWF_OT_ADD_BORDER_ROUTER", REF_IOCTL_FUNC_WITH_TUN(otAddBorderRouter) },
- { "IOCTL_OTLWF_OT_REMOVE_BORDER_ROUTER", REF_IOCTL_FUNC_WITH_TUN(otRemoveBorderRouter) },
- { "IOCTL_OTLWF_OT_ADD_EXTERNAL_ROUTE", REF_IOCTL_FUNC_WITH_TUN(otAddExternalRoute) },
- { "IOCTL_OTLWF_OT_REMOVE_EXTERNAL_ROUTE", REF_IOCTL_FUNC_WITH_TUN(otRemoveExternalRoute) },
- { "IOCTL_OTLWF_OT_SEND_SERVER_DATA", REF_IOCTL_FUNC(otSendServerData) },
- { "IOCTL_OTLWF_OT_CONTEXT_ID_REUSE_DELAY", REF_IOCTL_FUNC_WITH_TUN(otContextIdReuseDelay) },
- { "IOCTL_OTLWF_OT_KEY_SEQUENCE_COUNTER", REF_IOCTL_FUNC_WITH_TUN(otKeySequenceCounter) },
- { "IOCTL_OTLWF_OT_NETWORK_ID_TIMEOUT", REF_IOCTL_FUNC_WITH_TUN(otNetworkIdTimeout) },
- { "IOCTL_OTLWF_OT_ROUTER_UPGRADE_THRESHOLD", REF_IOCTL_FUNC_WITH_TUN(otRouterUpgradeThreshold) },
- { "IOCTL_OTLWF_OT_RELEASE_ROUTER_ID", REF_IOCTL_FUNC_WITH_TUN(otReleaseRouterId) },
- { "IOCTL_OTLWF_OT_MAC_WHITELIST_ENABLED", REF_IOCTL_FUNC_WITH_TUN(otMacWhitelistEnabled) },
- { "IOCTL_OTLWF_OT_ADD_MAC_WHITELIST", REF_IOCTL_FUNC_WITH_TUN(otAddMacWhitelist) },
- { "IOCTL_OTLWF_OT_REMOVE_MAC_WHITELIST", REF_IOCTL_FUNC_WITH_TUN(otRemoveMacWhitelist) },
- { "IOCTL_OTLWF_OT_NEXT_MAC_WHITELIST", REF_IOCTL_FUNC(otNextMacWhitelist) },
- { "IOCTL_OTLWF_OT_CLEAR_MAC_WHITELIST", REF_IOCTL_FUNC_WITH_TUN(otClearMacWhitelist) },
- { "IOCTL_OTLWF_OT_DEVICE_ROLE", REF_IOCTL_FUNC_WITH_TUN(otDeviceRole) },
- { "IOCTL_OTLWF_OT_CHILD_INFO_BY_ID", REF_IOCTL_FUNC(otChildInfoById) },
- { "IOCTL_OTLWF_OT_CHILD_INFO_BY_INDEX", REF_IOCTL_FUNC(otChildInfoByIndex) },
- { "IOCTL_OTLWF_OT_EID_CACHE_ENTRY", REF_IOCTL_FUNC(otEidCacheEntry) },
- { "IOCTL_OTLWF_OT_LEADER_DATA", REF_IOCTL_FUNC(otLeaderData) },
- { "IOCTL_OTLWF_OT_LEADER_ROUTER_ID", REF_IOCTL_FUNC_WITH_TUN(otLeaderRouterId) },
- { "IOCTL_OTLWF_OT_LEADER_WEIGHT", REF_IOCTL_FUNC_WITH_TUN(otLeaderWeight) },
- { "IOCTL_OTLWF_OT_NETWORK_DATA_VERSION", REF_IOCTL_FUNC_WITH_TUN(otNetworkDataVersion) },
- { "IOCTL_OTLWF_OT_PARTITION_ID", REF_IOCTL_FUNC_WITH_TUN(otPartitionId) },
- { "IOCTL_OTLWF_OT_RLOC16", REF_IOCTL_FUNC_WITH_TUN(otRloc16) },
- { "IOCTL_OTLWF_OT_ROUTER_ID_SEQUENCE", REF_IOCTL_FUNC(otRouterIdSequence) },
- { "IOCTL_OTLWF_OT_MAX_ROUTER_ID", REF_IOCTL_FUNC(otMaxRouterId) },
- { "IOCTL_OTLWF_OT_ROUTER_INFO", REF_IOCTL_FUNC(otRouterInfo) },
- { "IOCTL_OTLWF_OT_STABLE_NETWORK_DATA_VERSION", REF_IOCTL_FUNC_WITH_TUN(otStableNetworkDataVersion) },
- { "IOCTL_OTLWF_OT_MAC_BLACKLIST_ENABLED", REF_IOCTL_FUNC(otMacBlacklistEnabled) },
- { "IOCTL_OTLWF_OT_ADD_MAC_BLACKLIST", REF_IOCTL_FUNC(otAddMacBlacklist) },
- { "IOCTL_OTLWF_OT_REMOVE_MAC_BLACKLIST", REF_IOCTL_FUNC(otRemoveMacBlacklist) },
- { "IOCTL_OTLWF_OT_NEXT_MAC_BLACKLIST", REF_IOCTL_FUNC(otNextMacBlacklist) },
- { "IOCTL_OTLWF_OT_CLEAR_MAC_BLACKLIST", REF_IOCTL_FUNC(otClearMacBlacklist) },
- { "IOCTL_OTLWF_OT_TRANSMIT_POWER", REF_IOCTL_FUNC(otTransmitPower) },
- { "IOCTL_OTLWF_OT_NEXT_ON_MESH_PREFIX", REF_IOCTL_FUNC(otNextOnMeshPrefix) },
- { "IOCTL_OTLWF_OT_POLL_PERIOD", REF_IOCTL_FUNC(otPollPeriod) },
- { "IOCTL_OTLWF_OT_LOCAL_LEADER_PARTITION_ID", REF_IOCTL_FUNC(otLocalLeaderPartitionId) },
- { "IOCTL_OTLWF_OT_PLATFORM_RESET", REF_IOCTL_FUNC_WITH_TUN(otPlatformReset) },
- { "IOCTL_OTLWF_OT_PARENT_INFO", REF_IOCTL_FUNC_WITH_TUN(otParentInfo) },
- { "IOCTL_OTLWF_OT_SINGLETON", REF_IOCTL_FUNC(otSingleton) },
- { "IOCTL_OTLWF_OT_MAC_COUNTERS", REF_IOCTL_FUNC(otMacCounters) },
- { "IOCTL_OTLWF_OT_MAX_CHILDREN", REF_IOCTL_FUNC_WITH_TUN(otMaxChildren) },
- { "IOCTL_OTLWF_OT_COMMISIONER_START", REF_IOCTL_FUNC(otCommissionerStart) },
- { "IOCTL_OTLWF_OT_COMMISIONER_STOP", REF_IOCTL_FUNC(otCommissionerStop) },
- { "IOCTL_OTLWF_OT_JOINER_START", REF_IOCTL_FUNC(otJoinerStart) },
- { "IOCTL_OTLWF_OT_JOINER_STOP", REF_IOCTL_FUNC(otJoinerStop) },
- { "IOCTL_OTLWF_OT_FACTORY_EUI64", REF_IOCTL_FUNC(otFactoryAssignedIeeeEui64) },
- { "IOCTL_OTLWF_OT_JOINER_ID", REF_IOCTL_FUNC(otJoinerId) },
- { "IOCTL_OTLWF_OT_ROUTER_DOWNGRADE_THRESHOLD", REF_IOCTL_FUNC_WITH_TUN(otRouterDowngradeThreshold) },
- { "IOCTL_OTLWF_OT_COMMISSIONER_PANID_QUERY", REF_IOCTL_FUNC(otCommissionerPanIdQuery) },
- { "IOCTL_OTLWF_OT_COMMISSIONER_ENERGY_SCAN", REF_IOCTL_FUNC(otCommissionerEnergyScan) },
- { "IOCTL_OTLWF_OT_ROUTER_SELECTION_JITTER", REF_IOCTL_FUNC_WITH_TUN(otRouterSelectionJitter) },
- { "IOCTL_OTLWF_OT_JOINER_UDP_PORT", REF_IOCTL_FUNC(otJoinerUdpPort) },
- { "IOCTL_OTLWF_OT_SEND_DIAGNOSTIC_GET", REF_IOCTL_FUNC(otSendDiagnosticGet) },
- { "IOCTL_OTLWF_OT_SEND_DIAGNOSTIC_RESET", REF_IOCTL_FUNC(otSendDiagnosticReset) },
- { "IOCTL_OTLWF_OT_COMMISIONER_ADD_JOINER", REF_IOCTL_FUNC(otCommissionerAddJoiner) },
- { "IOCTL_OTLWF_OT_COMMISIONER_REMOVE_JOINER", REF_IOCTL_FUNC(otCommissionerRemoveJoiner) },
- { "IOCTL_OTLWF_OT_COMMISIONER_PROVISIONING_URL", REF_IOCTL_FUNC(otCommissionerProvisioningUrl) },
- { "IOCTL_OTLWF_OT_COMMISIONER_ANNOUNCE_BEGIN", REF_IOCTL_FUNC(otCommissionerAnnounceBegin) },
- { "IOCTL_OTLWF_OT_ENERGY_SCAN", REF_IOCTL_FUNC_WITH_TUN(otEnergyScan) },
- { "IOCTL_OTLWF_OT_SEND_ACTIVE_GET", REF_IOCTL_FUNC(otSendActiveGet) },
- { "IOCTL_OTLWF_OT_SEND_ACTIVE_SET", REF_IOCTL_FUNC(otSendActiveSet) },
- { "IOCTL_OTLWF_OT_SEND_PENDING_GET", REF_IOCTL_FUNC(otSendPendingGet) },
- { "IOCTL_OTLWF_OT_SEND_PENDING_SET", REF_IOCTL_FUNC(otSendPendingSet) },
- { "IOCTL_OTLWF_OT_SEND_MGMT_COMMISSIONER_GET", REF_IOCTL_FUNC(otSendMgmtCommissionerGet) },
- { "IOCTL_OTLWF_OT_SEND_MGMT_COMMISSIONER_SET", REF_IOCTL_FUNC(otSendMgmtCommissionerSet) },
- { "IOCTL_OTLWF_OT_KEY_SWITCH_GUARDTIME", REF_IOCTL_FUNC_WITH_TUN(otKeySwitchGuardtime) },
- { "IOCTL_OTLWF_OT_FACTORY_RESET", REF_IOCTL_FUNC(otFactoryReset) },
- { "IOCTL_OTLWF_OT_THREAD_AUTO_START", REF_IOCTL_FUNC(otThreadAutoStart) },
- { "IOCTL_OTLWF_OT_PREFERRED_ROUTER_ID", REF_IOCTL_FUNC(otThreadPreferredRouterId) },
- { "IOCTL_OTLWF_OT_PSKC", REF_IOCTL_FUNC_WITH_TUN(otPSKc) },
- { "IOCTL_OTLWF_OT_PARENT_PRIORITY", REF_IOCTL_FUNC(otParentPriority) },
- { "IOCTL_OTLWF_OT_ADD_MAC_FIXED_RSS", REF_IOCTL_FUNC_WITH_TUN(otAddMacFixedRss) },
- { "IOCTL_OTLWF_OT_REMOVE_MAC_FIXED_RSS", REF_IOCTL_FUNC_WITH_TUN(otRemoveMacFixedRss) },
- { "IOCTL_OTLWF_OT_NEXT_MAC_FIXED_RSS", REF_IOCTL_FUNC(otNextMacFixedRss) },
- { "IOCTL_OTLWF_OT_CLEAR_MAC_FIXED_RSS", REF_IOCTL_FUNC_WITH_TUN(otClearMacFixedRss) },
- { "IOCTL_OTLWF_OT_NEXT_ROUTE", REF_IOCTL_FUNC(otNextRoute) },
- { "IOCTL_OTLWF_OT_MLE_COUNTERS", REF_IOCTL_FUNC(otMleCounters) },
- { "IOCTL_OTLWF_OT_LINK_LOCAL_ADDRESS", REF_IOCTL_FUNC(otLinkLocalAddress) },
- { "IOCTL_OTLWF_OT_RLOC", REF_IOCTL_FUNC(otRloc) },
-};
-
-// intentionally -1 in the end due to that IOCTL_OTLWF_OT_ASSIGN_LINK_QUALITY (#161) is removed now.
-static_assert(ARRAYSIZE(IoCtls) == (MAX_OTLWF_IOCTL_FUNC_CODE - MIN_OTLWF_IOCTL_FUNC_CODE) + 1 - 1,
- "The IoCtl strings should be up to date with the actual IoCtl list.");
-
-const char*
-IoCtlString(
- ULONG IoControlCode
-)
-{
- ULONG FuncCode = ((IoControlCode >> 2) & 0xFFF) - 100;
- return FuncCode < ARRAYSIZE(IoCtls) ? IoCtls[FuncCode].Name : "UNKNOWN IOCTL";
-}
-
-// Handles queries for the current list of Thread interfaces
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtlEnumerateInterfaces(
- _In_reads_bytes_(InBufferLength)
- PVOID InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- ULONG NewOutBufferLength = 0;
- POTLWF_INTERFACE_LIST pInterfaceList = (POTLWF_INTERFACE_LIST)OutBuffer;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- LogFuncEntry(DRIVER_IOCTL);
-
- // Make sure to zero out the output first
- RtlZeroMemory(OutBuffer, *OutBufferLength);
-
- NdisAcquireSpinLock(&FilterListLock);
-
- // Make sure there is enough space for the first uint16_t
- if (*OutBufferLength < sizeof(uint16_t))
- {
- status = STATUS_BUFFER_TOO_SMALL;
- goto error;
- }
-
- // Iterate through each interface and build up the list of running interfaces
- for (PLIST_ENTRY Link = FilterModuleList.Flink; Link != &FilterModuleList; Link = Link->Flink)
- {
- PMS_FILTER pFilter = CONTAINING_RECORD(Link, MS_FILTER, FilterModuleLink);
- if (pFilter->State != FilterRunning) continue;
-
- PGUID pInterfaceGuid = &pInterfaceList->InterfaceGuids[pInterfaceList->cInterfaceGuids];
- pInterfaceList->cInterfaceGuids++;
-
- NewOutBufferLength =
- FIELD_OFFSET(OTLWF_INTERFACE_LIST, InterfaceGuids) +
- pInterfaceList->cInterfaceGuids * sizeof(GUID);
-
- if (NewOutBufferLength <= *OutBufferLength)
- {
- *pInterfaceGuid = pFilter->InterfaceGuid;
- }
- }
-
- if (NewOutBufferLength > *OutBufferLength)
- {
- NewOutBufferLength = sizeof(USHORT);
- }
-
-error:
-
- NdisReleaseSpinLock(&FilterListLock);
-
- *OutBufferLength = NewOutBufferLength;
-
- LogFuncExitNT(DRIVER_IOCTL, status);
-
- return status;
-}
-
-// Handles queries for the details of a specific Thread interface
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtlQueryInterface(
- _In_reads_bytes_(InBufferLength)
- PVOID InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- ULONG NewOutBufferLength = 0;
-
- LogFuncEntry(DRIVER_IOCTL);
-
- // Make sure there is enough space for the first USHORT
- if (InBufferLength < sizeof(GUID) || *OutBufferLength < sizeof(OTLWF_DEVICE))
- {
- status = STATUS_BUFFER_TOO_SMALL;
- goto error;
- }
-
- PGUID pInterfaceGuid = (PGUID)InBuffer;
- POTLWF_DEVICE pDevice = (POTLWF_DEVICE)OutBuffer;
-
- // Look up the interface
- PMS_FILTER pFilter = otLwfFindAndRefInterface(pInterfaceGuid);
- if (pFilter == NULL)
- {
- status = STATUS_DEVICE_DOES_NOT_EXIST;
- goto error;
- }
-
- NewOutBufferLength = sizeof(OTLWF_DEVICE);
- pDevice->CompartmentID = pFilter->InterfaceCompartmentID;
-
- // Release the ref on the interface
- ExReleaseRundownProtection(&pFilter->ExternalRefs);
-
-error:
-
- if (NewOutBufferLength < *OutBufferLength)
- {
- RtlZeroMemory((PUCHAR)OutBuffer + NewOutBufferLength, *OutBufferLength - NewOutBufferLength);
- }
-
- *OutBufferLength = NewOutBufferLength;
-
- LogFuncExitNT(DRIVER_IOCTL, status);
-
- return status;
-}
-
-// Handles IOTCLs for OpenThread control
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtlOpenThreadControl(
- _In_ PIRP Irp
- )
-{
- NTSTATUS status = STATUS_PENDING;
- PMS_FILTER pFilter = NULL;
-
- PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
-
- LogFuncEntry(DRIVER_IOCTL);
-
- if (IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(GUID))
- {
- status = STATUS_INVALID_PARAMETER;
- goto error;
- }
-
- pFilter = otLwfFindAndRefInterface((PGUID)Irp->AssociatedIrp.SystemBuffer);
- if (pFilter == NULL)
- {
- status = STATUS_DEVICE_DOES_NOT_EXIST;
- goto error;
- }
-
- if (pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE)
- {
- // Pend the Irp for processing on the OpenThread event processing thread
- otLwfEventProcessingIndicateIrp(pFilter, Irp);
- }
- else
- {
- status = otLwfTunIoCtl(pFilter, Irp);
- }
-
- // Release our ref on the filter
- ExReleaseRundownProtection(&pFilter->ExternalRefs);
-
-error:
-
- // Complete the IRP if we aren't pending (indicates we failed)
- if (status != STATUS_PENDING)
- {
- NT_ASSERT(status != STATUS_SUCCESS);
- RtlZeroMemory(Irp->AssociatedIrp.SystemBuffer, IrpSp->Parameters.DeviceIoControl.OutputBufferLength);
- Irp->IoStatus.Status = status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- }
-
- LogFuncExitNT(DRIVER_IOCTL, status);
-
- return status;
-}
-
-// Handles Irp for IOTCLs for OpenThread control on the OpenThread thread
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfCompleteOpenThreadIrp(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP Irp
- )
-{
- PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
-
- PUCHAR InBuffer = (PUCHAR)Irp->AssociatedIrp.SystemBuffer + sizeof(GUID);
- PVOID OutBuffer = Irp->AssociatedIrp.SystemBuffer;
-
- ULONG InBufferLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength - sizeof(GUID);
- ULONG OutBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
- ULONG IoControlCode = IrpSp->Parameters.DeviceIoControl.IoControlCode;
-
- ULONG OrigOutBufferLength = OutBufferLength;
-
- NTSTATUS status = STATUS_NOT_IMPLEMENTED;
-
- ULONG FuncCode = ((IoControlCode >> 2) & 0xFFF) - 100;
- if (FuncCode < ARRAYSIZE(IoCtls))
- {
- LogVerbose(DRIVER_IOCTL, "Processing Irp=%p, for %s (In:%u,Out:%u)",
- Irp, IoCtls[FuncCode].Name, InBufferLength, OutBufferLength);
-
- if (IoCtls[FuncCode].otFunc)
- {
- status = IoCtls[FuncCode].otFunc(pFilter, InBuffer, InBufferLength, OutBuffer, &OutBufferLength);
- }
- else
- {
- OutBufferLength = 0;
- }
-
- LogVerbose(DRIVER_IOCTL, "Completing Irp=%p, with %!STATUS! for %s (Out:%u)",
- Irp, status, IoCtls[FuncCode].Name, OutBufferLength);
- }
- else
- {
- OutBufferLength = 0;
- }
-
- // Clear any leftover output buffer
- if (OutBufferLength < OrigOutBufferLength)
- {
- RtlZeroMemory((PUCHAR)OutBuffer + OutBufferLength, OrigOutBufferLength - OutBufferLength);
- }
-
- // Complete the IRP
- Irp->IoStatus.Information = OutBufferLength;
- Irp->IoStatus.Status = status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-}
-
-// Handles Irp for IOTCLs for OpenThread control on the OpenThread thread
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP Irp
- )
-{
- PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
-
- PUCHAR InBuffer = (PUCHAR)Irp->AssociatedIrp.SystemBuffer + sizeof(GUID);
- ULONG InBufferLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength - sizeof(GUID);
- ULONG OutBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
- ULONG IoControlCode = IrpSp->Parameters.DeviceIoControl.IoControlCode;
-
- NTSTATUS status = STATUS_NOT_IMPLEMENTED;
-
- ULONG FuncCode = ((IoControlCode >> 2) & 0xFFF) - 100;
- if (FuncCode < ARRAYSIZE(IoCtls))
- {
- LogVerbose(DRIVER_IOCTL, "Processing Irp=%p, for %s (In:%u,Out:%u)",
- Irp, IoCtls[FuncCode].Name, InBufferLength, OutBufferLength);
-
- if (IoCtls[FuncCode].tunFunc)
- {
- status = IoCtls[FuncCode].tunFunc(pFilter, Irp, InBuffer, InBufferLength, OutBufferLength);
- }
-
- if (!NT_SUCCESS(status))
- {
- LogVerbose(DRIVER_IOCTL, "Completing Irp=%p, with %!STATUS! for %s",
- Irp, status, IoCtls[FuncCode].Name);
- }
- }
-
- if (NT_SUCCESS(status))
- {
- status = STATUS_PENDING;
-
- // Mark the Irp as pending
- IoMarkIrpPending(Irp);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otInterface(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN))
- {
- BOOLEAN IsEnabled = *(BOOLEAN*)InBuffer;
- if (IsEnabled)
- {
- // Make sure our addresses are in sync
- (void)otLwfInitializeAddresses(pFilter);
- otLwfRadioAddressesUpdated(pFilter);
- }
-
- status = ThreadErrorToNtstatus(otIp6SetEnabled(pFilter->otCtx, IsEnabled));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(BOOLEAN))
- {
- *(BOOLEAN*)OutBuffer = otIp6IsEnabled(pFilter->otCtx) ? TRUE : FALSE;
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otInterface(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN))
- {
- BOOLEAN IsEnabled = *(BOOLEAN*)InBuffer;
- if (IsEnabled)
- {
- // Make sure our addresses are in sync
- (void)otLwfInitializeAddresses(pFilter);
-
- // Sync the current addresses
- KeSetEvent(&pFilter->TunWorkerThreadAddressChangedEvent, IO_NO_INCREMENT, FALSE);
- }
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_NET_IF_UP,
- sizeof(BOOLEAN),
- SPINEL_DATATYPE_BOOL_S,
- IsEnabled);
- }
- else if (OutBufferLength >= sizeof(BOOLEAN))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otInterface_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_NET_IF_UP,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otInterface_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_NET_IF_UP)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_BOOL_S, (BOOLEAN*)OutBuffer))
- {
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otThread(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN))
- {
- BOOLEAN IsEnabled = *(BOOLEAN*)InBuffer;
- status = ThreadErrorToNtstatus(otThreadSetEnabled(pFilter->otCtx, IsEnabled));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(BOOLEAN))
- {
- *(BOOLEAN*)OutBuffer = (otThreadGetDeviceRole(pFilter->otCtx) > OT_DEVICE_ROLE_DISABLED) ? TRUE : FALSE;
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otThread(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_NET_STACK_UP,
- sizeof(BOOLEAN),
- SPINEL_DATATYPE_BOOL_S,
- *(BOOLEAN*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(BOOLEAN))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otThread_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_NET_STACK_UP,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otThread_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_NET_STACK_UP)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_BOOL_S, (BOOLEAN*)OutBuffer))
- {
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otActiveScan(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t) + sizeof(uint16_t))
- {
- uint32_t aScanChannels = *(uint32_t*)InBuffer;
- uint16_t aScanDuration = *(uint16_t*)(InBuffer + sizeof(uint32_t));
- status = ThreadErrorToNtstatus(
- otLinkActiveScan(
- pFilter->otCtx,
- aScanChannels,
- aScanDuration,
- otLwfActiveScanCallback,
- pFilter)
- );
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(BOOLEAN))
- {
- *(BOOLEAN*)OutBuffer = otLinkIsActiveScanInProgress(pFilter->otCtx) ? TRUE : FALSE;
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otActiveScan(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t) + sizeof(uint16_t))
- {
- uint32_t aScanChannels = *(uint32_t*)InBuffer;
- uint16_t aScanDuration = *(uint16_t*)(InBuffer + sizeof(uint32_t));
- uint8_t aScanState = SPINEL_SCAN_STATE_BEACON;
-
- // TODO - Send down scan channel & duration first
- UNREFERENCED_PARAMETER(aScanChannels);
- status = otLwfCmdSetProp(pFilter, SPINEL_PROP_MAC_SCAN_MASK, SPINEL_DATATYPE_UINT16_S, aScanDuration);
- if (!NT_SUCCESS(status)) goto error;
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_MAC_SCAN_STATE,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- aScanState);
- }
- else if (OutBufferLength >= sizeof(BOOLEAN))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otActiveScan_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_MAC_SCAN_STATE,
- 0,
- NULL);
- }
-
-error:
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otActiveScan_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_MAC_SCAN_STATE)
- {
- uint8_t aScanState = 0;
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, &aScanState))
- {
- *(BOOLEAN*)OutBuffer = (aScanState == SPINEL_SCAN_STATE_BEACON) ? TRUE : FALSE;
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otEnergyScan(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t) + sizeof(uint16_t))
- {
- uint32_t aScanChannels = *(uint32_t*)InBuffer;
- uint16_t aScanDuration = *(uint16_t*)(InBuffer + sizeof(uint32_t));
- status = ThreadErrorToNtstatus(
- otLinkEnergyScan(
- pFilter->otCtx,
- aScanChannels,
- aScanDuration,
- otLwfEnergyScanCallback,
- pFilter)
- );
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(BOOLEAN))
- {
- *(BOOLEAN*)OutBuffer = otLinkIsEnergyScanInProgress(pFilter->otCtx) ? TRUE : FALSE;
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otEnergyScan(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t) + sizeof(uint16_t))
- {
- uint32_t aScanChannels = *(uint32_t*)InBuffer;
- uint16_t aScanDuration = *(uint16_t*)(InBuffer + sizeof(uint32_t));
- uint8_t aScanState = SPINEL_SCAN_STATE_ENERGY;
-
- // TODO - Send down scan channel & duration first
- UNREFERENCED_PARAMETER(aScanChannels);
- status = otLwfCmdSetProp(pFilter, SPINEL_PROP_MAC_SCAN_MASK, SPINEL_DATATYPE_UINT16_S, aScanDuration);
- if (!NT_SUCCESS(status)) goto error;
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_MAC_SCAN_STATE,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- aScanState);
- }
- else if (OutBufferLength >= sizeof(BOOLEAN))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otEnergyScan_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_MAC_SCAN_STATE,
- 0,
- NULL);
- }
-
-error:
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otEnergyScan_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_MAC_SCAN_STATE)
- {
- uint8_t aScanState = 0;
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, &aScanState))
- {
- *(BOOLEAN*)OutBuffer = (aScanState == SPINEL_SCAN_STATE_ENERGY) ? TRUE : FALSE;
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otDiscover(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t) + sizeof(uint16_t) + sizeof(bool))
- {
- uint32_t aScanChannels = *(uint32_t*)InBuffer;
- uint16_t aPanid = *(uint16_t*)(InBuffer + sizeof(uint32_t));
- bool aJoiner = *(uint8_t*)(InBuffer + sizeof(uint32_t) + sizeof(uint16_t));
- bool aEnableEui64Filtering = *(uint8_t*)(InBuffer + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint8_t));
- status = ThreadErrorToNtstatus(
- otThreadDiscover(
- pFilter->otCtx,
- aScanChannels,
- aPanid,
- aJoiner,
- aEnableEui64Filtering,
- otLwfDiscoverCallback,
- pFilter)
- );
- }
- else if (*OutBufferLength >= sizeof(BOOLEAN))
- {
- *(BOOLEAN*)OutBuffer = otThreadIsDiscoverInProgress(pFilter->otCtx) ? TRUE : FALSE;
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otChannel(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- status = ThreadErrorToNtstatus(otLinkSetChannel(pFilter->otCtx, *(uint8_t*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otLinkGetChannel(pFilter->otCtx);
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otChannel(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_PHY_CHAN,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- *(uint8_t*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otChannel_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_PHY_CHAN,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otChannel_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_PHY_CHAN)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, (uint8_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otChildTimeout(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t))
- {
- otThreadSetChildTimeout(pFilter->otCtx, *(uint32_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint32_t))
- {
- *(uint32_t*)OutBuffer = otThreadGetChildTimeout(pFilter->otCtx);
- *OutBufferLength = sizeof(uint32_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otChildTimeout(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_THREAD_CHILD_TIMEOUT,
- sizeof(uint32_t),
- SPINEL_DATATYPE_UINT32_S,
- *(uint32_t*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(uint32_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otChildTimeout_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_CHILD_TIMEOUT,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otChildTimeout_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_CHILD_TIMEOUT)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT32_S, (uint32_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint32_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otExtendedAddress(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otExtAddress))
- {
- status = ThreadErrorToNtstatus(otLinkSetExtendedAddress(pFilter->otCtx, (otExtAddress*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(otExtAddress))
- {
- memcpy(OutBuffer, otLinkGetExtendedAddress(pFilter->otCtx), sizeof(otExtAddress));
- *OutBufferLength = sizeof(otExtAddress);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otExtendedAddress(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otExtAddress))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_HWADDR,
- sizeof(otExtAddress),
- SPINEL_DATATYPE_EUI64_S,
- (otExtAddress*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(otExtAddress))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otExtendedAddress_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_HWADDR,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otExtendedAddress_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_HWADDR)
- {
- spinel_eui64_t *data = NULL;
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_EUI64_S, &data) && data != NULL)
- {
- memcpy(OutBuffer, data, sizeof(otExtAddress));
- *OutBufferLength = sizeof(otExtAddress);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otExtendedPanId(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otExtendedPanId))
- {
- status = ThreadErrorToNtstatus(otThreadSetExtendedPanId(pFilter->otCtx, (otExtendedPanId*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(otExtendedPanId))
- {
- const otExtendedPanId* aExtendedPanId = otThreadGetExtendedPanId(pFilter->otCtx);
- memcpy(OutBuffer, aExtendedPanId, sizeof(otExtendedPanId));
- *OutBufferLength = sizeof(otExtendedPanId);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otExtendedPanId(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otExtendedPanId))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_NET_XPANID,
- sizeof(otExtendedPanId) + sizeof(uint16_t),
- SPINEL_DATATYPE_DATA_S,
- (otExtendedPanId*)InBuffer,
- sizeof(otExtendedPanId));
- }
- else if (OutBufferLength >= sizeof(otExtendedPanId))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otExtendedPanId_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_NET_XPANID,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otExtendedPanId_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_NET_XPANID)
- {
- uint8_t *data = NULL;
- spinel_size_t aExtPanIdLen;
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_DATA_S, &data, &aExtPanIdLen) && data != NULL &&
- aExtPanIdLen == sizeof(otExtendedPanId))
- {
- memcpy(OutBuffer, data, sizeof(otExtendedPanId));
- *OutBufferLength = sizeof(otExtendedPanId);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otFactoryAssignedIeeeEui64(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(otExtAddress))
- {
- otLinkGetFactoryAssignedIeeeEui64(pFilter->otCtx, (otExtAddress*)OutBuffer);
- *OutBufferLength = sizeof(otExtAddress);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otJoinerId(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(otExtAddress))
- {
- status = ThreadErrorToNtstatus(otJoinerGetId(pFilter->otCtx, (otExtAddress*)OutBuffer));
- *OutBufferLength = sizeof(otExtAddress);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otLeaderRloc(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(otIp6Address))
- {
- status = ThreadErrorToNtstatus(otThreadGetLeaderRloc(pFilter->otCtx, (otIp6Address*)OutBuffer));
- *OutBufferLength = sizeof(otIp6Address);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otLeaderRloc(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otIp6Address))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_THREAD_LEADER_ADDR,
- sizeof(otIp6Address),
- SPINEL_DATATYPE_IPv6ADDR_S,
- (otIp6Address*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(otIp6Address))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otLeaderRloc_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_LEADER_ADDR,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otLeaderRloc_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_LEADER_ADDR)
- {
- spinel_ipv6addr_t *data = NULL;
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_IPv6ADDR_S, &data) && data != NULL)
- {
- memcpy(OutBuffer, data, sizeof(spinel_ipv6addr_t));
- *OutBufferLength = sizeof(otIp6Address);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otLinkMode(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- static_assert(sizeof(otLinkModeConfig) == 4, "The size of otLinkModeConfig should be 4 bytes");
- if (InBufferLength >= sizeof(otLinkModeConfig))
- {
- status = ThreadErrorToNtstatus(otThreadSetLinkMode(pFilter->otCtx, *(otLinkModeConfig*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(otLinkModeConfig))
- {
- *(otLinkModeConfig*)OutBuffer = otThreadGetLinkMode(pFilter->otCtx);
- *OutBufferLength = sizeof(otLinkModeConfig);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-enum
-{
- kThreadMode_RxOnWhenIdle = (1 << 3),
- kThreadMode_SecureDataRequest = (1 << 2),
- kThreadMode_FullThreadDevice = (1 << 1),
- kThreadMode_FullNetworkData = (1 << 0),
-};
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otLinkMode(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otLinkModeConfig))
- {
- const otLinkModeConfig* aLinkMode = (otLinkModeConfig*)InBuffer;
- uint8_t numeric_mode = 0;
-
- if (aLinkMode->mRxOnWhenIdle) numeric_mode |= kThreadMode_RxOnWhenIdle;
- if (aLinkMode->mSecureDataRequests) numeric_mode |= kThreadMode_SecureDataRequest;
- if (aLinkMode->mDeviceType) numeric_mode |= kThreadMode_FullThreadDevice;
- if (aLinkMode->mNetworkData) numeric_mode |= kThreadMode_FullNetworkData;
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_THREAD_MODE,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- numeric_mode);
- }
- else if (OutBufferLength >= sizeof(otLinkModeConfig))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otLinkMode_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_MODE,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otLinkMode_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_MODE)
- {
- uint8_t numeric_mode = 0;
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, &numeric_mode))
- {
- otLinkModeConfig* aLinkMode = (otLinkModeConfig*)OutBuffer;
-
- aLinkMode->mRxOnWhenIdle = ((numeric_mode & kThreadMode_RxOnWhenIdle) == kThreadMode_RxOnWhenIdle);
- aLinkMode->mSecureDataRequests = ((numeric_mode & kThreadMode_SecureDataRequest) == kThreadMode_SecureDataRequest);
- aLinkMode->mDeviceType = ((numeric_mode & kThreadMode_FullThreadDevice) == kThreadMode_FullThreadDevice);
- aLinkMode->mNetworkData = ((numeric_mode & kThreadMode_FullNetworkData) == kThreadMode_FullNetworkData);
-
- *OutBufferLength = sizeof(otLinkModeConfig);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otMasterKey(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otMasterKey))
- {
- status = ThreadErrorToNtstatus(otThreadSetMasterKey(pFilter->otCtx, (otMasterKey*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(otMasterKey))
- {
- const otMasterKey* aMasterKey = otThreadGetMasterKey(pFilter->otCtx);
- memcpy(OutBuffer, aMasterKey, sizeof(otMasterKey));
- *OutBufferLength = sizeof(otMasterKey);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otMasterKey(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otMasterKey))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_NET_MASTER_KEY,
- sizeof(otMasterKey) + sizeof(uint16_t),
- SPINEL_DATATYPE_DATA_S,
- (otMasterKey*)InBuffer,
- sizeof(otMasterKey));
- }
- else if (OutBufferLength >= sizeof(otMasterKey))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otMasterKey_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_NET_MASTER_KEY,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otMasterKey_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_NET_MASTER_KEY)
- {
- uint8_t *data = NULL;
- spinel_size_t aKeyLength;
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_DATA_S, &data, &aKeyLength) && data != NULL &&
- aKeyLength == sizeof(otMasterKey))
- {
- memcpy(OutBuffer, data, sizeof(otMasterKey));
- *OutBufferLength = sizeof(otMasterKey);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otPSKc(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otPSKc))
- {
- status = ThreadErrorToNtstatus(otThreadSetPSKc(pFilter->otCtx, (otPSKc*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(otPSKc))
- {
- const otPSKc* aPSKc = otThreadGetPSKc(pFilter->otCtx);
- memcpy(OutBuffer, aPSKc, sizeof(otPSKc));
- *OutBufferLength = sizeof(otPSKc);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otPSKc(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otPSKc))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_NET_PSKC,
- sizeof(otPSKc) + sizeof(uint16_t),
- SPINEL_DATATYPE_DATA_S,
- (otPSKc*)InBuffer,
- OT_PSKC_MAX_SIZE);
- }
- else if (OutBufferLength >= sizeof(otPSKc))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otPSKc_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_NET_PSKC,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otPSKc_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_NET_PSKC)
- {
- uint8_t *data = NULL;
- spinel_size_t aPSKcLength;
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_DATA_S, &data, &aPSKcLength) && data != NULL &&
- aPSKcLength == sizeof(otPSKc))
- {
- memcpy(OutBuffer, data, sizeof(otPSKc));
- *OutBufferLength = sizeof(otPSKc);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otLinkLocalAddress(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(otIp6Address))
- {
- memcpy(OutBuffer, otThreadGetLinkLocalIp6Address(pFilter->otCtx), sizeof(otIp6Address));
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRloc(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(otIp6Address))
- {
- memcpy(OutBuffer, otThreadGetRloc(pFilter->otCtx), sizeof(otIp6Address));
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otMeshLocalEid(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(otIp6Address))
- {
- memcpy(OutBuffer, otThreadGetMeshLocalEid(pFilter->otCtx), sizeof(otIp6Address));
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otMeshLocalEid(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (OutBufferLength >= sizeof(otIp6Address))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otMeshLocalEid_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_IPV6_ML_ADDR,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otMeshLocalEid_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_IPV6_ML_ADDR)
- {
- spinel_ipv6addr_t *data = NULL;
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_IPv6ADDR_S, &data) && data != NULL)
- {
- memcpy(OutBuffer, data, sizeof(spinel_ipv6addr_t));
- *OutBufferLength = sizeof(otIp6Address);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otMeshLocalPrefix(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otMeshLocalPrefix))
- {
- status = ThreadErrorToNtstatus(otThreadSetMeshLocalPrefix(pFilter->otCtx, (otMeshLocalPrefix*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(otMeshLocalPrefix))
- {
- const otMeshLocalPrefix* aMeshLocalPrefix = otThreadGetMeshLocalPrefix(pFilter->otCtx);
- memcpy(OutBuffer, aMeshLocalPrefix, sizeof(otMeshLocalPrefix));
- *OutBufferLength = sizeof(otMeshLocalPrefix);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otMeshLocalPrefix(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otMeshLocalPrefix))
- {
- otIp6Address aAddress = {0};
- memcpy(&aAddress, InBuffer, sizeof(otMeshLocalPrefix));
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_IPV6_ML_PREFIX,
- sizeof(otIp6Address),
- SPINEL_DATATYPE_IPv6ADDR_S,
- &aAddress);
- }
- else if (OutBufferLength >= sizeof(otMeshLocalPrefix))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otMeshLocalPrefix_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_IPV6_ML_PREFIX,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otMeshLocalPrefix_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_IPV6_ML_PREFIX)
- {
- if (DataLength >= sizeof(otMeshLocalPrefix))
- {
- memcpy(OutBuffer, Data, sizeof(otMeshLocalPrefix));
- *OutBufferLength = sizeof(otMeshLocalPrefix);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-// otLwfIoCtl_otNetworkDataLeader
-
-// otLwfIoCtl_otNetworkDataLocal
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otNetworkName(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otNetworkName))
- {
- status = ThreadErrorToNtstatus(otThreadSetNetworkName(pFilter->otCtx, (char*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(otNetworkName))
- {
- strcpy_s((char*)OutBuffer, sizeof(otNetworkName), otThreadGetNetworkName(pFilter->otCtx));
- *OutBufferLength = sizeof(otNetworkName);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otNetworkName(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otNetworkName))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_NET_NETWORK_NAME,
- sizeof(otIp6Address),
- SPINEL_DATATYPE_UTF8_S,
- (otNetworkName*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(otNetworkName))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otNetworkName_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_NET_NETWORK_NAME,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otNetworkName_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_NET_NETWORK_NAME)
- {
- const char *data = NULL;
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UTF8_S, &data) && data != NULL)
- {
- strcpy_s(OutBuffer, sizeof(otNetworkName), data);
- *OutBufferLength = sizeof(otNetworkName);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otPanId(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otPanId))
- {
- status = ThreadErrorToNtstatus(otLinkSetPanId(pFilter->otCtx, *(otPanId*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(otPanId))
- {
- *(otPanId*)OutBuffer = otLinkGetPanId(pFilter->otCtx);
- *OutBufferLength = sizeof(otPanId);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otPanId(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otPanId))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_MAC_15_4_PANID,
- sizeof(otPanId),
- SPINEL_DATATYPE_UINT16_S,
- *(otPanId*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(otPanId))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otPanId_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_MAC_15_4_PANID,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otPanId_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_MAC_15_4_PANID)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT16_S, (otPanId*)OutBuffer))
- {
- *OutBufferLength = sizeof(otPanId);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRouterRollEnabled(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN))
- {
- otThreadSetRouterRoleEnabled(pFilter->otCtx, *(BOOLEAN*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(BOOLEAN))
- {
- *(BOOLEAN*)OutBuffer = otThreadIsRouterRoleEnabled(pFilter->otCtx) ? TRUE : FALSE;
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRouterRollEnabled(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_THREAD_ROUTER_ROLE_ENABLED,
- sizeof(BOOLEAN),
- SPINEL_DATATYPE_BOOL_S,
- *(BOOLEAN*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(BOOLEAN))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otRouterRollEnabled_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_ROUTER_ROLE_ENABLED,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRouterRollEnabled_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_ROUTER_ROLE_ENABLED)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_BOOL_S, (BOOLEAN*)OutBuffer))
- {
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otShortAddress(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(otShortAddress))
- {
- *(otShortAddress*)OutBuffer = otLinkGetShortAddress(pFilter->otCtx);
- *OutBufferLength = sizeof(otShortAddress);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otShortAddress(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (OutBufferLength >= sizeof(otShortAddress))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otShortAddress_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_MAC_15_4_SADDR,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otShortAddress_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_MAC_15_4_SADDR)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT16_S, (otShortAddress*)OutBuffer))
- {
- *OutBufferLength = sizeof(otShortAddress);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-// otLwfIoCtl_otUnicastAddresses
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otActiveDataset(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otOperationalDataset))
- {
- status = ThreadErrorToNtstatus(otDatasetSetActive(pFilter->otCtx, (otOperationalDataset*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(otOperationalDataset))
- {
- status = ThreadErrorToNtstatus(otDatasetGetActive(pFilter->otCtx, (otOperationalDataset*)OutBuffer));
- *OutBufferLength = sizeof(otOperationalDataset);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otPendingDataset(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(otOperationalDataset))
- {
- status = ThreadErrorToNtstatus(otDatasetSetPending(pFilter->otCtx, (otOperationalDataset*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(otOperationalDataset))
- {
- status = ThreadErrorToNtstatus(otDatasetGetPending(pFilter->otCtx, (otOperationalDataset*)OutBuffer));
- *OutBufferLength = sizeof(otOperationalDataset);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otLocalLeaderWeight(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- otThreadSetLocalLeaderWeight(pFilter->otCtx, *(uint8_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otThreadGetLeaderWeight(pFilter->otCtx);
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otLocalLeaderWeight(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_THREAD_LOCAL_LEADER_WEIGHT,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- *(uint8_t*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otLocalLeaderWeight_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_LOCAL_LEADER_WEIGHT,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otLocalLeaderWeight_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_LOCAL_LEADER_WEIGHT)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, (uint8_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otAddBorderRouter(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(otBorderRouterConfig))
- {
- status = ThreadErrorToNtstatus(otBorderRouterAddOnMeshPrefix(pFilter->otCtx, (otBorderRouterConfig*)InBuffer));
- }
-
- return status;
-}
-
-const uint8_t kPreferenceOffset = 6;
-//const uint8_t kPreferenceMask = 3 << kPreferenceOffset;
-const uint8_t kPreferredFlag = 1 << 5;
-const uint8_t kSlaacFlag = 1 << 4;
-const uint8_t kDhcpFlag = 1 << 3;
-const uint8_t kConfigureFlag = 1 << 2;
-const uint8_t kDefaultRouteFlag = 1 << 1;
-const uint8_t kOnMeshFlag = 1 << 0;
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otAddBorderRouter(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- if (InBufferLength >= sizeof(otBorderRouterConfig))
- {
- const otBorderRouterConfig *aConfig = (otBorderRouterConfig*)InBuffer;
-
- otIp6Address prefix = {0};
- memcpy_s(&prefix, sizeof(prefix), &aConfig->mPrefix.mPrefix, aConfig->mPrefix.mLength);
-
- uint8_t flags = (uint8_t)(aConfig->mPreference << kPreferenceOffset);
- if (aConfig->mSlaac) flags |= kSlaacFlag;
- if (aConfig->mDhcp) flags |= kDhcpFlag;
- if (aConfig->mConfigure) flags |= kConfigureFlag;
- if (aConfig->mDefaultRoute) flags |= kDefaultRouteFlag;
- if (aConfig->mOnMesh) flags |= kOnMeshFlag;
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_INSERT,
- SPINEL_PROP_THREAD_ON_MESH_NETS,
- sizeof(otIp6Address) + 3 * sizeof(uint8_t),
- "6CbC",
- &prefix,
- aConfig->mPrefix.mLength,
- aConfig->mStable,
- flags);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRemoveBorderRouter(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(otIp6Prefix))
- {
- status = ThreadErrorToNtstatus(otBorderRouterRemoveOnMeshPrefix(pFilter->otCtx, (otIp6Prefix*)InBuffer));
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRemoveBorderRouter(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- if (InBufferLength >= sizeof(otIp6Prefix))
- {
- const otIp6Prefix *aPrefix = (otIp6Prefix*)InBuffer;
-
- otIp6Address prefix = {0};
- memcpy_s(&prefix, sizeof(prefix), &aPrefix->mPrefix, aPrefix->mLength);
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_REMOVE,
- SPINEL_PROP_THREAD_ON_MESH_NETS,
- sizeof(otIp6Address) + sizeof(uint8_t),
- "6C",
- &prefix,
- aPrefix->mLength);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otAddExternalRoute(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(otExternalRouteConfig))
- {
- status = ThreadErrorToNtstatus(otBorderRouterAddRoute(pFilter->otCtx, (otExternalRouteConfig*)InBuffer));
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otAddExternalRoute(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- if (InBufferLength >= sizeof(otBorderRouterConfig))
- {
- const otBorderRouterConfig *aConfig = (otBorderRouterConfig*)InBuffer;
-
- otIp6Address prefix = {0};
- memcpy_s(&prefix, sizeof(prefix), &aConfig->mPrefix.mPrefix, aConfig->mPrefix.mLength);
-
- uint8_t flags = (uint8_t)(aConfig->mPreference << kPreferenceOffset);
- if (aConfig->mSlaac) flags |= kSlaacFlag;
- if (aConfig->mDhcp) flags |= kDhcpFlag;
- if (aConfig->mConfigure) flags |= kConfigureFlag;
- if (aConfig->mDefaultRoute) flags |= kDefaultRouteFlag;
- if (aConfig->mOnMesh) flags |= kOnMeshFlag;
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_INSERT,
- SPINEL_PROP_THREAD_OFF_MESH_ROUTES,
- sizeof(otIp6Address) + 3 * sizeof(uint8_t),
- "6CbC",
- &prefix,
- aConfig->mPrefix.mLength,
- aConfig->mStable,
- flags);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRemoveExternalRoute(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(otIp6Prefix))
- {
- status = ThreadErrorToNtstatus(otBorderRouterRemoveRoute(pFilter->otCtx, (otIp6Prefix*)InBuffer));
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRemoveExternalRoute(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- if (InBufferLength >= sizeof(otIp6Prefix))
- {
- const otIp6Prefix *aPrefix = (otIp6Prefix*)InBuffer;
-
- otIp6Address prefix = {0};
- memcpy_s(&prefix, sizeof(prefix), &aPrefix->mPrefix, aPrefix->mLength);
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_REMOVE,
- SPINEL_PROP_THREAD_OFF_MESH_ROUTES,
- sizeof(otIp6Address) + sizeof(uint8_t),
- "6C",
- &prefix,
- aPrefix->mLength);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otSendServerData(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- status = ThreadErrorToNtstatus(otBorderRouterRegister(pFilter->otCtx));
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otContextIdReuseDelay(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t))
- {
- otThreadSetContextIdReuseDelay(pFilter->otCtx, *(uint32_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint32_t))
- {
- *(uint32_t*)OutBuffer = otThreadGetContextIdReuseDelay(pFilter->otCtx);
- status = STATUS_SUCCESS;
- *OutBufferLength = sizeof(uint32_t);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otContextIdReuseDelay(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_THREAD_CONTEXT_REUSE_DELAY,
- sizeof(uint32_t),
- SPINEL_DATATYPE_UINT32_S,
- *(uint32_t*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(uint32_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otContextIdReuseDelay_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_CONTEXT_REUSE_DELAY,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otContextIdReuseDelay_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_CONTEXT_REUSE_DELAY)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT32_S, (uint32_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint32_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otKeySequenceCounter(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t))
- {
- otThreadSetKeySequenceCounter(pFilter->otCtx, *(uint32_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint32_t))
- {
- *(uint32_t*)OutBuffer = otThreadGetKeySequenceCounter(pFilter->otCtx);
- status = STATUS_SUCCESS;
- *OutBufferLength = sizeof(uint32_t);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otKeySequenceCounter(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_NET_KEY_SEQUENCE_COUNTER,
- sizeof(uint32_t),
- SPINEL_DATATYPE_UINT32_S,
- *(uint32_t*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(uint32_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otKeySequenceCounter_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_NET_KEY_SEQUENCE_COUNTER,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otKeySequenceCounter_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_NET_KEY_SEQUENCE_COUNTER)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT32_S, (uint32_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint32_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otNetworkIdTimeout(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- otThreadSetNetworkIdTimeout(pFilter->otCtx, *(uint8_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otThreadGetNetworkIdTimeout(pFilter->otCtx);
- status = STATUS_SUCCESS;
- *OutBufferLength = sizeof(uint8_t);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otNetworkIdTimeout(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_THREAD_NETWORK_ID_TIMEOUT,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- *(uint8_t*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otNetworkIdTimeout_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_NETWORK_ID_TIMEOUT,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otNetworkIdTimeout_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_NETWORK_ID_TIMEOUT)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, (uint8_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRouterUpgradeThreshold(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- otThreadSetRouterUpgradeThreshold(pFilter->otCtx, *(uint8_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otThreadGetRouterUpgradeThreshold(pFilter->otCtx);
- status = STATUS_SUCCESS;
- *OutBufferLength = sizeof(uint8_t);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRouterUpgradeThreshold(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_THREAD_ROUTER_UPGRADE_THRESHOLD,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- *(uint8_t*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otRouterUpgradeThreshold_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_ROUTER_UPGRADE_THRESHOLD,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRouterUpgradeThreshold_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_ROUTER_UPGRADE_THRESHOLD)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, (uint8_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRouterDowngradeThreshold(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- otThreadSetRouterDowngradeThreshold(pFilter->otCtx, *(uint8_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otThreadGetRouterDowngradeThreshold(pFilter->otCtx);
- status = STATUS_SUCCESS;
- *OutBufferLength = sizeof(uint8_t);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRouterDowngradeThreshold(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_THREAD_ROUTER_DOWNGRADE_THRESHOLD,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- *(uint8_t*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otRouterDowngradeThreshold_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_ROUTER_DOWNGRADE_THRESHOLD,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRouterDowngradeThreshold_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_ROUTER_DOWNGRADE_THRESHOLD)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, (uint8_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otReleaseRouterId(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- status = ThreadErrorToNtstatus(otThreadReleaseRouterId(pFilter->otCtx, *(uint8_t*)InBuffer));
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otReleaseRouterId(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_REMOVE,
- SPINEL_PROP_THREAD_ACTIVE_ROUTER_IDS,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- *(uint8_t*)InBuffer);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otMacWhitelistEnabled(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN))
- {
- BOOLEAN aEnabled = *(BOOLEAN*)InBuffer;
- otMacFilterAddressMode mode =
- aEnabled ? OT_MAC_FILTER_ADDRESS_MODE_WHITELIST : OT_MAC_FILTER_ADDRESS_MODE_DISABLED;
- status = ThreadErrorToNtstatus(otLinkFilterSetAddressMode(pFilter->otCtx, mode));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(BOOLEAN))
- {
- otMacFilterAddressMode mode = otLinkFilterGetAddressMode(pFilter->otCtx);
- *(BOOLEAN*)OutBuffer = (mode == OT_MAC_FILTER_ADDRESS_MODE_WHITELIST) ? TRUE : FALSE;
- status = STATUS_SUCCESS;
- *OutBufferLength = sizeof(BOOLEAN);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otMacWhitelistEnabled(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_MAC_WHITELIST_ENABLED,
- sizeof(BOOLEAN),
- SPINEL_DATATYPE_BOOL_S,
- *(BOOLEAN*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(BOOLEAN))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otMacWhitelistEnabled_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_MAC_WHITELIST_ENABLED,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otMacWhitelistEnabled_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_MAC_WHITELIST_ENABLED)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_BOOL_S, (BOOLEAN*)OutBuffer))
- {
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otAddMacWhitelist(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
- int8_t aRss = OT_MAC_FILTER_FIXED_RSS_DISABLED;
-
- if (InBufferLength >= sizeof(otExtAddress) + sizeof(int8_t))
- {
- aRss = *(int8_t*)(InBuffer + sizeof(otExtAddress));
- }
-
- otError error = otLinkFilterAddAddress(pFilter->otCtx, (otExtAddress *)InBuffer);
-
- if ((error == OT_ERROR_NONE || error == OT_ERROR_ALREADY) &&
- (aRss != OT_MAC_FILTER_FIXED_RSS_DISABLED))
- {
-
- error = otLinkFilterAddRssIn(pFilter->otCtx, (otExtAddress *)InBuffer, aRss);
- }
-
- status = ThreadErrorToNtstatus(error);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otAddMacWhitelist(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- if (InBufferLength >= sizeof(otExtAddress))
- {
- int8_t aRss = OT_MAC_FILTER_FIXED_RSS_DISABLED;
- if (InBufferLength >= sizeof(otExtAddress) + sizeof(int8_t))
- {
- aRss = *(int8_t*)(InBuffer + sizeof(otExtAddress));
- }
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_INSERT,
- SPINEL_PROP_MAC_WHITELIST,
- sizeof(otExtAddress) + sizeof(int8_t),
- "Ec",
- (otExtAddress*)InBuffer,
- &aRss);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRemoveMacWhitelist(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(otExtAddress))
- {
- status = ThreadErrorToNtstatus(otLinkFilterRemoveAddress(pFilter->otCtx,
- (otExtAddress *)InBuffer));
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRemoveMacWhitelist(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- if (InBufferLength >= sizeof(otExtAddress))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_REMOVE,
- SPINEL_PROP_MAC_WHITELIST,
- sizeof(otExtAddress),
- "E",
- (otExtAddress*)InBuffer);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otNextMacWhitelist(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t) &&
- *OutBufferLength >= sizeof(uint8_t) + sizeof(otMacFilterEntry))
- {
- uint8_t aIterator = *(uint8_t*)(InBuffer);
- otMacFilterEntry *aEntry = (otMacFilterEntry*)((PUCHAR)OutBuffer + sizeof(uint8_t));
-
- status = ThreadErrorToNtstatus(
- otLinkFilterGetNextAddress(
- pFilter->otCtx,
- &aIterator,
- aEntry
- )
- );
-
- *OutBufferLength = sizeof(otMacFilterEntry) + sizeof(uint8_t);
-
- if (status == STATUS_SUCCESS)
- {
- *(uint8_t*)OutBuffer = aIterator;
- }
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otClearMacWhitelist(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- otLinkFilterClearAddresses(pFilter->otCtx);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otClearMacWhitelist(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_MAC_WHITELIST,
- 0,
- NULL);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otDeviceRole(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- otDeviceRole role = *(uint8_t*)InBuffer;
-
- InBufferLength -= sizeof(uint8_t);
- InBuffer = InBuffer + sizeof(uint8_t);
-
- if (role == OT_DEVICE_ROLE_LEADER)
- {
- status = ThreadErrorToNtstatus(
- otThreadBecomeLeader(pFilter->otCtx)
- );
- }
- else if (role == OT_DEVICE_ROLE_ROUTER)
- {
- status = ThreadErrorToNtstatus(
- otThreadBecomeRouter(pFilter->otCtx)
- );
- }
- else if (role == OT_DEVICE_ROLE_CHILD)
- {
- status = ThreadErrorToNtstatus(
- otThreadBecomeChild(pFilter->otCtx)
- );
- }
- else if (role == OT_DEVICE_ROLE_DETACHED)
- {
- status = ThreadErrorToNtstatus(
- otThreadBecomeDetached(pFilter->otCtx)
- );
- }
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = (uint8_t)otThreadGetDeviceRole(pFilter->otCtx);
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otDeviceRole(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- otDeviceRole role = *(uint8_t*)InBuffer;
- uint8_t spinel_role = SPINEL_NET_ROLE_DETACHED;
-
- switch (role)
- {
- case OT_DEVICE_ROLE_CHILD:
- spinel_role = SPINEL_NET_ROLE_CHILD;
- break;
- case OT_DEVICE_ROLE_ROUTER:
- spinel_role = SPINEL_NET_ROLE_ROUTER;
- break;
- case OT_DEVICE_ROLE_LEADER:
- spinel_role = SPINEL_NET_ROLE_LEADER;
- break;
- }
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_NET_ROLE,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- spinel_role);
- }
- else if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otDeviceRole_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_NET_ROLE,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otDeviceRole_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_NET_ROLE)
- {
- uint8_t spinel_role = 0;
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, &spinel_role))
- {
- switch (spinel_role)
- {
- default:
- case SPINEL_NET_ROLE_DETACHED:
- *(uint8_t*)OutBuffer = OT_DEVICE_ROLE_DETACHED;
- break;
- case SPINEL_NET_ROLE_CHILD:
- *(uint8_t*)OutBuffer = OT_DEVICE_ROLE_CHILD;
- break;
- case SPINEL_NET_ROLE_ROUTER:
- *(uint8_t*)OutBuffer = OT_DEVICE_ROLE_ROUTER;
- break;
- case SPINEL_NET_ROLE_LEADER:
- *(uint8_t*)OutBuffer = OT_DEVICE_ROLE_LEADER;
- break;
- }
-
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otChildInfoById(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint16_t) &&
- *OutBufferLength >= sizeof(otChildInfo))
- {
- status = ThreadErrorToNtstatus(
- otThreadGetChildInfoById(
- pFilter->otCtx,
- *(uint16_t*)InBuffer,
- (otChildInfo*)OutBuffer)
- );
- *OutBufferLength = sizeof(otChildInfo);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otChildInfoByIndex(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t) &&
- *OutBufferLength >= sizeof(otChildInfo))
- {
- status = ThreadErrorToNtstatus(
- otThreadGetChildInfoByIndex(
- pFilter->otCtx,
- *(uint8_t*)InBuffer,
- (otChildInfo*)OutBuffer)
- );
- *OutBufferLength = sizeof(otChildInfo);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otEidCacheEntry(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t) &&
- *OutBufferLength >= sizeof(otEidCacheEntry))
- {
- status = ThreadErrorToNtstatus(
- otThreadGetEidCacheEntry(
- pFilter->otCtx,
- *(uint8_t*)InBuffer,
- (otEidCacheEntry*)OutBuffer)
- );
- *OutBufferLength = sizeof(otEidCacheEntry);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otLeaderData(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(otLeaderData))
- {
- status = ThreadErrorToNtstatus(otThreadGetLeaderData(pFilter->otCtx, (otLeaderData*)OutBuffer));
- *OutBufferLength = sizeof(otLeaderData);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otLeaderRouterId(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otThreadGetLeaderRouterId(pFilter->otCtx);
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otLeaderRouterId(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otLeaderRouterId_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_LEADER_RID,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otLeaderRouterId_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_LEADER_RID)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, (uint8_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otLeaderWeight(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otThreadGetLeaderWeight(pFilter->otCtx);
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otLeaderWeight(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otLeaderWeight_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_LEADER_WEIGHT,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otLeaderWeight_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_LEADER_WEIGHT)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, (uint8_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otNetworkDataVersion(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otNetDataGetVersion(pFilter->otCtx);
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otNetworkDataVersion(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otNetworkDataVersion_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_NETWORK_DATA_VERSION,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otNetworkDataVersion_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_NETWORK_DATA_VERSION)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, (uint8_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otPartitionId(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(uint32_t))
- {
- *(uint32_t*)OutBuffer = otThreadGetPartitionId(pFilter->otCtx);
- *OutBufferLength = sizeof(uint32_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otPartitionId(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (OutBufferLength >= sizeof(uint32_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otPartitionId_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_NET_PARTITION_ID,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otPartitionId_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_NET_PARTITION_ID)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT32_S, (uint32_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint32_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRloc16(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(uint16_t))
- {
- *(uint16_t*)OutBuffer = otThreadGetRloc16(pFilter->otCtx);
- *OutBufferLength = sizeof(uint16_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRloc16(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (OutBufferLength >= sizeof(uint16_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otRloc16_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_RLOC16,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRloc16_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_RLOC16)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT16_S, (uint16_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint16_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRouterIdSequence(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otThreadGetRouterIdSequence(pFilter->otCtx);
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otMaxRouterId(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otThreadGetMaxRouterId(pFilter->otCtx);
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRouterInfo(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint16_t) &&
- *OutBufferLength >= sizeof(otRouterInfo))
- {
- status = ThreadErrorToNtstatus(
- otThreadGetRouterInfo(
- pFilter->otCtx,
- *(uint16_t*)InBuffer,
- (otRouterInfo*)OutBuffer)
- );
- *OutBufferLength = sizeof(otRouterInfo);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otStableNetworkDataVersion(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otNetDataGetStableVersion(pFilter->otCtx);
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otStableNetworkDataVersion(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otStableNetworkDataVersion_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_STABLE_NETWORK_DATA_VERSION,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otStableNetworkDataVersion_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_STABLE_NETWORK_DATA_VERSION)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, (uint8_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otMacBlacklistEnabled(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN))
- {
- BOOLEAN aEnabled = *(BOOLEAN*)InBuffer;
- otMacFilterAddressMode mode =
- aEnabled ? OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST : OT_MAC_FILTER_ADDRESS_MODE_DISABLED;
- status = ThreadErrorToNtstatus(otLinkFilterSetAddressMode(pFilter->otCtx, mode));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(BOOLEAN))
- {
- otMacFilterAddressMode mode = otLinkFilterGetAddressMode(pFilter->otCtx);
- *(BOOLEAN*)OutBuffer = mode == (OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST) ? TRUE : FALSE;
- status = STATUS_SUCCESS;
- *OutBufferLength = sizeof(BOOLEAN);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otAddMacBlacklist(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(otExtAddress))
- {
- status = ThreadErrorToNtstatus(otLinkFilterAddAddress(pFilter->otCtx,
- (otExtAddress *)InBuffer));
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRemoveMacBlacklist(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(otExtAddress))
- {
- status = ThreadErrorToNtstatus(otLinkFilterRemoveAddress(pFilter->otCtx,
- (otExtAddress *)InBuffer));
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otNextMacBlacklist(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t) &&
- *OutBufferLength >= sizeof(uint8_t) + sizeof(otMacFilterEntry))
- {
- uint8_t aIterator = *(uint8_t*)(InBuffer);
- otMacFilterEntry *aEntry = (otMacFilterEntry*)((PUCHAR)OutBuffer + sizeof(uint8_t));
-
- status = ThreadErrorToNtstatus(
- otLinkFilterGetNextAddress(
- pFilter->otCtx,
- &aIterator,
- aEntry
- )
- );
-
- *OutBufferLength = sizeof(otMacFilterEntry) + sizeof(uint8_t);
-
- if (status == STATUS_SUCCESS)
- {
- *(uint8_t*)OutBuffer = aIterator;
- }
- }
-
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otClearMacBlacklist(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- otLinkFilterClearAddresses(pFilter->otCtx);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otTransmitPower(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(int8_t))
- {
- status = ThreadErrorToNtstatus(otPlatRadioSetTransmitPower(pFilter->otCtx, *(int8_t*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(int8_t))
- {
- status = ThreadErrorToNtstatus(otPlatRadioGetTransmitPower(pFilter->otCtx, (int8_t*)OutBuffer));
- *OutBufferLength = sizeof(int8_t);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otNextOnMeshPrefix(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN) + sizeof(uint32_t) &&
- *OutBufferLength >= sizeof(uint32_t) + sizeof(otBorderRouterConfig))
- {
- BOOLEAN aLocal = *(BOOLEAN*)InBuffer;
- uint32_t aIterator = *(uint32_t*)(InBuffer + sizeof(BOOLEAN));
- otBorderRouterConfig* aConfig = (otBorderRouterConfig*)((PUCHAR)OutBuffer + sizeof(uint32_t));
- if (aLocal)
- {
- status = ThreadErrorToNtstatus(
- otBorderRouterGetNextOnMeshPrefix(
- pFilter->otCtx,
- &aIterator,
- aConfig)
- );
- }
- else
- {
- status = ThreadErrorToNtstatus(
- otNetDataGetNextOnMeshPrefix(
- pFilter->otCtx,
- &aIterator,
- aConfig)
- );
- }
- *OutBufferLength = sizeof(uint8_t) + sizeof(otBorderRouterConfig);
- if (status == STATUS_SUCCESS)
- {
- *(uint32_t*)OutBuffer = aIterator;
- }
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otNextRoute(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN) + sizeof(uint32_t) &&
- *OutBufferLength >= sizeof(uint32_t) + sizeof(otExternalRouteConfig))
- {
- BOOLEAN aLocal = *(BOOLEAN*)InBuffer;
- uint32_t aIterator = *(uint32_t*)(InBuffer + sizeof(BOOLEAN));
- otExternalRouteConfig* aConfig = (otExternalRouteConfig*)((PUCHAR)OutBuffer + sizeof(uint32_t));
- if (aLocal)
- {
- status = ThreadErrorToNtstatus(
- otBorderRouterGetNextRoute(
- pFilter->otCtx,
- &aIterator,
- aConfig)
- );
- }
- else
- {
- status = ThreadErrorToNtstatus(
- otNetDataGetNextRoute(
- pFilter->otCtx,
- &aIterator,
- aConfig)
- );
- }
- *OutBufferLength = sizeof(uint8_t) + sizeof(otExternalRouteConfig);
- if (status == STATUS_SUCCESS)
- {
- *(uint32_t*)OutBuffer = aIterator;
- }
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otPollPeriod(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t))
- {
- status = ThreadErrorToNtstatus(otLinkSetPollPeriod(pFilter->otCtx, *(uint32_t*)InBuffer));
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint32_t))
- {
- *(uint32_t*)OutBuffer = otLinkGetPollPeriod(pFilter->otCtx);
- *OutBufferLength = sizeof(uint32_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otLocalLeaderPartitionId(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t))
- {
- otThreadSetLocalLeaderPartitionId(pFilter->otCtx, *(uint32_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint32_t))
- {
- *(uint32_t*)OutBuffer = otThreadGetLocalLeaderPartitionId(pFilter->otCtx);
- *OutBufferLength = sizeof(uint32_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otPlatformReset(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- otInstanceReset(pFilter->otCtx);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otFactoryReset(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- otInstanceFactoryReset(pFilter->otCtx);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otPlatformReset(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_RESET,
- 0,
- 0,
- NULL);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otParentInfo(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- static_assert(sizeof(otRouterInfo) == 20, "The size of otRouterInfo should be 20 bytes");
- if (*OutBufferLength >= sizeof(otRouterInfo))
- {
- status = ThreadErrorToNtstatus(otThreadGetParentInfo(pFilter->otCtx, (otRouterInfo*)OutBuffer));
- *OutBufferLength = sizeof(otRouterInfo);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otParentInfo(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (OutBufferLength >= sizeof(otRouterInfo))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otParentInfo_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_PARENT,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otParentInfo_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_PARENT)
- {
- otRouterInfo* aRouterInfo = (otRouterInfo*)OutBuffer;
- RtlZeroMemory(aRouterInfo, sizeof(otRouterInfo));
- if (try_spinel_datatype_unpack(Data, DataLength, "ES", &aRouterInfo->mExtAddress.m8, &aRouterInfo->mRloc16))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otSingleton(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(BOOLEAN))
- {
- *(BOOLEAN*)OutBuffer = otThreadIsSingleton(pFilter->otCtx) ? TRUE : FALSE;
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otMacCounters(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(otMacCounters))
- {
- memcpy_s(OutBuffer, *OutBufferLength, otLinkGetCounters(pFilter->otCtx), sizeof(otMacCounters));
- *OutBufferLength = sizeof(otMacCounters);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otMaxChildren(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- otThreadSetMaxAllowedChildren(pFilter->otCtx, *(uint8_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otThreadGetMaxAllowedChildren(pFilter->otCtx);
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otMaxChildren(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_THREAD_CHILD_COUNT_MAX,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- *(uint8_t*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otMaxChildren_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_CHILD_COUNT_MAX,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otMaxChildren_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_CHILD_COUNT_MAX)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, (uint8_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otCommissionerStart(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- return ThreadErrorToNtstatus(otCommissionerStart(pFilter->otCtx, NULL, NULL, NULL));
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otCommissionerStop(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- status = ThreadErrorToNtstatus(otCommissionerStop(pFilter->otCtx));
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otJoinerStart(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(otCommissionConfig))
- {
- otCommissionConfig *aConfig = (otCommissionConfig*)InBuffer;
-
-#define IsNotNullTerminated(buf) (strnlen(buf, sizeof(buf)) == sizeof(buf))
-
- if (IsNotNullTerminated(aConfig->PSKd) ||
- IsNotNullTerminated(aConfig->ProvisioningUrl) ||
- IsNotNullTerminated(aConfig->VendorName) ||
- IsNotNullTerminated(aConfig->VendorModel) ||
- IsNotNullTerminated(aConfig->VendorSwVersion) ||
- IsNotNullTerminated(aConfig->VendorData))
- {
- status = STATUS_INVALID_PARAMETER;
- }
- else
- {
- strcpy_s(pFilter->otVendorName, sizeof(pFilter->otVendorName), aConfig->VendorName);
- strcpy_s(pFilter->otVendorModel, sizeof(pFilter->otVendorModel), aConfig->VendorModel);
- strcpy_s(pFilter->otVendorSwVersion, sizeof(pFilter->otVendorSwVersion), aConfig->VendorSwVersion);
- strcpy_s(pFilter->otVendorData, sizeof(pFilter->otVendorData), aConfig->VendorData);
-
- status = ThreadErrorToNtstatus(
- otJoinerStart(
- pFilter->otCtx,
- aConfig->PSKd,
- aConfig->ProvisioningUrl,
- pFilter->otVendorName,
- pFilter->otVendorModel,
- pFilter->otVendorSwVersion,
- pFilter->otVendorData[0] == '\0' ? NULL : pFilter->otVendorData,
- otLwfJoinerCallback,
- pFilter)
- );
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otJoinerStop(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- status = ThreadErrorToNtstatus(otJoinerStop(pFilter->otCtx));
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otCommissionerPanIdQuery(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(uint16_t) + sizeof(uint32_t) + sizeof(otIp6Address))
- {
- uint16_t aPanId = *(uint16_t*)InBuffer;
- uint32_t aChannelMask = *(uint32_t*)(InBuffer + sizeof(uint16_t));
- const otIp6Address *aAddress = (otIp6Address*)(InBuffer + sizeof(uint16_t) + sizeof(uint32_t));
-
- status = ThreadErrorToNtstatus(
- otCommissionerPanIdQuery(
- pFilter->otCtx,
- aPanId,
- aChannelMask,
- aAddress,
- otLwfCommissionerPanIdConflictCallback,
- pFilter)
- );
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otCommissionerEnergyScan(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(otIp6Address))
- {
- uint32_t aChannelMask = *(uint32_t*)InBuffer;
- uint8_t aCount = *(uint8_t*)(InBuffer + sizeof(uint32_t));
- uint16_t aPeriod = *(uint16_t*)(InBuffer + sizeof(uint32_t) + sizeof(uint8_t));
- uint16_t aScanDuration = *(uint16_t*)(InBuffer + sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint16_t));
- const otIp6Address *aAddress = (otIp6Address*)(InBuffer + sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint16_t) + sizeof(uint16_t));
-
- status = ThreadErrorToNtstatus(
- otCommissionerEnergyScan(
- pFilter->otCtx,
- aChannelMask,
- aCount,
- aPeriod,
- aScanDuration,
- aAddress,
- otLwfCommissionerEnergyReportCallback,
- pFilter)
- );
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRouterSelectionJitter(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- otThreadSetRouterSelectionJitter(pFilter->otCtx, *(uint8_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint8_t))
- {
- *(uint8_t*)OutBuffer = otThreadGetRouterSelectionJitter(pFilter->otCtx);
- status = STATUS_SUCCESS;
- *OutBufferLength = sizeof(uint8_t);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRouterSelectionJitter(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_THREAD_ROUTER_SELECTION_JITTER,
- sizeof(uint8_t),
- SPINEL_DATATYPE_UINT8_S,
- *(uint8_t*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(uint8_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otRouterSelectionJitter_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_THREAD_ROUTER_SELECTION_JITTER,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRouterSelectionJitter_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_THREAD_ROUTER_SELECTION_JITTER)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT8_S, (uint8_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint8_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otJoinerUdpPort(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint16_t))
- {
- otThreadSetJoinerUdpPort(pFilter->otCtx, *(uint16_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint16_t))
- {
- *(uint16_t*)OutBuffer = otThreadGetJoinerUdpPort(pFilter->otCtx);
- status = STATUS_SUCCESS;
- *OutBufferLength = sizeof(uint16_t);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otSendDiagnosticGet(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(otIp6Address) + sizeof(uint8_t))
- {
- const otIp6Address *aAddress = (otIp6Address*)InBuffer;
- uint8_t aCount = *(uint8_t*)(InBuffer + sizeof(otIp6Address));
- PUCHAR aTlvTypes = InBuffer + sizeof(otIp6Address) + sizeof(uint8_t);
-
- if (InBufferLength >= sizeof(otIp6Address) + sizeof(uint8_t) + aCount)
- {
- status = ThreadErrorToNtstatus(
- otThreadSendDiagnosticGet(
- pFilter->otCtx,
- aAddress,
- aTlvTypes,
- aCount)
- );
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otSendDiagnosticReset(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(otIp6Address) + sizeof(uint8_t))
- {
- const otIp6Address *aAddress = (otIp6Address*)InBuffer;
- uint8_t aCount = *(uint8_t*)(InBuffer + sizeof(otIp6Address));
- PUCHAR aTlvTypes = InBuffer + sizeof(otIp6Address) + sizeof(uint8_t);
-
- if (InBufferLength >= sizeof(otIp6Address) + sizeof(uint8_t) + aCount)
- {
- status = ThreadErrorToNtstatus(
- otThreadSendDiagnosticReset(
- pFilter->otCtx,
- aAddress,
- aTlvTypes,
- aCount)
- );
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otCommissionerAddJoiner(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(uint8_t) + sizeof(otExtAddress))
- {
- const ULONG aPSKdBufferLength = InBufferLength - sizeof(uint8_t) - sizeof(otExtAddress) - sizeof(uint32_t);
-
- if (aPSKdBufferLength <= OPENTHREAD_PSK_MAX_LENGTH + 1)
- {
- uint8_t aExtAddressValid = *(uint8_t*)InBuffer;
- const otExtAddress *aExtAddress = aExtAddressValid == 0 ? NULL : (otExtAddress*)(InBuffer + sizeof(uint8_t));
- char *aPSKd = (char*)(InBuffer + sizeof(uint8_t) + sizeof(otExtAddress));
- uint32_t aTimeout = *(uint32_t*)(InBuffer + sizeof(uint8_t) + sizeof(otExtAddress) + aPSKdBufferLength);
-
- // Ensure aPSKd is NULL terminated in the buffer
- if (strnlen(aPSKd, aPSKdBufferLength) < aPSKdBufferLength)
- {
- status = ThreadErrorToNtstatus(otCommissionerAddJoiner(
- pFilter->otCtx, aExtAddress, aPSKd, aTimeout));
- }
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otCommissionerRemoveJoiner(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(uint8_t) + sizeof(otExtAddress))
- {
- uint8_t aExtAddressValid = *(uint8_t*)InBuffer;
- const otExtAddress *aExtAddress = aExtAddressValid == 0 ? NULL : (otExtAddress*)(InBuffer + sizeof(uint8_t));
- status = ThreadErrorToNtstatus(otCommissionerRemoveJoiner(
- pFilter->otCtx, aExtAddress));
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otCommissionerProvisioningUrl(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength <= OPENTHREAD_PROV_URL_MAX_LENGTH + 1)
- {
- char *aProvisioningUrl = InBufferLength > 1 ? (char*)InBuffer : NULL;
-
- // Ensure aProvisioningUrl is empty or NULL terminated in the buffer
- if (aProvisioningUrl == NULL ||
- strnlen(aProvisioningUrl, InBufferLength) < InBufferLength)
- {
- status = ThreadErrorToNtstatus(otCommissionerSetProvisioningUrl(
- pFilter->otCtx, aProvisioningUrl));
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otCommissionerAnnounceBegin(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint16_t) + sizeof(otIp6Address))
- {
- uint32_t aChannelMask = *(uint32_t*)InBuffer;
- uint8_t aCount = *(uint8_t*)(InBuffer + sizeof(uint32_t));
- uint16_t aPeriod = *(uint16_t*)(InBuffer + sizeof(uint32_t) + sizeof(uint8_t));
- const otIp6Address *aAddress = (otIp6Address*)(InBuffer + sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint16_t));
-
- if (InBufferLength >= sizeof(otIp6Address) + sizeof(uint8_t) + aCount)
- {
- status = ThreadErrorToNtstatus(
- otCommissionerAnnounceBegin(
- pFilter->otCtx,
- aChannelMask,
- aCount,
- aPeriod,
- aAddress)
- );
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otSendActiveGet(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(otOperationalDatasetComponents) + sizeof(uint8_t))
- {
- const otOperationalDatasetComponents *aDatasetComp = (otOperationalDatasetComponents*)InBuffer;
- uint8_t aLength = *(uint8_t*)(InBuffer + sizeof(otOperationalDatasetComponents));
- PUCHAR aTlvTypes = aLength == 0 ? NULL : InBuffer + sizeof(otOperationalDatasetComponents) + sizeof(uint8_t);
-
- if (InBufferLength >= sizeof(otOperationalDatasetComponents) + sizeof(uint8_t) + aLength)
- {
- otIp6Address *aAddress = NULL;
- if (InBufferLength >= sizeof(otOperationalDatasetComponents) + sizeof(uint8_t) + aLength + sizeof(otIp6Address))
- aAddress = (otIp6Address*)(InBuffer + sizeof(otOperationalDatasetComponents) + sizeof(uint8_t) + aLength);
-
- status = ThreadErrorToNtstatus(
- otDatasetSendMgmtActiveGet(
- pFilter->otCtx,
- aDatasetComp,
- aTlvTypes,
- aLength,
- aAddress)
- );
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otSendActiveSet(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(otOperationalDataset) + sizeof(uint8_t))
- {
- const otOperationalDataset *aDataset = (otOperationalDataset*)InBuffer;
- uint8_t aLength = *(uint8_t*)(InBuffer + sizeof(otOperationalDataset));
- PUCHAR aTlvTypes = aLength == 0 ? NULL : InBuffer + sizeof(otOperationalDataset) + sizeof(uint8_t);
-
- if (InBufferLength >= sizeof(otOperationalDataset) + sizeof(uint8_t) + aLength)
- {
- status = ThreadErrorToNtstatus(
- otDatasetSendMgmtActiveSet(
- pFilter->otCtx,
- aDataset,
- aTlvTypes,
- aLength)
- );
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otSendPendingGet(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(otOperationalDataset) + sizeof(uint8_t))
- {
- const otOperationalDatasetComponents *aDatasetComp = (otOperationalDatasetComponents*)InBuffer;
- uint8_t aLength = *(uint8_t*)(InBuffer + sizeof(otOperationalDataset));
- PUCHAR aTlvTypes = aLength == 0 ? NULL : InBuffer + sizeof(otOperationalDataset) + sizeof(uint8_t);
-
- if (InBufferLength >= sizeof(otOperationalDatasetComponents) + sizeof(uint8_t) + aLength)
- {
- otIp6Address *aAddress = NULL;
- if (InBufferLength >= sizeof(otOperationalDatasetComponents) + sizeof(uint8_t) + aLength + sizeof(otIp6Address))
- aAddress = (otIp6Address*)(InBuffer + sizeof(otOperationalDataset) + sizeof(uint8_t) + aLength);
-
- status = ThreadErrorToNtstatus(
- otDatasetSendMgmtPendingGet(
- pFilter->otCtx,
- aDatasetComp,
- aTlvTypes,
- aLength,
- aAddress)
- );
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otSendPendingSet(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(otOperationalDataset) + sizeof(uint8_t))
- {
- const otOperationalDataset *aDataset = (otOperationalDataset*)InBuffer;
- uint8_t aLength = *(uint8_t*)(InBuffer + sizeof(otOperationalDataset));
- PUCHAR aTlvTypes = aLength == 0 ? NULL : InBuffer + sizeof(otOperationalDataset) + sizeof(uint8_t);
-
- if (InBufferLength >= sizeof(otOperationalDataset) + sizeof(uint8_t) + aLength)
- {
- status = ThreadErrorToNtstatus(
- otDatasetSendMgmtPendingSet(
- pFilter->otCtx,
- aDataset,
- aTlvTypes,
- aLength)
- );
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otSendMgmtCommissionerGet(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- uint8_t aLength = *(uint8_t*)InBuffer;
- PUCHAR aTlvs = aLength == 0 ? NULL : InBuffer + sizeof(uint8_t);
-
- if (InBufferLength >= sizeof(uint8_t) + aLength)
- {
- status = ThreadErrorToNtstatus(
- otCommissionerSendMgmtGet(
- pFilter->otCtx,
- aTlvs,
- aLength)
- );
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otSendMgmtCommissionerSet(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(otCommissioningDataset) + sizeof(uint8_t))
- {
- const otCommissioningDataset *aDataset = (otCommissioningDataset*)InBuffer;
- uint8_t aLength = *(uint8_t*)(InBuffer + sizeof(otCommissioningDataset));
- PUCHAR aTlvs = aLength == 0 ? NULL : InBuffer + sizeof(otCommissioningDataset) + sizeof(uint8_t);
-
- if (InBufferLength >= sizeof(otCommissioningDataset) + sizeof(uint8_t) + aLength)
- {
- status = ThreadErrorToNtstatus(
- otCommissionerSendMgmtSet(
- pFilter->otCtx,
- aDataset,
- aTlvs,
- aLength)
- );
- }
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otKeySwitchGuardtime(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t))
- {
- otThreadSetKeySwitchGuardTime(pFilter->otCtx, *(uint32_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(uint32_t))
- {
- *(uint32_t*)OutBuffer = otThreadGetKeySwitchGuardTime(pFilter->otCtx);
- status = STATUS_SUCCESS;
- *OutBufferLength = sizeof(uint32_t);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otKeySwitchGuardtime(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint32_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_NET_KEY_SWITCH_GUARDTIME,
- sizeof(uint32_t),
- SPINEL_DATATYPE_UINT32_S,
- *(uint32_t*)InBuffer);
- }
- else if (OutBufferLength >= sizeof(uint32_t))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- otLwfTunIoCtl_otKeySwitchGuardtime_Handler,
- SPINEL_CMD_PROP_VALUE_GET,
- SPINEL_PROP_NET_KEY_SWITCH_GUARDTIME,
- 0,
- NULL);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otKeySwitchGuardtime_Handler(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
- if (Key == SPINEL_PROP_NET_KEY_SWITCH_GUARDTIME)
- {
- if (try_spinel_datatype_unpack(Data, DataLength, SPINEL_DATATYPE_UINT32_S, (uint32_t*)OutBuffer))
- {
- *OutBufferLength = sizeof(uint32_t);
- status = STATUS_SUCCESS;
- }
- }
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otThreadAutoStart(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(BOOLEAN))
- {
- status =
- ThreadErrorToNtstatus(
- otThreadSetAutoStart(
- pFilter->otCtx,
- *(BOOLEAN*)InBuffer != FALSE)
- );
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(BOOLEAN))
- {
- *(BOOLEAN*)OutBuffer = otThreadGetAutoStart(pFilter->otCtx) ? TRUE : FALSE;
- *OutBufferLength = sizeof(BOOLEAN);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otThreadPreferredRouterId(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- *OutBufferLength = 0;
- UNREFERENCED_PARAMETER(OutBuffer);
-
- if (InBufferLength >= sizeof(uint8_t))
- {
- status =
- ThreadErrorToNtstatus(
- otThreadSetPreferredRouterId(
- pFilter->otCtx,
- *(uint8_t*)InBuffer != FALSE)
- );
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otParentPriority(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(int8_t))
- {
- otThreadSetParentPriority(pFilter->otCtx, *(int8_t*)InBuffer);
- status = STATUS_SUCCESS;
- *OutBufferLength = 0;
- }
- else if (*OutBufferLength >= sizeof(int8_t))
- {
- *(uint16_t*)OutBuffer = otThreadGetParentPriority(pFilter->otCtx);
- status = STATUS_SUCCESS;
- *OutBufferLength = sizeof(int8_t);
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otAddMacFixedRss(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(otExtAddress) + sizeof(int8_t))
- {
- int8_t aRss = *(int8_t*)(InBuffer + sizeof(otExtAddress));
- status = ThreadErrorToNtstatus(otLinkFilterAddRssIn(pFilter->otCtx,
- (otExtAddress *)InBuffer, aRss));
- }
- else if (InBufferLength >= sizeof(int8_t))
- {
- status = ThreadErrorToNtstatus(otLinkFilterAddRssIn(pFilter->otCtx, NULL,
- *(int8_t *)InBuffer));
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otAddMacFixedRss(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- if (InBufferLength >= sizeof(otExtAddress) + sizeof(int8_t))
- {
- int8_t aRss = OT_MAC_FILTER_FIXED_RSS_DISABLED;
- aRss = *(int8_t*)(InBuffer + sizeof(otExtAddress));
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_INSERT,
- SPINEL_PROP_MAC_FIXED_RSS,
- sizeof(otExtAddress) + sizeof(int8_t),
- "Ec",
- (otExtAddress*)InBuffer,
- &aRss);
- }
- else
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_INSERT,
- SPINEL_PROP_MAC_FIXED_RSS,
- sizeof(int8_t),
- "c",
- (int8_t*)InBuffer);
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otRemoveMacFixedRss(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- if (InBufferLength >= sizeof(otExtAddress))
- {
- status = ThreadErrorToNtstatus(otLinkFilterRemoveRssIn(pFilter->otCtx, (otExtAddress *)InBuffer));
- }
- else
- {
- status = ThreadErrorToNtstatus(otLinkFilterRemoveRssIn(pFilter->otCtx, NULL));
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otRemoveMacFixedRss(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- if (InBufferLength >= sizeof(otExtAddress))
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_REMOVE,
- SPINEL_PROP_MAC_FIXED_RSS,
- sizeof(otExtAddress),
- "E",
- (otExtAddress*)InBuffer);
- }
- else
- {
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_REMOVE,
- SPINEL_PROP_MAC_FIXED_RSS,
- 0,
- NULL);
-
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otClearMacFixedRss(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBuffer);
- *OutBufferLength = 0;
-
- otLinkFilterClearRssIn(pFilter->otCtx);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunIoCtl_otClearMacFixedRss(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP pIrp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
- UNREFERENCED_PARAMETER(OutBufferLength);
-
- status =
- otLwfTunSendCommandForIrp(
- pFilter,
- pIrp,
- NULL,
- SPINEL_CMD_PROP_VALUE_SET,
- SPINEL_PROP_MAC_FIXED_RSS,
- 0,
- NULL);
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otNextMacFixedRss(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- if (InBufferLength >= sizeof(uint8_t) &&
- *OutBufferLength >= sizeof(uint8_t) + sizeof(otMacFilterEntry))
- {
- uint8_t aIterator = *(uint8_t*)(InBuffer);
- otMacFilterEntry *aEntry = (otMacFilterEntry*)((PUCHAR)OutBuffer + sizeof(uint8_t));
-
- status = ThreadErrorToNtstatus(
- otLinkFilterGetNextRssIn(
- pFilter->otCtx,
- &aIterator,
- aEntry
- )
- );
-
- *OutBufferLength = sizeof(otMacFilterEntry) + sizeof(uint8_t);
-
- if (status == STATUS_SUCCESS)
- {
- *(uint8_t*)OutBuffer = aIterator;
- }
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtl_otMleCounters(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- )
-{
- NTSTATUS status = STATUS_INVALID_PARAMETER;
-
- UNREFERENCED_PARAMETER(InBuffer);
- UNREFERENCED_PARAMETER(InBufferLength);
-
- if (*OutBufferLength >= sizeof(otMleCounters))
- {
- memcpy_s(OutBuffer, *OutBufferLength, otThreadGetMleCounters(pFilter->otCtx), sizeof(otMleCounters));
- *OutBufferLength = sizeof(otMleCounters);
- status = STATUS_SUCCESS;
- }
- else
- {
- *OutBufferLength = 0;
- }
-
- return status;
-}
diff --git a/examples/drivers/windows/otLwf/iocontrol.h b/examples/drivers/windows/otLwf/iocontrol.h
deleted file mode 100644
index 71bde2154..000000000
--- a/examples/drivers/windows/otLwf/iocontrol.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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 _IOCONTROL_H
-#define _IOCONTROL_H
-
-//
-// Function prototype for general Io Control functions
-//
-
-typedef
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-OTLWF_IOCTL_FUNC(
- _In_reads_bytes_(InBufferLength)
- PVOID InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- );
-
-//
-// General Io Control Functions
-//
-
-// Handles queries for the current list of Thread interfaces
-OTLWF_IOCTL_FUNC otLwfIoCtlEnumerateInterfaces;
-
-// Handles queries for the details of a specific Thread interface
-OTLWF_IOCTL_FUNC otLwfIoCtlQueryInterface;
-
-// Handles IOTCLs for OpenThread control
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfIoCtlOpenThreadControl(
- _In_ PIRP Irp
- );
-
-// Handles Irp for IOTCLs for OpenThread control on the OpenThread thread
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfCompleteOpenThreadIrp(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP Irp
- );
-
-// Helper for converting IoCtl to string
-const char*
-IoCtlString(
- ULONG IoControlCode
- );
-
-//
-// Function prototype for OpenThread Io Control functions
-//
-
-typedef
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-OTLWF_OT_IOCTL_FUNC(
- _In_ PMS_FILTER pFilter,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- );
-
-typedef
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-OTLWF_TUN_IOCTL_FUNC(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP Irp,
- _In_reads_bytes_(InBufferLength)
- PUCHAR InBuffer,
- _In_ ULONG InBufferLength,
- _In_ ULONG OutBufferLength
- );
-
-typedef
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-(SPINEL_IRP_CMD_HANDLER)(
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength,
- _Out_writes_bytes_(*OutBufferLength)
- PVOID OutBuffer,
- _Inout_ PULONG OutBufferLength
- );
-
-#define DECL_IOCTL_FUNC(X) \
- OTLWF_OT_IOCTL_FUNC otLwfIoCtl_##X
-
-#define DECL_IOCTL_FUNC_WITH_TUN(X) \
- OTLWF_OT_IOCTL_FUNC otLwfIoCtl_##X; \
- OTLWF_TUN_IOCTL_FUNC otLwfTunIoCtl_##X
-
-#define DECL_IOCTL_FUNC_WITH_TUN2(X) \
- OTLWF_OT_IOCTL_FUNC otLwfIoCtl_##X; \
- OTLWF_TUN_IOCTL_FUNC otLwfTunIoCtl_##X; \
- SPINEL_IRP_CMD_HANDLER otLwfTunIoCtl_##X##_Handler
-
-#define REF_IOCTL_FUNC(X) otLwfIoCtl_##X , NULL
-
-#define REF_IOCTL_FUNC_WITH_TUN(X) otLwfIoCtl_##X , otLwfTunIoCtl_##X
-
-DECL_IOCTL_FUNC_WITH_TUN2(otInterface);
-DECL_IOCTL_FUNC_WITH_TUN2(otThread);
-DECL_IOCTL_FUNC_WITH_TUN2(otActiveScan);
-DECL_IOCTL_FUNC(otDiscover);
-DECL_IOCTL_FUNC_WITH_TUN2(otChannel);
-DECL_IOCTL_FUNC_WITH_TUN2(otChildTimeout);
-DECL_IOCTL_FUNC_WITH_TUN2(otExtendedAddress);
-DECL_IOCTL_FUNC_WITH_TUN2(otExtendedPanId);
-DECL_IOCTL_FUNC_WITH_TUN2(otLeaderRloc);
-DECL_IOCTL_FUNC_WITH_TUN2(otLinkMode);
-DECL_IOCTL_FUNC_WITH_TUN2(otMasterKey);
-DECL_IOCTL_FUNC_WITH_TUN2(otMeshLocalEid);
-DECL_IOCTL_FUNC_WITH_TUN2(otMeshLocalPrefix);
-//DECL_IOCTL_FUNC(otNetworkDataLeader);
-//DECL_IOCTL_FUNC(otNetworkDataLocal);
-DECL_IOCTL_FUNC_WITH_TUN2(otNetworkName);
-DECL_IOCTL_FUNC_WITH_TUN2(otPanId);
-DECL_IOCTL_FUNC_WITH_TUN2(otRouterRollEnabled);
-DECL_IOCTL_FUNC_WITH_TUN2(otShortAddress);
-DECL_IOCTL_FUNC(otActiveDataset);
-DECL_IOCTL_FUNC(otPendingDataset);
-DECL_IOCTL_FUNC_WITH_TUN2(otLocalLeaderWeight);
-DECL_IOCTL_FUNC_WITH_TUN(otAddBorderRouter);
-DECL_IOCTL_FUNC_WITH_TUN(otRemoveBorderRouter);
-DECL_IOCTL_FUNC_WITH_TUN(otAddExternalRoute);
-DECL_IOCTL_FUNC_WITH_TUN(otRemoveExternalRoute);
-DECL_IOCTL_FUNC(otSendServerData);
-DECL_IOCTL_FUNC_WITH_TUN2(otContextIdReuseDelay);
-DECL_IOCTL_FUNC_WITH_TUN2(otKeySequenceCounter);
-DECL_IOCTL_FUNC_WITH_TUN2(otNetworkIdTimeout);
-DECL_IOCTL_FUNC_WITH_TUN2(otRouterUpgradeThreshold);
-DECL_IOCTL_FUNC_WITH_TUN(otReleaseRouterId);
-DECL_IOCTL_FUNC_WITH_TUN2(otMacWhitelistEnabled);
-DECL_IOCTL_FUNC_WITH_TUN(otAddMacWhitelist);
-DECL_IOCTL_FUNC_WITH_TUN(otRemoveMacWhitelist);
-DECL_IOCTL_FUNC(otNextMacWhitelist);
-DECL_IOCTL_FUNC_WITH_TUN(otClearMacWhitelist);
-DECL_IOCTL_FUNC_WITH_TUN2(otDeviceRole);
-DECL_IOCTL_FUNC(otChildInfoById);
-DECL_IOCTL_FUNC(otChildInfoByIndex);
-DECL_IOCTL_FUNC(otEidCacheEntry);
-DECL_IOCTL_FUNC(otLeaderData);
-DECL_IOCTL_FUNC_WITH_TUN2(otLeaderRouterId);
-DECL_IOCTL_FUNC_WITH_TUN2(otLeaderWeight);
-DECL_IOCTL_FUNC_WITH_TUN2(otNetworkDataVersion);
-DECL_IOCTL_FUNC_WITH_TUN2(otPartitionId);
-DECL_IOCTL_FUNC_WITH_TUN2(otRloc16);
-DECL_IOCTL_FUNC(otRouterIdSequence);
-DECL_IOCTL_FUNC(otMaxRouterId);
-DECL_IOCTL_FUNC(otRouterInfo);
-DECL_IOCTL_FUNC_WITH_TUN2(otStableNetworkDataVersion);
-DECL_IOCTL_FUNC(otMacBlacklistEnabled);
-DECL_IOCTL_FUNC(otAddMacBlacklist);
-DECL_IOCTL_FUNC(otRemoveMacBlacklist);
-DECL_IOCTL_FUNC(otNextMacBlacklist);
-DECL_IOCTL_FUNC(otClearMacBlacklist);
-DECL_IOCTL_FUNC(otTransmitPower);
-DECL_IOCTL_FUNC(otNextOnMeshPrefix);
-DECL_IOCTL_FUNC(otPollPeriod);
-DECL_IOCTL_FUNC(otLocalLeaderPartitionId);
-DECL_IOCTL_FUNC_WITH_TUN(otPlatformReset);
-DECL_IOCTL_FUNC_WITH_TUN2(otParentInfo);
-DECL_IOCTL_FUNC(otSingleton);
-DECL_IOCTL_FUNC(otMacCounters);
-DECL_IOCTL_FUNC_WITH_TUN2(otMaxChildren);
-DECL_IOCTL_FUNC(otCommissionerStart);
-DECL_IOCTL_FUNC(otCommissionerStop);
-DECL_IOCTL_FUNC(otJoinerStart);
-DECL_IOCTL_FUNC(otJoinerStop);
-DECL_IOCTL_FUNC(otFactoryAssignedIeeeEui64);
-DECL_IOCTL_FUNC(otJoinerId);
-DECL_IOCTL_FUNC_WITH_TUN2(otRouterDowngradeThreshold);
-DECL_IOCTL_FUNC(otCommissionerPanIdQuery);
-DECL_IOCTL_FUNC(otCommissionerEnergyScan);
-DECL_IOCTL_FUNC_WITH_TUN2(otRouterSelectionJitter);
-DECL_IOCTL_FUNC(otJoinerUdpPort);
-DECL_IOCTL_FUNC(otSendDiagnosticGet);
-DECL_IOCTL_FUNC(otSendDiagnosticReset);
-DECL_IOCTL_FUNC(otCommissionerAddJoiner);
-DECL_IOCTL_FUNC(otCommissionerRemoveJoiner);
-DECL_IOCTL_FUNC(otCommissionerProvisioningUrl);
-DECL_IOCTL_FUNC(otCommissionerAnnounceBegin);
-DECL_IOCTL_FUNC_WITH_TUN2(otEnergyScan);
-DECL_IOCTL_FUNC(otSendActiveGet);
-DECL_IOCTL_FUNC(otSendActiveSet);
-DECL_IOCTL_FUNC(otSendPendingGet);
-DECL_IOCTL_FUNC(otSendPendingSet);
-DECL_IOCTL_FUNC(otSendMgmtCommissionerGet);
-DECL_IOCTL_FUNC(otSendMgmtCommissionerSet);
-DECL_IOCTL_FUNC_WITH_TUN2(otKeySwitchGuardtime);
-DECL_IOCTL_FUNC(otFactoryReset);
-DECL_IOCTL_FUNC(otThreadAutoStart);
-DECL_IOCTL_FUNC(otThreadPreferredRouterId);
-DECL_IOCTL_FUNC_WITH_TUN2(otPSKc);
-DECL_IOCTL_FUNC(otParentPriority);
-DECL_IOCTL_FUNC_WITH_TUN(otAddMacFixedRss);
-DECL_IOCTL_FUNC_WITH_TUN(otRemoveMacFixedRss);
-DECL_IOCTL_FUNC(otNextMacFixedRss);
-DECL_IOCTL_FUNC_WITH_TUN(otClearMacFixedRss);
-DECL_IOCTL_FUNC(otNextRoute);
-DECL_IOCTL_FUNC(otMleCounters);
-DECL_IOCTL_FUNC(otLinkLocalAddress);
-DECL_IOCTL_FUNC(otRloc);
-
-#endif // _IOCONTROL_H
diff --git a/examples/drivers/windows/otLwf/nsihelper.h b/examples/drivers/windows/otLwf/nsihelper.h
deleted file mode 100644
index c3831995e..000000000
--- a/examples/drivers/windows/otLwf/nsihelper.h
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines the various types and function required to use NSI to
- * query an interface's compartment ID.
- */
-
-#ifndef _NSI_HELPER_H
-#define _NSI_HELPER_H
-
-#define NSISTATUS NTSTATUS
-
-typedef enum _NSI_STORE {
- NsiPersistent,
- // Persists as long as module exists.
- NsiActive,
- NsiBoth,
- NsiCurrent,
- NsiBootFirmwareTable
-} NSI_STORE;
-
-typedef enum _NSI_SET_ACTION {
- NsiSetDefault,
- NsiSetCreateOnly,
- NsiSetCreateOrSet,
- NsiSetDelete,
- NsiSetReset,
- NsiSetClear,
- NsiSetCreateOrSetWithReference,
- NsiSetDeleteWithReference,
-} NSI_SET_ACTION;
-
-typedef enum _NSI_STRUCT_TYPE {
- NsiStructRw,
- NsiStructRoDynamic,
- NsiStructRoStatic,
- NsiMaximumStructType
-} NSI_STRUCT_TYPE;
-
-typedef struct _NL_INTERFACE_KEY {
- IF_LUID Luid;
-} NL_INTERFACE_KEY, *PNL_INTERFACE_KEY;
-
-typedef enum _NL_TYPE_OF_INTERFACE {
- InterfaceAllowAll = 0,
- InterfaceDisallowUnicast,
- InterfaceDisallowMulticast,
- InterfaceDisallowAll,
- InterfaceUnchanged = -1
-} NL_TYPE_OF_INTERFACE;
-
-typedef enum _NL_DOMAIN_NETWORK_LOCATION {
- DomainNetworkLocationRemote = 0, // connect to a domain network remotely via DA i.e. outside corp network.
- DomainNetworkCategoryLink = 1, // connect to a domain network directly i.e. inside corp network.
- DomainNetworkUnchanged = -1
-} NL_DOMAIN_NETWORK_LOCATION;
-
-typedef enum _NL_DOMAIN_TYPE {
- DomainTypeNonDomainNetwork = 0, // connected to non-domain network.
- DomainTypeDomainNetwork = 1, // connected to a network that has active directory.
- DomainTypeDomainAuthenticated = 2, // connected to AD network and machine is authenticated against it.
- DomainTypeUnchanged = -1
-} NL_DOMAIN_TYPE;
-
-typedef enum _NL_INTERFACE_ECN_CAPABILITY {
- NlInterfaceEcnUnchanged = -1,
- NlInterfaceEcnDisabled = 0,
- NlInterfaceEcnUseEct1 = 1,
- NlInterfaceEcnUseEct0 = 2,
- NlInterfaceEcnAppDecide = 3
-} NL_INTERFACE_ECN_CAPABILITY, *PNL_INTERFACE_ECN_CAPABILITY;
-
-typedef enum _NL_INTERNET_CONNECTIVITY_STATUS {
- NlNoInternetConnectivity,
- NlNoInternetDnsResolutionSucceeded,
- NlInternetConnectivityDetected,
- NlInternetConnectivityUnknown = -1
-} NL_INTERNET_CONNECTIVITY_STATUS, *PNL_INTERNET_CONNECTIVITY_STATUS;
-
-typedef union _IP_ADDRESS_STORAGE {
- IN_ADDR Ipv4;
- IN6_ADDR Ipv6;
- UCHAR Buffer[sizeof(IN6_ADDR)];
-} IP_ADDRESS_STORAGE, *PIP_ADDRESS_STORAGE;
-
-typedef struct _NL_INTERFACE_RW {
- BOOLEAN AdvertisingEnabled;
- BOOLEAN ForwardingEnabled;
- BOOLEAN MulticastForwardingEnabled;
- BOOLEAN WeakHostSend;
- BOOLEAN WeakHostReceive;
- BOOLEAN UseNeighborUnreachabilityDetection;
- BOOLEAN UseAutomaticMetric;
- BOOLEAN UseZeroBroadcastAddress;
- BOOLEAN UseBroadcastForRouterDiscovery;
- BOOLEAN DhcpRouterDiscoveryEnabled;
- BOOLEAN ManagedAddressConfigurationSupported;
- BOOLEAN OtherStatefulConfigurationSupported;
- BOOLEAN AdvertiseDefaultRoute;
- NL_NETWORK_CATEGORY NetworkCategory;
- NL_ROUTER_DISCOVERY_BEHAVIOR RouterDiscoveryBehavior;
- NL_TYPE_OF_INTERFACE TypeOfInterface;
- ULONG Metric;
- ULONG BaseReachableTime; // Base for random ReachableTime (in ms).
- ULONG RetransmitTime; // Neighbor Solicitation timeout (in ms).
- ULONG PathMtuDiscoveryTimeout; // Path MTU discovery timeout (in ms).
- ULONG DadTransmits; // DupAddrDetectTransmits in RFC 2462.
- NL_LINK_LOCAL_ADDRESS_BEHAVIOR LinkLocalAddressBehavior;
- ULONG LinkLocalAddressTimeout; // In ms.
- ULONG ZoneIndices[ScopeLevelCount]; // Zone part of a SCOPE_ID.
- ULONG NlMtu;
- ULONG SitePrefixLength;
- ULONG MulticastForwardingHopLimit;
- ULONG CurrentHopLimit;
- IP_ADDRESS_STORAGE LinkLocalAddress;
- BOOLEAN DisableDefaultRoutes;
- ULONG AdvertisedRouterLifetime;
- BOOLEAN SendUnsolicitedNeighborAdvertisementOnDad;
- BOOLEAN LimitedLinkConnectivity;
- BOOLEAN ForceARPNDPattern;
- BOOLEAN EnableDirectMACPattern;
- BOOLEAN EnableWol;
- BOOLEAN ForceTunneling;
- NL_DOMAIN_NETWORK_LOCATION DomainNetworkLocation;
- ULONGLONG RandomizedEpoch;
- NL_INTERFACE_ECN_CAPABILITY EcnCapability;
- NL_DOMAIN_TYPE DomainType;
- GUID NetworkSignature;
- NL_INTERNET_CONNECTIVITY_STATUS InternetConnectivityDetected;
- BOOLEAN ProxyDetected;
- ULONG DadRetransmitTime;
- BOOLEAN PrefixSharing;
- BOOLEAN DisableUnconstrainedRouteLookup;
- ULONG NetworkContext;
- BOOLEAN ResetAutoconfigurationOnOperStatusDown;
- BOOLEAN ClampMssEnabled;
-
-} NL_INTERFACE_RW, *PNL_INTERFACE_RW;
-
-__inline
-VOID
-NlInitializeInterfaceRw(
- IN OUT PNL_INTERFACE_RW Rw
- )
-{
- //
- // Initialize all fields to values that indicate "no change".
- //
- memset(Rw, 0xff, sizeof(*Rw));
- Rw->BaseReachableTime = 0;
- Rw->RetransmitTime = 0;
- Rw->PathMtuDiscoveryTimeout = 0;
- Rw->NlMtu = 0;
- Rw->DadRetransmitTime = 0;
-}
-
-typedef enum {
- NlBestRouteObject,
- NlCompartmentForwardingObject,
- NlCompartmentObject,
- NlControlProtocolObject,
- NlEchoRequestObject,
- NlEchoSequenceRequestObject,
- NlGlobalObject,
- NlInterfaceObject,
- NlLocalAnycastAddressObject,
- NlLocalMulticastAddressObject,
- NlLocalUnicastAddressObject,
- NlNeighborObject,
- NlPathObject,
- NlPotentialRouterObject,
- NlPrefixPolicyObject,
- NlProxyNeighborObject,
- NlRouteObject,
- NlSitePrefixObject,
- NlSubInterfaceObject,
- NlWakeUpPatternObject,
- NlResolveNeighborObject,
- NlSortAddressesObject,
- NlMfeObject,
- NlMfeNotifyObject,
- NlInterfaceHopObject,
- NlInterfaceUnprivilegedObject,
- NlTunnelPhysicalInterfaceObject,
- NlLocalityObject,
- NlLocalityDataObject,
- NlLocalityPrivateObject,
- NlLocalBottleneckObject,
- NlTimerObject,
- NlDisconnectInterface,
- NlMaximumObject
-} NL_OBJECT_TYPE, *PNL_OBJECT_TYPE;
-
-NSISTATUS
-NsiGetParameter(
- __in NSI_STORE Store,
- __in PNPI_MODULEID ModuleId,
- __in ULONG ObjectIndex,
- __in_bcount_opt(KeyStructLength) PVOID KeyStruct,
- __in ULONG KeyStructLength,
- __in NSI_STRUCT_TYPE StructType,
- __out_bcount(ParameterLen) PVOID Parameter,
- __in ULONG ParameterLen,
- __in ULONG ParameterOffset
- );
-
-NSISTATUS
-NsiSetAllParameters(
- __in NSI_STORE Store,
- __in NSI_SET_ACTION Action,
- __in PNPI_MODULEID ModuleId,
- __in ULONG ObjectIndex,
- __in_bcount_opt(KeyStructLength) PVOID KeyStruct,
- __in ULONG KeyStructLength,
- __in_bcount_opt(RwParameterStructLength) PVOID RwParameterStruct,
- __in ULONG RwParameterStructLength
- );
-
-extern CONST NPI_MODULEID NPI_MS_NDIS_MODULEID;
-
-typedef enum _NDIS_NSI_OBJECT_INDEX
-{
- NdisNsiObjectInterfaceInformation,
- NdisNsiObjectInterfaceEnum,
- NdisNsiObjectInterfaceLookUp,
- NdisNsiObjectIfRcvAddress,
- NdisNsiObjectStackIfEntry,
- NdisNsiObjectInvertedIfStackEntry,
- NdisNsiObjectNetwork,
- NdisNsiObjectCompartment,
- NdisNsiObjectThread,
- NdisNsiObjectSession,
- NdisNsiObjectInterfacePersist,
- NdisNsiObjectCompartmentLookup,
- NdisNsiObjectInterfaceInformationRaw,
- NdisNsiObjectInterfaceEnumRaw,
- NdisNsiObjectStackIfEnum,
- NdisNsiObjectInterfaceIsolationInfo,
- NdisNsiObjectJob,
- NdisNsiObjectMaximum
-} NDIS_NSI_OBJECT_INDEX, *PNDIS_NSI_OBJECT_INDEX;
-
-typedef struct _NDIS_NSI_INTERFACE_INFORMATION_RW
-{
- // rw fields
- GUID NetworkGuid;
- NET_IF_ADMIN_STATUS ifAdminStatus;
- NDIS_IF_COUNTED_STRING ifAlias;
- NDIS_IF_PHYSICAL_ADDRESS ifPhysAddress;
- NDIS_IF_COUNTED_STRING ifL2NetworkInfo;
-}NDIS_NSI_INTERFACE_INFORMATION_RW, *PNDIS_NSI_INTERFACE_INFORMATION_RW;
-
-#define NDIS_SIZEOF_NSI_INTERFACE_INFORMATION_RW_REVISION_1 \
- RTL_SIZEOF_THROUGH_FIELD(NDIS_NSI_INTERFACE_INFORMATION_RW, ifPhysAddress)
-
-typedef NDIS_INTERFACE_INFORMATION NDIS_NSI_INTERFACE_INFORMATION_ROD, *PNDIS_NSI_INTERFACE_INFORMATION_ROD;
-
-//
-// Copied from ndiscomp.h
-//
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-EXPORT
-COMPARTMENT_ID
-NdisGetThreadObjectCompartmentId(
- _In_ PETHREAD ThreadObject
- );
-
-_IRQL_requires_(PASSIVE_LEVEL)
-EXPORT
-NTSTATUS
-NdisSetThreadObjectCompartmentId(
- _In_ PETHREAD ThreadObject,
- _In_ NET_IF_COMPARTMENT_ID CompartmentId
- );
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-__inline
-COMPARTMENT_ID
-NdisGetCurrentThreadCompartmentId(
- VOID
- )
-{
- return NdisGetThreadObjectCompartmentId(PsGetCurrentThread());
-}
-
-_IRQL_requires_(PASSIVE_LEVEL)
-__inline
-NTSTATUS
-NdisSetCurrentThreadCompartmentId(
- _In_ COMPARTMENT_ID CompartmentId
- )
-{
- return
- NdisSetThreadObjectCompartmentId(PsGetCurrentThread(), CompartmentId);
-}
-
-#endif // _NSI_HELPER_H
diff --git a/examples/drivers/windows/otLwf/otLwf.inf b/examples/drivers/windows/otLwf/otLwf.inf
deleted file mode 100644
index fa90a24a7..000000000
--- a/examples/drivers/windows/otLwf/otLwf.inf
+++ /dev/null
@@ -1,106 +0,0 @@
-;
-; Copyright (c) 2016, The OpenThread Authors.
-; 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 copyright holder 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 COPYRIGHT HOLDER 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.
-;
-
-[Version]
-Signature = "$Windows NT$"
-Class = NetService
-ClassGUID = {4D36E974-E325-11CE-BFC1-08002BE10318}
-Provider = %OpenThread%
-DriverVer =
-PnpLockDown = 1
-CatalogFile = otLwf.cat
-
-[Manufacturer]
-%OpenThread% = OpenThread,NT$ARCH$
-
-[OpenThread.NT$ARCH$]
-%otlwf.DeviceDesc% = otlwf.ndi, otLwf
-
-;-------------------------------------------------------------------------------
-; OpenThread NDIS Filter Driver
-;-------------------------------------------------------------------------------
-[otlwf.ndi]
-Characteristics = 0x40000
-NetCfgInstanceId = "{B3A3845A-164E-4727-B12E-32B8DCE1F6CD}"
-AddReg = otlwf.Reg
-Copyfiles = otLwf.CopyFiles
-
-[otlwf.ndi.Services]
-AddService = otLwf, , otlwf.Service
-
-[otlwf.ndi.Remove.Services]
-; The SPSVCINST_STOPSERVICE flag instructs SCM to stop the NT service
-; before uninstalling the driver.
-DelService = otLwf, 0x200 ; SPSVCINST_STOPSERVICE
-
-;-------------------------------------------------------------------------------
-; OpenThread NDIS Filter Common
-;-------------------------------------------------------------------------------
-[otlwf.Reg]
-HKR, Ndi, Service, , "otLwf"
-HKR, Ndi, CoServices, 0x00010000, "otLwf"
-HKR, Ndi, FilterClass, , ms_medium_converter_top
-HKR, Ndi, FilterType, 0x00010001, 0x00000002
-HKR, Ndi, FilterRunType, 0x00010001, 0x00000002 ;OPTIONAL filter
-HKR, Ndi\Interfaces, UpperRange, , "noupper"
-HKR, Ndi\Interfaces, LowerRange, , "nolower"
-HKR, Ndi\Interfaces, FilterMediaTypes, , "802.15.4"
-
-;-------------------------------------------------------------------------------
-; Driver and Service Section
-;-------------------------------------------------------------------------------
-[otLwf.CopyFiles]
-otLwf.sys,,,2
-
-[otlwf.Service]
-DisplayName = %otlwf.Service.DispName%
-ServiceType = 1 ;SERVICE_KERNEL_DRIVER
-StartType = 1 ;SERVICE_SYSTEM_START
-ErrorControl = 1 ;SERVICE_ERROR_NORMAL
-ServiceBinary = %12%\otLwf.sys
-LoadOrderGroup = NDIS
-Description = %otlwf.DeviceDesc%
-
-[SourceDisksNames]
-1 = %otlwf.DeviceDesc%,"",,
-
-[SourceDisksFiles]
-; TODO: Include any related files that should be installed with your driver.
-otLwf.sys = 1
-
-[DestinationDirs]
-DefaultDestDir = 12
-otLwf.CopyFiles = 12
-
-;-------------------------------------------------------------------------------
-; Localizable Strings
-;-------------------------------------------------------------------------------
-[Strings]
-OpenThread = "OpenThread"
-otlwf.DeviceDesc = "OpenThread NDIS LightWeight Filter"
-otlwf.Service.DispName = "OpenThread NDIS LightWeight Filter"
diff --git a/examples/drivers/windows/otLwf/precomp.c b/examples/drivers/windows/otLwf/precomp.c
deleted file mode 100644
index ceeb0d649..000000000
--- a/examples/drivers/windows/otLwf/precomp.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "precomp.h"
diff --git a/examples/drivers/windows/otLwf/precomp.h b/examples/drivers/windows/otLwf/precomp.h
deleted file mode 100644
index c85e4a2c1..000000000
--- a/examples/drivers/windows/otLwf/precomp.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * Precompiled header for otLwf project.
- */
-
-#pragma warning(disable:4201) // nonstandard extension used : nameless struct/union
-#pragma warning(disable:4204) // nonstandard extension used : non-constant aggregate initializer
-#pragma warning(disable:28175) // The 'MajorFunction' member of _DRIVER_OBJECT should not be accessed by a driver:
- // Access to this member may be permitted for certain classes of drivers.
-#pragma warning(disable:28301) // No annotations for first declaration of *
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-VOID
-RtlCopyBufferToMdl(
- _In_reads_bytes_(BytesToCopy) CONST VOID *Buffer,
- _Inout_ PMDL MdlChain,
- _In_ SIZE_T MdlOffset,
- _In_ SIZE_T BytesToCopy,
- _Out_ SIZE_T* BytesCopied
- );
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#ifdef _KERNEL_MODE
-#define CODE_SEG(segment) __declspec(code_seg(segment))
-#else
-#define CODE_SEG(segment)
-#endif
-
-#define PAGED CODE_SEG("PAGE") _IRQL_always_function_max_(PASSIVE_LEVEL)
-#define PAGEDX CODE_SEG("PAGE")
-#define INITCODE CODE_SEG("INIT")
-
-typedef struct _MS_FILTER MS_FILTER, *PMS_FILTER;
-
-#pragma pack(push)
-#pragma pack(1)
-
-typedef struct UDPHeader
-{
- USHORT SourcePort;
- USHORT DestinationPort;
- USHORT TotalLength;
- USHORT Checksum;
-
-} UDPHeader;
-
-#pragma pack(pop)
-
-//#define DEBUG_TIMING
-//#define DEBUG_ALLOC
-#define LOG_BUFFERS
-//#define FORCE_SYNCHRONOUS_RECEIVE
-#define COMMAND_INIT_RETRY
-
-#include "driver.h"
-#include "device.h"
-#include "iocontrol.h"
-#include "radio.h"
-#include "filter.h"
-#include "command.h"
-#include "thread.h"
-#include "tunnel.h"
diff --git a/examples/drivers/windows/otLwf/radio.c b/examples/drivers/windows/otLwf/radio.c
deleted file mode 100644
index 7d0591862..000000000
--- a/examples/drivers/windows/otLwf/radio.c
+++ /dev/null
@@ -1,956 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file implements the logging function required for the OpenThread library.
- */
-
-#include "precomp.h"
-#include "radio.tmh"
-
-void
-LogMac(
- _In_ PCSTR szDir,
- _In_ PMS_FILTER pFilter,
- ULONG frameLength,
- _In_reads_bytes_(frameLength) PUCHAR frame
- );
-
-const char MacSend[] = "MAC_SEND";
-const char MacRecv[] = "MAC_RECV";
-
-#define LogMacSend(pFilter, frameLength, frame) LogMac(MacSend, pFilter, frameLength, frame)
-#define LogMacRecv(pFilter, frameLength, frame) LogMac(MacRecv, pFilter, frameLength, frame)
-
-void
-otPlatReset(
- _In_ otInstance *otCtx
- )
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! resetting...", &pFilter->InterfaceGuid);
-
- // Indicate to the miniport
- (void)otLwfCmdResetDevice(pFilter, TRUE);
-
- // Finalize previous OpenThread instance
- otLwfReleaseInstance(pFilter);
-
- // Reset radio layer
- pFilter->otRadioState = OT_RADIO_STATE_DISABLED;
- pFilter->otCurrentListenChannel = 0xFF;
- pFilter->otPromiscuous = false;
- pFilter->otPendingMacOffloadEnabled = FALSE;
-
- // Reinitialize the OpenThread library
- pFilter->otCachedRole = OT_DEVICE_ROLE_DISABLED;
- pFilter->otCtx = otInstanceInit(pFilter->otInstanceBuffer + sizeof(PMS_FILTER), &pFilter->otInstanceSize);
- ASSERT(pFilter->otCtx);
-
- // Make sure our helper function returns the right pointer for the filter, given the openthread instance
- NT_ASSERT(otCtxToFilter(pFilter->otCtx) == pFilter);
-
- // Disable Icmp (ping) handling
- otIcmp6SetEchoMode(pFilter->otCtx, OT_ICMP6_ECHO_HANDLER_DISABLED);
-
- // Register callbacks with OpenThread
- otSetStateChangedCallback(pFilter->otCtx, otLwfStateChangedCallback, pFilter);
- otIp6SetReceiveCallback(pFilter->otCtx, otLwfReceiveIp6DatagramCallback, pFilter);
-
- // Query the current addresses from TCPIP and cache them
- (void)otLwfInitializeAddresses(pFilter);
-
- // Initialze media connect state to disconnected
- otLwfIndicateLinkState(pFilter, MediaConnectStateDisconnected);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-otPlatResetReason
-otPlatGetResetReason(
- _In_ otInstance *otCtx
- )
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- return pFilter->cmdResetReason;
-}
-
-VOID
-otLwfRadioGetFactoryAddress(
- _In_ PMS_FILTER pFilter
- )
-{
- NTSTATUS status;
- PVOID SpinelBuffer = NULL;
- uint8_t *hwAddress = NULL;
-
- RtlZeroMemory(&pFilter->otFactoryAddress, sizeof(pFilter->otFactoryAddress));
-
- // Query the MP for the address
- status =
- otLwfCmdGetProp(
- pFilter,
- &SpinelBuffer,
- SPINEL_PROP_HWADDR,
- SPINEL_DATATYPE_EUI64_S,
- &hwAddress
- );
- if (!NT_SUCCESS(status) || hwAddress == NULL)
- {
- LogError(DRIVER_DEFAULT, "Get SPINEL_PROP_HWADDR failed, %!STATUS!", status);
- return;
- }
-
- NT_ASSERT(SpinelBuffer);
- memcpy(&pFilter->otFactoryAddress, hwAddress, sizeof(pFilter->otFactoryAddress));
- FILTER_FREE_MEM(SpinelBuffer);
-
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! cached factory Extended Mac Address: %llX", &pFilter->InterfaceGuid, pFilter->otFactoryAddress);
-}
-
-VOID
-otLwfRadioInit(
- _In_ PMS_FILTER pFilter
- )
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- NT_ASSERT(pFilter->DeviceStatus == OTLWF_DEVICE_STATUS_RADIO_MODE);
-
- // Initialize the OpenThread radio capability flags
- pFilter->otRadioCapabilities = 0;
- if ((pFilter->DeviceCapabilities & OTLWF_DEVICE_CAP_RADIO_ACK_TIMEOUT) != 0)
- pFilter->otRadioCapabilities |= OT_RADIO_CAPS_ACK_TIMEOUT;
- if ((pFilter->DeviceCapabilities & OTLWF_DEVICE_CAP_RADIO_MAC_RETRY_AND_COLLISION_AVOIDANCE) != 0)
- pFilter->otRadioCapabilities |= OT_RADIO_CAPS_TRANSMIT_RETRIES;
- if ((pFilter->DeviceCapabilities & OTLWF_DEVICE_CAP_RADIO_ENERGY_SCAN) != 0)
- pFilter->otRadioCapabilities |= OT_RADIO_CAPS_ENERGY_SCAN;
-
- pFilter->otRadioState = OT_RADIO_STATE_DISABLED;
- pFilter->otCurrentListenChannel = 0xFF;
- pFilter->otPromiscuous = false;
-
- pFilter->otReceiveFrame.mPsdu = pFilter->otReceiveMessage;
- pFilter->otTransmitFrame.mPsdu = pFilter->otTransmitMessage;
-
- pFilter->otPendingMacOffloadEnabled = FALSE;
-
- // Cache the factory address
- otLwfRadioGetFactoryAddress(pFilter);
-
- LogInfo(DRIVER_DEFAULT, "Filter %p RadioState = OT_RADIO_STATE_DISABLED.", pFilter);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-void otPlatRadioGetIeeeEui64(otInstance *otCtx, uint8_t *aIeeeEui64)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- memcpy(aIeeeEui64, &pFilter->otFactoryAddress, sizeof(ULONGLONG));
-}
-
-void otPlatRadioSetPanId(_In_ otInstance *otCtx, uint16_t panid)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- NTSTATUS status;
-
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! set PanID: %X", &pFilter->InterfaceGuid, panid);
-
- pFilter->otPanID = panid;
-
- if (pFilter->otRadioState != OT_RADIO_STATE_DISABLED &&
- pFilter->otPanID != 0xFFFF)
- {
- // Indicate to the miniport
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_15_4_PANID,
- SPINEL_DATATYPE_UINT16_S,
- panid
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_PANID failed, %!STATUS!", status);
- }
- }
-}
-
-void otPlatRadioSetExtendedAddress(_In_ otInstance *otCtx, const otExtAddress *address)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- NTSTATUS status;
- spinel_eui64_t extAddr;
-
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! set Extended Mac Address: %llX", &pFilter->InterfaceGuid, *(ULONGLONG*)address);
-
- pFilter->otExtendedAddress = *(ULONGLONG*)address;
-
- for (size_t i = 0; i < OT_EXT_ADDRESS_SIZE; i++)
- {
- extAddr.bytes[i] = address->m8[7 - i];
- }
-
- // Indicate to the miniport
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_15_4_LADDR,
- SPINEL_DATATYPE_EUI64_S,
- &extAddr
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_LADDR failed, %!STATUS!", status);
- }
-}
-
-void otPlatRadioSetShortAddress(_In_ otInstance *otCtx, uint16_t address)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- NTSTATUS status;
-
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! set Short Mac Address: %X", &pFilter->InterfaceGuid, address);
-
- pFilter->otShortAddress = address;
-
- if (pFilter->otRadioState != OT_RADIO_STATE_DISABLED)
- {
- // Indicate to the miniport
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_15_4_SADDR,
- SPINEL_DATATYPE_UINT16_S,
- address
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_SADDR failed, %!STATUS!", status);
- }
- }
-}
-
-void otPlatRadioSetPromiscuous(_In_ otInstance *otCtx, bool aEnable)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- NTSTATUS status;
-
- pFilter->otPromiscuous = (BOOLEAN)aEnable;
-
- // Indicate to the miniport
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_PROMISCUOUS_MODE,
- SPINEL_DATATYPE_UINT8_S,
- aEnable != 0 ? SPINEL_MAC_PROMISCUOUS_MODE_NETWORK : SPINEL_MAC_PROMISCUOUS_MODE_OFF
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_PROMISCUOUS_MODE failed, %!STATUS!", status);
- }
-}
-
-bool otPlatRadioIsEnabled(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- return pFilter->otRadioState != OT_RADIO_STATE_DISABLED;
-}
-
-otError otPlatRadioEnable(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- NTSTATUS status;
-
- NT_ASSERT(pFilter->otRadioState <= OT_RADIO_STATE_SLEEP);
- if (pFilter->otRadioState > OT_RADIO_STATE_SLEEP) return OT_ERROR_BUSY;
-
- pFilter->otRadioState = OT_RADIO_STATE_SLEEP;
-
- // Indicate to the miniport
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_PHY_ENABLED,
- SPINEL_DATATYPE_BOOL_S,
- TRUE
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_PHY_ENABLED (true) failed, %!STATUS!", status);
- }
-
- LogInfo(DRIVER_DEFAULT, "Filter %p RadioState = OT_RADIO_STATE_SLEEP.", pFilter);
-
- if (pFilter->otPanID != 0xFFFF)
- {
- // Indicate PANID to the miniport
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_15_4_PANID,
- SPINEL_DATATYPE_UINT16_S,
- pFilter->otPanID
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_PANID failed, %!STATUS!", status);
- }
- }
-
- // Indicate Short address to the miniport
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_15_4_SADDR,
- SPINEL_DATATYPE_UINT16_S,
- pFilter->otShortAddress
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_15_4_SADDR failed, %!STATUS!", status);
- }
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-otError otPlatRadioDisable(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- NTSTATUS status;
-
- // First make sure we are in the Sleep state if we weren't already
- if (pFilter->otRadioState > OT_RADIO_STATE_SLEEP)
- {
- (void)otPlatRadioSleep(otCtx);
- }
-
- pFilter->otRadioState = OT_RADIO_STATE_DISABLED;
-
- // Indicate to the miniport
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_PHY_ENABLED,
- SPINEL_DATATYPE_BOOL_S,
- FALSE
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_PHY_ENABLED (false) failed, %!STATUS!", status);
- }
-
- LogInfo(DRIVER_DEFAULT, "Filter %p RadioState = OT_RADIO_STATE_DISABLED.", pFilter);
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-otError otPlatRadioSleep(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- // If we were in the transmit state, cancel the transmit
- if (pFilter->otRadioState == OT_RADIO_STATE_TRANSMIT)
- {
- pFilter->otLastTransmitError = OT_ERROR_ABORT;
- otLwfRadioTransmitFrameDone(pFilter);
- }
-
- if (pFilter->otRadioState != OT_RADIO_STATE_SLEEP)
- {
- pFilter->otRadioState = OT_RADIO_STATE_SLEEP;
- LogInfo(DRIVER_DEFAULT, "Filter %p RadioState = OT_RADIO_STATE_SLEEP.", pFilter);
-
- // Indicate to the miniport
- NTSTATUS status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_RAW_STREAM_ENABLED,
- SPINEL_DATATYPE_BOOL_S,
- FALSE
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_RAW_STREAM_ENABLED (false) failed, %!STATUS!", status);
- }
- }
-
- return OT_ERROR_NONE;
-}
-
-otError otPlatRadioReceive(_In_ otInstance *otCtx, uint8_t aChannel)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- NT_ASSERT(pFilter->otRadioState != OT_RADIO_STATE_DISABLED);
- if (pFilter->otRadioState == OT_RADIO_STATE_DISABLED) return OT_ERROR_BUSY;
-
- LogFuncEntryMsg(DRIVER_DATA_PATH, "Filter: %p", pFilter);
-
- // Update current channel if different
- if (pFilter->otCurrentListenChannel != aChannel)
- {
- NTSTATUS status;
-
- NT_ASSERT(aChannel >= 11 && aChannel <= 26);
-
- LogInfo(DRIVER_DEFAULT, "Filter %p new Listen Channel = %u.", pFilter, aChannel);
- pFilter->otCurrentListenChannel = aChannel;
-
- // Indicate to the miniport
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_PHY_CHAN,
- SPINEL_DATATYPE_UINT8_S,
- aChannel
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_PHY_CHAN failed, %!STATUS!", status);
- }
- }
-
- // Only transition to the receive state if we were sleeping; otherwise we
- // are already in receive or transmit state.
- if (pFilter->otRadioState == OT_RADIO_STATE_SLEEP)
- {
- pFilter->otRadioState = OT_RADIO_STATE_RECEIVE;
- LogInfo(DRIVER_DEFAULT, "Filter %p RadioState = OT_RADIO_STATE_RECEIVE.", pFilter);
-
- NTSTATUS status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_RAW_STREAM_ENABLED,
- SPINEL_DATATYPE_BOOL_S,
- TRUE
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_RAW_STREAM_ENABLED (true) failed, %!STATUS!", status);
- }
-
- // Set the event to indicate we can process NBLs
- KeSetEvent(&pFilter->EventWorkerThreadProcessNBLs, 0, FALSE);
- }
-
- LogFuncExit(DRIVER_DATA_PATH);
-
- return OT_ERROR_NONE;
-}
-
-otRadioFrame *otPlatRadioGetTransmitBuffer(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- return &pFilter->otTransmitFrame;
-}
-
-int8_t otPlatRadioGetRssi(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- UNREFERENCED_PARAMETER(pFilter);
- return 0;
-}
-
-otRadioCaps otPlatRadioGetCaps(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- return otCtxToFilter(otCtx)->otRadioCapabilities;
-}
-
-bool otPlatRadioGetPromiscuous(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- return pFilter->otPromiscuous;
-}
-
-VOID
-otLwfRadioReceiveFrame(
- _In_ PMS_FILTER pFilter,
- _In_ otError errorCode
- )
-{
- NT_ASSERT(pFilter->otReceiveFrame.mChannel >= 11 && pFilter->otReceiveFrame.mChannel <= 26);
-
- LogFuncEntryMsg(DRIVER_DATA_PATH, "Filter: %p", pFilter);
-
- LogMacRecv(pFilter, pFilter->otReceiveFrame.mLength, pFilter->otReceiveFrame.mPsdu);
-
- if (pFilter->otRadioState > OT_RADIO_STATE_DISABLED)
- {
- otPlatRadioReceiveDone(pFilter->otCtx, &pFilter->otReceiveFrame, errorCode);
- }
- else
- {
- LogVerbose(DRIVER_DATA_PATH, "Mac frame dropped.");
- }
-
- LogFuncExit(DRIVER_DATA_PATH);
-}
-
-otError otPlatRadioTransmit(_In_ otInstance *otCtx, _In_ otRadioFrame *aFrame)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- otError error = OT_ERROR_BUSY;
-
- UNREFERENCED_PARAMETER(aFrame);
-
- LogFuncEntryMsg(DRIVER_DATA_PATH, "Filter: %p", pFilter);
-
- NT_ASSERT(pFilter->otRadioState == OT_RADIO_STATE_RECEIVE);
- if (pFilter->otRadioState == OT_RADIO_STATE_RECEIVE)
- {
- error = OT_ERROR_NONE;
- pFilter->otRadioState = OT_RADIO_STATE_TRANSMIT;
-
- LogInfo(DRIVER_DEFAULT, "Filter %p RadioState = OT_RADIO_STATE_TRANSMIT.", pFilter);
- }
-
- LogFuncExitMsg(DRIVER_DATA_PATH, "%u", error);
-
- return error;
-}
-
-VOID otLwfRadioTransmitFrame(_In_ PMS_FILTER pFilter)
-{
- NT_ASSERT(pFilter->otRadioState == OT_RADIO_STATE_TRANSMIT);
-
- LogMacSend(pFilter, pFilter->otTransmitFrame.mLength, pFilter->otTransmitFrame.mPsdu);
-
- LogFuncEntryMsg(DRIVER_DATA_PATH, "Filter: %p", pFilter);
-
- otLwfCmdSendMacFrameAsync(pFilter, &pFilter->otTransmitFrame);
-
- LogFuncExit(DRIVER_DATA_PATH);
-}
-
-VOID
-otLwfRadioTransmitFrameDone(
- _In_ PMS_FILTER pFilter
- )
-{
- LogFuncEntryMsg(DRIVER_DATA_PATH, "Filter: %p", pFilter);
-
- if (pFilter->otRadioState == OT_RADIO_STATE_TRANSMIT)
- {
- pFilter->SendPending = FALSE;
-
- // Now that we are completing a send, fall back to receive state and set the event
- pFilter->otRadioState = OT_RADIO_STATE_RECEIVE;
- LogInfo(DRIVER_DEFAULT, "Filter %p RadioState = OT_RADIO_STATE_RECEIVE.", pFilter);
- KeSetEvent(&pFilter->EventWorkerThreadProcessNBLs, 0, FALSE);
-
- if (pFilter->otLastTransmitError != OT_ERROR_NONE &&
- pFilter->otLastTransmitError != OT_ERROR_CHANNEL_ACCESS_FAILURE &&
- pFilter->otLastTransmitError != OT_ERROR_NO_ACK)
- {
- pFilter->otLastTransmitError = OT_ERROR_ABORT;
- }
-
- if (((pFilter->otTransmitFrame.mPsdu[0] & IEEE802154_ACK_REQUEST) == 0) ||
- pFilter->otLastTransmitError != OT_ERROR_NONE)
- {
- otPlatRadioTxDone(pFilter->otCtx, &pFilter->otTransmitFrame, NULL, pFilter->otLastTransmitError);
- }
- else
- {
- otPlatRadioTxDone(pFilter->otCtx, &pFilter->otTransmitFrame, &pFilter->otReceiveFrame, pFilter->otLastTransmitError);
- }
- }
-
- LogFuncExit(DRIVER_DATA_PATH);
-}
-
-void otPlatRadioEnableSrcMatch(_In_ otInstance *otCtx, bool aEnable)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- // Ignore if we are already in the correct state
- if (aEnable == pFilter->otPendingMacOffloadEnabled) return;
-
- // Cache the new value
- pFilter->otPendingMacOffloadEnabled = aEnable ? TRUE : FALSE;
-
- // Indicate to the miniport
- NTSTATUS status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_SRC_MATCH_ENABLED,
- SPINEL_DATATYPE_BOOL_S,
- (aEnable ? TRUE : FALSE)
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_SRC_MATCH_ENABLED failed, %!STATUS!", status);
- }
-}
-
-otError otPlatRadioAddSrcMatchShortEntry(_In_ otInstance *otCtx, otShortAddress aShortAddress)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- // Indicate to the miniport
- NTSTATUS status =
- otLwfCmdInsertProp(
- pFilter,
- SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES,
- SPINEL_DATATYPE_UINT16_S,
- aShortAddress
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Insert SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES failed, %!STATUS!", status);
- }
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-otError otPlatRadioAddSrcMatchExtEntry(_In_ otInstance *otCtx, const otExtAddress *aExtAddress)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- // Indicate to the miniport
- NTSTATUS status =
- otLwfCmdInsertProp(
- pFilter,
- SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES,
- SPINEL_DATATYPE_EUI64_S,
- aExtAddress
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Insert SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES failed, %!STATUS!", status);
- }
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-otError otPlatRadioClearSrcMatchShortEntry(_In_ otInstance *otCtx, otShortAddress aShortAddress)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- // Indicate to the miniport
- NTSTATUS status =
- otLwfCmdRemoveProp(
- pFilter,
- SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES,
- SPINEL_DATATYPE_UINT16_S,
- aShortAddress
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Remove SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES failed, %!STATUS!", status);
- }
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-otError otPlatRadioClearSrcMatchExtEntry(_In_ otInstance *otCtx, const otExtAddress *aExtAddress)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- // Indicate to the miniport
- NTSTATUS status =
- otLwfCmdRemoveProp(
- pFilter,
- SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES,
- SPINEL_DATATYPE_EUI64_S,
- aExtAddress
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Remove SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES failed, %!STATUS!", status);
- }
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-void otPlatRadioClearSrcMatchShortEntries(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- // Indicate to the miniport
- NTSTATUS status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES,
- NULL
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES failed, %!STATUS!", status);
- }
-}
-
-void otPlatRadioClearSrcMatchExtEntries(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- // Indicate to the miniport
- NTSTATUS status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES,
- NULL
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES failed, %!STATUS!", status);
- }
-}
-
-otError otPlatRadioEnergyScan(_In_ otInstance *otCtx, uint8_t aScanChannel, uint16_t aScanDuration)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- NTSTATUS status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_SCAN_MASK,
- SPINEL_DATATYPE_UINT8_S,
- aScanChannel
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_SCAN_MASK failed, %!STATUS!", status);
- goto error;
- }
-
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_SCAN_PERIOD,
- SPINEL_DATATYPE_UINT16_S,
- aScanDuration
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_SCAN_PERIOD failed, %!STATUS!", status);
- goto error;
- }
-
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_MAC_SCAN_STATE,
- SPINEL_DATATYPE_UINT8_S,
- SPINEL_SCAN_STATE_ENERGY
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_MAC_SCAN_STATE failed, %!STATUS!", status);
- goto error;
- }
-
-error:
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-otError otPlatRadioGetTransmitPower(_In_ otInstance *otCtx, int8_t *aPower)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- NTSTATUS status;
-
- status =
- otLwfCmdGetProp(
- pFilter,
- NULL,
- SPINEL_PROP_PHY_TX_POWER,
- SPINEL_DATATYPE_INT8_S,
- aPower
- );
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Get SPINEL_PROP_PHY_TX_POWER, failed, %!STATUS!", status);
- }
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-otError otPlatRadioSetTransmitPower(_In_ otInstance *otCtx, int8_t aPower)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- NTSTATUS status;
-
- // Indicate to the miniport
- status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_PHY_TX_POWER,
- SPINEL_DATATYPE_INT8_S,
- aPower
- );
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Set SPINEL_PROP_PHY_TX_POWER failed, %!STATUS!", status);
- }
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-int8_t otPlatRadioGetReceiveSensitivity(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- NTSTATUS status;
- int8_t receiveSensitivity;
-
- status =
- otLwfCmdGetProp(
- pFilter,
- NULL,
- SPINEL_PROP_PHY_RX_SENSITIVITY,
- SPINEL_DATATYPE_INT8_S,
- &receiveSensitivity
- );
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "Get SPINEL_PROP_PHY_RX_SENSITIVITY, failed, %!STATUS!", status);
- return -100; // return default value -100dBm
- }
-
- return receiveSensitivity;
-}
-
-inline USHORT getDstShortAddress(const UCHAR *frame)
-{
- return (((USHORT)frame[IEEE802154_DSTADDR_OFFSET + 1]) << 8) | frame[IEEE802154_DSTADDR_OFFSET];
-}
-
-inline USHORT getSrcShortAddress(ULONG frameLength, _In_reads_bytes_(frameLength) PUCHAR frame, ULONG offset)
-{
- return (offset + 1 < frameLength) ? ((((USHORT)frame[offset + 1]) << 8) | frame[offset]) : 0;
-}
-
-inline ULONGLONG getDstExtAddress(const UCHAR *frame)
-{
- return *(ULONGLONG*)(frame + IEEE802154_DSTADDR_OFFSET);
-}
-
-inline ULONGLONG getSrcExtAddress(ULONG frameLength, _In_reads_bytes_(frameLength) PUCHAR frame, ULONG offset)
-{
- return (offset + 7 < frameLength) ? (*(ULONGLONG*)(frame + offset)) : 0;
-}
-
-void
-LogMac(
- _In_ PCSTR szDir,
- _In_ PMS_FILTER pFilter,
- ULONG frameLength,
- _In_reads_bytes_(frameLength) PUCHAR frame
- )
-{
- if (frameLength < 6) return;
-
- NT_ASSERT(frame);
-
- UCHAR AckRequested = (frame[0] & IEEE802154_ACK_REQUEST) != 0 ? 1 : 0;
- UCHAR FramePending = (frame[0] & IEEE802154_FRAME_PENDING) != 0 ? 1 : 0;
-
- switch (frame[1] & (IEEE802154_DST_ADDR_MASK | IEEE802154_SRC_ADDR_MASK))
- {
- case IEEE802154_DST_ADDR_NONE | IEEE802154_SRC_ADDR_NONE:
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, %s: null => null (%u bytes, AckReq=%u, FramePending=%u)",
- pFilter, szDir, frameLength, AckRequested, FramePending);
- break;
- case IEEE802154_DST_ADDR_NONE | IEEE802154_SRC_ADDR_SHORT:
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, %s: %X => null (%u bytes, AckReq=%u, FramePending=%u)",
- pFilter, szDir, getSrcShortAddress(frameLength, frame, IEEE802154_DSTADDR_OFFSET), frameLength, AckRequested, FramePending);
- break;
- case IEEE802154_DST_ADDR_NONE | IEEE802154_SRC_ADDR_EXT:
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, %s: %llX => null (%u bytes, AckReq=%u, FramePending=%u)",
- pFilter, szDir, getSrcExtAddress(frameLength, frame, IEEE802154_DSTADDR_OFFSET), frameLength, AckRequested, FramePending);
- break;
-
- case IEEE802154_DST_ADDR_SHORT | IEEE802154_SRC_ADDR_NONE:
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, %s: null => %X (%u bytes, AckReq=%u, FramePending=%u)",
- pFilter, szDir, getDstShortAddress(frame), frameLength, AckRequested, FramePending);
- break;
- case IEEE802154_DST_ADDR_SHORT | IEEE802154_SRC_ADDR_SHORT:
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, %s: %X => %X (%u bytes, AckReq=%u, FramePending=%u)",
- pFilter, szDir, getSrcShortAddress(frameLength, frame, IEEE802154_DSTADDR_OFFSET+2), getDstShortAddress(frame), frameLength, AckRequested, FramePending);
- break;
- case IEEE802154_DST_ADDR_SHORT | IEEE802154_SRC_ADDR_EXT:
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, %s: %llX => %X (%u bytes, AckReq=%u, FramePending=%u)",
- pFilter, szDir, getSrcExtAddress(frameLength, frame, IEEE802154_DSTADDR_OFFSET+2), getDstShortAddress(frame), frameLength, AckRequested, FramePending);
- break;
-
- case IEEE802154_DST_ADDR_EXT | IEEE802154_SRC_ADDR_NONE:
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, %s: null => %llX (%u bytes, AckReq=%u, FramePending=%u)",
- pFilter, szDir, getDstExtAddress(frame), frameLength, AckRequested, FramePending);
- break;
- case IEEE802154_DST_ADDR_EXT | IEEE802154_SRC_ADDR_SHORT:
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, %s: %X => %llX (%u bytes, AckReq=%u, FramePending=%u)",
- pFilter, szDir, getSrcShortAddress(frameLength, frame, IEEE802154_DSTADDR_OFFSET+8), getDstExtAddress(frame), frameLength, AckRequested, FramePending);
- break;
- case IEEE802154_DST_ADDR_EXT | IEEE802154_SRC_ADDR_EXT:
- LogVerbose(DRIVER_DATA_PATH, "Filter: %p, %s: %llX => %llX (%u bytes, AckReq=%u, FramePending=%u)",
- pFilter, szDir, getSrcExtAddress(frameLength, frame, IEEE802154_DSTADDR_OFFSET+8), getDstExtAddress(frame), frameLength, AckRequested, FramePending);
- break;
- }
-
-#ifdef LOG_BUFFERS
- otLogBuffer(frame, frameLength);
-#endif
-}
diff --git a/examples/drivers/windows/otLwf/radio.h b/examples/drivers/windows/otLwf/radio.h
deleted file mode 100644
index 310d4d783..000000000
--- a/examples/drivers/windows/otLwf/radio.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines the structures and functions for the OpenThread radio interface.
- */
-
-#ifndef _OTLWF_RADIO_H
-#define _OTLWF_RADIO_H
-
-enum
-{
- IEEE802154_MIN_LENGTH = 5,
- IEEE802154_MAX_LENGTH = 127,
- IEEE802154_ACK_LENGTH = 5,
-
- IEEE802154_BROADCAST = 0xffff,
-
- IEEE802154_FRAME_TYPE_ACK = 2 << 0,
- IEEE802154_FRAME_TYPE_MACCMD = 3 << 0,
- IEEE802154_FRAME_TYPE_MASK = 7 << 0,
-
- IEEE802154_SECURITY_ENABLED = 1 << 3,
- IEEE802154_FRAME_PENDING = 1 << 4,
- IEEE802154_ACK_REQUEST = 1 << 5,
- IEEE802154_PANID_COMPRESSION = 1 << 6,
-
- IEEE802154_DST_ADDR_NONE = 0 << 2,
- IEEE802154_DST_ADDR_SHORT = 2 << 2,
- IEEE802154_DST_ADDR_EXT = 3 << 2,
- IEEE802154_DST_ADDR_MASK = 3 << 2,
-
- IEEE802154_SRC_ADDR_NONE = 0 << 6,
- IEEE802154_SRC_ADDR_SHORT = 2 << 6,
- IEEE802154_SRC_ADDR_EXT = 3 << 6,
- IEEE802154_SRC_ADDR_MASK = 3 << 6,
-
- IEEE802154_DSN_OFFSET = 2,
- IEEE802154_DSTPAN_OFFSET = 3,
- IEEE802154_DSTADDR_OFFSET = 5,
-
- IEEE802154_SEC_LEVEL_MASK = 7 << 0,
-
- IEEE802154_KEY_ID_MODE_0 = 0 << 3,
- IEEE802154_KEY_ID_MODE_1 = 1 << 3,
- IEEE802154_KEY_ID_MODE_2 = 2 << 3,
- IEEE802154_KEY_ID_MODE_3 = 3 << 3,
- IEEE802154_KEY_ID_MODE_MASK = 3 << 3,
-
- IEEE802154_MACCMD_DATA_REQ = 4,
-};
-
-// Initializes the radio layer
-VOID otLwfRadioInit(_In_ PMS_FILTER pFilter);
-
-// Indicates a received frame from the radio layer
-VOID otLwfRadioReceiveFrame(_In_ PMS_FILTER pFilter, _In_ otError errorCode);
-
-// Indicates the transmit frame is ready to send to the radio layer
-VOID otLwfRadioTransmitFrame(_In_ PMS_FILTER pFilter);
-
-// Indicates the transmit frame finished sending
-VOID otLwfRadioTransmitFrameDone(_In_ PMS_FILTER pFilter);
-
-#endif //_OTLWF_RADIO_H
diff --git a/examples/drivers/windows/otLwf/settings.c b/examples/drivers/windows/otLwf/settings.c
deleted file mode 100644
index 41aefaac6..000000000
--- a/examples/drivers/windows/otLwf/settings.c
+++ /dev/null
@@ -1,609 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file implements the settings functions required for the OpenThread library.
- */
-
-#include "precomp.h"
-#include "settings.tmh"
-
-void otPlatSettingsInit(otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- DECLARE_CONST_UNICODE_STRING(SubKeyName, L"OpenThread");
-
- OBJECT_ATTRIBUTES attributes;
- ULONG disposition;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- InitializeObjectAttributes(
- &attributes,
- (PUNICODE_STRING)&SubKeyName,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- pFilter->InterfaceRegKey,
- NULL);
-
- // Create/Open the 'OpenThread' sub key
- NTSTATUS status =
- ZwCreateKey(
- &pFilter->otSettingsRegKey,
- KEY_ALL_ACCESS,
- &attributes,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- &disposition);
-
- NT_ASSERT(NT_SUCCESS(status));
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "ZwCreateKey for 'OpenThread' key failed, %!STATUS!", status);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-uint16_t FilterCountSettings(_In_ PMS_FILTER pFilter, uint16_t aKey)
-{
- HANDLE regKey = NULL;
- OBJECT_ATTRIBUTES attributes;
- DECLARE_UNICODE_STRING_SIZE(Name, 8);
- UCHAR InfoBuffer[128] = {0};
- PKEY_FULL_INFORMATION pInfo = (PKEY_FULL_INFORMATION)InfoBuffer;
- ULONG InfoLength = sizeof(InfoBuffer);
-
- // Convert 'aKey' to a string
- RtlIntegerToUnicodeString((ULONG)aKey, 16, &Name);
-
- InitializeObjectAttributes(
- &attributes,
- &Name,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- pFilter->otSettingsRegKey,
- NULL);
-
- // Open the registry key
- NTSTATUS status =
- ZwOpenKey(
- ®Key,
- KEY_ALL_ACCESS,
- &attributes);
-
- if (!NT_SUCCESS(status))
- {
- // Key doesn't exist, return a count of 0
- goto error;
- }
-
- // Query the key info from the registry
- status =
- ZwQueryKey(
- regKey,
- KeyValueFullInformation,
- pInfo,
- InfoLength,
- &InfoLength);
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "ZwQueryKey for %S value failed, %!STATUS!", Name.Buffer, status);
- goto error;
- }
-
-error:
-
- if (regKey) ZwClose(regKey);
-
- return (uint16_t)pInfo->Values;
-}
-
-NTSTATUS FilterReadSetting(_In_ PMS_FILTER pFilter, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)
-{
- HANDLE regKey = NULL;
- OBJECT_ATTRIBUTES attributes;
- DECLARE_UNICODE_STRING_SIZE(Name, 20);
- PKEY_VALUE_PARTIAL_INFORMATION pInfo = NULL;
- ULONG InfoLength = sizeof(*pInfo) + *aValueLength;
-
- // Convert 'aKey' to a string
- RtlIntegerToUnicodeString((ULONG)aKey, 16, &Name);
-
- InitializeObjectAttributes(
- &attributes,
- &Name,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- pFilter->otSettingsRegKey,
- NULL);
-
- // Open the registry key
- NTSTATUS status =
- ZwOpenKey(
- ®Key,
- KEY_ALL_ACCESS,
- &attributes);
-
- if (!NT_SUCCESS(status))
- {
- // Key doesn't exist
- goto error;
- }
-
- // Convert 'aIndex' to a string
- RtlIntegerToUnicodeString((ULONG)aIndex, 16, &Name);
-
- // Allocate buffer for query
- pInfo = FILTER_ALLOC_MEM(pFilter->FilterHandle, InfoLength);
- if (pInfo == NULL)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto error;
- }
-
- // Query the data
- status = ZwQueryValueKey(
- regKey,
- &Name,
- KeyValuePartialInformation,
- pInfo,
- InfoLength,
- &InfoLength);
-
- if (!NT_SUCCESS(status))
- {
- LogVerbose(DRIVER_DEFAULT, "ZwQueryValueKey for %S value failed, %!STATUS!", Name.Buffer, status);
- goto error;
- }
-
- NT_ASSERT(*aValueLength >= pInfo->DataLength);
- *aValueLength = (uint16_t)pInfo->DataLength;
- if (aValue)
- {
- memcpy(aValue, pInfo->Data, pInfo->DataLength);
- }
-
-error:
-
- if (pInfo) FILTER_FREE_MEM(pInfo);
- if (regKey) ZwClose(regKey);
-
- return status;
-}
-
-NTSTATUS FilterWriteSetting(_In_ PMS_FILTER pFilter, uint16_t aKey, int aIndex, const uint8_t *aValue, uint16_t aValueLength)
-{
- HANDLE regKey = NULL;
- OBJECT_ATTRIBUTES attributes;
- DECLARE_UNICODE_STRING_SIZE(Name, 20);
-
- // Convert 'aKey' to a string
- RtlIntegerToUnicodeString((ULONG)aKey, 16, &Name);
-
- InitializeObjectAttributes(
- &attributes,
- &Name,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- pFilter->otSettingsRegKey,
- NULL);
-
- // Create/Open the registry key
- NTSTATUS status =
- ZwCreateKey(
- ®Key,
- KEY_ALL_ACCESS,
- &attributes,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- NULL);
-
- NT_ASSERT(NT_SUCCESS(status));
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "ZwCreateKey for %S key failed, %!STATUS!", Name.Buffer, status);
- goto error;
- }
-
- // Convert 'aIndex' to a string
- RtlIntegerToUnicodeString((ULONG)aIndex, 16, &Name);
-
- // Write the data to the registry
- status =
- ZwSetValueKey(
- regKey,
- &Name,
- 0,
- REG_BINARY,
- (PVOID)aValue,
- aValueLength);
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "ZwSetValueKey for %S value failed, %!STATUS!", Name.Buffer, status);
- goto error;
- }
-
-error:
-
- if (regKey) ZwClose(regKey);
-
- return status;
-}
-
-NTSTATUS FilterDeleteSetting(_In_ PMS_FILTER pFilter, uint16_t aKey, int aIndex)
-{
- HANDLE regKey = NULL;
- OBJECT_ATTRIBUTES attributes;
- DECLARE_UNICODE_STRING_SIZE(Name, 20);
-
- // Convert 'aKey' to a string
- RtlIntegerToUnicodeString((ULONG)aKey, 16, &Name);
-
- InitializeObjectAttributes(
- &attributes,
- &Name,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- pFilter->otSettingsRegKey,
- NULL);
-
- // Open the registry key
- NTSTATUS status =
- ZwOpenKey(
- ®Key,
- KEY_ALL_ACCESS,
- &attributes);
-
- if (!NT_SUCCESS(status))
- {
- // Key doesn't exist
- goto error;
- }
-
- // If 'aIndex' is -1 then delete the whole key, otherwise delete the individual value
- if (aIndex == -1)
- {
- // Delete the registry key
- status = ZwDeleteKey(regKey);
- }
- else
- {
- UCHAR KeyInfoBuffer[128] = { 0 };
- PKEY_FULL_INFORMATION pKeyInfo = (PKEY_FULL_INFORMATION)KeyInfoBuffer;
- ULONG KeyInfoLength = sizeof(KeyInfoBuffer);
-
- // When deleting an individual value, since order doesn't matter, we will actually
- // copy the last value over the one being deleted and then delete the last value; so
- // we maintain a contiguous list of numbered values
-
- // Query the number of values
- // Note: Can't use helper function because we already have the key open
- status =
- ZwQueryKey(
- regKey,
- KeyValueFullInformation,
- pKeyInfo,
- KeyInfoLength,
- &KeyInfoLength);
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "ZwQueryKey for %S value failed, %!STATUS!", Name.Buffer, status);
- goto error;
- }
-
- if ((ULONG)aIndex >= pKeyInfo->Values)
- {
- // Attempt to delete beyond the end of the list
- status = STATUS_OBJECT_NAME_NOT_FOUND;
- goto error;
- }
- else if (pKeyInfo->Values == 1)
- {
- // Deleting the only value on the key, go ahead and delete the entire key
- status = ZwDeleteKey(regKey);
- }
- else if (pKeyInfo->Values - 1 != (ULONG)aIndex)
- {
- // We aren't deleting the last value so we need to copy the last value
- // over this one, and then delete the last one.
-
- PKEY_VALUE_PARTIAL_INFORMATION pValueInfo = NULL;
- ULONG ValueInfoLength = 0;
-
- // Convert pKeyInfo->Values-1 to a string
- RtlIntegerToUnicodeString(pKeyInfo->Values - 1, 16, &Name);
-
- // Query the key data buffer size
- status = ZwQueryValueKey(
- regKey,
- &Name,
- KeyValuePartialInformation,
- pValueInfo,
- 0,
- &ValueInfoLength);
-
- NT_ASSERT(status != STATUS_SUCCESS);
- if (status != STATUS_BUFFER_TOO_SMALL)
- {
- LogVerbose(DRIVER_DEFAULT, "ZwQueryValueKey for %S value failed, %!STATUS!", Name.Buffer, status);
- goto error;
- }
-
- pValueInfo = FILTER_ALLOC_MEM(pFilter->FilterHandle, ValueInfoLength);
- if (pValueInfo == NULL)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto error;
- }
-
- // Query the data buffer
- status = ZwQueryValueKey(
- regKey,
- &Name,
- KeyValuePartialInformation,
- pValueInfo,
- ValueInfoLength,
- &ValueInfoLength);
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "ZwQueryValueKey for %S value failed, %!STATUS!", Name.Buffer, status);
- goto cleanup;
- }
-
- // Delete the registry value
- status =
- ZwDeleteValueKey(
- regKey,
- &Name);
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "ZwDeleteValueKey for %S value failed, %!STATUS!", Name.Buffer, status);
- goto cleanup;
- }
-
- // Convert 'aIndex' to a string
- RtlIntegerToUnicodeString((ULONG)aIndex, 16, &Name);
-
- // Write the data to the registry key we are deleting
- status =
- ZwSetValueKey(
- regKey,
- &Name,
- 0,
- REG_BINARY,
- (PVOID)pValueInfo->Data,
- pValueInfo->DataLength);
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "ZwSetValueKey for %S value failed, %!STATUS!", Name.Buffer, status);
- goto cleanup;
- }
-
- cleanup:
-
- if (pValueInfo) FILTER_FREE_MEM(pValueInfo);
- }
- else
- {
- // Deleting the last value in the list (but not the only value)
- // Just delete the value directly. No need to copy any others.
-
- // Convert 'aIndex' to a string
- RtlIntegerToUnicodeString((ULONG)aIndex, 16, &Name);
-
- // Delete the registry value
- status =
- ZwDeleteValueKey(
- regKey,
- &Name);
- }
- }
-
-error:
-
- if (regKey) ZwClose(regKey);
-
- return status;
-}
-
-otError otPlatSettingsBeginChange(otInstance *otCtx)
-{
- UNREFERENCED_PARAMETER(otCtx);
- return OT_ERROR_NOT_IMPLEMENTED;
-}
-
-otError otPlatSettingsCommitChange(otInstance *otCtx)
-{
- UNREFERENCED_PARAMETER(otCtx);
- return OT_ERROR_NOT_IMPLEMENTED;
-}
-
-otError otPlatSettingsAbandonChange(otInstance *otCtx)
-{
- UNREFERENCED_PARAMETER(otCtx);
- return OT_ERROR_NOT_IMPLEMENTED;
-}
-
-otError otPlatSettingsGet(otInstance *otCtx, uint16_t aKey, int aIndex, uint8_t *aValue, uint16_t *aValueLength)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- NTSTATUS status =
- FilterReadSetting(
- pFilter,
- aKey,
- aIndex,
- aValue,
- aValueLength);
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_NOT_FOUND;
-}
-
-otError otPlatSettingsSet(otInstance *otCtx, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- NTSTATUS status =
- FilterWriteSetting(
- pFilter,
- aKey,
- 0,
- aValue,
- aValueLength);
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-otError otPlatSettingsAdd(otInstance *otCtx, uint16_t aKey, const uint8_t *aValue, uint16_t aValueLength)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- uint16_t count = FilterCountSettings(pFilter, aKey);
-
- NTSTATUS status =
- FilterWriteSetting(
- pFilter,
- aKey,
- count,
- aValue,
- aValueLength);
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-otError otPlatSettingsDelete(otInstance *otCtx, uint16_t aKey, int aIndex)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- NTSTATUS status =
- FilterDeleteSetting(
- pFilter,
- aKey,
- aIndex);
-
- return NT_SUCCESS(status) ? OT_ERROR_NONE : OT_ERROR_FAILED;
-}
-
-void otPlatSettingsWipe(otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- // Delete all subkeys of 'OpenThread'
- if (pFilter->otSettingsRegKey)
- {
- NTSTATUS status = STATUS_SUCCESS;
- ULONG index = 0;
- UCHAR keyInfo[sizeof(KEY_BASIC_INFORMATION) + 64];
-
- while (status == STATUS_SUCCESS)
- {
- ULONG size = sizeof(keyInfo);
- status =
- ZwEnumerateKey(
- pFilter->otSettingsRegKey,
- index,
- KeyBasicInformation,
- keyInfo,
- size,
- &size);
-
- bool deleted = false;
- if (NT_SUCCESS(status))
- {
- HANDLE subKey = NULL;
- OBJECT_ATTRIBUTES attributes;
- PKEY_BASIC_INFORMATION pKeyInfo = (PKEY_BASIC_INFORMATION)keyInfo;
-
- UNICODE_STRING subKeyName =
- {
- (USHORT)pKeyInfo->NameLength,
- (USHORT)pKeyInfo->NameLength,
- pKeyInfo->Name
- };
-
- InitializeObjectAttributes(
- &attributes,
- &subKeyName,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- pFilter->otSettingsRegKey,
- NULL);
-
- // Open the sub key
- status =
- ZwOpenKey(
- &subKey,
- KEY_ALL_ACCESS,
- &attributes);
-
- if (NT_SUCCESS(status))
- {
- // Delete the key
- status = ZwDeleteKey(subKey);
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "ZwDeleteKey for subkey failed, %!STATUS!", status);
- }
- else
- {
- deleted = true;
- }
-
- // Close handle
- ZwClose(subKey);
- }
- else
- {
- LogError(DRIVER_DEFAULT, "ZwOpenKey for subkey failed, %!STATUS!", status);
- }
- }
-
- // Only increment index if we didn't delete
- if (!deleted)
- {
- index++;
- }
- }
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
diff --git a/examples/drivers/windows/otLwf/thread.c b/examples/drivers/windows/otLwf/thread.c
deleted file mode 100644
index 9917fdf25..000000000
--- a/examples/drivers/windows/otLwf/thread.c
+++ /dev/null
@@ -1,807 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file implements the Thread mode (Radio Miniport) functions required for the OpenThread library.
- */
-
-#include "precomp.h"
-#include "thread.tmh"
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NDIS_STATUS
-otLwfInitializeThreadMode(
- _In_ PMS_FILTER pFilter
- )
-{
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- NT_ASSERT(pFilter->DeviceCapabilities & OTLWF_DEVICE_CAP_RADIO);
-
- do
- {
- KeInitializeEvent(
- &pFilter->SendNetBufferListComplete,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
-
- // Initialize the event processing
- pFilter->EventWorkerThread = NULL;
- NdisAllocateSpinLock(&pFilter->EventsLock);
- InitializeListHead(&pFilter->AddressChangesHead);
- InitializeListHead(&pFilter->NBLsHead);
- InitializeListHead(&pFilter->MacFramesHead);
- InitializeListHead(&pFilter->EventIrpListHead);
- KeInitializeEvent(
- &pFilter->EventWorkerThreadStopEvent,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
- KeInitializeEvent(
- &pFilter->EventWorkerThreadWaitTimeUpdated,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
- KeInitializeEvent(
- &pFilter->EventWorkerThreadProcessTasklets,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
- KeInitializeEvent(
- &pFilter->EventWorkerThreadProcessAddressChanges,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
- KeInitializeEvent(
- &pFilter->EventWorkerThreadProcessNBLs,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
- KeInitializeEvent(
- &pFilter->EventWorkerThreadProcessMacFrames,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
- KeInitializeEvent(
- &pFilter->EventWorkerThreadProcessIrp,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
- KeInitializeEvent(
- &pFilter->EventWorkerThreadEnergyScanComplete,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
- pFilter->EventHighPrecisionTimer =
- ExAllocateTimer(
- otLwfEventProcessingTimer,
- pFilter,
- EX_TIMER_HIGH_RESOLUTION
- );
- if (pFilter->EventHighPrecisionTimer == NULL)
- {
- LogError(DRIVER_DEFAULT, "Failed to allocate timer!");
- break;
- }
-
- // Query the interface state (best effort, since it might not be supported)
- BOOLEAN IfUp = FALSE;
- Status = otLwfCmdGetProp(pFilter, NULL, SPINEL_PROP_NET_IF_UP, SPINEL_DATATYPE_BOOL_S, &IfUp);
- if (!NT_SUCCESS(Status))
- {
- LogVerbose(DRIVER_DEFAULT, "Failed to query SPINEL_PROP_INTERFACE_TYPE, %!STATUS!", Status);
- Status = NDIS_STATUS_SUCCESS;
- }
- else
- {
- NT_ASSERT(IfUp == FALSE);
- }
-
- // Initialize the event processing thread
- if (!NT_SUCCESS(otLwfEventProcessingStart(pFilter)))
- {
- Status = NDIS_STATUS_RESOURCES;
- break;
- }
-
- } while (FALSE);
-
- if (Status != NDIS_STATUS_SUCCESS)
- {
- // Stop event processing thread
- otLwfEventProcessingStop(pFilter);
-
- // Stop and free the timer
- if (pFilter->EventHighPrecisionTimer)
- {
- ExDeleteTimer(pFilter->EventHighPrecisionTimer, TRUE, FALSE, NULL);
- }
- }
-
- LogFuncExitNDIS(DRIVER_DEFAULT, Status);
-
- return Status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void
-otLwfUninitializeThreadMode(
- _In_ PMS_FILTER pFilter
- )
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- // Stop event processing thread
- otLwfEventProcessingStop(pFilter);
-
- // Free timer
- if (pFilter->EventHighPrecisionTimer)
- {
- ExDeleteTimer(pFilter->EventHighPrecisionTimer, TRUE, FALSE, NULL);
- pFilter->EventHighPrecisionTimer = NULL;
- }
-
- // Close handle to settings registry key
- if (pFilter->otSettingsRegKey)
- {
- ZwClose(pFilter->otSettingsRegKey);
- pFilter->otSettingsRegKey = NULL;
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-#if DEBUG_ALLOC
-PMS_FILTER
-otLwfFindFromCurrentThread()
-{
- PMS_FILTER pOutput = NULL;
- HANDLE CurThreadId = PsGetCurrentThreadId();
-
- NdisAcquireSpinLock(&FilterListLock);
-
- for (PLIST_ENTRY Link = FilterModuleList.Flink; Link != &FilterModuleList; Link = Link->Flink)
- {
- PMS_FILTER pFilter = CONTAINING_RECORD(Link, MS_FILTER, FilterModuleLink);
-
- if (pFilter->otThreadId == CurThreadId)
- {
- pOutput = pFilter;
- break;
- }
- }
-
- NdisReleaseSpinLock(&FilterListLock);
-
- NT_ASSERT(pOutput);
- return pOutput;
-}
-#endif
-
-#define OTPLAT_CALLOC_TAG 'OTDM'
-#define BUFFER_POOL_TAG 'OTBP'
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void
-otLwfReleaseInstance(
- _In_ PMS_FILTER pFilter
- )
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- if (pFilter->otCtx != NULL)
- {
- otInstanceFinalize(pFilter->otCtx);
- pFilter->otCtx = NULL;
-
-#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
-
- // Free all the pools as there should be no outstanding
- // references to the buffers any more.
- BufferPool *curPool = pFilter->otBufferPoolHead;
- while (curPool != NULL)
- {
- BufferPool *nextPool = curPool->Next;
- ExFreePoolWithTag(curPool, BUFFER_POOL_TAG);
- curPool = nextPool;
- }
-
-#endif
-
-#if DEBUG_ALLOC
-
- NT_ASSERT(pFilter->otOutstandingAllocationCount == 0);
- NT_ASSERT(pFilter->otOutstandingMemoryAllocated == 0);
- PLIST_ENTRY Link = pFilter->otOutStandingAllocations.Flink;
- while (Link != &pFilter->otOutStandingAllocations)
- {
- OT_ALLOC* AllocHeader = CONTAINING_RECORD(Link, OT_ALLOC, Link);
- Link = Link->Flink;
-
- LogVerbose(DRIVER_DEFAULT, "Leaked Alloc ID:%u", AllocHeader->ID);
-
- ExFreePoolWithTag(AllocHeader, OTPLAT_CALLOC_TAG);
- }
-
-#endif
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-//
-// OpenThread Platform functions
-//
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void *otPlatCAlloc(size_t aNum, size_t aSize)
-{
- size_t totalSize = aNum * aSize;
-#if DEBUG_ALLOC
- totalSize += sizeof(OT_ALLOC);
-#endif
- PVOID mem = ExAllocatePoolWithTag(PagedPool, totalSize, OTPLAT_CALLOC_TAG);
- if (mem)
- {
- RtlZeroMemory(mem, totalSize);
-#if DEBUG_ALLOC
- PMS_FILTER pFilter = otLwfFindFromCurrentThread();
- //LogVerbose(DRIVER_DEFAULT, "otPlatAlloc(%u) = ID:%u %p", (ULONG)totalSize, pFilter->otAllocationID, mem);
-
- OT_ALLOC* AllocHeader = (OT_ALLOC*)mem;
- AllocHeader->Length = (LONG)totalSize;
- AllocHeader->ID = pFilter->otAllocationID++;
- InsertTailList(&pFilter->otOutStandingAllocations, &AllocHeader->Link);
-
- InterlockedIncrement(&pFilter->otOutstandingAllocationCount);
- InterlockedAdd(&pFilter->otOutstandingMemoryAllocated, AllocHeader->Length);
-
- mem = (PUCHAR)(mem) + sizeof(OT_ALLOC);
-#endif
- }
- return mem;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void otPlatFree(_In_opt_ void *aPtr)
-{
- if (aPtr == NULL) return;
-#if DEBUG_ALLOC
- aPtr = (PUCHAR)(aPtr) - sizeof(OT_ALLOC);
- //LogVerbose(DRIVER_DEFAULT, "otPlatFree(%p)", aPtr);
- OT_ALLOC* AllocHeader = (OT_ALLOC*)aPtr;
-
- PMS_FILTER pFilter = otLwfFindFromCurrentThread();
- InterlockedDecrement(&pFilter->otOutstandingAllocationCount);
- InterlockedAdd(&pFilter->otOutstandingMemoryAllocated, -AllocHeader->Length);
- RemoveEntryList(&AllocHeader->Link);
-#endif
- ExFreePoolWithTag(aPtr, OTPLAT_CALLOC_TAG);
-}
-
-#if OPENTHREAD_CONFIG_PLATFORM_MESSAGE_MANAGEMENT
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-BufferPool* AllocBufferPool(_In_ PMS_FILTER pFilter)
-{
- // Allocate the memory
- BufferPool* bufPool = (BufferPool*)ExAllocatePoolWithTag(PagedPool, pFilter->otBufferPoolByteSize, BUFFER_POOL_TAG);
- if (bufPool == NULL)
- {
- LogWarning(DRIVER_DEFAULT, "Failed to allocate new buffer pool!");
- return NULL;
- }
-
- // Zero out the memory
- RtlZeroMemory(bufPool, pFilter->otBufferPoolByteSize);
-
- // Set all mNext for the buffers
- otMessage* prevBuf = (otMessage*)bufPool->Buffers;
- for (uint16_t i = 1; i < pFilter->otBufferPoolBufferCount; i++)
- {
- otMessage* curBuf =
- (otMessage*)&bufPool->Buffers[i * pFilter->otBufferSize];
-
- prevBuf->mNext = curBuf;
- prevBuf = curBuf;
- }
-
- LogVerbose(DRIVER_DEFAULT, "Allocated new buffer pool (%d bytes)!", pFilter->otBufferPoolByteSize);
-
- return bufPool;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-otMessage* GetNextFreeBufferFromPool(_In_ PMS_FILTER pFilter)
-{
- // Immediately return if we have hit our limit
- if (pFilter->otBuffersLeft == 0) return NULL;
-
- // If we don't have any free buffers left, allocate another pool
- if (pFilter->otFreeBuffers == NULL)
- {
- BufferPool *newPool = AllocBufferPool(pFilter);
- if (newPool == NULL) return NULL; // Out of physical memory
-
- // Push on top of the pool list
- newPool->Next = pFilter->otBufferPoolHead;
- pFilter->otBufferPoolHead = newPool;
-
- // Set the free buffer list
- pFilter->otFreeBuffers = (otMessage*)newPool->Buffers;
- }
-
- // Pop the top free buffer
- otMessage* buffer = pFilter->otFreeBuffers;
- pFilter->otFreeBuffers = pFilter->otFreeBuffers->mNext;
- pFilter->otBuffersLeft--;
- buffer->mNext = NULL;
- return buffer;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void otPlatMessagePoolInit(_In_ otInstance *otCtx, uint16_t aMinNumFreeBuffers, size_t aBufferSize)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- LogFuncEntry(DRIVER_DEFAULT);
- UNREFERENCED_PARAMETER(aMinNumFreeBuffers);
-
- // Initialize parameters
- pFilter->otBufferSize = (uint16_t)aBufferSize;
- pFilter->otBufferPoolByteSize = (uint16_t)(kPageSize * kPagesPerBufferPool);
- pFilter->otBufferPoolBufferCount = (uint16_t)((pFilter->otBufferPoolByteSize - sizeof(BufferPool)) / aBufferSize);
- pFilter->otBuffersLeft = kMaxPagesForBufferPools * pFilter->otBufferPoolBufferCount;
-
- // Allocate first pool
- pFilter->otBufferPoolHead = AllocBufferPool(pFilter);
- ASSERT(pFilter->otBufferPoolHead); // Should this API allow for failure ???
-
- // Set initial free buffer list
- pFilter->otFreeBuffers = (otMessage*)pFilter->otBufferPoolHead->Buffers;
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-otMessage *otPlatMessagePoolNew(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- return GetNextFreeBufferFromPool(pFilter);
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void otPlatMessagePoolFree(_In_ otInstance *otCtx, _In_ otMessage *aBuffer)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
-
- // Put buffer back on the list
- aBuffer->mNext = pFilter->otFreeBuffers;
- pFilter->otFreeBuffers = aBuffer;
- pFilter->otBuffersLeft++;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-uint16_t otPlatMessagePoolNumFreeBuffers(_In_ otInstance *otCtx)
-{
- NT_ASSERT(otCtx);
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- return pFilter->otBuffersLeft;
-}
-
-#endif
-
-otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength)
-{
- // Just use the system-preferred random number generator algorithm
- NTSTATUS status =
- BCryptGenRandom(
- NULL,
- aOutput,
- (ULONG)aOutputLength,
- BCRYPT_USE_SYSTEM_PREFERRED_RNG
- );
- NT_ASSERT(NT_SUCCESS(status));
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "BCryptGenRandom failed, %!STATUS!", status);
- return OT_ERROR_FAILED;
- }
-
- return OT_ERROR_NONE;
-}
-
-void otTaskletsSignalPending(_In_ otInstance *otCtx)
-{
- LogVerbose(DRIVER_DEFAULT, "otTaskletsSignalPending");
- PMS_FILTER pFilter = otCtxToFilter(otCtx);
- otLwfEventProcessingIndicateNewTasklet(pFilter);
-}
-
-// Process a role state change
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfProcessRoleStateChange(
- _In_ PMS_FILTER pFilter
- )
-{
- otDeviceRole prevRole = pFilter->otCachedRole;
- pFilter->otCachedRole = otThreadGetDeviceRole(pFilter->otCtx);
- if (prevRole == pFilter->otCachedRole) return;
-
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! new role: %!otDeviceRole!", &pFilter->InterfaceGuid, pFilter->otCachedRole);
-
- // Make sure we are in the correct media connect state
- otLwfIndicateLinkState(
- pFilter,
- IsAttached(pFilter->otCachedRole) ?
- MediaConnectStateConnected :
- MediaConnectStateDisconnected);
-}
-
-void otLwfStateChangedCallback(uint32_t aFlags, _In_ void *aContext)
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PMS_FILTER pFilter = (PMS_FILTER)aContext;
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
-
- //
- // Process the notification internally
- //
-
- if ((aFlags & OT_CHANGED_IP6_ADDRESS_ADDED) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_CHANGED_IP6_ADDRESS_ADDED", pFilter);
- otLwfRadioAddressesUpdated(pFilter);
- }
-
- if ((aFlags & OT_CHANGED_IP6_ADDRESS_REMOVED) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_CHANGED_IP6_ADDRESS_REMOVED", pFilter);
- otLwfRadioAddressesUpdated(pFilter);
- }
-
- if ((aFlags & OT_CHANGED_THREAD_RLOC_ADDED) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_CHANGED_THREAD_RLOC_ADDED", pFilter);
- otLwfRadioAddressesUpdated(pFilter);
- }
-
- if ((aFlags & OT_CHANGED_THREAD_RLOC_REMOVED) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_CHANGED_THREAD_RLOC_REMOVED", pFilter);
- otLwfRadioAddressesUpdated(pFilter);
- }
-
- if ((aFlags & OT_CHANGED_THREAD_ROLE) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_CHANGED_THREAD_ROLE", pFilter);
- otLwfProcessRoleStateChange(pFilter);
- }
-
- if ((aFlags & OT_CHANGED_THREAD_PARTITION_ID) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_CHANGED_THREAD_PARTITION_ID", pFilter);
- }
-
- if ((aFlags & OT_CHANGED_THREAD_KEY_SEQUENCE_COUNTER) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_CHANGED_THREAD_KEY_SEQUENCE_COUNTER", pFilter);
- }
-
- if ((aFlags & OT_CHANGED_THREAD_CHILD_ADDED) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_CHANGED_THREAD_CHILD_ADDED", pFilter);
- }
-
- if ((aFlags & OT_CHANGED_THREAD_CHILD_REMOVED) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_CHANGED_THREAD_CHILD_REMOVED", pFilter);
- }
-
- if ((aFlags & OT_CHANGED_THREAD_NETDATA) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_CHANGED_THREAD_NETDATA", pFilter);
- }
-
- if ((aFlags & OT_CHANGED_THREAD_ML_ADDR) != 0)
- {
- LogVerbose(DRIVER_DEFAULT, "Filter %p received OT_CHANGED_THREAD_ML_ADDR", pFilter);
- }
-
- //
- // Queue the notification for clients
- //
-
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_STATE_CHANGE;
- NotifEntry->Notif.StateChangePayload.Flags = aFlags;
-
- otLwfIndicateNotification(NotifEntry);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-void otLwfActiveScanCallback(_In_ otActiveScanResult *aResult, _In_ void *aContext)
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PMS_FILTER pFilter = (PMS_FILTER)aContext;
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_ACTIVE_SCAN;
-
- if (aResult)
- {
- NotifEntry->Notif.ActiveScanPayload.Valid = TRUE;
- NotifEntry->Notif.ActiveScanPayload.Results = *aResult;
- }
- else
- {
- NotifEntry->Notif.ActiveScanPayload.Valid = FALSE;
- }
-
- otLwfIndicateNotification(NotifEntry);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-void otLwfEnergyScanCallback(_In_ otEnergyScanResult *aResult, _In_ void *aContext)
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PMS_FILTER pFilter = (PMS_FILTER)aContext;
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_ENERGY_SCAN;
-
- if (aResult)
- {
- NotifEntry->Notif.EnergyScanPayload.Valid = TRUE;
- NotifEntry->Notif.EnergyScanPayload.Results = *aResult;
- }
- else
- {
- NotifEntry->Notif.EnergyScanPayload.Valid = FALSE;
- }
-
- otLwfIndicateNotification(NotifEntry);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-void otLwfDiscoverCallback(_In_ otActiveScanResult *aResult, _In_ void *aContext)
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PMS_FILTER pFilter = (PMS_FILTER)aContext;
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_DISCOVER;
-
- if (aResult)
- {
- NotifEntry->Notif.DiscoverPayload.Valid = TRUE;
- NotifEntry->Notif.DiscoverPayload.Results = *aResult;
- }
- else
- {
- NotifEntry->Notif.DiscoverPayload.Valid = FALSE;
- }
-
- otLwfIndicateNotification(NotifEntry);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-void otLwfCommissionerEnergyReportCallback(uint32_t aChannelMask, const uint8_t *aEnergyList, uint8_t aEnergyListLength, void *aContext)
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PMS_FILTER pFilter = (PMS_FILTER)aContext;
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_COMMISSIONER_ENERGY_REPORT;
-
- // Limit the number of reports if necessary
- if (aEnergyListLength > MAX_ENERGY_REPORT_LENGTH) aEnergyListLength = MAX_ENERGY_REPORT_LENGTH;
-
- NotifEntry->Notif.CommissionerEnergyReportPayload.ChannelMask = aChannelMask;
- NotifEntry->Notif.CommissionerEnergyReportPayload.EnergyListLength = aEnergyListLength;
- memcpy(NotifEntry->Notif.CommissionerEnergyReportPayload.EnergyList, aEnergyList, aEnergyListLength);
-
- otLwfIndicateNotification(NotifEntry);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-void otLwfCommissionerPanIdConflictCallback(uint16_t aPanId, uint32_t aChannelMask, _In_ void *aContext)
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PMS_FILTER pFilter = (PMS_FILTER)aContext;
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_COMMISSIONER_PANID_QUERY;
-
- NotifEntry->Notif.CommissionerPanIdQueryPayload.PanId = aPanId;
- NotifEntry->Notif.CommissionerPanIdQueryPayload.ChannelMask = aChannelMask;
-
- otLwfIndicateNotification(NotifEntry);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-void otLwfJoinerCallback(otError aError, _In_ void *aContext)
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PMS_FILTER pFilter = (PMS_FILTER)aContext;
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_JOINER_COMPLETE;
-
- NotifEntry->Notif.JoinerCompletePayload.Error = aError;
-
- otLwfIndicateNotification(NotifEntry);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfThreadValueIs(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ spinel_prop_key_t key,
- _In_reads_bytes_(value_data_len) const uint8_t* value_data_ptr,
- _In_ spinel_size_t value_data_len
- )
-{
- LogFuncEntryMsg(DRIVER_DEFAULT, "[%p] received Value for %s", pFilter, spinel_prop_key_to_cstr(key));
-
- if (key == SPINEL_PROP_MAC_ENERGY_SCAN_RESULT)
- {
- uint8_t scanChannel;
- int8_t maxRssi;
- spinel_ssize_t ret;
-
- ret = spinel_datatype_unpack(
- value_data_ptr,
- value_data_len,
- "Cc",
- &scanChannel,
- &maxRssi);
-
- NT_ASSERT(ret > 0);
- if (ret > 0)
- {
- LogInfo(DRIVER_DEFAULT, "Filter: %p, completed energy scan: Rssi:%d", pFilter, maxRssi);
- otLwfEventProcessingIndicateEnergyScanResult(pFilter, maxRssi);
- }
- }
- else if (key == SPINEL_PROP_STREAM_RAW)
- {
- if (value_data_len < 256)
- {
- otLwfEventProcessingIndicateNewMacFrameCommand(
- pFilter,
- DispatchLevel,
- value_data_ptr,
- (uint8_t)value_data_len);
- }
- }
- else if (key == SPINEL_PROP_STREAM_DEBUG)
- {
- const uint8_t* output = NULL;
- UINT output_len = 0;
- spinel_ssize_t ret;
-
- ret = spinel_datatype_unpack(
- value_data_ptr,
- value_data_len,
- SPINEL_DATATYPE_DATA_S,
- &output,
- &output_len);
-
- NT_ASSERT(ret > 0);
- if (ret > 0 && output && output_len <= (UINT)ret)
- {
- if (strnlen((char*)output, output_len) != output_len)
- {
- LogInfo(DRIVER_DEFAULT, "DEVICE: %s", (char*)output);
- }
- else if (output_len < 128)
- {
- char strOutput[128] = { 0 };
- memcpy(strOutput, output, output_len);
- LogInfo(DRIVER_DEFAULT, "DEVICE: %s", strOutput);
- }
- }
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfThreadValueInserted(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ spinel_prop_key_t key,
- _In_reads_bytes_(value_data_len) const uint8_t* value_data_ptr,
- _In_ spinel_size_t value_data_len
- )
-{
- LogFuncEntryMsg(DRIVER_DEFAULT, "[%p] received Value Inserted for %s", pFilter, spinel_prop_key_to_cstr(key));
-
- UNREFERENCED_PARAMETER(pFilter);
- UNREFERENCED_PARAMETER(DispatchLevel);
- UNREFERENCED_PARAMETER(key);
- UNREFERENCED_PARAMETER(value_data_ptr);
- UNREFERENCED_PARAMETER(value_data_len);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
diff --git a/examples/drivers/windows/otLwf/thread.h b/examples/drivers/windows/otLwf/thread.h
deleted file mode 100644
index 4621b343b..000000000
--- a/examples/drivers/windows/otLwf/thread.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines the functions for the otLwf Filter Thread mode.
- */
-
-#ifndef _THREAD_H_
-#define _THREAD_H_
-
-// Helper function that converts an otInstance pointer to a MS_FILTER pointer
-__inline PMS_FILTER otCtxToFilter(_In_ otInstance* otCtx)
-{
- return *(PMS_FILTER*)((PUCHAR)otCtx - sizeof(PMS_FILTER));
-}
-
-// Helper function to indicate if a role means it is attached or not
-_inline BOOLEAN IsAttached(_In_ otDeviceRole role)
-{
- return role > OT_DEVICE_ROLE_DETACHED;
-}
-
-//
-// Initialization functions
-//
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NDIS_STATUS
-otLwfInitializeThreadMode(
- _In_ PMS_FILTER pFilter
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void
-otLwfUninitializeThreadMode(
- _In_ PMS_FILTER pFilter
- );
-
-//
-// Clean up otInstance
-//
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void
-otLwfReleaseInstance(
- _In_ PMS_FILTER pFilter
- );
-
-//
-// Event Processing Functions
-//
-
-EXT_CALLBACK otLwfEventProcessingTimer;
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfEventProcessingStart(
- _In_ PMS_FILTER pFilter
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingStop(
- _In_ PMS_FILTER pFilter
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingIndicateNewWaitTime(
- _In_ PMS_FILTER pFilter,
- _In_ ULONG waitTime
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingIndicateNewTasklet(
- _In_ PMS_FILTER pFilter
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingIndicateAddressChange(
- _In_ PMS_FILTER pFilter,
- _In_ MIB_NOTIFICATION_TYPE NotificationType,
- _In_ PIN6_ADDR pAddr
- );
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfEventProcessingIndicateNewNetBufferLists(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ PNET_BUFFER_LIST NetBufferLists
- );
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfEventProcessingIndicateNewMacFrameCommand(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_reads_bytes_(BufferLength)
- const uint8_t* Buffer,
- _In_ uint8_t BufferLength
- );
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfEventProcessingIndicateNetBufferListsCancelled(
- _In_ PMS_FILTER pFilter,
- _In_ PVOID CancelId
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-otLwfEventProcessingIndicateIrp(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP Irp
- );
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfEventProcessingIndicateEnergyScanResult(
- _In_ PMS_FILTER pFilter,
- _In_ CHAR MaxRssi
- );
-
-//
-// OpenThread callbacks
-//
-
-void otLwfStateChangedCallback(uint32_t aFlags, _In_ void *aContext);
-void otLwfReceiveIp6DatagramCallback(_In_ otMessage *aMessage, _In_ void *aContext);
-void otLwfActiveScanCallback(_In_ otActiveScanResult *aResult, _In_ void *aContext);
-void otLwfEnergyScanCallback(_In_ otEnergyScanResult *aResult, _In_ void *aContext);
-void otLwfDiscoverCallback(_In_ otActiveScanResult *aResult, _In_ void *aContext);
-void otLwfCommissionerEnergyReportCallback(uint32_t aChannelMask, const uint8_t *aEnergyList, uint8_t aEnergyListLength, void *aContext);
-void otLwfCommissionerPanIdConflictCallback(uint16_t aPanId, uint32_t aChannelMask, _In_ void *aContext);
-void otLwfJoinerCallback(otError aError, _In_ void *aContext);
-
-//
-// Value Callbacks
-//
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfThreadValueIs(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ spinel_prop_key_t key,
- _In_reads_bytes_(value_data_len) const uint8_t* value_data_ptr,
- _In_ spinel_size_t value_data_len
- );
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfThreadValueInserted(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ spinel_prop_key_t key,
- _In_reads_bytes_(value_data_len) const uint8_t* value_data_ptr,
- _In_ spinel_size_t value_data_len
- );
-
-#endif //_THREAD_H_
diff --git a/examples/drivers/windows/otLwf/tunnel.c b/examples/drivers/windows/otLwf/tunnel.c
deleted file mode 100644
index e28178d51..000000000
--- a/examples/drivers/windows/otLwf/tunnel.c
+++ /dev/null
@@ -1,671 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file implements the Tunnel mode (Thread Miniport) functions required for the OpenThread library.
- */
-
-#include "precomp.h"
-#include "tunnel.tmh"
-
-KSTART_ROUTINE otLwfTunWorkerThread;
-
-SPINEL_CMD_HANDLER otLwfIrpCommandHandler;
-
-typedef struct _SPINEL_IRP_CMD_CONTEXT
-{
- PMS_FILTER pFilter;
- PIRP Irp;
- SPINEL_IRP_CMD_HANDLER *Handler;
- spinel_tid_t tid;
-} SPINEL_IRP_CMD_CONTEXT;
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NDIS_STATUS
-otLwfTunInitialize(
- _In_ PMS_FILTER pFilter
- )
-{
- NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
- HANDLE threadHandle = NULL;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- NT_ASSERT(pFilter->DeviceCapabilities & OTLWF_DEVICE_CAP_THREAD_1_0);
-
- KeInitializeEvent(
- &pFilter->TunWorkerThreadStopEvent,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
- KeInitializeEvent(
- &pFilter->TunWorkerThreadAddressChangedEvent,
- SynchronizationEvent, // auto-clearing event
- FALSE // event initially non-signalled
- );
-
- // Start the worker thread
- Status = PsCreateSystemThread(
- &threadHandle, // ThreadHandle
- THREAD_ALL_ACCESS, // DesiredAccess
- NULL, // ObjectAttributes
- NULL, // ProcessHandle
- NULL, // ClientId
- otLwfTunWorkerThread, // StartRoutine
- pFilter // StartContext
- );
- if (!NT_SUCCESS(Status))
- {
- LogError(DRIVER_DEFAULT, "PsCreateSystemThread failed, %!STATUS!", Status);
- goto error;
- }
-
- // Grab the object reference to the worker thread
- Status = ObReferenceObjectByHandle(
- threadHandle,
- THREAD_ALL_ACCESS,
- *PsThreadType,
- KernelMode,
- &pFilter->TunWorkerThread,
- NULL
- );
- if (!NT_VERIFYMSG("ObReferenceObjectByHandle can't fail with a valid kernel handle", NT_SUCCESS(Status)))
- {
- LogError(DRIVER_DEFAULT, "ObReferenceObjectByHandle failed, %!STATUS!", Status);
- KeSetEvent(&pFilter->TunWorkerThreadStopEvent, IO_NO_INCREMENT, FALSE);
- }
-
- // Make sure to enable RLOC passthrough
- Status =
- otLwfCmdSetProp(
- pFilter,
- SPINEL_PROP_THREAD_RLOC16_DEBUG_PASSTHRU,
- SPINEL_DATATYPE_BOOL_S,
- TRUE
- );
- if (!NT_SUCCESS(Status))
- {
- LogError(DRIVER_DEFAULT, "Enabling RLOC pass through failed, %!STATUS!", Status);
- goto error;
- }
-
- // TODO - Query other values and capabilities
-
-error:
-
- if (!NT_SUCCESS(Status))
- {
- otLwfTunUninitialize(pFilter);
- }
-
- LogFuncExitNDIS(DRIVER_DEFAULT, Status);
-
- return Status;
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void
-otLwfTunUninitialize(
- _In_ PMS_FILTER pFilter
- )
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- // Clean up worker thread
- if (pFilter->TunWorkerThread)
- {
- LogInfo(DRIVER_DEFAULT, "Stopping tunnel worker thread and waiting for it to complete.");
-
- // Send event to shutdown worker thread
- KeSetEvent(&pFilter->TunWorkerThreadStopEvent, 0, FALSE);
-
- // Wait for worker thread to finish
- KeWaitForSingleObject(
- pFilter->TunWorkerThread,
- Executive,
- KernelMode,
- FALSE,
- NULL
- );
-
- // Free worker thread
- ObDereferenceObject(pFilter->TunWorkerThread);
- pFilter->TunWorkerThread = NULL;
-
- LogInfo(DRIVER_DEFAULT, "Tunnel worker thread cleaned up.");
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-// Worker thread for processing all tunnel events
-_Use_decl_annotations_
-VOID
-otLwfTunWorkerThread(
- PVOID Context
- )
-{
- PMS_FILTER pFilter = (PMS_FILTER)Context;
- NT_ASSERT(pFilter);
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PKEVENT WaitEvents[] =
- {
- &pFilter->TunWorkerThreadStopEvent,
- &pFilter->TunWorkerThreadAddressChangedEvent
- };
-
- LogFuncExit(DRIVER_DEFAULT);
-
- while (true)
- {
- // Wait for event to stop or process event to fire
- NTSTATUS status =
- KeWaitForMultipleObjects(
- ARRAYSIZE(WaitEvents),
- (PVOID*)WaitEvents,
- WaitAny,
- Executive,
- KernelMode,
- FALSE,
- NULL,
- NULL);
-
- // If it is the first event, then we are shutting down. Exit loop and terminate thread
- if (status == STATUS_WAIT_0)
- {
- LogInfo(DRIVER_DEFAULT, "Received tunnel worker thread shutdown event.");
- break;
- }
- else if (status == STATUS_WAIT_0 + 1) // TunWorkerThreadAddressChangedEvent fired
- {
- PVOID DataBuffer = NULL;
- const uint8_t* value_data_ptr = NULL;
- spinel_size_t value_data_len = 0;
-
- // Query the current addresses
- status =
- otLwfCmdGetProp(
- pFilter,
- &DataBuffer,
- SPINEL_PROP_IPV6_ADDRESS_TABLE,
- SPINEL_DATATYPE_DATA_S,
- &value_data_ptr,
- &value_data_len);
- if (NT_SUCCESS(status))
- {
- uint32_t aNotifFlags = 0;
- otLwfTunAddressesUpdated(pFilter, value_data_ptr, value_data_len, &aNotifFlags);
-
- // Send notification
- if (aNotifFlags != 0)
- {
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_STATE_CHANGE;
- NotifEntry->Notif.StateChangePayload.Flags = aNotifFlags;
-
- otLwfIndicateNotification(NotifEntry);
- }
- }
- }
- else
- {
- LogWarning(DRIVER_DEFAULT, "Failed to query addresses, %!STATUS!", status);
- }
-
- if (DataBuffer) FILTER_FREE_MEM(DataBuffer);
- }
- else
- {
- LogWarning(DRIVER_DEFAULT, "Unexpected wait result, %!STATUS!", status);
- }
- }
-
- PsTerminateSystemThread(STATUS_SUCCESS);
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-VOID
-otLwfIrpCommandHandler(
- _In_ PMS_FILTER pFilter,
- _In_ PVOID Context,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_reads_bytes_(DataLength) const uint8_t* Data,
- _In_ spinel_size_t DataLength
- )
-{
- SPINEL_IRP_CMD_CONTEXT* CmdContext = (SPINEL_IRP_CMD_CONTEXT*)Context;
- PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(CmdContext->Irp);
-
- ULONG IoControlCode = IrpSp->Parameters.DeviceIoControl.IoControlCode;
- PVOID OutBuffer = CmdContext->Irp->AssociatedIrp.SystemBuffer;
- ULONG OutBufferLength = IrpSp->Parameters.DeviceIoControl.OutputBufferLength;
- ULONG OrigOutBufferLength = OutBufferLength;
-
- NTSTATUS status;
-
- UNREFERENCED_PARAMETER(pFilter);
-
- // Clear the cancel routine
- IoSetCancelRoutine(CmdContext->Irp, NULL);
-
- if (Data == NULL)
- {
- status = STATUS_CANCELLED;
- OutBufferLength = 0;
- }
- else if (Command == SPINEL_CMD_PROP_VALUE_IS && Key == SPINEL_PROP_LAST_STATUS)
- {
- spinel_status_t spinel_status = SPINEL_STATUS_OK;
- spinel_ssize_t packed_len = spinel_datatype_unpack(Data, DataLength, "i", &spinel_status);
- if (packed_len < 0 || (ULONG)packed_len > DataLength)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- }
- else
- {
- status = ThreadErrorToNtstatus(SpinelStatusToThreadError(spinel_status));
- }
- }
- else if (CmdContext->Handler)
- {
- status = CmdContext->Handler(Key, Data, DataLength, OutBuffer, &OutBufferLength);
- }
- else // No handler, so no output
- {
- status = STATUS_SUCCESS;
- OutBufferLength = 0;
- }
-
- // Clear any leftover output buffer
- if (OutBufferLength < OrigOutBufferLength)
- {
- RtlZeroMemory((PUCHAR)OutBuffer + OutBufferLength, OrigOutBufferLength - OutBufferLength);
- }
-
- LogVerbose(DRIVER_IOCTL, "Completing Irp=%p, with %!STATUS! for %s (Out:%u)",
- CmdContext->Irp, status, IoCtlString(IoControlCode), OutBufferLength);
-
- // Complete the IRP
- CmdContext->Irp->IoStatus.Information = OutBufferLength;
- CmdContext->Irp->IoStatus.Status = status;
- IoCompleteRequest(CmdContext->Irp, IO_NO_INCREMENT);
-
- FILTER_FREE_MEM(Context);
-}
-
-_Function_class_(DRIVER_CANCEL)
-_Requires_lock_held_(_Global_cancel_spin_lock_)
-_Releases_lock_(_Global_cancel_spin_lock_)
-_IRQL_requires_min_(DISPATCH_LEVEL)
-_IRQL_requires_(DISPATCH_LEVEL)
-VOID
-otLwfTunCancelIrp(
- _Inout_ struct _DEVICE_OBJECT *DeviceObject,
- _Inout_ _IRQL_uses_cancel_ struct _IRP *Irp
- )
-{
- PIO_STACK_LOCATION IrpStack = IoGetCurrentIrpStackLocation(Irp);
- SPINEL_IRP_CMD_CONTEXT* CmdContext = (SPINEL_IRP_CMD_CONTEXT*)IrpStack->Context;
-
- UNREFERENCED_PARAMETER(DeviceObject);
-
- LogFuncEntryMsg(DRIVER_IOCTL, "Irp=%p", Irp);
-
- IoReleaseCancelSpinLock(Irp->CancelIrql);
-
- // Try to cancel pending command
- otLwfCmdCancel(
- CmdContext->pFilter,
- (Irp->CancelIrql == DISPATCH_LEVEL) ? TRUE : FALSE,
- CmdContext->tid);
-
- LogFuncExit(DRIVER_IOCTL);
-}
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunSendCommandForIrp(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP Irp,
- _In_opt_ SPINEL_IRP_CMD_HANDLER *Handler,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_ ULONG MaxDataLength,
- _In_opt_ const char *pack_format,
- ...
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- SPINEL_IRP_CMD_CONTEXT *pContext = NULL;
- PIO_STACK_LOCATION IrpStack = IoGetCurrentIrpStackLocation(Irp);
-
- // Create the context structure
- pContext = FILTER_ALLOC_MEM(pFilter->FilterHandle, sizeof(SPINEL_IRP_CMD_CONTEXT));
- if (pContext == NULL)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- LogWarning(DRIVER_DEFAULT, "Failed to allocate irp cmd context");
- goto exit;
- }
-
- pContext->pFilter = pFilter;
- pContext->Irp = Irp;
- pContext->Handler = Handler;
-
- NT_ASSERT(IrpStack->Context == NULL);
- IrpStack->Context = pContext;
-
- // Set the cancel routine
- IoSetCancelRoutine(Irp, otLwfTunCancelIrp);
-
- va_list args;
- va_start(args, pack_format);
- status =
- otLwfCmdSendAsyncV(
- pFilter,
- otLwfIrpCommandHandler,
- pContext,
- &pContext->tid,
- Command,
- Key,
- MaxDataLength,
- pack_format,
- args);
- va_end(args);
-
- // Remove the handler entry from the list
- if (!NT_SUCCESS(status))
- {
- // Clear the cancel routine
- IoSetCancelRoutine(Irp, NULL);
-
- FILTER_FREE_MEM(pContext);
- }
-
-exit:
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfTunValueIs(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ spinel_prop_key_t key,
- _In_reads_bytes_(value_data_len) const uint8_t* value_data_ptr,
- _In_ spinel_size_t value_data_len
- )
-{
- uint32_t aNotifFlags = 0;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "[%p] received Value for %s", pFilter, spinel_prop_key_to_cstr(key));
-
- if (key == SPINEL_PROP_NET_ROLE)
- {
- uint8_t value;
- spinel_datatype_unpack(value_data_ptr, value_data_len, SPINEL_DATATYPE_UINT8_S, &value);
-
- LogInfo(DRIVER_DEFAULT, "Interface %!GUID! new spinel role: %u", &pFilter->InterfaceGuid, value);
-
- // Make sure we are in the correct media connect state
- otLwfIndicateLinkState(
- pFilter,
- value > SPINEL_NET_ROLE_DETACHED ?
- MediaConnectStateConnected :
- MediaConnectStateDisconnected);
-
- // Set flag to indicate we should send a notification
- aNotifFlags = OT_CHANGED_THREAD_ROLE;
- }
- else if (key == SPINEL_PROP_IPV6_LL_ADDR)
- {
- // Set flag to indicate we should send a notification
- aNotifFlags = OT_CHANGED_THREAD_LL_ADDR;
- }
- else if (key == SPINEL_PROP_IPV6_ML_ADDR)
- {
- // Set flag to indicate we should send a notification
- aNotifFlags = OT_CHANGED_THREAD_ML_ADDR;
- }
- else if (key == SPINEL_PROP_NET_PARTITION_ID)
- {
- // Set flag to indicate we should send a notification
- aNotifFlags = OT_CHANGED_THREAD_PARTITION_ID;
- }
- else if (key == SPINEL_PROP_NET_KEY_SEQUENCE_COUNTER)
- {
- // Set flag to indicate we should send a notification
- aNotifFlags = OT_CHANGED_THREAD_KEY_SEQUENCE_COUNTER;
- }
- else if (key == SPINEL_PROP_IPV6_ADDRESS_TABLE)
- {
- KeSetEvent(&pFilter->TunWorkerThreadAddressChangedEvent, IO_NO_INCREMENT, FALSE);
- }
- else if (key == SPINEL_PROP_THREAD_CHILD_TABLE)
- {
- // TODO - Update cached children
- // TODO - Send notification
- }
- else if (key == SPINEL_PROP_THREAD_ON_MESH_NETS)
- {
- // TODO - Slaac
-
- // Set flag to indicate we should send a notification
- aNotifFlags = OT_CHANGED_THREAD_NETDATA;
- }
- else if ((key == SPINEL_PROP_STREAM_NET) || (key == SPINEL_PROP_STREAM_NET_INSECURE))
- {
- const uint8_t* frame_ptr = NULL;
- UINT frame_len = 0;
- spinel_ssize_t ret;
-
- ret = spinel_datatype_unpack(
- value_data_ptr,
- value_data_len,
- SPINEL_DATATYPE_DATA_WLEN_S SPINEL_DATATYPE_DATA_S,
- &frame_ptr,
- &frame_len,
- NULL,
- NULL);
-
- NT_ASSERT(ret > 0);
- if (ret > 0)
- {
- otLwfTunReceiveIp6Packet(
- pFilter,
- DispatchLevel,
- (SPINEL_PROP_STREAM_NET_INSECURE == key) ? FALSE : TRUE,
- frame_ptr,
- frame_len);
- }
- }
- else if (key == SPINEL_PROP_MAC_SCAN_STATE)
- {
- // TODO - If pending scan, send notification of completion
- }
- else if (key == SPINEL_PROP_STREAM_RAW)
- {
- // May be used in the future
- }
- else if (key == SPINEL_PROP_STREAM_DEBUG)
- {
- const uint8_t* output = NULL;
- UINT output_len = 0;
- spinel_ssize_t ret;
-
- ret = spinel_datatype_unpack(
- value_data_ptr,
- value_data_len,
- SPINEL_DATATYPE_DATA_S,
- &output,
- &output_len);
-
- NT_ASSERT(ret > 0);
- if (ret > 0 && output && output_len <= (UINT)ret)
- {
- if (strnlen((char*)output, output_len) != output_len)
- {
- LogInfo(DRIVER_DEFAULT, "DEVICE: %s", (char*)output);
- }
- else if (output_len < 128)
- {
- char strOutput[128] = { 0 };
- memcpy(strOutput, output, output_len);
- LogInfo(DRIVER_DEFAULT, "DEVICE: %s", strOutput);
- }
- }
- }
-
- // Send notification
- if (aNotifFlags != 0)
- {
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_STATE_CHANGE;
- NotifEntry->Notif.StateChangePayload.Flags = aNotifFlags;
-
- otLwfIndicateNotification(NotifEntry);
- }
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfTunValueInserted(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ spinel_prop_key_t key,
- _In_reads_bytes_(value_data_len) const uint8_t* value_data_ptr,
- _In_ spinel_size_t value_data_len
- )
-{
- LogFuncEntryMsg(DRIVER_DEFAULT, "[%p] received Value Inserted for %s", pFilter, spinel_prop_key_to_cstr(key));
-
- UNREFERENCED_PARAMETER(pFilter);
- UNREFERENCED_PARAMETER(DispatchLevel);
- UNREFERENCED_PARAMETER(value_data_ptr);
- UNREFERENCED_PARAMETER(value_data_len);
-
- if (key == SPINEL_PROP_MAC_SCAN_BEACON)
- {
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_ACTIVE_SCAN;
- NotifEntry->Notif.ActiveScanPayload.Valid = TRUE;
-
- const otExtAddress *aExtAddr = NULL;
- const uint8_t *aExtPanId = NULL;
- const char *aNetworkName = NULL;
- unsigned int xpanid_len = 0;
-
- if (try_spinel_datatype_unpack(
- value_data_ptr,
- value_data_len,
- SPINEL_DATATYPE_MAC_SCAN_RESULT_S(
- SPINEL_802_15_4_DATATYPE_MAC_SCAN_RESULT_V1_S,
- SPINEL_NET_DATATYPE_MAC_SCAN_RESULT_V1_S
- ),
- &NotifEntry->Notif.ActiveScanPayload.Results.mChannel,
- &NotifEntry->Notif.ActiveScanPayload.Results.mRssi,
- &aExtAddr,
- NULL, // saddr (don't care)
- &NotifEntry->Notif.ActiveScanPayload.Results.mPanId,
- &NotifEntry->Notif.ActiveScanPayload.Results.mLqi,
- NULL, // proto (don't care)
- NULL, // flags (don't care)
- &aNetworkName,
- &aExtPanId,
- &xpanid_len
- ) &&
- aExtAddr != NULL && aExtPanId != NULL && aNetworkName != NULL &&
- xpanid_len == OT_EXT_PAN_ID_SIZE)
- {
- memcpy_s(NotifEntry->Notif.ActiveScanPayload.Results.mExtAddress.m8,
- sizeof(NotifEntry->Notif.ActiveScanPayload.Results.mExtAddress.m8),
- aExtAddr, sizeof(otExtAddress));
- memcpy_s(NotifEntry->Notif.ActiveScanPayload.Results.mExtendedPanId.m8,
- sizeof(NotifEntry->Notif.ActiveScanPayload.Results.mExtendedPanId.m8),
- aExtPanId, sizeof(otExtendedPanId));
- strcpy_s(NotifEntry->Notif.ActiveScanPayload.Results.mNetworkName.m8,
- sizeof(NotifEntry->Notif.ActiveScanPayload.Results.mNetworkName.m8),
- aNetworkName);
- otLwfIndicateNotification(NotifEntry);
- }
- else
- {
- FILTER_FREE_MEM(NotifEntry);
- }
- }
- }
- else if (key == SPINEL_PROP_MAC_ENERGY_SCAN_RESULT)
- {
- PFILTER_NOTIFICATION_ENTRY NotifEntry = FILTER_ALLOC_NOTIF(pFilter);
- if (NotifEntry)
- {
- RtlZeroMemory(NotifEntry, sizeof(FILTER_NOTIFICATION_ENTRY));
- NotifEntry->Notif.InterfaceGuid = pFilter->InterfaceGuid;
- NotifEntry->Notif.NotifType = OTLWF_NOTIF_ENERGY_SCAN;
- NotifEntry->Notif.EnergyScanPayload.Valid = TRUE;
-
- if (try_spinel_datatype_unpack(
- value_data_ptr,
- value_data_len,
- "Cc",
- &NotifEntry->Notif.EnergyScanPayload.Results.mChannel,
- &NotifEntry->Notif.EnergyScanPayload.Results.mMaxRssi
- ))
- {
- otLwfIndicateNotification(NotifEntry);
- }
- else
- {
- FILTER_FREE_MEM(NotifEntry);
- }
- }
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
diff --git a/examples/drivers/windows/otLwf/tunnel.h b/examples/drivers/windows/otLwf/tunnel.h
deleted file mode 100644
index 83112076f..000000000
--- a/examples/drivers/windows/otLwf/tunnel.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * @brief
- * This file defines the functions for the otLwf Filter Tunnel mode.
- */
-
-#ifndef _TUNNEL_H_
-#define _TUNNEL_H_
-
-//
-// Initialization
-//
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NDIS_STATUS
-otLwfTunInitialize(
- _In_ PMS_FILTER pFilter
- );
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-void
-otLwfTunUninitialize(
- _In_ PMS_FILTER pFilter
- );
-
-//
-// Irp Commands
-//
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-otLwfTunSendCommandForIrp(
- _In_ PMS_FILTER pFilter,
- _In_ PIRP Irp,
- _In_opt_ SPINEL_IRP_CMD_HANDLER *Handler,
- _In_ UINT Command,
- _In_ spinel_prop_key_t Key,
- _In_ ULONG MaxDataLength,
- _In_opt_ const char *pack_format,
- ...
- );
-
-//
-// Value Callbacks
-//
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfTunValueIs(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ spinel_prop_key_t key,
- _In_reads_bytes_(value_data_len) const uint8_t* value_data_ptr,
- _In_ spinel_size_t value_data_len
- );
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfTunValueInserted(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ spinel_prop_key_t key,
- _In_reads_bytes_(value_data_len) const uint8_t* value_data_ptr,
- _In_ spinel_size_t value_data_len
- );
-
-// Called in response to receiving a Spinel Ip6 packet command
-_IRQL_requires_max_(DISPATCH_LEVEL)
-void
-otLwfTunReceiveIp6Packet(
- _In_ PMS_FILTER pFilter,
- _In_ BOOLEAN DispatchLevel,
- _In_ BOOLEAN Secure,
- _In_reads_bytes_(BufferLength) const uint8_t* Buffer,
- _In_ UINT BufferLength
- );
-
-#endif //_TUNNEL_H_
diff --git a/examples/drivers/windows/otNodeApi/dllmain.cpp b/examples/drivers/windows/otNodeApi/dllmain.cpp
deleted file mode 100644
index beae2f684..000000000
--- a/examples/drivers/windows/otNodeApi/dllmain.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "precomp.h"
-#include "dllmain.tmh"
-
-BOOL
-__stdcall
-DllMain(
- HINSTANCE hinstDll,
- DWORD dwReason,
- LPVOID /* lpvReserved */
- )
-{
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls(hinstDll);
- WPP_INIT_TRACING(L"otNodeApi");
- break;
-
- case DLL_PROCESS_DETACH:
- Unload();
- WPP_CLEANUP();
- break;
-
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- break;
- }
-
- return TRUE;
-}
-
diff --git a/examples/drivers/windows/otNodeApi/otNodeApi.cpp b/examples/drivers/windows/otNodeApi/otNodeApi.cpp
deleted file mode 100644
index 39ad50e28..000000000
--- a/examples/drivers/windows/otNodeApi/otNodeApi.cpp
+++ /dev/null
@@ -1,2399 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "precomp.h"
-#include "otNodeApi.tmh"
-
-#define DEBUG_PING 1
-
-#define GUID_FORMAT "{%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX}"
-#define GUID_ARG(guid) guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]
-
-typedef DWORD (*fp_otvmpOpenHandle)(_Out_ HANDLE* phandle);
-typedef VOID (*fp_otvmpCloseHandle)(_In_ HANDLE handle);
-typedef DWORD (*fp_otvmpAddVirtualBus)(_In_ HANDLE handle, _Inout_ ULONG* pBusNumber, _Out_ ULONG* pIfIndex);
-typedef DWORD (*fp_otvmpRemoveVirtualBus)(_In_ HANDLE handle, ULONG BusNumber);
-typedef DWORD (*fp_otvmpSetAdapterTopologyGuid)(_In_ HANDLE handle, DWORD BusNumber, _In_ const GUID* pTopologyGuid);
-typedef void (*fp_otvmpListenerCallback)(_In_opt_ PVOID aContext, _In_ ULONG SourceInterfaceIndex, _In_reads_bytes_(FrameLength) PUCHAR FrameBuffer, _In_ UCHAR FrameLength, _In_ UCHAR Channel);
-typedef HANDLE (*fp_otvmpListenerCreate)(_In_ const GUID* pAdapterTopologyGuid);
-typedef void (*fp_otvmpListenerDestroy)(_In_opt_ HANDLE pHandle);
-typedef void(*fp_otvmpListenerRegister)(_In_ HANDLE pHandle, _In_opt_ fp_otvmpListenerCallback Callback, _In_opt_ PVOID Context);
-
-fp_otvmpOpenHandle otvmpOpenHandle = nullptr;
-fp_otvmpCloseHandle otvmpCloseHandle = nullptr;
-fp_otvmpAddVirtualBus otvmpAddVirtualBus = nullptr;
-fp_otvmpRemoveVirtualBus otvmpRemoveVirtualBus = nullptr;
-fp_otvmpSetAdapterTopologyGuid otvmpSetAdapterTopologyGuid = nullptr;
-fp_otvmpListenerCreate otvmpListenerCreate = nullptr;
-fp_otvmpListenerDestroy otvmpListenerDestroy = nullptr;
-fp_otvmpListenerRegister otvmpListenerRegister = nullptr;
-
-HMODULE gVmpModule = nullptr;
-HANDLE gVmpHandle = nullptr;
-
-ULONG gNextBusNumber = 1;
-GUID gTopologyGuid = {0};
-
-volatile LONG gNumberOfInterfaces = 0;
-CRITICAL_SECTION gCS;
-vector gNodes;
-HANDLE gDeviceArrivalEvent = nullptr;
-
-otApiInstance *gApiInstance = nullptr;
-
-_Success_(return == OT_ERROR_NONE)
-otError otNodeParsePrefix(const char *aStrPrefix, _Out_ otIp6Prefix *aPrefix)
-{
- char *prefixLengthStr;
- char *endptr;
-
- if ((prefixLengthStr = (char*)strchr(aStrPrefix, '/')) == NULL)
- {
- printf("invalid prefix (%s)!\r\n", aStrPrefix);
- return OT_ERROR_INVALID_ARGS;
- }
-
- *prefixLengthStr++ = '\0';
-
- auto error = otIp6AddressFromString(aStrPrefix, &aPrefix->mPrefix);
- if (error != OT_ERROR_NONE)
- {
- printf("ipaddr (%s) to string failed, 0x%x!\r\n", aStrPrefix, error);
- return error;
- }
-
- aPrefix->mLength = static_cast(strtol(prefixLengthStr, &endptr, 0));
-
- if (*endptr != '\0')
- {
- printf("invalid prefix ending (%s)!\r\n", aStrPrefix);
- return OT_ERROR_PARSE;
- }
-
- return OT_ERROR_NONE;
-}
-
-void OTCALL otNodeDeviceAvailabilityChanged(bool aAdded, const GUID *, void *)
-{
- if (aAdded) SetEvent(gDeviceArrivalEvent);
-}
-
-otApiInstance* GetApiInstance()
-{
- if (gApiInstance == nullptr)
- {
- WSADATA wsaData;
- int result = WSAStartup(MAKEWORD(2, 2), &wsaData);
- if (result != 0)
- {
- printf("WSAStartup failed!\r\n");
- return nullptr;
- }
-
- gApiInstance = otApiInit();
- if (gApiInstance == nullptr)
- {
- printf("otApiInit failed!\r\n");
- Unload();
- return nullptr;
- }
-
- InitializeCriticalSection(&gCS);
-
- gVmpModule = LoadLibrary(TEXT("otvmpapi.dll"));
- if (gVmpModule == nullptr)
- {
- printf("LoadLibrary(\"otvmpapi\") failed!\r\n");
- Unload();
- return nullptr;
- }
-
- otvmpOpenHandle = (fp_otvmpOpenHandle)GetProcAddress(gVmpModule, "otvmpOpenHandle");
- otvmpCloseHandle = (fp_otvmpCloseHandle)GetProcAddress(gVmpModule, "otvmpCloseHandle");
- otvmpAddVirtualBus = (fp_otvmpAddVirtualBus)GetProcAddress(gVmpModule, "otvmpAddVirtualBus");
- otvmpRemoveVirtualBus = (fp_otvmpRemoveVirtualBus)GetProcAddress(gVmpModule, "otvmpRemoveVirtualBus");
- otvmpSetAdapterTopologyGuid = (fp_otvmpSetAdapterTopologyGuid)GetProcAddress(gVmpModule, "otvmpSetAdapterTopologyGuid");
- otvmpListenerCreate = (fp_otvmpListenerCreate)GetProcAddress(gVmpModule, "otvmpListenerCreate");
- otvmpListenerDestroy = (fp_otvmpListenerDestroy)GetProcAddress(gVmpModule, "otvmpListenerDestroy");
- otvmpListenerRegister = (fp_otvmpListenerRegister)GetProcAddress(gVmpModule, "otvmpListenerRegister");
-
- assert(otvmpOpenHandle);
- assert(otvmpCloseHandle);
- assert(otvmpAddVirtualBus);
- assert(otvmpRemoveVirtualBus);
- assert(otvmpSetAdapterTopologyGuid);
- assert(otvmpListenerCreate);
- assert(otvmpListenerDestroy);
- assert(otvmpListenerRegister);
-
- if (otvmpOpenHandle == nullptr) printf("otvmpOpenHandle is null!\r\n");
- if (otvmpCloseHandle == nullptr) printf("otvmpCloseHandle is null!\r\n");
- if (otvmpAddVirtualBus == nullptr) printf("otvmpAddVirtualBus is null!\r\n");
- if (otvmpRemoveVirtualBus == nullptr) printf("otvmpRemoveVirtualBus is null!\r\n");
- if (otvmpSetAdapterTopologyGuid == nullptr) printf("otvmpSetAdapterTopologyGuid is null!\r\n");
- if (otvmpListenerCreate == nullptr) printf("otvmpListenerCreate is null!\r\n");
- if (otvmpListenerDestroy == nullptr) printf("otvmpListenerDestroy is null!\r\n");
- if (otvmpListenerRegister == nullptr) printf("otvmpListenerRegister is null!\r\n");
-
- (VOID)otvmpOpenHandle(&gVmpHandle);
- if (gVmpHandle == nullptr)
- {
- printf("otvmpOpenHandle failed!\r\n");
- Unload();
- return nullptr;
- }
-
- auto status = UuidCreate(&gTopologyGuid);
- if (status != NO_ERROR)
- {
- printf("UuidCreate failed, 0x%x!\r\n", status);
- Unload();
- return nullptr;
- }
-
- auto offset = getenv("INSTANCE");
- if (offset)
- {
- gNextBusNumber = (atoi(offset) * 32) % 1000 + 1;
- }
- else
- {
- srand(gTopologyGuid.Data1);
- gNextBusNumber = rand() % 1000 + 1;
- }
-
- gDeviceArrivalEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
-
- // Set callback to wait for device arrival notifications
- otSetDeviceAvailabilityChangedCallback(gApiInstance, otNodeDeviceAvailabilityChanged, nullptr);
-
- printf("New topology created\r\n" GUID_FORMAT " [%d]\r\n\r\n", GUID_ARG(gTopologyGuid), gNextBusNumber);
- }
-
- InterlockedIncrement(&gNumberOfInterfaces);
-
- return gApiInstance;
-}
-
-void ReleaseApiInstance()
-{
- if (0 == InterlockedDecrement(&gNumberOfInterfaces))
- {
- // Uninitialize everything else if this is the last ref
- Unload();
- }
-}
-
-void Unload()
-{
- if (gNumberOfInterfaces != 0)
- {
- printf("Unloaded with %d outstanding nodes!\r\n", gNumberOfInterfaces);
- }
-
- if (gApiInstance)
- {
- otSetDeviceAvailabilityChangedCallback(gApiInstance, nullptr, nullptr);
-
- if (gDeviceArrivalEvent != nullptr)
- {
- CloseHandle(gDeviceArrivalEvent);
- gDeviceArrivalEvent = nullptr;
- }
-
- if (gVmpHandle != nullptr)
- {
- otvmpCloseHandle(gVmpHandle);
- gVmpHandle = nullptr;
- }
-
- if (gVmpModule != nullptr)
- {
- FreeLibrary(gVmpModule);
- gVmpModule = nullptr;
- }
-
- DeleteCriticalSection(&gCS);
-
- otApiFinalize(gApiInstance);
- gApiInstance = nullptr;
-
- WSACleanup();
-
- printf("Topology destroyed\r\n");
- }
-}
-
-int Hex2Bin(const char *aHex, uint8_t *aBin, uint16_t aBinLength)
-{
- size_t hexLength = strlen(aHex);
- const char *hexEnd = aHex + hexLength;
- uint8_t *cur = aBin;
- uint8_t numChars = hexLength & 1;
- uint8_t byte = 0;
-
- if ((hexLength + 1) / 2 > aBinLength)
- {
- return -1;
- }
-
- while (aHex < hexEnd)
- {
- if ('A' <= *aHex && *aHex <= 'F')
- {
- byte |= 10 + (*aHex - 'A');
- }
- else if ('a' <= *aHex && *aHex <= 'f')
- {
- byte |= 10 + (*aHex - 'a');
- }
- else if ('0' <= *aHex && *aHex <= '9')
- {
- byte |= *aHex - '0';
- }
- else
- {
- return -1;
- }
-
- aHex++;
- numChars++;
-
- if (numChars >= 2)
- {
- numChars = 0;
- *cur++ = byte;
- byte = 0;
- }
- else
- {
- byte <<= 4;
- }
- }
-
- return static_cast(cur - aBin);
-}
-
-typedef struct otPingHandler
-{
- otNode* mParentNode;
- bool mActive;
- otIp6Address mAddress;
- SOCKET mSocket;
- CHAR mRecvBuffer[1500];
- WSAOVERLAPPED mOverlapped;
- PTP_WAIT mThreadpoolWait;
- WSABUF mWSARecvBuffer;
- DWORD mNumBytesReceived;
- SOCKADDR_IN6 mSourceAddr6;
- int mSourceAddr6Len;
-
-} otPingHandler;
-
-typedef struct otNode
-{
- uint32_t mId;
- DWORD mBusIndex;
- DWORD mInterfaceIndex;
- otInstance* mInstance;
- HANDLE mEnergyScanEvent;
- HANDLE mPanIdConflictEvent;
- CRITICAL_SECTION mCS;
- vector mPingHandlers;
- vector mMemoryToFree;
-} otNode;
-
-const char* otDeviceRoleToString(otDeviceRole role)
-{
- switch (role)
- {
- case OT_DEVICE_ROLE_DISABLED: return "disabled";
- case OT_DEVICE_ROLE_DETACHED: return "detached";
- case OT_DEVICE_ROLE_CHILD: return "child";
- case OT_DEVICE_ROLE_ROUTER: return "router";
- case OT_DEVICE_ROLE_LEADER: return "leader";
- default: return "invalid";
- }
-}
-
-const USHORT CertificationPingPort = htons(12345);
-
-const IN6_ADDR LinkLocalAllNodesAddress = { { 0xFF, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } };
-const IN6_ADDR LinkLocalAllRoutersAddress = { { 0xFF, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x02 } };
-const IN6_ADDR RealmLocalAllNodesAddress = { { 0xFF, 0x03, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01 } };
-const IN6_ADDR RealmLocalAllRoutersAddress = { { 0xFF, 0x03, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x02 } };
-const IN6_ADDR RealmLocalSpecialAddress = { { 0xFF, 0x33, 0, 0x40, 0xfd, 0xde, 0xad, 0, 0xbe, 0xef, 0, 0, 0, 0, 0, 0x01 } };
-
-void
-CALLBACK
-PingHandlerRecvCallback(
- _Inout_ PTP_CALLBACK_INSTANCE /* Instance */,
- _Inout_opt_ PVOID Context,
- _Inout_ PTP_WAIT /* Wait */,
- _In_ TP_WAIT_RESULT /* WaitResult */
- )
-{
- otPingHandler *aPingHandler = (otPingHandler*)Context;
- if (aPingHandler == NULL) return;
-
- // Get the result of the IO operation
- DWORD cbTransferred = 0;
- DWORD dwFlags = 0;
- if (!WSAGetOverlappedResult(
- aPingHandler->mSocket,
- &aPingHandler->mOverlapped,
- &cbTransferred,
- TRUE,
- &dwFlags))
- {
- int result = WSAGetLastError();
- // Only log if we are shutting down
- if (result != WSAENOTSOCK && result != ERROR_OPERATION_ABORTED)
- printf("WSAGetOverlappedResult failed, 0x%x\r\n", result);
- return;
- }
-
- int result;
-
- // Make sure it didn't come from our address
- if (memcmp(&aPingHandler->mSourceAddr6.sin6_addr, &aPingHandler->mAddress, sizeof(IN6_ADDR)) != 0)
- {
- bool shouldReply = true;
-
- // TODO - Fix this hack...
- auto RecvDest = (const otIp6Address*)aPingHandler->mRecvBuffer;
- if (memcmp(RecvDest, &LinkLocalAllRoutersAddress, sizeof(IN6_ADDR)) == 0 ||
- memcmp(RecvDest, &RealmLocalAllRoutersAddress, sizeof(IN6_ADDR)) == 0)
- {
- auto Role = otThreadGetDeviceRole(aPingHandler->mParentNode->mInstance);
- if (Role != OT_DEVICE_ROLE_LEADER && Role != OT_DEVICE_ROLE_ROUTER)
- shouldReply = false;
- }
-
- if (shouldReply)
- {
-#if DEBUG_PING
- CHAR szIpAddress[46] = { 0 };
- RtlIpv6AddressToStringA(&aPingHandler->mSourceAddr6.sin6_addr, szIpAddress);
- printf("%d: received ping (%d bytes) from %s\r\n", aPingHandler->mParentNode->mId, cbTransferred, szIpAddress);
-#endif
-
- // Send the received data back
- result =
- sendto(
- aPingHandler->mSocket,
- aPingHandler->mRecvBuffer, cbTransferred, 0,
- (SOCKADDR*)&aPingHandler->mSourceAddr6, aPingHandler->mSourceAddr6Len
- );
- if (result == SOCKET_ERROR)
- {
- printf("sendto failed, 0x%x\r\n", WSAGetLastError());
- }
- }
- }
-
- // Start the otpool waiting on the overlapped event
- SetThreadpoolWait(aPingHandler->mThreadpoolWait, aPingHandler->mOverlapped.hEvent, nullptr);
-
- // Post another recv
- dwFlags = MSG_PARTIAL;
- aPingHandler->mSourceAddr6Len = sizeof(aPingHandler->mSourceAddr6);
- result =
- WSARecvFrom(
- aPingHandler->mSocket,
- &aPingHandler->mWSARecvBuffer, 1, &aPingHandler->mNumBytesReceived, &dwFlags,
- (SOCKADDR*)&aPingHandler->mSourceAddr6, &aPingHandler->mSourceAddr6Len,
- &aPingHandler->mOverlapped, nullptr
- );
- if (result != SOCKET_ERROR)
- {
- // Not pending, so manually trigger the event for the Threadpool to execute
- SetEvent(aPingHandler->mOverlapped.hEvent);
- }
- else
- {
- result = WSAGetLastError();
- if (result != WSA_IO_PENDING)
- {
- printf("WSARecvFrom failed, 0x%x\r\n", result);
- }
- }
-}
-
-bool IsMeshLocalEID(otNode *aNode, const otIp6Address *aAddress)
-{
- auto ML_EID = otThreadGetMeshLocalEid(aNode->mInstance);
- if (ML_EID == nullptr) return false;
- bool result = memcmp(ML_EID->mFields.m8, aAddress->mFields.m8, sizeof(otIp6Address)) == 0;
- otFreeMemory(ML_EID);
- return result;
-}
-
-void AddPingHandler(otNode *aNode, const otIp6Address *aAddress)
-{
- otPingHandler *aPingHandler = new otPingHandler();
- aPingHandler->mParentNode = aNode;
- aPingHandler->mAddress = *aAddress;
- aPingHandler->mSocket = INVALID_SOCKET;
- aPingHandler->mOverlapped.hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
- aPingHandler->mWSARecvBuffer = { 1500, aPingHandler->mRecvBuffer };
- aPingHandler->mActive = true;
- aPingHandler->mThreadpoolWait =
- CreateThreadpoolWait(
- PingHandlerRecvCallback,
- aPingHandler,
- nullptr
- );
-
- SOCKADDR_IN6 addr6 = { 0 };
- addr6.sin6_family = AF_INET6;
- addr6.sin6_port = CertificationPingPort;
- memcpy(&addr6.sin6_addr, aAddress, sizeof(IN6_ADDR));
-
-#if DEBUG_PING
- CHAR szIpAddress[46] = { 0 };
- RtlIpv6AddressToStringA(&addr6.sin6_addr, szIpAddress);
-
- printf("%d: starting ping handler for %s\r\n", aNode->mId, szIpAddress);
-#endif
-
- // Put the current thead in the correct compartment
- bool RevertCompartmentOnExit = false;
- ULONG OriginalCompartmentID = GetCurrentThreadCompartmentId();
- if (OriginalCompartmentID != otGetCompartmentId(aNode->mInstance))
- {
- DWORD dwError = ERROR_SUCCESS;
- if ((dwError = SetCurrentThreadCompartmentId(otGetCompartmentId(aNode->mInstance))) != ERROR_SUCCESS)
- {
- printf("SetCurrentThreadCompartmentId failed, 0x%x\r\n", dwError);
- }
- RevertCompartmentOnExit = true;
- }
-
- int result;
- DWORD Flag = FALSE;
- IPV6_MREQ MCReg;
- MCReg.ipv6mr_interface = otGetDeviceIfIndex(aNode->mInstance);
-
- if (aPingHandler->mOverlapped.hEvent == nullptr ||
- aPingHandler->mThreadpoolWait == nullptr)
- {
- goto exit;
- }
-
- // Create the socket
- aPingHandler->mSocket = WSASocketW(AF_INET6, SOCK_DGRAM, IPPROTO_UDP, NULL, 0, WSA_FLAG_OVERLAPPED);
- if (aPingHandler->mSocket == INVALID_SOCKET)
- {
- printf("WSASocket failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
-
- // Bind the socket to the address
- result = bind(aPingHandler->mSocket, (sockaddr*)&addr6, sizeof(addr6));
- if (result == SOCKET_ERROR)
- {
- printf("bind failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
-
- // Block our own sends from getting called as receives
- result = setsockopt(aPingHandler->mSocket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (char *)&Flag, sizeof(Flag));
- if (result == SOCKET_ERROR)
- {
- printf("setsockopt (IPV6_MULTICAST_LOOP) failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
-
- // Bind to the multicast addresses
- if (IN6_IS_ADDR_LINKLOCAL(&addr6.sin6_addr))
- {
- // All nodes address
- MCReg.ipv6mr_multiaddr = LinkLocalAllNodesAddress;
- result = setsockopt(aPingHandler->mSocket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&MCReg, sizeof(MCReg));
- if (result == SOCKET_ERROR)
- {
- printf("setsockopt (IPV6_ADD_MEMBERSHIP) failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
-
- // All routers address
- MCReg.ipv6mr_multiaddr = LinkLocalAllRoutersAddress;
- result = setsockopt(aPingHandler->mSocket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&MCReg, sizeof(MCReg));
- if (result == SOCKET_ERROR)
- {
- printf("setsockopt (IPV6_ADD_MEMBERSHIP) failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
- }
- else if (IsMeshLocalEID(aNode, aAddress))
- {
- // All nodes address
- MCReg.ipv6mr_multiaddr = RealmLocalAllNodesAddress;
- result = setsockopt(aPingHandler->mSocket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&MCReg, sizeof(MCReg));
- if (result == SOCKET_ERROR)
- {
- printf("setsockopt (IPV6_ADD_MEMBERSHIP) failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
-
- // All routers address
- MCReg.ipv6mr_multiaddr = RealmLocalAllRoutersAddress;
- result = setsockopt(aPingHandler->mSocket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&MCReg, sizeof(MCReg));
- if (result == SOCKET_ERROR)
- {
- printf("setsockopt (IPV6_ADD_MEMBERSHIP) failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
-
- // Special realm local address
- MCReg.ipv6mr_multiaddr = RealmLocalSpecialAddress;
- result = setsockopt(aPingHandler->mSocket, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, (char *)&MCReg, sizeof(MCReg));
- if (result == SOCKET_ERROR)
- {
- printf("setsockopt (IPV6_ADD_MEMBERSHIP) failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
- }
-
- // Start the otpool waiting on the overlapped event
- SetThreadpoolWait(aPingHandler->mThreadpoolWait, aPingHandler->mOverlapped.hEvent, nullptr);
-
- // Start the receive
- Flag = MSG_PARTIAL;
- aPingHandler->mSourceAddr6Len = sizeof(aPingHandler->mSourceAddr6);
- result =
- WSARecvFrom(
- aPingHandler->mSocket,
- &aPingHandler->mWSARecvBuffer, 1, &aPingHandler->mNumBytesReceived, &Flag,
- (SOCKADDR*)&aPingHandler->mSourceAddr6, &aPingHandler->mSourceAddr6Len,
- &aPingHandler->mOverlapped, nullptr
- );
- if (result != SOCKET_ERROR)
- {
- // Not pending, so manually trigger the event for the Threadpool to execute
- SetEvent(aPingHandler->mOverlapped.hEvent);
- }
- else
- {
- result = WSAGetLastError();
- if (result != WSA_IO_PENDING)
- {
- printf("WSARecvFrom failed, 0x%x\r\n", result);
- goto exit;
- }
- }
-
- aNode->mPingHandlers.push_back(aPingHandler);
- aPingHandler = nullptr;
-
-exit:
-
- // Revert the comparment if necessary
- if (RevertCompartmentOnExit)
- {
- (VOID)SetCurrentThreadCompartmentId(OriginalCompartmentID);
- }
-
- // Clean up ping handler if necessary
- if (aPingHandler)
- {
- if (aPingHandler->mThreadpoolWait != nullptr)
- {
- if (aPingHandler->mSocket != INVALID_SOCKET)
- closesocket(aPingHandler->mSocket);
- WaitForThreadpoolWaitCallbacks(aPingHandler->mThreadpoolWait, TRUE);
- CloseThreadpoolWait(aPingHandler->mThreadpoolWait);
- }
- if (aPingHandler->mOverlapped.hEvent)
- {
- CloseHandle(aPingHandler->mOverlapped.hEvent);
- }
- delete aPingHandler;
- }
-}
-
-void HandleAddressChanges(otNode *aNode)
-{
- otLogFuncEntry();
- auto addrs = otIp6GetUnicastAddresses(aNode->mInstance);
-
- EnterCriticalSection(&aNode->mCS);
-
- // Invalidate all handlers
- for (ULONG i = 0; i < aNode->mPingHandlers.size(); i++)
- aNode->mPingHandlers[i]->mActive = false;
-
- // Search for matches
- for (auto addr = addrs; addr; addr = addr->mNext)
- {
- bool found = false;
- for (ULONG i = 0; i < aNode->mPingHandlers.size(); i++)
- if (!aNode->mPingHandlers[i]->mActive &&
- memcmp(&addr->mAddress, &aNode->mPingHandlers[i]->mAddress, sizeof(otIp6Address)) == 0)
- {
- found = true;
- aNode->mPingHandlers[i]->mActive = true;
- break;
- }
- if (!found) AddPingHandler(aNode, &addr->mAddress);
- }
-
- vector pingHandlersToDelete;
-
- // Release all left over handlers
- for (int i = aNode->mPingHandlers.size() - 1; i >= 0; i--)
- if (aNode->mPingHandlers[i]->mActive == false)
- {
- auto aPingHandler = aNode->mPingHandlers[i];
-
-#if DEBUG_PING
- CHAR szIpAddress[46] = { 0 };
- RtlIpv6AddressToStringA((PIN6_ADDR)&aPingHandler->mAddress, szIpAddress);
- printf("%d: removing ping handler for %s\r\n", aNode->mId, szIpAddress);
-#endif
-
- aNode->mPingHandlers.erase(aNode->mPingHandlers.begin() + i);
-
- shutdown(aPingHandler->mSocket, SD_BOTH);
- closesocket(aPingHandler->mSocket);
-
- pingHandlersToDelete.push_back(aPingHandler);
- }
-
- LeaveCriticalSection(&aNode->mCS);
-
- for each (auto aPingHandler in pingHandlersToDelete)
- {
- WaitForThreadpoolWaitCallbacks(aPingHandler->mThreadpoolWait, TRUE);
- CloseThreadpoolWait(aPingHandler->mThreadpoolWait);
- CloseHandle(aPingHandler->mOverlapped.hEvent);
-
- delete aPingHandler;
- }
-
- if (addrs) otFreeMemory(addrs);
-
- otLogFuncExit();
-}
-
-void OTCALL otNodeStateChangedCallback(uint32_t aFlags, void *aContext)
-{
- otLogFuncEntry();
- otNode* aNode = (otNode*)aContext;
-
- if ((aFlags & OT_CHANGED_THREAD_ROLE) != 0)
- {
- auto Role = otThreadGetDeviceRole(aNode->mInstance);
- printf("%d: new role: %s\r\n", aNode->mId, otDeviceRoleToString(Role));
- }
-
- if ((aFlags & OT_CHANGED_IP6_ADDRESS_ADDED) != 0 || (aFlags & OT_CHANGED_IP6_ADDRESS_REMOVED) != 0 ||
- (aFlags & OT_CHANGED_THREAD_RLOC_ADDED) != 0 || (aFlags & OT_CHANGED_THREAD_RLOC_REMOVED) != 0)
- {
- HandleAddressChanges(aNode);
- }
- otLogFuncExit();
-}
-
-OTNODEAPI int32_t OTCALL otNodeLog(const char *aMessage)
-{
- LogInfo(OT_API, "%s", aMessage);
- return 0;
-}
-
-OTNODEAPI otNode* OTCALL otNodeInit(uint32_t id)
-{
- otLogFuncEntry();
-
- auto ApiInstance = GetApiInstance();
- if (ApiInstance == nullptr)
- {
- printf("GetApiInstance failed!\r\n");
- otLogFuncExitMsg("GetApiInstance failed");
- return nullptr;
- }
-
- bool BusAdded = false;
- DWORD newBusIndex;
- NET_IFINDEX ifIndex = {};
- NET_LUID ifLuid = {};
- GUID ifGuid = {};
- otNode *node = nullptr;
-
- DWORD dwError;
- DWORD tries = 0;
- while (tries < 1000)
- {
- newBusIndex = (gNextBusNumber + tries) % 1000;
- if (newBusIndex == 0) newBusIndex++;
-
- dwError = otvmpAddVirtualBus(gVmpHandle, &newBusIndex, &ifIndex);
- if (dwError == ERROR_SUCCESS)
- {
- BusAdded = true;
- gNextBusNumber = newBusIndex + 1;
- break;
- }
- else if (dwError == ERROR_INVALID_PARAMETER || dwError == ERROR_FILE_NOT_FOUND)
- {
- tries++;
- }
- else
- {
- printf("otvmpAddVirtualBus failed, 0x%x!\r\n", dwError);
- otLogFuncExitMsg("otvmpAddVirtualBus failed");
- goto error;
- }
- }
-
- if (tries == 1000)
- {
- printf("otvmpAddVirtualBus failed to find an empty bus!\r\n");
- otLogFuncExitMsg("otvmpAddVirtualBus failed to find an empty bus");
- goto error;
- }
-
- if ((dwError = otvmpSetAdapterTopologyGuid(gVmpHandle, newBusIndex, &gTopologyGuid)) != ERROR_SUCCESS)
- {
- printf("otvmpSetAdapterTopologyGuid failed, 0x%x!\r\n", dwError);
- otLogFuncExitMsg("otvmpSetAdapterTopologyGuid failed");
- goto error;
- }
-
- if (ERROR_SUCCESS != ConvertInterfaceIndexToLuid(ifIndex, &ifLuid))
- {
- printf("ConvertInterfaceIndexToLuid(%u) failed!\r\n", ifIndex);
- otLogFuncExitMsg("ConvertInterfaceIndexToLuid failed");
- goto error;
- }
-
- if (ERROR_SUCCESS != ConvertInterfaceLuidToGuid(&ifLuid, &ifGuid))
- {
- printf("ConvertInterfaceLuidToGuid failed!\r\n");
- otLogFuncExitMsg("ConvertInterfaceLuidToGuid failed");
- goto error;
- }
-
- // Keep trying for up to 30 seconds
- auto StartTick = GetTickCount64();
- otInstance *instance = nullptr;
- do
- {
- instance = otInstanceInit(ApiInstance, &ifGuid);
- if (instance != nullptr) break;
-
- auto waitTimeMs = (30 * 1000 - (LONGLONG)(GetTickCount64() - StartTick));
- if (waitTimeMs <= 0) break;
- auto waitResult = WaitForSingleObject(gDeviceArrivalEvent, (DWORD)waitTimeMs);
- if (waitResult != WAIT_OBJECT_0) break;
-
- } while (true);
-
- if (instance == nullptr)
- {
- printf("otInstanceInit failed!\r\n");
- otLogFuncExitMsg("otInstanceInit failed");
- goto error;
- }
-
- GUID DeviceGuid = otGetDeviceGuid(instance);
- uint32_t Compartment = otGetCompartmentId(instance);
-
- node = new otNode();
- printf("%d: New Device " GUID_FORMAT " in compartment %d\r\n", id, GUID_ARG(DeviceGuid), Compartment);
-
- node->mId = id;
- node->mInterfaceIndex = ifIndex;
- node->mBusIndex = newBusIndex;
- node->mInstance = instance;
-
- node->mEnergyScanEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
- node->mPanIdConflictEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
-
- EnterCriticalSection(&gCS);
- gNodes.push_back(node);
- LeaveCriticalSection(&gCS);
-
- InitializeCriticalSection(&node->mCS);
-
- // Reset any previously saved settings
- otInstanceFactoryReset(instance);
-
- otSetStateChangedCallback(instance, otNodeStateChangedCallback, node);
-
- HandleAddressChanges(node);
-
- otLogFuncExitMsg("success. [%d] = %!GUID!", id, &DeviceGuid);
-
-error:
-
- if (node == nullptr)
- {
- if (BusAdded)
- {
- otvmpRemoveVirtualBus(gVmpHandle, newBusIndex);
- }
-
- ReleaseApiInstance();
- }
-
- return node;
-}
-
-OTNODEAPI int32_t OTCALL otNodeFinalize(otNode* aNode)
-{
- otLogFuncEntry();
- if (aNode != nullptr)
- {
- printf("%d: Removing Device\r\n", aNode->mId);
-
- // Free any memory that we allocated now
- for each (auto mem in aNode->mMemoryToFree)
- free(mem);
-
- // Clean up callbacks
- CloseHandle(aNode->mPanIdConflictEvent);
- CloseHandle(aNode->mEnergyScanEvent);
- otSetStateChangedCallback(aNode->mInstance, nullptr, nullptr);
-
- EnterCriticalSection(&gCS);
- for (uint32_t i = 0; i < gNodes.size(); i++)
- {
- if (gNodes[i] == aNode)
- {
- gNodes.erase(gNodes.begin() + i);
- break;
- }
- }
- LeaveCriticalSection(&gCS);
-
- // Free the instance
- otFreeMemory(aNode->mInstance);
- aNode->mInstance = nullptr;
-
- // Free the ping handlers
- HandleAddressChanges(aNode);
- assert(aNode->mPingHandlers.size() == 0);
- if (aNode->mPingHandlers.size() != 0) printf("%d left over ping handlers!!!", (int)aNode->mPingHandlers.size());
-
- DeleteCriticalSection(&aNode->mCS);
-
- // Delete the virtual bus
- otvmpRemoveVirtualBus(gVmpHandle, aNode->mBusIndex);
- delete aNode;
-
- ReleaseApiInstance();
- }
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetMode(otNode* aNode, const char *aMode)
-{
- otLogFuncEntryMsg("[%d] %s", aNode->mId, aMode);
- printf("%d: mode %s\r\n", aNode->mId, aMode);
-
- otLinkModeConfig linkMode = {0};
-
- const char *index = aMode;
- while (*index)
- {
- switch (*index)
- {
- case 'r':
- linkMode.mRxOnWhenIdle = true;
- break;
- case 's':
- linkMode.mSecureDataRequests = true;
- break;
- case 'd':
- linkMode.mDeviceType = true;
- break;
- case 'n':
- linkMode.mNetworkData = true;
- break;
- }
-
- index++;
- }
-
- auto result = otThreadSetLinkMode(aNode->mInstance, linkMode);
-
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeInterfaceUp(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: ifconfig up\r\n", aNode->mId);
-
- auto error = otIp6SetEnabled(aNode->mInstance, true);
-
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI int32_t OTCALL otNodeInterfaceDown(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: ifconfig down\r\n", aNode->mId);
-
- (void)otIp6SetEnabled(aNode->mInstance, false);
-
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeThreadStart(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: thread start\r\n", aNode->mId);
-
- auto error = otThreadSetEnabled(aNode->mInstance, true);
-
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI int32_t OTCALL otNodeThreadStop(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: thread stop\r\n", aNode->mId);
-
- (void)otThreadSetEnabled(aNode->mInstance, false);
-
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeCommissionerStart(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: commissioner start\r\n", aNode->mId);
-
- // TODO: handle commissioner callback
- auto error = otCommissionerStart(aNode->mInstance, NULL, NULL, NULL);
-
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI int32_t OTCALL otNodeCommissionerJoinerAdd(otNode* aNode, const char *aExtAddr, const char *aPSKd)
-{
- otLogFuncEntryMsg("[%d] %s %s", aNode->mId, aExtAddr, aPSKd);
- printf("%d: commissioner joiner add %s %s\r\n", aNode->mId, aExtAddr, aPSKd);
-
- const uint32_t kDefaultJoinerTimeout = 120;
-
- otError error;
-
- if (strcmp(aExtAddr, "*") == 0)
- {
- error = otCommissionerAddJoiner(aNode->mInstance, nullptr, aPSKd, kDefaultJoinerTimeout);
- }
- else
- {
- otExtAddress extAddr;
- if (Hex2Bin(aExtAddr, extAddr.m8, sizeof(extAddr)) != sizeof(extAddr))
- return OT_ERROR_PARSE;
-
- error = otCommissionerAddJoiner(aNode->mInstance, &extAddr, aPSKd, kDefaultJoinerTimeout);
- }
-
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI int32_t OTCALL otNodeCommissionerStop(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: commissioner stop\r\n", aNode->mId);
-
- (void)otCommissionerStop(aNode->mInstance);
-
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeJoinerStart(otNode* aNode, const char *aPSKd, const char *aProvisioningUrl)
-{
- otLogFuncEntryMsg("[%d] %s %s", aNode->mId, aPSKd, aProvisioningUrl);
- printf("%d: joiner start %s %s\r\n", aNode->mId, aPSKd, aProvisioningUrl);
-
- // TODO: handle the joiner completion callback
- auto error = otJoinerStart(aNode->mInstance, aPSKd, aProvisioningUrl, NULL, NULL, NULL, NULL, NULL, NULL);
-
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI int32_t OTCALL otNodeJoinerStop(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: joiner stop\r\n", aNode->mId);
-
- (void)otJoinerStop(aNode->mInstance);
-
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeClearWhitelist(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: whitelist clear\r\n", aNode->mId);
-
- otLinkFilterClearAddresses(aNode->mInstance);
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeEnableWhitelist(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: whitelist enable\r\n", aNode->mId);
-
- otError error = otLinkFilterSetAddressMode(aNode->mInstance, OT_MAC_FILTER_ADDRESS_MODE_WHITELIST);
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI int32_t OTCALL otNodeDisableWhitelist(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: whitelist disable\r\n", aNode->mId);
-
- otError error = otLinkFilterSetAddressMode(aNode->mInstance, OT_MAC_FILTER_ADDRESS_MODE_DISABLED);
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI int32_t OTCALL otNodeAddWhitelist(otNode* aNode,
- const char *aExtAddr, int8_t aRssi = OT_MAC_FILTER_FIXED_RSS_DISABLED)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- otError error = OT_ERROR_NONE;
-
- otExtAddress extAddress;
- if (Hex2Bin(aExtAddr, extAddress.m8, OT_EXT_ADDRESS_SIZE) != OT_EXT_ADDRESS_SIZE)
- return OT_ERROR_PARSE;
-
- printf("%d: whitelist add %s", aNode->mId, aExtAddr);
-
- error = otLinkFilterAddAddress(aNode->mInstance, &extAddress);
-
- if (error == OT_ERROR_NONE || error == OT_ERROR_ALREADY)
- {
- if (aRssi != OT_MAC_FILTER_FIXED_RSS_DISABLED)
- {
- error = otLinkFilterAddRssIn(aNode->mInstance, &extAddress, aRssi);
- printf(" %d", aRssi);
- }
- }
-
- printf("\r\n");
-
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI int32_t OTCALL otNodeRemoveWhitelist(otNode* aNode, const char *aExtAddr)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: whitelist remove %s\r\n", aNode->mId, aExtAddr);
-
- otExtAddress extAddress;
- if (Hex2Bin(aExtAddr, extAddress.m8, OT_EXT_ADDRESS_SIZE) != OT_EXT_ADDRESS_SIZE)
- return OT_ERROR_PARSE;
-
- otError error = otLinkFilterRemoveAddress(aNode->mInstance, &extAddress);
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI uint16_t OTCALL otNodeGetAddr16(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto result = otThreadGetRloc16(aNode->mInstance);
- printf("%d: rloc16\r\n%04x\r\n", aNode->mId, result);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI const char* OTCALL otNodeGetAddr64(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto extAddr = otLinkGetExtendedAddress(aNode->mInstance);
- char* str = (char*)malloc(18);
- if (str != nullptr)
- {
- aNode->mMemoryToFree.push_back(str);
- for (int i = 0; i < 8; i++)
- sprintf_s(str + i * 2, 18 - (2 * i), "%02x", extAddr->m8[i]);
- printf("%d: extaddr\r\n%s\r\n", aNode->mId, str);
- }
- otFreeMemory(extAddr);
- otLogFuncExit();
- return str;
-}
-
-OTNODEAPI const char* OTCALL otNodeGetEui64(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- otExtAddress aEui64 = {};
- otLinkGetFactoryAssignedIeeeEui64(aNode->mInstance, &aEui64);
- char* str = (char*)malloc(18);
- if (str != nullptr)
- {
- aNode->mMemoryToFree.push_back(str);
- for (int i = 0; i < 8; i++)
- sprintf_s(str + i * 2, 18 - (2 * i), "%02x", aEui64.m8[i]);
- printf("%d: eui64\r\n%s\r\n", aNode->mId, str);
- }
- otLogFuncExit();
- return str;
-}
-
-OTNODEAPI const char* OTCALL otNodeGetJoinerId(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- otExtAddress aJoinerId = {};
- otJoinerGetId(aNode->mInstance, &aJoinerId);
- char* str = (char*)malloc(18);
- if (str != nullptr)
- {
- aNode->mMemoryToFree.push_back(str);
- for (int i = 0; i < 8; i++)
- sprintf_s(str + i * 2, 18 - (2 * i), "%02x", aJoinerId.m8[i]);
- printf("%d: joinerid\r\n%s\r\n", aNode->mId, str);
- }
- otLogFuncExit();
- return str;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetChannel(otNode* aNode, uint8_t aChannel)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: channel %d\r\n", aNode->mId, aChannel);
- auto result = otLinkSetChannel(aNode->mInstance, aChannel);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI uint8_t OTCALL otNodeGetChannel(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto result = otLinkGetChannel(aNode->mInstance);
- printf("%d: channel\r\n%d\r\n", aNode->mId, result);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetMasterkey(otNode* aNode, const char *aMasterkey)
-{
- otLogFuncEntryMsg("[%d] %s", aNode->mId, aMasterkey);
- printf("%d: masterkey %s\r\n", aNode->mId, aMasterkey);
-
- int keyLength;
- otMasterKey key;
- if ((keyLength = Hex2Bin(aMasterkey, key.m8, sizeof(key.m8))) != OT_MASTER_KEY_SIZE)
- {
- printf("invalid length key %d\r\n", keyLength);
- return OT_ERROR_PARSE;
- }
-
- auto error = otThreadSetMasterKey(aNode->mInstance, &key);
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI const char* OTCALL otNodeGetMasterkey(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto aMasterKey = otThreadGetMasterKey(aNode->mInstance);
- uint8_t strLength = 2*sizeof(otMasterKey) + 1;
- char* str = (char*)malloc(strLength);
- if (str != nullptr)
- {
- aNode->mMemoryToFree.push_back(str);
- for (int i = 0; i < sizeof(otMasterKey); i++)
- sprintf_s(str + i * 2, strLength - (2 * i), "%02x", aMasterKey->m8[i]);
- printf("%d: masterkey\r\n%s\r\n", aNode->mId, str);
- }
- otFreeMemory(aMasterKey);
- otLogFuncExit();
- return str;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetPSKc(otNode* aNode, const char *aPSKc)
-{
- otLogFuncEntryMsg("[%d] %s", aNode->mId, aPSKc);
- printf("%d: pskc %s\r\n", aNode->mId, aPSKc);
-
- int pskcLength;
- otPSKc pskc;
- if ((pskcLength = Hex2Bin(aPSKc, pskc.m8, sizeof(aPSKc))) != OT_PSKC_MAX_SIZE)
- {
- printf("invalid length pskd %d\r\n", pskcLength);
- return OT_ERROR_PARSE;
- }
-
- auto error = otThreadSetPSKc(aNode->mInstance, &pskc);
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI const char* OTCALL otNodeGetPSKc(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto aPSKc = otThreadGetPSKc(aNode->mInstance);
- uint8_t strLength = 2 * OT_PSKC_MAX_SIZE + 1;
- char* str = (char*)malloc(strLength);
- if (str != nullptr)
- {
- aNode->mMemoryToFree.push_back(str);
- for (int i = 0; i < OT_PSKC_MAX_SIZE; i++)
- sprintf_s(str + i * 2, strLength - (2 * i), "%02x", aPSKc->m8[i]);
- printf("%d: pskc\r\n%s\r\n", aNode->mId, str);
- }
- otFreeMemory(aPSKc);
- otLogFuncExit();
- return str;
-}
-
-OTNODEAPI uint32_t OTCALL otNodeGetKeySequenceCounter(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto result = otThreadGetKeySequenceCounter(aNode->mInstance);
- printf("%d: keysequence\r\n%d\r\n", aNode->mId, result);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetKeySequenceCounter(otNode* aNode, uint32_t aSequence)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: keysequence counter %d\r\n", aNode->mId, aSequence);
- otThreadSetKeySequenceCounter(aNode->mInstance, aSequence);
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetKeySwitchGuardTime(otNode* aNode, uint32_t aKeySwitchGuardTime)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: keysequence guardtime %d\r\n", aNode->mId, aKeySwitchGuardTime);
- otThreadSetKeySwitchGuardTime(aNode->mInstance, aKeySwitchGuardTime);
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetNetworkIdTimeout(otNode* aNode, uint8_t aTimeout)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: networkidtimeout %d\r\n", aNode->mId, aTimeout);
- otThreadSetNetworkIdTimeout(aNode->mInstance, aTimeout);
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetNetworkName(otNode* aNode, const char *aName)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: networkname %s\r\n", aNode->mId, aName);
- auto result = otThreadSetNetworkName(aNode->mInstance, aName);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI const char* OTCALL otNodeGetNetworkName(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto result = otThreadGetNetworkName(aNode->mInstance);
- aNode->mMemoryToFree.push_back((char*)result);
- printf("%d: networkname\r\n%s\r\n", aNode->mId, result);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI uint16_t OTCALL otNodeGetPanId(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto result = otLinkGetPanId(aNode->mInstance);
- printf("%d: panid\r\n0x%04x\r\n", aNode->mId, result);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetPanId(otNode* aNode, uint16_t aPanId)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: panid 0x%04x\r\n", aNode->mId, aPanId);
- auto result = otLinkSetPanId(aNode->mInstance, aPanId);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI uint32_t OTCALL otNodeGetPartitionId(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto result = otThreadGetLocalLeaderPartitionId(aNode->mInstance);
- printf("%d: leaderpartitionid\r\n0x%04x\r\n", aNode->mId, result);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetPartitionId(otNode* aNode, uint32_t aPartitionId)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: leaderpartitionid 0x%04x\r\n", aNode->mId, aPartitionId);
- otThreadSetLocalLeaderPartitionId(aNode->mInstance, aPartitionId);
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetRouterUpgradeThreshold(otNode* aNode, uint8_t aThreshold)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: routerupgradethreshold %d\r\n", aNode->mId, aThreshold);
- otThreadSetRouterUpgradeThreshold(aNode->mInstance, aThreshold);
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetRouterDowngradeThreshold(otNode* aNode, uint8_t aThreshold)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: routerdowngradethreshold %d\r\n", aNode->mId, aThreshold);
- otThreadSetRouterDowngradeThreshold(aNode->mInstance, aThreshold);
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeReleaseRouterId(otNode* aNode, uint8_t aRouterId)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: releaserouterid %d\r\n", aNode->mId, aRouterId);
- auto result = otThreadReleaseRouterId(aNode->mInstance, aRouterId);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI const char* OTCALL otNodeGetState(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto role = otThreadGetDeviceRole(aNode->mInstance);
- auto result = _strdup(otDeviceRoleToString(role));
- aNode->mMemoryToFree.push_back(result);
- printf("%d: state\r\n%s\r\n", aNode->mId, result);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetState(otNode* aNode, const char *aState)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: state %s\r\n", aNode->mId, aState);
-
- otError error;
- if (strcmp(aState, "detached") == 0)
- {
- error = otThreadBecomeDetached(aNode->mInstance);
- }
- else if (strcmp(aState, "child") == 0)
- {
- error = otThreadBecomeChild(aNode->mInstance);
- }
- else if (strcmp(aState, "router") == 0)
- {
- error = otThreadBecomeRouter(aNode->mInstance);
- }
- else if (strcmp(aState, "leader") == 0)
- {
- error = otThreadBecomeLeader(aNode->mInstance);
- }
- else
- {
- error = OT_ERROR_INVALID_ARGS;
- }
- otLogFuncExit();
- return error;
-}
-
-OTNODEAPI uint32_t OTCALL otNodeGetTimeout(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto result = otThreadGetChildTimeout(aNode->mInstance);
- printf("%d: childtimeout\r\n%d\r\n", aNode->mId, result);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetTimeout(otNode* aNode, uint32_t aTimeout)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: childtimeout %d\r\n", aNode->mId, aTimeout);
- otThreadSetChildTimeout(aNode->mInstance, aTimeout);
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI uint8_t OTCALL otNodeGetWeight(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto result = otThreadGetLeaderWeight(aNode->mInstance);
- printf("%d: leaderweight\r\n%d\r\n", aNode->mId, result);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetWeight(otNode* aNode, uint8_t aWeight)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: leaderweight %d\r\n", aNode->mId, aWeight);
- otThreadSetLocalLeaderWeight(aNode->mInstance, aWeight);
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeAddIpAddr(otNode* aNode, const char *aAddr)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: add ipaddr %s\r\n", aNode->mId, aAddr);
-
- otNetifAddress aAddress;
- auto error = otIp6AddressFromString(aAddr, &aAddress.mAddress);
- if (error != OT_ERROR_NONE) return error;
-
- aAddress.mPrefixLength = 64;
- aAddress.mPreferred = true;
- aAddress.mValid = true;
- auto result = otIp6AddUnicastAddress(aNode->mInstance, &aAddress);
- otLogFuncExit();
- return result;
-}
-
-inline uint16_t Swap16(uint16_t v)
-{
- return
- (((v & 0x00ffU) << 8) & 0xff00) |
- (((v & 0xff00U) >> 8) & 0x00ff);
-}
-
-OTNODEAPI const char* OTCALL otNodeGetAddrs(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: ipaddr\r\n", aNode->mId);
-
- auto addrs = otIp6GetUnicastAddresses(aNode->mInstance);
- if (addrs == nullptr) return nullptr;
-
- char* str = (char*)malloc(512);
- if (str != nullptr)
- {
- aNode->mMemoryToFree.push_back(str);
- RtlZeroMemory(str, 512);
-
- char* cur = str;
-
- for (const otNetifAddress *addr = addrs; addr; addr = addr->mNext)
- {
- if (cur != str)
- {
- *cur = '\n';
- cur++;
- }
-
- auto last = cur;
-
- cur +=
- sprintf_s(
- cur, 512 - (cur - str),
- "%x:%x:%x:%x:%x:%x:%x:%x",
- Swap16(addr->mAddress.mFields.m16[0]),
- Swap16(addr->mAddress.mFields.m16[1]),
- Swap16(addr->mAddress.mFields.m16[2]),
- Swap16(addr->mAddress.mFields.m16[3]),
- Swap16(addr->mAddress.mFields.m16[4]),
- Swap16(addr->mAddress.mFields.m16[5]),
- Swap16(addr->mAddress.mFields.m16[6]),
- Swap16(addr->mAddress.mFields.m16[7]));
-
- printf("%s\r\n", last);
- }
- }
-
- otFreeMemory(addrs);
- otLogFuncExit();
-
- return str;
-}
-
-OTNODEAPI uint32_t OTCALL otNodeGetContextReuseDelay(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- auto result = otThreadGetContextIdReuseDelay(aNode->mInstance);
- printf("%d: contextreusedelay\r\n%d\r\n", aNode->mId, result);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetContextReuseDelay(otNode* aNode, uint32_t aDelay)
-{
- otLogFuncEntryMsg("[%d] %d", aNode->mId, aDelay);
- printf("%d: contextreusedelay %d\r\n", aNode->mId, aDelay);
- otThreadSetContextIdReuseDelay(aNode->mInstance, aDelay);
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeAddPrefix(otNode* aNode, const char *aPrefix, const char *aFlags, const char *aPreference)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: prefix add %s %s %s\r\n", aNode->mId, aPrefix, aFlags, aPreference);
-
- otBorderRouterConfig config = {0};
-
- auto error = otNodeParsePrefix(aPrefix, &config.mPrefix);
- if (error != OT_ERROR_NONE) return error;
-
- const char *index = aFlags;
- while (*index)
- {
- switch (*index)
- {
- case 'p':
- config.mPreferred = true;
- break;
- case 'a':
- config.mSlaac = true;
- break;
- case 'd':
- config.mDhcp = true;
- break;
- case 'c':
- config.mConfigure = true;
- break;
- case 'r':
- config.mDefaultRoute = true;
- break;
- case 'o':
- config.mOnMesh = true;
- break;
- case 's':
- config.mStable = true;
- break;
- default:
- return OT_ERROR_INVALID_ARGS;
- }
-
- index++;
- }
-
- if (strcmp(aPreference, "high") == 0)
- {
- config.mPreference = OT_ROUTE_PREFERENCE_HIGH;
- }
- else if (strcmp(aPreference, "med") == 0)
- {
- config.mPreference = OT_ROUTE_PREFERENCE_MED;
- }
- else if (strcmp(aPreference, "low") == 0)
- {
- config.mPreference = OT_ROUTE_PREFERENCE_LOW;
- }
- else
- {
- return OT_ERROR_INVALID_ARGS;
- }
-
- auto result = otBorderRouterAddOnMeshPrefix(aNode->mInstance, &config);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeRemovePrefix(otNode* aNode, const char *aPrefix)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
-
- otIp6Prefix prefix;
- auto error = otNodeParsePrefix(aPrefix, &prefix);
- if (error != OT_ERROR_NONE) return error;
-
- auto result = otBorderRouterRemoveOnMeshPrefix(aNode->mInstance, &prefix);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeAddRoute(otNode* aNode, const char *aPrefix, const char *aPreference)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- otExternalRouteConfig config = {0};
-
- auto error = otNodeParsePrefix(aPrefix, &config.mPrefix);
- if (error != OT_ERROR_NONE) return error;
-
- if (strcmp(aPreference, "high") == 0)
- {
- config.mPreference = OT_ROUTE_PREFERENCE_HIGH;
- }
- else if (strcmp(aPreference, "med") == 0)
- {
- config.mPreference = OT_ROUTE_PREFERENCE_MED;
- }
- else if (strcmp(aPreference, "low") == 0)
- {
- config.mPreference = OT_ROUTE_PREFERENCE_LOW;
- }
- else
- {
- return OT_ERROR_INVALID_ARGS;
- }
-
- auto result = otBorderRouterAddRoute(aNode->mInstance, &config);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeRemoveRoute(otNode* aNode, const char *aPrefix)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
-
- otIp6Prefix prefix;
- auto error = otNodeParsePrefix(aPrefix, &prefix);
- if (error != OT_ERROR_NONE) return error;
-
- auto result = otBorderRouterRemoveRoute(aNode->mInstance, &prefix);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeRegisterNetdata(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: registernetdata\r\n", aNode->mId);
- auto result = otBorderRouterRegister(aNode->mInstance);
- otLogFuncExit();
- return result;
-}
-
-void OTCALL otNodeCommissionerEnergyReportCallback(uint32_t aChannelMask, const uint8_t *aEnergyList, uint8_t aEnergyListLength, void *aContext)
-{
- otNode* aNode = (otNode*)aContext;
-
- printf("Energy: 0x%08x\r\n", aChannelMask);
- for (uint8_t i = 0; i < aEnergyListLength; i++)
- printf("%d ", aEnergyList[i]);
- printf("\r\n");
-
- SetEvent(aNode->mEnergyScanEvent);
-}
-
-OTNODEAPI int32_t OTCALL otNodeEnergyScan(otNode* aNode, uint32_t aMask, uint8_t aCount, uint16_t aPeriod, uint16_t aDuration, const char *aAddr)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: energy scan 0x%x %d %d %d %s\r\n", aNode->mId, aMask, aCount, aPeriod, aDuration, aAddr);
-
- otIp6Address address = {0};
- auto error = otIp6AddressFromString(aAddr, &address);
- if (error != OT_ERROR_NONE)
- {
- printf("otIp6AddressFromString(%s) failed, 0x%x!\r\n", aAddr, error);
- return error;
- }
-
- ResetEvent(aNode->mEnergyScanEvent);
-
- error = otCommissionerEnergyScan(aNode->mInstance, aMask, aCount, aPeriod, aDuration, &address, otNodeCommissionerEnergyReportCallback, aNode);
- if (error != OT_ERROR_NONE)
- {
- printf("otCommissionerEnergyScan failed, 0x%x!\r\n", error);
- return error;
- }
-
- auto result = WaitForSingleObject(aNode->mEnergyScanEvent, 8000) == WAIT_OBJECT_0 ? OT_ERROR_NONE : OT_ERROR_NOT_FOUND;
- otLogFuncExit();
- return result;
-}
-
-void OTCALL otNodeCommissionerPanIdConflictCallback(uint16_t aPanId, uint32_t aChannelMask, void *aContext)
-{
- otNode* aNode = (otNode*)aContext;
- printf("Conflict: 0x%04x, 0x%08x\r\n", aPanId, aChannelMask);
- SetEvent(aNode->mPanIdConflictEvent);
-}
-
-OTNODEAPI int32_t OTCALL otNodePanIdQuery(otNode* aNode, uint16_t aPanId, uint32_t aMask, const char *aAddr)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- printf("%d: panid query 0x%04x 0x%x %s\r\n", aNode->mId, aPanId, aMask, aAddr);
-
- otIp6Address address = {0};
- auto error = otIp6AddressFromString(aAddr, &address);
- if (error != OT_ERROR_NONE)
- {
- printf("otIp6AddressFromString(%s) failed, 0x%x!\r\n", aAddr, error);
- return error;
- }
-
- ResetEvent(aNode->mPanIdConflictEvent);
-
- error = otCommissionerPanIdQuery(aNode->mInstance, aPanId, aMask, &address, otNodeCommissionerPanIdConflictCallback, aNode);
- if (error != OT_ERROR_NONE)
- {
- printf("otCommissionerPanIdQuery failed, 0x%x!\r\n", error);
- return error;
- }
-
- auto result = WaitForSingleObject(aNode->mPanIdConflictEvent, 8000) == WAIT_OBJECT_0 ? OT_ERROR_NONE : OT_ERROR_NOT_FOUND;
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI const char* OTCALL otNodeScan(otNode* aNode)
-{
- otLogFuncEntryMsg("[%d]", aNode->mId);
- UNREFERENCED_PARAMETER(aNode);
- otLogFuncExit();
- return nullptr;
-}
-
-OTNODEAPI uint32_t OTCALL otNodePing(otNode* aNode, const char *aAddr, uint16_t aSize, uint32_t aMinReplies, uint16_t aTimeout)
-{
- otLogFuncEntryMsg("[%d] %s (%d bytes)", aNode->mId, aAddr, aSize);
- printf("%d: ping %s (%d bytes)\r\n", aNode->mId, aAddr, aSize);
-
- // Convert string to destination address
- otIp6Address otDestinationAddress = {0};
- auto error = otIp6AddressFromString(aAddr, &otDestinationAddress);
- if (error != OT_ERROR_NONE)
- {
- printf("otIp6AddressFromString(%s) failed!\r\n", aAddr);
- return 0;
- }
-
- // Get ML-EID as source address for ping
- auto otSourceAddress = otThreadGetMeshLocalEid(aNode->mInstance);
-
- sockaddr_in6 SourceAddress = { AF_INET6, (USHORT)(CertificationPingPort + 1) };
- sockaddr_in6 DestinationAddress = { AF_INET6, CertificationPingPort };
-
- memcpy(&SourceAddress.sin6_addr, otSourceAddress, sizeof(IN6_ADDR));
- memcpy(&DestinationAddress.sin6_addr, &otDestinationAddress, sizeof(IN6_ADDR));
-
- otFreeMemory(otSourceAddress);
- otSourceAddress = nullptr;
-
- // Put the current thead in the correct compartment
- bool RevertCompartmentOnExit = false;
- ULONG OriginalCompartmentID = GetCurrentThreadCompartmentId();
- if (OriginalCompartmentID != otGetCompartmentId(aNode->mInstance))
- {
- DWORD dwError = ERROR_SUCCESS;
- if ((dwError = SetCurrentThreadCompartmentId(otGetCompartmentId(aNode->mInstance))) != ERROR_SUCCESS)
- {
- printf("SetCurrentThreadCompartmentId failed, 0x%x\r\n", dwError);
- }
- RevertCompartmentOnExit = true;
- }
-
- int result = 0;
-
- auto SendBuffer = (PCHAR)malloc(aSize);
- auto RecvBuffer = (PCHAR)malloc(aSize);
-
- WSABUF WSARecvBuffer = { aSize, RecvBuffer };
-
- WSAOVERLAPPED Overlapped = { 0 };
- Overlapped.hEvent = WSACreateEvent();
-
- DWORD numberOfReplies = 0;
- bool isPending = false;
- DWORD Flags;
- DWORD cbReceived;
- int cbDestinationAddress = sizeof(DestinationAddress);
- DWORD hopLimit = 64;
-
- SOCKET Socket = WSASocketW(AF_INET6, SOCK_DGRAM, IPPROTO_UDP, NULL, 0, WSA_FLAG_OVERLAPPED);
- if (Socket == INVALID_SOCKET)
- {
- printf("WSASocket failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
-
- // Bind the socket to the address
- result = bind(Socket, (sockaddr*)&SourceAddress, sizeof(SourceAddress));
- if (result == SOCKET_ERROR)
- {
- printf("bind failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
-
- // Set the multicast hop limit to 64
- result = setsockopt(Socket, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, (char *)&hopLimit, sizeof(hopLimit));
- if (result == SOCKET_ERROR)
- {
- printf("setsockopt (IPV6_MULTICAST_HOPS) failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
-
- // Initialize the send buffer pattern.
- for (uint32_t i = 0; i < aSize; i++)
- SendBuffer[i] = (char)('a' + (i % 23));
-
- // Hack to retrieve destination on other end
- memcpy_s(SendBuffer, aSize, &otDestinationAddress, sizeof(IN6_ADDR));
-
- // Send the buffer
- result = sendto(Socket, SendBuffer, aSize, 0, (SOCKADDR*)&DestinationAddress, sizeof(DestinationAddress));
- if (result == SOCKET_ERROR)
- {
- printf("sendto failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
-
- auto StartTick = GetTickCount64();
-
- while (numberOfReplies < aMinReplies)
- {
- Flags = 0; //MSG_PARTIAL;
- result = WSARecvFrom(Socket, &WSARecvBuffer, 1, &cbReceived, &Flags, (SOCKADDR*)&DestinationAddress, &cbDestinationAddress, &Overlapped, NULL);
- if (result == SOCKET_ERROR)
- {
- result = WSAGetLastError();
- if (result == WSA_IO_PENDING)
- {
- isPending = true;
- }
- else
- {
- printf("WSARecvFrom failed, 0x%x\r\n", result);
- goto exit;
- }
- }
-
- if (isPending)
- {
- //printf("waiting for completion event...\r\n");
- // Wait for the receive to complete
- ULONGLONG elapsed = (GetTickCount64() - StartTick);
- result = WSAWaitForMultipleEvents(1, &Overlapped.hEvent, TRUE, (DWORD)(aTimeout - min(aTimeout, elapsed)), TRUE);
- if (result == WSA_WAIT_TIMEOUT)
- {
- //printf("recv timeout\r\n");
- goto exit;
- }
- else if (result == WSA_WAIT_FAILED)
- {
- printf("recv failed\r\n");
- goto exit;
- }
- }
-
- result = WSAGetOverlappedResult(Socket, &Overlapped, &cbReceived, TRUE, &Flags);
- if (result == FALSE)
- {
- printf("WSAGetOverlappedResult failed, 0x%x\r\n", WSAGetLastError());
- goto exit;
- }
-
- numberOfReplies++;
- }
-
-exit:
-
- // Revert the comparment if necessary
- if (RevertCompartmentOnExit)
- {
- (VOID)SetCurrentThreadCompartmentId(OriginalCompartmentID);
- }
-
- free(RecvBuffer);
- free(SendBuffer);
-
- WSACloseEvent(Overlapped.hEvent);
-
- if (Socket != INVALID_SOCKET) closesocket(Socket);
-
- otLogFuncExit();
-
- return numberOfReplies;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetRouterSelectionJitter(otNode* aNode, uint8_t aRouterJitter)
-{
- otLogFuncEntryMsg("[%d] %d", aNode->mId, aRouterJitter);
- printf("%d: routerselectionjitter %d\r\n", aNode->mId, aRouterJitter);
- otThreadSetRouterSelectionJitter(aNode->mInstance, aRouterJitter);
- otLogFuncExit();
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otNodeCommissionerAnnounceBegin(otNode* aNode, uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod, const char *aAddr)
-{
- otLogFuncEntryMsg("[%d] 0x%08x %d %d %s", aNode->mId, aChannelMask, aCount, aPeriod, aAddr);
- printf("%d: commissioner announce 0x%08x %d %d %s\r\n", aNode->mId, aChannelMask, aCount, aPeriod, aAddr);
-
- otIp6Address aAddress;
- auto error = otIp6AddressFromString(aAddr, &aAddress);
- if (error != OT_ERROR_NONE) return error;
-
- auto result = otCommissionerAnnounceBegin(aNode->mInstance, aChannelMask, aCount, aPeriod, &aAddress);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetActiveDataset(otNode* aNode, uint64_t aTimestamp, uint16_t aPanId, uint16_t aChannel, uint32_t aChannelMask, const char *aMasterKey)
-{
- otLogFuncEntryMsg("[%d] 0x%llX %d %d", aNode->mId, aTimestamp, aPanId, aChannel);
- printf("%d: dataset set active 0x%llX %d %d\r\n", aNode->mId, aTimestamp, aPanId, aChannel);
-
- otOperationalDataset aDataset = {};
-
- aDataset.mActiveTimestamp = aTimestamp;
- aDataset.mComponents.mIsActiveTimestampPresent = true;
-
- if (aPanId != 0)
- {
- aDataset.mPanId = aPanId;
- aDataset.mComponents.mIsPanIdPresent = true;
- }
-
- if (aChannel != 0)
- {
- aDataset.mChannel = aChannel;
- aDataset.mComponents.mIsChannelPresent = true;
- }
-
- if (aChannelMask != 0)
- {
- aDataset.mChannelMask = aChannelMask;
- aDataset.mComponents.mIsChannelMaskPresent = true;
- }
-
- if (aMasterKey != NULL && strlen(aMasterKey) != 0)
- {
- int keyLength;
- if ((keyLength = Hex2Bin(aMasterKey, aDataset.mMasterKey.m8, sizeof(aDataset.mMasterKey))) != OT_MASTER_KEY_SIZE)
- {
- printf("invalid length key %d\r\n", keyLength);
- return OT_ERROR_PARSE;
- }
- aDataset.mComponents.mIsMasterKeyPresent = true;
- }
-
- auto result = otDatasetSetActive(aNode->mInstance, &aDataset);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetPendingDataset(otNode* aNode, uint64_t aActiveTimestamp, uint64_t aPendingTimestamp, uint16_t aPanId, uint16_t aChannel)
-{
- otLogFuncEntryMsg("[%d] 0x%llX 0x%llX %d %d", aNode->mId, aActiveTimestamp, aPendingTimestamp, aPanId, aChannel);
- printf("%d: dataset set pending 0x%llX 0x%llX %d %d\r\n", aNode->mId, aActiveTimestamp, aPendingTimestamp, aPanId, aChannel);
-
- otOperationalDataset aDataset = {};
-
- if (aActiveTimestamp != 0)
- {
- aDataset.mActiveTimestamp = aActiveTimestamp;
- aDataset.mComponents.mIsActiveTimestampPresent = true;
- }
-
- if (aPendingTimestamp != 0)
- {
- aDataset.mPendingTimestamp = aPendingTimestamp;
- aDataset.mComponents.mIsPendingTimestampPresent = true;
- }
-
- if (aPanId != 0)
- {
- aDataset.mPanId = aPanId;
- aDataset.mComponents.mIsPanIdPresent = true;
- }
-
- if (aChannel != 0)
- {
- aDataset.mChannel = aChannel;
- aDataset.mComponents.mIsChannelPresent = true;
- }
-
- auto result = otDatasetSetPending(aNode->mInstance, &aDataset);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSendPendingSet(otNode* aNode, uint64_t aActiveTimestamp, uint64_t aPendingTimestamp, uint32_t aDelayTimer, uint16_t aPanId, uint16_t aChannel, const char *aMasterKey, const char *aMeshLocal, const char *aNetworkName)
-{
- otLogFuncEntryMsg("[%d] 0x%llX 0x%llX %d %d", aNode->mId, aActiveTimestamp, aPendingTimestamp, aPanId, aChannel);
- printf("%d: dataset send pending 0x%llX 0x%llX %d %d\r\n", aNode->mId, aActiveTimestamp, aPendingTimestamp, aPanId, aChannel);
-
- otOperationalDataset aDataset = {};
-
- if (aActiveTimestamp != 0)
- {
- aDataset.mActiveTimestamp = aActiveTimestamp;
- aDataset.mComponents.mIsActiveTimestampPresent = true;
- }
-
- if (aPendingTimestamp != 0)
- {
- aDataset.mPendingTimestamp = aPendingTimestamp;
- aDataset.mComponents.mIsPendingTimestampPresent = true;
- }
-
- if (aDelayTimer != 0)
- {
- aDataset.mDelay = aDelayTimer;
- aDataset.mComponents.mIsDelayPresent = true;
- }
-
- if (aPanId != 0)
- {
- aDataset.mPanId = aPanId;
- aDataset.mComponents.mIsPanIdPresent = true;
- }
-
- if (aChannel != 0)
- {
- aDataset.mChannel = aChannel;
- aDataset.mComponents.mIsChannelPresent = true;
- }
-
- if (aMasterKey != NULL && strlen(aMasterKey) != 0)
- {
- int keyLength;
- if ((keyLength = Hex2Bin(aMasterKey, aDataset.mMasterKey.m8, sizeof(aDataset.mMasterKey))) != OT_MASTER_KEY_SIZE)
- {
- printf("invalid length key %d\r\n", keyLength);
- return OT_ERROR_PARSE;
- }
- aDataset.mComponents.mIsMasterKeyPresent = true;
- }
-
- if (aMeshLocal != NULL && strlen(aMeshLocal) != 0)
- {
- otIp6Address prefix;
- auto error = otIp6AddressFromString(aMeshLocal, &prefix);
- if (error != OT_ERROR_NONE) return error;
- memcpy(aDataset.mMeshLocalPrefix.m8, prefix.mFields.m8, sizeof(aDataset.mMeshLocalPrefix.m8));
- aDataset.mComponents.mIsMeshLocalPrefixPresent = true;
- }
-
- if (aNetworkName != NULL && strlen(aNetworkName) != 0)
- {
- strcpy_s(aDataset.mNetworkName.m8, sizeof(aDataset.mNetworkName.m8), aNetworkName);
- aDataset.mComponents.mIsNetworkNamePresent = true;
- }
-
- auto result = otDatasetSendMgmtPendingSet(aNode->mInstance, &aDataset, nullptr, 0);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSendActiveSet(otNode* aNode, uint64_t aActiveTimestamp, uint16_t aPanId, uint16_t aChannel, uint32_t aChannelMask, const char *aExtPanId, const char *aMasterKey, const char *aMeshLocal, const char *aNetworkName, const char *aBinary)
-{
- otLogFuncEntryMsg("[%d] 0x%llX %d %d", aNode->mId, aActiveTimestamp, aPanId, aChannel);
- printf("%d: dataset send active 0x%llX %d %d\r\n", aNode->mId, aActiveTimestamp, aPanId, aChannel);
-
- otOperationalDataset aDataset = {};
- uint8_t tlvs[128];
- uint8_t tlvsLength = 0;
-
- if (aActiveTimestamp != 0)
- {
- aDataset.mActiveTimestamp = aActiveTimestamp;
- aDataset.mComponents.mIsActiveTimestampPresent = true;
- }
- if (aPanId != 0)
- {
- aDataset.mPanId = aPanId;
- aDataset.mComponents.mIsPanIdPresent = true;
- }
-
- if (aChannel != 0)
- {
- aDataset.mChannel = aChannel;
- aDataset.mComponents.mIsChannelPresent = true;
- }
-
- if (aChannelMask != 0)
- {
- aDataset.mChannelMask = aChannelMask;
- aDataset.mComponents.mIsChannelMaskPresent = true;
- }
-
- if (aExtPanId != NULL && strlen(aExtPanId) != 0)
- {
- int keyLength;
- if ((keyLength = Hex2Bin(aExtPanId, aDataset.mExtendedPanId.m8, sizeof(aDataset.mExtendedPanId))) != OT_EXT_PAN_ID_SIZE)
- {
- printf("invalid length ext pan id %d\r\n", keyLength);
- return OT_ERROR_PARSE;
- }
- aDataset.mComponents.mIsExtendedPanIdPresent = true;
- }
-
- if (aMasterKey != NULL && strlen(aMasterKey) != 0)
- {
- int keyLength;
- if ((keyLength = Hex2Bin(aMasterKey, aDataset.mMasterKey.m8, sizeof(aDataset.mMasterKey))) != OT_MASTER_KEY_SIZE)
- {
- printf("invalid length key %d\r\n", keyLength);
- return OT_ERROR_PARSE;
- }
- aDataset.mComponents.mIsMasterKeyPresent = true;
- }
-
- if (aMeshLocal != NULL && strlen(aMeshLocal) != 0)
- {
- otIp6Address prefix;
- auto error = otIp6AddressFromString(aMeshLocal, &prefix);
- if (error != OT_ERROR_NONE) return error;
- memcpy(aDataset.mMeshLocalPrefix.m8, prefix.mFields.m8, sizeof(aDataset.mMeshLocalPrefix.m8));
- aDataset.mComponents.mIsMeshLocalPrefixPresent = true;
- }
-
- if (aNetworkName != NULL && strlen(aNetworkName) != 0)
- {
- strcpy_s(aDataset.mNetworkName.m8, sizeof(aDataset.mNetworkName.m8), aNetworkName);
- aDataset.mComponents.mIsNetworkNamePresent = true;
- }
-
- if (aBinary != NULL && strlen(aBinary) != 0)
- {
- int length;
- if ((length = Hex2Bin(aBinary,tlvs, sizeof(tlvs))) < 0)
- {
- printf("invalid length tlvs %d\r\n", length);
- return OT_ERROR_PARSE;
- }
- tlvsLength = (uint8_t)length;
- }
-
- auto result = otDatasetSendMgmtActiveSet(aNode->mInstance, &aDataset, tlvsLength == 0 ? nullptr : tlvs, tlvsLength);
- otLogFuncExit();
- return result;
-}
-
-OTNODEAPI int32_t OTCALL otNodeSetMaxChildren(otNode* aNode, uint8_t aMaxChildren)
-{
- otLogFuncEntryMsg("[%d] %d", aNode->mId, aMaxChildren);
- printf("%d: childmax %d\r\n", aNode->mId, aMaxChildren);
- auto result = otThreadSetMaxAllowedChildren(aNode->mInstance, aMaxChildren);
- otLogFuncExit();
- return result;
-}
-
-typedef struct otMacFrameEntry
-{
- otMacFrame Frame;
- LIST_ENTRY Link;
-} otMacFrameEntry;
-
-typedef struct otListener
-{
- HANDLE mListener;
- CRITICAL_SECTION mCS;
- HANDLE mStopEvent;
- HANDLE mFramesUpdatedEvent;
- LIST_ENTRY mFrames; // List of otMacFrameEntry
-} otListener;
-
-void
-otListenerCallback(
- _In_opt_ PVOID aContext,
- _In_ ULONG SourceInterfaceIndex,
- _In_reads_bytes_(FrameLength) PUCHAR FrameBuffer,
- _In_ UCHAR FrameLength,
- _In_ UCHAR Channel
-)
-{
- otListener* aListener = (otListener*)aContext;
- assert(aListener);
-
- if (FrameLength)
- {
- otMacFrameEntry* entry = new otMacFrameEntry;
- entry->Frame.buffer[0] = Channel;
- memcpy_s(entry->Frame.buffer + 1, sizeof(entry->Frame.buffer) - 1, FrameBuffer, FrameLength);
- entry->Frame.length = FrameLength + 1;
- entry->Frame.nodeid = (uint32_t)-1;
-
- // Look up the Node ID from by interface guid
- EnterCriticalSection(&gCS);
- for (uint32_t i = 0; i < gNodes.size(); i++)
- {
- if (gNodes[i]->mInterfaceIndex == SourceInterfaceIndex)
- {
- entry->Frame.nodeid = gNodes[i]->mId;
- break;
- }
- }
- LeaveCriticalSection(&gCS);
-
- // Push the frame on the list to process
- EnterCriticalSection(&aListener->mCS);
- InsertTailList(&aListener->mFrames, &entry->Link);
- LeaveCriticalSection(&aListener->mCS);
-
- // Set event indicating we have a new frame to process
- SetEvent(aListener->mFramesUpdatedEvent);
- }
-}
-
-OTNODEAPI otListener* OTCALL otListenerInit(uint32_t /* nodeid */)
-{
- otLogFuncEntry();
-
- auto ApiInstance = GetApiInstance();
- if (ApiInstance == nullptr)
- {
- printf("GetApiInstance failed!\r\n");
- otLogFuncExitMsg("GetApiInstance failed");
- return nullptr;
- }
-
- otListener *listener = new otListener();
- assert(listener);
-
- InitializeCriticalSection(&listener->mCS);
- listener->mStopEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
- listener->mFramesUpdatedEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
- InitializeListHead(&listener->mFrames);
-
- // Create the listener
- listener->mListener = otvmpListenerCreate(&gTopologyGuid);
- if (listener->mListener == nullptr) goto error;
-
- // Register for callbacks
- otvmpListenerRegister(listener->mListener, otListenerCallback, listener);
-
- printf("S: Sniffer started\r\n");
-
-error:
-
- // Clean up on failure
- if (listener)
- {
- if (listener->mListener == nullptr)
- {
- otListenerFinalize(listener);
- }
- }
-
- otLogFuncExit();
-
- return listener;
-}
-
-OTNODEAPI int32_t OTCALL otListenerFinalize(otListener* aListener)
-{
- otLogFuncEntry();
-
- if (aListener != nullptr)
- {
- // Set stop event to prevent cancel any pending otListenerRead calls
- SetEvent(aListener->mStopEvent);
-
- if (aListener->mListener)
- {
- // Unregisters (and waits for callbacks to complete) and cleans up the handle
- otvmpListenerDestroy(aListener->mListener);
- aListener->mListener = nullptr;
-
- // Clean up left over frames
- PLIST_ENTRY Link = aListener->mFrames.Flink;
- while (Link != &aListener->mFrames)
- {
- otMacFrameEntry *entry = CONTAINING_RECORD(Link, otMacFrameEntry, Link);
- Link = Link->Flink;
- delete entry;
- }
-
- printf("S: Sniffer stopped\r\n");
- }
-
- // Clean up everything else
- CloseHandle(aListener->mFramesUpdatedEvent);
- aListener->mFramesUpdatedEvent = nullptr;
- CloseHandle(aListener->mStopEvent);
- aListener->mStopEvent = nullptr;
- DeleteCriticalSection(&aListener->mCS);
- delete aListener;
-
- ReleaseApiInstance();
- }
-
- otLogFuncExit();
-
- return 0;
-}
-
-OTNODEAPI int32_t OTCALL otListenerRead(otListener* aListener, otMacFrame *aFrame)
-{
- do
- {
- bool exit = false;
-
- EnterCriticalSection(&aListener->mCS);
-
- // If we have a pending frame, return it now
- if (!IsListEmpty(&aListener->mFrames))
- {
- PLIST_ENTRY Link = RemoveHeadList(&aListener->mFrames);
- otMacFrameEntry *entry = CONTAINING_RECORD(Link, otMacFrameEntry, Link);
- *aFrame = entry->Frame;
- delete entry;
- exit = true;
- }
-
- LeaveCriticalSection(&aListener->mCS);
-
- if (exit) break;
-
- // Wait for the shutdown or frames updated event
- auto waitResult = WaitForMultipleObjects(2, &aListener->mStopEvent, FALSE, INFINITE);
-
- if (waitResult == WAIT_OBJECT_0 + 1) // mFramesUpdatedEvent
- {
- continue;
- }
- else // mStopEvent
- {
- return 1;
- }
-
- } while (true);
-
- //printf("S: Sniffer read %d bytes from node %d\r\n", aFrame->length, aFrame->nodeid);
-
- return 0;
-}
diff --git a/examples/drivers/windows/otNodeApi/precomp.h b/examples/drivers/windows/otNodeApi/precomp.h
deleted file mode 100644
index d7de64809..000000000
--- a/examples/drivers/windows/otNodeApi/precomp.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-#define _CRT_SECURE_NO_WARNINGS
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-using namespace std;
-
-// Define to export necessary functions
-#define OTDLL
-#define OTNODEAPI EXTERN_C __declspec(dllexport)
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-void Unload();
-
-FORCEINLINE
-VOID
-InitializeListHead(
- _Out_ PLIST_ENTRY ListHead
- )
-{
- ListHead->Flink = ListHead->Blink = ListHead;
-}
-
-FORCEINLINE
-PLIST_ENTRY
-RemoveHeadList(
- _Inout_ PLIST_ENTRY ListHead
- )
-
-{
-
- PLIST_ENTRY Entry;
- PLIST_ENTRY NextEntry;
- Entry = ListHead->Flink;
- NextEntry = Entry->Flink;
- ListHead->Flink = NextEntry;
- NextEntry->Blink = ListHead;
- return Entry;
-}
-
-FORCEINLINE
-VOID
-InsertTailList(
- _Inout_ PLIST_ENTRY ListHead,
- _Out_ __drv_aliasesMem PLIST_ENTRY Entry
- )
-{
-
- PLIST_ENTRY PrevEntry;
- PrevEntry = ListHead->Blink;
- Entry->Flink = ListHead;
- Entry->Blink = PrevEntry;
- PrevEntry->Flink = Entry;
- ListHead->Blink = Entry;
-}
-
-_Must_inspect_result_
-BOOLEAN
-CFORCEINLINE
-IsListEmpty(
- _In_ const LIST_ENTRY * ListHead
- )
-{
- return (BOOLEAN)(ListHead->Flink == ListHead);
-}
diff --git a/examples/drivers/windows/ottmp/adapter.cpp b/examples/drivers/windows/ottmp/adapter.cpp
deleted file mode 100644
index 583654991..000000000
--- a/examples/drivers/windows/ottmp/adapter.cpp
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * This module implements code to manage the NETADAPTER object for the
- * network adapter.
- */
-
-#include "pch.hpp"
-#include "adapter.tmh"
-
-PAGED
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NDIS_STATUS
-AdapterInitialize(
- _In_ NDIS_HANDLE MiniportAdapterHandle,
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- )
-/*++
-Routine Description:
-
- AdapterInitialize function is called to initialize the Network Adapter
- at the time of Pnp Add device.
-
- This routine initializes the context of the adapter object
-
-Arguments:
-
- MiniportAdapterHandle - Handle to the NDIS Miniport Adapter object.
-
- AdapterContext - The context associated with the adapter
-
-Return Value:
-
- NTSTATUS - A failure here will indicate a fatal error in the driver.
-
---*/
-{
- NDIS_STATUS Status;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- do
- {
- NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES AdapterRegistration = { 0 };
- NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES AdapterGeneral = { 0 };
- NDIS_PM_CAPABILITIES PmCapabilities = { 0 };
-
- //
- // First, set the registration attributes.
- //
- AdapterRegistration.Header.Type = NDIS_OBJECT_TYPE_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES;
- AdapterRegistration.Header.Size = sizeof(AdapterRegistration);
- AdapterRegistration.Header.Revision = NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES_REVISION_2;
-
- AdapterRegistration.MiniportAdapterContext = AdapterContext;
- AdapterRegistration.AttributeFlags = NDIS_MINIPORT_ATTRIBUTES_SURPRISE_REMOVE_OK | NDIS_MINIPORT_ATTRIBUTES_NDIS_WDM | NDIS_MINIPORT_ATTRIBUTES_NO_PAUSE_ON_SUSPEND;
- AdapterRegistration.InterfaceType = NdisInterfacePNPBus;
-
- NDIS_DECLARE_MINIPORT_ADAPTER_CONTEXT(_OTTMP_ADAPTER_CONTEXT);
- Status = NdisMSetMiniportAttributes(
- MiniportAdapterHandle,
- (PNDIS_MINIPORT_ADAPTER_ATTRIBUTES)&AdapterRegistration);
-
- if (NDIS_STATUS_SUCCESS != Status)
- {
- LogError(DRIVER_DEFAULT, "[%p] NdisSetOptionalHandlers Status %!NDIS_STATUS!", AdapterContext, Status);
- break;
- }
-
- //
- // Next, set the general attributes.
- //
-
- AdapterGeneral.Header.Type = NDIS_OBJECT_TYPE_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES;
- AdapterGeneral.Header.Size = NDIS_SIZEOF_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES_REVISION_2;
- AdapterGeneral.Header.Revision = NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES_REVISION_2;
-
- //
- // Specify the medium type that the NIC can support but not
- // necessarily the medium type that the NIC currently uses.
- //
- AdapterGeneral.MediaType = NIC_MEDIUM_TYPE;
-
- //
- // Specifiy medium type that the NIC currently uses.
- //
- AdapterGeneral.PhysicalMediumType = NdisPhysicalMediumNative802_15_4;
-
- //
- // We have to lie about the MTU, so that TCPIP will bind to us.
- // Specifically, we have to rely that the ThreadLwf will fragment
- // the packets appropriately.
- //
- AdapterGeneral.MtuSize = HW_MAX_FRAME_SIZE;
- AdapterGeneral.MaxXmitLinkSpeed = NIC_RECV_XMIT_SPEED;
- AdapterGeneral.XmitLinkSpeed = NIC_RECV_XMIT_SPEED;
- AdapterGeneral.MaxRcvLinkSpeed = NIC_RECV_XMIT_SPEED;
- AdapterGeneral.RcvLinkSpeed = NIC_RECV_XMIT_SPEED;
- AdapterGeneral.MediaConnectState = MediaConnectStateConnected;
- AdapterGeneral.MediaDuplexState = MediaDuplexStateFull;
-
- //
- // The maximum number of bytes the NIC can provide as lookahead data.
- // If that value is different from the size of the lookahead buffer
- // supported by bound protocols, NDIS will call MiniportOidRequest to
- // set the size of the lookahead buffer provided by the miniport driver
- // to the minimum of the miniport driver and protocol(s) values. If the
- // driver always indicates up full packets with
- // NdisMIndicateReceiveNetBufferLists, it should set this value to the
- // maximum total frame size, which excludes the header.
- //
- // Upper-layer drivers examine lookahead data to determine whether a
- // packet that is associated with the lookahead data is intended for
- // one or more of their clients. If the underlying driver supports
- // multipacket receive indications, bound protocols are given full net
- // packets on every indication. Consequently, this value is identical
- // to that returned for OID_GEN_RECEIVE_BLOCK_SIZE.
- //
- AdapterGeneral.LookaheadSize = HW_MAX_FRAME_SIZE;
- AdapterGeneral.PowerManagementCapabilities = NULL;
- AdapterGeneral.MacOptions = NIC_MAC_OPTIONS;
- AdapterGeneral.SupportedPacketFilters = NIC_SUPPORTED_FILTERS;
-
- //
- // The maximum number of multicast addresses the NIC driver can manage.
- // This list is global for all protocols bound to (or above) the NIC.
- // Consequently, a protocol can receive NDIS_STATUS_MULTICAST_FULL from
- // the NIC driver when attempting to set the multicast address list,
- // even if the number of elements in the given list is less than the
- // number originally returned for this query.
- //
- AdapterGeneral.MaxMulticastListSize = NIC_MAX_MCAST_LIST;
- AdapterGeneral.MacAddressLength = NIC_MACADDR_SIZE;
-
- //
- // Return the MAC address of the NIC burnt in the hardware.
- //
- memcpy(AdapterGeneral.PermanentMacAddress, &AdapterContext->ExtendedAddress, sizeof(AdapterContext->ExtendedAddress));
- memcpy(AdapterGeneral.CurrentMacAddress, &AdapterContext->ExtendedAddress, sizeof(AdapterContext->ExtendedAddress));
-
- AdapterGeneral.RecvScaleCapabilities = NULL;
- AdapterGeneral.AccessType = NET_IF_ACCESS_BROADCAST;
- AdapterGeneral.DirectionType = NET_IF_DIRECTION_SENDRECEIVE;
- AdapterGeneral.ConnectionType = NET_IF_CONNECTION_DEDICATED;
- AdapterGeneral.IfType = IF_TYPE_IEEE802154;
- AdapterGeneral.IfConnectorPresent = TRUE;
- AdapterGeneral.SupportedStatistics = NIC_SUPPORTED_STATISTICS;
- AdapterGeneral.SupportedPauseFunctions = NdisPauseFunctionsUnsupported;
- AdapterGeneral.DataBackFillSize = 0;
- AdapterGeneral.ContextBackFillSize = 0;
-
- //
- // The SupportedOidList is an array of OIDs for objects that the
- // underlying driver or its NIC supports. Objects include general,
- // media-specific, and implementation-specific objects. NDIS forwards a
- // subset of the returned list to protocols that make this query. That
- // is, NDIS filters any supported statistics OIDs out of the list
- // because protocols never make statistics queries.
- //
- AdapterGeneral.SupportedOidList = NICSupportedOids;
- AdapterGeneral.SupportedOidListLength = SizeOfNICSupportedOids;
- AdapterGeneral.AutoNegotiationFlags = NDIS_LINK_STATE_DUPLEX_AUTO_NEGOTIATED;
-
- //
- // Set the power management capabilities. All 0 basically means we don't
- // support Dx for anything.
- //
-
- PmCapabilities.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
- PmCapabilities.Header.Size = NDIS_SIZEOF_NDIS_PM_CAPABILITIES_REVISION_2;
- PmCapabilities.Header.Revision = NDIS_PM_CAPABILITIES_REVISION_2;
-
- AdapterGeneral.PowerManagementCapabilitiesEx = &PmCapabilities;
-
- Status = NdisMSetMiniportAttributes(
- MiniportAdapterHandle,
- (PNDIS_MINIPORT_ADAPTER_ATTRIBUTES)&AdapterGeneral);
-
- if (NDIS_STATUS_SUCCESS != Status)
- {
- LogError(DRIVER_DEFAULT, "[%p] NdisSetOptionalHandlers failed %!NDIS_STATUS!", AdapterContext, Status);
- break;
- }
-
- } while (FALSE);
-
- LogFuncExitNDIS(DRIVER_DEFAULT, Status);
-
- return Status;
-}
-
-PAGED
-_IRQL_requires_(PASSIVE_LEVEL)
-VOID
-AdapterUninitialize(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- )
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- SerialUninitialize(AdapterContext);
-
- if (AdapterContext->Device)
- {
- WdfObjectDelete(AdapterContext->Device);
- AdapterContext->Device = nullptr;
- }
-
- NdisFreeMemory(AdapterContext, 0, 0);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-PAGED
-_IRQL_requires_( PASSIVE_LEVEL )
-_Function_class_( MINIPORT_RESTART )
-NDIS_STATUS
-MPRestart(
- _In_ NDIS_HANDLE MiniportAdapterContext,
- _In_ PNDIS_MINIPORT_RESTART_PARAMETERS /* RestartParameters */
- )
-/*++
-
-Routine Description:
-
- When a miniport receives a restart request, it enters into a Restarting
- state. The miniport may begin indicating received data (e.g., using
- NdisMIndicateReceiveNetBufferLists), handling status indications, and
- processing OID requests in the Restarting state. However, no sends will be
- requested while the miniport is in the Restarting state.
-
- Once the miniport is ready to send data, it has entered the Running state.
- The miniport informs NDIS that it is in the Running state by returning
- NDIS_STATUS_SUCCESS from this MiniportRestart function; or if this function
- has already returned NDIS_STATUS_PENDING, by calling NdisMRestartComplete.
-
-
- MiniportRestart runs at IRQL = PASSIVE_LEVEL.
-
-Arguments:
-
- MiniportAdapterContext Pointer to the Adapter
- RestartParameters Additional information about the restart operation
-
-Return Value:
-
- If the miniport is able to immediately enter the Running state, it should
- return NDIS_STATUS_SUCCESS.
-
- If the miniport is still in the Restarting state, it should return
- NDIS_STATUS_PENDING now, and call NdisMRestartComplete when the miniport
- has entered the Running state.
-
- Other NDIS_STATUS codes indicate errors. If an error is encountered, the
- miniport must return to the Paused state (i.e., stop indicating receives).
-
---*/
-
-{
- NDIS_STATUS status = NDIS_STATUS_SUCCESS;
- POTTMP_ADAPTER_CONTEXT AdapterContext = (POTTMP_ADAPTER_CONTEXT)MiniportAdapterContext;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- // Set the running flag
- AdapterContext->IsRunning = true;
-
- LogFuncExitNDIS(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-PAGED
-_IRQL_requires_( PASSIVE_LEVEL )
-_Function_class_( MINIPORT_PAUSE )
-NDIS_STATUS
-MPPause(
- _In_ NDIS_HANDLE MiniportAdapterContext,
- _In_ PNDIS_MINIPORT_PAUSE_PARAMETERS /* MiniportPauseParameters */
- )
-/*++
-
-Routine Description:
-
- When a miniport receives a pause request, it enters into a Pausing state.
- The miniport should not indicate up any more network data. Any pending
- send requests must be completed, and new requests must be rejected with
- NDIS_STATUS_PAUSED.
-
- Once all sends have been completed and all recieve NBLs have returned to
- the miniport, the miniport enters the Paused state.
-
- While paused, the miniport can still service interrupts from the hardware
- (to, for example, continue to indicate NDIS_STATUS_MEDIA_CONNECT
- notifications).
-
- The miniport must continue to be able to handle status indications and OID
- requests. MiniportPause is different from MiniportHalt because, in
- general, the MiniportPause operation won't release any resources.
- MiniportPause must not attempt to acquire any resources where allocation
- can fail, since MiniportPause itself must not fail.
-
-
- MiniportPause runs at IRQL = PASSIVE_LEVEL.
-
-Arguments:
-
- MiniportAdapterContext Pointer to the Adapter
- MiniportPauseParameters Additional information about the pause operation
-
-Return Value:
-
- If the miniport is able to immediately enter the Paused state, it should
- return NDIS_STATUS_SUCCESS.
-
- If the miniport must wait for send completions or pending receive NBLs, it
- should return NDIS_STATUS_PENDING now, and call NDISMPauseComplete when the
- miniport has entered the Paused state.
-
- No other return value is permitted. The pause operation must not fail.
-
---*/
-{
- NDIS_STATUS status = NDIS_STATUS_SUCCESS;
- POTTMP_ADAPTER_CONTEXT AdapterContext = (POTTMP_ADAPTER_CONTEXT)MiniportAdapterContext;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- // Clear the flag to indicate we are no longer running
- AdapterContext->IsRunning = false;
-
- LogFuncExitNDIS(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-VOID
-MPSendNetBufferLists(
- _In_ NDIS_HANDLE MiniportAdapterContext,
- _In_ PNET_BUFFER_LIST NetBufferLists,
- _In_ NDIS_PORT_NUMBER /* PortNumber */,
- _In_ ULONG SendFlags
- )
-/*++
-
-Routine Description:
-
- Send Packet Array handler. Called by NDIS whenever a protocol
- bound to our miniport sends one or more packets.
-
- The input packet descriptor pointers have been ordered according
- to the order in which the packets should be sent over the network
- by the protocol driver that set up the packet array. The NDIS
- library preserves the protocol-determined ordering when it submits
- each packet array to MiniportSendPackets
-
- As a deserialized driver, we are responsible for holding incoming send
- packets in our internal queue until they can be transmitted over the
- network and for preserving the protocol-determined ordering of packet
- descriptors incoming to its MiniportSendPackets function.
- A deserialized miniport driver must complete each incoming send packet
- with NdisMSendComplete, and it cannot call NdisMSendResourcesAvailable.
-
- Runs at IRQL <= DISPATCH_LEVEL
-
-Arguments:
-
- MiniportAdapterContext Pointer to our adapter
- NetBufferLists Head of a list of NBLs to send
- PortNumber A miniport adapter port. Default is 0.
- SendFlags Additional flags for the send operation
-
-Return Value:
-
- None. Write status directly into each NBL with the NET_BUFFER_LIST_STATUS
- macro.
-
---*/
-{
- POTTMP_ADAPTER_CONTEXT AdapterContext = (POTTMP_ADAPTER_CONTEXT)MiniportAdapterContext;
- PNET_BUFFER_LIST FailedNbls = NULL;
-
- LogFuncEntryMsg(DRIVER_DEFAULT, "NetBufferList: %p", NetBufferLists);
-
- PNET_BUFFER_LIST CurrNbl = NetBufferLists;
- while (CurrNbl)
- {
- PNET_BUFFER_LIST NextNbl = CurrNbl->Next;
- CurrNbl->Next = NULL;
-
- // Only allow one NB per NBL
- if (CurrNbl->FirstNetBuffer == NULL ||
- CurrNbl->FirstNetBuffer->Next != NULL)
- {
- CurrNbl->Status = STATUS_INVALID_PARAMETER;
- }
- else
- {
- // Try to queue up for send
- NTSTATUS status = SerialSendData(AdapterContext, CurrNbl);
-
- if (!NT_SUCCESS(status)) {
- CurrNbl->Status = status;
- }
- else {
- CurrNbl = NULL;
- }
- }
-
- // If we still have the CurrNbl, it failed, so move it to the failure list
- if (CurrNbl) {
- CurrNbl->Next = FailedNbls;
- FailedNbls = CurrNbl;
- }
-
- CurrNbl = NextNbl;
- }
-
- // Complete any failures
- if (FailedNbls) {
- NdisMSendNetBufferListsComplete(AdapterContext->Adapter, FailedNbls, (SendFlags & NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL));
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-VOID
-MPCancelSend(
- _In_ NDIS_HANDLE /* MiniportAdapterContext */,
- _In_ PVOID /* CancelId */
- )
-/*++
-
-Routine Description:
-
- MiniportCancelSend cancels the transmission of all NET_BUFFER_LISTs that
- are marked with a specified cancellation identifier. Miniport drivers
- that queue send packets for more than one second should export this
- handler. When a protocol driver or intermediate driver calls the
- NdisCancelSendNetBufferLists function, NDIS calls the MiniportCancelSend
- function of the appropriate lower-level driver (miniport driver or
- intermediate driver) on the binding.
-
- Runs at IRQL <= DISPATCH_LEVEL.
-
-Arguments:
-
- MiniportAdapterContext Pointer to our adapter
- CancelId All the packets with this Id should be cancelled
-
-Return Value:
-
- None.
-
---*/
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-VOID
-MPReturnNetBufferLists(
- _In_ NDIS_HANDLE /* MiniportAdapterContext */,
- _In_ PNET_BUFFER_LIST NetBufferLists,
- _In_ ULONG /* ReturnFlags */
- )
-/*++
-
-Routine Description:
-
- NDIS Miniport entry point called whenever protocols are done with one or
- NBLs that we indicated up with NdisMIndicateReceiveNetBufferLists.
-
- Note that the list of NBLs may be chained together from multiple separate
- lists that were indicated up individually.
-
-Arguments:
-
- MiniportAdapterContext Pointer to our adapter
- NetBufferLists NBLs being returned
- ReturnFlags May contain the NDIS_RETURN_FLAGS_DISPATCH_LEVEL
- flag, which if is set, indicates we can get a
- small perf win by not checking or raising the
- IRQL
-
-Return Value:
-
- None.
-
---*/
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- // Iterate through all the NetBufferLists
- for (PNET_BUFFER_LIST pNblNext, pNbl = NetBufferLists; pNbl; pNbl = pNblNext)
- {
- // Save next to temporary and clear member variable
- pNblNext = NET_BUFFER_LIST_NEXT_NBL(pNbl);
- NET_BUFFER_LIST_NEXT_NBL(pNbl) = NULL;
-
- // Iterate through all the Netbuffers
- for (PNET_BUFFER pNbNext, pNb = NET_BUFFER_LIST_FIRST_NB(pNbl); pNb; pNb = pNbNext)
- {
- pNbNext = NET_BUFFER_NEXT_NB(pNb);
- NdisFreeNetBuffer(pNb);
- }
-
- NdisFreeNetBufferList(pNbl);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
diff --git a/examples/drivers/windows/ottmp/adapter.hpp b/examples/drivers/windows/ottmp/adapter.hpp
deleted file mode 100644
index fc51171aa..000000000
--- a/examples/drivers/windows/ottmp/adapter.hpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * Header file for the routines related to NETADAPTER Object for the
- * Network Adapter
- */
-
-#define NIC_TAG_RECV_NBL ((ULONG)'rMVT') // TVMr
-#define OTTMP_ADAPTER_CONTEXT_SIGNATURE 'pdAt'
-
-// The maximum size of one Spinel command / serial packet
-#define MAX_SPINEL_COMMAND_LENGTH 1300
-
-typedef struct _SERIAL_SEND_ITEM
-{
- LIST_ENTRY Link;
- PNET_BUFFER_LIST NetBufferList;
- WDFMEMORY WdfMemory;
- ULONG EncodedBufferLength;
- _Field_size_bytes_(EncodedBufferLength)
- UCHAR EncodedBuffer[0];
-
-} SERIAL_SEND_ITEM, *PSERIAL_SEND_ITEM;
-
-const ULONG SERIAL_SEND_ITEM_SIZE = FIELD_OFFSET(SERIAL_SEND_ITEM, EncodedBuffer);
-
-typedef struct _OTTMP_ADAPTER_CONTEXT {
- ULONG Signature;
-
-#ifdef OTTMP_LEGACY
- NDIS_HANDLE Adapter;
-#else
- //
- // Handle to the NETADAPTER object for this context
- //
- NETADAPTER Adapter;
-#endif
-
- //
- // Handle to the corresponding WDFDEVICE
- //
- WDFDEVICE Device;
-
- // Flag to indicate if the data path is enabled
- bool IsConnected;
-
- // Flag to indicate if the Adapter has been started or not
- bool IsRunning;
-
-#ifdef OTTMP_LEGACY
- PGLOBALS pGlobals;
-#else
- // Receive packet pool
- NETBUFFERLISTCOLLECTION ReceiveCollection;
-#endif
-
- ULONGLONG ExtendedAddress; // TODO - Cache
-
- //
- // Serial Device
- //
-
- WDFIOTARGET WdfIoTarget;
-
- WDFSPINLOCK SendLock;
- _Guarded_by_(SendLock)
- LIST_ENTRY SendQueue;
- bool SendQueueRunning;
- WDFWORKITEM SendWorkItem;
-
- WDFWORKITEM RecvWorkItem;
- WDFREQUEST RecvReadRequest;
-
- UCHAR RecvBuffer[MAX_SPINEL_COMMAND_LENGTH * 2];
- ULONG RecvBufferLength;
-
- //
- // NIC configuration - This information is queried by the protocol drivers.
- // Since this sample focuses on demonstrating the NDIS WDF model,
- // it doesn't modify any these values during runtime.
- // Please look at the netvmini630 sample to see how these values can be set
- // and updated
- // -------------------------------------------------------------------------
- //
- ULONG PacketFilter;
- ULONG ulLookahead;
- ULONG64 ulLinkSendSpeed;
- ULONG64 ulLinkRecvSpeed;
- ULONG ulMaxBusySends;
- ULONG ulMaxBusyRecvs;
-
- //
- // Statistics -
- // Since this sample focuses on demonstrating the NDIS WDF model,
- // it doesn't modify any these values during runtime.
- // Please look at the netvmini630 sample to see how these values can be set
- // and updated
- // -------------------------------------------------------------------------
- //
-
- // Packet counts
- ULONG64 FramesRxDirected;
- ULONG64 FramesRxMulticast;
- ULONG64 FramesRxBroadcast;
- ULONG64 FramesTxDirected;
- ULONG64 FramesTxMulticast;
- ULONG64 FramesTxBroadcast;
-
- // Byte counts
- ULONG64 BytesRxDirected;
- ULONG64 BytesRxMulticast;
- ULONG64 BytesRxBroadcast;
- ULONG64 BytesTxDirected;
- ULONG64 BytesTxMulticast;
- ULONG64 BytesTxBroadcast;
-
- // Count of transmit errors
- ULONG TxAbortExcessCollisions;
- ULONG TxLateCollisions;
- ULONG TxDmaUnderrun;
- ULONG TxLostCRS;
- ULONG TxOKButDeferred;
- ULONG OneRetry;
- ULONG MoreThanOneRetry;
- ULONG TotalRetries;
- ULONG TransmitFailuresOther;
-
- // Count of receive errors
- ULONG RxCrcErrors;
- ULONG RxAlignmentErrors;
- ULONG RxResourceErrors;
- ULONG RxDmaOverrunErrors;
- ULONG RxCdtFrames;
- ULONG RxRuntErrors;
-
-} OTTMP_ADAPTER_CONTEXT, *POTTMP_ADAPTER_CONTEXT;
-
-WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(OTTMP_ADAPTER_CONTEXT, GetAdapterContext);
-
-typedef struct _WDF_DEVICE_INFO
-{
- POTTMP_ADAPTER_CONTEXT AdapterContext;
-
-} WDF_DEVICE_INFO, *PWDF_DEVICE_INFO;
-
-WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(WDF_DEVICE_INFO, GetWdfDeviceInfo);
-
-#ifdef OTTMP_LEGACY
-
-PAGED MINIPORT_PAUSE MPPause;
-PAGED MINIPORT_RESTART MPRestart;
-
-MINIPORT_SEND_NET_BUFFER_LISTS MPSendNetBufferLists;
-MINIPORT_RETURN_NET_BUFFER_LISTS MPReturnNetBufferLists;
-MINIPORT_CANCEL_SEND MPCancelSend;
-
-PAGED
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NDIS_STATUS
-AdapterInitialize(
- _In_ NDIS_HANDLE MiniportAdapterHandle,
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- );
-
-PAGED
-_IRQL_requires_(PASSIVE_LEVEL)
-VOID
-AdapterUninitialize(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- );
-
-#else
-
-PAGED EVT_NET_ADAPTER_SET_CAPABILITIES EvtAdapterSetCapabilities;
-PAGED EVT_NET_ADAPTER_START EvtAdapterStart;
-PAGED EVT_NET_ADAPTER_PAUSE EvtAdapterPause;
-
-EVT_NET_ADAPTER_SEND_NET_BUFFER_LISTS EvtAdapterSendNetBufferLists;
-
-PAGED
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-AdapterInitialize(
- _In_ NETADAPTER Adapter,
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ POTTMP_DEVICE_CONTEXT DeviceContext
- );
-
-#endif
-
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-AdapterIndicateEnergyScanComplete(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ NDIS_STATUS Status
- );
-
-EXT_CALLBACK AdapterEnergyScanTimerCallback;
diff --git a/examples/drivers/windows/ottmp/device.cpp b/examples/drivers/windows/ottmp/device.cpp
deleted file mode 100644
index 9b7619cb4..000000000
--- a/examples/drivers/windows/ottmp/device.cpp
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * This module implements code to manage the WDFDEVICE object for the
- * network adapter.
- */
-
-#include
-#include "pch.hpp"
-#include "device.tmh"
-
-PAGED
-_IRQL_requires_( PASSIVE_LEVEL )
-_Function_class_( MINIPORT_INITIALIZE )
-NDIS_STATUS
-MPInitializeEx(
- _In_ NDIS_HANDLE MiniportAdapterHandle,
- _In_ NDIS_HANDLE MiniportDriverContext,
- _In_ PNDIS_MINIPORT_INIT_PARAMETERS /* MiniportInitParameters */
- )
-/*++
-Routine Description:
-
- The MiniportInitialize function is a required function that sets up a
- NIC (or virtual NIC) for network I/O operations, claims all hardware
- resources necessary to the NIC in the registry, and allocates resources
- the driver needs to carry out network I/O operations.
-
- MiniportInitialize runs at IRQL = PASSIVE_LEVEL.
-
-Arguments:
-
-Return Value:
-
- NDIS_STATUS_xxx code
-
---*/
-{
- NDIS_STATUS Status = NDIS_STATUS_FAILURE;
- PGLOBALS pGlobals = (PGLOBALS)MiniportDriverContext;
- PDEVICE_OBJECT pPdo = nullptr;
- PDEVICE_OBJECT pFdo = nullptr;
- PDEVICE_OBJECT pNextDeviceObject = nullptr;
- WDF_OBJECT_ATTRIBUTES attributes;
- WDFDEVICE device = nullptr;
- POTTMP_DEVICE_CONTEXT deviceContext = nullptr;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- do
- {
- NDIS_MINIPORT_ADAPTER_REGISTRATION_ATTRIBUTES AdapterRegistration = { 0 };
- NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES AdapterGeneral = { 0 };
- NDIS_PM_CAPABILITIES PmCapabilities = { 0 };
-
- //
- // NdisMGetDeviceProperty function enables us to get the:
- // PDO - created by the bus driver to represent our device.
- // FDO - created by NDIS to represent our miniport as a function
- // driver.
- // NextDeviceObject - deviceobject of another driver (filter)
- // attached to us at the bottom.
- // Since our driver is talking to NDISPROT, the NextDeviceObject
- // is not useful. But if we were to talk to a driver that we
- // are attached to as part of the devicestack then NextDeviceObject
- // would be our target DeviceObject for sending read/write Requests.
- //
-
- NdisMGetDeviceProperty(
- MiniportAdapterHandle,
- &pPdo,
- &pFdo,
- &pNextDeviceObject,
- nullptr,
- nullptr);
-
- WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, OTTMP_DEVICE_CONTEXT);
-
- NTSTATUS ntStatus = WdfDeviceMiniportCreate(
- pGlobals->WdfDriver,
- &attributes,
- pFdo,
- pNextDeviceObject,
- pPdo,
- &device);
-
- if (!NT_SUCCESS(ntStatus))
- {
- LogError(DRIVER_DEFAULT, "WdfDeviceMiniportCreate failed %!STATUS!", ntStatus);
- Status = NDIS_STATUS_FAILURE;
- break;
- }
-
- //
- // Get WDF miniport device context.
- //
- deviceContext = GetDeviceContext(device);
- deviceContext->Signature = OTTMP_DEVICE_CONTEXT_SIGNATURE;
- deviceContext->Device = device;
-
- //
- // Allocate adapter context structure and initialize all the
- // memory resources for sending and receiving packets.
- //
- deviceContext->AdapterContext = (POTTMP_ADAPTER_CONTEXT)NdisAllocateMemoryWithTagPriority(
- pGlobals->hDriver,
- sizeof(OTTMP_ADAPTER_CONTEXT),
- OTTMP_ADAPTER_CONTEXT_SIGNATURE,
- NormalPoolPriority);
-
- if (deviceContext->AdapterContext == nullptr)
- {
- LogError(DRIVER_DEFAULT, "NdisAllocateMemoryWithTagPriority failed");
- Status = NDIS_STATUS_RESOURCES;
- break;
- }
-
- RtlZeroMemory(deviceContext->AdapterContext, sizeof(OTTMP_ADAPTER_CONTEXT));
- deviceContext->AdapterContext->Signature = OTTMP_ADAPTER_CONTEXT_SIGNATURE;
- deviceContext->AdapterContext->Adapter = MiniportAdapterHandle;
- deviceContext->AdapterContext->Device = deviceContext->Device;
- deviceContext->AdapterContext->pGlobals = pGlobals;
-
- Status = AdapterInitialize(
- MiniportAdapterHandle,
- deviceContext->AdapterContext);
-
- if (NDIS_STATUS_SUCCESS != Status)
- {
- LogError(DRIVER_DEFAULT, "AdapterInitialize failed %!NDIS_STATUS!", Status);
- break;
- }
-
- ntStatus = SerialInitialize(deviceContext->AdapterContext);
- if (!NT_SUCCESS(ntStatus))
- {
- Status = NDIS_STATUS_FAILURE;
- break;
- }
-
- // Start the read loop
- LogVerbose(DRIVER_DEFAULT, "Starting recv worker");
- WdfWorkItemEnqueue(deviceContext->AdapterContext->RecvWorkItem);
-
- } while (FALSE);
-
- if (Status != NDIS_STATUS_SUCCESS)
- {
- if (deviceContext && deviceContext->AdapterContext)
- {
- AdapterUninitialize(deviceContext->AdapterContext);
- deviceContext->AdapterContext = nullptr;
- }
- }
-
- LogFuncExitNDIS(DRIVER_DEFAULT, Status);
-
- return Status;
-}
-
-PAGED
-VOID
-MPHaltEx(
- _In_ NDIS_HANDLE MiniportAdapterContext,
- _In_ NDIS_HALT_ACTION HaltAction
- )
-/*++
-
-Routine Description:
-
- Halt handler is called when NDIS receives IRP_MN_STOP_DEVICE,
- IRP_MN_SUPRISE_REMOVE or IRP_MN_REMOVE_DEVICE requests from the PNP
- manager. Here, the driver should free all the resources acquired in
- MiniportInitialize and stop access to the hardware. NDIS will not submit
- any further request once this handler is invoked.
-
- 1) Free and unmap all I/O resources.
- 2) Disable interrupt and deregister interrupt handler.
- 3) Deregister shutdown handler regsitered by
- NdisMRegisterAdapterShutdownHandler .
- 4) Cancel all queued up timer callbacks.
- 5) Finally wait indefinitely for all the outstanding receive
- packets indicated to the protocol to return.
-
- MiniportHalt runs at IRQL = PASSIVE_LEVEL.
-
-
-Arguments:
-
- MiniportAdapterContext Pointer to the Adapter
- HaltAction The reason for halting the adapter
-
-Return Value:
-
- None.
-
---*/
-{
- POTTMP_ADAPTER_CONTEXT AdapterContext = (POTTMP_ADAPTER_CONTEXT)MiniportAdapterContext;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- //
- // Call Shutdown handler to disable interrupt and turn the hardware off
- // by issuing a full reset
- //
- if (HaltAction != NdisHaltDeviceSurpriseRemoved)
- {
- MPShutdownEx(MiniportAdapterContext, NdisShutdownPowerOff);
- }
-
- AdapterUninitialize(AdapterContext);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-VOID
-MPShutdownEx(
- _In_ NDIS_HANDLE /* MiniportAdapterContext */,
- _In_ NDIS_SHUTDOWN_ACTION /* ShutdownAction */
- )
-/*++
-
-Routine Description:
-
- The MiniportShutdownEx handler restores hardware to its initial state when
- the system is shut down, whether by the user or because an unrecoverable
- system error occurred. This is to ensure that the NIC is in a known
- state and ready to be reinitialized when the machine is rebooted after
- a system shutdown occurs for any reason, including a crash dump.
-
- Here just disable the interrupt and stop the DMA engine. Do not free
- memory resources or wait for any packet transfers to complete. Do not call
- into NDIS at this time.
-
- This can be called at aribitrary IRQL, including in the context of a
- bugcheck.
-
-Arguments:
-
- MiniportAdapterContext Pointer to our adapter
- ShutdownAction The reason why NDIS called the shutdown function
-
-Return Value:
-
- None.
-
---*/
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-PAGED
-VOID
-MPDevicePnpEventNotify(
- _In_ NDIS_HANDLE /* MiniportAdapterContext */,
- _In_ PNET_DEVICE_PNP_EVENT NetDevicePnPEvent
- )
-/*++
-
-Routine Description:
-
- Runs at IRQL = PASSIVE_LEVEL in the context of system thread.
-
-Arguments:
-
- MiniportAdapterContext Pointer to our adapter
- NetDevicePnPEvent Self-explanatory
-
-Return Value:
-
- None.
-
---*/
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- switch (NetDevicePnPEvent->DevicePnPEvent)
- {
- case NdisDevicePnPEventQueryRemoved:
- //
- // Called when NDIS receives IRP_MN_QUERY_REMOVE_DEVICE.
- //
- LogInfo(DRIVER_DEFAULT, "MPPnPEventNotify: NdisDevicePnPEventQueryRemoved");
- break;
-
- case NdisDevicePnPEventRemoved:
- //
- // Called when NDIS receives IRP_MN_REMOVE_DEVICE.
- // NDIS calls MiniportHalt function after this call returns.
- //
- LogInfo(DRIVER_DEFAULT, "MPPnPEventNotify: NdisDevicePnPEventRemoved");
- break;
-
- case NdisDevicePnPEventSurpriseRemoved:
- //
- // Called when NDIS receives IRP_MN_SUPRISE_REMOVAL.
- // NDIS calls MiniportHalt function after this call returns.
- //
- LogInfo(DRIVER_DEFAULT, "MPDevicePnpEventNotify: NdisDevicePnPEventSurpriseRemoved");
- break;
-
- case NdisDevicePnPEventQueryStopped:
- //
- // Called when NDIS receives IRP_MN_QUERY_STOP_DEVICE. ??
- //
- LogInfo(DRIVER_DEFAULT, "MPPnPEventNotify: NdisDevicePnPEventQueryStopped");
- break;
-
- case NdisDevicePnPEventStopped:
- //
- // Called when NDIS receives IRP_MN_STOP_DEVICE.
- // NDIS calls MiniportHalt function after this call returns.
- //
- //
- LogInfo(DRIVER_DEFAULT, "MPPnPEventNotify: NdisDevicePnPEventStopped");
- break;
-
- case NdisDevicePnPEventPowerProfileChanged:
- //
- // After initializing a miniport driver and after miniport driver
- // receives an OID_PNP_SET_POWER notification that specifies
- // a device power state of NdisDeviceStateD0 (the powered-on state),
- // NDIS calls the miniport's MiniportPnPEventNotify function with
- // PnPEvent set to NdisDevicePnPEventPowerProfileChanged.
- //
- LogInfo(DRIVER_DEFAULT, "MPDevicePnpEventNotify: NdisDevicePnPEventPowerProfileChanged");
-
- if (NetDevicePnPEvent->InformationBufferLength == sizeof( ULONG ))
- {
- const ULONG NdisPowerProfile = *((const ULONG *)NetDevicePnPEvent->InformationBuffer);
-
- if (NdisPowerProfile == NdisPowerProfileBattery)
- {
- LogInfo(DRIVER_DEFAULT, "The host system is running on battery power");
- }
- else if (NdisPowerProfile == NdisPowerProfileAcOnLine)
- {
- LogInfo(DRIVER_DEFAULT, "The host system is running on AC power");
- }
- }
- break;
-
- default:
- LogError(DRIVER_DEFAULT, "MPDevicePnpEventNotify: unknown PnP event 0x%x\n", NetDevicePnPEvent->DevicePnPEvent);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
diff --git a/examples/drivers/windows/ottmp/device.hpp b/examples/drivers/windows/ottmp/device.hpp
deleted file mode 100644
index cca9ef260..000000000
--- a/examples/drivers/windows/ottmp/device.hpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * Header file for the routines related to WDFDEVICE representing the
- * Network Adapter
- */
-
-#pragma once
-
-#define OTTMP_DEVICE_CONTEXT_SIGNATURE 'veDt'
-typedef struct _OTTMP_DEVICE_CONTEXT {
- //
- // Signature for Sanity Check.
- //
- ULONG Signature;
-
- //
- // Handle to the WDFDEVICE of which this is the context
- //
- WDFDEVICE Device;
-
- //
- // Pointer to the Context of the corresponding NETADAPTER object
- //
- POTTMP_ADAPTER_CONTEXT AdapterContext;
-
-} OTTMP_DEVICE_CONTEXT, *POTTMP_DEVICE_CONTEXT;
-
-WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(OTTMP_DEVICE_CONTEXT, GetDeviceContext);
-
-extern "C" {
-#ifdef OTTMP_LEGACY
-PAGED MINIPORT_INITIALIZE MPInitializeEx;
-PAGED MINIPORT_HALT MPHaltEx;
-MINIPORT_SHUTDOWN MPShutdownEx;
-PAGED MINIPORT_DEVICE_PNP_EVENT_NOTIFY MPDevicePnpEventNotify;
-#else
-PAGED EVT_WDF_DRIVER_DEVICE_ADD EvtDriverDeviceAdd;
-PAGED EVT_WDF_DEVICE_D0_EXIT EvtDeviceD0Exit;
-PAGED EVT_WDF_DEVICE_PREPARE_HARDWARE EvtDevicePrepareHardware;
-PAGED EVT_WDF_DEVICE_RELEASE_HARDWARE EvtDeviceReleaseHardware;
-PAGED EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT EvtDeviceSelfManagedIoInit;
-PAGED EVT_WDF_DEVICE_SELF_MANAGED_IO_CLEANUP EvtDeviceSelfManagedIoCleanup;
-EVT_WDF_DEVICE_D0_ENTRY EvtDeviceD0Entry;
-#endif
-}
diff --git a/examples/drivers/windows/ottmp/driver.cpp b/examples/drivers/windows/ottmp/driver.cpp
deleted file mode 100644
index 348df824d..000000000
--- a/examples/drivers/windows/ottmp/driver.cpp
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * This module has code to deal with loading and unloading of the driver
- */
-
-#include "pch.hpp"
-#include "driver.tmh"
-
-#ifdef OTTMP_LEGACY
-static GLOBALS GlobalData = { 0 };
-#endif
-
-INITCODE
-extern "C"
-NTSTATUS
-DriverEntry (
- _In_ PDRIVER_OBJECT DriverObject,
- _In_ PUNICODE_STRING RegistryPath
- )
-/*++
-
-Routine Description:
- DriverEntry initializes the driver and is the first routine called by the
- system after the driver is loaded. DriverEntry specifies the other entry
- points in the function driver, such as EvtDevice and DriverUnload.
-
-Parameters Description:
-
- DriverObject - represents the instance of the function driver that is loaded
- into memory. DriverEntry must initialize members of DriverObject before it
- returns to the caller. DriverObject is allocated by the system before the
- driver is loaded, and it is released by the system after the system unloads
- the function driver from memory.
-
- RegistryPath - represents the driver specific path in the Registry.
- The function driver can use the path to store driver related data between
- reboots. The path does not store hardware instance specific data.
-
-Return Value:
-
- A success status as determined by NT_SUCCESS macro, if successful.
-
---*/
-{
- NTSTATUS status;
- WDF_DRIVER_CONFIG config;
-#ifdef OTTMP_LEGACY
- NDIS_STATUS ndisStatus = NDIS_STATUS_FAILURE;
- NDIS_MINIPORT_DRIVER_CHARACTERISTICS MPChar = { 0 };
- NET_BUFFER_LIST_POOL_PARAMETERS NblParams = { 0 };
- NET_BUFFER_POOL_PARAMETERS NbParams = { 0 };
-#endif
-
- WPP_INIT_TRACING(DriverObject, RegistryPath);
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- //
- // Create the WdfDriver Object
- //
- WDF_DRIVER_CONFIG_INIT(&config, WDF_NO_EVENT_CALLBACK);
-
-#ifdef OTTMP_LEGACY
- //
- // Set WdfDriverInitNoDispatchOverride flag to tell the framework
- // not to provide dispatch routines for the driver. In other words,
- // the framework must not intercept IRPs that the I/O manager has
- // directed to the driver. In this case, it will be handled by NDIS
- // port driver.
- //
- config.DriverInitFlags |= WdfDriverInitNoDispatchOverride;
-#else
- config.EvtDriverDeviceAdd = EvtDriverDeviceAdd;
- config.EvtDriverUnload = EvtDriverUnload;
-#endif
-
- status = WdfDriverCreate(DriverObject,
- RegistryPath,
- WDF_NO_OBJECT_ATTRIBUTES,
- &config,
-#ifdef OTTMP_LEGACY
- &GlobalData.WdfDriver
-#else
- NULL
-#endif
- );
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "WdfDriverCreate failed, %!STATUS!", status);
- goto error;
- }
-
-#ifdef OTTMP_LEGACY
- MPChar.Header.Type = NDIS_OBJECT_TYPE_MINIPORT_DRIVER_CHARACTERISTICS;
- MPChar.Header.Revision = NDIS_MINIPORT_DRIVER_CHARACTERISTICS_REVISION_2;
- MPChar.Header.Size = NDIS_SIZEOF_MINIPORT_DRIVER_CHARACTERISTICS_REVISION_2;
-
- // Version Suff
- MPChar.MajorNdisVersion = NDIS_MINIPORT_MAJOR_VERSION;
- MPChar.MinorNdisVersion = NDIS_MINIPORT_MINOR_VERSION;
- MPChar.MajorDriverVersion = NIC_VENDOR_DRIVER_VERSION_MAJOR;
- MPChar.MinorDriverVersion = NIC_VENDOR_DRIVER_VERSION_MINOR;
-
- MPChar.InitializeHandlerEx = MPInitializeEx;
- MPChar.HaltHandlerEx = MPHaltEx;
- MPChar.UnloadHandler = MPDriverUnload;
- MPChar.PauseHandler = MPPause;
- MPChar.RestartHandler = MPRestart;
- MPChar.OidRequestHandler = MPOidRequest;
- MPChar.SendNetBufferListsHandler = MPSendNetBufferLists;
- MPChar.ReturnNetBufferListsHandler = MPReturnNetBufferLists;
- MPChar.CancelSendHandler = MPCancelSend;
- MPChar.DevicePnPEventNotifyHandler = MPDevicePnpEventNotify;
- MPChar.ShutdownHandlerEx = MPShutdownEx;
- MPChar.CancelOidRequestHandler = MPCancelOidRequest;
-
- ndisStatus = NdisMRegisterMiniportDriver(DriverObject,
- RegistryPath,
- &GlobalData,
- &MPChar,
- &GlobalData.hDriver);
- if (ndisStatus != NDIS_STATUS_SUCCESS)
- {
- LogError(DRIVER_DEFAULT, "NdisMRegisterMiniportDriver failed %!NDIS_STATUS!", ndisStatus);
- status = STATUS_UNSUCCESSFUL;
- goto error;
- }
-
- NblParams.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
- NblParams.Header.Revision = NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1;
- NblParams.Header.Size = NDIS_SIZEOF_NET_BUFFER_LIST_POOL_PARAMETERS_REVISION_1;
- NblParams.PoolTag = NIC_TAG_RECV_NBL;
- GlobalData.hNblPool = NdisAllocateNetBufferListPool(GlobalData.hDriver, &NblParams);
- if (GlobalData.hNblPool == 0)
- {
- LogError(DRIVER_DEFAULT, "NdisAllocateNetBufferListPool failed");
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto error;
- }
-
- NbParams.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
- NbParams.Header.Revision = NET_BUFFER_POOL_PARAMETERS_REVISION_1;
- NbParams.Header.Size = NDIS_SIZEOF_NET_BUFFER_POOL_PARAMETERS_REVISION_1;
- NbParams.PoolTag = NIC_TAG_RECV_NBL;
- NbParams.DataSize = MAX_SPINEL_COMMAND_LENGTH;
- GlobalData.hNbPool = NdisAllocateNetBufferPool(GlobalData.hDriver, &NbParams);
- if (GlobalData.hNbPool == 0)
- {
- LogError(DRIVER_DEFAULT, "NdisAllocateNetBufferListPool failed");
- status = STATUS_INSUFFICIENT_RESOURCES;
- goto error;
- }
-#endif
-
-error:
-
- if (!NT_SUCCESS(status))
- {
-#ifdef OTTMP_LEGACY
- MPDriverUnload(DriverObject);
-#else
- WPP_CLEANUP(DriverObject);
-#endif
- }
-
- LogFuncExitNT(DRIVER_DEFAULT, status);
- return status;
-}
-
-#ifdef OTTMP_LEGACY
-
-PAGED
-_Use_decl_annotations_
-VOID
-MPDriverUnload(
- _In_ PDRIVER_OBJECT DriverObject
- )
-/*++
-Routine Description:
-
- MPDriverUnload will clean up the WPP resources that was allocated
- for this driver.
-
-Arguments:
-
- DriverObject - Handle to a framework driver object created in DriverEntry
-
---*/
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- if (GlobalData.WdfDriver)
- {
- NT_ASSERT(GlobalData.WdfDriver == WdfGetDriver());
- WdfDriverMiniportUnload(GlobalData.WdfDriver);
- GlobalData.WdfDriver = nullptr;
- }
-
- if (GlobalData.hNblPool)
- {
- NdisFreeNetBufferListPool(GlobalData.hNblPool);
- GlobalData.hNblPool = nullptr;
- }
-
- if (GlobalData.hDriver)
- {
- NdisMDeregisterMiniportDriver(GlobalData.hDriver);
- GlobalData.hDriver = nullptr;
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-
-#pragma warning(suppress: 25024) // Dangerous cast
- WPP_CLEANUP(DriverObject);
-}
-
-#else
-
-PAGED
-VOID
-EvtDriverUnload(
- WDFDRIVER Driver
- )
-/*++
-Routine Description:
-
- EvtDriverUnload will clean up the WPP resources that was allocated
- for this driver.
-
-Arguments:
-
- Driver - Handle to a framework driver object created in DriverEntry
-
---*/
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- LogFuncExit(DRIVER_DEFAULT);
- WPP_CLEANUP(WdfDriverWdmGetDriverObject(Driver));
-}
-
-#endif
diff --git a/examples/drivers/windows/ottmp/driver.hpp b/examples/drivers/windows/ottmp/driver.hpp
deleted file mode 100644
index f63e6ad4e..000000000
--- a/examples/drivers/windows/ottmp/driver.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * Header file for the Driver Load / Unload routines
- */
-
-#pragma once
-
-extern "C" {
-DRIVER_INITIALIZE DriverEntry;
-}
-
-#ifdef OTTMP_LEGACY
-PAGED MINIPORT_UNLOAD MPDriverUnload;
-
-typedef struct _GLOBALS
-{
- WDFDRIVER WdfDriver;
- NDIS_HANDLE hDriver;
- NDIS_HANDLE hNblPool;
- NDIS_HANDLE hNbPool;
-} GLOBALS, *PGLOBALS;
-#else
-PAGED EVT_WDF_DRIVER_UNLOAD EvtDriverUnload;
-#endif
-
-//
-// Own Version
-//
-#define NIC_VENDOR_DRIVER_VERSION_MAJOR 1
-#define NIC_VENDOR_DRIVER_VERSION_MINOR 0
-#define NIC_VENDOR_DRIVER_VERSION ((NIC_VENDOR_DRIVER_VERSION_MAJOR << 16) | NIC_VENDOR_DRIVER_VERSION_MINOR)
diff --git a/examples/drivers/windows/ottmp/hardware.hpp b/examples/drivers/windows/ottmp/hardware.hpp
deleted file mode 100644
index bedf3d470..000000000
--- a/examples/drivers/windows/ottmp/hardware.hpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * This module defines constants that describe physical characteristics and
- * limits of the underlying hardware.
- */
-
-#pragma once
-
-#ifndef IF_TYPE_IEEE802154
-#define IF_TYPE_IEEE802154 259 // IEEE 802.15.4 WPAN interface
-#define NdisPhysicalMediumNative802_15_4 (NDIS_PHYSICAL_MEDIUM)20
-#endif
-
-//
-// Link layer addressing
-// -----------------------------------------------------------------------------
-//
-
-// Number of bytes in a hardware address. 802.15.4 uses 8 byte addresses.
-#define NIC_MACADDR_SIZE 8
-
-//
-// Frames
-// -----------------------------------------------------------------------------
-//
-
-#define HW_MAX_FRAME_SIZE 1280
-
-//
-// Medium properties
-// -----------------------------------------------------------------------------
-//
-
-#define NIC_MEDIUM_TYPE NdisMediumIP
-
-// Claim to be 250kbps duplex
-#define KILOBITS_PER_SECOND 1000ULL
-#define MEGABITS_PER_SECOND 1000000ULL
-#define NIC_RECV_XMIT_SPEED (250ULL*KILOBITS_PER_SECOND)
-
-//
-// Hardware limits
-// -----------------------------------------------------------------------------
-//
-
-// Max number of multicast addresses supported in hardware
-#define NIC_MAX_MCAST_LIST 32
-
-// Maximum number of uncompleted sends that a single adapter will permit
-#define NIC_MAX_BUSY_SENDS 1024
-
-// Maximum number of received packets that can be in the OS at any time
-// (Also known as the receive pool size)
-#define NIC_MAX_OUTSTANDING_RECEIVES 32
-
-
-//
-// Physical adapter properties
-// -----------------------------------------------------------------------------
-//
-
-// Change to your company name instead of using OpenThread
-#define NIC_VENDOR_DESC "OpenThread"
-
-// Highest byte is the NIC byte plus three vendor bytes. This is normally
-// obtained from the NIC.
-#define NIC_VENDOR_ID 0x00FFFFFF
-
-#ifdef OTTMP_LEGACY
-#define NIC_SUPPORTED_FILTERS ( \
- NDIS_PACKET_TYPE_DIRECTED | \
- NDIS_PACKET_TYPE_MULTICAST | \
- NDIS_PACKET_TYPE_BROADCAST | \
- NDIS_PACKET_TYPE_PROMISCUOUS | \
- NDIS_PACKET_TYPE_ALL_MULTICAST)
-#else
-#define NIC_SUPPORTED_FILTERS (NET_PACKET_FILTER_TYPES_FLAGS) ( \
- NET_PACKET_FILTER_TYPE_DIRECTED | \
- NET_PACKET_FILTER_TYPE_MULTICAST | \
- NET_PACKET_FILTER_TYPE_BROADCAST | \
- NET_PACKET_FILTER_TYPE_PROMISCUOUS | \
- NET_PACKET_FILTER_TYPE_ALL_MULTICAST)
-#endif
-
-//
-// Specify a bitmask that defines optional properties of the NIC.
-// This miniport indicates receive with NdisMIndicateReceiveNetBufferLists
-// function. Such a driver should set this NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
-// flag.
-//
-// NDIS_MAC_OPTION_NO_LOOPBACK tells NDIS that NIC has no internal
-// loopback support so NDIS will manage loopbacks on behalf of
-// this driver.
-//
-// NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA tells the protocol that
-// our receive buffer is not on a device-specific card. If
-// NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA is not set, multi-buffer
-// indications are copied to a single flat buffer.
-//
-#define NIC_MAC_OPTIONS (\
- NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA | \
- NDIS_MAC_OPTION_TRANSFERS_NOT_PEND | \
- NDIS_MAC_OPTION_NO_LOOPBACK | \
- NDIS_MAC_OPTION_8021P_PRIORITY | \
- NDIS_MAC_OPTION_8021Q_VLAN)
-
-// NDIS 6.x miniports must support all counters in OID_GEN_STATISTICS.
-#define NIC_SUPPORTED_STATISTICS (\
- NDIS_STATISTICS_FLAGS_VALID_DIRECTED_FRAMES_RCV | \
- NDIS_STATISTICS_FLAGS_VALID_MULTICAST_FRAMES_RCV | \
- NDIS_STATISTICS_FLAGS_VALID_BROADCAST_FRAMES_RCV | \
- NDIS_STATISTICS_FLAGS_VALID_BYTES_RCV | \
- NDIS_STATISTICS_FLAGS_VALID_RCV_DISCARDS | \
- NDIS_STATISTICS_FLAGS_VALID_RCV_ERROR | \
- NDIS_STATISTICS_FLAGS_VALID_DIRECTED_FRAMES_XMIT | \
- NDIS_STATISTICS_FLAGS_VALID_MULTICAST_FRAMES_XMIT | \
- NDIS_STATISTICS_FLAGS_VALID_BROADCAST_FRAMES_XMIT | \
- NDIS_STATISTICS_FLAGS_VALID_BYTES_XMIT | \
- NDIS_STATISTICS_FLAGS_VALID_XMIT_ERROR | \
- NDIS_STATISTICS_FLAGS_VALID_XMIT_DISCARDS | \
- NDIS_STATISTICS_FLAGS_VALID_DIRECTED_BYTES_RCV | \
- NDIS_STATISTICS_FLAGS_VALID_MULTICAST_BYTES_RCV | \
- NDIS_STATISTICS_FLAGS_VALID_BROADCAST_BYTES_RCV | \
- NDIS_STATISTICS_FLAGS_VALID_DIRECTED_BYTES_XMIT | \
- NDIS_STATISTICS_FLAGS_VALID_MULTICAST_BYTES_XMIT | \
- NDIS_STATISTICS_FLAGS_VALID_BROADCAST_BYTES_XMIT)
diff --git a/examples/drivers/windows/ottmp/hdlc.cpp b/examples/drivers/windows/ottmp/hdlc.cpp
deleted file mode 100644
index 89dc90702..000000000
--- a/examples/drivers/windows/ottmp/hdlc.cpp
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * This file implements an HDLC-lite encoder and decoder.
- */
-
-#include "pch.hpp"
-#include "hdlc.tmh"
-
-/**
- * FCS lookup table
- */
-enum
-{
- kInitFcs = 0xffff, ///< Initial FCS value.
- kGoodFcs = 0xf0b8, ///< Good FCS value.
-};
-
-static bool
-hdlc_byte_needs_escape(UCHAR byte)
-{
- switch (byte)
- {
- case HdlcXOn:
- case HdlcXOff:
- case HdlcEscapeSequence:
- case HdlcFlagSequence:
- case HdlcSpecial:
- return true;
-
- default:
- return false;
- }
-}
-
-/**
- * This method updates an FCS.
- *
- * @param[in] aFcs The FCS to update.
- * @param[in] aByte The input byte value.
- *
- * @returns The updated FCS.
- */
-USHORT UpdateFcs(USHORT aFcs, UCHAR aByte)
-{
- const USHORT sFcsTable[256] =
- {
- 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
- 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
- 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
- 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
- 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
- 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
- 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
- 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
- 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
- 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
- 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
- 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
- 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
- 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
- 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
- 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
- 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
- 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
- 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
- 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
- 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
- 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
- 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
- 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
- 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
- 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
- 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
- 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
- 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
- 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
- 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
- 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
- };
- return (aFcs >> 8) ^ sFcsTable[(aFcs ^ aByte) & 0xff];
-}
-
-ULONG
-HdlcComputeEncodedByteLength(
- _In_ UCHAR aByte
- )
-{
- return hdlc_byte_needs_escape(aByte) ? 2 : 1;
-}
-
-ULONG
-HdlcComputeEncodedLength(
- _In_reads_bytes_(DecodedBufferLength)
- PUCHAR DecodedBuffer,
- _In_ ULONG DecodedBufferLength
- )
-{
- USHORT Fcs = kInitFcs;
- ULONG Length = 2; // Start and end sequence
-
- for (ULONG i = 0; i < DecodedBufferLength; i++)
- {
- Length += HdlcComputeEncodedByteLength(DecodedBuffer[i]);
- Fcs = UpdateFcs(Fcs, DecodedBuffer[i]);
- }
-
- Fcs ^= 0xffff;
-
- Length += HdlcComputeEncodedByteLength(Fcs & 0xff);
- Length += HdlcComputeEncodedByteLength(Fcs >> 8);
-
- return Length;
-}
-
-bool
-HdlcEncodeByte(
- _In_ UCHAR aByte,
- _Inout_ ULONG& Offset,
- _In_ ULONG EncodedBufferLength,
- _Out_writes_bytes_(EncodedBufferLength)
- PUCHAR EncodedBuffer
- )
-{
- if (hdlc_byte_needs_escape(aByte))
- {
- if (Offset + 2 > EncodedBufferLength) return false;
-
- EncodedBuffer[Offset++] = HdlcEscapeSequence;
- EncodedBuffer[Offset++] = (aByte ^ 0x20);
- }
- else
- {
- if (Offset + 1 > EncodedBufferLength) return false;
-
- EncodedBuffer[Offset++] = aByte;
- }
-
- return true;
-}
-
-_Success_(return == true)
-bool
-HdlcEncodeBuffer(
- _In_reads_bytes_(DecodedBufferLength)
- PUCHAR DecodedBuffer,
- _In_ ULONG DecodedBufferLength,
- _Out_writes_bytes_(EncodedBufferLength)
- PUCHAR EncodedBuffer,
- _In_ ULONG EncodedBufferLength
- )
-{
- USHORT Fcs = kInitFcs;
- ULONG Offset = 0;
- bool Complete = false;
-
- if (Offset + 1 > EncodedBufferLength) goto error;
- EncodedBuffer[Offset++] = HdlcFlagSequence;
-
- for (ULONG i = 0; i < DecodedBufferLength; i++)
- {
- UCHAR aByte = DecodedBuffer[i];
-
- if (!HdlcEncodeByte(aByte, Offset, EncodedBufferLength, EncodedBuffer)) {
- goto error;
- }
-
- Fcs = UpdateFcs(Fcs, aByte);
- }
-
- Fcs ^= 0xffff;
-
- if (!HdlcEncodeByte(Fcs & 0xff, Offset, EncodedBufferLength, EncodedBuffer) ||
- !HdlcEncodeByte(Fcs >> 8, Offset, EncodedBufferLength, EncodedBuffer)) {
- goto error;
- }
-
- if (Offset + 1 > EncodedBufferLength) goto error;
- EncodedBuffer[Offset++] = HdlcFlagSequence;
-
- NT_ASSERT(Offset == EncodedBufferLength);
- Complete = true;
-
-error:
-
- return Complete;
-}
-
-enum HdlcDecodeState
-{
- kStateNoSync = 0,
- kStateSync,
- kStateEscaped,
-};
-
-_Success_(return == true)
-bool
-HdlcDecodeBuffer(
- _In_reads_bytes_(*EncodedBufferLength)
- PUCHAR EncodedBuffer,
- _Inout_ PULONG EncodedBufferLength,
- _Inout_ PULONG DecodedBufferLength,
- _Out_writes_bytes_opt_(*DecodedBufferLength)
- PUCHAR DecodedBuffer,
- _Out_ bool* IsGood
- )
-{
- UCHAR byte;
- HdlcDecodeState state = kStateNoSync;
- ULONG DecodedLength = 0;
- USHORT Fcs = kInitFcs;
-
- for (ULONG i = 0; i < *EncodedBufferLength; i++)
- {
- byte = EncodedBuffer[i];
-
- switch (state)
- {
- case kStateNoSync:
- {
- if (byte == HdlcFlagSequence)
- {
- if (i != 0)
- {
- // Set the output for junk length
- *EncodedBufferLength = i;
-
- // Set the output 'IsGood' flag based on FCS
- *IsGood = false;
-
- return true;
- }
- else
- {
- state = kStateSync;
- }
- }
- break;
- }
- case kStateSync:
- {
- switch (byte)
- {
- case HdlcEscapeSequence:
- {
- state = kStateEscaped;
- break;
- }
- case HdlcFlagSequence:
- {
- // If it wasn't enough buffer to be a complete sequence, maybe we are
- // actually between sequences. Leave the trailing escape character.
- if (i < sizeof(USHORT) + 2)
- {
- // Set the output encoded buffer length
- *EncodedBufferLength = i;
-
- *IsGood = false;
- }
- else
- {
- // Set the output encoded buffer length
- *EncodedBufferLength = i + 1;
-
- // Set the decoded buffer length (subtract 2 for the FCS)
- *DecodedBufferLength = DecodedLength - 2;
-
- // Set the output 'IsGood' flag based on FCS
- *IsGood = (Fcs == kGoodFcs);
- }
-
- return true;
- }
- default:
- {
- Fcs = UpdateFcs(Fcs, byte);
- DecodedLength++;
- if (DecodedBuffer)
- {
- if (*DecodedBufferLength >= DecodedLength)
- {
- DecodedBuffer[DecodedLength - 1] = byte;
- }
- }
- break;
- }
- }
- break;
- }
- case kStateEscaped:
- {
- if (i + 1 < *EncodedBufferLength)
- {
- byte ^= 0x20;
- Fcs = UpdateFcs(Fcs, byte);
- DecodedLength++;
- if (DecodedBuffer)
- {
- if (*DecodedBufferLength >= DecodedLength)
- {
- DecodedBuffer[DecodedLength - 1] = byte;
- }
- }
-
- state = kStateSync;
- }
- else
- {
- // Not enough buffer
- }
- break;
- }
- }
- }
-
- return false;
-}
diff --git a/examples/drivers/windows/ottmp/hdlc.hpp b/examples/drivers/windows/ottmp/hdlc.hpp
deleted file mode 100644
index cb73394d6..000000000
--- a/examples/drivers/windows/ottmp/hdlc.hpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * This file includes definitions for an HDLC-lite encoder and decoder.
- */
-
-#pragma once
-
-enum
-{
- HdlcXOn = 0x11,
- HdlcXOff = 0x13,
- HdlcFlagSequence = 0x7e, ///< HDLC Flag value
- HdlcEscapeSequence = 0x7d, ///< HDLC Escape value
- HdlcSpecial = 0xF8
-};
-
-ULONG
-HdlcComputeEncodedLength(
- _In_reads_bytes_(DecodedBufferLength)
- PUCHAR DecodedBuffer,
- _In_ ULONG DecodedBufferLength
- );
-
-_Success_(return == true)
-bool
-HdlcEncodeBuffer(
- _In_reads_bytes_(DecodedBufferLength)
- PUCHAR DecodedBuffer,
- _In_ ULONG DecodedBufferLength,
- _Out_writes_bytes_(EncodedBufferLength)
- PUCHAR EncodedBuffer,
- _In_ ULONG EncodedBufferLength
- );
-
-_Success_(return == true)
-bool
-HdlcDecodeBuffer(
- _In_reads_bytes_(*EncodedBufferLength)
- PUCHAR EncodedBuffer,
- _Inout_ PULONG EncodedBufferLength,
- _Inout_ PULONG DecodedBufferLength,
- _Out_writes_bytes_opt_(*DecodedBufferLength)
- PUCHAR DecodedBuffer,
- _Out_ bool* IsGood
- );
diff --git a/examples/drivers/windows/ottmp/oid.cpp b/examples/drivers/windows/ottmp/oid.cpp
deleted file mode 100644
index 4e34c9a52..000000000
--- a/examples/drivers/windows/ottmp/oid.cpp
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.hpp"
-#include "oid.tmh"
-
-template
-PAGED NDIS_STATUS RequestQuery( _In_ PNDIS_OID_REQUEST OidRequest, const _Datum & value );
-
-#define VERIFY_NDIS_OBJECT_HEADER(_header, _type, _revision, _size) \
- (((_header).Type == _type) && \
- ((_header).Revision >= _revision) && \
- ((_header).Size >= _size))
-
-#define VERIFY_NDIS_OBJECT_HEADER_PTR(_header, _type, _revision, _size) \
- (((_header)->Type == _type) && \
- ((_header)->Revision >= _revision) && \
- ((_header)->Size >= _size))
-
-#define VERIFY_NDIS_REQUEST_OBJECT_HEADER(_buffer, _type, _revision, _size) \
- VERIFY_NDIS_OBJECT_HEADER_PTR(reinterpret_cast(_buffer), _type, _revision, _size)
-
-#define ASSIGN_NDIS_OBJECT_HEADER(_header, _type, _revision, _size) \
- (_header).Type = _type; \
- (_header).Revision = _revision; \
- (_header).Size = _size;
-
-#define ASSIGN_NDIS_OBJECT_HEADER_PTR(_header, _type, _revision, _size) \
- (_header)->Type = _type; \
- (_header)->Revision = _revision; \
- (_header)->Size = _size;
-
-//
-// List of Supported OIDs.
-//
-NDIS_OID NICSupportedOids[] =
-{
- // General
- OID_GEN_CURRENT_LOOKAHEAD,
- OID_GEN_CURRENT_PACKET_FILTER,
- OID_GEN_INTERRUPT_MODERATION,
- OID_GEN_LINK_PARAMETERS, // TODO: Mandatory Set
- OID_GEN_MAXIMUM_TOTAL_SIZE,
- OID_GEN_RCV_OK,
- OID_GEN_RECEIVE_BLOCK_SIZE,
- OID_GEN_RECEIVE_BUFFER_SPACE,
- OID_GEN_STATISTICS,
- OID_GEN_TRANSMIT_BLOCK_SIZE,
- OID_GEN_TRANSMIT_BUFFER_SPACE,
- OID_GEN_VENDOR_DRIVER_VERSION,
- OID_GEN_VENDOR_DESCRIPTION,
- OID_GEN_VENDOR_ID,
- OID_GEN_XMIT_OK,
- OID_GEN_LINK_PARAMETERS, // TODO: Mandatory Set
-
- // 802.3 Specific
- OID_802_3_CURRENT_ADDRESS,
- OID_802_3_PERMANENT_ADDRESS,
- OID_802_3_MULTICAST_LIST,
- OID_802_3_MAXIMUM_LIST_SIZE,
- OID_802_3_RCV_ERROR_ALIGNMENT,
- OID_802_3_XMIT_ONE_COLLISION,
- OID_802_3_XMIT_MORE_COLLISIONS,
-
- // PnP Stuff
- OID_PNP_CAPABILITIES, // Optional
- OID_PNP_QUERY_POWER, // Optional
-
- // OpenThread Stuff
- OID_OT_CAPABILITIES,
-};
-
-const ULONG SizeOfNICSupportedOids = sizeof(NICSupportedOids);
-
-template
-PAGED
-NDIS_STATUS RequestQuery( _In_ PNDIS_OID_REQUEST OidRequest, const _Datum & value )
-{
- PAGED_CODE();
- NT_ASSERT( (OidRequest->RequestType == NdisRequestQueryInformation) ||
- (OidRequest->RequestType == NdisRequestQueryStatistics) );
-
- if (OidRequest->DATA.QUERY_INFORMATION.InformationBufferLength < sizeof( _Datum ))
- {
- OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = sizeof( _Datum );
- OidRequest->DATA.QUERY_INFORMATION.BytesWritten = 0;
- return NDIS_STATUS_INVALID_LENGTH;
- }
- else
- {
- OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = sizeof( _Datum );
- OidRequest->DATA.QUERY_INFORMATION.BytesWritten = sizeof( _Datum );
- _Datum * pData = reinterpret_cast<_Datum *>(OidRequest->DATA.QUERY_INFORMATION.InformationBuffer);
- *pData = value;
- return NDIS_STATUS_SUCCESS;
- }
-}
-
-PAGED
-NDIS_STATUS RequestQuery32or64( _In_ PNDIS_OID_REQUEST OidRequest, const ULONG64 value )
-{
- PAGED_CODE();
- NT_ASSERT( (OidRequest->RequestType == NdisRequestQueryInformation) ||
- (OidRequest->RequestType == NdisRequestQueryStatistics) );
-
- if (OidRequest->DATA.QUERY_INFORMATION.InformationBufferLength >= sizeof( ULONG64 ))
- {
- OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = sizeof( ULONG64 );
- OidRequest->DATA.QUERY_INFORMATION.BytesWritten = sizeof( ULONG64 );
- PULONG64 pData = reinterpret_cast(OidRequest->DATA.QUERY_INFORMATION.InformationBuffer);
- *pData = value;
- return NDIS_STATUS_SUCCESS;
- }
- else if (OidRequest->DATA.QUERY_INFORMATION.InformationBufferLength >= sizeof( ULONG ))
- {
- OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = sizeof( ULONG );
- OidRequest->DATA.QUERY_INFORMATION.BytesWritten = sizeof( ULONG );
- PULONG pData = reinterpret_cast(OidRequest->DATA.QUERY_INFORMATION.InformationBuffer);
- *pData = (ULONG)value;
- return NDIS_STATUS_SUCCESS;
- }
- else
- {
- OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = sizeof( ULONG64 );
- OidRequest->DATA.QUERY_INFORMATION.BytesWritten = 0;
- return NDIS_STATUS_INVALID_LENGTH;
- }
-}
-
-PAGED
-NDIS_STATUS RequestQueryThreadCapabilities(_In_ PNDIS_OID_REQUEST OidRequest)
-{
- PAGED_CODE();
-
- OT_CAPABILITIES caps = { 0 };
- ASSIGN_NDIS_OBJECT_HEADER(caps.Header, NDIS_OBJECT_TYPE_DEFAULT, OT_CAPABILITIES_REVISION_1, SIZEOF_OT_CAPABILITIES_REVISION_1);
- caps.MiniportMode = OT_MP_MODE_THREAD; // Thread Tunnel mode
-
- if (OidRequest->DATA.QUERY_INFORMATION.InformationBufferLength < SIZEOF_OT_CAPABILITIES_REVISION_1)
- {
- OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = SIZEOF_OT_CAPABILITIES_REVISION_1;
- OidRequest->DATA.QUERY_INFORMATION.BytesWritten = 0;
- return NDIS_STATUS_INVALID_LENGTH;
- }
- else
- {
- OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = SIZEOF_OT_CAPABILITIES_REVISION_1;
- OidRequest->DATA.QUERY_INFORMATION.BytesWritten = SIZEOF_OT_CAPABILITIES_REVISION_1;
- memcpy(OidRequest->DATA.QUERY_INFORMATION.InformationBuffer, &caps, SIZEOF_OT_CAPABILITIES_REVISION_1);
- return NDIS_STATUS_SUCCESS;
- }
-}
-
-PAGED
-NDIS_STATUS RequestQueryGenStatistics(_In_ PNDIS_OID_REQUEST OidRequest, _In_ POTTMP_ADAPTER_CONTEXT AdapterContext)
-{
- PAGED_CODE();
-
- NDIS_STATISTICS_INFO statistics = { 0 };
- ASSIGN_NDIS_OBJECT_HEADER(statistics.Header, NDIS_OBJECT_TYPE_DEFAULT, NDIS_SIZEOF_STATISTICS_INFO_REVISION_1, NDIS_STATISTICS_INFO_REVISION_1);
-
- statistics.SupportedStatistics = NIC_SUPPORTED_STATISTICS;
-
- /* Bytes in */
- statistics.ifHCInOctets = AdapterContext->BytesRxDirected +
- AdapterContext->BytesRxMulticast +
- AdapterContext->BytesRxBroadcast;
-
- statistics.ifHCInUcastOctets = AdapterContext->BytesRxDirected;
- statistics.ifHCInMulticastOctets = AdapterContext->BytesRxMulticast;
- statistics.ifHCInBroadcastOctets = AdapterContext->BytesRxBroadcast;
-
- /* Packets in */
- statistics.ifHCInUcastPkts = AdapterContext->FramesRxDirected;
- statistics.ifHCInMulticastPkts = AdapterContext->FramesRxMulticast;
- statistics.ifHCInBroadcastPkts = AdapterContext->FramesRxBroadcast;
-
- /* Errors in */
- statistics.ifInErrors = AdapterContext->RxCrcErrors +
- AdapterContext->RxAlignmentErrors +
- AdapterContext->RxDmaOverrunErrors +
- AdapterContext->RxRuntErrors;
-
- statistics.ifInDiscards = AdapterContext->RxResourceErrors;
-
- /* Bytes out */
- statistics.ifHCOutOctets = AdapterContext->BytesTxDirected +
- AdapterContext->BytesTxMulticast +
- AdapterContext->BytesTxBroadcast;
-
- statistics.ifHCOutUcastOctets = AdapterContext->BytesTxDirected;
- statistics.ifHCOutMulticastOctets = AdapterContext->BytesTxMulticast;
- statistics.ifHCOutBroadcastOctets = AdapterContext->BytesTxBroadcast;
-
- /* Packets out */
- statistics.ifHCOutUcastPkts = AdapterContext->FramesTxDirected;
- statistics.ifHCOutMulticastPkts = AdapterContext->FramesTxMulticast;
- statistics.ifHCOutBroadcastPkts = AdapterContext->FramesTxBroadcast;
-
- /* Errors out */
- statistics.ifOutErrors = AdapterContext->TxAbortExcessCollisions +
- AdapterContext->TxDmaUnderrun +
- AdapterContext->TxLostCRS +
- AdapterContext->TxLateCollisions+
- AdapterContext->TransmitFailuresOther;
-
- statistics.ifOutDiscards = 0ULL;
-
- return RequestQuery(OidRequest, statistics);
-}
-
-PAGED
-_Use_decl_annotations_
-NDIS_STATUS
-MPOidRequest(
- _In_ NDIS_HANDLE MiniportAdapterContext,
- _In_ PNDIS_OID_REQUEST OidRequest
- )
-{
- POTTMP_ADAPTER_CONTEXT AdapterContext = (POTTMP_ADAPTER_CONTEXT)MiniportAdapterContext;
- NDIS_STATUS status = NDIS_STATUS_NOT_SUPPORTED;
- bool fFailExpected = false;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- switch (OidRequest->RequestType)
- {
- case NdisRequestSetInformation:
- switch (OidRequest->DATA.QUERY_INFORMATION.Oid)
- {
- case OID_802_3_MULTICAST_LIST:
- // TODO: Check with Jeffrey how to better handle this
- status = NDIS_STATUS_MULTICAST_FULL;
- fFailExpected = true;
- break;
-
- //
- // Fake it until we make it :)
- // We can't bind unless we report success for these OIDs
- //
- case OID_GEN_CURRENT_PACKET_FILTER:
- case OID_PM_ADD_WOL_PATTERN:
- case OID_PM_REMOVE_WOL_PATTERN:
- case OID_GEN_CURRENT_LOOKAHEAD:
- // TODO: Implement this
- status = NDIS_STATUS_SUCCESS;
- break;
-
- // Explicitly not supported
- case OID_GEN_INTERRUPT_MODERATION:
- status = NDIS_STATUS_NOT_SUPPORTED;
- fFailExpected = true;
- break;
-
- // Unknown
- default:
- status = NDIS_STATUS_NOT_SUPPORTED;
- break;
- }
- break;
- case NdisRequestQueryInformation:
- case NdisRequestQueryStatistics:
- switch (OidRequest->DATA.QUERY_INFORMATION.Oid)
- {
- case OID_GEN_INTERRUPT_MODERATION:
- {
- static const NDIS_INTERRUPT_MODERATION_PARAMETERS nimp = {
- { NDIS_OBJECT_TYPE_DEFAULT, NDIS_INTERRUPT_MODERATION_PARAMETERS_REVISION_1, NDIS_SIZEOF_INTERRUPT_MODERATION_PARAMETERS_REVISION_1 },
- 0,
- NdisInterruptModerationNotSupported };
- status = RequestQuery( OidRequest, nimp );
- break;
- }
-
- case OID_GEN_RCV_OK:
- status = RequestQuery32or64( OidRequest, AdapterContext->FramesRxBroadcast
- + AdapterContext->FramesRxMulticast
- + AdapterContext->FramesRxDirected );
- break;
-
- case OID_GEN_MAXIMUM_TOTAL_SIZE:
- case OID_GEN_TRANSMIT_BLOCK_SIZE:
- case OID_GEN_RECEIVE_BLOCK_SIZE:
- status = RequestQuery( OidRequest, HW_MAX_FRAME_SIZE );
- break;
-
- case OID_GEN_RECEIVE_BUFFER_SPACE:
- status = RequestQuery( OidRequest, HW_MAX_FRAME_SIZE * AdapterContext->ulMaxBusyRecvs );
- break;
-
- case OID_GEN_STATISTICS:
- status = RequestQueryGenStatistics(OidRequest, AdapterContext);
- break;
-
- case OID_GEN_TRANSMIT_BUFFER_SPACE:
- status = RequestQuery( OidRequest, HW_MAX_FRAME_SIZE * AdapterContext->ulMaxBusySends );
- break;
-
- case OID_GEN_VENDOR_DESCRIPTION:
- case OID_GEN_VENDOR_DRIVER_VERSION:
- case OID_GEN_VENDOR_ID:
- if (OidRequest->DATA.QUERY_INFORMATION.InformationBufferLength < sizeof(NIC_VENDOR_DESC))
- {
- OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = sizeof( NIC_VENDOR_DESC );
- OidRequest->DATA.QUERY_INFORMATION.BytesWritten = 0;
- status = NDIS_STATUS_INVALID_LENGTH;
- }
- else
- {
- OidRequest->DATA.QUERY_INFORMATION.BytesNeeded = sizeof( NIC_VENDOR_DESC );
- OidRequest->DATA.QUERY_INFORMATION.BytesWritten = sizeof( NIC_VENDOR_DESC );
- memcpy(OidRequest->DATA.QUERY_INFORMATION.InformationBuffer, NIC_VENDOR_DESC, sizeof(NIC_VENDOR_DESC));
- status = NDIS_STATUS_SUCCESS;
- }
- break;
-
- case OID_GEN_XMIT_OK:
- status = RequestQuery32or64( OidRequest, AdapterContext->FramesTxBroadcast
- + AdapterContext->FramesTxMulticast
- + AdapterContext->FramesTxDirected );
- break;
-
- case OID_802_3_CURRENT_ADDRESS:
- status = RequestQuery( OidRequest, AdapterContext->ExtendedAddress );
- break;
-
- case OID_802_3_PERMANENT_ADDRESS:
- status = RequestQuery( OidRequest, AdapterContext->ExtendedAddress );
- break;
-
- case OID_PNP_CAPABILITIES:
- // We do not support low power
- status = NDIS_STATUS_NOT_SUPPORTED;
- fFailExpected = true;
- break;
-
- case OID_PNP_QUERY_POWER:
- status = NDIS_STATUS_NOT_ACCEPTED;
- fFailExpected = true;
- break;
-
- case OID_OT_CAPABILITIES:
- status = RequestQueryThreadCapabilities( OidRequest );
- break;
-
- default:
- status = NDIS_STATUS_NOT_SUPPORTED;
- break;
- }
- break;
- case NdisRequestMethod:
- break;
- default:
- status = NDIS_STATUS_INVALID_OID;
- break;
-
- }
- UNREFERENCED_PARAMETER( OidRequest );
-
- if (!fFailExpected && (status != NDIS_STATUS_SUCCESS))
- {
- LogFuncExitMsg(DRIVER_DEFAULT, " Type:%u Oid:%u Status:%!NDIS_STATUS!", OidRequest->RequestType, OidRequest->DATA.QUERY_INFORMATION.Oid, status);
- }
- else
- {
- // By not using LogFuncExitNDIS, this won't get auto-promoted to a warning on non-0 statuses
- LogFuncExitMsg(DRIVER_DEFAULT, " Type:%u Oid:%u Status:%!NDIS_STATUS!", OidRequest->RequestType, OidRequest->DATA.QUERY_INFORMATION.Oid, status);
- }
- return status;
-}
-
-_Use_decl_annotations_
-VOID
-MPCancelOidRequest(
- _In_ NDIS_HANDLE /* MiniportAdapterContext */,
- _In_ PVOID /* pRequestId */
-)
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- LogFuncExit(DRIVER_DEFAULT);
-}
diff --git a/examples/drivers/windows/ottmp/oid.hpp b/examples/drivers/windows/ottmp/oid.hpp
deleted file mode 100644
index 3c9b122dd..000000000
--- a/examples/drivers/windows/ottmp/oid.hpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-/**
- * @file
- * Header file for the routines related to OIDs
- */
-
-extern NDIS_OID NICSupportedOids[];
-extern const ULONG SizeOfNICSupportedOids;
-
-#ifdef OTTMP_LEGACY
-
-PAGED MINIPORT_OID_REQUEST MPOidRequest;
-MINIPORT_CANCEL_OID_REQUEST MPCancelOidRequest;
-
-#else
-
-EVT_NET_REQUEST_QUERY_DATA EvtQueryUlong;
-EVT_NET_REQUEST_QUERY_DATA EvtQueryGenVendorDescription;
-EVT_NET_REQUEST_QUERY_DATA EvtQueryAddress;
-EVT_NET_REQUEST_QUERY_DATA EvtQueryGenStatistics;
-EVT_NET_REQUEST_QUERY_DATA EvtQueryGenInterruptModeration;
-EVT_NET_REQUEST_QUERY_DATA EvtQueryGenXmitRcvOk;
-
-EVT_NET_REQUEST_QUERY_DATA EvtQueryThreadCapabilities;
-
-EVT_NET_REQUEST_DEFAULT_SET_DATA EvtDefaultSetData;
-
-NDIS_STATUS
-AdapterSetInformation(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ PNDIS_OID_REQUEST NdisSetRequest);
-
-NDIS_STATUS
-AdapterQueryInformation(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _Inout_ PNDIS_OID_REQUEST NdisQueryRequest
- );
-
-PAGED
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-AddDefaultRequestSequentialQueue(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- );
-
-
-#endif
diff --git a/examples/drivers/windows/ottmp/ottmp.inf b/examples/drivers/windows/ottmp/ottmp.inf
deleted file mode 100644
index 3a91afa9d..000000000
--- a/examples/drivers/windows/ottmp/ottmp.inf
+++ /dev/null
@@ -1,121 +0,0 @@
-;
-; Copyright (c) 2016, The OpenThread Authors.
-; 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 copyright holder 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 COPYRIGHT HOLDER 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.
-;
-
-[Version]
-Signature = "$Windows NT$"
-Class = Net
-ClassGUID = {4d36e972-e325-11ce-bfc1-08002be10318}
-Provider = %OpenThread%
-DriverVer =
-PnpLockDown = 1
-CatalogFile = ottmp.cat
-
-[Manufacturer]
-%OpenThread% = OpenThread,NT$ARCH$
-
-[OpenThread.NT$ARCH$]
-%ottmp.DeviceDesc% = ottmp.ndi, root\ottmp ; Root enumerated
-
-;-------------------------------------------------------------------------------
-; OpenThread Tunnel Thread Adapter
-;-------------------------------------------------------------------------------
-[ottmp.ndi]
-Characteristics = 0x4 ; NCF_PHYSICAL
-*IfType = 259 ; IF_TYPE_IEEE802154
-*MediaType = 19 ; NdisMediumIP
-*PhysicalMediaType = 20 ; NdisPhysicalMediumNative802_15_4
-*IfConnectorPresent = 0
-*AccessType = 2 ; NET_IF_ACCESS_BROADCAST
-*ConnectionType = 1 ; NET_IF_CONNECTION_PASSIVE
-*DirectionType = 0 ; NET_IF_DIRECTION_SENDRECEIVE
-AddReg = ottmp.Reg
-CopyFiles = ottmp.CopyFiles
-
-[ottmp.ndi.Services]
-AddService = ottmp, 2, ottmp.Service, ottmp.EventLog
-
-;-------------------------------------------------------------------------------
-; OpenThread Tunnel Miniport Common
-;-------------------------------------------------------------------------------
-[ottmp.Reg]
-HKR, , BusNumber, 0, "0"
-HKR, Ndi, Service, 0, "ottmp"
-HKR, Ndi\Interfaces, UpperRange, 0, "flpp6"
-HKR, Ndi\Interfaces, LowerRange, 0, "802.15.4"
-
-;-------------------------------------------------------------------------------
-; WDF Section
-;-------------------------------------------------------------------------------
-[ottmp.ndi.Wdf]
-KmdfService = ottmp, ottmp.wdfsect
-
-[ottmp.wdfsect]
-KmdfLibraryVersion = $KMDFVERSION$
-
-;-------------------------------------------------------------------------------
-; Driver and Service Section
-;-------------------------------------------------------------------------------
-[ottmp.CopyFiles]
-ottmp.sys,,,2
-
-[ottmp.Service]
-DisplayName = %ottmp.Service.DispName%
-ServiceType = 1 ;%SERVICE_KERNEL_DRIVER%
-StartType = 3 ;%SERVICE_DEMAND_START%
-ErrorControl = 1 ;%SERVICE_ERROR_NORMAL%
-ServiceBinary = %12%\ottmp.sys
-LoadOrderGroup = NDIS
-AddReg = TextModeFlags.Reg
-Description = %ottmp.DeviceDesc%
-
-[ottmp.EventLog]
-AddReg = ottmp.AddEventLog.Reg
-
-[ottmp.AddEventLog.Reg]
-HKR, , EventMessageFile, 0x00020000, "%%SystemRoot%%\System32\netevent.dll"
-HKR, , TypesSupported, 0x00010001, 7
-
-[TextModeFlags.Reg]
-HKR, , TextModeFlags, 0x00010001, 0x0001
-
-[SourceDisksNames]
-1 = %ottmp.DeviceDesc%,,,""
-
-[SourceDisksFiles]
-ottmp.sys = 1,,
-
-[DestinationDirs]
-ottmp.CopyFiles = 12
-
-;-------------------------------------------------------------------------------
-; Localizable Strings
-;-------------------------------------------------------------------------------
-[Strings]
-OpenThread = "OpenThread"
-ottmp.DeviceDesc = "OpenThread Tunnel Thread Adapter"
-ottmp.Service.DispName = "OpenThread Tunnel Miniport"
diff --git a/examples/drivers/windows/ottmp/ottmp.rc b/examples/drivers/windows/ottmp/ottmp.rc
deleted file mode 100644
index 26a7c387f..000000000
--- a/examples/drivers/windows/ottmp/ottmp.rc
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include
-#include
-
-/*-----------------------------------------------*/
-/* the following lines are specific to this file */
-/*-----------------------------------------------*/
-
-/* VER_FILETYPE, VER_FILESUBTYPE, VER_FILEDESCRIPTION_STR
- * and VER_INTERNALNAME_STR must be defined before including COMMON.VER
- * The strings don't need a '\0', since common.ver has them.
- */
-#define VER_FILETYPE VFT_DRV
-/* possible values: VFT_UNKNOWN
- VFT_APP
- VFT_DLL
- VFT_DRV
- VFT_FONT
- VFT_VXD
- VFT_STATIC_LIB
-*/
-#define VER_FILESUBTYPE VFT2_DRV_NETWORK
-/* possible values VFT2_UNKNOWN
- VFT2_DRV_PRINTER
- VFT2_DRV_KEYBOARD
- VFT2_DRV_LANGUAGE
- VFT2_DRV_DISPLAY
- VFT2_DRV_MOUSE
- VFT2_DRV_NETWORK
- VFT2_DRV_SYSTEM
- VFT2_DRV_INSTALLABLE
- VFT2_DRV_SOUND
- VFT2_DRV_COMM
-*/
-#define VER_FILEDESCRIPTION_STR "OpenThread Tunnel Miniport"
-#define VER_INTERNALNAME_STR "OTTMP.SYS"
-
-
-#include "common.ver" // NT5.0 version file.
-
diff --git a/examples/drivers/windows/ottmp/pch.hpp b/examples/drivers/windows/ottmp/pch.hpp
deleted file mode 100644
index 4c791670d..000000000
--- a/examples/drivers/windows/ottmp/pch.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-//
-// system headers
-//
-extern "C" {
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#ifndef OTTMP_LEGACY
-#include
-#endif
-#include
-#include
-#include
-}
-
-// Intellisense definition for DbgRaiseAssertionFailure because for some reason Visual Studio can't
-// find it.
-#ifdef __INTELLISENSE__
-#define DbgRaiseAssertionFailure() ((void) 0)
-#endif
-
-#include "otOID.h"
-
-#define CODE_SEG(seg) __declspec(code_seg(seg))
-#define INITCODE CODE_SEG("INIT")
-#define PAGED CODE_SEG("PAGE")
-
-typedef struct _OTTMP_ADAPTER_CONTEXT *POTTMP_ADAPTER_CONTEXT;
-typedef struct _OTTMP_DEVICE_CONTEXT *POTTMP_DEVICE_CONTEXT;
-
-#include "hardware.hpp"
-#include "hdlc.hpp"
-#include "driver.hpp"
-#include "adapter.hpp"
-#include "device.hpp"
-#include "serial.hpp"
-#include "oid.hpp"
-#include "openthread/platform/logging-windows.h"
diff --git a/examples/drivers/windows/ottmp/serial.cpp b/examples/drivers/windows/ottmp/serial.cpp
deleted file mode 100644
index ff85d7ea0..000000000
--- a/examples/drivers/windows/ottmp/serial.cpp
+++ /dev/null
@@ -1,1308 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "pch.hpp"
-#include "serial.tmh"
-
-PAGED
-_No_competing_thread_
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-SerialInitialize(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- )
-/*++
-Routine Description:
-
- SerialInitialize attempts to find and open the first COM port available, with
- the assumption that it should be for the Thread device.
-
-Arguments:
-
- AdapterContext - handle to a OTTMP Adapter
-
-Return Value:
-
- NTSTATUS - A failure here will indicate the serial COM port was not able
- to be opened.
---*/
-{
- NTSTATUS status = STATUS_UNSUCCESSFUL;
- PWSTR SymbolicLinkList = NULL;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- do
- {
- WDF_OBJECT_ATTRIBUTES attr = { 0 };
- WDF_WORKITEM_CONFIG config = { 0 };
-
- //
- // Send Queue Variables
- //
-
- InitializeListHead(&AdapterContext->SendQueue);
- AdapterContext->SendQueueRunning = false;
-
- WDF_OBJECT_ATTRIBUTES_INIT(&attr);
- attr.ParentObject = AdapterContext->Device;
- status = WdfSpinLockCreate(&attr, &AdapterContext->SendLock);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "WdfSpinLockCreate(lockSend) failed %!STATUS!", status);
- break;
- }
-
- WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attr, WDF_DEVICE_INFO);
- attr.ParentObject = AdapterContext->Device;
- WDF_WORKITEM_CONFIG_INIT(&config, SerialSendLoop);
-
- status = WdfWorkItemCreate(&config, &attr, &AdapterContext->SendWorkItem);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "WdfWorkItemCreate(SerialSendLoop) failed %!STATUS!", status);
- break;
- }
- GetWdfDeviceInfo(AdapterContext->SendWorkItem)->AdapterContext = AdapterContext;
-
- //
- // Receive Variables
- //
-
- WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attr, WDF_DEVICE_INFO);
- attr.ParentObject = AdapterContext->Device;
- WDF_WORKITEM_CONFIG_INIT(&config, SerialRecvLoop);
-
- status = WdfWorkItemCreate(&config, &attr, &AdapterContext->RecvWorkItem);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "WdfWorkItemCreate(SerialRecvLoop) failed %!STATUS!", status);
- break;
- }
-
- GetWdfDeviceInfo(AdapterContext->RecvWorkItem)->AdapterContext = AdapterContext;
-
- // Query the system for device with SERIAL interface
- status =
- IoGetDeviceInterfaces(
- &GUID_DEVINTERFACE_COMPORT,
- NULL,
- 0,
- &SymbolicLinkList // List of symbolic names; separate by NULL, EOL with NULL+NULL.
- );
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IoGetDeviceInterfaces failed %!STATUS!", status);
- break;
- }
-
- // Make sure there is a COM port found
- NT_ASSERT(SymbolicLinkList);
- if (*SymbolicLinkList == NULL) {
- status = STATUS_DEVICE_NOT_CONNECTED;
- LogError(DRIVER_DEFAULT, "No COM ports found!");
- break;
- }
-
-#if DBG
- for (PCWSTR sym = SymbolicLinkList; *sym != NULL; sym += wcslen(sym) + 1)
- {
- LogVerbose(DRIVER_DEFAULT, "Symbolic Name found: %ws", sym);
- }
-#endif
-
- // Try to open each serial port until we get that one works or we exhaust them all
- for (PCWSTR sym = SymbolicLinkList; *sym != NULL; sym += wcslen(sym) + 1)
- {
- // Initialize the target
- status = SerialInitializeTarget(AdapterContext, sym);
-
- // Break on success
- if (NT_SUCCESS(status)) {
- break;
- }
- }
-
- } while (false);
-
- // Clean up on failure
- if (!NT_SUCCESS(status)) {
- SerialUninitialize(AdapterContext);
- }
-
- if (SymbolicLinkList) {
- ExFreePool(SymbolicLinkList);
- SymbolicLinkList = NULL;
- }
-
- LogFuncExitNT(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-PAGED
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-SerialUninitialize(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- )
-/*++
-Routine Description:
-
- SerialUninitialize cleans up any cached Wdf IoTarget created from SerialInitialize.
-
-Arguments:
-
- AdapterContext - handle to a OTTMP Adapter
---*/
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- // TODO - Clean up work item
-
- // TODO - Clean up send queue
-
- SerialUninitializeTarget(AdapterContext);
-
- if (AdapterContext->RecvWorkItem) {
- WdfWorkItemFlush(AdapterContext->RecvWorkItem);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-PAGED
-_No_competing_thread_
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-SerialInitializeTarget(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ PCWSTR TargetName
-)
-{
- NTSTATUS status = STATUS_UNSUCCESSFUL;
- WDFIOTARGET tempTarget = WDF_NO_HANDLE;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- do
- {
- DECLARE_UNICODE_STRING_SIZE(PortName, 64); // Maximum name length of the device path to a serial port
- WDF_IO_TARGET_OPEN_PARAMS openParams = { 0 };
- WDF_OBJECT_ATTRIBUTES attr = { 0 };
-
- // Create the Wdf IoTarget
- status = WdfIoTargetCreate(AdapterContext->Device, WDF_NO_OBJECT_ATTRIBUTES, &tempTarget);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "WdfIoTargetCreate failed %!STATUS!", status);
- break;
- }
-
- // Try the COM port
- LogInfo(DRIVER_DEFAULT, "Opening device: %ws", TargetName);
- RtlInitUnicodeString(&PortName, TargetName);
- WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
- &openParams,
- &PortName,
- GENERIC_READ | GENERIC_WRITE);
-
- // Open the port on the target
- status = WdfIoTargetOpen(tempTarget, &openParams);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "WdfIoTargetOpen(%wZ) failed %!STATUS!", &PortName, status);
- break;
- }
-
- AdapterContext->WdfIoTarget = tempTarget;
- tempTarget = WDF_NO_HANDLE;
-
- WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attr, WDF_DEVICE_INFO);
- attr.ParentObject = AdapterContext->Device;
-
- status = WdfRequestCreate(&attr, AdapterContext->WdfIoTarget, &AdapterContext->RecvReadRequest);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "WdfRequestCreate failed %!STATUS!", status);
- break;
- }
-
- // Try to configure the target
- status = SerialConfigure(AdapterContext);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "SerialConfigure failed %!STATUS!", status);
- break;
- }
-
- } while (false);
-
- // Clean up on failure
- if (!NT_SUCCESS(status)) {
- SerialUninitializeTarget(AdapterContext);
- }
-
- if (tempTarget) {
- WdfIoTargetClose(tempTarget);
- }
-
- LogFuncExitNT(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-PAGED
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-SerialUninitializeTarget(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
-)
-/*++
-Routine Description:
-
- SerialUninitializeTarget cleans up any cached Wdf IoTarget created from SerialInitializeTarget.
-
-Arguments:
-
- AdapterContext - handle to a OTTMP Adapter
---*/
-{
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- if (AdapterContext->WdfIoTarget) {
- //
- // WdfIoTargetStop will cancel all the outstanding I/O and wait
- // for them to complete before returning. WdfIoTargetStop with the
- // action type WdfIoTargetCancelSentIo can be called at IRQL PASSIVE_LEVEL only.
- //
- WdfIoTargetStop(AdapterContext->WdfIoTarget, WdfIoTargetCancelSentIo);
- WdfIoTargetClose(AdapterContext->WdfIoTarget);
- AdapterContext->WdfIoTarget = NULL;
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_Must_inspect_result_
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-FORCEINLINE
-SerialSendIoctl(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ ULONG IoctlCode,
- _In_opt_ PWDF_REQUEST_SEND_OPTIONS RequestOptions = NULL,
- _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer = WDF_NO_HANDLE,
- _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer = WDF_NO_HANDLE,
- _Out_opt_ PULONG_PTR BytesReturned = NULL
- )
-/*++
-Routine Description:
-
- Helper/Wrapper function for WdfIoTargetSendIoctlSynchronously.
-
---*/
-{
- return WdfIoTargetSendIoctlSynchronously(
- AdapterContext->WdfIoTarget,
- WDF_NO_HANDLE,
- IoctlCode,
- InputBuffer,
- OutputBuffer,
- RequestOptions,
- BytesReturned);
-}
-
-PAGED
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-SerialConfigure(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- )
-/*++
-Routine Description:
-
- SerialInitialize attempts to find and open the first COM port available, with
- the assumption that it should be for the Thread device.
-
-Arguments:
-
- AdapterContext - handle to a OTTMP Adapter
-
-Return Value:
-
- NTSTATUS - A failure here will indicate the serial COM port was not able
- to be configured as desired.
---*/
-{
- NTSTATUS status = STATUS_UNSUCCESSFUL;
- WDF_MEMORY_DESCRIPTOR inputDesc;
- WDF_REQUEST_SEND_OPTIONS wrso = {
- sizeof(WDF_REQUEST_SEND_OPTIONS),
- WDF_REQUEST_SEND_OPTION_TIMEOUT | WDF_REQUEST_SEND_OPTION_SYNCHRONOUS,
- WDF_REL_TIMEOUT_IN_SEC(1) // Nothing should take more than a second to complete
- };
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- do
- {
- // Initial reset of the device
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_RESET_DEVICE, &wrso);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_RESET_DEVICE failed %!STATUS!", status);
- break;
- }
-
- // 8 bits, no parity, 1 stop bit
- {
- const SERIAL_LINE_CONTROL slc = { STOP_BIT_1, NO_PARITY, 8 };
- WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&inputDesc, (PVOID)&slc, sizeof(slc));
-
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_SET_LINE_CONTROL, &wrso, &inputDesc);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_SET_LINE_CONTROL failed %!STATUS!", status );
- break;
- }
- }
-
- // Xon and Xoff characters
- {
- const SERIAL_CHARS sc = { 0, 0, 0, 0, 0x11, 0x13 };
- WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&inputDesc, (PVOID)&sc, sizeof(sc));
-
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_SET_CHARS, &wrso, &inputDesc);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_SET_CHARS failed %!STATUS!", status);
- break;
- }
- }
-
- // Baud rate
- {
- const SERIAL_BAUD_RATE sbr = { 115200 };
- WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&inputDesc, (PVOID)&sbr, sizeof(sbr));
-
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_SET_BAUD_RATE, &wrso, &inputDesc);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_SET_BAUD_RATE failed %!STATUS!", status);
- break;
- }
- }
-
- /*{
- // Only send if CTS is set, Set RTS before sending
- const SERIAL_HANDFLOW shf =
- {
- SERIAL_CTS_HANDSHAKE, SERIAL_RTS_CONTROL,
- MAX_SPINEL_COMMAND_LENGTH, MAX_SPINEL_COMMAND_LENGTH
- };
- WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&inputDesc, (PVOID)&shf, sizeof(shf));
-
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_SET_HANDFLOW, &wrso, &inputDesc);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_SET_HANDFLOW failed %!STATUS!", status);
- // break; Ignore for now
- }
- }
-
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_SET_XON, &wrso);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_SET_XON failed %!STATUS!", status);
- break;
- }
-
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_SET_RTS, &wrso);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_SET_RTS failed %!STATUS!", status);
- break;
- }
-
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_SET_DTR, &wrso);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_SET_DTR failed %!STATUS!", status);
- break;
- }*/
-
- {
- const SERIAL_TIMEOUTS sto = {
- 1, 0, 0, // On read, only timeout if more than 1ms *between* bytes (wait forever for first byte)
- 1, 10 // Write times out after (1ms * n-bytes) + (10ms)
- };
- WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&inputDesc, (PVOID)&sto, sizeof(sto));
-
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_SET_TIMEOUTS, &wrso, &inputDesc);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_SET_TIMEOUTS failed %!STATUS!", status);
- break;
- }
- }
-
- status = SerialFlushAndCheckStatus(AdapterContext);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "SerialFlushAndCheckStatus failed %!STATUS!", status);
- break;
- }
-
- } while (false);
-
- LogFuncExitNT(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-PAGED
-_IRQL_requires_(PASSIVE_LEVEL)
-NTSTATUS
-SerialCheckStatus(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ bool DataExpected
- )
-/*++
-Routine Description:
-
- SerialCheckStatus validates the current status of the serial COM port.
-
-Arguments:
-
- AdapterContext - handle to a OTTMP Adapter
-
-Return Value:
-
- NTSTATUS - A failure here will indicate the serial COM port is not in an
- expected state.
---*/
-{
- NTSTATUS status = STATUS_UNSUCCESSFUL;
- WDF_MEMORY_DESCRIPTOR outputDesc;
- WDF_REQUEST_SEND_OPTIONS wrso = {
- sizeof(WDF_REQUEST_SEND_OPTIONS),
- WDF_REQUEST_SEND_OPTION_TIMEOUT | WDF_REQUEST_SEND_OPTION_SYNCHRONOUS,
- WDF_REL_TIMEOUT_IN_SEC(1) // Nothing should take more than a second to complete
- };
- ULONG_PTR bytesReturned = 0;
- SERIAL_STATUS ss = { 0 };
- WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&outputDesc, (PVOID)&ss, sizeof(ss));
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- // Check to ensure we are ready to send
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_GET_COMMSTATUS, &wrso, WDF_NO_HANDLE, &outputDesc, &bytesReturned);
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_GET_COMMSTATUS failed %!STATUS!", status);
- }
- else if (bytesReturned >= sizeof(ss))
- {
- if (ss.HoldReasons)
- {
- if (ss.HoldReasons != SERIAL_TX_WAITING_FOR_CTS)
- {
- LogError(DRIVER_DEFAULT, "HoldReasons is wrong (should only be CTS, but is %x)", ss.HoldReasons );
- status = STATUS_INVALID_DEVICE_STATE;
- }
- else if (!DataExpected)
- {
- LogError(DRIVER_DEFAULT, "Adapter already has data on init!?!?!");
- status = STATUS_INVALID_STATE_TRANSITION;
- }
- }
- if (ss.Errors)
- {
- LogWarning(DRIVER_DEFAULT, "Unexpected Error %x", ss.Errors);
- status = STATUS_UNSUCCESSFUL;
- }
- }
-
- LogFuncExitNT(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-PAGED
-_IRQL_requires_(PASSIVE_LEVEL)
-NTSTATUS
-SerialFlushAndCheckStatus(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- )
-/*++
-Routine Description:
-
- SerialFlushAndCheckStatus flushed and validates the current status of the serial COM port.
-
-Arguments:
-
- AdapterContext - handle to a OTTMP Adapter
-
-Return Value:
-
- NTSTATUS - A failure here will indicate the serial COM port is not in an
- expected state.
---*/
-{
- NTSTATUS status = STATUS_UNSUCCESSFUL;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- do
- {
- WDF_MEMORY_DESCRIPTOR inputDesc;
- WDF_REQUEST_SEND_OPTIONS wrso = {
- sizeof(WDF_REQUEST_SEND_OPTIONS),
- WDF_REQUEST_SEND_OPTION_TIMEOUT | WDF_REQUEST_SEND_OPTION_SYNCHRONOUS,
- WDF_REL_TIMEOUT_IN_SEC(1) // Nothing should take more than a second to complete
- };
- const ULONG flags = SERIAL_PURGE_RXABORT | SERIAL_PURGE_RXCLEAR | SERIAL_PURGE_TXABORT | SERIAL_PURGE_TXCLEAR;
-
- WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(&inputDesc, (PVOID)&flags, sizeof(flags));
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_PURGE, &wrso, &inputDesc);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_PURGE failed %!STATUS!", status);
- break;
- }
-
- status = SerialSendIoctl(AdapterContext, IOCTL_SERIAL_CLEAR_STATS, &wrso);
-
- if (!NT_SUCCESS(status)) {
- LogError(DRIVER_DEFAULT, "IOCTL_SERIAL_CLEAR_STATS failed %!STATUS!", status);
- break;
- }
-
- status = SerialCheckStatus(AdapterContext, false);
- for (int i = 0; !NT_SUCCESS(status) && i < 20; i++)
- {
- NdisMSleep(1); // just sleep enough to give up our quantum
- status = SerialCheckStatus(AdapterContext, false);
- }
-
- } while (false);
-
- LogFuncExitNT(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-bool
-SerialPushSend(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ PSERIAL_SEND_ITEM SendItem
- )
-{
- WdfSpinLockAcquire(AdapterContext->SendLock);
-
- // Start the work item up if it's not already running
- if (!AdapterContext->SendQueueRunning)
- {
- LogVerbose(DRIVER_DEFAULT, "Starting Send Work Item");
- AdapterContext->SendQueueRunning = true;
- WdfWorkItemEnqueue(AdapterContext->SendWorkItem);
- }
-
- // Insert the new item at the end of the list
- InsertTailList(&AdapterContext->SendQueue, &SendItem->Link);
-
- WdfSpinLockRelease(AdapterContext->SendLock);
-
- return true;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-PSERIAL_SEND_ITEM
-SerialPopSend(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- )
-{
- PLIST_ENTRY current = NULL;
-
- // Grab the head of the list
- // Careful, this might have gotten aborted, leaving the list empty
- WdfSpinLockAcquire(AdapterContext->SendLock);
-
- if (!IsListEmpty(&AdapterContext->SendQueue))
- {
- current = RemoveHeadList(&AdapterContext->SendQueue);
- }
- if (current == NULL)
- {
- // Do this under the lock, but the state is consumed outside the lock
- AdapterContext->SendQueueRunning = false;
- LogVerbose(DRIVER_DEFAULT, "Send Work Item Complete");
- }
-
- WdfSpinLockRelease(AdapterContext->SendLock);
-
- return current ? CONTAINING_RECORD(current, SERIAL_SEND_ITEM, Link) : NULL;
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-SerialSendData(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ PNET_BUFFER_LIST NetBufferList
- )
-/*++
-Routine Description:
-
- SerialSendData encodes and queues up the data to be sent over the serial COM port.
-
-Arguments:
-
- AdapterContext - handle to a OTTMP Adapter
-
- NetBufferLists - a single NET_BUFFER_LIST object, containing a signle NET_BUFFER for
- Spinel tunnel commands.
-
- DispatchLevel - flag indicating if we are running at dispatch or not
-
-Return Value:
-
- NTSTATUS - A failure here will indicate we either failed to encode or queue the data.
---*/
-{
- NTSTATUS status = STATUS_SUCCESS;
- WDF_OBJECT_ATTRIBUTES attributes;
- WDFMEMORY WdfMemBuffer = NULL;
- PSERIAL_SEND_ITEM SendItem = NULL;
- PUCHAR DecodedBuffer = NULL;
- ULONG DecodedBufferLength = NetBufferList->FirstNetBuffer->DataLength;
- ULONG EncodedBufferLength;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- do
- {
- // Get the decoded buffer from the NBL/NB. We required
- // the use of contiguous buffers.
- DecodedBuffer = (PUCHAR)NdisGetDataBuffer(NetBufferList->FirstNetBuffer, DecodedBufferLength, NULL, 1, 0);
- if (DecodedBuffer == NULL) {
- status = STATUS_INVALID_PARAMETER;
- break;
- }
-
- LogVerbose(DRIVER_DEFAULT, "Sending %u decoded bytes", DecodedBufferLength);
- DumpBuffer(DecodedBuffer, DecodedBufferLength);
-
- // Calculate the buffer size required
- EncodedBufferLength = HdlcComputeEncodedLength(DecodedBuffer, DecodedBufferLength);
-
- // Allocate the memory
- WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
- attributes.ParentObject = AdapterContext->Device;
-#pragma warning(push)
-#pragma warning(suppress: 28160) // Param 3 could be 0
- status = WdfMemoryCreate(
- &attributes,
- NonPagedPoolNx,
- 0,
- SERIAL_SEND_ITEM_SIZE + EncodedBufferLength,
- &WdfMemBuffer,
- (PVOID*)&SendItem
- );
-#pragma warning(pop)
-
- if (!NT_SUCCESS(status)) {
- LogWarning(DRIVER_DEFAULT, "WdfMemoryCreate (%u bytes) failed %!STATUS!", (SERIAL_SEND_ITEM_SIZE + EncodedBufferLength), status);
- break;
- }
-
- SendItem->NetBufferList = NetBufferList;
- SendItem->WdfMemory = WdfMemBuffer;
- SendItem->EncodedBufferLength = EncodedBufferLength;
-
- // Encode data
- if (!HdlcEncodeBuffer(DecodedBuffer, DecodedBufferLength, SendItem->EncodedBuffer, EncodedBufferLength)) {
- NT_ASSERT(FALSE); // Should never fail, unless we have a bug in the length computation
- status = STATUS_INSUFFICIENT_RESOURCES;
- break;
- }
-
- // Queue data to be sent out
- if (!SerialPushSend(AdapterContext, SendItem)) {
- status = STATUS_DEVICE_NOT_READY;
- break;
- }
-
- } while (false);
-
- if (!NT_SUCCESS(status)) {
- if (WdfMemBuffer) {
- WdfObjectDelete(WdfMemBuffer);
- }
- }
-
- LogFuncExitNT(DRIVER_DEFAULT, status);
-
- return status;
-}
-
-PAGED
-_Function_class_(EVT_WDF_WORKITEM)
-_IRQL_requires_same_
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-SerialSendLoop(
- _In_ WDFWORKITEM WorkItem
- )
-/*++
-Routine Description:
-
- SerialSendLoop handles the actual sending of data over the serial COM port.
-
-Arguments:
-
- WorkItem - handle to a Wdf Device Info object for the Adapter context
-
---*/
-{
- POTTMP_ADAPTER_CONTEXT AdapterContext = GetWdfDeviceInfo(WorkItem)->AdapterContext;
- WDF_REQUEST_SEND_OPTIONS wrso = {
- sizeof(WDF_REQUEST_SEND_OPTIONS),
- WDF_REQUEST_SEND_OPTION_TIMEOUT | WDF_REQUEST_SEND_OPTION_SYNCHRONOUS,
- WDF_REL_TIMEOUT_IN_SEC(1) // Nothing should take more than a second to complete
- };
- WDFMEMORY_OFFSET offset = { 0 };
- PSERIAL_SEND_ITEM SendItem = NULL;
- WDF_MEMORY_DESCRIPTOR wmd;
- NTSTATUS status;
-
- WDF_OBJECT_ATTRIBUTES Attributes;
- WDF_OBJECT_ATTRIBUTES_INIT(&Attributes);
- Attributes.ParentObject = AdapterContext->Device;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
-#pragma warning(push)
-#pragma warning(suppress: 6387) // Param 2 is NULL
- WDF_MEMORY_DESCRIPTOR_INIT_HANDLE(&wmd, NULL, &offset);
-#pragma warning(pop)
-
- while (NULL != (SendItem = SerialPopSend(AdapterContext)))
- {
- LogVerbose(DRIVER_DEFAULT, "Sending %u encoded bytes", SendItem->EncodedBufferLength);
- DumpBuffer(SendItem->EncodedBuffer, SendItem->EncodedBufferLength);
-
- if (SendItem->EncodedBufferLength > 0)
- {
- offset.BufferLength = SendItem->EncodedBufferLength;
- status =
- WdfMemoryCreatePreallocated(
- &Attributes,
- SendItem->EncodedBuffer,
- SendItem->EncodedBufferLength,
- &wmd.u.HandleType.Memory);
-
- if (!NT_SUCCESS( status )) {
- LogError(DRIVER_DEFAULT, "WdfIoTargetSendWriteSynchronously (%u bytes) failed %!STATUS!", SendItem->EncodedBufferLength, status);
- }
- else
- {
- // Send the buffer out
- status = WdfIoTargetSendWriteSynchronously(AdapterContext->WdfIoTarget, NULL, &wmd, NULL, &wrso, NULL);
-
- if (!NT_SUCCESS( status )) {
- LogError(DRIVER_DEFAULT, "WdfIoTargetSendWriteSynchronously (%u bytes) failed %!STATUS!", SendItem->EncodedBufferLength, status);
- }
-
- WdfObjectDelete(wmd.u.HandleType.Memory);
- }
- }
- else
- {
- status = STATUS_INVALID_PARAMETER;
- }
-
- // Complete the NetBufferList
- SendItem->NetBufferList->Status = status;
-#ifdef OTTMP_LEGACY
- NdisMSendNetBufferListsComplete(AdapterContext->Adapter, SendItem->NetBufferList, 0);
-#else
- NetBufferListsCompleteSend(SendItem->NetBufferList);
-#endif
-
- // Hack to sleep 1 ms per 5 bytes sent
- NdisMSleep(1000 * (1 + SendItem->EncodedBufferLength / 5));
-
- // Cleanup
- WdfObjectDelete(SendItem->WdfMemory);
- };
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-PAGED
-_Function_class_(EVT_WDF_WORKITEM)
-_IRQL_requires_same_
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-SerialRecvLoop(
- _In_ WDFWORKITEM WorkItem
- )
-{
- POTTMP_ADAPTER_CONTEXT AdapterContext = GetWdfDeviceInfo(WorkItem)->AdapterContext;
- WDFMEMORY mem = { 0 };
- NTSTATUS status;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- PAGED_CODE();
-
- do
- {
- WDFREQUEST & request = AdapterContext->RecvReadRequest;
-
- WDF_OBJECT_ATTRIBUTES attributes;
- WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
- attributes.ParentObject = AdapterContext->Device;
- status =
- WdfMemoryCreatePreallocated(
- &attributes,
- AdapterContext->RecvBuffer + AdapterContext->RecvBufferLength,
- MAX_SPINEL_COMMAND_LENGTH,
- &mem);
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "WdfMemoryCreateFromLookaside failed %!STATUS!", status);
- break;
- }
-
- status = WdfIoTargetFormatRequestForRead(AdapterContext->WdfIoTarget, request, mem, NULL, NULL);
-
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "WdfIoTargetFormatRequestForRead failed %!STATUS!", status);
- break;
- }
- else
- {
- WdfRequestSetCompletionRoutine(request, SerialRecvComplete, AdapterContext);
- if (WdfRequestSend(request, AdapterContext->WdfIoTarget, WDF_NO_SEND_OPTIONS))
- {
- // Send succeeded, no cleanup
- mem = NULL;
- break;
- }
-
- status = WdfRequestGetStatus(request);
- if (!NT_SUCCESS(status))
- {
- LogError(DRIVER_DEFAULT, "WdfRequestSend failed %!STATUS!", status);
- }
-
- WDF_REQUEST_REUSE_PARAMS reuseParams = { 0 };
- WDF_REQUEST_REUSE_PARAMS_INIT(&reuseParams, WDF_REQUEST_REUSE_NO_FLAGS, STATUS_SUCCESS);
-
- // refresh the request so it is ready to reuse
- status = WdfRequestReuse(request, &reuseParams);
- if (!NT_SUCCESS(status))
- {
- NT_ASSERT(NT_SUCCESS(status));
- LogError(DRIVER_DEFAULT, "WdfRequestReuse failed %!STATUS!", status);
- }
- }
-
- } while (false);
-
- if (mem) {
- WdfObjectDelete(mem);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-_When_(return==0,_At_(*pNetBufferList, __drv_allocatesMem(mem)))
-_When_(return==0,_At_((*pNetBufferList)->FirstNetBuffer, __drv_allocatesMem(mem)))
-NTSTATUS
-SerialAllocateNetBufferList(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ ULONG BufferLength,
- _Out_ PNET_BUFFER_LIST *pNetBufferList
- )
-{
- NTSTATUS status = STATUS_SUCCESS;
- PNET_BUFFER_LIST NetBufferList = NULL;
- PNET_BUFFER NetBuffer = NULL;
-
- do
- {
-
-#ifdef OTTMP_LEGACY
- // Allocate the NetBufferList
- NetBufferList = NdisAllocateNetBufferList(AdapterContext->pGlobals->hNblPool, 0, 0);
-
- if (NetBufferList == NULL)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- break;
- }
-
- // Allocate the NetBuffer
- NetBufferList->FirstNetBuffer = NdisAllocateNetBufferMdlAndData(AdapterContext->pGlobals->hNbPool);
-
- if (NetBufferList->FirstNetBuffer == NULL)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- break;
- }
-#else
- // Grab a NetBufferList from the collection
- status = NetBufferListCollectionRetrieveNbls(AdapterContext->ReceiveCollection, 1, &NetBufferList);
-
- if (!NT_SUCCESS(status))
- {
- break;
- }
-#endif
-
- NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS;
- NetBuffer = NetBufferList->FirstNetBuffer;
-
- // If there is no buffer allocated yet, go ahead and allocate the max
- if (NET_BUFFER_DATA_LENGTH(NetBuffer) == 0)
- {
- // Allocate the max buffer size
- ndisStatus = NdisRetreatNetBufferDataStart(NetBuffer, MAX_SPINEL_COMMAND_LENGTH, 0, NULL);
- if (ndisStatus != NDIS_STATUS_SUCCESS)
- {
- LogError(DRIVER_DEFAULT, "NdisRetreatNetBufferDataStart failed %!NDIS_STATUS!", ndisStatus);
- status = STATUS_INSUFFICIENT_RESOURCES;
- break;
- }
- }
-
- // By this point, we should have a NetBuffer with a contiguous memory block of MAX_SPINEL_COMMAND_LENGTH bytes,
- // though it's offset could be anywhere in the buffer, from when it was previously used.
-
- // Adjust buffer length to fit the requested length
- if (NET_BUFFER_DATA_LENGTH(NetBuffer) > BufferLength)
- {
- NdisAdvanceNetBufferDataStart(NetBuffer, NET_BUFFER_DATA_LENGTH(NetBuffer) - BufferLength, FALSE, NULL);
- }
- else if (NET_BUFFER_DATA_LENGTH(NetBuffer) < BufferLength)
- {
- ndisStatus = NdisRetreatNetBufferDataStart(NetBuffer, BufferLength - NET_BUFFER_DATA_LENGTH(NetBuffer), 0, NULL);
- NT_ASSERT(ndisStatus == NDIS_STATUS_SUCCESS);
- if (ndisStatus != NDIS_STATUS_SUCCESS)
- {
- status = STATUS_INSUFFICIENT_RESOURCES;
- break;
- }
- }
-
- // Set the output
- *pNetBufferList = NetBufferList;
-
- } while (FALSE);
-
- if (!NT_SUCCESS(status))
- {
-#ifdef OTTMP_LEGACY
- if (NetBuffer) NdisFreeNetBuffer(NetBuffer);
- if (NetBufferList) NdisFreeNetBufferList(NetBufferList);
-#else
- if (NetBufferList) NetBufferListsDiscardReceive(NetBufferList);
-#endif
- }
-
- return status;
-}
-
-_Function_class_(EVT_WDF_REQUEST_COMPLETION_ROUTINE)
-_IRQL_requires_same_
-VOID
-SerialRecvComplete(
- _In_ WDFREQUEST Request,
- _In_ WDFIOTARGET Target,
- _In_ PWDF_REQUEST_COMPLETION_PARAMS Params,
- _In_ WDFCONTEXT Context
- )
-{
- POTTMP_ADAPTER_CONTEXT AdapterContext = (POTTMP_ADAPTER_CONTEXT)Context;
- NTSTATUS status;
-
- LogFuncEntry(DRIVER_DEFAULT);
-
- UNREFERENCED_PARAMETER(Target); // Except for an assert
- NT_ASSERT((Target == AdapterContext->WdfIoTarget) || (WDF_NO_HANDLE == AdapterContext->WdfIoTarget));
- NT_ASSERT(Request == AdapterContext->RecvReadRequest);
-
- WDFMEMORY mem = Params->Parameters.Read.Buffer;
- NT_ASSERT(mem);
-
- status = WdfRequestGetStatus(Request);
- if (NT_SUCCESS(status))
- {
- NT_ASSERT(Params->Type == WdfRequestTypeRead);
- NT_ASSERT(Params->Parameters.Read.Offset == 0);
-
- size_t MemoryLength = 0;
- NT_ASSERT(AdapterContext->RecvBuffer + AdapterContext->RecvBufferLength == (PUCHAR)WdfMemoryGetBuffer(mem, &MemoryLength));
- UNREFERENCED_PARAMETER(MemoryLength);
-
- LogVerbose(DRIVER_DEFAULT, "Received %u encoded bytes", (ULONG)Params->IoStatus.Information);
- DumpBuffer(AdapterContext->RecvBuffer + AdapterContext->RecvBufferLength, (ULONG)Params->IoStatus.Information);
-
- AdapterContext->RecvBufferLength += (ULONG)Params->IoStatus.Information;
-
- // Decode and receive
- ULONG ReadOffset = 0;
- while (AdapterContext->RecvBufferLength > ReadOffset)
- {
- // Parse, validate and compute the decoded buffer size requirements
- ULONG UsedEncodedBufferLength = AdapterContext->RecvBufferLength - ReadOffset;
- ULONG DecodedBufferLength = 0;
- bool HasGoodBuffer = false;
- bool HasCompleteBuffer =
- HdlcDecodeBuffer(
- AdapterContext->RecvBuffer + ReadOffset,
- &UsedEncodedBufferLength,
- &DecodedBufferLength,
- NULL,
- &HasGoodBuffer);
-
- // We should never have used more buffer than available
- NT_ASSERT(UsedEncodedBufferLength <= AdapterContext->RecvBufferLength - ReadOffset);
-
- // Did we have a complete (start and end sequence chars) buffer?
- if (!HasCompleteBuffer)
- {
- AdapterContext->RecvBufferLength -= ReadOffset;
-
- LogWarning(DRIVER_DEFAULT, "Buffering %u incomplete bytes", AdapterContext->RecvBufferLength);
- NT_ASSERT(AdapterContext->RecvBufferLength < MAX_SPINEL_COMMAND_LENGTH);
-
- memmove_s(AdapterContext->RecvBuffer, sizeof(AdapterContext->RecvBuffer),
- AdapterContext->RecvBuffer + ReadOffset, AdapterContext->RecvBufferLength);
- break;
- }
- else
- {
- // Was the buffer too short or did it's FCS not match?
- if (HasGoodBuffer)
- {
- NT_ASSERT(UsedEncodedBufferLength <= MAX_SPINEL_COMMAND_LENGTH);
-
- // Allocate the NetBufferList & NetBuffer to decode the data to
- PNET_BUFFER_LIST NetBufferList = NULL;
- status = SerialAllocateNetBufferList(AdapterContext, DecodedBufferLength, &NetBufferList);
-
- if (NT_SUCCESS(status))
- {
- PNET_BUFFER NetBuffer = NetBufferList->FirstNetBuffer;
- NT_ASSERT(DecodedBufferLength == NET_BUFFER_DATA_LENGTH(NetBuffer));
-
- // Get pointer to contiguous buffer
- PUCHAR DecodedBuffer = (PUCHAR)NdisGetDataBuffer(NetBuffer, DecodedBufferLength, NULL, 1, 0);
- NT_ASSERT(DecodedBuffer);
- if (DecodedBuffer)
- {
- HasCompleteBuffer =
- HdlcDecodeBuffer(
- AdapterContext->RecvBuffer + ReadOffset,
- &UsedEncodedBufferLength,
- &DecodedBufferLength,
- DecodedBuffer,
- &HasGoodBuffer);
-
- NT_ASSERT(HasCompleteBuffer);
- NT_ASSERT(HasGoodBuffer);
- NT_ASSERT(DecodedBufferLength == NET_BUFFER_DATA_LENGTH(NetBuffer));
-
- LogVerbose(DRIVER_DEFAULT, "Received %u decoded bytes", DecodedBufferLength);
- DumpBuffer(DecodedBuffer, DecodedBufferLength);
- }
- else
- {
- status = STATUS_INVALID_PARAMETER;
- }
-
- if (NT_SUCCESS(status))
- {
- // Indicate up the new NBL we just created
-#ifdef OTTMP_LEGACY
- NdisMIndicateReceiveNetBufferLists(
- AdapterContext->Adapter,
- NetBufferList,
- NDIS_DEFAULT_PORT_NUMBER,
- 1,
- 0
- );
-#else
- NetBufferListsCompleteReceive(
- NetBufferList,
- NDIS_DEFAULT_PORT_NUMBER,
- 0
- );
-#endif
- }
- else
- {
-#ifdef OTTMP_LEGACY
- NdisFreeNetBuffer(NetBuffer);
- NdisFreeNetBufferList(NetBufferList);
-#else
- NetBufferListsDiscardReceive(NetBufferList);
-#endif
- }
- }
- }
- else
- {
- LogWarning(DRIVER_DEFAULT, "Dropping %u bad bytes", UsedEncodedBufferLength);
- DumpBuffer(AdapterContext->RecvBuffer + ReadOffset, UsedEncodedBufferLength);
- }
-
- // Skip over used data
- ReadOffset += UsedEncodedBufferLength;
- }
- }
-
- // We read all the buffer, so reset the length
- if (AdapterContext->RecvBufferLength == ReadOffset)
- {
- AdapterContext->RecvBufferLength = 0;
- }
- }
- else
- {
- LogError(DRIVER_DEFAULT, "Read request failed %!STATUS!", status);
- }
-
- WdfObjectDelete(mem);
-
- if (status != STATUS_DELETE_PENDING)
- {
- WDF_REQUEST_REUSE_PARAMS reuseParams = { 0 };
- WDF_REQUEST_REUSE_PARAMS_INIT(&reuseParams, WDF_REQUEST_REUSE_NO_FLAGS, STATUS_SUCCESS);
- status = WdfRequestReuse(Request, &reuseParams);
- if (!NT_SUCCESS(status))
- {
- NT_ASSERT(NT_SUCCESS(status));
- LogError(DRIVER_DEFAULT, "WdfRequestReuse failed %!STATUS!", status);
- }
-
- LogVerbose(DRIVER_DEFAULT, "Starting recv worker");
- WdfWorkItemEnqueue(AdapterContext->RecvWorkItem);
- }
-
- LogFuncExit(DRIVER_DEFAULT);
-}
-
-VOID
-DumpLine(
- _In_reads_bytes_(aLength) PCUCHAR aBuf,
- _In_ size_t aLength
- )
-{
- char buf[80] = {0};
- char *cur = buf;
-
- sprintf_s(cur, sizeof(buf) - (cur - buf), "|");
- cur += 1;
-
- for (size_t i = 0; i < 16; i++)
- {
- if (i < aLength)
- {
- sprintf_s(cur, sizeof(buf) - (cur - buf), " %02X", aBuf[i]);
- cur += 3;
- }
- else
- {
- sprintf_s(cur, sizeof(buf) - (cur - buf), " ..");
- cur += 3;
- }
-
- if (!((i + 1) % 8))
- {
- sprintf_s(cur, sizeof(buf) - (cur - buf), " |");
- cur += 2;
- }
- }
-
- sprintf_s(cur, sizeof(buf) - (cur - buf), " ");
- cur += 1;
-
- for (size_t i = 0; i < 16; i++)
- {
- if (i < aLength && isprint(0x7f & aBuf[i]))
- {
- char c = 0x7f & aBuf[i];
- sprintf_s(cur, sizeof(buf) - (cur - buf), "%c", c);
- cur += 1;
- }
- else
- {
- sprintf_s(cur, sizeof(buf) - (cur - buf), ".");
- cur += 1;
- }
- }
-
- LogVerbose(DRIVER_DEFAULT, "%s", buf);
-}
-
-VOID
-DumpBuffer(
- _In_reads_bytes_(aLength) PCUCHAR aBuf,
- _In_ size_t aLength
- )
-{
- for (size_t i = 0; i < aLength; i += 16)
- {
- DumpLine(aBuf + i, (aLength - i) < 16 ? (aLength - i) : 16);
- }
-}
diff --git a/examples/drivers/windows/ottmp/serial.hpp b/examples/drivers/windows/ottmp/serial.hpp
deleted file mode 100644
index 7d581921e..000000000
--- a/examples/drivers/windows/ottmp/serial.hpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#pragma once
-
-PAGED
-_No_competing_thread_
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-SerialInitialize(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- );
-
-PAGED
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-SerialUninitialize(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- );
-
-PAGED
-_No_competing_thread_
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-SerialInitializeTarget(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ PCWSTR TargetName
-);
-
-PAGED
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-SerialUninitializeTarget(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
-);
-
-PAGED
-_IRQL_requires_max_(PASSIVE_LEVEL)
-NTSTATUS
-SerialConfigure(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- );
-
-PAGED
-_IRQL_requires_(PASSIVE_LEVEL)
-NTSTATUS
-SerialCheckStatus(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ bool DataExpected
- );
-
-PAGED
-_IRQL_requires_(PASSIVE_LEVEL)
-NTSTATUS
-SerialFlushAndCheckStatus(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext
- );
-
-_IRQL_requires_max_(DISPATCH_LEVEL)
-NTSTATUS
-SerialSendData(
- _In_ POTTMP_ADAPTER_CONTEXT AdapterContext,
- _In_ PNET_BUFFER_LIST NetBufferLists
- );
-
-PAGED
-_Function_class_(EVT_WDF_WORKITEM)
-_IRQL_requires_same_
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-SerialSendLoop(
- _In_ WDFWORKITEM WorkItem
- );
-
-PAGED
-_Function_class_(EVT_WDF_WORKITEM)
-_IRQL_requires_same_
-_IRQL_requires_max_(PASSIVE_LEVEL)
-VOID
-SerialRecvLoop(
- _In_ WDFWORKITEM WorkItem
- );
-
-_Function_class_(EVT_WDF_REQUEST_COMPLETION_ROUTINE)
-_IRQL_requires_same_
-VOID
-SerialRecvComplete(
- _In_ WDFREQUEST Request,
- _In_ WDFIOTARGET Target,
- _In_ PWDF_REQUEST_COMPLETION_PARAMS Params,
- _In_ WDFCONTEXT Context
- );
-
-VOID
-DumpBuffer(
- _In_reads_bytes_(aLength) PCUCHAR aBuf,
- _In_ size_t aLength
- );
diff --git a/examples/platforms/efr32/sleepy-demo/efr32-sleepy-demo-ftd/main.c b/examples/platforms/efr32/sleepy-demo/efr32-sleepy-demo-ftd/main.c
index c20cf2fb9..300b45f1a 100644
--- a/examples/platforms/efr32/sleepy-demo/efr32-sleepy-demo-ftd/main.c
+++ b/examples/platforms/efr32/sleepy-demo/efr32-sleepy-demo-ftd/main.c
@@ -65,12 +65,12 @@ typedef struct ButtonArray
// Prototypes
void setNetworkConfiguration(otInstance *aInstance);
-void OTCALL handleNetifStateChanged(uint32_t aFlags, void *aContext);
-void gpioInit(void (*gpioCallback)(uint8_t pin));
-void buttonCallback(uint8_t pin);
-void initUdp(void);
-void applicationTick(void);
-void sFtdReceiveCallback(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
+void handleNetifStateChanged(uint32_t aFlags, void *aContext);
+void gpioInit(void (*gpioCallback)(uint8_t pin));
+void buttonCallback(uint8_t pin);
+void initUdp(void);
+void applicationTick(void);
+void sFtdReceiveCallback(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
// Variables
static otInstance * instance;
@@ -181,7 +181,7 @@ void setNetworkConfiguration(otInstance *aInstance)
otDatasetSetActive(aInstance, &aDataset);
}
-void OTCALL handleNetifStateChanged(uint32_t aFlags, void *aContext)
+void handleNetifStateChanged(uint32_t aFlags, void *aContext)
{
if ((aFlags & OT_CHANGED_THREAD_ROLE) != 0)
{
diff --git a/examples/platforms/efr32/sleepy-demo/efr32-sleepy-demo-mtd/main.c b/examples/platforms/efr32/sleepy-demo/efr32-sleepy-demo-mtd/main.c
index 6d3c6c158..441aed276 100644
--- a/examples/platforms/efr32/sleepy-demo/efr32-sleepy-demo-mtd/main.c
+++ b/examples/platforms/efr32/sleepy-demo/efr32-sleepy-demo-mtd/main.c
@@ -70,12 +70,12 @@ typedef struct ButtonArray
// Prototypes
bool sleepCb(void);
void setNetworkConfiguration(otInstance *aInstance);
-void OTCALL handleNetifStateChanged(uint32_t aFlags, void *aContext);
-void gpioInit(void (*gpioCallback)(uint8_t pin));
-void buttonCallback(uint8_t pin);
-void initUdp(void);
-void applicationTick(void);
-void mtdReceiveCallback(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
+void handleNetifStateChanged(uint32_t aFlags, void *aContext);
+void gpioInit(void (*gpioCallback)(uint8_t pin));
+void buttonCallback(uint8_t pin);
+void initUdp(void);
+void applicationTick(void);
+void mtdReceiveCallback(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
// Variables
static otInstance * instance;
@@ -197,7 +197,7 @@ void setNetworkConfiguration(otInstance *aInstance)
otDatasetSetActive(aInstance, &aDataset);
}
-void OTCALL handleNetifStateChanged(uint32_t aFlags, void *aContext)
+void handleNetifStateChanged(uint32_t aFlags, void *aContext)
{
otLinkModeConfig config;
diff --git a/examples/platforms/gp712/logging.c b/examples/platforms/gp712/logging.c
index f0a3a98b9..5538a8eef 100644
--- a/examples/platforms/gp712/logging.c
+++ b/examples/platforms/gp712/logging.c
@@ -36,10 +36,7 @@
#include
#include
#include
-
-#ifndef _WIN32
#include
-#endif
#include
#include
diff --git a/examples/platforms/posix/alarm.c b/examples/platforms/posix/alarm.c
index ccba28693..80ff79f05 100644
--- a/examples/platforms/posix/alarm.c
+++ b/examples/platforms/posix/alarm.c
@@ -169,11 +169,7 @@ void platformAlarmUpdateTimeout(struct timeval *aTimeout)
remaining = 1;
}
-#ifndef _WIN32
- aTimeout->tv_sec = (time_t)remaining / US_PER_S;
-#else
- aTimeout->tv_sec = (long)remaining / US_PER_S;
-#endif
+ aTimeout->tv_sec = (time_t)remaining / US_PER_S;
aTimeout->tv_usec = remaining % US_PER_S;
}
}
diff --git a/examples/platforms/posix/flash-windows-stubs.c b/examples/platforms/posix/flash-windows-stubs.c
deleted file mode 100644
index 08768ff54..000000000
--- a/examples/platforms/posix/flash-windows-stubs.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2016, The OpenThread Authors.
- * 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 copyright holder 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 COPYRIGHT HOLDER 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.
- */
-
-#include "platform-posix.h"
-
-otError utilsFlashInit(void)
-{
- return OT_ERROR_NOT_IMPLEMENTED;
-}
-
-uint32_t utilsFlashGetSize(void)
-{
- return 0;
-}
-
-otError utilsFlashErasePage(uint32_t aAddress)
-{
- return OT_ERROR_NOT_IMPLEMENTED;
-}
-
-otError utilsFlashStatusWait(uint32_t aTimeout)
-{
- return OT_ERROR_NONE;
-}
-
-uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
-{
- return 0;
-}
-
-uint32_t utilsFlashRead(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
-{
- return 0;
-}
diff --git a/examples/platforms/posix/logging.c b/examples/platforms/posix/logging.c
index 66171a102..21f3e590c 100644
--- a/examples/platforms/posix/logging.c
+++ b/examples/platforms/posix/logging.c
@@ -36,10 +36,7 @@
#include
#include
#include
-
-#ifndef _WIN32
#include
-#endif
#include
#include
@@ -77,11 +74,7 @@ OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const
otEXPECT_ACTION(charsWritten >= 0, logString[offset] = 0);
exit:
-#ifndef _WIN32
syslog(LOG_CRIT, "%s", logString);
-#else
- printf("%s\r\n", logString);
-#endif
}
#endif // #if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
diff --git a/examples/platforms/posix/misc.c b/examples/platforms/posix/misc.c
index c271114f6..35fe8b6fc 100644
--- a/examples/platforms/posix/misc.c
+++ b/examples/platforms/posix/misc.c
@@ -28,18 +28,14 @@
#include "platform-posix.h"
-#ifndef _WIN32
#include
#include
-#endif
#include
#include "openthread-system.h"
-#ifndef _WIN32
extern jmp_buf gResetJump;
-#endif
static otPlatResetReason sPlatResetReason = OT_PLAT_RESET_REASON_POWER_ON;
bool gPlatformPseudoResetWasRequested;
@@ -49,14 +45,11 @@ void otPlatReset(otInstance *aInstance)
{
OT_UNUSED_VARIABLE(aInstance);
-#if _WIN32
- // This function does nothing on the Windows platform.
-
-#elif OPENTHREAD_PLATFORM_USE_PSEUDO_RESET // if _WIN32
+#if OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
gPlatformPseudoResetWasRequested = true;
sPlatResetReason = OT_PLAT_RESET_REASON_SOFTWARE;
-#else // elif OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
+#else // OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
// Restart the process using execvp.
otSysDeinit();
platformUartRestore();
@@ -64,7 +57,7 @@ void otPlatReset(otInstance *aInstance)
longjmp(gResetJump, 1);
assert(false);
-#endif // else OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
+#endif // OPENTHREAD_PLATFORM_USE_PSEUDO_RESET
}
otPlatResetReason otPlatGetResetReason(otInstance *aInstance)
diff --git a/examples/platforms/posix/platform-posix.h b/examples/platforms/posix/platform-posix.h
index 2d797d9eb..244f8e490 100644
--- a/examples/platforms/posix/platform-posix.h
+++ b/examples/platforms/posix/platform-posix.h
@@ -29,7 +29,7 @@
/**
* @file
* @brief
- * This file includes the (posix or windows) platform-specific initializers.
+ * This file includes the platform-specific initializers.
*/
#ifndef PLATFORM_POSIX_H_
@@ -44,28 +44,6 @@
#include
#include