1 Commits
main ... v1.0.0

Author SHA1 Message Date
Mike
1f69fd9dfe ci: update actions name and filename 2021-02-09 11:17:47 -07:00
45 changed files with 233 additions and 1910 deletions

View File

@@ -1,42 +0,0 @@
{{ if .Versions -}}
<a name="unreleased"></a>
## [Unreleased]
{{ if .Unreleased.CommitGroups -}}
{{ range .Unreleased.CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}
{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}
{{- if .Versions }}
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
{{ range .Versions -}}
{{ if .Tag.Previous -}}
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
{{ end -}}
{{ end -}}
{{ end -}}

View File

@@ -1,28 +0,0 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/open-amt-cloud-toolkit/rpc
options:
commits:
# filters:
# Type:
# - feat
# - fix
# - perf
# - refactor
commit_groups:
# title_maps:
# feat: Features
# fix: Bug Fixes
# perf: Performance Improvements
# refactor: Code Refactoring
header:
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
pattern_maps:
- Type
- Scope
- Subject
notes:
keywords:
- BREAKING CHANGE

View File

@@ -1,16 +0,0 @@
## PR Checklist
<!-- Please check if your PR fulfills the following requirements: -->
- [ ] Unit Tests have been added for new changes
- [ ] API tests have been updated if applicable
- [ ] All commented code has been removed
- [ ] If you've added a dependency, you've ensured license is compatible with Apache 2.0 and clearly outlined the added dependency.
## What are you changing?
<!-- Please provide a short description of the updates that are in the PR -->
## Anything the reviewer should know when reviewing this PR?
### If the there are associated PRs in other repositories, please link them here (i.e. open-amt-cloud-toolkit/repo#365 )

14
.github/semantic.yml vendored
View File

@@ -1,14 +0,0 @@
allowMergeCommits: true
# Always validate the PR title AND all the commits
titleAndCommits: true
types:
- feat
- fix
- docs
- style
- refactor
- perf
- test
- build
- ci
- revert

View File

@@ -7,57 +7,44 @@ name: Build RPC (Native) Debug/Release
on:
workflow_dispatch:
inputs:
build_type:
description: 'Build Type can be "debug" or "release".'
required: true
default: "release"
env:
BUILD_TYPE: ${{github.event.inputs.build_type}}
BUILD_TYPE: Release
jobs:
build-windows:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: Create Build Dir
run: mkdir build
- name: Clone
run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0
- name: Build VCPKG
run: cd vcpkg && bootstrap-vcpkg.bat
shell: cmd
- name: dir
run: ls
- name: dir
run: cd vcpkg && ls
- name: Install C++ REST SDK
run: ${{ runner.workspace }}\rpc\vcpkg\vcpkg.exe install cpprestsdk[websockets]:x64-windows-static
shell: cmd
- name: dir
run: ls && cd vcpkg && ls
shell: bash
- name: Prepare for build
run: cd build && cmake .. -DCMAKE_PREFIX_PATH=D:/a/rpc/rpc/vcpkg/installed/x64-windows-static -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=D:/a/rpc/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake
- name: Build RPC (Debug)
if: ${{ github.event.inputs.build_type }} == "debug"
run: cd build && cmake --build . --config Debug
- name: Build RPC (Release)
if: ${{ github.event.inputs.build_type }} == "release"
run: cd build && cmake --build . --config Release
- name: GitHub Upload Release Artifacts
if: ${{ github.event.inputs.build_type }} == "release"
uses: actions/upload-artifact@v2
with:
name: RPC_Windows_release.exe
path: ${{ runner.workspace }}\rpc\build\Release\rpc.exe
- name: GitHub Upload Release Artifacts
if: ${{ github.event.inputs.build_type }} == "debug"
uses: actions/upload-artifact@v2
with:
name: RPC_Windows_debug.exe
path: ${{ runner.workspace }}\rpc\build\Debug\rpc.exe
- uses: actions/checkout@v2
- name: Create Build Dir
run: mkdir build
- name: Clone
run: git clone --branch 2020.01 https://github.com/microsoft/vcpkg.git
- name: Build VCPKG
run: cd vcpkg && bootstrap-vcpkg.bat
shell: cmd
- name: dir
run: ls
- name: dir
run: cd vcpkg && ls
- name: Integrate with VS
run: ${{ runner.workspace }}\rpc\vcpkg\vcpkg.exe integrate install
shell: cmd
- name: Install C++ REST SDK
run: ${{ runner.workspace }}\rpc\vcpkg\vcpkg.exe install cpprestsdk:x64-windows-static
shell: cmd
- name: dir
run: ls && cd vcpkg && ls
shell: bash
- name: Prepare for build
run: cd build && cmake .. -DCMAKE_PREFIX_PATH=D:/a/rpc/rpc/vcpkg/installed/x64-windows-static -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=D:/a/rpc/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake
- name: Build RPC
run: cd build && cmake --build . --config Debug
- name: GitHub Upload Release Artifacts
uses: actions/upload-artifact@v2
with:
name: RPC_Windows.exe
path: ${{ runner.workspace }}\rpc\build\Debug\rpc.exe
build-linux:
runs-on: ${{ matrix.os }}
@@ -65,37 +52,18 @@ jobs:
matrix:
os: [ubuntu-18.04, ubuntu-20.04]
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
run: sudo apt install git cmake build-essential curl zip unzip tar pkg-config
- name: Create Build Dir
run: mkdir build
- name: Clone
run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0
- name: Build VCPKG
run: cd vcpkg && ./bootstrap-vcpkg.sh
shell: bash
- name: dir
run: ls
- name: dir
run: cd vcpkg && ls
- name: Install C++ REST SDK
run: ${{ runner.workspace }}/rpc/vcpkg/vcpkg install cpprestsdk[websockets]
shell: bash
- name: dir
run: ls && cd vcpkg && ls
shell: bash
- name: Prepare for build
if: ${{ github.event.inputs.build_type }} == "debug"
run: cd build && cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake
- name: Prepare for build
if: ${{ github.event.inputs.build_type }} == "release"
run: cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake
- name: Build RPC
run: cd build && cmake --build .
- name: GitHub Upload Release Artifacts
uses: actions/upload-artifact@v2
with:
name: RPC_Linux_${{ matrix.os }}_${{github.event.inputs.build_type}}
path: |
build/rpc
- uses: actions/checkout@v2
- name: Install Dependencies
run: |
sudo apt install libboost-system-dev libboost-thread-dev libboost-random-dev libboost-regex-dev libboost-filesystem-dev libssl-dev zlib1g-dev -y
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .
- name: GitHub Upload Release Artifacts
uses: actions/upload-artifact@v2
with:
name: RPC_Linux_${{ matrix.os }}
path: |
build/rpc

View File

@@ -1,20 +0,0 @@
name: Changelog Generator
on:
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: docker run -v $PWD:/workdir quay.io/git-chglog/git-chglog --next-tag vNext --output CHANGELOG-new.md vNext..
- name: GitHub Upload Release Artifacts
uses: actions/upload-artifact@v2
with:
name: CHANGELOG-new.md
path: |
./CHANGELOG-new.md

View File

@@ -1,74 +0,0 @@
#*********************************************************************
# Copyright (c) Intel Corporation 2020
# SPDX-License-Identifier: Apache-2.0
#*********************************************************************/
name: Build RPC (Native)
on:
pull_request:
branches: [ main ]
env:
BUILD_TYPE: Release
jobs:
build-windows:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: Create Build Dir
run: mkdir build
- name: Clone
run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0
- name: Build VCPKG
run: cd vcpkg && bootstrap-vcpkg.bat
shell: cmd
- name: dir
run: ls
- name: dir
run: cd vcpkg && ls
- name: Install C++ REST SDK
run: ${{ runner.workspace }}\rpc\vcpkg\vcpkg.exe install cpprestsdk[websockets]:x64-windows-static
shell: cmd
- name: dir
run: ls && cd vcpkg && ls
shell: bash
- name: Prepare for build
run: cd build && cmake .. -DCMAKE_PREFIX_PATH=D:/a/rpc/rpc/vcpkg/installed/x64-windows-static -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=D:/a/rpc/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake
- name: Build RPC (Release)
run: cd build && cmake --build . --config Release
- name: Build RPC (Debug)
run: cd build && cmake --build . --config Debug
build-linux:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04]
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
run: sudo apt install git cmake build-essential curl zip unzip tar pkg-config
- name: Create Build Dir
run: mkdir build
- name: Clone
run: git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0
- name: Build VCPKG
run: cd vcpkg && ./bootstrap-vcpkg.sh
shell: bash
- name: dir
run: ls
- name: dir
run: cd vcpkg && ls
- name: Install C++ REST SDK
run: ${{ runner.workspace }}/rpc/vcpkg/vcpkg install cpprestsdk[websockets]
shell: bash
- name: dir
run: ls && cd vcpkg && ls
shell: bash
- name: Prepare for build
run: cd build && cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake
- name: Build RPC
run: cd build && cmake --build .

View File

@@ -1,29 +0,0 @@
#*********************************************************************
# Copyright (c) Intel Corporation 2020
# SPDX-License-Identifier: Apache-2.0
#*********************************************************************/
name: Docker Image CI
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build -f "Dockerfile" --tag vprodemo.azurecr.io/rpc:${{ github.sha }} --tag vprodemo.azurecr.io/rpc:latest .
- name: Docker Login
uses: docker/login-action@v1.6.0
with:
registry: vprodemo.azurecr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
logout: true
- name: Push the Docker image to the registry
run: docker push vprodemo.azurecr.io/rpc:${{ github.sha }}
- name: Push the Docker image to the registry
run: docker push vprodemo.azurecr.io/rpc:latest

