Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add protocol version check for outgoing DATA messages #97

Merged
merged 52 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
39db7b1
Add protocol version check for outgoing DATA messages
sfodagain Aug 15, 2023
cf9b787
Fix logging when protocols mismatch
sfodagain Aug 15, 2023
8f07b40
Use s_aws_secure_tunnel_protocol_version_match_check in aws_secure_tu…
sfodagain Aug 15, 2023
7bd8829
Add protocol match tests for outbound message
sfodagain Aug 17, 2023
423ff36
Fix constness and formatting
sfodagain Aug 17, 2023
31cf647
Add comments to the tests
sfodagain Aug 17, 2023
9c11ea4
Add more validations for outgoing DATA messages
sfodagain Aug 17, 2023
2f0046c
Fix naming
sfodagain Aug 17, 2023
c21052d
Return error on sending DATA message with incorrect parameters
sfodagain Aug 18, 2023
0124473
Fix comments
sfodagain Aug 18, 2023
2438ee1
Rearrange tests
sfodagain Aug 18, 2023
38484fe
Clean tests
sfodagain Aug 18, 2023
bab5632
Fix formatting
sfodagain Aug 18, 2023
4b5b31c
Add new errors, add test
sfodagain Aug 18, 2023
041e937
Fix formatting
sfodagain Aug 18, 2023
4d8e6e5
Fix typo
sfodagain Aug 18, 2023
a561c40
Fix tests naming
sfodagain Aug 18, 2023
267ab22
Fix order of enum errors
sfodagain Aug 18, 2023
424b24c
Fix enum erros
sfodagain Aug 18, 2023
5061e4a
Remove extra variable
sfodagain Aug 18, 2023
cdd6d72
Add test with data race
sfodagain Aug 22, 2023
8bdf6e7
Fix
sfodagain Aug 22, 2023
39137aa
Reproducible data race
sfodagain Aug 22, 2023
3eefe56
Working tests
sfodagain Aug 23, 2023
0618b39
Remove todo
sfodagain Aug 23, 2023
b30e584
Remove unused function
sfodagain Aug 23, 2023
e6e79f8
Remove todo
sfodagain Aug 23, 2023
1ed9483
Fix logging format
sfodagain Aug 23, 2023
388ff13
Rename goto label
sfodagain Aug 23, 2023
04c463a
Remove unused include
sfodagain Aug 23, 2023
59b863f
Remove stream start test
sfodagain Aug 23, 2023
662e32e
Fix tests naming
sfodagain Aug 23, 2023
fb2c9f5
Receive messages from mocked server in the event loop
sfodagain Aug 23, 2023
7757a8e
Add missing static
sfodagain Aug 23, 2023
fc70e82
Fix naming
sfodagain Aug 23, 2023
3cdf140
Remove unnecessary unused-casts
sfodagain Aug 23, 2023
dbbdbf2
Remove unused function
sfodagain Aug 23, 2023
5eea789
Use vtable for fixing connection id in outbound message
sfodagain Aug 24, 2023
1c1d97e
Add doxygen comments
sfodagain Aug 24, 2023
5a92cd9
Move STREAM_START validation to event loop
sfodagain Aug 24, 2023
1e7af76
Add test for STREM_START in SOURCE mode
sfodagain Aug 24, 2023
3b017c0
Revert "Move STREAM_START validation to event loop"
sfodagain Aug 24, 2023
9a77ade
Fix stream_start test
sfodagain Aug 24, 2023
05878fa
Add CONNECTION_START test for source mode
sfodagain Aug 24, 2023
2cbe3e4
Revert "Revert "Move STREAM_START validation to event loop""
sfodagain Aug 24, 2023
85da045
Revert "Move STREAM_START validation to event loop"
sfodagain Aug 24, 2023
0ab2997
Add test for outbound STREAM_START message causing reset
sfodagain Aug 24, 2023
5d1d183
Revert "Revert "Move STREAM_START validation to event loop""
sfodagain Aug 24, 2023
5521fd1
Move validation of CONNECTION_START to event loop
sfodagain Aug 24, 2023
254293a
Disable failing test
sfodagain Aug 24, 2023
78bc7fa
Fix stream_start test with reset
sfodagain Aug 24, 2023
1ee3b31
Fix windows build
sfodagain Aug 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/aws/iotdevice/iotdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ enum aws_iotdevice_error {
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_OPERATION_FAILED_DUE_TO_OFFLINE_QUEUE_POLICY,
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_UNEXPECTED_HANGUP,
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_USER_REQUESTED_STOP,
/* NOTE Leave the old name for compatibility. */
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_PROTOCOL_VERSION_MISSMATCH,
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_PROTOCOL_VERSION_MISMATCH =
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_PROTOCOL_VERSION_MISSMATCH,
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_TERMINATED,
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_DECODE_FAILURE,
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_DATA_NO_ACTIVE_CONNECTION,
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_DATA_PROTOCOL_VERSION_MISMATCH,
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_INACTIVE_SERVICE_ID,

AWS_ERROR_END_IOTDEVICE_RANGE = AWS_ERROR_ENUM_END_RANGE(AWS_C_IOTDEVICE_PACKAGE_ID),
};
Expand Down
2 changes: 1 addition & 1 deletion include/aws/iotdevice/private/secure_tunneling_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ struct aws_secure_tunnel_connections {
/* Table containing streams using multiplexing (service ids) */
struct aws_hash_table service_ids;

/* Message used for initializing a stream upon a reconnect due to a protocol version missmatch */
/* Message used for initializing a stream upon a reconnect due to a protocol version mismatch */
struct aws_secure_tunnel_message_storage *restore_stream_message_view;
struct aws_secure_tunnel_message_storage restore_stream_message;
};
Expand Down
5 changes: 5 additions & 0 deletions include/aws/iotdevice/private/secure_tunneling_operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ struct aws_secure_tunnel_operation_vtable {
int (*aws_secure_tunnel_operation_set_connection_start_id)(
struct aws_secure_tunnel_operation *operation,
struct aws_secure_tunnel *secure_tunnel);

/* Perform actions on outbound message before sending it */
void (*aws_secure_tunnel_operation_prepare_message_for_send_fn)(
struct aws_secure_tunnel_operation *operation,
struct aws_secure_tunnel *secure_tunnel);
};

