Skip to content

Commit

Permalink
Merge branch 'main' into IotPublishSubscribeTest
Browse files Browse the repository at this point in the history
  • Loading branch information
bretambrose authored Feb 27, 2025
2 parents 4035874 + c776ab5 commit d84f131
Show file tree
Hide file tree
Showing 24 changed files with 129 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
# that are up-to-date (AL2) or don't provide OpenSSL development packages that is found in CMake (alpine)
# or are not able to connect on the socket even with the correct setup (manylinux2014)
linux-compat:
runs-on: ubuntu-24.04 # latest
runs-on: ubuntu-22.04 # temporarily downgrade to old ubuntu until https://github.com/actions/runner-images/issues/11471 resolves
strategy:
fail-fast: false
matrix:
Expand Down
63 changes: 19 additions & 44 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
cmake_minimum_required(VERSION 3.9)

if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
cmake_minimum_required(VERSION 3.9...3.31)

option(BUILD_DEPS "Builds aws common runtime dependencies as part of build. Turn off if you want to control your dependency chain." ON)
option(BYO_CRYPTO "Don't build a tls implementation or link against a crypto interface. This feature is only for unix builds currently" OFF)
Expand Down Expand Up @@ -30,24 +26,7 @@ project("aws-crt-cpp"
VERSION ${SIMPLE_VERSION})

include(CTest)

if(DEFINED CMAKE_PREFIX_PATH)
file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH)
endif()

if(DEFINED CMAKE_INSTALL_PREFIX)
file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX)
endif()