4
.gitignore vendored
View File

@@ -8,6 +8,4 @@ install_manifest.txt
compile_commands.json
CTestTestfile.cmake
build/
.vscode/*
.vs
*.exe
.vscode/*

103
Build.md
View File

@@ -1,103 +0,0 @@
# Remote Provisioning Client (RPC)
RPC is an application which enables remote capabilities for AMT, such as as device activation. To accomplish this, RPC communicates with the RPS (Remote Provisioning Server).
The steps below assume the following directory structure where **rpc** is the clone of this repository, **vcpkg** is a clone of the VCPKG tool source and **build** is the RPC build directory. Both vcpkg and build directories will be created in later steps.
```
\rpc
|__vcpkg
|__build
```
# Linux
Steps below are for Ubuntu 18.04 and 20.04.
## Dependencies
```
sudo apt install git cmake build-essential curl zip unzip tar pkg-config
```
## Build C++ REST SDK
Open a Terminal window.
```
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0
./bootstrap-vcpkg.sh
./vcpkg install cpprestsdk[websockets]
```
## Build RPC
Open a Terminal window.
```
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
```
To build debug:
```
cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .
```
## Run RPC
Open a Terminal window.
```
cd build
sudo ./rpc --url wss://localhost:8080 --cmd "-t activate --profile profile1"
```
Use --help for more options.
# Windows
Steps below are for Windows 10 and Visual Studio 2019 Professional.
## Build C++ REST SDK
Open an x64 Native Tools Command Prompt for Visual Studio 2019.
```
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0
bootstrap-vcpkg.bat
vcpkg install cpprestsdk[websockets]:x64-windows-static
```
## Build RPC
Open an x64 Native Tools Command Prompt for Visual Studio 2019.
```
mkdir build
cd build
cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake --build . --config Release
```
To build debug:
```
cmake --build . --config Debug
```
## Run RPC
Open a Command Prompt as Administrator.
```
cd build\Release
rpc.exe --url wss://localhost:8080 --cmd "-t activate --profile profile1"
```
Use --help for more options.

View File

@@ -1,92 +0,0 @@
<a name="v2.0.0"></a>
## v2.0.0
### Build
- bump version to v1.3.0
- bump version to v2.0.0
### Ci
- update scanning
### Docs
- **readme:** wording
- **readme:** update readme
- **security:** added SECURITY.md file
### Feat
- update to OpenSSL 1.1.1l
- update workflows and Docker build.
- Update to latest vcpkg
- Update docs and scripts for Windows and Ubuntu.
- format json status messages
- add AMT wireless adapter info to amtinfo LAN settings.
### Fix
- klockwork reported success / failure check fix
- **spelling:** lan inteface -> lan interface in amtinfo
<a name="v1.2.2"></a>
## [v1.2.2] - 2021-06-22
### Ci
- remove Jenkins chron
- **changelog:** add automation for changelog generation
### Fix
- update examples text and version
<a name="v1.2.1"></a>
## [v1.2.1] - 2021-05-06
### Fix
**docker:** add missing ca-certs
<a name="v1.2.0"></a>
## v1.2.0
### Ci
- breakout docker build for merge only
### Feat
- update RPC version to 1.2.0.
- BREAKING CHANGE: add heartbeat capability, bump RPC Protocol version to 4.0.0
- add unit test framework
- add hostname to activation info
- **docker:** add dockerfile support for RPC
### Fix
- use message status instead, cleanup message fields.
<a name="v1.1.0"></a>
## [v1.1.0] - 2021-02-09
### Build
- **jenkins:** jenkins build scripts for Windows and Ubuntu
- add support for centos7 and 8
- Use `-DNO_SELECT=ON` to work around select behavior on older distros
- Use vcpkg for both linux and windows
### Ci
- update build
- update build
- add support for release or debug
- add types for conventional commits
- add ci for status checks
### Docs
- add release disclaimer
### Fix
- link status not reported correctly
- free fqdn buffer
### Feat
- version update
- Add `--nocertcheck`, `-n` args to skip websocket server certificate verification for all builds.
- Add/update DNS Suffix (OS), Hostname (OS), fqdn [AMT] and DNS Suffix info returned by --amtinfo.
<a name="v1.0.0"></a>
## [v1.0.0] - 2020-11-20
### Build
- Add Github Actions Support

View File

@@ -1,14 +1,18 @@
cmake_minimum_required (VERSION 3.1)
project (rpc VERSION 2.0.0)
project (rpc VERSION 1.0.0)
set (CMAKE_CXX_STANDARD 11)
# RPC version info
configure_file(version.h.in version.h)
configure_file(version.h.in
version.h)
include_directories(${PROJECT_BINARY_DIR})
# Common compiler settings
# TODO: figure out how to read the LMS version from repo like the main lms CMakeLists.txt
set (LMS_VERSION_STRING 1932.0.0.0)
# Compiler settings [Obtained from CmakeLists.txt for lms]
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -DDEBUG -D_DEBUG")
string(APPEND CMAKE_C_FLAGS_DEBUG " -DDEBUG -D_DEBUG")
@@ -27,6 +31,7 @@ if (UNIX)
else (UNIX)
add_definitions (/GS /sdl)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NXCompat /DynamicBase")
#add_definitions (/D UNICODE /D _UNICODE)
add_definitions (/D UNICODE /D _UNICODE /D_NO_ASYNCRTIMP /D_ASYNCRT_EXPORT /D_NO_PPLXIMP /DWIN32 /DMBCS /D_USRDLL /DCPPREST_EXCLUDE_COMPRESSION /D_WINSOCK_DEPRECATED_NO_WARNINGS)
add_compile_options ($<$<CONFIG:Release>:/O2>)
add_compile_options (/MT$<$<CONFIG:Debug>:d>)
@@ -37,49 +42,48 @@ endif (UNIX)
# Add MicroLMS directly to our build. This adds
# the following targets: MicroLMS
add_subdirectory(MicroLMS)
#add_dependencies(rpc MicroLMS)
if (UNIX)
# Find threads [unix it pthreads]
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
# Find Boost
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost COMPONENTS system REQUIRED)
# Find OpenSSL
find_package(OpenSSL)
# Find ZLIB
find_package(ZLIB)
# Download and build CppRestSDK, If GIT_TAG is changed then need to delete cpprestsdk-prefix because UPDATE_COMMAND is set to ""
include(ExternalProject)
ExternalProject_Add(cpprestsdk
GIT_REPOSITORY https://github.com/Microsoft/cpprestsdk.git
GIT_TAG v2.10.16
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=0 -DBUILD_SAMPLES=OFF -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=<SOURCE_DIR>/../../install
TEST_COMMAND ""
UPDATE_COMMAND ""
)
ExternalProject_Get_Property(cpprestsdk SOURCE_DIR)
set(CPPRESTSDK_LIBARIES ${SOURCE_DIR}/../../install/lib/)
set(CPPRESTSDK_INCLUDE_DIR ${SOURCE_DIR}/../../install/include/)
add_library(cpprest INTERFACE)
target_link_libraries(cpprest INTERFACE ${CPPRESTSDK_LIBARIES}/libcpprest.a OpenSSL::SSL OpenSSL::Crypto ${Boost_LIBRARIES} Threads::Threads ZLIB::ZLIB)
target_include_directories(cpprest INTERFACE ${CPPRESTSDK_INCLUDE_DIR})
else (UNIX)
# CppRestSDK
find_package(cpprestsdk CONFIG REQUIRED)
# GoogleTest
# Download and unpack googletest at configure time
configure_file(googletest.cmake.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()
# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
# add the test executable
add_executable(rpctest
test.cpp
utils.cpp
)
target_link_libraries(rpctest
gtest_main
cpprestsdk::cpprest
cpprestsdk::cpprestsdk_zlib_internal
cpprestsdk::cpprestsdk_boost_internal
cpprestsdk::cpprestsdk_openssl_internal
)
endif (UNIX)
# ccu-poc
add_executable (rpc
@@ -98,8 +102,6 @@ add_executable (rpc
commands.cpp
activation.h
activation.cpp
heartbeat.h
heartbeat.cpp
lms.h
lms.cpp
main.cpp
@@ -109,37 +111,38 @@ target_include_directories(rpc PUBLIC
"MicroLMS/heci"
)
add_dependencies(rpc MicroLMS)
if (UNIX)
add_dependencies(rpc cpprestsdk)
target_link_libraries (rpc PRIVATE
MicroLMS
cpprestsdk::cpprest
cpprestsdk::cpprestsdk_zlib_internal
cpprestsdk::cpprestsdk_boost_internal
cpprestsdk::cpprestsdk_openssl_internal
cpprest
)
else (UNIX)
add_dependencies(rpc MicroLMS )
target_link_libraries (rpc PRIVATE
MicroLMS
iphlpapi
cpprestsdk::cpprest
cpprestsdk::cpprestsdk_zlib_internal
cpprestsdk::cpprestsdk_boost_internal
cpprestsdk::cpprestsdk_brotli_internal
${Boost_LIBRARIES}
DbgHelp.lib
Iphlpapi.lib
Setupapi.lib
ws2_32.lib
Psapi.lib
Crypt32.lib
Wintrust.lib
Version.lib
Wtsapi32.lib
Gdiplus.lib
Userenv.lib
Iphlpapi.lib
Setupapi.lib
ws2_32.lib
Psapi.lib
Crypt32.lib
Wintrust.lib
Version.lib
Wtsapi32.lib
Gdiplus.lib
Userenv.lib
)
endif (UNIX)

View File

@@ -1,101 +0,0 @@
## <a name="commit"></a> Commit Message Guidelines
We have precise rules over how our git commit messages should be formatted. This leads to more readable messages that are easy to follow when looking through the project history.
### Commit Message Format
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special format that includes a **type**, a **scope** and a **subject**:
```
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```
The **header** with **type** is mandatory. The **scope** of the header is optional as far as the automated PR checks are concerned, but be advised that PR reviewers **may request** you provide an applicable scope.
Any line of the commit message should no be longer 72 characters! This allows the message to be easier to read on GitHub as well as in various git tools.
The footer should contain a reference to an Azure Boards ticket (e.g. AB#[number]).
Example 1:
```
feat(telemetry): Add new MQTT events
Events are now emitted over various /mps topics on MQTT for success/failures
as they occur throughout the service.
Resolves: AB#2222
```
### Revert
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
### Type
Must be one of the following:
* **feat**: A new feature
* **fix**: A bug fix
* **docs**: Documentation only changes
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, etc)
* **refactor**: A code change that neither fixes a bug nor adds a feature
* **perf**: A code change that improves performance
* **test**: Adding missing tests or correcting existing tests
* **build**: Changes that affect the CI/CD pipeline or build system or external dependencies (example scopes: travis, jenkins, makefile)
* **ci**: Changes provided by DevOps for CI purposes.
* **revert**: Reverts a previous commit.
### Scope
Should be one of the following:
Modules:
* **common**: A change or addition to the common module
* **tracker**: A change or addition to the tracker module
* **server**: A change or addition to the server module
* **msgs**: A change or addition to msgs module
* **eval**: Any change to benchmark tools
* **deps**: A change to any dependency or 3rd-party library
* **all**: A change that affects all modules
* *no scope*: If no scope is provided, it is assumed the PR does not apply to the above scopes
### Body
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
Here is detailed guideline on how to write the body of the commit message ([Reference](https://chris.beams.io/posts/git-commit/)):
```
More detailed explanatory text, if necessary. Wrap it to about 72
characters or so. In some contexts, the first line is treated as the
subject of the commit and the rest of the text as the body. The
blank line separating the summary from the body is critical (unless
you omit the body entirely); various tools like `log`, `shortlog`
and `rebase` can get confused if you run the two together.
Explain the problem that this commit is solving. Focus on why you
are making this change as opposed to how (the code explains that).
Are there side effects or other unintuitive consequences of this
change? Here's the place to explain them.
Further paragraphs come after blank lines.
- Bullet points are okay, too
- Typically a hyphen or asterisk is used for the bullet, preceded
by a single space, with blank lines in between, but conventions
vary here
```
### Footer
The footer should contain a reference to JIRA ticket (e.g. SL6-0000) that this commit **Closes** or **Resolves**.
The footer should contain any information about **Breaking Changes**.
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines.
### Pull Requests practices
* PR author is responsible to merge its own PR after review has been done and CI has passed.
* When merging, make sure git linear history is preserved. PR author should select a merge option (`Rebase and merge` or `Squash and merge`) based on which option will fit the best to the git linear history.
* PR topic should follow the same guidelines as the header of the [Git Commit Message](#commit-message-format)

View File

@@ -1,86 +0,0 @@
# Remote Provisioning Client (RPC)
RPC is an application which enables remote capabilities for AMT, such as as device activation. To accomplish this, RPC communicates with the RPS (Remote Provisioning Server).
The steps below assume the following directory structure where **rpc** is the clone of this repository, **vcpkg** is a clone of the VCPKG tool source and **build** is the RPC build directory. Both vcpkg and build directories will be created in later steps.
```
\rpc
|__vcpkg
|__build
```
# Linux
Steps below are for CentOS7.
**The "export PATH=..." (for CMake and Git), and "scl enable devtoolset-7 bash" (for GCC) must be executed in in the Terminal you are building from; i.e. these are temporary changes which only affect the current Terminal session.**
## Dependencies
### CMake
Download cmake-3.10.2-Linux-x86_64.sh from https://github.com/Kitware/CMake/releases/tag/v3.10.2.
```
./cmake-3.10.2-Linux-x86_64.sh
export PATH=/home/user/Downloads/cmake-3.10.2-Linux-x86_64/bin:$PATH
```
### GCC
Update GCC toolchain.
```
sudo yum install centos-release-scl
sudo yum install devtoolset-7
scl enable devtoolset-7 bash
```
### Git
Build Git source control system.
```
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-CPAN perl-devel
git clone https://github.com/git/git.git
make configure
make
export PATH=/home/user/Downloads/git:$PATH
```
## Build C++ REST SDK
Using a Terminal window with the PATH and devtoolset enabled per the Dependencies.
```
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0
./bootstrap-vcpkg.sh
./vcpkg install cpprestsdk[websockets]
```
## Build RPC
Using a Terminal window with the PATH and devtoolset enabled per the Dependencies.
```
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release -DNO_SELECT=ON ..
cmake --build .
```
To build debug:
```
cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug -DNO_SELECT=ON ..
cmake --build .
```
## Run RPC
Open a Terminal window.
```
cd build
sudo ./rpc --url wss://localhost:8080 --cmd "-t activate --profile profile1"
```
Use --help for more options.

View File

@@ -1,64 +0,0 @@
# Remote Provisioning Client (RPC)
RPC is an application which enables remote capabilities for AMT, such as as device activation. To accomplish this, RPC communicates with the RPS (Remote Provisioning Server).
The steps below assume the following directory structure where **rpc** is the clone of this repository, **vcpkg** is a clone of the VCPKG tool source and **build** is the RPC build directory. Both vcpkg and build directories will be created in later steps.
```
\rpc
|__vcpkg
|__build
```
# Linux
Steps below are for CentOS8.
## Dependencies
### CMake
Install CMake.
```
sudo yum install cmake
```
## Build C++ REST SDK
Using a Terminal window with the PATH and devtoolset enabled per the Dependencies.
```
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0
./bootstrap-vcpkg.sh
./vcpkg install cpprestsdk[websockets]
```
## Build RPC
Using a Terminal window with the PATH and devtoolset enabled per the Dependencies.
```
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
```
To build debug:
```
cmake -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .
```
## Run RPC
Open a Terminal window.
```
cd build
sudo ./rpc --url wss://localhost:8080 --cmd "-t activate --profile profile1"
```
Use --help for more options.

View File

@@ -1,37 +0,0 @@
#*********************************************************************
# Copyright (c) Intel Corporation 2021
# SPDX-License-Identifier: Apache-2.0
#*********************************************************************/
FROM ubuntu:20.04 AS rpc-builder
WORKDIR /
ARG DEBIAN_FRONTEND=noninteractive
RUN \
apt-get update -y -qq && \
apt install -y -qq \
git cmake build-essential libssl-dev zlib1g-dev \
curl unzip zip pkg-config ca-certificates
RUN git clone https://github.com/open-amt-cloud-toolkit/rpc.git
WORKDIR /rpc
RUN mkdir -p build
RUN git clone https://github.com/microsoft/vcpkg.git && cd vcpkg && git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0
RUN cd vcpkg && ./bootstrap-vcpkg.sh
RUN ./vcpkg/vcpkg install cpprestsdk[websockets]
WORKDIR /rpc/build
RUN cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=/rpc/vcpkg/scripts/buildsystems/vcpkg.cmake ..
RUN cmake --build .
FROM ubuntu:20.04
LABEL license='SPDX-License-Identifier: Apache-2.0' \
copyright='Copyright (c) 2021: Intel'
WORKDIR /root
RUN \
apt-get update -y -qq && \
apt install -y -qq \
libssl-dev
COPY --from=rpc-builder /rpc/build/rpc .
ENTRYPOINT ["/root/rpc"]

