Skip to content

Commit

Permalink
Merge branch 'master' into development/valuerecorder
Browse files Browse the repository at this point in the history
  • Loading branch information
msieben authored May 29, 2024
2 parents 1925a8b + b477a05 commit 124b07e
Show file tree
Hide file tree
Showing 38 changed files with 211 additions and 166 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/main-mend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Mend workflow
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: comcast-runner
steps:
# It will checkout the latest code
- uses: actions/checkout@v3
- name: Run Whitesource/Mend scan
run: |
java -version
curl -LJO https://github.com/whitesource/unified-agent-distribution/releases/latest/download/wss-unified-agent.jar
java -jar wss-unified-agent.jar -apiKey ${{ secrets.MEND_API_KEY }} -product Thunder -project thunder-github-action-test
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ endif()

include(platform)
include(CmakeHelperFunctions)
include(GNUInstallDirs)

set(PLATFORM "PC_UNIX" CACHE STRING
"Defines on what platform the application will run")
Expand Down Expand Up @@ -96,26 +97,26 @@ configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/project.cmake.in"

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${NAMESPACE}.cmake"
RENAME "${NAMESPACE}Config.cmake"
DESTINATION lib/cmake/${NAMESPACE})
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE})

if(CMAKE_VERSION VERSION_LESS 3.20.0 AND LEGACY_CONFIG_GENERATOR)
install(DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/config"
DESTINATION lib/cmake/${NAMESPACE})
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE})
endif(CMAKE_VERSION VERSION_LESS 3.20.0 AND LEGACY_CONFIG_GENERATOR)

install(DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/common"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates"
DESTINATION lib/cmake/${NAMESPACE})
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAMESPACE})

if(APPLE)
# Mac needed variables
# http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()

Expand Down
8 changes: 4 additions & 4 deletions Source/WPEFramework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ set_target_properties(${TARGET} PROPERTIES

install(
TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies
ARCHIVE DESTINATION lib COMPONENT libs # static lib
LIBRARY DESTINATION lib COMPONENT libs # shared lib
RUNTIME DESTINATION bin COMPONENT libs # binaries
FRAMEWORK DESTINATION bin COMPONENT libs # for mac
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac
)

install(DIRECTORY
Expand Down
2 changes: 1 addition & 1 deletion Source/WPEFramework/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ namespace PluginHost {
_pluginConfigPath = Core::Directory::Normalize(config.Observe.PluginConfigPath.Value());
}
_postMortemPath = Core::Directory::Normalize(config.PostMortemPath.Value());
_appPath = Core::File::PathName(Core::ProcessInfo().Executable());
_appPath = Core::Directory::Normalize(Core::File::PathName(Core::ProcessInfo().Executable()));
_hashKey = config.Signature.Value();
_communicator = Core::NodeId(config.Communicator.Value().c_str());
_redirect = config.Redirect.Value();
Expand Down
8 changes: 4 additions & 4 deletions Source/WPEFramework/GenericConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ set(SOFT_KILL_CHECK_WAIT_TIME 10 CACHE STRING "Soft kill check waiting time")
set(HARD_KILL_CHECK_WAIT_TIME 4 CACHE STRING "Hard kill check waiting time")
set(PERSISTENT_PATH "/root" CACHE STRING "Persistent path")
set(DATA_PATH "${CMAKE_INSTALL_PREFIX}/share/${NAMESPACE}" CACHE STRING "Data path")
set(SYSTEM_PATH "${CMAKE_INSTALL_PREFIX}/lib/${NAMESPACE_LIB}/plugins" CACHE STRING "System path")
set(SYSTEM_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${NAMESPACE_LIB}/plugins" CACHE STRING "System path")
set(WEBSERVER_PATH "/boot/www" CACHE STRING "Root path for the HTTP server")
set(WEBSERVER_PORT 8080 CACHE STRING "Port for the HTTP server")
set(PROXYSTUB_PATH "${CMAKE_INSTALL_PREFIX}/lib/${NAMESPACE_LIB}/proxystubs" CACHE STRING "Proxy stub path")
set(PROXYSTUB_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${NAMESPACE_LIB}/proxystubs" CACHE STRING "Proxy stub path")
set(POSTMORTEM_PATH "/opt/minidumps" CACHE STRING "Core file path to do the postmortem of the crash")
set(MESSAGECONTROL_PATH "MessageDispatcher" CACHE STRING "MessageControl base path to create message files")
set(MESSAGING_PORT 0 CACHE STRING "The port for the messaging")
Expand Down Expand Up @@ -284,7 +284,7 @@ json_write("${CMAKE_BINARY_DIR}/Config.json" ${CONFIG})

install(
FILES ${CMAKE_BINARY_DIR}/Config.json
DESTINATION ${CMAKE_INSTALL_PREFIX}/../etc/${NAMESPACE}/
DESTINATION ../${CMAKE_INSTALL_SYSCONFDIR}/${NAMESPACE}/
RENAME config.json
COMPONENT ${MODULE_NAME})
else()
Expand All @@ -295,7 +295,7 @@ else()
SKIP_CLASSNAME
SKIP_LOCATOR
CUSTOM_PARAMS_WHITELIST "${CMAKE_CURRENT_LIST_DIR}/params.config"
INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/../etc/${NAMESPACE}/"
INSTALL_PATH "../${CMAKE_INSTALL_SYSCONFDIR}/${NAMESPACE}/"
INSTALL_NAME "config.json"
PLUGINS "WPEFramework"
)
Expand Down
4 changes: 2 additions & 2 deletions Source/WPEFramework/scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (SYSTEMD_SERVICE)
)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/wpeframework.service "${MOD_WPEFRAMEWORK_SYSTEMD_SERVICE}")

install(DIRECTORY DESTINATION ${CMAKE_INSTALL_PREFIX}/../lib)
install(DIRECTORY DESTINATION ${CMAKE_INSTALL_PREFIX}/../${CMAKE_INSTALL_LIBDIR})
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/wpeframework.service
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
Expand All @@ -43,7 +43,7 @@ else()
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/wpeframework
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
DESTINATION ${CMAKE_INSTALL_PREFIX}/../etc/init.d/
DESTINATION ../${CMAKE_INSTALL_SYSCONFDIR}/init.d/
)
endif()