/**
Expand Down
21 changes: 21 additions & 0 deletions include/aws/iotdevice/secure_tunneling.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,25 @@ const char *aws_secure_tunnel_message_type_to_c_string(enum aws_secure_tunnel_me
//***********************************************************************************************************************
/* THIS API SHOULD ONLY BE USED FROM SOURCE MODE */
//***********************************************************************************************************************
/**
* Queue a STREAM_START message in a secure tunnel
* @note This function should only be used from source mode.
* @param secure_tunnel secure tunnel to queue a message for
* @param message_options configuration options for the message operation
* @return success/failure in the synchronous logic that kicks off the message operation
*/
AWS_IOTDEVICE_API
int aws_secure_tunnel_stream_start(
struct aws_secure_tunnel *secure_tunnel,
const struct aws_secure_tunnel_message_view *message_options);

/**
* Queue a CONNECTION_START message in a secure tunnel
* @note This function should only be used from source mode.
* @param secure_tunnel secure tunnel to queue a message for
* @param message_options configuration options for the message operation
* @return success/failure in the synchronous logic that kicks off the message operation
*/
AWS_IOTDEVICE_API
int aws_secure_tunnel_connection_start(
struct aws_secure_tunnel *secure_tunnel,
Expand All @@ -331,6 +345,13 @@ int aws_secure_tunnel_connection_start(
//***********************************************************************************************************************
/* THIS API SHOULD NOT BE USED BY THE CUSTOMER AND IS DEPRECATED */
//***********************************************************************************************************************
/**
* Queue a STREAM_RESET message in a secure tunnel
* @deprecated This function should not be used.
* @param secure_tunnel secure tunnel to queue a message for
* @param message_options configuration options for the message operation
* @return success/failure in the synchronous logic that kicks off the message operation
*/
AWS_IOTDEVICE_API
int aws_secure_tunnel_stream_reset(
struct aws_secure_tunnel *secure_tunnel,
Expand Down
21 changes: 15 additions & 6 deletions source/iotdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,31 @@ static struct aws_error_info s_errors[] = {
"Error while processing secure tunnel operational state."),
AWS_DEFINE_ERROR_INFO_IOTDEVICE(
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_OPERATION_FAILED_DUE_TO_OFFLINE_QUEUE_POLICY,
"Error while processing secure tunnel operational state."),
"Secure Tunnel operation failed due to offline queue policy."),
AWS_DEFINE_ERROR_INFO_IOTDEVICE(
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_UNEXPECTED_HANGUP,
"The connection was closed unexpectedly."),
AWS_DEFINE_ERROR_INFO_IOTDEVICE(
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_USER_REQUESTED_STOP,
"Secure Tunnel connection interrupted by user request."),
AWS_DEFINE_ERROR_INFO_IOTDEVICE(
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_PROTOCOL_VERSION_MISSMATCH,
"Secure Tunnel connection interrupted due to a protocol version missmatch."),
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_PROTOCOL_VERSION_MISMATCH,
"Secure Tunnel connection interrupted due to a protocol version mismatch."),
AWS_DEFINE_ERROR_INFO_IOTDEVICE(
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_TERMINATED,
"Secure Tunnel terminated by user request."),
AWS_DEFINE_ERROR_INFO_IOTDEVICE(
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_DECODE_FAILURE,
"Error occured while decoding an incoming message." ),
AWS_DEFINE_ERROR_INFO_IOTDEVICE(
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_DECODE_FAILURE,
"Error occured while decoding an incoming message." ),
AWS_DEFINE_ERROR_INFO_IOTDEVICE(
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_DATA_NO_ACTIVE_CONNECTION,
"DATA message processing failed due to no active connection found." ),
AWS_DEFINE_ERROR_INFO_IOTDEVICE(
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_DATA_PROTOCOL_VERSION_MISMATCH,
"DATA message processing failed due to a protocol version mismatch." ),
AWS_DEFINE_ERROR_INFO_IOTDEVICE(
AWS_ERROR_IOTDEVICE_SECURE_TUNNELING_INACTIVE_SERVICE_ID,
"Secure Tunnel operation failed due to using inactive service id." ),
};
/* clang-format on */
#undef AWS_DEFINE_ERROR_INFO_IOTDEVICE
Expand Down
Loading