159
Jenkinsfile vendored
View File

@@ -1,159 +0,0 @@
pipeline {
agent {
label 'docker-amt'
}
options {
buildDiscarder(logRotator(numToKeepStr: '5', daysToKeepStr: '30'))
timestamps()
timeout(unit: 'HOURS', time: 2)
}
stages {
stage ('Cloning Repository') {
steps {
script {
scmCheckout {
clean = true
}
}
}
}
stage('Static Code Scan - Protex') {
environment{
PROJECT_NAME = 'OpenAMT - RPC'
SCANNERS = 'protex'
}
when {
anyOf {
branch 'main';
}
}
steps {
rbheStaticCodeScan()
}
}
stage ('Parallel Builds') {
parallel {
stage ('Linux') {
agent { label 'docker-amt' }
stages {
stage('Build') {
agent {
docker {
image 'ubuntu:18.04'
reuseNode true
}
}
steps {
sh './scripts/jenkins-pre-build.sh'
sh './scripts/jenkins-build.sh'
stash includes: 'build/rpc', name: 'linux-rpc-app'
}
}
stage ('Archive') {
steps {
archiveArtifacts allowEmptyArchive: true, artifacts: 'build/rpc', caseSensitive: false, onlyIfSuccessful: true
}
}
}
}
stage ('Windows') {
agent { label 'openamt-win' }
stages{
stage ('Build') {
steps {
bat 'scripts\\jenkins-pre-build.cmd'
bat 'scripts\\jenkins-build.cmd'
// prepare stash for the binary scan
stash includes: '**/*.exe', name: 'win-rpc-app'
}
}
stage ('Archive') {
steps {
archiveArtifacts allowEmptyArchive: true, artifacts: 'build\\Release\\rpc.exe', caseSensitive: false, onlyIfSuccessful: true
}
}
}
}
}
}
stage('Prep Binary') {
steps {
sh 'mkdir -p ./bin'
dir('./bin') {
unstash 'linux-rpc-app'
unstash 'win-rpc-app'
}
}
}
stage('Linux Scans') {
environment{
PROJECT_NAME = 'OpenAMT - RPC - Linux'
SCANNERS = 'bdba,klocwork'
// protecode details
PROTECODE_BIN_DIR = './bin'
PROTECODE_INCLUDE_SUB_DIRS = true
// klocwork details
KLOCWORK_SCAN_TYPE = 'c++'
KLOCWORK_PRE_BUILD_SCRIPT = './scripts/jenkins-pre-build.sh'
KLOCWORK_BUILD_COMMAND = './scripts/jenkins-build.sh'
KLOCWORK_IGNORE_COMPILE_ERRORS = true
// publishArtifacts details
PUBLISH_TO_ARTIFACTORY = true
}
steps {
rbheStaticCodeScan()
dir('artifacts/Klockwork'){
sh 'cp kw_report.html kw_report_linux.html'
sh 'cp kw_report.csv kw_report_linux.csv'
archiveArtifacts allowEmptyArchive: true, artifacts: 'kw_report_linux.html'
archiveArtifacts allowEmptyArchive: true, artifacts: 'kw_report_linux.csv'
}
}
}
stage('Windows Scans'){
agent { label 'openamt-win' }
stages{
stage ('Windows Scans - klocwork') {
environment {
PROJECT_NAME = 'OpenAMT - RPC - Windows'
SCANNERS = 'klocwork'
// klocwork details
KLOCWORK_SCAN_TYPE = 'c++'
KLOCWORK_PRE_BUILD_SCRIPT = 'scripts\\jenkins-pre-build.cmd'
KLOCWORK_BUILD_COMMAND = 'scripts\\jenkins-build.cmd'
KLOCWORK_IGNORE_COMPILE_ERRORS = true
// publishArtifacts details
PUBLISH_TO_ARTIFACTORY = true
}
steps {
rbheStaticCodeScan()
dir('artifacts\\Klockwork'){
bat 'copy kw_report.html kw_report_windows.html'
bat 'copy kw_report.csv kw_report_windows.csv'
stash includes: 'kw_report_windows.*', name: 'win-kwreports'
archiveArtifacts allowEmptyArchive: true, artifacts: 'kw_report_windows.html'
archiveArtifacts allowEmptyArchive: true, artifacts: 'kw_report_windows.csv'
}
}
}
}
}
stage('Publish Artifacts'){
steps{
dir('artifacts/Klockwork'){
unstash 'win-kwreports'
}
publishArtifacts()
}
}
}
}