8 changes: 4 additions & 4 deletions Source/WPEProcess/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ set_target_properties(${TARGET} PROPERTIES

install(
TARGETS COMProcess ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies
ARCHIVE DESTINATION lib COMPONENT libs # static lib
LIBRARY DESTINATION lib COMPONENT libs # shared lib
RUNTIME DESTINATION bin COMPONENT libs # binaries
FRAMEWORK DESTINATION bin COMPONENT libs # for mac
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac
)
36 changes: 18 additions & 18 deletions Source/com/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# If not stated otherwise in this file or this component's license file the
# following copyright and licenses apply:
#If not stated otherwise in this file or this component's license file the
#following copyright and licenses apply:
#
# Copyright 2020 Metrological
#Copyright 2020 Metrological
#
# 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
#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
#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.
#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.

set(TARGET ${NAMESPACE}COM)

Expand Down Expand Up @@ -93,12 +93,12 @@ set_target_properties(${TARGET} PROPERTIES

install(
TARGETS ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies
ARCHIVE DESTINATION lib COMPONENT libs # static lib
LIBRARY DESTINATION lib COMPONENT libs # shared lib
RUNTIME DESTINATION bin COMPONENT libs # binaries
FRAMEWORK DESTINATION bin COMPONENT libs # for mac
PUBLIC_HEADER DESTINATION include/${NAMESPACE}/com COMPONENT devel # headers for mac (note the different component -> different package)
INCLUDES DESTINATION include/${NAMESPACE} # default include path
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/com COMPONENT devel # headers for mac (note the different component -> different package)
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE} # default include path
)

InstallCMakeConfig(TARGETS ${TARGET})
12 changes: 6 additions & 6 deletions Source/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ endif()
# ===========================================================================================
install(
TARGETS CompileSettings ${TARGET} EXPORT ${TARGET}Targets # for downstream dependencies
ARCHIVE DESTINATION lib COMPONENT libs # static lib
LIBRARY DESTINATION lib COMPONENT libs # shared lib
RUNTIME DESTINATION bin COMPONENT libs # binaries
FRAMEWORK DESTINATION bin COMPONENT libs # for mac
PUBLIC_HEADER DESTINATION include/${NAMESPACE}/core COMPONENT devel # for mac
INCLUDES DESTINATION include/${NAMESPACE} # default include path
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # static lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libs # shared lib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # binaries
FRAMEWORK DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libs # for mac
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE}/core COMPONENT devel # for mac
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${NAMESPACE} # default include path
)