if(UNIX AND NOT APPLE)
include(GNUInstallDirs)
elseif(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()

if(${CMAKE_INSTALL_LIBDIR} STREQUAL "lib64")
set(FIND_LIBRARY_USE_LIB64_PATHS true)
endif()
include(GNUInstallDirs)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
Expand All @@ -65,13 +44,6 @@ set(GENERATED_INCLUDE_DIR "${GENERATED_ROOT_DIR}/include")
set(GENERATED_CONFIG_HEADER "${GENERATED_INCLUDE_DIR}/aws/crt/Config.h")
configure_file(include/aws/crt/Config.h.in ${GENERATED_CONFIG_HEADER} @ONLY)

# This is required in order to append /lib/cmake to each element in CMAKE_PREFIX_PATH
set(AWS_MODULE_DIR "/${CMAKE_INSTALL_LIBDIR}/cmake")
string(REPLACE ";" "${AWS_MODULE_DIR};" AWS_MODULE_PATH "${CMAKE_PREFIX_PATH}${AWS_MODULE_DIR}")

# Append that generated list to the module search path
list(APPEND CMAKE_MODULE_PATH ${AWS_MODULE_PATH})

if(BUILD_DEPS)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/crt/aws-c-common/cmake")

Expand Down Expand Up @@ -132,6 +104,9 @@ if(BUILD_DEPS)
add_subdirectory(crt/aws-c-s3)
set(BUILD_TESTING ${BUILD_TESTING_PREV})
else()
# this is required so we can use aws-c-common's CMake modules
find_package(aws-c-common REQUIRED)

include(AwsFindPackage)
set(IN_SOURCE_BUILD OFF)
endif()
Expand Down Expand Up @@ -356,23 +331,23 @@ aws_add_sanitizers(${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME} PUBLIC ${DEP_AWS_LIBS})

install(FILES ${AWS_CRT_HEADERS} DESTINATION "include/aws/crt" COMPONENT Development)
install(FILES ${AWS_CRT_AUTH_HEADERS} DESTINATION "include/aws/crt/auth" COMPONENT Development)
install(FILES ${AWS_CRT_CHECKSUM_HEADERS} DESTINATION "include/aws/crt/checksum" COMPONENT Development)
install(FILES ${AWS_CRT_CRYPTO_HEADERS} DESTINATION "include/aws/crt/crypto" COMPONENT Development)
install(FILES ${AWS_CRT_IO_HEADERS} DESTINATION "include/aws/crt/io" COMPONENT Development)
install(FILES ${AWS_CRT_IOT_HEADERS} DESTINATION "include/aws/iot" COMPONENT Development)
install(FILES ${AWS_CRT_MQTT_HEADERS} DESTINATION "include/aws/crt/mqtt" COMPONENT Development)
install(FILES ${AWS_CRT_HTTP_HEADERS} DESTINATION "include/aws/crt/http" COMPONENT Development)
install(FILES ${AWS_CRT_ENDPOINT_HEADERS} DESTINATION "include/aws/crt/endpoints" COMPONENT Development)
install(FILES ${AWS_CRT_CBOR_HEADERS} DESTINATION "include/aws/crt/cbor" COMPONENT Development)
install(FILES ${AWS_CRT_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/crt" COMPONENT Development)
install(FILES ${AWS_CRT_AUTH_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/crt/auth" COMPONENT Development)
install(FILES ${AWS_CRT_CHECKSUM_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/crt/checksum" COMPONENT Development)
install(FILES ${AWS_CRT_CRYPTO_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/crt/crypto" COMPONENT Development)
install(FILES ${AWS_CRT_IO_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/crt/io" COMPONENT Development)
install(FILES ${AWS_CRT_IOT_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/iot" COMPONENT Development)
install(FILES ${AWS_CRT_MQTT_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/crt/mqtt" COMPONENT Development)
install(FILES ${AWS_CRT_HTTP_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/crt/http" COMPONENT Development)
install(FILES ${AWS_CRT_ENDPOINT_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/crt/endpoints" COMPONENT Development)
install(FILES ${AWS_CRT_CBOR_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/aws/crt/cbor" COMPONENT Development)

install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development
RUNTIME DESTINATION bin COMPONENT Runtime
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime
)

if(BUILD_SHARED_LIBS)
Expand All @@ -382,7 +357,7 @@ else()
endif()

install(EXPORT "${PROJECT_NAME}-targets"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake/${TARGET_DIR}"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/${TARGET_DIR}"
NAMESPACE AWS::
COMPONENT Development)

Expand All @@ -398,11 +373,11 @@ write_basic_package_version_file(
)

install(FILES "${GENERATED_ROOT_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake/"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/"
COMPONENT Development)

install(FILES "${GENERATED_ROOT_DIR}/${PROJECT_NAME}-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake/"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/"
COMPONENT Development)

if(NOT CMAKE_CROSSCOMPILING)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.29.9
0.31.0
4 changes: 1 addition & 3 deletions bin/elasticurl_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
project(elasticurl_cpp CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/lib/cmake")

file(GLOB ELASTICURL_CPP_SRC
"*.cpp"
)
Expand Down Expand Up @@ -43,5 +41,5 @@ install(TARGETS ${ELASTICURL_CPP_PROJECT_NAME}
EXPORT ${ELASTICURL_CPP_PROJECT_NAME}-targets
COMPONENT Runtime
RUNTIME
DESTINATION bin
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Runtime)
4 changes: 1 addition & 3 deletions bin/mqtt5_app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
project(mqtt5_app CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/lib/cmake")

file(GLOB MQTT5_APP_SRC
"*.cpp"
)
Expand Down Expand Up @@ -43,5 +41,5 @@ install(TARGETS ${MQTT5_APP_PROJECT_NAME}
EXPORT ${MQTT5_APP_PROJECT_NAME}-targets
COMPONENT Runtime
RUNTIME
DESTINATION bin
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Runtime)
4 changes: 1 addition & 3 deletions bin/mqtt5_canary/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
project(mqtt5_canary CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_PREFIX_PATH}/lib/cmake")

file(GLOB MQTT5_CANARY_SRC
"*.cpp"
)
Expand Down Expand Up @@ -43,5 +41,5 @@ install(TARGETS ${MQTT5_CANARY_PROJECT_NAME}
EXPORT ${MQTT5_CANARY_PROJECT_NAME}-targets
COMPONENT Runtime
RUNTIME
DESTINATION bin
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT Runtime)
2 changes: 1 addition & 1 deletion crt/aws-c-http
2 changes: 1 addition & 1 deletion crt/aws-c-io
Submodule aws-c-io updated 43 files
+43 −0 .builder/actions/tls_server_setup.py
+172 −73 .github/workflows/ci.yml
+3 −3 .github/workflows/proof-alarm.yml
+33 −34 CMakeLists.txt
+4 −0 builder.json
+26 −0 include/aws/io/event_loop.h
+25 −8 include/aws/io/private/event_loop_impl.h
+2 −1 include/aws/io/private/pki_utils.h
+72 −0 include/aws/io/private/socket_impl.h
+22 −0 include/aws/io/private/tls_channel_handler_private.h
+31 −15 include/aws/io/socket.h
+3 −0 include/aws/io/tls_channel_handler.h
+0 −1 include/aws/testing/io_testing_channel.h
+3 −1 source/bsd/kqueue_event_loop.c
+1 −1 source/darwin/secure_transport_tls_channel_handler.c
+167 −9 source/event_loop.c
+1 −1 source/linux/epoll_event_loop.c
+75 −44 source/posix/socket.c
+6 −0 source/s2n/s2n_tls_channel_handler.c
+258 −0 source/socket.c
+1 −0 source/windows/host_resolver.c
+1 −1 source/windows/iocp/iocp_event_loop.c
+108 −81 source/windows/iocp/socket.c
+496 −122 source/windows/secure_channel_tls_handler.c
+114 −38 source/windows/windows_pki_utils.c
+1 −0 source/windows/winsock_init.c
+17 −0 tests/CMakeLists.txt
+76 −3 tests/event_loop_test.c
+28 −0 tests/resources/tls13_device.key
+24 −0 tests/resources/tls13_device.pem.crt
+28 −0 tests/resources/tls13_device_root_ca.key
+24 −0 tests/resources/tls13_device_root_ca.pem.crt
+28 −0 tests/resources/tls13_server.key
+24 −0 tests/resources/tls13_server.pem.crt
+28 −0 tests/resources/tls13_server_root_ca.key
+24 −0 tests/resources/tls13_server_root_ca.pem.crt
+1 −1 tests/socket_handler_test.c
+48 −0 tests/socket_test.c
+165 −2 tests/tls_handler_test.c
+23 −0 tests/tls_server/tls_server.py
+2 −2 tests/vcc/Makefile
+3 −3 tests/vcc/new_destroy.c
+1 −1 tests/vcc/preamble.h
2 changes: 1 addition & 1 deletion crt/aws-c-sdkutils
Submodule aws-c-sdkutils updated 1 files
+9 −24 CMakeLists.txt
2 changes: 1 addition & 1 deletion crt/aws-checksums
2 changes: 1 addition & 1 deletion crt/aws-lc
2 changes: 1 addition & 1 deletion crt/s2n
Submodule s2n updated from 2e79e7 to 21cefc
17 changes: 17 additions & 0 deletions include/aws/crt/DnsUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/crt/Exports.h>

namespace Aws
{
namespace Crt
{
namespace DnsUtils
{
AWS_CRT_CPP_API bool IsValidIpV6(const char *host, bool is_uri_encoded);
} // namespace DnsUtils
} // namespace Crt
} // namespace Aws
28 changes: 26 additions & 2 deletions include/aws/iot/MqttRequestResponseClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,28 @@ namespace Aws
/**
* Default constructor
*/
IncomingPublishEvent() : m_payload() { AWS_ZERO_STRUCT(m_payload); }
IncomingPublishEvent() : m_topic(), m_payload()
{
AWS_ZERO_STRUCT(m_topic);
AWS_ZERO_STRUCT(m_payload);
}

/**
* Sets the message response topic associated with this event. The event does not own this topic.
*
* @param topic the message response topic associated with this event
* @return reference to this
*/
IncomingPublishEvent &WithTopic(Aws::Crt::ByteCursor topic)
{
m_topic = topic;
return *this;
}

/**
* Sets the message payload associated with this event. The event does not own this payload.
*
* @param payload he message payload associated with this event
* @param payload the message payload associated with this event
* @return reference to this
*/
IncomingPublishEvent &WithPayload(Aws::Crt::ByteCursor payload)
Expand All @@ -135,6 +151,13 @@ namespace Aws
return *this;
}

/**
* Gets the message response topic associated with this event.
*
* @return the message response topic associated with this event
*/
Aws::Crt::ByteCursor GetTopic() const { return m_topic; }

/**
* Gets the message payload associated with this event.
*
Expand All @@ -143,6 +166,7 @@ namespace Aws
Aws::Crt::ByteCursor GetPayload() const { return m_payload; }

private:
Aws::Crt::ByteCursor m_topic;
Aws::Crt::ByteCursor m_payload;
};

Expand Down
24 changes: 24 additions & 0 deletions source/DnsUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/

#include <aws/common/host_utils.h>
#include <aws/crt/DnsUtils.h>
#include <aws/crt/Types.h>

namespace Aws
{
namespace Crt
{
namespace DnsUtils
{

bool IsValidIpV6(const char *host, bool is_uri_encoded)
{
return aws_host_utils_is_ipv6(Aws::Crt::ByteCursorFromCString(host), is_uri_encoded);
}

} // namespace DnsUtils
} // namespace Crt
} // namespace Aws
12 changes: 9 additions & 3 deletions source/iot/MqttRequestResponseClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ namespace Aws
int error_code,
void *user_data);

static void OnIncomingPublishCallback(struct aws_byte_cursor payload, void *user_data);
static void OnIncomingPublishCallback(
struct aws_byte_cursor payload,
struct aws_byte_cursor topic,
void *user_data);

static void OnTerminatedCallback(void *user_data);

Expand Down Expand Up @@ -187,7 +190,10 @@ namespace Aws
}
}

void StreamingOperationImpl::OnIncomingPublishCallback(struct aws_byte_cursor payload, void *user_data)
void StreamingOperationImpl::OnIncomingPublishCallback(
struct aws_byte_cursor payload,
struct aws_byte_cursor topic,
void *user_data)
{
auto *handle = static_cast<StreamingOperationImplHandle *>(user_data);
StreamingOperationImpl *impl = handle->m_impl.get();
Expand All @@ -198,7 +204,7 @@ namespace Aws
if (!impl->m_closed && impl->m_config.incomingPublishEventHandler)
{
IncomingPublishEvent event;
event.WithPayload(payload);
event.WithTopic(topic).WithPayload(payload);

impl->m_config.incomingPublishEventHandler(std::move(event));
}
Expand Down
Loading

0 comments on commit d84f131

Please sign in to comment.