201
LICENSE
View File

@@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2019 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -37,10 +37,6 @@ if (${BUILD_LIBRARY})
add_definitions(-D BUILD_LIBRARY)
endif (${BUILD_LIBRARY})
if (${NO_SELECT})
add_definitions(-D NO_SELECT)
endif (${NO_SELECT})
add_definitions( -D_POSIX )
else (UNIX)
@@ -187,5 +183,16 @@ target_link_libraries (
endif (BUILD_LIBRARY)
endif (UNIX)

View File

@@ -105,17 +105,13 @@ static ssize_t mei_recv_msg(struct mei *me, unsigned char *buffer, ssize_t len,
static ssize_t mei_send_msg(struct mei *me, const unsigned char *buffer, ssize_t len, unsigned long timeout)
{
#ifndef NO_SELECT
struct timeval tv;
#endif
ssize_t written;
ssize_t rc;
fd_set set;
#ifndef NO_SELECT
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000000;
#endif
mei_msg(me, "call write length = %zd, cmd=%d\n", len, (int)buffer[0]);
@@ -127,7 +123,7 @@ static ssize_t mei_send_msg(struct mei *me, const unsigned char *buffer, ssize_t
mei_err(me, "write failed with status %zd %s\n", written, strerror(errno));
goto out;
}
#ifndef NO_SELECT
FD_ZERO(&set);
FD_SET(me->fd, &set);
rc = select(me->fd + 1 , NULL, &set, NULL, &tv);
@@ -140,7 +136,7 @@ static ssize_t mei_send_msg(struct mei *me, const unsigned char *buffer, ssize_t
mei_err(me, "write failed on select with status %zd\n", rc);
goto out;
}
#endif
rc = written;
out:
sem_post(&(me->Lock));

View File

@@ -147,10 +147,6 @@ const PTHI_MESSAGE_HEADER SET_HOST_FQDN_HEADER = {
{AMT_MAJOR_VERSION, AMT_MAJOR_VERSION}, 0, {{SET_HOST_FQDN_REQUEST}}, 0
};
const PTHI_MESSAGE_HEADER GET_FQDN_HEADER = {
{AMT_MAJOR_VERSION, AMT_MAJOR_VERSION}, 0, {{GET_FQDN_REQUEST}}, 0
};
const PTHI_MESSAGE_HEADER GET_LOCAL_SYSTEM_ACCOUNT_HEADER = {
{AMT_MAJOR_VERSION, AMT_MINOR_VERSION}, 0, {{GET_LOCAL_SYSTEM_ACCOUNT_REQUEST}}, 40
};
@@ -206,7 +202,10 @@ AMT_STATUS _call(const unsigned char *command, UINT32 command_size, UINT8 **read
{
return status;
}
if ((expSize != 0) && (expSize != outBuffSize))
{
return PTSDK_STATUS_INTERNAL_ERROR;
}
return AMT_STATUS_SUCCESS;
}
@@ -1360,54 +1359,6 @@ AMT_STATUS pthi_SetHostFQDN(char* str)
return status;
}
/*
* Gets host FQDN in AMT Calls to CFG_SET_HOST_FQDN_REQUEST command
* Arguments:
* host - host FQDN
* Return values:
* AMT_STATUS_SUCCESS - on success
* PTSDK_STATUS_INTERNAL_ERROR - on failure
*/
AMT_STATUS pthi_GetHostFQDN(CFG_GET_FQDN_RESPONSE* fqdn)
{
AMT_STATUS status;
UINT8* readBuffer = NULL;
UINT32 command_size = sizeof(CFG_GET_HOST_FQDN_REQUEST);
CFG_GET_HOST_FQDN_REQUEST command;
CFG_GET_FQDN_RESPONSE* tmp_response;
memset(&command, 0, sizeof(CFG_GET_HOST_FQDN_REQUEST));
memcpy_s((UINT8*)&command, sizeof(command), (char*)&(GET_FQDN_HEADER), sizeof(GET_FQDN_HEADER));
status = _call((UINT8*)&command, command_size, &readBuffer, GET_FQDN_RESPONSE, sizeof(CFG_GET_FQDN_RESPONSE) - sizeof(char *));
// tes
if (status == AMT_STATUS_SUCCESS)
{
tmp_response = (CFG_GET_FQDN_RESPONSE*)readBuffer;
memcpy_s(&(fqdn->Header), sizeof(PTHI_MESSAGE_HEADER), (char*)&(tmp_response->Header), sizeof(PTHI_MESSAGE_HEADER));
fqdn->Status = tmp_response->Status;
fqdn->SharedFQDN = tmp_response->SharedFQDN;
fqdn->DDNSUpdateEnabled = tmp_response->DDNSUpdateEnabled;
fqdn->DDNSPeriodicUpdateInterval = tmp_response->DDNSPeriodicUpdateInterval;
fqdn->DDNSTTL = tmp_response->DDNSTTL;
fqdn->FQDN.Length = tmp_response->FQDN.Length;
fqdn->FQDN.Buffer = (CHAR*)malloc(fqdn->FQDN.Length * sizeof(CHAR));
if (NULL == fqdn->FQDN.Buffer) {
status = AMT_STATUS_INTERNAL_ERROR;
}
else {
memcpy_s(fqdn->FQDN.Buffer,
fqdn->FQDN.Length * sizeof(CHAR),
&(tmp_response->FQDN.Buffer),
tmp_response->FQDN.Length * sizeof(CHAR));
}
}
if (readBuffer != NULL) free(readBuffer);
return status;
}
/*

View File

@@ -509,18 +509,6 @@ typedef struct _AMT_PROV_AUDIT_RECORD
AMT_ANSI_STRING ProvServerFQDN;
} AMT_PROV_AUDIT_RECORD;
typedef struct
{
PTHI_MESSAGE_HEADER Header;
AMT_STATUS Status;
AMT_BOOLEAN SharedFQDN;
AMT_BOOLEAN DDNSUpdateEnabled;
UINT32 DDNSPeriodicUpdateInterval;
UINT32 DDNSTTL;
UINT32 HostNameLength;
AMT_ANSI_STRING FQDN;
} CFG_GET_FQDN_RESPONSE;
typedef struct _CFG_GENERATE_RNG_SEED_RESPONSE
{
PTHI_RESPONSE_MESSAGE_HEADER Header;
@@ -595,11 +583,6 @@ typedef struct CFG_SET_HOST_FQDN_REQUEST
char FQDN[256];
}CFG_SET_HOST_FQDN_REQUEST;
typedef struct CFG_GET_HOST_FQDN_REQUEST
{
PTHI_MESSAGE_HEADER Header;
} CFG_GET_HOST_FQDN_REQUEST;
typedef struct _CFG_SET_HOST_FQDN_RESPONSE
{
PTHI_MESSAGE_HEADER Header;
@@ -695,7 +678,6 @@ AMT_STATUS pthi_EnumerateHashHandles(AMT_HASH_HANDLES *hashHandles);
AMT_STATUS pthi_GetCertificateHashEntry(UINT32 hashHandle, CERTHASH_ENTRY *hashEntry);
AMT_STATUS pthi_GetDnsSuffix(AMT_ANSI_STRING *dnsSuffix);
AMT_STATUS pthi_SetHostFQDN(char* str);
AMT_STATUS pthi_GetHostFQDN(CFG_GET_FQDN_RESPONSE* fqdn);
AMT_STATUS pthi_GetLocalSystemAccount(LOCAL_SYSTEM_ACCOUNT *localAccount);
AMT_STATUS pthi_Unprovision(CFG_PROVISIONING_MODE provisionMode);
AMT_STATUS pthi_GetStateEHBC(AMT_EHBC_STATE *state);
@@ -808,10 +790,6 @@ const PTHI_MESSAGE_HEADER GET_FEATURES_STATE_HEADER;
#define SET_HOST_FQDN_RESPONSE 0x0480005b
//const PTHI_MESSAGE_HEADER GET_PKI_FQDN_SUFFIX_HEADER;
#define GET_FQDN_REQUEST 0x4000056
#define GET_FQDN_RESPONSE 0x4800056
#define GET_LOCAL_SYSTEM_ACCOUNT_REQUEST 0x04000067
#define GET_LOCAL_SYSTEM_ACCOUNT_RESPONSE 0x04800067
//const PTHI_MESSAGE_HEADER GET_LOCAL_SYSTEM_ACCOUNT_HEADER;

View File

@@ -1,46 +1,27 @@
# Remote Provisioning Client
> Disclaimer: Production viable releases are tagged and listed under 'Releases'. All other check-ins should be considered 'in-development' and should not be used in production
The Remote Provisioning Client (RPC) is an application that enables remote capabilities for Intel® AMT, such as as device activation and configuration. To accomplish this, RPC communicates with the Remote Provisioning Server (RPS) to activate and connect the edge device.
<br><br>
**For detailed documentation** about RPC or other features of the Open AMT Cloud Toolkit, see the [docs](https://open-amt-cloud-toolkit.github.io/docs/).
<br>
**For detailed documentation** about RPC or other features of the Open AMT Cloud Toolkit, see the [docs](https://open-amt-cloud-toolkit.github.io/mps/).
## Prerequisites
We leverage GitHub Actions as a means to build RPC automatically leveraging Github's CI/CD Infrastructure. This avoids having to deal with the challenges of getting your build environment just right on your local machine and allows you to get up and running much faster. Read more about GitHub Actions [here](https://github.blog/2019-08-08-github-actions-now-supports-ci-cd/#:~:text=GitHub%20Actions%20is%20an%20API,every%20step%20along%20the%20way.)
## Build the Remote Provisioning Client (RPC)
<p align="center">
<img src="assets/animations/forkandbuild.gif" width="650" />
</p>
## Build the Remote Provisioning Client (RPC)
1. Create a fork of the rpc repository [here](https://github.com/open-amt-cloud-toolkit/rpc/fork) or via the Fork button in the top-right corner of the rpc repository.
1. <a href="https://github.com/open-amt-cloud-toolkit/rpc/fork" target="_blank">Create a fork of rpc on GitHub.</a>
2. Click on "Actions" and Select "Build RPC (Native)" Workflow.
2. Click on the **Actions** tab at the top and select **Build RPC (Native) Debug/Release**.
3. Click "Run Workflow", select branch "master", and click "Run Workflow".
3. Click the **Run Workflow** dropdown.
4. Grab a coffee. The build for Windows will take approximately 30 minutes and the build for Linux will take approximately 5 minutes.
4. Select the **Branch: main**, or a preferred version, from the **Use workflow from** dropdown.
5. Once complete, click the completed job, and download the appropriate RPC for your OS under the "Artifacts" section.
5. By default, the Build Type should be **release**.
6. Click the **Run Workflow** button. Grab a coffee and take a break! The build time ranges from 15 to 20 minutes.
8. Once the download is complete, click the completed job which will feature a green checkmark.
9. Download the appropriate RPC for your managed device's OS under the **Artifacts** section.
### To Delete your workflow run
1. Click the ellipsis ( **...** ) menu for the workflow.
2. Choose the **Delete workflow run** option.
For detailed documentation about RPC and using it to activate a device, see the [docs](https://open-amt-cloud-toolkit.github.io/docs/)
For detailed documentation about RPC and using it to activate a device, see the [docs](https://open-amt-cloud-toolkit.github.io/mps/)

View File

@@ -1,5 +0,0 @@
# Security Policy
Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation.
## Reporting a Vulnerability
Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html).

View File

@@ -60,8 +60,22 @@ std::string get_dns_info()
if (!dnsSuffix.length())
{
// get DNS from OS
dnsSuffix = net_get_dns();
std::vector<unsigned char> address;
cmd_get_wired_mac_address(address);
if (address.size() == 6)
{
char macAddress[6];
macAddress[0] = address[0];
macAddress[1] = address[1];
macAddress[2] = address[2];
macAddress[3] = address[3];
macAddress[4] = address[4];
macAddress[5] = address[5];
// get DNS from OS
dnsSuffix = net_get_dns(macAddress);
}
}
return dnsSuffix;
@@ -77,16 +91,6 @@ web::json::value get_dns()
return web::json::value::string(tmp);
}
web::json::value get_hostname()
{
utility::string_t tmp;
std::string hostName = net_get_hostname();
tmp = utility::conversions::convertstring(hostName);
return web::json::value::string(tmp);
}
bool getVersion(web::json::value& value)
{
std::string version;
@@ -212,9 +216,6 @@ bool get_activation_payload(web::json::value& payload)
// get DNS Info
activationParams[U("fqdn")] = get_dns();
// get hostname
activationParams[U("hostname")] = get_hostname();
// get client string
if (!get_client_string(value)) return false;
activationParams[U("client")] = value;
@@ -236,7 +237,7 @@ bool act_create_request(std::string commands, std::string dns_suffix, std::strin
utility::string_t tmp = utility::conversions::convertstring(commands);
msg[U("method")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
tmp = utility::conversions::convertstring("key");
msg[U("apiKey")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring(PROJECT_VER);
@@ -245,10 +246,10 @@ bool act_create_request(std::string commands, std::string dns_suffix, std::strin
tmp = utility::conversions::convertstring(PROTOCOL_VERSION);
msg[U("protocolVersion")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
tmp = utility::conversions::convertstring("ok");
msg[U("status")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
tmp = utility::conversions::convertstring("ok");
msg[U("message")] = web::json::value::string(tmp);
// get the activation payload
@@ -281,7 +282,7 @@ bool act_create_response(std::string payload, std::string& response)
utility::string_t tmp = utility::conversions::convertstring("response");
msg[U("method")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
tmp = utility::conversions::convertstring("key");
msg[U("apiKey")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring(PROJECT_VER);
@@ -290,10 +291,10 @@ bool act_create_response(std::string payload, std::string& response)
tmp = utility::conversions::convertstring(PROTOCOL_VERSION);
msg[U("protocolVersion")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
tmp = utility::conversions::convertstring("ok");
msg[U("status")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
tmp = utility::conversions::convertstring("ok");
msg[U("message")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring(util_encode_base64(payload));
@@ -303,4 +304,3 @@ bool act_create_response(std::string payload, std::string& response)
return true;
}

View File

@@ -8,7 +8,7 @@
#include <string>
#define PROTOCOL_VERSION "4.0.0"
#define PROTOCOL_VERSION "3.0.0"
#ifdef _WIN32
#define convertstring to_utf16string

View File

@@ -126,9 +126,4 @@ bool args_get_info(int argc, char* argv[], std::string& info)
bool args_get_verbose(int argc, char* argv[])
{
return get_arg_exists(argc, argv, "--verbose", "-v");
}
bool args_get_nocertcheck(int argc, char* argv[])
{
return get_arg_exists(argc, argv, "--nocertcheck", "-n");
}
}

1
args.h
View File

@@ -16,6 +16,5 @@ bool args_get_cmd(int argc, char* argv[], std::string& cmd);
bool args_get_dns(int argc, char* argv[], std::string& dns);
bool args_get_info(int argc, char* argv[], std::string& info);
bool args_get_verbose(int argc, char* argv[]);
bool args_get_nocertcheck(int argc, char* argv[]);
#endif

View File

@@ -179,37 +179,6 @@ bool cmd_get_control_mode(int& mode)
return false;
}
bool cmd_get_fqdn(fqdn_settings& fqdn_settings)
{
fqdn_settings.fqdn.clear();
// initialize HECI interface
if (heci_Init(NULL, PTHI_CLIENT) == 0) return false;
// get fqdn
CFG_GET_FQDN_RESPONSE fqdn;
memset(&fqdn, 0, sizeof(CFG_GET_FQDN_RESPONSE));
AMT_STATUS amt_status = pthi_GetHostFQDN(&fqdn);
if (amt_status == 0)
{
fqdn_settings.ddns_ttl = fqdn.DDNSTTL;
fqdn_settings.ddns_update_enabled = fqdn.DDNSUpdateEnabled;
fqdn_settings.ddns_update_interval = fqdn.DDNSPeriodicUpdateInterval;
if (fqdn.FQDN.Length > 0)
{
fqdn_settings.fqdn = std::string(fqdn.FQDN.Buffer, fqdn.FQDN.Length);
free(fqdn.FQDN.Buffer);
}
return true;
}
return false;
}
bool cmd_get_dns_suffix(std::string& suffix)
{
suffix.clear();
@@ -282,54 +251,51 @@ bool cmd_get_certificate_hashes(std::vector<cert_hash_entry>& hash_entries)
for (int i = 0; i < (int) amt_hash_handles.Length; i++)
{
// get each entry
AMT_STATUS amt_status = pthi_GetCertificateHashEntry(amt_hash_handles.Handles[i], &certhash_entry);
AMT_STATUS status = pthi_GetCertificateHashEntry(amt_hash_handles.Handles[i], &certhash_entry);
if (amt_status == 0)
int hashSize;
cert_hash_entry tmp;
switch (certhash_entry.HashAlgorithm) {
case 0: // MD5
hashSize = 16;
tmp.algorithm = "MD5";
break;
case 1: // SHA1
hashSize = 20;
tmp.algorithm = "SHA1";
break;
case 2: // SHA256
hashSize = 32;
tmp.algorithm = "SHA256";
break;
case 3: // SHA512
hashSize = 64;
tmp.algorithm = "SHA512";
break;
default:
hashSize = 0;
tmp.algorithm = "UNKNOWN";
break;
}
if (certhash_entry.IsActive == 1)
{
int hashSize;
cert_hash_entry tmp;
switch (certhash_entry.HashAlgorithm) {
case 0: // MD5
hashSize = 16;
tmp.algorithm = "MD5";
break;
case 1: // SHA1
hashSize = 20;
tmp.algorithm = "SHA1";
break;
case 2: // SHA256
hashSize = 32;
tmp.algorithm = "SHA256";
break;
case 3: // SHA512
hashSize = 64;
tmp.algorithm = "SHA512";
break;
default:
hashSize = 0;
tmp.algorithm = "UNKNOWN";
break;
}
std::string cert_name(certhash_entry.Name.Buffer, certhash_entry.Name.Length);
tmp.name = cert_name;
tmp.is_default = certhash_entry.IsDefault;
tmp.is_active = certhash_entry.IsActive;
if (certhash_entry.IsActive == 1)
std::string hashString;
for (int i = 0; i < hashSize; i++)
{
std::string cert_name(certhash_entry.Name.Buffer, certhash_entry.Name.Length);
tmp.name = cert_name;
tmp.is_default = certhash_entry.IsDefault;
tmp.is_active = certhash_entry.IsActive;
std::string hashString;
for (int i = 0; i < hashSize; i++)
{
char hex[10];
snprintf(hex, 10, "%02x", certhash_entry.CertificateHash[i]);
hashString += hex;
}
tmp.hash = hashString;
hash_entries.push_back(tmp);
char hex[10];
snprintf(hex, 10, "%02x", certhash_entry.CertificateHash[i]);
hashString += hex;
}
tmp.hash = hashString;
hash_entries.push_back(tmp);
}
}
@@ -380,29 +346,26 @@ bool cmd_get_remote_access_connection_status(int& network_status, int& remote_st
return false;
}
bool cmd_get_lan_interface_settings(lan_interface_settings& lan_interface_settings, bool wired_interface)
bool cmd_get_lan_interface_settings(lan_interface_settings& lan_interface_settings)
{
// initialize HECI interface
if (heci_Init(NULL, PTHI_CLIENT) == 0) return false;
// get wired interface
LAN_SETTINGS lan_settings;
UINT32 interface_settings = (wired_interface) ? 0 : 1; // wired=0, wireless=1
UINT32 interface_settings = 0; // wired=0, wireless=1
AMT_STATUS amt_status = pthi_GetLanInterfaceSettings(interface_settings, &lan_settings);
if (amt_status == 0)
{
lan_interface_settings.is_enabled = lan_settings.Enabled;
lan_interface_settings.dhcp_mode = lan_settings.DhcpIpMode;
lan_interface_settings.dhcp_enabled = lan_settings.DhcpEnabled;
lan_interface_settings.link_status = lan_settings.LinkStatus;
lan_interface_settings.ip_address.clear();
lan_interface_settings.ip_address.push_back((lan_settings.Ipv4Address >> 24) & 0xff);
lan_interface_settings.ip_address.push_back((lan_settings.Ipv4Address >> 16) & 0xff);
lan_interface_settings.ip_address.push_back((lan_settings.Ipv4Address >> 8) & 0xff);
lan_interface_settings.ip_address.push_back((lan_settings.Ipv4Address) & 0xff);
lan_interface_settings.mac_address.clear();
lan_interface_settings.mac_address.push_back(lan_settings.MacAddress[0]);
lan_interface_settings.mac_address.push_back(lan_settings.MacAddress[1]);
lan_interface_settings.mac_address.push_back(lan_settings.MacAddress[2]);

View File

@@ -28,15 +28,6 @@ struct lan_interface_settings
std::vector<unsigned char> mac_address;
};
struct fqdn_settings
{
bool shared_fqdn;
bool ddns_update_enabled;
int ddns_update_interval;
int ddns_ttl;
std::string fqdn;
};
bool cmd_is_admin();
bool cmd_get_version(std::string& version);
bool cmd_get_build_number(std::string& version);
@@ -44,11 +35,10 @@ bool cmd_get_sku(std::string& version);
bool cmd_get_uuid(std::vector<unsigned char>& uuid);
bool cmd_get_local_system_account(std::string& username, std::string& password);
bool cmd_get_control_mode(int& mode);
bool cmd_get_fqdn(fqdn_settings& fqdn_settings);
bool cmd_get_dns_suffix(std::string& suffix);
bool cmd_get_wired_mac_address(std::vector<unsigned char>& address);
bool cmd_get_certificate_hashes(std::vector<cert_hash_entry>& hash_entries);
bool cmd_get_remote_access_connection_status(int& network_status, int& remote_status, int& remote_trigger, std::string& mps_hostname);
bool cmd_get_lan_interface_settings(lan_interface_settings& lan_interface_settings, bool wired_interface = true);
bool cmd_get_lan_interface_settings(lan_interface_settings& lan_interface_settings);
#endif

View File

@@ -1,15 +0,0 @@
cmake_minimum_required(VERSION 2.8.12)
project(googletest-download NONE)
include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.10.0
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)

View File

@@ -1,48 +0,0 @@
/*********************************************************************
* Copyright (c) Intel Corporation 2019 - 2020
* SPDX-License-Identifier: Apache-2.0
**********************************************************************/
#include "heartbeat.h"
#include <cpprest/ws_client.h>
#include <cpprest/json.h>
#include <cpprest/streams.h>
#include <iostream>
#include <string>
#include "activation.h"
#include "version.h"
#include "commands.h"
#include "network.h"
#include "utils.h"
bool heartbeat_create_response(std::string& response)
{
web::json::value msg;
utility::string_t tmp = utility::conversions::convertstring("heartbeat_response");
msg[U("method")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
msg[U("apiKey")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring(PROJECT_VER);
msg[U("appVersion")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring(PROTOCOL_VERSION);
msg[U("protocolVersion")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("success");
msg[U("status")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
msg[U("message")] = web::json::value::string(tmp);
// set empty payload
tmp = utility::conversions::convertstring("");
msg[U("payload")] = web::json::value::string(tmp);
// serialize the entire message
response = utility::conversions::to_utf8string(msg.serialize());
return true;
}

View File

@@ -1,13 +0,0 @@
/*********************************************************************
* Copyright (c) Intel Corporation 2019 - 2020
* SPDX-License-Identifier: Apache-2.0
**********************************************************************/
#ifndef __HEARTBEAT_H__
#define __HEARTBEAT_H__
#include <string>
bool heartbeat_create_response(std::string& response);
#endif

View File

@@ -9,7 +9,6 @@
#include <iomanip>
#include "commands.h"
#include "utils.h"
#include "network.h"
const int PADDING = 25;
@@ -20,7 +19,7 @@ void out_text(const std::string name, const std::vector<unsigned char> value, co
for (unsigned char tmp : value)
{
(hex) ? std::cout << std::setfill('0') << std::setw(2) << std::hex << (unsigned int)tmp
: std::cout << std::dec << (unsigned int)tmp;
: std::cout << (unsigned int)tmp;
if (char_count++ < value.size())
{
@@ -125,29 +124,6 @@ bool info_get_dns_suffix()
out_text("DNS Suffix", tmp);
tmp = net_get_dns();
out_text("DNS Suffix (OS)", tmp);
return true;
}
bool info_get_fqdn()
{
fqdn_settings fqdn;
if (cmd_get_fqdn(fqdn))
{
out_text("FQDN", fqdn.fqdn);
}
std::string tmp;
std::string dns;
tmp = net_get_hostname();
out_text("Hostname (OS)", tmp);
return true;
}
@@ -177,19 +153,20 @@ bool info_get_certificate_hashes()
bool info_get_all()
{
std::vector<std::string> tmp;
bool status_ver = info_get_version();
bool status_bld = info_get_build_number();
bool status_sku = info_get_sku();
bool status_uuid = info_get_uuid();
bool status_mode = info_get_control_mode();
bool status_dns = info_get_dns_suffix();
bool status_fqdn = info_get_fqdn();
bool status_ras = info_get_remote_access_connection_status();
bool status_lan = info_get_lan_interface_settings();
bool status_cert = info_get_certificate_hashes();
if (status_ver && status_bld && status_sku && status_uuid && status_mode &&
status_dns && status_fqdn && status_ras && status_lan && status_cert)
status_dns && status_ras && status_lan && status_cert)
{
return true;
}
@@ -263,48 +240,15 @@ bool info_get_lan_interface_settings()
{
lan_interface_settings tmp;
tmp.is_enabled = false;
tmp.link_status = false;
tmp.dhcp_enabled = false;
tmp.dhcp_mode = 0;
tmp.ip_address.clear();
tmp.mac_address.clear();
if (!cmd_get_lan_interface_settings(tmp)) return false;
bool hasWired = cmd_get_lan_interface_settings(tmp);
if (hasWired)
{
out_text("LAN Interface", "wired");
out_text("DHCP Enabled", (tmp.dhcp_enabled) ? "true" : "false");
out_text("DHCP Mode", (tmp.dhcp_mode == 1) ? "active" : "passive");
out_text("Link Status", (tmp.link_status) ? "up" : "down");
out_text("IP Address", tmp.ip_address, '.', false);
out_text("MAC Address", tmp.mac_address, ':');
}
tmp.is_enabled = false;
tmp.link_status = false;
tmp.dhcp_enabled = false;
tmp.dhcp_mode = 0;
tmp.ip_address.clear();
tmp.mac_address.clear();
out_text("DHCP Enabled", (tmp.dhcp_enabled) ? "true" : "false");
out_text("DHCP Mode", (tmp.dhcp_mode == 1) ? "active" : "passive");
out_text("Link Status", (tmp.link_status) ? "up" : "down");
out_text("IP Address", tmp.ip_address, '.', false);
out_text("MAC Address", tmp.mac_address, ':');
bool hasWireless = cmd_get_lan_interface_settings(tmp, false);
if (hasWireless)
{
out_text("LAN Interface", "wireless");
out_text("DHCP Enabled", (tmp.dhcp_enabled) ? "true" : "false");
out_text("DHCP Mode", (tmp.dhcp_mode == 1) ? "active" : "passive");
out_text("Link Status", (tmp.link_status) ? "up" : "down");
out_text("IP Address", tmp.ip_address, '.', false);
out_text("MAC Address", tmp.mac_address, ':');
}
if (hasWired || hasWireless)
{
return true;
}
return false;
return true;
}
bool info_get(const std::string info)
@@ -333,10 +277,6 @@ bool info_get(const std::string info)
{
return info_get_dns_suffix();
}
else if (info.compare("fqdn") == 0)
{
return info_get_fqdn();
}
else if (info.compare("cert") == 0)
{
return info_get_certificate_hashes();
@@ -359,13 +299,13 @@ bool info_get(const std::string info)
bool info_get_verify(const std::string info)
{
if ((info.compare("ver") == 0) || (info.compare("bld") == 0) || (info.compare("sku") == 0) ||
(info.compare("uuid") == 0) || (info.compare("mode") == 0) || (info.compare("fqdn") == 0) ||
(info.compare("dns") == 0) || (info.compare("cert") == 0) || (info.compare("ras") == 0) ||
(info.compare("lan") == 0) || (info.compare("all") == 0))
if ((info.compare("ver") == 0) || (info.compare("bld") == 0) || (info.compare("sku") == 0) ||
(info.compare("uuid") == 0) || (info.compare("mode") == 0) || (info.compare("dns") == 0) ||
(info.compare("cert") == 0) || (info.compare("ras") == 0) || (info.compare("lan") == 0) ||
(info.compare("all") == 0))
{
return true;
}
return false;
}
}

1
info.h
View File

@@ -16,7 +16,6 @@ bool info_get_sku();
bool info_get_uuid();
bool info_get_control_mode();
bool info_get_dns_suffix();
bool info_get_fqdn();
bool info_get_all();
bool info_get_remote_access_connection_status();
bool info_get_lan_interface_settings();

View File

@@ -7,12 +7,10 @@
#include <thread>
#include <cpprest/ws_client.h>
#include <cpprest/json.h>
#include <algorithm>
#include "port.h"
#include "lms.h"
#include "commands.h"
#include "activation.h"
#include "heartbeat.h"
#include "utils.h"
#include "usage.h"
#include "args.h"
@@ -62,7 +60,6 @@ int main(int argc, char* argv[])
std::string arg_dns;
std::string arg_info;
bool arg_verbose = false;
bool arg_nocertcheck = false;
if (argc == 1)
{
@@ -119,13 +116,6 @@ int main(int argc, char* argv[])
arg_verbose = true;
}
// no websocket server certificate verification
if (args_get_nocertcheck(argc, argv))
{
arg_nocertcheck = true;
}
// Print version info
usage_show_version();
@@ -170,15 +160,11 @@ int main(int argc, char* argv[])
{
client_config.set_proxy(web::web_proxy(utility::conversions::to_string_t(arg_proxy)));
}
// websocket server certificate verification
if (arg_nocertcheck)
{
// skip websocket server certificate verification
std::cout << "Skipping certificate verification." << std::endl;
client_config.set_validate_certificates(false);
}
#ifdef DEBUG
// skip certificate verification if debug build
std::cout << "Skipping certificate verification." << std::endl;
client_config.set_validate_certificates(false);
#endif
web::websockets::client::websocket_callback_client client(client_config);
std::condition_variable cv;
std::mutex mx;
@@ -248,70 +234,25 @@ int main(int argc, char* argv[])
return;
}
if (msgMethod.compare("heartbeat_request") == 0)
{
// create the response
std::string response;
if (!heartbeat_create_response(response)) return;
// send it
web::websockets::client::websocket_outgoing_message send_websocket_msg;
std::string send_websocket_buffer(response);
send_websocket_msg.set_utf8_message(send_websocket_buffer);
client.send(send_websocket_msg).wait();
return;
}
// process any messages we can
// - if success, done
// - if error, get out
if (msgStatus.compare("success")==0)
if (msgMethod.compare("success")==0)
{
// cleanup
g_timeout_val = 0;
// exit
try {
std::cout << std::endl;
utility::string_t tmp = utility::conversions::convertstring(msgMessage);
web::json::value parsed = web::json::value::parse(tmp);
for (const auto& obj : parsed.as_object()) {
std::string key = utility::conversions::to_utf8string(obj.first);
std::string value = utility::conversions::to_utf8string(obj.second.serialize());
value.erase(std::remove(value.begin(), value.end(), '"'), value.end());
std::cout << key << ": " << value << std::endl;
}
}
catch (...)
{
std::cout << std::endl << msgMessage << std::endl;
}
std::cout << std::endl << msgMessage << std::endl;
return;
}
else if (msgStatus.compare("failed")==0)
else if (msgMethod.compare("error")==0)
{
// cleanup
g_timeout_val = 0;
// exit
try {
std::cout << std::endl;
utility::string_t tmp = utility::conversions::convertstring(msgMessage);
web::json::value parsed = web::json::value::parse(tmp);
for (const auto& obj : parsed.as_object()) {
std::string key = utility::conversions::to_utf8string(obj.first);
std::string value = utility::conversions::to_utf8string(obj.second.serialize());
value.erase(std::remove(value.begin(), value.end(), '"'), value.end());
std::cout << key << ": " << value << std::endl;
}
}
catch (...)
{
std::cout << std::endl << msgMessage << std::endl;
}
std::cout << std::endl << msgMessage << std::endl;
return;
}

View File

@@ -4,9 +4,7 @@
**********************************************************************/
#include "network.h"
#include "commands.h"
#include <iostream>
#include <vector>
#ifdef _WIN32
#include <winsock2.h>
@@ -183,58 +181,5 @@ std::string net_get_dns(char* macAddress)
return dnsSuffix;
}
#endif
std::string net_get_hostname()
{
char hostname[256];
std::string hostname_string = "";
int result;
#ifdef WIN32
WSADATA wsa;
if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0)
{
throw std::runtime_error("error: network error");
}
#endif
// get hostname
result = gethostname(hostname, sizeof(hostname));
#ifdef WIN32
WSACleanup();
#endif
if (result == 0)
{
hostname_string = hostname;
}
return hostname_string;
}
std::string net_get_dns()
{
std::string dns_suffix;
std::vector<unsigned char> address;
cmd_get_wired_mac_address(address);
if (address.size() == 6)
{
char macAddress[6];
macAddress[0] = address[0];
macAddress[1] = address[1];
macAddress[2] = address[2];
macAddress[3] = address[3];
macAddress[4] = address[4];
macAddress[5] = address[5];
// get DNS from OS
dns_suffix = net_get_dns(macAddress);
}
return dns_suffix;
}
#endif

View File

@@ -9,7 +9,5 @@
#include <string>
std::string net_get_dns(char* macAddress);
std::string net_get_hostname();
std::string net_get_dns();
#endif

View File

@@ -1,26 +0,0 @@
:: Build script
:: - Windows 10
:: - Visual Studio 2019
:: - Git
::
:: IMPORTANT!!!
:: Open "x64 Native Command Tool Prompt for VS 2019" as Administrator.
::
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
REM current dir - RPC source directory
set BASE_DIR=%cd%
set VCPKG_DIR=C:\opt\vcpkg-source
REM build RPC
if exist "build" rd /q /s "build"
mkdir build
cd build
echo %VCPKG_DIR%\vcpkg\scripts\buildsystems\vcpkg.cmake
cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_TOOLCHAIN_FILE=%VCPKG_DIR%\vcpkg\scripts\buildsystems\vcpkg.cmake ..
cmake --build . --config Release
dir %BASE_DIR%\build

View File

@@ -1,19 +0,0 @@
#!/bin/bash
set -x
# Jenkins Build script
# - Ubuntu 18.04
#
export BASE_DIR="$PWD"
export CMAKE_CXX_FLAGS="-isystem /usr/lib/gcc/x86_64-linux-gnu/7/include"
if [ -d "build" ]; then
rm -rf build
fi
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE="$BASE_DIR"/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .

View File

@@ -1,24 +0,0 @@
:: Build script
:: - Windows 10
:: - Visual Studio 2019
:: - Git
::
:: IMPORTANT!!!
:: Open "x64 Native Command Tool Prompt for VS 2019" as Administrator.
::
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
REM current dir - RPC source directory
set VCPKG_DIR=C:\opt\vcpkg-source
cd %VCPKG_DIR%
REM build vcpkg
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0
cmd /c bootstrap-vcpkg.bat
REM install CPPRestSDK
cmd /c vcpkg install cpprestsdk[websockets]:x64-windows-static

View File

@@ -1,21 +0,0 @@
#!/bin/bash
# Jenkins Pre Build script
# - Ubuntu 18.04
#
apt update
apt install git cmake build-essential curl zip unzip tar pkg-config -y
## current dir - RPC source directory
#export BASE_DIR="$PWD"
#cd "$BASE_DIR"/rpc
## build vcpkg
git -C vcpkg pull || git clone https://github.com/microsoft/vcpkg.git vcpkg
cd vcpkg
git checkout 772d435ba18bf2f342458e0187ab7b48b84fe3f0
./bootstrap-vcpkg.sh
## install CPPRestSDK
./vcpkg install cpprestsdk[websockets]

View File

@@ -1,89 +0,0 @@
/*********************************************************************
* Copyright (c) Intel Corporation 2019 - 2020
* SPDX-License-Identifier: Apache-2.0
**********************************************************************/
#include "gtest/gtest.h"
#include <string>
#include <thread>
#include <cpprest/ws_client.h>
#include <cpprest/json.h>
#include "port.h"
#include "utils.h"
const std::string plainText = "Ut aliquet ex id enim accumsan bibendum. Nullam nibh ligula, rhoncus vitae nisl eu, fermentum luctus tellus. Sed non semper augue, vitae congue nibh. Suspendisse sed placerat metus. Nunc a sapien vel nisl semper fringilla. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam accumsan, nisi vitae efficitur ultricies, velit neque mattis velit, sed sodales tellus est at orci. Duis sed ipsum lorem. In eu enim eu odio fringilla lacinia id id lorem. Vestibulum velit augue, ultricies et neque eget, molestie vehicula urna. Etiam venenatis nibh vel nunc fringilla, vitae feugiat ipsum posuere. Pellentesque ac libero quis nulla pretium iaculis sed at felis. Integer malesuada turpis eget lectus interdum, a commodo nisl tristique. Proin rutrum nisl ut metus aliquam, vel lacinia tortor ullamcorper. Nulla rhoncus ullamcorper accumsan. Fusce eget augue vulputate, porta quam at, laoreet justo.";
const std::string encodedText = "VXQgYWxpcXVldCBleCBpZCBlbmltIGFjY3Vtc2FuIGJpYmVuZHVtLiBOdWxsYW0gbmliaCBsaWd1bGEsIHJob25jdXMgdml0YWUgbmlzbCBldSwgZmVybWVudHVtIGx1Y3R1cyB0ZWxsdXMuIFNlZCBub24gc2VtcGVyIGF1Z3VlLCB2aXRhZSBjb25ndWUgbmliaC4gU3VzcGVuZGlzc2Ugc2VkIHBsYWNlcmF0IG1ldHVzLiBOdW5jIGEgc2FwaWVuIHZlbCBuaXNsIHNlbXBlciBmcmluZ2lsbGEuIFBlbGxlbnRlc3F1ZSBoYWJpdGFudCBtb3JiaSB0cmlzdGlxdWUgc2VuZWN0dXMgZXQgbmV0dXMgZXQgbWFsZXN1YWRhIGZhbWVzIGFjIHR1cnBpcyBlZ2VzdGFzLiBBbGlxdWFtIGFjY3Vtc2FuLCBuaXNpIHZpdGFlIGVmZmljaXR1ciB1bHRyaWNpZXMsIHZlbGl0IG5lcXVlIG1hdHRpcyB2ZWxpdCwgc2VkIHNvZGFsZXMgdGVsbHVzIGVzdCBhdCBvcmNpLiBEdWlzIHNlZCBpcHN1bSBsb3JlbS4gSW4gZXUgZW5pbSBldSBvZGlvIGZyaW5naWxsYSBsYWNpbmlhIGlkIGlkIGxvcmVtLiBWZXN0aWJ1bHVtIHZlbGl0IGF1Z3VlLCB1bHRyaWNpZXMgZXQgbmVxdWUgZWdldCwgbW9sZXN0aWUgdmVoaWN1bGEgdXJuYS4gRXRpYW0gdmVuZW5hdGlzIG5pYmggdmVsIG51bmMgZnJpbmdpbGxhLCB2aXRhZSBmZXVnaWF0IGlwc3VtIHBvc3VlcmUuIFBlbGxlbnRlc3F1ZSBhYyBsaWJlcm8gcXVpcyBudWxsYSBwcmV0aXVtIGlhY3VsaXMgc2VkIGF0IGZlbGlzLiBJbnRlZ2VyIG1hbGVzdWFkYSB0dXJwaXMgZWdldCBsZWN0dXMgaW50ZXJkdW0sIGEgY29tbW9kbyBuaXNsIHRyaXN0aXF1ZS4gUHJvaW4gcnV0cnVtIG5pc2wgdXQgbWV0dXMgYWxpcXVhbSwgdmVsIGxhY2luaWEgdG9ydG9yIHVsbGFtY29ycGVyLiBOdWxsYSByaG9uY3VzIHVsbGFtY29ycGVyIGFjY3Vtc2FuLiBGdXNjZSBlZ2V0IGF1Z3VlIHZ1bHB1dGF0ZSwgcG9ydGEgcXVhbSBhdCwgbGFvcmVldCBqdXN0by4=";
// Test if characters are printable
TEST(testUtils, isPrintableTestValid)
{
std::string s = "The quick brown fox jumps over the lazy dog.";
EXPECT_EQ(true, util_is_printable(s));
}
// Test if characters are printable
TEST(testUtils, isPrintableTestInvalid)
{
std::string s = "The quick brown fox jumps over the lazy dog.";
s[0] = 10; // non-printable character
EXPECT_EQ(false, util_is_printable(s));
}
// Test encode of base64 string
TEST(testUtils, encodebase64)
{
EXPECT_EQ(encodedText, util_encode_base64(plainText));
}
// Test decode of base64 sstring
TEST(testUtils, decodebase64)
{
EXPECT_EQ(plainText, util_decode_base64(encodedText));
}
// Test return value of util_format_uuid
TEST(testUtils, formatUUIDSuccess)
{
std::vector<unsigned char> uuid_bytes;
for (int i=0; i<16; i++)
{
uuid_bytes.push_back(i);
}
std::string uuid_string;
util_format_uuid(uuid_bytes, uuid_string);
EXPECT_EQ(true, util_format_uuid(uuid_bytes, uuid_string));
}
// Test return value of util_format_uuid
TEST(testUtils, formatUUIDFail)
{
std::vector<unsigned char> uuid_bytes;
for (int i=0; i<5; i++) // invalid length
{
uuid_bytes.push_back(i);
}
std::string uuid_string;
util_format_uuid(uuid_bytes, uuid_string);
EXPECT_EQ(false, util_format_uuid(uuid_bytes, uuid_string));
}
// Test value of the uuid format to ensure format is correct
TEST(testUtils, formatUUIDValue)
{
std::string uuid_string;
std::vector<unsigned char> uuid_bytes;
for (int i=0; i<16; i++)
{
uuid_bytes.push_back(i);
}
util_format_uuid(uuid_bytes, uuid_string);
EXPECT_EQ("03020100-0504-0706-0809-0a0b0c0d0e0f", uuid_string);
}

View File

@@ -25,7 +25,6 @@ void usage_show_help()
std::cout << "Optional:" << std::endl;
std::cout << " -p, --proxy <addr> proxy address and port" << std::endl;
std::cout << " -d, --dns <dns> dns suffix override" << std::endl;
std::cout << " -n, --nocertcheck skip websocket server certificate verification" << std::endl;
std::cout << " -v, --verbose verbose output" << std::endl;
std::cout << std::endl;
std::cout << "Informational:" << std::endl;
@@ -41,7 +40,6 @@ void usage_show_help()
std::cout << " uuid unique identifier" << std::endl;
std::cout << " mode current control mode" << std::endl;
std::cout << " dns domain name suffix" << std::endl;
std::cout << " fqdn fully qualified domain name" << std::endl;
std::cout << " cert certificate hashes" << std::endl;
std::cout << " ras remote access status" << std::endl;
std::cout << " lan LAN settings" << std::endl;
@@ -49,15 +47,15 @@ void usage_show_help()
std::cout << "Examples:" << std::endl;
std::cout << " # Activate platform using profile1" << std::endl;
std::cout << " " << PROJECT_NAME << \
" --url wss://192.168.86.100/activate --cmd \"-t activate --profile profile1\"" << std::endl;
" --url wss://localhost:8080 --cmd \"-t activate --profile profile1\"" << std::endl;
std::cout << std::endl;
std::cout << " # Activate platform using profile1 and override DNS detection" << std::endl;
std::cout << " " << PROJECT_NAME << \
" --url wss://mycloud.com/activate --cmd \"-t activate --profile profile1\" --dns corp.com" << std::endl;
" --url wss://localhost:8080 --cmd \"-t activate --profile profile1\" --dns corp.com" << std::endl;
std::cout << std::endl;
std::cout << " # Deactivate platform and connect through a proxy" << std::endl;
std::cout << " " << PROJECT_NAME << \
" -u wss://mycloud.com/activate -c \"-t deactivate --password P@ssw0rd\" -p http://proxy.com:1000" << std::endl;
" -u wss://localhost:8080 -c \"-t deactivate --password P@ssw0rd\" -p http://proxy.com:1000" << std::endl;
std::cout << std::endl;
std::cout << " # Show all informational items" << std::endl;
std::cout << " " << PROJECT_NAME << " --amtinfo all" << std::endl;
@@ -70,4 +68,4 @@ void usage_show_version()
std::cout << project_name << " " << PROJECT_VER << "." << std::endl;
std::cout << "Protocol " << PROTOCOL_VERSION << "." << std::endl;
}
}

1
vcpkg

Submodule vcpkg deleted from 5568f110b5