# ===========================================================================================
Expand Down
22 changes: 11 additions & 11 deletions Source/core/CyclicBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,25 +394,25 @@ namespace Core {
foundData = false;
}
} else {
uint32_t part1 = 0;
uint32_t part2 = 0;
uint32_t newOffset = 0;

if (_administration->_size < offset) {
part2 = result - (offset - _administration->_size);
const uint32_t skip = offset - _administration->_size;
newOffset = skip + bufferLength;
::memcpy(buffer, _realBuffer + skip, bufferLength);
} else {
part1 = _administration->_size - offset;
part2 = result - part1;
}

memcpy(buffer, _realBuffer + offset, std::min(part1, bufferLength));
const uint32_t part1 = _administration->_size - offset;
newOffset = result - part1;
::memcpy(buffer, _realBuffer + offset, std::min(part1, bufferLength));

if (part1 < bufferLength) {
memcpy(buffer + part1, _realBuffer, bufferLength - part1);
if (part1 < bufferLength) {
::memcpy(buffer + part1, _realBuffer, bufferLength - part1);
}
}

// Add one round, but prevent overflow.
roundCount = (roundCount + 1) % _administration->_roundCountModulo;
uint32_t newTail = part2 + roundCount * (1 + _administration->_tailIndexMask);
uint32_t newTail = newOffset + roundCount * (1 + _administration->_tailIndexMask);
if (!_administration->_tail.compare_exchange_weak(oldTail, newTail)) {
foundData = false;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/core/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace Core {
AllocatorType<STARTSIZE, SIZETYPE>& operator=(const AllocatorType<STARTSIZE, SIZETYPE>& copy) = delete;

AllocatorType()
: _bufferSize(STARTSIZE)
: _bufferSize(static_cast<SIZETYPE>(STARTSIZE))
, _data(static_cast<uint8_t*>(::malloc(_bufferSize)))
{
// It looks like there is a bug in the windows compiler. It prepares a default/copy constructor
Expand Down Expand Up @@ -178,7 +178,7 @@ namespace Core {
if (_data != nullptr) {
::free(_data);
}
_data == move._data;
_data = move._data;
move._data = nullptr;
_bufferSize = move._bufferSize;
}
Expand Down
44 changes: 33 additions & 11 deletions Source/core/IPFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ namespace Core {
public:
bool IsValid() const {
const ip* ipHeader = reinterpret_cast<const ip*>(Base::Frame());
#ifdef __WINDOWS__
return ((ipHeader->protocol == PROTOCOL) && (Checksum() == ipHeader->check));
#else
return ((ipHeader->ip_p == PROTOCOL) && (Checksum() == ipHeader->ip_sum));
#endif
}
uint16_t Load(const uint8_t buffer[], const uint16_t size) {
uint16_t copySize = std::min(size, static_cast<uint16_t>(SIZE + HeaderSize));
Expand All @@ -139,55 +143,73 @@ namespace Core {
inline NodeId Source() const {
NodeId result;
const ip* ipHeader = reinterpret_cast<const ip*>(Base::Frame());
ASSERT (ipHeader->ip_v == IPV4_VERSION);

ASSERT(ipHeader->ip_v == IPV4_VERSION);

sockaddr_in node;
::memset (&node, 0, sizeof(node));
node.sin_family = AF_INET;
node.sin_port = 0;
#ifdef __WINDOWS__
node.sin_addr.S_un.S_addr = ipHeader->ip_src;
#else
node.sin_addr = ipHeader->ip_src;
#endif
result = node;

return (result);
}
inline void Source(const NodeId& node) {
ip* ipHeader = reinterpret_cast<ip*>(Base::Frame());
ASSERT (ipHeader->ip_v == IPV4_VERSION);
ASSERT(ipHeader->ip_v == IPV4_VERSION);
ASSERT (node.Type() == NodeId::TYPE_IPV4);

const sockaddr_in& result = static_cast<const NodeId::SocketInfo&>(node).IPV4Socket;
ipHeader->ip_src = result.sin_addr;
#ifdef __WINDOWS__
ipHeader->ip_src = result.sin_addr.S_un.S_addr;
#else
ipHeader->ip_src = result.sin_addr;
#endif
ipHeader->ip_sum = Checksum();
}
inline NodeId Destination() const {
NodeId result;
const ip* ipHeader = reinterpret_cast<const ip*>(Base::Frame());
ASSERT (ipHeader->ip_v == IPV4_VERSION);
ASSERT(ipHeader->ip_v == IPV4_VERSION);

sockaddr_in node;
::memset (&node, 0, sizeof(node));
node.sin_family = AF_INET;
node.sin_port = 0;
node.sin_addr = ipHeader->ip_dst;
#ifdef __WINDOWS__
node.sin_addr.S_un.S_addr = ipHeader->ip_dst;
#else
node.sin_addr = ipHeader->ip_dst;
#endif
result = node;

return (result);
}
inline void Destination(const NodeId& node) {
ip* ipHeader = reinterpret_cast<ip*>(Base::Frame());
ASSERT (ipHeader->ip_v == IPV4_VERSION);

ASSERT(ipHeader->ip_v == IPV4_VERSION);
ASSERT (node.Type() == NodeId::TYPE_IPV4);

const sockaddr_in& result = static_cast<const NodeId::SocketInfo&>(node).IPV4Socket;
ipHeader->ip_dst = result.sin_addr;
#ifdef __WINDOWS__
ipHeader->ip_dst = result.sin_addr.S_un.S_addr;
#else
ipHeader->ip_dst = result.sin_addr;
#endif
ipHeader->ip_sum = Checksum();
}
inline uint8_t TTL() const {
return (reinterpret_cast<const ip*>(Base::Frame())->ip_ttl);
}
inline void TTL(const uint8_t ttl) {
ip* ipHeader = reinterpret_cast<ip*>(Base::Frame());
ipHeader->ip_ttl = ttl;
ipHeader->ip_ttl = ttl;
ipHeader->ip_sum = Checksum();
}
inline uint16_t Length() const {
Expand Down Expand Up @@ -244,15 +266,14 @@ namespace Core {

private:
uint16_t Checksum() const {

ip* ipHeader = const_cast<ip*>(reinterpret_cast<const ip*>(Base::Frame()));
ip* ipHeader = const_cast<ip*>(reinterpret_cast<const ip*>(Base::Frame()));
uint16_t original = ipHeader->ip_sum;
ipHeader->ip_sum = 0;
uint32_t result = Checksum(0, reinterpret_cast<const uint16_t*>(ipHeader), HeaderSize);
ipHeader->ip_sum = original;

return (Shrink(result));
}

};

static constexpr uint16_t TCPv4FrameSize = sizeof(tcphdr);
Expand Down Expand Up @@ -449,6 +470,7 @@ namespace Core {
udphdr* udpHeader = const_cast<udphdr*>(reinterpret_cast<const udphdr*>(Base::Frame()));
uint16_t original = udpHeader->uh_sum;
udpHeader->uh_sum = 0;

uint32_t result = Base::Checksum(0, reinterpret_cast<const uint16_t*>(pseudoHeader), sizeof(pseudoHeader));
result = Base::Checksum (result, reinterpret_cast<const uint16_t*>(udpHeader), Base::Length());
udpHeader->uh_sum = original;
Expand Down
Loading

0 comments on commit 124b07e

Please sign in to comment.