Skip to content

Commit

Permalink
Refactor symbol controls in anticipation of first internal import (#45)
Browse files Browse the repository at this point in the history
* Add hidden cjson to tests; expose various internal apis to tests; properly globalize private apis for tests
  • Loading branch information
bretambrose authored Feb 11, 2021
1 parent dfe3e0a commit ca2b98c
Show file tree
Hide file tree
Showing 8 changed files with 3,046 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ aws_add_sanitizers(${PROJECT_NAME})
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 1.0.0)
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION 0unstable)

target_compile_definitions(${PROJECT_NAME} PRIVATE -DCJSON_HIDE_SYMBOLS)

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
Expand Down
43 changes: 43 additions & 0 deletions include/aws/iotdevice/private/iotdevice_internals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#ifndef AWS_IOTDEVICE_IOTDEVICE_INTERNALS_H
#define AWS_IOTDEVICE_IOTDEVICE_INTERNALS_H

#include <aws/iotdevice/private/serializer.h>

struct aws_byte_buf;
struct aws_byte_cursor;
struct aws_secure_tunnel;
struct aws_websocket;
struct aws_websocket_client_connection_options;
struct aws_websocket_send_frame_options;

AWS_EXTERN_C_BEGIN

AWS_IOTDEVICE_API
int secure_tunneling_init_send_frame(
struct aws_websocket_send_frame_options *frame_options,
struct aws_secure_tunnel *secure_tunnel,
const struct aws_byte_cursor *data,
enum aws_iot_st_message_type type);

AWS_IOTDEVICE_API
void init_websocket_client_connection_options(
struct aws_secure_tunnel *secure_tunnel,
struct aws_websocket_client_connection_options *websocket_options);

AWS_IOTDEVICE_API
int secure_tunneling_init_send_frame(
struct aws_websocket_send_frame_options *frame_options,
struct aws_secure_tunnel *secure_tunnel,
const struct aws_byte_cursor *data,
enum aws_iot_st_message_type type);

AWS_IOTDEVICE_API
bool secure_tunneling_send_data_call(struct aws_websocket *websocket, struct aws_byte_buf *out_buf, void *user_data);

AWS_EXTERN_C_END

#endif /* AWS_IOTDEVICE_IOTDEVICE_INTERNALS_H */
9 changes: 9 additions & 0 deletions include/aws/iotdevice/private/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define AWS_IOTDEVICE_NETWORK_H

#include <aws/common/hash_table.h>
#include <aws/iotdevice/exports.h>

#include <stdbool.h>
#include <stdint.h>
Expand Down Expand Up @@ -42,20 +43,28 @@ struct aws_iotdevice_network_ifconfig {
struct aws_hash_table iface_name_to_info;
};

AWS_EXTERN_C_BEGIN

AWS_IOTDEVICE_API
void get_system_network_total(
struct aws_iotdevice_metric_network_transfer *total,
struct aws_iotdevice_network_ifconfig *ifconfig);

AWS_IOTDEVICE_API
int get_network_config_and_transfer(struct aws_iotdevice_network_ifconfig *ifconfig, struct aws_allocator *allocator);

AWS_IOTDEVICE_API
int get_network_connections(
struct aws_array_list *net_conns,
struct aws_iotdevice_network_ifconfig *ifconfig,
struct aws_allocator *allocator);

AWS_IOTDEVICE_API
void get_network_total_delta(
struct aws_iotdevice_metric_network_transfer *delta,
struct aws_iotdevice_metric_network_transfer *prev_total,
struct aws_iotdevice_metric_network_transfer *curr_total);

AWS_EXTERN_C_END

#endif
5 changes: 2 additions & 3 deletions include/aws/iotdevice/secure_tunneling.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
enum aws_secure_tunneling_local_proxy_mode { AWS_SECURE_TUNNELING_SOURCE_MODE, AWS_SECURE_TUNNELING_DESTINATION_MODE };

struct aws_secure_tunnel;
struct aws_websocket_incoming_frame;
struct ping_task_context;

struct data_tunnel_pair {
struct aws_byte_buf buf;
Expand Down Expand Up @@ -68,8 +70,6 @@ struct aws_secure_tunneling_connection_config {
void *user_data;
};

struct ping_task_context;

struct aws_secure_tunnel {
/* Static settings */
struct aws_secure_tunneling_connection_config config;
Expand Down Expand Up @@ -122,7 +122,6 @@ AWS_IOTDEVICE_API
int aws_secure_tunnel_stream_reset(struct aws_secure_tunnel *secure_tunnel);

/* Making this exposed public to verify testing in the sdk layer */
struct aws_websocket_incoming_frame;
AWS_IOTDEVICE_API
bool on_websocket_incoming_frame_payload(
struct aws_websocket *websocket,
Expand Down
1 change: 1 addition & 0 deletions source/secure_tunneling.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <aws/io/event_loop.h>
#include <aws/io/tls_channel_handler.h>
#include <aws/iotdevice/iotdevice.h>
#include <aws/iotdevice/private/iotdevice_internals.h>
#include <aws/iotdevice/private/serializer.h>
#include <aws/iotdevice/secure_tunneling.h>
#include <math.h>
Expand Down
3 changes: 2 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ include(AwsTestHarness)
enable_testing()

file(GLOB TEST_HDRS "mqtt_mock_structs.h")
set(EXTERNAL_SRC "external/cJSON.c")
set(TEST_SRC metrics_tests.c secure_tunneling_tests.c)
file(GLOB TESTS ${TEST_HDRS} ${TEST_SRC})
file(GLOB TESTS ${TEST_HDRS} ${TEST_SRC} ${EXTERNAL_SRC})

add_test_case(devicedefender_task_unsupported_report_format)

Expand Down
Loading

0 comments on commit ca2b98c

Please sign in to comment.