Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp iothub_client_sample_amqp ... more
Revision 53:e21e1e88460f, committed 2018-06-11
- Comitter:
- AzureIoTClient
- Date:
- Mon Jun 11 15:38:09 2018 -0700
- Parent:
- 52:615e9b97dd01
- Child:
- 54:830550fef7ea
- Commit message:
- 1.2.5
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/internal/iothub_client_retry_control.h Mon Jun 11 15:38:09 2018 -0700
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef IOTHUB_CLIENT_RETRY_CONTROL
+#define IOTHUB_CLIENT_RETRY_CONTROL
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include "azure_c_shared_utility/optionhandler.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
+#include "iothub_client_core_ll.h"
+#include "internal/iothubtransport.h"
+#include "azure_c_shared_utility/const_defines.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_INITIAL_WAIT_TIME_IN_SECS = "initial_wait_time_in_secs";
+static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_MAX_JITTER_PERCENT = "max_jitter_percent";
+static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_SAVED_OPTIONS = "retry_control_saved_options";
+
+typedef enum RETRY_ACTION_TAG
+{
+ RETRY_ACTION_RETRY_NOW,
+ RETRY_ACTION_RETRY_LATER,
+ RETRY_ACTION_STOP_RETRYING
+} RETRY_ACTION;
+
+struct RETRY_CONTROL_INSTANCE_TAG;
+typedef struct RETRY_CONTROL_INSTANCE_TAG* RETRY_CONTROL_HANDLE;
+
+MOCKABLE_FUNCTION(, RETRY_CONTROL_HANDLE, retry_control_create, IOTHUB_CLIENT_RETRY_POLICY, policy, unsigned int, max_retry_time_in_secs);
+MOCKABLE_FUNCTION(, int, retry_control_should_retry, RETRY_CONTROL_HANDLE, retry_control_handle, RETRY_ACTION*, retry_action);
+MOCKABLE_FUNCTION(, void, retry_control_reset, RETRY_CONTROL_HANDLE, retry_control_handle);
+MOCKABLE_FUNCTION(, int, retry_control_set_option, RETRY_CONTROL_HANDLE, retry_control_handle, const char*, name, const void*, value);
+MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, retry_control_retrieve_options, RETRY_CONTROL_HANDLE, retry_control_handle);
+MOCKABLE_FUNCTION(, void, retry_control_destroy, RETRY_CONTROL_HANDLE, retry_control_handle);
+
+MOCKABLE_FUNCTION(, int, is_timeout_reached, time_t, start_time, unsigned int, timeout_in_secs, bool*, is_timed_out);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // IOTHUB_CLIENT_RETRY_CONTROL
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/internal/iothubtransport_amqp_cbs_auth.h Mon Jun 11 15:38:09 2018 -0700
@@ -0,0 +1,71 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef IOTHUBTRANSPORT_AMQP_CBS_AUTH_H
+#define IOTHUBTRANSPORT_AMQP_CBS_AUTH_H
+
+#include <stdint.h>
+#include "internal/iothub_transport_ll_private.h"
+#include "azure_uamqp_c/cbs.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
+#include "azure_c_shared_utility/optionhandler.h"
+
+static const char* AUTHENTICATION_OPTION_SAVED_OPTIONS = "saved_authentication_options";
+static const char* AUTHENTICATION_OPTION_CBS_REQUEST_TIMEOUT_SECS = "cbs_request_timeout_secs";
+static const char* AUTHENTICATION_OPTION_SAS_TOKEN_REFRESH_TIME_SECS = "sas_token_refresh_time_secs";
+static const char* AUTHENTICATION_OPTION_SAS_TOKEN_LIFETIME_SECS = "sas_token_lifetime_secs";
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef enum AUTHENTICATION_STATE_TAG
+ {
+ AUTHENTICATION_STATE_STOPPED,
+ AUTHENTICATION_STATE_STARTING,
+ AUTHENTICATION_STATE_STARTED,
+ AUTHENTICATION_STATE_ERROR
+ } AUTHENTICATION_STATE;
+
+ typedef enum AUTHENTICATION_ERROR_TAG
+ {
+ AUTHENTICATION_ERROR_AUTH_TIMEOUT,
+ AUTHENTICATION_ERROR_AUTH_FAILED,
+ AUTHENTICATION_ERROR_SAS_REFRESH_TIMEOUT,
+ AUTHENTICATION_ERROR_SAS_REFRESH_FAILED
+ } AUTHENTICATION_ERROR_CODE;
+
+ typedef void(*ON_AUTHENTICATION_STATE_CHANGED_CALLBACK)(void* context, AUTHENTICATION_STATE previous_state, AUTHENTICATION_STATE new_state);
+ typedef void(*ON_AUTHENTICATION_ERROR_CALLBACK)(void* context, AUTHENTICATION_ERROR_CODE error_code);
+
+ typedef struct AUTHENTICATION_CONFIG_TAG
+ {
+ const char* device_id;
+ char* iothub_host_fqdn;
+
+ ON_AUTHENTICATION_STATE_CHANGED_CALLBACK on_state_changed_callback;
+ void* on_state_changed_callback_context;
+
+ ON_AUTHENTICATION_ERROR_CALLBACK on_error_callback;
+ void* on_error_callback_context;
+
+ IOTHUB_AUTHORIZATION_HANDLE authorization_module; // with either SAS Token, x509 Certs, and Device SAS Token
+
+ } AUTHENTICATION_CONFIG;
+
+ typedef struct AUTHENTICATION_INSTANCE* AUTHENTICATION_HANDLE;
+
+ MOCKABLE_FUNCTION(, AUTHENTICATION_HANDLE, authentication_create, const AUTHENTICATION_CONFIG*, config);
+ MOCKABLE_FUNCTION(, int, authentication_start, AUTHENTICATION_HANDLE, authentication_handle, const CBS_HANDLE, cbs_handle);
+ MOCKABLE_FUNCTION(, int, authentication_stop, AUTHENTICATION_HANDLE, authentication_handle);
+ MOCKABLE_FUNCTION(, void, authentication_do_work, AUTHENTICATION_HANDLE, authentication_handle);
+ MOCKABLE_FUNCTION(, void, authentication_destroy, AUTHENTICATION_HANDLE, authentication_handle);
+ MOCKABLE_FUNCTION(, int, authentication_set_option, AUTHENTICATION_HANDLE, authentication_handle, const char*, name, void*, value);
+ MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, authentication_retrieve_options, AUTHENTICATION_HANDLE, authentication_handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*IOTHUBTRANSPORT_AMQP_CBS_AUTH_H*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/internal/iothubtransport_amqp_common.h Mon Jun 11 15:38:09 2018 -0700
@@ -0,0 +1,50 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef IOTHUBTRANSPORTAMQP_COMMON_H
+#define IOTHUBTRANSPORTAMQP_COMMON_H
+
+#include "azure_c_shared_utility/strings.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
+#include "internal/iothub_transport_ll_private.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef struct AMQP_TRANSPORT_PROXY_OPTIONS_TAG
+{
+ const char* host_address;
+ int port;
+ const char* username;
+ const char* password;
+} AMQP_TRANSPORT_PROXY_OPTIONS;
+
+typedef XIO_HANDLE(*AMQP_GET_IO_TRANSPORT)(const char* target_fqdn, const AMQP_TRANSPORT_PROXY_OPTIONS* amqp_transport_proxy_options);
+static const char* OPTION_EVENT_SEND_TIMEOUT_SECS = "event_send_timeout_secs";
+
+MOCKABLE_FUNCTION(, TRANSPORT_LL_HANDLE, IoTHubTransport_AMQP_Common_Create, const IOTHUBTRANSPORT_CONFIG*, config, AMQP_GET_IO_TRANSPORT, get_io_transport);
+MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_Destroy, TRANSPORT_LL_HANDLE, handle);
+MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_Common_Subscribe, IOTHUB_DEVICE_HANDLE, handle);
+MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_Unsubscribe, IOTHUB_DEVICE_HANDLE, handle);
+MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_Common_Subscribe_DeviceTwin, IOTHUB_DEVICE_HANDLE, handle);
+MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_Unsubscribe_DeviceTwin, IOTHUB_DEVICE_HANDLE, handle);
+MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_Common_Subscribe_DeviceMethod, IOTHUB_DEVICE_HANDLE, handle);
+MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_Unsubscribe_DeviceMethod, IOTHUB_DEVICE_HANDLE, handle);
+MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_Common_DeviceMethod_Response, IOTHUB_DEVICE_HANDLE, handle, METHOD_HANDLE, methodId, const unsigned char*, response, size_t, response_size, int, status_response);
+MOCKABLE_FUNCTION(, IOTHUB_PROCESS_ITEM_RESULT, IoTHubTransport_AMQP_Common_ProcessItem, TRANSPORT_LL_HANDLE, handle, IOTHUB_IDENTITY_TYPE, item_type, IOTHUB_IDENTITY_INFO*, iothub_item);
+MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_DoWork, TRANSPORT_LL_HANDLE, handle, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle);
+MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_Common_SetRetryPolicy, TRANSPORT_LL_HANDLE, handle, IOTHUB_CLIENT_RETRY_POLICY, retryPolicy, size_t, retryTimeoutLimitInSeconds);
+MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_AMQP_Common_GetSendStatus, IOTHUB_DEVICE_HANDLE, handle, IOTHUB_CLIENT_STATUS*, iotHubClientStatus);
+MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_AMQP_Common_SetOption, TRANSPORT_LL_HANDLE, handle, const char*, option, const void*, value);
+MOCKABLE_FUNCTION(, IOTHUB_DEVICE_HANDLE, IoTHubTransport_AMQP_Common_Register, TRANSPORT_LL_HANDLE, handle, const IOTHUB_DEVICE_CONFIG*, device, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle, PDLIST_ENTRY, waitingToSend);
+MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_Unregister, IOTHUB_DEVICE_HANDLE, deviceHandle);
+MOCKABLE_FUNCTION(, STRING_HANDLE, IoTHubTransport_AMQP_Common_GetHostname, TRANSPORT_LL_HANDLE, handle);
+MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_AMQP_Common_SendMessageDisposition, MESSAGE_CALLBACK_INFO*, message_data, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IOTHUBTRANSPORTAMQP_COMMON_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/internal/iothubtransport_amqp_connection.h Mon Jun 11 15:38:09 2018 -0700
@@ -0,0 +1,54 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef IOTHUBTRANSPORTAMQP_AMQP_CONNECTION_H
+#define IOTHUBTRANSPORTAMQP_AMQP_CONNECTION_H
+
+#include "azure_c_shared_utility/umock_c_prod.h"
+#include "azure_c_shared_utility/macro_utils.h"
+#include "azure_c_shared_utility/xio.h"
+#include "azure_uamqp_c/session.h"
+#include "azure_uamqp_c/cbs.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define AMQP_CONNECTION_STATE_VALUES \
+ AMQP_CONNECTION_STATE_OPENED, \
+ AMQP_CONNECTION_STATE_CLOSED, \
+ AMQP_CONNECTION_STATE_ERROR
+
+DEFINE_ENUM(AMQP_CONNECTION_STATE, AMQP_CONNECTION_STATE_VALUES);
+
+typedef void(*ON_AMQP_CONNECTION_STATE_CHANGED)(const void* context, AMQP_CONNECTION_STATE old_state, AMQP_CONNECTION_STATE new_state);
+
+typedef struct AMQP_CONNECTION_CONFIG_TAG
+{
+ const char* iothub_host_fqdn;
+ XIO_HANDLE underlying_io_transport;
+ bool create_sasl_io;
+ bool create_cbs_connection;
+ bool is_trace_on;
+
+ ON_AMQP_CONNECTION_STATE_CHANGED on_state_changed_callback;
+ const void* on_state_changed_context;
+ size_t svc2cl_keep_alive_timeout_secs;
+ double cl2svc_keep_alive_send_ratio;
+} AMQP_CONNECTION_CONFIG;
+
+typedef struct AMQP_CONNECTION_INSTANCE* AMQP_CONNECTION_HANDLE;
+
+MOCKABLE_FUNCTION(, AMQP_CONNECTION_HANDLE, amqp_connection_create, AMQP_CONNECTION_CONFIG*, config);
+MOCKABLE_FUNCTION(, void, amqp_connection_destroy, AMQP_CONNECTION_HANDLE, conn_handle);
+MOCKABLE_FUNCTION(, void, amqp_connection_do_work, AMQP_CONNECTION_HANDLE, conn_handle);
+MOCKABLE_FUNCTION(, int, amqp_connection_get_session_handle, AMQP_CONNECTION_HANDLE, conn_handle, SESSION_HANDLE*, session_handle);
+MOCKABLE_FUNCTION(, int, amqp_connection_get_cbs_handle, AMQP_CONNECTION_HANDLE, conn_handle, CBS_HANDLE*, cbs_handle);
+MOCKABLE_FUNCTION(, int, amqp_connection_set_logging, AMQP_CONNECTION_HANDLE, conn_handle, bool, is_trace_on);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*IOTHUBTRANSPORTAMQP_AMQP_CONNECTION_H*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/internal/iothubtransport_amqp_device.h Mon Jun 11 15:38:09 2018 -0700
@@ -0,0 +1,129 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef IOTHUBTRANSPORTAMQP_AMQP_DEVICE_H
+#define IOTHUBTRANSPORTAMQP_AMQP_DEVICE_H
+
+#include "azure_c_shared_utility/umock_c_prod.h"
+#include "azure_c_shared_utility/optionhandler.h"
+#include "azure_uamqp_c/session.h"
+#include "azure_uamqp_c/cbs.h"
+#include "iothub_message.h"
+#include "iothub_client_private.h"
+#include "iothubtransport_amqp_device.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+// @brief name of option to apply the instance obtained using device_retrieve_options
+static const char* DEVICE_OPTION_SAVED_OPTIONS = "saved_device_options";
+static const char* DEVICE_OPTION_EVENT_SEND_TIMEOUT_SECS = "event_send_timeout_secs";
+static const char* DEVICE_OPTION_CBS_REQUEST_TIMEOUT_SECS = "cbs_request_timeout_secs";
+static const char* DEVICE_OPTION_SAS_TOKEN_REFRESH_TIME_SECS = "sas_token_refresh_time_secs";
+static const char* DEVICE_OPTION_SAS_TOKEN_LIFETIME_SECS = "sas_token_lifetime_secs";
+
+#define DEVICE_STATE_VALUES \
+ DEVICE_STATE_STOPPED, \
+ DEVICE_STATE_STOPPING, \
+ DEVICE_STATE_STARTING, \
+ DEVICE_STATE_STARTED, \
+ DEVICE_STATE_ERROR_AUTH, \
+ DEVICE_STATE_ERROR_AUTH_TIMEOUT, \
+ DEVICE_STATE_ERROR_MSG
+
+DEFINE_ENUM(DEVICE_STATE, DEVICE_STATE_VALUES);
+
+#define DEVICE_AUTH_MODE_VALUES \
+ DEVICE_AUTH_MODE_CBS, \
+ DEVICE_AUTH_MODE_X509
+
+DEFINE_ENUM(DEVICE_AUTH_MODE, DEVICE_AUTH_MODE_VALUES);
+
+#define DEVICE_SEND_STATUS_VALUES \
+ DEVICE_SEND_STATUS_IDLE, \
+ DEVICE_SEND_STATUS_BUSY
+
+DEFINE_ENUM(DEVICE_SEND_STATUS, DEVICE_SEND_STATUS_VALUES);
+
+#define D2C_EVENT_SEND_RESULT_VALUES \
+ D2C_EVENT_SEND_COMPLETE_RESULT_OK, \
+ D2C_EVENT_SEND_COMPLETE_RESULT_ERROR_CANNOT_PARSE, \
+ D2C_EVENT_SEND_COMPLETE_RESULT_ERROR_FAIL_SENDING, \
+ D2C_EVENT_SEND_COMPLETE_RESULT_ERROR_TIMEOUT, \
+ D2C_EVENT_SEND_COMPLETE_RESULT_DEVICE_DESTROYED, \
+ D2C_EVENT_SEND_COMPLETE_RESULT_ERROR_UNKNOWN
+
+DEFINE_ENUM(D2C_EVENT_SEND_RESULT, D2C_EVENT_SEND_RESULT_VALUES);
+
+#define DEVICE_MESSAGE_DISPOSITION_RESULT_VALUES \
+ DEVICE_MESSAGE_DISPOSITION_RESULT_NONE, \
+ DEVICE_MESSAGE_DISPOSITION_RESULT_ACCEPTED, \
+ DEVICE_MESSAGE_DISPOSITION_RESULT_REJECTED, \
+ DEVICE_MESSAGE_DISPOSITION_RESULT_RELEASED
+
+DEFINE_ENUM(DEVICE_MESSAGE_DISPOSITION_RESULT, DEVICE_MESSAGE_DISPOSITION_RESULT_VALUES);
+
+#define DEVICE_TWIN_UPDATE_RESULT_STRINGS \
+ DEVICE_TWIN_UPDATE_RESULT_OK, \
+ DEVICE_TWIN_UPDATE_RESULT_ERROR
+
+DEFINE_ENUM(DEVICE_TWIN_UPDATE_RESULT, DEVICE_TWIN_UPDATE_RESULT_STRINGS);
+
+#define DEVICE_TWIN_UPDATE_TYPE_STRINGS \
+ DEVICE_TWIN_UPDATE_TYPE_PARTIAL, \
+ DEVICE_TWIN_UPDATE_TYPE_COMPLETE
+
+DEFINE_ENUM(DEVICE_TWIN_UPDATE_TYPE, DEVICE_TWIN_UPDATE_TYPE_STRINGS)
+
+typedef struct DEVICE_MESSAGE_DISPOSITION_INFO_TAG
+{
+ unsigned long message_id;
+ char* source;
+} DEVICE_MESSAGE_DISPOSITION_INFO;
+
+typedef void(*ON_DEVICE_STATE_CHANGED)(void* context, DEVICE_STATE previous_state, DEVICE_STATE new_state);
+typedef DEVICE_MESSAGE_DISPOSITION_RESULT(*ON_DEVICE_C2D_MESSAGE_RECEIVED)(IOTHUB_MESSAGE_HANDLE message, DEVICE_MESSAGE_DISPOSITION_INFO* disposition_info, void* context);
+typedef void(*ON_DEVICE_D2C_EVENT_SEND_COMPLETE)(IOTHUB_MESSAGE_LIST* message, D2C_EVENT_SEND_RESULT result, void* context);
+typedef void(*DEVICE_SEND_TWIN_UPDATE_COMPLETE_CALLBACK)(DEVICE_TWIN_UPDATE_RESULT result, int status_code, void* context);
+typedef void(*DEVICE_TWIN_UPDATE_RECEIVED_CALLBACK)(DEVICE_TWIN_UPDATE_TYPE update_type, const unsigned char* message, size_t length, void* context);
+
+typedef struct DEVICE_CONFIG_TAG
+{
+ const char* device_id;
+ char* product_info;
+ char* iothub_host_fqdn;
+ DEVICE_AUTH_MODE authentication_mode;
+ ON_DEVICE_STATE_CHANGED on_state_changed_callback;
+ void* on_state_changed_context;
+
+ // Auth module used to generating handle authorization
+ // with either SAS Token, x509 Certs, and Device SAS Token
+ IOTHUB_AUTHORIZATION_HANDLE authorization_module;
+} DEVICE_CONFIG;
+
+typedef struct AMQP_DEVICE_INSTANCE* AMQP_DEVICE_HANDLE;
+
+MOCKABLE_FUNCTION(, AMQP_DEVICE_HANDLE, device_create, DEVICE_CONFIG*, config);
+MOCKABLE_FUNCTION(, void, device_destroy, AMQP_DEVICE_HANDLE, handle);
+MOCKABLE_FUNCTION(, int, device_start_async, AMQP_DEVICE_HANDLE, handle, SESSION_HANDLE, session_handle, CBS_HANDLE, cbs_handle);
+MOCKABLE_FUNCTION(, int, device_stop, AMQP_DEVICE_HANDLE, handle);
+MOCKABLE_FUNCTION(, void, device_do_work, AMQP_DEVICE_HANDLE, handle);
+MOCKABLE_FUNCTION(, int, device_send_event_async, AMQP_DEVICE_HANDLE, handle, IOTHUB_MESSAGE_LIST*, message, ON_DEVICE_D2C_EVENT_SEND_COMPLETE, on_device_d2c_event_send_complete_callback, void*, context);
+MOCKABLE_FUNCTION(, int, device_send_twin_update_async, AMQP_DEVICE_HANDLE, handle, CONSTBUFFER_HANDLE, data, DEVICE_SEND_TWIN_UPDATE_COMPLETE_CALLBACK, on_send_twin_update_complete_callback, void*, context);
+MOCKABLE_FUNCTION(, int, device_subscribe_for_twin_updates, AMQP_DEVICE_HANDLE, handle, DEVICE_TWIN_UPDATE_RECEIVED_CALLBACK, on_device_twin_update_received_callback, void*, context);
+MOCKABLE_FUNCTION(, int, device_unsubscribe_for_twin_updates, AMQP_DEVICE_HANDLE, handle);
+MOCKABLE_FUNCTION(, int, device_get_send_status, AMQP_DEVICE_HANDLE, handle, DEVICE_SEND_STATUS*, send_status);
+MOCKABLE_FUNCTION(, int, device_subscribe_message, AMQP_DEVICE_HANDLE, handle, ON_DEVICE_C2D_MESSAGE_RECEIVED, on_message_received_callback, void*, context);
+MOCKABLE_FUNCTION(, int, device_unsubscribe_message, AMQP_DEVICE_HANDLE, handle);
+MOCKABLE_FUNCTION(, int, device_send_message_disposition, AMQP_DEVICE_HANDLE, AMQP_DEVICE_HANDLE, DEVICE_MESSAGE_DISPOSITION_INFO*, disposition_info, DEVICE_MESSAGE_DISPOSITION_RESULT, disposition_result);
+MOCKABLE_FUNCTION(, int, device_set_retry_policy, AMQP_DEVICE_HANDLE, handle, IOTHUB_CLIENT_RETRY_POLICY, policy, size_t, retry_timeout_limit_in_seconds);
+MOCKABLE_FUNCTION(, int, device_set_option, AMQP_DEVICE_HANDLE, handle, const char*, name, void*, value);
+MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, device_retrieve_options, AMQP_DEVICE_HANDLE, handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // IOTHUBTRANSPORTAMQP_AMQP_DEVICE_H
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/internal/iothubtransport_amqp_messenger.h Mon Jun 11 15:38:09 2018 -0700
@@ -0,0 +1,129 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef IOTHUBTRANSPORT_AMQP_MESSENGER
+#define IOTHUBTRANSPORT_AMQP_MESSENGER
+
+#include "azure_c_shared_utility/umock_c_prod.h"
+#include "azure_c_shared_utility/optionhandler.h"
+#include "azure_c_shared_utility/map.h"
+#include "azure_uamqp_c/message.h"
+#include "azure_uamqp_c/session.h"
+#include "azure_uamqp_c/link.h"
+#include "azure_uamqp_c/amqp_definitions_sequence_no.h"
+#include "azure_uamqp_c/amqp_definitions_delivery_number.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+static const char* AMQP_MESSENGER_OPTION_EVENT_SEND_TIMEOUT_SECS = "amqp_event_send_timeout_secs";
+
+typedef struct AMQP_MESSENGER_INSTANCE* AMQP_MESSENGER_HANDLE;
+
+#define AMQP_MESSENGER_SEND_STATUS_VALUES \
+ AMQP_MESSENGER_SEND_STATUS_IDLE, \
+ AMQP_MESSENGER_SEND_STATUS_BUSY
+
+DEFINE_ENUM(AMQP_MESSENGER_SEND_STATUS, AMQP_MESSENGER_SEND_STATUS_VALUES);
+
+#define AMQP_MESSENGER_SEND_RESULT_VALUES \
+ AMQP_MESSENGER_SEND_RESULT_SUCCESS, \
+ AMQP_MESSENGER_SEND_RESULT_ERROR, \
+ AMQP_MESSENGER_SEND_RESULT_CANCELLED
+
+DEFINE_ENUM(AMQP_MESSENGER_SEND_RESULT, AMQP_MESSENGER_SEND_RESULT_VALUES);
+
+#define AMQP_MESSENGER_REASON_VALUES \
+ AMQP_MESSENGER_REASON_NONE, \
+ AMQP_MESSENGER_REASON_CANNOT_PARSE, \
+ AMQP_MESSENGER_REASON_FAIL_SENDING, \
+ AMQP_MESSENGER_REASON_TIMEOUT, \
+ AMQP_MESSENGER_REASON_MESSENGER_DESTROYED
+
+DEFINE_ENUM(AMQP_MESSENGER_REASON, AMQP_MESSENGER_REASON_VALUES);
+
+#define AMQP_MESSENGER_DISPOSITION_RESULT_VALUES \
+ AMQP_MESSENGER_DISPOSITION_RESULT_NONE, \
+ AMQP_MESSENGER_DISPOSITION_RESULT_ACCEPTED, \
+ AMQP_MESSENGER_DISPOSITION_RESULT_REJECTED, \
+ AMQP_MESSENGER_DISPOSITION_RESULT_RELEASED
+
+DEFINE_ENUM(AMQP_MESSENGER_DISPOSITION_RESULT, AMQP_MESSENGER_DISPOSITION_RESULT_VALUES);
+
+#define AMQP_MESSENGER_STATE_VALUES \
+ AMQP_MESSENGER_STATE_STARTING, \
+ AMQP_MESSENGER_STATE_STARTED, \
+ AMQP_MESSENGER_STATE_STOPPING, \
+ AMQP_MESSENGER_STATE_STOPPED, \
+ AMQP_MESSENGER_STATE_ERROR
+
+DEFINE_ENUM(AMQP_MESSENGER_STATE, AMQP_MESSENGER_STATE_VALUES);
+
+typedef struct AMQP_MESSENGER_MESSAGE_DISPOSITION_INFO_TAG
+{
+ delivery_number message_id;
+ char* source;
+} AMQP_MESSENGER_MESSAGE_DISPOSITION_INFO;
+
+typedef void(*AMQP_MESSENGER_SEND_COMPLETE_CALLBACK)(AMQP_MESSENGER_SEND_RESULT result, AMQP_MESSENGER_REASON reason, void* context);
+typedef void(*AMQP_MESSENGER_STATE_CHANGED_CALLBACK)(void* context, AMQP_MESSENGER_STATE previous_state, AMQP_MESSENGER_STATE new_state);
+typedef void(*AMQP_MESSENGER_SUBSCRIPTION_CALLBACK)(void* context, bool is_subscribed);
+typedef AMQP_MESSENGER_DISPOSITION_RESULT(*ON_AMQP_MESSENGER_MESSAGE_RECEIVED)(MESSAGE_HANDLE message, AMQP_MESSENGER_MESSAGE_DISPOSITION_INFO* disposition_info, void* context);
+
+typedef struct AMQP_MESSENGER_LINK_CONFIG_TAG
+{
+ /**
+ * @brief Sample format: "/messages/devicebound"
+ */
+ char* source_suffix;
+
+ /**
+ * @brief Sample format: "/messages/events"
+ */
+ char* target_suffix;
+
+ receiver_settle_mode rcv_settle_mode;
+ sender_settle_mode snd_settle_mode;
+
+ MAP_HANDLE attach_properties;
+} AMQP_MESSENGER_LINK_CONFIG;
+
+typedef struct AMQP_MESSENGER_CONFIG_TAG
+{
+ char* client_version;
+ char* device_id;
+ char* iothub_host_fqdn;
+
+ AMQP_MESSENGER_LINK_CONFIG send_link;
+ AMQP_MESSENGER_LINK_CONFIG receive_link;
+
+ AMQP_MESSENGER_STATE_CHANGED_CALLBACK on_state_changed_callback;
+ void* on_state_changed_context;
+
+ AMQP_MESSENGER_SUBSCRIPTION_CALLBACK on_subscription_changed_callback;
+ void* on_subscription_changed_context;
+} AMQP_MESSENGER_CONFIG;
+
+MOCKABLE_FUNCTION(, AMQP_MESSENGER_HANDLE, amqp_messenger_create, const AMQP_MESSENGER_CONFIG*, messenger_config);
+MOCKABLE_FUNCTION(, int, amqp_messenger_send_async, AMQP_MESSENGER_HANDLE, messenger_handle, MESSAGE_HANDLE, message, AMQP_MESSENGER_SEND_COMPLETE_CALLBACK, on_messenger_event_send_complete_callback, void*, context);
+MOCKABLE_FUNCTION(, int, amqp_messenger_subscribe_for_messages, AMQP_MESSENGER_HANDLE, messenger_handle, ON_AMQP_MESSENGER_MESSAGE_RECEIVED, on_message_received_callback, void*, context);
+MOCKABLE_FUNCTION(, int, amqp_messenger_unsubscribe_for_messages, AMQP_MESSENGER_HANDLE, messenger_handle);
+MOCKABLE_FUNCTION(, int, amqp_messenger_send_message_disposition, AMQP_MESSENGER_HANDLE, messenger_handle, AMQP_MESSENGER_MESSAGE_DISPOSITION_INFO*, disposition_info, AMQP_MESSENGER_DISPOSITION_RESULT, disposition_result);
+MOCKABLE_FUNCTION(, int, amqp_messenger_get_send_status, AMQP_MESSENGER_HANDLE, messenger_handle, AMQP_MESSENGER_SEND_STATUS*, send_status);
+MOCKABLE_FUNCTION(, int, amqp_messenger_start, AMQP_MESSENGER_HANDLE, messenger_handle, SESSION_HANDLE, session_handle);
+MOCKABLE_FUNCTION(, int, amqp_messenger_stop, AMQP_MESSENGER_HANDLE, messenger_handle);
+MOCKABLE_FUNCTION(, void, amqp_messenger_do_work, AMQP_MESSENGER_HANDLE, messenger_handle);
+MOCKABLE_FUNCTION(, void, amqp_messenger_destroy, AMQP_MESSENGER_HANDLE, messenger_handle);
+MOCKABLE_FUNCTION(, int, amqp_messenger_set_option, AMQP_MESSENGER_HANDLE, messenger_handle, const char*, name, void*, value);
+MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, amqp_messenger_retrieve_options, AMQP_MESSENGER_HANDLE, messenger_handle);
+MOCKABLE_FUNCTION(, void, amqp_messenger_destroy_disposition_info, AMQP_MESSENGER_MESSAGE_DISPOSITION_INFO*, disposition_info);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*IOTHUBTRANSPORT_AMQP_AMQP_MESSENGER*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/internal/iothubtransport_amqp_telemetry_messenger.h Mon Jun 11 15:38:09 2018 -0700
@@ -0,0 +1,97 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef IOTHUBTRANSPORT_AMQP_TELEMETRY_MESSENGER
+#define IOTHUBTRANSPORT_AMQP_TELEMETRY_MESSENGER
+
+#include "azure_c_shared_utility/umock_c_prod.h"
+#include "azure_c_shared_utility/optionhandler.h"
+#include "azure_uamqp_c/session.h"
+
+#include "azure_uamqp_c/amqp_definitions_sequence_no.h"
+#include "azure_uamqp_c/amqp_definitions_delivery_number.h"
+
+#include "iothub_client_private.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+static const char* TELEMETRY_MESSENGER_OPTION_EVENT_SEND_TIMEOUT_SECS = "telemetry_event_send_timeout_secs";
+static const char* TELEMETRY_MESSENGER_OPTION_SAVED_OPTIONS = "saved_telemetry_messenger_options";
+
+typedef struct TELEMETRY_MESSENGER_INSTANCE* TELEMETRY_MESSENGER_HANDLE;
+
+typedef enum TELEMETRY_MESSENGER_SEND_STATUS_TAG
+{
+ TELEMETRY_MESSENGER_SEND_STATUS_IDLE,
+ TELEMETRY_MESSENGER_SEND_STATUS_BUSY
+} TELEMETRY_MESSENGER_SEND_STATUS;
+
+typedef enum TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_TAG
+{
+ TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_OK,
+ TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_ERROR_CANNOT_PARSE,
+ TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_ERROR_FAIL_SENDING,
+ TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_ERROR_TIMEOUT,
+ TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_MESSENGER_DESTROYED
+} TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT;
+
+typedef enum TELEMETRY_MESSENGER_DISPOSITION_RESULT_TAG
+{
+ TELEMETRY_MESSENGER_DISPOSITION_RESULT_NONE,
+ TELEMETRY_MESSENGER_DISPOSITION_RESULT_ACCEPTED,
+ TELEMETRY_MESSENGER_DISPOSITION_RESULT_REJECTED,
+ TELEMETRY_MESSENGER_DISPOSITION_RESULT_RELEASED
+} TELEMETRY_MESSENGER_DISPOSITION_RESULT;
+
+typedef enum TELEMETRY_MESSENGER_STATE_TAG
+{
+ TELEMETRY_MESSENGER_STATE_STARTING,
+ TELEMETRY_MESSENGER_STATE_STARTED,
+ TELEMETRY_MESSENGER_STATE_STOPPING,
+ TELEMETRY_MESSENGER_STATE_STOPPED,
+ TELEMETRY_MESSENGER_STATE_ERROR
+} TELEMETRY_MESSENGER_STATE;
+
+typedef struct TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO_TAG
+{
+ delivery_number message_id;
+ char* source;
+} TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO;
+
+typedef void(*ON_TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE)(IOTHUB_MESSAGE_LIST* iothub_message_list, TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT messenger_event_send_complete_result, void* context);
+typedef void(*ON_TELEMETRY_MESSENGER_STATE_CHANGED_CALLBACK)(void* context, TELEMETRY_MESSENGER_STATE previous_state, TELEMETRY_MESSENGER_STATE new_state);
+typedef TELEMETRY_MESSENGER_DISPOSITION_RESULT(*ON_TELEMETRY_MESSENGER_MESSAGE_RECEIVED)(IOTHUB_MESSAGE_HANDLE message, TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO* disposition_info, void* context);
+
+typedef struct TELEMETRY_MESSENGER_CONFIG_TAG
+{
+ const char* device_id;
+ char* iothub_host_fqdn;
+ ON_TELEMETRY_MESSENGER_STATE_CHANGED_CALLBACK on_state_changed_callback;
+ void* on_state_changed_context;
+} TELEMETRY_MESSENGER_CONFIG;
+
+#define AMQP_BATCHING_RESERVE_SIZE (1024)
+
+MOCKABLE_FUNCTION(, TELEMETRY_MESSENGER_HANDLE, telemetry_messenger_create, const TELEMETRY_MESSENGER_CONFIG*, messenger_config, const char*, product_info);
+MOCKABLE_FUNCTION(, int, telemetry_messenger_send_async, TELEMETRY_MESSENGER_HANDLE, messenger_handle, IOTHUB_MESSAGE_LIST*, message, ON_TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE, on_messenger_event_send_complete_callback, void*, context);
+MOCKABLE_FUNCTION(, int, telemetry_messenger_subscribe_for_messages, TELEMETRY_MESSENGER_HANDLE, messenger_handle, ON_TELEMETRY_MESSENGER_MESSAGE_RECEIVED, on_message_received_callback, void*, context);
+MOCKABLE_FUNCTION(, int, telemetry_messenger_unsubscribe_for_messages, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
+MOCKABLE_FUNCTION(, int, telemetry_messenger_send_message_disposition, TELEMETRY_MESSENGER_HANDLE, messenger_handle, TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO*, disposition_info, TELEMETRY_MESSENGER_DISPOSITION_RESULT, disposition_result);
+MOCKABLE_FUNCTION(, int, telemetry_messenger_get_send_status, TELEMETRY_MESSENGER_HANDLE, messenger_handle, TELEMETRY_MESSENGER_SEND_STATUS*, send_status);
+MOCKABLE_FUNCTION(, int, telemetry_messenger_start, TELEMETRY_MESSENGER_HANDLE, messenger_handle, SESSION_HANDLE, session_handle);
+MOCKABLE_FUNCTION(, int, telemetry_messenger_stop, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
+MOCKABLE_FUNCTION(, void, telemetry_messenger_do_work, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
+MOCKABLE_FUNCTION(, void, telemetry_messenger_destroy, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
+MOCKABLE_FUNCTION(, int, telemetry_messenger_set_option, TELEMETRY_MESSENGER_HANDLE, messenger_handle, const char*, name, void*, value);
+MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, telemetry_messenger_retrieve_options, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*IOTHUBTRANSPORT_AMQP_TELEMETRY_MESSENGER*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/internal/iothubtransport_amqp_twin_messenger.h Mon Jun 11 15:38:09 2018 -0700
@@ -0,0 +1,87 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef IOTHUBTRANSPORT_AMQP_TWIN_MESSENGER
+#define IOTHUBTRANSPORT_AMQP_TWIN_MESSENGER
+
+#include "azure_c_shared_utility/macro_utils.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
+#include "azure_c_shared_utility/optionhandler.h"
+#include "azure_uamqp_c/session.h"
+#include "iothub_client_private.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct TWIN_MESSENGER_INSTANCE* TWIN_MESSENGER_HANDLE;
+
+ #define TWIN_MESSENGER_SEND_STATUS_VALUES \
+ TWIN_MESSENGER_SEND_STATUS_IDLE, \
+ TWIN_MESSENGER_SEND_STATUS_BUSY
+
+ DEFINE_ENUM(TWIN_MESSENGER_SEND_STATUS, TWIN_MESSENGER_SEND_STATUS_VALUES);
+
+ #define TWIN_REPORT_STATE_RESULT_VALUES \
+ TWIN_REPORT_STATE_RESULT_SUCCESS, \
+ TWIN_REPORT_STATE_RESULT_ERROR, \
+ TWIN_REPORT_STATE_RESULT_CANCELLED
+
+ DEFINE_ENUM(TWIN_REPORT_STATE_RESULT, TWIN_REPORT_STATE_RESULT_VALUES);
+
+ #define TWIN_REPORT_STATE_REASON_VALUES \
+ TWIN_REPORT_STATE_REASON_NONE, \
+ TWIN_REPORT_STATE_REASON_INTERNAL_ERROR, \
+ TWIN_REPORT_STATE_REASON_FAIL_SENDING, \
+ TWIN_REPORT_STATE_REASON_TIMEOUT, \
+ TWIN_REPORT_STATE_REASON_INVALID_RESPONSE, \
+ TWIN_REPORT_STATE_REASON_MESSENGER_DESTROYED
+
+ DEFINE_ENUM(TWIN_REPORT_STATE_REASON, TWIN_REPORT_STATE_REASON_VALUES);
+
+ #define TWIN_MESSENGER_STATE_VALUES \
+ TWIN_MESSENGER_STATE_STARTING, \
+ TWIN_MESSENGER_STATE_STARTED, \
+ TWIN_MESSENGER_STATE_STOPPING, \
+ TWIN_MESSENGER_STATE_STOPPED, \
+ TWIN_MESSENGER_STATE_ERROR
+
+ DEFINE_ENUM(TWIN_MESSENGER_STATE, TWIN_MESSENGER_STATE_VALUES);
+
+ #define TWIN_UPDATE_TYPE_VALUES \
+ TWIN_UPDATE_TYPE_PARTIAL, \
+ TWIN_UPDATE_TYPE_COMPLETE
+
+ DEFINE_ENUM(TWIN_UPDATE_TYPE, TWIN_UPDATE_TYPE_VALUES);
+
+ typedef void(*TWIN_MESSENGER_STATE_CHANGED_CALLBACK)(void* context, TWIN_MESSENGER_STATE previous_state, TWIN_MESSENGER_STATE new_state);
+ typedef void(*TWIN_MESSENGER_REPORT_STATE_COMPLETE_CALLBACK)(TWIN_REPORT_STATE_RESULT result, TWIN_REPORT_STATE_REASON reason, int status_code, const void* context);
+ typedef void(*TWIN_STATE_UPDATE_CALLBACK)(TWIN_UPDATE_TYPE update_type, const char* payload, size_t size, const void* context);
+
+ typedef struct TWIN_MESSENGER_CONFIG_TAG
+ {
+ const char* client_version;
+ const char* device_id;
+ char* iothub_host_fqdn;
+ TWIN_MESSENGER_STATE_CHANGED_CALLBACK on_state_changed_callback;
+ void* on_state_changed_context;
+ } TWIN_MESSENGER_CONFIG;
+
+ MOCKABLE_FUNCTION(, TWIN_MESSENGER_HANDLE, twin_messenger_create, const TWIN_MESSENGER_CONFIG*, messenger_config);
+ MOCKABLE_FUNCTION(, int, twin_messenger_report_state_async, TWIN_MESSENGER_HANDLE, twin_msgr_handle, CONSTBUFFER_HANDLE, data, TWIN_MESSENGER_REPORT_STATE_COMPLETE_CALLBACK, on_report_state_complete_callback, const void*, context);
+ MOCKABLE_FUNCTION(, int, twin_messenger_subscribe, TWIN_MESSENGER_HANDLE, twin_msgr_handle, TWIN_STATE_UPDATE_CALLBACK, on_twin_state_update_callback, void*, context);
+ MOCKABLE_FUNCTION(, int, twin_messenger_unsubscribe, TWIN_MESSENGER_HANDLE, twin_msgr_handle);
+ MOCKABLE_FUNCTION(, int, twin_messenger_get_send_status, TWIN_MESSENGER_HANDLE, twin_msgr_handle, TWIN_MESSENGER_SEND_STATUS*, send_status);
+ MOCKABLE_FUNCTION(, int, twin_messenger_start, TWIN_MESSENGER_HANDLE, twin_msgr_handle, SESSION_HANDLE, session_handle);
+ MOCKABLE_FUNCTION(, int, twin_messenger_stop, TWIN_MESSENGER_HANDLE, twin_msgr_handle);
+ MOCKABLE_FUNCTION(, void, twin_messenger_do_work, TWIN_MESSENGER_HANDLE, twin_msgr_handle);
+ MOCKABLE_FUNCTION(, void, twin_messenger_destroy, TWIN_MESSENGER_HANDLE, twin_msgr_handle);
+ MOCKABLE_FUNCTION(, int, twin_messenger_set_option, TWIN_MESSENGER_HANDLE, twin_msgr_handle, const char*, name, void*, value);
+ MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, twin_messenger_retrieve_options, TWIN_MESSENGER_HANDLE, twin_msgr_handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*IOTHUBTRANSPORT_AMQP_TWIN_MESSENGER*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/internal/iothubtransportamqp_methods.h Mon Jun 11 15:38:09 2018 -0700
@@ -0,0 +1,40 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef IOTHUBTRANSPORTAMQP_METHODS_H
+#define IOTHUBTRANSPORTAMQP_METHODS_H
+
+#include "azure_uamqp_c/session.h"
+#include "azure_c_shared_utility/buffer_.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
+
+#ifdef __cplusplus
+#include <cstddef>
+
+extern "C"
+{
+#else
+#include <stddef.h>
+#endif
+
+ typedef struct IOTHUBTRANSPORT_AMQP_METHOD_TAG* IOTHUBTRANSPORT_AMQP_METHOD_HANDLE;
+ typedef struct IOTHUBTRANSPORT_AMQP_METHODS_TAG* IOTHUBTRANSPORT_AMQP_METHODS_HANDLE;
+ typedef void(*ON_METHODS_ERROR)(void* context);
+ typedef int(*ON_METHOD_REQUEST_RECEIVED)(void* context, const char* method_name, const unsigned char* request, size_t request_size, IOTHUBTRANSPORT_AMQP_METHOD_HANDLE response);
+ typedef void(*ON_METHODS_UNSUBSCRIBED)(void* context);
+
+ MOCKABLE_FUNCTION(, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransportamqp_methods_create, const char*, hostname, const char*, device_id);
+ MOCKABLE_FUNCTION(, void, iothubtransportamqp_methods_destroy, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransport_amqp_methods_handle);
+ MOCKABLE_FUNCTION(, int, iothubtransportamqp_methods_subscribe, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransport_amqp_methods_handle,
+ SESSION_HANDLE, session_handle, ON_METHODS_ERROR, on_methods_error, void*, on_methods_error_context,
+ ON_METHOD_REQUEST_RECEIVED, on_method_request_received, void*, on_method_request_received_context,
+ ON_METHODS_UNSUBSCRIBED, on_methods_unsubscribed, void*, on_methods_unsubscribed_context);
+ MOCKABLE_FUNCTION(, int, iothubtransportamqp_methods_respond, IOTHUBTRANSPORT_AMQP_METHOD_HANDLE, method_handle,
+ const unsigned char*, response, size_t, response_size, int, status_code);
+ MOCKABLE_FUNCTION(, void, iothubtransportamqp_methods_unsubscribe, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransport_amqp_methods_handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IOTHUBTRANSPORTAMQP_METHODS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/internal/message_queue.h Mon Jun 11 15:38:09 2018 -0700
@@ -0,0 +1,182 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+/** @file message_queue.h
+* @brief A generic message queue.
+*/
+
+#ifndef MESSAGE_QUEUE_H
+#define MESSAGE_QUEUE_H
+
+#include "azure_c_shared_utility/macro_utils.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
+#include "azure_c_shared_utility/optionhandler.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef struct MESSAGE_QUEUE_TAG* MESSAGE_QUEUE_HANDLE;
+typedef void* MQ_MESSAGE_HANDLE;
+typedef void* USER_DEFINED_REASON;
+
+#define MESSAGE_QUEUE_RESULT_STRINGS \
+ MESSAGE_QUEUE_SUCCESS, \
+ MESSAGE_QUEUE_ERROR, \
+ MESSAGE_QUEUE_RETRYABLE_ERROR, \
+ MESSAGE_QUEUE_TIMEOUT, \
+ MESSAGE_QUEUE_CANCELLED
+
+DEFINE_ENUM(MESSAGE_QUEUE_RESULT, MESSAGE_QUEUE_RESULT_STRINGS);
+
+/**
+* @brief User-provided callback invoked by MESSAGE_QUEUE back to the user when a messages completes being processed.
+*/
+typedef void(*MESSAGE_PROCESSING_COMPLETED_CALLBACK)(MQ_MESSAGE_HANDLE message, MESSAGE_QUEUE_RESULT result, USER_DEFINED_REASON reason, void* user_context);
+
+/**
+* @brief Callback that MUST be invoked by PROCESS_MESSAGE_CALLBACK (user provided) to signal to MESSAGE_QUEUE that a message has been processed.
+* @remarks Besides causing MESSAGE_QUEUE to dequeue the message from its internal lists, causes MESSAGE_PROCESSING_COMPLETED_CALLBACK to be triggered.
+*/
+typedef void(*PROCESS_MESSAGE_COMPLETED_CALLBACK)(MESSAGE_QUEUE_HANDLE message_queue, MQ_MESSAGE_HANDLE message, MESSAGE_QUEUE_RESULT result, USER_DEFINED_REASON reason);
+
+/**
+* @brief User-provided callback invoked by MESSAGE_QUEUE when a messages is ready to be processed, getting internally moved from "pending" to "in-progress".
+*/
+typedef void(*PROCESS_MESSAGE_CALLBACK)(MESSAGE_QUEUE_HANDLE message_queue, MQ_MESSAGE_HANDLE message, PROCESS_MESSAGE_COMPLETED_CALLBACK on_process_message_completed_callback, void* user_context);
+
+typedef struct MESSAGE_QUEUE_CONFIG_TAG
+{
+ /**
+ * @brief Function that actually process (a.k.a, e.g, sends) a message previously queued.
+ *
+ * @remarks When MESSAGE_QUEUE is summoned to invoke @c on_process_message_callback (upon call to message_queue_do_work, when a message is moved from the pending to in-progress list),
+ * it passes as arguments the MESSAGE_QUEUE handle and a callback function that MUST be invoked by @c on_process_message_callback once it completes.
+ * The @c user_context passed is the same provided as argument by the upper layer on @c message_queue_add.
+ */
+ PROCESS_MESSAGE_CALLBACK on_process_message_callback;
+ size_t max_message_enqueued_time_secs;
+ size_t max_message_processing_time_secs;
+ size_t max_retry_count;
+} MESSAGE_QUEUE_CONFIG;
+
+/**
+* @brief Creates a new instance of MESSAGE_QUEUE.
+*
+* @param config Pointer to an @c MESSAGE_QUEUE_CONFIG structure
+*
+* @returns A non-NULL @c MESSAGE_QUEUE_HANDLE value that is used when invoking other API functions.
+*/
+MOCKABLE_FUNCTION(, MESSAGE_QUEUE_HANDLE, message_queue_create, MESSAGE_QUEUE_CONFIG*, config);
+
+/**
+* @brief Destroys an instance of MESSAGE_QUEUE, releasing all memory it allocated.
+*
+* @remarks All messages still pending to be processed and currently in-progress get bubbled up back to the upper-layer
+* through the @c on_message_processing_completed_callback (passed on the @c MESSAGE_QUEUE_CONFIG instance)
+* with the @c result set as @c MESSAGE_QUEUE_CANCELLED and @c reason set to @c NULL.
+*
+* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
+*/
+MOCKABLE_FUNCTION(, void, message_queue_destroy, MESSAGE_QUEUE_HANDLE, message_queue);
+
+/**
+* @brief Adds a new generic message to MESSAGE_QUEUE's pending list.
+*
+* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
+*
+* @param message A generic message to be queued and then processed (i.e., sent, consolidated, etc).
+*
+* @returns Zero if the no errors occur, non-zero otherwise.
+*/
+MOCKABLE_FUNCTION(, int, message_queue_add, MESSAGE_QUEUE_HANDLE, message_queue, MQ_MESSAGE_HANDLE, message, MESSAGE_PROCESSING_COMPLETED_CALLBACK, on_message_processing_completed_callback, void*, user_context);
+
+/**
+* @brief Causes all messages in-progress to be moved back to the beginning of the pending list.
+*
+* @remarks If on_message_process_completed_callback is invoked for any of message not in in-progress, it is disregarded.
+* Messages are queued back into the pending list in a way they will be sent first when message_queue_do_work is invoked again.
+*
+* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
+*
+* @returns Zero if the no errors occur, non-zero otherwise.
+*/
+MOCKABLE_FUNCTION(, int, message_queue_move_all_back_to_pending, MESSAGE_QUEUE_HANDLE, message_queue);
+
+/**
+* @brief Causes all messages pending to be sent and in-progress to be flushed back to the user through @c on_message_processing_completed_callback.
+*
+* @remarks @c on_message_processing_completed_callback gets invoked with @c result set as MESSAGE_QUEUE_CANCELLED and @c reason set to NULL.
+*
+* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
+*/
+MOCKABLE_FUNCTION(, void, message_queue_remove_all, MESSAGE_QUEUE_HANDLE, message_queue);
+
+/**
+* @brief Informs if there are messages pending to be sent and/or currently in-progress.
+*
+* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
+*
+* @param @c is_empty Set to @c true if there are any messages in pending to be sent and/or currently in-progress, @c false otherwise.
+*
+* @remarks The parameter @c is_empty is only set if no errors occur (like passing a NULL @c message_queue).
+*
+* @returns Zero if the no errors occur, non-zero otherwise.
+*/
+MOCKABLE_FUNCTION(, int, message_queue_is_empty, MESSAGE_QUEUE_HANDLE, message_queue, bool*, is_empty);
+
+/**
+* @brief Causes MESSAGE_QUEUE to go through its list of pending messages and move them to in-progress, as well as trigering retry and timeout controls.
+*
+* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
+*/
+MOCKABLE_FUNCTION(, void, message_queue_do_work, MESSAGE_QUEUE_HANDLE, message_queue);
+
+/**
+* @brief Sets the maximum time, in seconds, a message will be within MESSAGE_QUEUE (in either pending or in-progress lists).
+*
+* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
+*
+* @param seconds Number of seconds to set for this timeout. A value of zero de-activates this timeout control.
+*
+* @returns Zero if the no errors occur, non-zero otherwise.
+*/
+MOCKABLE_FUNCTION(, int, message_queue_set_max_message_enqueued_time_secs, MESSAGE_QUEUE_HANDLE, message_queue, size_t, seconds);
+
+/**
+* @brief Sets the maximum time, in seconds, a message will be in-progress within MESSAGE_QUEUE.
+*
+* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
+*
+* @param seconds Number of seconds to set for this timeout. A value of zero de-activates this timeout control.
+*
+* @returns Zero if the no errors occur, non-zero otherwise.
+*/
+MOCKABLE_FUNCTION(, int, message_queue_set_max_message_processing_time_secs, MESSAGE_QUEUE_HANDLE, message_queue, size_t, seconds);
+
+/**
+* @brief Sets the maximum number of times MESSAGE_QUEUE will try to re-process a message (no counting the initial attempt).
+*
+* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
+*
+* @param max_retry_count The number of times MESSAGE_QUEUE will try to re-process a message.
+*
+* @returns Zero if the no errors occur, non-zero otherwise.
+*/
+MOCKABLE_FUNCTION(, int, message_queue_set_max_retry_count, MESSAGE_QUEUE_HANDLE, message_queue, size_t, max_retry_count);
+
+/**
+* @brief Retrieves a blob with all the options currently set in the instance of MESSAGE_QUEUE.
+*
+* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
+*
+* @returns A non-NULL @c OPTIONHANDLER_HANDLE if no errors occur, or NULL otherwise.
+*/
+MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, message_queue_retrieve_options, MESSAGE_QUEUE_HANDLE, message_queue);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*MESSAGE_QUEUE_H*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/internal/uamqp_messaging.h Mon Jun 11 15:38:09 2018 -0700
@@ -0,0 +1,23 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+#ifndef UAMQP_MESSAGING_H
+#define UAMQP_MESSAGING_H
+
+#include "iothub_message.h"
+#include "azure_uamqp_c/message.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ MOCKABLE_FUNCTION(, int, message_create_IoTHubMessage_from_uamqp_message, MESSAGE_HANDLE, uamqp_message, IOTHUB_MESSAGE_HANDLE*, iothubclient_message);
+ MOCKABLE_FUNCTION(, int, message_create_uamqp_encoding_from_iothub_message, MESSAGE_HANDLE, message_batch_container, IOTHUB_MESSAGE_HANDLE, message_handle, BINARY_DATA*, body_binary_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*UAMQP_MESSAGING_H*/
\ No newline at end of file
--- a/iothub_client_retry_control.c Fri May 04 13:22:48 2018 -0700 +++ b/iothub_client_retry_control.c Mon Jun 11 15:38:09 2018 -0700 @@ -1,7 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#include "iothub_client_retry_control.h" +#include "internal/iothub_client_retry_control.h" #include <math.h>
--- a/iothub_client_retry_control.h Fri May 04 13:22:48 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-#ifndef IOTHUB_CLIENT_RETRY_CONTROL
-#define IOTHUB_CLIENT_RETRY_CONTROL
-
-#include <stdlib.h>
-#include <stdbool.h>
-#include "azure_c_shared_utility/optionhandler.h"
-#include "azure_c_shared_utility/umock_c_prod.h"
-#include "iothub_client_ll.h"
-#include "azure_c_shared_utility/const_defines.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_INITIAL_WAIT_TIME_IN_SECS = "initial_wait_time_in_secs";
-static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_MAX_JITTER_PERCENT = "max_jitter_percent";
-static STATIC_VAR_UNUSED const char* RETRY_CONTROL_OPTION_SAVED_OPTIONS = "retry_control_saved_options";
-
-typedef enum RETRY_ACTION_TAG
-{
- RETRY_ACTION_RETRY_NOW,
- RETRY_ACTION_RETRY_LATER,
- RETRY_ACTION_STOP_RETRYING
-} RETRY_ACTION;
-
-struct RETRY_CONTROL_INSTANCE_TAG;
-typedef struct RETRY_CONTROL_INSTANCE_TAG* RETRY_CONTROL_HANDLE;
-
-MOCKABLE_FUNCTION(, RETRY_CONTROL_HANDLE, retry_control_create, IOTHUB_CLIENT_RETRY_POLICY, policy, unsigned int, max_retry_time_in_secs);
-MOCKABLE_FUNCTION(, int, retry_control_should_retry, RETRY_CONTROL_HANDLE, retry_control_handle, RETRY_ACTION*, retry_action);
-MOCKABLE_FUNCTION(, void, retry_control_reset, RETRY_CONTROL_HANDLE, retry_control_handle);
-MOCKABLE_FUNCTION(, int, retry_control_set_option, RETRY_CONTROL_HANDLE, retry_control_handle, const char*, name, const void*, value);
-MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, retry_control_retrieve_options, RETRY_CONTROL_HANDLE, retry_control_handle);
-MOCKABLE_FUNCTION(, void, retry_control_destroy, RETRY_CONTROL_HANDLE, retry_control_handle);
-
-MOCKABLE_FUNCTION(, int, is_timeout_reached, time_t, start_time, unsigned int, timeout_in_secs, bool*, is_timed_out);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // IOTHUB_CLIENT_RETRY_CONTROL
\ No newline at end of file
--- a/iothubtransport_amqp_cbs_auth.c Fri May 04 13:22:48 2018 -0700
+++ b/iothubtransport_amqp_cbs_auth.c Mon Jun 11 15:38:09 2018 -0700
@@ -2,7 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <stdlib.h>
-#include "iothubtransport_amqp_cbs_auth.h"
+#include "internal/iothubtransport_amqp_cbs_auth.h"
#include "azure_c_shared_utility/optimize_size.h"
#include "azure_c_shared_utility/gballoc.h"
#include "azure_c_shared_utility/agenttime.h"
@@ -250,7 +250,7 @@
if (cred_type == IOTHUB_CREDENTIAL_TYPE_DEVICE_KEY || cred_type == IOTHUB_CREDENTIAL_TYPE_DEVICE_AUTH)
{
/* Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_049: [authentication_do_work() shall create a SAS token using IoTHubClient_Auth_Get_SasToken, unless it has failed previously] */
- sas_token = IoTHubClient_Auth_Get_SasToken(instance->authorization_module, STRING_c_str(devices_path), instance->sas_token_lifetime_secs);
+ sas_token = IoTHubClient_Auth_Get_SasToken(instance->authorization_module, STRING_c_str(devices_path), instance->sas_token_lifetime_secs, NULL);
if (sas_token == NULL)
{
LogError("failure getting sas token.");
@@ -280,7 +280,7 @@
else
{
/* Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_049: [authentication_do_work() shall create a SAS token using IoTHubClient_Auth_Get_SasToken, unless it has failed previously] */
- sas_token = IoTHubClient_Auth_Get_SasToken(instance->authorization_module, NULL, 0);
+ sas_token = IoTHubClient_Auth_Get_SasToken(instance->authorization_module, NULL, 0, NULL);
if (sas_token == NULL)
{
LogError("failure getting sas Token.");
--- a/iothubtransport_amqp_cbs_auth.h Fri May 04 13:22:48 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-#ifndef IOTHUBTRANSPORT_AMQP_CBS_AUTH_H
-#define IOTHUBTRANSPORT_AMQP_CBS_AUTH_H
-
-#include <stdint.h>
-#include "iothub_transport_ll.h"
-#include "azure_uamqp_c/cbs.h"
-#include "azure_c_shared_utility/umock_c_prod.h"
-#include "azure_c_shared_utility/optionhandler.h"
-
-static const char* AUTHENTICATION_OPTION_SAVED_OPTIONS = "saved_authentication_options";
-static const char* AUTHENTICATION_OPTION_CBS_REQUEST_TIMEOUT_SECS = "cbs_request_timeout_secs";
-static const char* AUTHENTICATION_OPTION_SAS_TOKEN_REFRESH_TIME_SECS = "sas_token_refresh_time_secs";
-static const char* AUTHENTICATION_OPTION_SAS_TOKEN_LIFETIME_SECS = "sas_token_lifetime_secs";
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- typedef enum AUTHENTICATION_STATE_TAG
- {
- AUTHENTICATION_STATE_STOPPED,
- AUTHENTICATION_STATE_STARTING,
- AUTHENTICATION_STATE_STARTED,
- AUTHENTICATION_STATE_ERROR
- } AUTHENTICATION_STATE;
-
- typedef enum AUTHENTICATION_ERROR_TAG
- {
- AUTHENTICATION_ERROR_AUTH_TIMEOUT,
- AUTHENTICATION_ERROR_AUTH_FAILED,
- AUTHENTICATION_ERROR_SAS_REFRESH_TIMEOUT,
- AUTHENTICATION_ERROR_SAS_REFRESH_FAILED
- } AUTHENTICATION_ERROR_CODE;
-
- typedef void(*ON_AUTHENTICATION_STATE_CHANGED_CALLBACK)(void* context, AUTHENTICATION_STATE previous_state, AUTHENTICATION_STATE new_state);
- typedef void(*ON_AUTHENTICATION_ERROR_CALLBACK)(void* context, AUTHENTICATION_ERROR_CODE error_code);
-
- typedef struct AUTHENTICATION_CONFIG_TAG
- {
- const char* device_id;
- char* iothub_host_fqdn;
-
- ON_AUTHENTICATION_STATE_CHANGED_CALLBACK on_state_changed_callback;
- void* on_state_changed_callback_context;
-
- ON_AUTHENTICATION_ERROR_CALLBACK on_error_callback;
- void* on_error_callback_context;
-
- IOTHUB_AUTHORIZATION_HANDLE authorization_module; // with either SAS Token, x509 Certs, and Device SAS Token
-
- } AUTHENTICATION_CONFIG;
-
- typedef struct AUTHENTICATION_INSTANCE* AUTHENTICATION_HANDLE;
-
- MOCKABLE_FUNCTION(, AUTHENTICATION_HANDLE, authentication_create, const AUTHENTICATION_CONFIG*, config);
- MOCKABLE_FUNCTION(, int, authentication_start, AUTHENTICATION_HANDLE, authentication_handle, const CBS_HANDLE, cbs_handle);
- MOCKABLE_FUNCTION(, int, authentication_stop, AUTHENTICATION_HANDLE, authentication_handle);
- MOCKABLE_FUNCTION(, void, authentication_do_work, AUTHENTICATION_HANDLE, authentication_handle);
- MOCKABLE_FUNCTION(, void, authentication_destroy, AUTHENTICATION_HANDLE, authentication_handle);
- MOCKABLE_FUNCTION(, int, authentication_set_option, AUTHENTICATION_HANDLE, authentication_handle, const char*, name, void*, value);
- MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, authentication_retrieve_options, AUTHENTICATION_HANDLE, authentication_handle);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*IOTHUBTRANSPORT_AMQP_CBS_AUTH_H*/
--- a/iothubtransport_amqp_common.c Fri May 04 13:22:48 2018 -0700
+++ b/iothubtransport_amqp_common.c Mon Jun 11 15:38:09 2018 -0700
@@ -27,14 +27,15 @@
#include "azure_uamqp_c/message.h"
#include "azure_uamqp_c/messaging.h"
-#include "iothub_client_ll.h"
+#include "iothub_client_core_ll.h"
#include "iothub_client_options.h"
-#include "iothub_client_private.h"
-#include "iothubtransportamqp_methods.h"
-#include "iothub_client_retry_control.h"
-#include "iothubtransport_amqp_common.h"
-#include "iothubtransport_amqp_connection.h"
-#include "iothubtransport_amqp_device.h"
+#include "internal/iothub_client_private.h"
+#include "internal/iothubtransportamqp_methods.h"
+#include "internal/iothub_client_retry_control.h"
+#include "internal/iothubtransport_amqp_common.h"
+#include "internal/iothubtransport_amqp_connection.h"
+#include "internal/iothubtransport_amqp_device.h"
+#include "internal/iothubtransport.h"
#include "iothub_client_version.h"
#define RESULT_OK 0
@@ -128,7 +129,7 @@
{
STRING_HANDLE device_id; // Identity of the device.
AMQP_DEVICE_HANDLE device_handle; // Logic unit that performs authentication, messaging, etc.
- IOTHUB_CLIENT_LL_HANDLE iothub_client_handle; // Saved reference to the IoTHub LL Client.
+ IOTHUB_CLIENT_CORE_LL_HANDLE iothub_client_handle; // Saved reference to the IoTHub Core LL Client.
AMQP_TRANSPORT_INSTANCE* transport_instance; // Saved reference to the transport the device is registered on.
PDLIST_ENTRY waiting_to_send; // List of events waiting to be sent to the iot hub (i.e., haven't been processed by the transport yet).
DEVICE_STATE device_state; // Current state of the device_handle instance.
@@ -154,7 +155,7 @@
typedef struct AMQP_TRANSPORT_DEVICE_TWIN_CONTEXT_TAG
{
uint32_t item_id;
- IOTHUB_CLIENT_LL_HANDLE client_handle;
+ IOTHUB_CLIENT_CORE_LL_HANDLE client_handle;
} AMQP_TRANSPORT_DEVICE_TWIN_CONTEXT;
@@ -258,7 +259,7 @@
AMQP_TRANSPORT_DEVICE_INSTANCE* registered_device = (AMQP_TRANSPORT_DEVICE_INSTANCE*)item;
- IoTHubClient_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, IOTHUB_CLIENT_CONNECTION_RETRY_EXPIRED);
+ IoTHubClientCore_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, IOTHUB_CLIENT_CONNECTION_RETRY_EXPIRED);
*continue_processing = true;
}
@@ -281,33 +282,33 @@
// Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_127: [If `new_state` is DEVICE_STATE_STARTED, retry_control_reset() shall be invoked passing `instance->connection_retry_control`]
reset_retry_control(registered_device);
- // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_120: [If `new_state` is DEVICE_STATE_STARTED, IoTHubClient_LL_ConnectionStatusCallBack shall be invoked with IOTHUB_CLIENT_CONNECTION_AUTHENTICATED and IOTHUB_CLIENT_CONNECTION_OK]
- IoTHubClient_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_AUTHENTICATED, IOTHUB_CLIENT_CONNECTION_OK);
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_120: [If `new_state` is DEVICE_STATE_STARTED, IoTHubClientCore_LL_ConnectionStatusCallBack shall be invoked with IOTHUB_CLIENT_CONNECTION_AUTHENTICATED and IOTHUB_CLIENT_CONNECTION_OK]
+ IoTHubClientCore_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_AUTHENTICATED, IOTHUB_CLIENT_CONNECTION_OK);
}
- // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_121: [If `new_state` is DEVICE_STATE_STOPPED, IoTHubClient_LL_ConnectionStatusCallBack shall be invoked with IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED and IOTHUB_CLIENT_CONNECTION_OK]
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_121: [If `new_state` is DEVICE_STATE_STOPPED, IoTHubClientCore_LL_ConnectionStatusCallBack shall be invoked with IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED and IOTHUB_CLIENT_CONNECTION_OK]
else if (new_state == DEVICE_STATE_STOPPED)
{
if (registered_device->transport_instance->state == AMQP_TRANSPORT_STATE_CONNECTED ||
registered_device->transport_instance->state == AMQP_TRANSPORT_STATE_BEING_DESTROYED)
{
- IoTHubClient_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, IOTHUB_CLIENT_CONNECTION_OK);
+ IoTHubClientCore_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, IOTHUB_CLIENT_CONNECTION_OK);
}
else if (registered_device->transport_instance->state == AMQP_TRANSPORT_STATE_RECONNECTION_REQUIRED ||
registered_device->transport_instance->state == AMQP_TRANSPORT_STATE_READY_FOR_RECONNECTION ||
registered_device->transport_instance->state == AMQP_TRANSPORT_STATE_RECONNECTING)
{
- IoTHubClient_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, IOTHUB_CLIENT_CONNECTION_NO_NETWORK);
+ IoTHubClientCore_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, IOTHUB_CLIENT_CONNECTION_NO_NETWORK);
}
}
- // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_122: [If `new_state` is DEVICE_STATE_ERROR_AUTH, IoTHubClient_LL_ConnectionStatusCallBack shall be invoked with IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED and IOTHUB_CLIENT_CONNECTION_BAD_CREDENTIAL]
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_122: [If `new_state` is DEVICE_STATE_ERROR_AUTH, IoTHubClientCore_LL_ConnectionStatusCallBack shall be invoked with IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED and IOTHUB_CLIENT_CONNECTION_BAD_CREDENTIAL]
else if (new_state == DEVICE_STATE_ERROR_AUTH)
{
- IoTHubClient_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, IOTHUB_CLIENT_CONNECTION_BAD_CREDENTIAL);
+ IoTHubClientCore_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, IOTHUB_CLIENT_CONNECTION_BAD_CREDENTIAL);
}
- // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_123: [If `new_state` is DEVICE_STATE_ERROR_AUTH_TIMEOUT or DEVICE_STATE_ERROR_MSG, IoTHubClient_LL_ConnectionStatusCallBack shall be invoked with IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED and IOTHUB_CLIENT_CONNECTION_COMMUNICATION_ERROR]
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_123: [If `new_state` is DEVICE_STATE_ERROR_AUTH_TIMEOUT or DEVICE_STATE_ERROR_MSG, IoTHubClientCore_LL_ConnectionStatusCallBack shall be invoked with IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED and IOTHUB_CLIENT_CONNECTION_COMMUNICATION_ERROR]
else if (new_state == DEVICE_STATE_ERROR_AUTH_TIMEOUT || new_state == DEVICE_STATE_ERROR_MSG)
{
- IoTHubClient_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, IOTHUB_CLIENT_CONNECTION_COMMUNICATION_ERROR);
+ IoTHubClientCore_LL_ConnectionStatusCallBack(registered_device->iothub_client_handle, IOTHUB_CLIENT_CONNECTION_UNAUTHENTICATED, IOTHUB_CLIENT_CONNECTION_COMMUNICATION_ERROR);
}
}
}
@@ -467,18 +468,18 @@
}
else
{
- // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_089: [IoTHubClient_LL_MessageCallback() shall be invoked passing the client and the incoming message handles as parameters]
- if (IoTHubClient_LL_MessageCallback(amqp_device_instance->iothub_client_handle, message_data) != true)
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_089: [IoTHubClientCore_LL_MessageCallback() shall be invoked passing the client and the incoming message handles as parameters]
+ if (IoTHubClientCore_LL_MessageCallback(amqp_device_instance->iothub_client_handle, message_data) != true)
{
- // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_090: [If IoTHubClient_LL_MessageCallback() fails, on_message_received_callback shall return DEVICE_MESSAGE_DISPOSITION_RESULT_RELEASED]
- LogError("Failed processing message received (IoTHubClient_LL_MessageCallback failed)");
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_090: [If IoTHubClientCore_LL_MessageCallback() fails, on_message_received_callback shall return DEVICE_MESSAGE_DISPOSITION_RESULT_RELEASED]
+ LogError("Failed processing message received (IoTHubClientCore_LL_MessageCallback failed)");
IoTHubMessage_Destroy(message);
MESSAGE_CALLBACK_INFO_Destroy(message_data);
device_disposition_result = DEVICE_MESSAGE_DISPOSITION_RESULT_RELEASED;
}
else
{
- // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_091: [If IoTHubClient_LL_MessageCallback() succeeds, on_message_received_callback shall return DEVICE_MESSAGE_DISPOSITION_RESULT_NONE]
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_091: [If IoTHubClientCore_LL_MessageCallback() succeeds, on_message_received_callback shall return DEVICE_MESSAGE_DISPOSITION_RESULT_NONE]
device_disposition_result = DEVICE_MESSAGE_DISPOSITION_RESULT_NONE;
}
}
@@ -506,11 +507,11 @@
int result;
AMQP_TRANSPORT_DEVICE_INSTANCE* device_state = (AMQP_TRANSPORT_DEVICE_INSTANCE*)context;
- /* Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_01_017: [ `on_methods_request_received` shall call the `IoTHubClient_LL_DeviceMethodComplete` passing the method name, request buffer and size and the newly created BUFFER handle. ]*/
- /* Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_01_022: [ The status code shall be the return value of the call to `IoTHubClient_LL_DeviceMethodComplete`. ]*/
- if (IoTHubClient_LL_DeviceMethodComplete(device_state->iothub_client_handle, method_name, request, request_size, (void*)method_handle) != 0)
+ /* Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_01_017: [ `on_methods_request_received` shall call the `IoTHubClientCore_LL_DeviceMethodComplete` passing the method name, request buffer and size and the newly created BUFFER handle. ]*/
+ /* Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_01_022: [ The status code shall be the return value of the call to `IoTHubClientCore_LL_DeviceMethodComplete`. ]*/
+ if (IoTHubClientCore_LL_DeviceMethodComplete(device_state->iothub_client_handle, method_name, request, request_size, (void*)method_handle) != 0)
{
- LogError("Failure: IoTHubClient_LL_DeviceMethodComplete");
+ LogError("Failure: IoTHubClientCore_LL_DeviceMethodComplete");
result = __FAILURE__;
}
else
@@ -567,8 +568,8 @@
{
AMQP_TRANSPORT_DEVICE_TWIN_CONTEXT* dev_twin_ctx = (AMQP_TRANSPORT_DEVICE_TWIN_CONTEXT*)context;
- // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_152: [`IoTHubClient_LL_ReportedStateComplete` shall be invoked passing `status_code` and `context` details]
- IoTHubClient_LL_ReportedStateComplete(dev_twin_ctx->client_handle, dev_twin_ctx->item_id, status_code);
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_152: [`IoTHubClientCore_LL_ReportedStateComplete` shall be invoked passing `status_code` and `context` details]
+ IoTHubClientCore_LL_ReportedStateComplete(dev_twin_ctx->client_handle, dev_twin_ctx->item_id, status_code);
// Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_153: [The memory allocated for `context` shall be released]
free(dev_twin_ctx);
@@ -586,9 +587,9 @@
{
AMQP_TRANSPORT_DEVICE_INSTANCE* registered_device = (AMQP_TRANSPORT_DEVICE_INSTANCE*)context;
- // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_138: [If `update_type` is DEVICE_TWIN_UPDATE_TYPE_PARTIAL IoTHubClient_LL_RetrievePropertyComplete shall be invoked passing `context` as handle, `DEVICE_TWIN_UPDATE_PARTIAL`, `payload` and `size`.]
- // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_139: [If `update_type` is DEVICE_TWIN_UPDATE_TYPE_COMPLETE IoTHubClient_LL_RetrievePropertyComplete shall be invoked passing `context` as handle, `DEVICE_TWIN_UPDATE_COMPLETE`, `payload` and `size`.]
- IoTHubClient_LL_RetrievePropertyComplete(
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_138: [If `update_type` is DEVICE_TWIN_UPDATE_TYPE_PARTIAL IoTHubClientCore_LL_RetrievePropertyComplete shall be invoked passing `context` as handle, `DEVICE_TWIN_UPDATE_PARTIAL`, `payload` and `size`.]
+ // Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_09_139: [If `update_type` is DEVICE_TWIN_UPDATE_TYPE_COMPLETE IoTHubClientCore_LL_RetrievePropertyComplete shall be invoked passing `context` as handle, `DEVICE_TWIN_UPDATE_COMPLETE`, `payload` and `size`.]
+ IoTHubClientCore_LL_RetrievePropertyComplete(
registered_device->iothub_client_handle,
(update_type == DEVICE_TWIN_UPDATE_TYPE_COMPLETE ? DEVICE_TWIN_UPDATE_COMPLETE : DEVICE_TWIN_UPDATE_PARTIAL),
message, length);
@@ -1529,7 +1530,7 @@
return result;
}
-void IoTHubTransport_AMQP_Common_DoWork(TRANSPORT_LL_HANDLE handle, IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle)
+void IoTHubTransport_AMQP_Common_DoWork(TRANSPORT_LL_HANDLE handle, IOTHUB_CLIENT_CORE_LL_HANDLE iotHubClientHandle)
{
(void)iotHubClientHandle; // unused as of now.
@@ -2122,7 +2123,7 @@
return result;
}
-IOTHUB_DEVICE_HANDLE IoTHubTransport_AMQP_Common_Register(TRANSPORT_LL_HANDLE handle, const IOTHUB_DEVICE_CONFIG* device, IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, PDLIST_ENTRY waitingToSend)
+IOTHUB_DEVICE_HANDLE IoTHubTransport_AMQP_Common_Register(TRANSPORT_LL_HANDLE handle, const IOTHUB_DEVICE_CONFIG* device, IOTHUB_CLIENT_CORE_LL_HANDLE iotHubClientHandle, PDLIST_ENTRY waitingToSend)
{
#ifdef NO_LOGGING
UNUSED(iotHubClientHandle);
@@ -2133,7 +2134,7 @@
// Codes_SRS_IOTHUBTRANSPORT_AMQP_COMMON_17_005: [If `handle`, `device`, `iotHubClientHandle` or `waitingToSend` is NULL, IoTHubTransport_AMQP_Common_Register shall return NULL]
if ((handle == NULL) || (device == NULL) || (waitingToSend == NULL) || (iotHubClientHandle == NULL))
{
- LogError("invalid parameter TRANSPORT_LL_HANDLE handle=%p, const IOTHUB_DEVICE_CONFIG* device=%p, IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle=%p, PDLIST_ENTRY waiting_to_send=%p",
+ LogError("invalid parameter TRANSPORT_LL_HANDLE handle=%p, const IOTHUB_DEVICE_CONFIG* device=%p, IOTHUB_CLIENT_CORE_LL_HANDLE iotHubClientHandle=%p, PDLIST_ENTRY waiting_to_send=%p",
handle, device, iotHubClientHandle, waitingToSend);
result = NULL;
}
@@ -2177,7 +2178,7 @@
char* local_product_info = NULL;
void* product_info;
- if ((IoTHubClient_LL_GetOption(iotHubClientHandle, OPTION_PRODUCT_INFO, &product_info) != IOTHUB_CLIENT_OK) || (product_info == NULL))
+ if ((IoTHubClientCore_LL_GetOption(iotHubClientHandle, OPTION_PRODUCT_INFO, &product_info) != IOTHUB_CLIENT_OK) || (product_info == NULL))
{
mallocAndStrcpy_s(&local_product_info, CLIENT_DEVICE_TYPE_PREFIX CLIENT_DEVICE_BACKSLASH IOTHUB_SDK_VERSION);
}
--- a/iothubtransport_amqp_common.h Fri May 04 13:22:48 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-#ifndef IOTHUBTRANSPORTAMQP_COMMON_H
-#define IOTHUBTRANSPORTAMQP_COMMON_H
-
-#include "azure_c_shared_utility/strings.h"
-#include "azure_c_shared_utility/umock_c_prod.h"
-#include "iothub_transport_ll.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef struct AMQP_TRANSPORT_PROXY_OPTIONS_TAG
-{
- const char* host_address;
- int port;
- const char* username;
- const char* password;
-} AMQP_TRANSPORT_PROXY_OPTIONS;
-
-typedef XIO_HANDLE(*AMQP_GET_IO_TRANSPORT)(const char* target_fqdn, const AMQP_TRANSPORT_PROXY_OPTIONS* amqp_transport_proxy_options);
-static const char* OPTION_EVENT_SEND_TIMEOUT_SECS = "event_send_timeout_secs";
-
-MOCKABLE_FUNCTION(, TRANSPORT_LL_HANDLE, IoTHubTransport_AMQP_Common_Create, const IOTHUBTRANSPORT_CONFIG*, config, AMQP_GET_IO_TRANSPORT, get_io_transport);
-MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_Destroy, TRANSPORT_LL_HANDLE, handle);
-MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_Common_Subscribe, IOTHUB_DEVICE_HANDLE, handle);
-MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_Unsubscribe, IOTHUB_DEVICE_HANDLE, handle);
-MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_Common_Subscribe_DeviceTwin, IOTHUB_DEVICE_HANDLE, handle);
-MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_Unsubscribe_DeviceTwin, IOTHUB_DEVICE_HANDLE, handle);
-MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_Common_Subscribe_DeviceMethod, IOTHUB_DEVICE_HANDLE, handle);
-MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_Unsubscribe_DeviceMethod, IOTHUB_DEVICE_HANDLE, handle);
-MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_Common_DeviceMethod_Response, IOTHUB_DEVICE_HANDLE, handle, METHOD_HANDLE, methodId, const unsigned char*, response, size_t, response_size, int, status_response);
-MOCKABLE_FUNCTION(, IOTHUB_PROCESS_ITEM_RESULT, IoTHubTransport_AMQP_Common_ProcessItem, TRANSPORT_LL_HANDLE, handle, IOTHUB_IDENTITY_TYPE, item_type, IOTHUB_IDENTITY_INFO*, iothub_item);
-MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_DoWork, TRANSPORT_LL_HANDLE, handle, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle);
-MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_Common_SetRetryPolicy, TRANSPORT_LL_HANDLE, handle, IOTHUB_CLIENT_RETRY_POLICY, retryPolicy, size_t, retryTimeoutLimitInSeconds);
-MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_AMQP_Common_GetSendStatus, IOTHUB_DEVICE_HANDLE, handle, IOTHUB_CLIENT_STATUS*, iotHubClientStatus);
-MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_AMQP_Common_SetOption, TRANSPORT_LL_HANDLE, handle, const char*, option, const void*, value);
-MOCKABLE_FUNCTION(, IOTHUB_DEVICE_HANDLE, IoTHubTransport_AMQP_Common_Register, TRANSPORT_LL_HANDLE, handle, const IOTHUB_DEVICE_CONFIG*, device, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, PDLIST_ENTRY, waitingToSend);
-MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_Unregister, IOTHUB_DEVICE_HANDLE, deviceHandle);
-MOCKABLE_FUNCTION(, STRING_HANDLE, IoTHubTransport_AMQP_Common_GetHostname, TRANSPORT_LL_HANDLE, handle);
-MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_AMQP_Common_SendMessageDisposition, MESSAGE_CALLBACK_INFO*, message_data, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IOTHUBTRANSPORTAMQP_COMMON_H */
--- a/iothubtransport_amqp_connection.c Fri May 04 13:22:48 2018 -0700 +++ b/iothubtransport_amqp_connection.c Mon Jun 11 15:38:09 2018 -0700 @@ -3,7 +3,7 @@ #include <stdlib.h> #include <limits.h> -#include "iothubtransport_amqp_connection.h" +#include "internal/iothubtransport_amqp_connection.h" #include "azure_c_shared_utility/optimize_size.h" #include "azure_c_shared_utility/gballoc.h" #include "azure_c_shared_utility/strings.h"
--- a/iothubtransport_amqp_connection.h Fri May 04 13:22:48 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-#ifndef IOTHUBTRANSPORTAMQP_AMQP_CONNECTION_H
-#define IOTHUBTRANSPORTAMQP_AMQP_CONNECTION_H
-
-#include "azure_c_shared_utility/umock_c_prod.h"
-#include "azure_c_shared_utility/macro_utils.h"
-#include "azure_c_shared_utility/xio.h"
-#include "azure_uamqp_c/session.h"
-#include "azure_uamqp_c/cbs.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define AMQP_CONNECTION_STATE_VALUES \
- AMQP_CONNECTION_STATE_OPENED, \
- AMQP_CONNECTION_STATE_CLOSED, \
- AMQP_CONNECTION_STATE_ERROR
-
-DEFINE_ENUM(AMQP_CONNECTION_STATE, AMQP_CONNECTION_STATE_VALUES);
-
-typedef void(*ON_AMQP_CONNECTION_STATE_CHANGED)(const void* context, AMQP_CONNECTION_STATE old_state, AMQP_CONNECTION_STATE new_state);
-
-typedef struct AMQP_CONNECTION_CONFIG_TAG
-{
- const char* iothub_host_fqdn;
- XIO_HANDLE underlying_io_transport;
- bool create_sasl_io;
- bool create_cbs_connection;
- bool is_trace_on;
-
- ON_AMQP_CONNECTION_STATE_CHANGED on_state_changed_callback;
- const void* on_state_changed_context;
- size_t svc2cl_keep_alive_timeout_secs;
- double cl2svc_keep_alive_send_ratio;
-} AMQP_CONNECTION_CONFIG;
-
-typedef struct AMQP_CONNECTION_INSTANCE* AMQP_CONNECTION_HANDLE;
-
-MOCKABLE_FUNCTION(, AMQP_CONNECTION_HANDLE, amqp_connection_create, AMQP_CONNECTION_CONFIG*, config);
-MOCKABLE_FUNCTION(, void, amqp_connection_destroy, AMQP_CONNECTION_HANDLE, conn_handle);
-MOCKABLE_FUNCTION(, void, amqp_connection_do_work, AMQP_CONNECTION_HANDLE, conn_handle);
-MOCKABLE_FUNCTION(, int, amqp_connection_get_session_handle, AMQP_CONNECTION_HANDLE, conn_handle, SESSION_HANDLE*, session_handle);
-MOCKABLE_FUNCTION(, int, amqp_connection_get_cbs_handle, AMQP_CONNECTION_HANDLE, conn_handle, CBS_HANDLE*, cbs_handle);
-MOCKABLE_FUNCTION(, int, amqp_connection_set_logging, AMQP_CONNECTION_HANDLE, conn_handle, bool, is_trace_on);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*IOTHUBTRANSPORTAMQP_AMQP_CONNECTION_H*/
--- a/iothubtransport_amqp_device.c Fri May 04 13:22:48 2018 -0700 +++ b/iothubtransport_amqp_device.c Mon Jun 11 15:38:09 2018 -0700 @@ -7,10 +7,10 @@ #include "azure_c_shared_utility/agenttime.h" #include "azure_c_shared_utility/xlogging.h" #include "azure_c_shared_utility/strings.h" -#include "iothubtransport_amqp_cbs_auth.h" -#include "iothubtransport_amqp_device.h" -#include "iothubtransport_amqp_telemetry_messenger.h" -#include "iothubtransport_amqp_twin_messenger.h" +#include "internal/iothubtransport_amqp_cbs_auth.h" +#include "internal/iothubtransport_amqp_device.h" +#include "internal/iothubtransport_amqp_telemetry_messenger.h" +#include "internal/iothubtransport_amqp_twin_messenger.h" DEFINE_ENUM_STRINGS(DEVICE_STATE, DEVICE_STATE_VALUES); DEFINE_ENUM_STRINGS(DEVICE_AUTH_MODE, DEVICE_AUTH_MODE_VALUES);
--- a/iothubtransport_amqp_device.h Fri May 04 13:22:48 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-#ifndef IOTHUBTRANSPORTAMQP_AMQP_DEVICE_H
-#define IOTHUBTRANSPORTAMQP_AMQP_DEVICE_H
-
-#include "azure_c_shared_utility/umock_c_prod.h"
-#include "azure_c_shared_utility/optionhandler.h"
-#include "azure_uamqp_c/session.h"
-#include "azure_uamqp_c/cbs.h"
-#include "iothub_message.h"
-#include "iothub_client_private.h"
-#include "iothubtransport_amqp_device.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-// @brief name of option to apply the instance obtained using device_retrieve_options
-static const char* DEVICE_OPTION_SAVED_OPTIONS = "saved_device_options";
-static const char* DEVICE_OPTION_EVENT_SEND_TIMEOUT_SECS = "event_send_timeout_secs";
-static const char* DEVICE_OPTION_CBS_REQUEST_TIMEOUT_SECS = "cbs_request_timeout_secs";
-static const char* DEVICE_OPTION_SAS_TOKEN_REFRESH_TIME_SECS = "sas_token_refresh_time_secs";
-static const char* DEVICE_OPTION_SAS_TOKEN_LIFETIME_SECS = "sas_token_lifetime_secs";
-
-#define DEVICE_STATE_VALUES \
- DEVICE_STATE_STOPPED, \
- DEVICE_STATE_STOPPING, \
- DEVICE_STATE_STARTING, \
- DEVICE_STATE_STARTED, \
- DEVICE_STATE_ERROR_AUTH, \
- DEVICE_STATE_ERROR_AUTH_TIMEOUT, \
- DEVICE_STATE_ERROR_MSG
-
-DEFINE_ENUM(DEVICE_STATE, DEVICE_STATE_VALUES);
-
-#define DEVICE_AUTH_MODE_VALUES \
- DEVICE_AUTH_MODE_CBS, \
- DEVICE_AUTH_MODE_X509
-
-DEFINE_ENUM(DEVICE_AUTH_MODE, DEVICE_AUTH_MODE_VALUES);
-
-#define DEVICE_SEND_STATUS_VALUES \
- DEVICE_SEND_STATUS_IDLE, \
- DEVICE_SEND_STATUS_BUSY
-
-DEFINE_ENUM(DEVICE_SEND_STATUS, DEVICE_SEND_STATUS_VALUES);
-
-#define D2C_EVENT_SEND_RESULT_VALUES \
- D2C_EVENT_SEND_COMPLETE_RESULT_OK, \
- D2C_EVENT_SEND_COMPLETE_RESULT_ERROR_CANNOT_PARSE, \
- D2C_EVENT_SEND_COMPLETE_RESULT_ERROR_FAIL_SENDING, \
- D2C_EVENT_SEND_COMPLETE_RESULT_ERROR_TIMEOUT, \
- D2C_EVENT_SEND_COMPLETE_RESULT_DEVICE_DESTROYED, \
- D2C_EVENT_SEND_COMPLETE_RESULT_ERROR_UNKNOWN
-
-DEFINE_ENUM(D2C_EVENT_SEND_RESULT, D2C_EVENT_SEND_RESULT_VALUES);
-
-#define DEVICE_MESSAGE_DISPOSITION_RESULT_VALUES \
- DEVICE_MESSAGE_DISPOSITION_RESULT_NONE, \
- DEVICE_MESSAGE_DISPOSITION_RESULT_ACCEPTED, \
- DEVICE_MESSAGE_DISPOSITION_RESULT_REJECTED, \
- DEVICE_MESSAGE_DISPOSITION_RESULT_RELEASED
-
-DEFINE_ENUM(DEVICE_MESSAGE_DISPOSITION_RESULT, DEVICE_MESSAGE_DISPOSITION_RESULT_VALUES);
-
-#define DEVICE_TWIN_UPDATE_RESULT_STRINGS \
- DEVICE_TWIN_UPDATE_RESULT_OK, \
- DEVICE_TWIN_UPDATE_RESULT_ERROR
-
-DEFINE_ENUM(DEVICE_TWIN_UPDATE_RESULT, DEVICE_TWIN_UPDATE_RESULT_STRINGS);
-
-#define DEVICE_TWIN_UPDATE_TYPE_STRINGS \
- DEVICE_TWIN_UPDATE_TYPE_PARTIAL, \
- DEVICE_TWIN_UPDATE_TYPE_COMPLETE
-
-DEFINE_ENUM(DEVICE_TWIN_UPDATE_TYPE, DEVICE_TWIN_UPDATE_TYPE_STRINGS)
-
-typedef struct DEVICE_MESSAGE_DISPOSITION_INFO_TAG
-{
- unsigned long message_id;
- char* source;
-} DEVICE_MESSAGE_DISPOSITION_INFO;
-
-typedef void(*ON_DEVICE_STATE_CHANGED)(void* context, DEVICE_STATE previous_state, DEVICE_STATE new_state);
-typedef DEVICE_MESSAGE_DISPOSITION_RESULT(*ON_DEVICE_C2D_MESSAGE_RECEIVED)(IOTHUB_MESSAGE_HANDLE message, DEVICE_MESSAGE_DISPOSITION_INFO* disposition_info, void* context);
-typedef void(*ON_DEVICE_D2C_EVENT_SEND_COMPLETE)(IOTHUB_MESSAGE_LIST* message, D2C_EVENT_SEND_RESULT result, void* context);
-typedef void(*DEVICE_SEND_TWIN_UPDATE_COMPLETE_CALLBACK)(DEVICE_TWIN_UPDATE_RESULT result, int status_code, void* context);
-typedef void(*DEVICE_TWIN_UPDATE_RECEIVED_CALLBACK)(DEVICE_TWIN_UPDATE_TYPE update_type, const unsigned char* message, size_t length, void* context);
-
-typedef struct DEVICE_CONFIG_TAG
-{
- const char* device_id;
- char* product_info;
- char* iothub_host_fqdn;
- DEVICE_AUTH_MODE authentication_mode;
- ON_DEVICE_STATE_CHANGED on_state_changed_callback;
- void* on_state_changed_context;
-
- // Auth module used to generating handle authorization
- // with either SAS Token, x509 Certs, and Device SAS Token
- IOTHUB_AUTHORIZATION_HANDLE authorization_module;
-} DEVICE_CONFIG;
-
-typedef struct AMQP_DEVICE_INSTANCE* AMQP_DEVICE_HANDLE;
-
-MOCKABLE_FUNCTION(, AMQP_DEVICE_HANDLE, device_create, DEVICE_CONFIG*, config);
-MOCKABLE_FUNCTION(, void, device_destroy, AMQP_DEVICE_HANDLE, handle);
-MOCKABLE_FUNCTION(, int, device_start_async, AMQP_DEVICE_HANDLE, handle, SESSION_HANDLE, session_handle, CBS_HANDLE, cbs_handle);
-MOCKABLE_FUNCTION(, int, device_stop, AMQP_DEVICE_HANDLE, handle);
-MOCKABLE_FUNCTION(, void, device_do_work, AMQP_DEVICE_HANDLE, handle);
-MOCKABLE_FUNCTION(, int, device_send_event_async, AMQP_DEVICE_HANDLE, handle, IOTHUB_MESSAGE_LIST*, message, ON_DEVICE_D2C_EVENT_SEND_COMPLETE, on_device_d2c_event_send_complete_callback, void*, context);
-MOCKABLE_FUNCTION(, int, device_send_twin_update_async, AMQP_DEVICE_HANDLE, handle, CONSTBUFFER_HANDLE, data, DEVICE_SEND_TWIN_UPDATE_COMPLETE_CALLBACK, on_send_twin_update_complete_callback, void*, context);
-MOCKABLE_FUNCTION(, int, device_subscribe_for_twin_updates, AMQP_DEVICE_HANDLE, handle, DEVICE_TWIN_UPDATE_RECEIVED_CALLBACK, on_device_twin_update_received_callback, void*, context);
-MOCKABLE_FUNCTION(, int, device_unsubscribe_for_twin_updates, AMQP_DEVICE_HANDLE, handle);
-MOCKABLE_FUNCTION(, int, device_get_send_status, AMQP_DEVICE_HANDLE, handle, DEVICE_SEND_STATUS*, send_status);
-MOCKABLE_FUNCTION(, int, device_subscribe_message, AMQP_DEVICE_HANDLE, handle, ON_DEVICE_C2D_MESSAGE_RECEIVED, on_message_received_callback, void*, context);
-MOCKABLE_FUNCTION(, int, device_unsubscribe_message, AMQP_DEVICE_HANDLE, handle);
-MOCKABLE_FUNCTION(, int, device_send_message_disposition, AMQP_DEVICE_HANDLE, AMQP_DEVICE_HANDLE, DEVICE_MESSAGE_DISPOSITION_INFO*, disposition_info, DEVICE_MESSAGE_DISPOSITION_RESULT, disposition_result);
-MOCKABLE_FUNCTION(, int, device_set_retry_policy, AMQP_DEVICE_HANDLE, handle, IOTHUB_CLIENT_RETRY_POLICY, policy, size_t, retry_timeout_limit_in_seconds);
-MOCKABLE_FUNCTION(, int, device_set_option, AMQP_DEVICE_HANDLE, handle, const char*, name, void*, value);
-MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, device_retrieve_options, AMQP_DEVICE_HANDLE, handle);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // IOTHUBTRANSPORTAMQP_AMQP_DEVICE_H
\ No newline at end of file
--- a/iothubtransport_amqp_messenger.c Fri May 04 13:22:48 2018 -0700 +++ b/iothubtransport_amqp_messenger.c Mon Jun 11 15:38:09 2018 -0700 @@ -13,9 +13,9 @@ #include "azure_uamqp_c/messaging.h" #include "azure_uamqp_c/message_sender.h" #include "azure_uamqp_c/message_receiver.h" -#include "message_queue.h" -#include "iothub_client_retry_control.h" -#include "iothubtransport_amqp_messenger.h" +#include "internal/message_queue.h" +#include "internal/iothub_client_retry_control.h" +#include "internal/iothubtransport_amqp_messenger.h" DEFINE_ENUM_STRINGS(AMQP_MESSENGER_SEND_STATUS, AMQP_MESSENGER_SEND_STATUS_VALUES); DEFINE_ENUM_STRINGS(AMQP_MESSENGER_SEND_RESULT, AMQP_MESSENGER_SEND_RESULT_VALUES);
--- a/iothubtransport_amqp_messenger.h Fri May 04 13:22:48 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-#ifndef IOTHUBTRANSPORT_AMQP_MESSENGER
-#define IOTHUBTRANSPORT_AMQP_MESSENGER
-
-#include "azure_c_shared_utility/umock_c_prod.h"
-#include "azure_c_shared_utility/optionhandler.h"
-#include "azure_c_shared_utility/map.h"
-#include "azure_uamqp_c/message.h"
-#include "azure_uamqp_c/session.h"
-#include "azure_uamqp_c/link.h"
-#include "azure_uamqp_c/amqp_definitions_sequence_no.h"
-#include "azure_uamqp_c/amqp_definitions_delivery_number.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-static const char* AMQP_MESSENGER_OPTION_EVENT_SEND_TIMEOUT_SECS = "amqp_event_send_timeout_secs";
-
-typedef struct AMQP_MESSENGER_INSTANCE* AMQP_MESSENGER_HANDLE;
-
-#define AMQP_MESSENGER_SEND_STATUS_VALUES \
- AMQP_MESSENGER_SEND_STATUS_IDLE, \
- AMQP_MESSENGER_SEND_STATUS_BUSY
-
-DEFINE_ENUM(AMQP_MESSENGER_SEND_STATUS, AMQP_MESSENGER_SEND_STATUS_VALUES);
-
-#define AMQP_MESSENGER_SEND_RESULT_VALUES \
- AMQP_MESSENGER_SEND_RESULT_SUCCESS, \
- AMQP_MESSENGER_SEND_RESULT_ERROR, \
- AMQP_MESSENGER_SEND_RESULT_CANCELLED
-
-DEFINE_ENUM(AMQP_MESSENGER_SEND_RESULT, AMQP_MESSENGER_SEND_RESULT_VALUES);
-
-#define AMQP_MESSENGER_REASON_VALUES \
- AMQP_MESSENGER_REASON_NONE, \
- AMQP_MESSENGER_REASON_CANNOT_PARSE, \
- AMQP_MESSENGER_REASON_FAIL_SENDING, \
- AMQP_MESSENGER_REASON_TIMEOUT, \
- AMQP_MESSENGER_REASON_MESSENGER_DESTROYED
-
-DEFINE_ENUM(AMQP_MESSENGER_REASON, AMQP_MESSENGER_REASON_VALUES);
-
-#define AMQP_MESSENGER_DISPOSITION_RESULT_VALUES \
- AMQP_MESSENGER_DISPOSITION_RESULT_NONE, \
- AMQP_MESSENGER_DISPOSITION_RESULT_ACCEPTED, \
- AMQP_MESSENGER_DISPOSITION_RESULT_REJECTED, \
- AMQP_MESSENGER_DISPOSITION_RESULT_RELEASED
-
-DEFINE_ENUM(AMQP_MESSENGER_DISPOSITION_RESULT, AMQP_MESSENGER_DISPOSITION_RESULT_VALUES);
-
-#define AMQP_MESSENGER_STATE_VALUES \
- AMQP_MESSENGER_STATE_STARTING, \
- AMQP_MESSENGER_STATE_STARTED, \
- AMQP_MESSENGER_STATE_STOPPING, \
- AMQP_MESSENGER_STATE_STOPPED, \
- AMQP_MESSENGER_STATE_ERROR
-
-DEFINE_ENUM(AMQP_MESSENGER_STATE, AMQP_MESSENGER_STATE_VALUES);
-
-typedef struct AMQP_MESSENGER_MESSAGE_DISPOSITION_INFO_TAG
-{
- delivery_number message_id;
- char* source;
-} AMQP_MESSENGER_MESSAGE_DISPOSITION_INFO;
-
-typedef void(*AMQP_MESSENGER_SEND_COMPLETE_CALLBACK)(AMQP_MESSENGER_SEND_RESULT result, AMQP_MESSENGER_REASON reason, void* context);
-typedef void(*AMQP_MESSENGER_STATE_CHANGED_CALLBACK)(void* context, AMQP_MESSENGER_STATE previous_state, AMQP_MESSENGER_STATE new_state);
-typedef void(*AMQP_MESSENGER_SUBSCRIPTION_CALLBACK)(void* context, bool is_subscribed);
-typedef AMQP_MESSENGER_DISPOSITION_RESULT(*ON_AMQP_MESSENGER_MESSAGE_RECEIVED)(MESSAGE_HANDLE message, AMQP_MESSENGER_MESSAGE_DISPOSITION_INFO* disposition_info, void* context);
-
-typedef struct AMQP_MESSENGER_LINK_CONFIG_TAG
-{
- /**
- * @brief Sample format: "/messages/devicebound"
- */
- char* source_suffix;
-
- /**
- * @brief Sample format: "/messages/events"
- */
- char* target_suffix;
-
- receiver_settle_mode rcv_settle_mode;
- sender_settle_mode snd_settle_mode;
-
- MAP_HANDLE attach_properties;
-} AMQP_MESSENGER_LINK_CONFIG;
-
-typedef struct AMQP_MESSENGER_CONFIG_TAG
-{
- char* client_version;
- char* device_id;
- char* iothub_host_fqdn;
-
- AMQP_MESSENGER_LINK_CONFIG send_link;
- AMQP_MESSENGER_LINK_CONFIG receive_link;
-
- AMQP_MESSENGER_STATE_CHANGED_CALLBACK on_state_changed_callback;
- void* on_state_changed_context;
-
- AMQP_MESSENGER_SUBSCRIPTION_CALLBACK on_subscription_changed_callback;
- void* on_subscription_changed_context;
-} AMQP_MESSENGER_CONFIG;
-
-MOCKABLE_FUNCTION(, AMQP_MESSENGER_HANDLE, amqp_messenger_create, const AMQP_MESSENGER_CONFIG*, messenger_config);
-MOCKABLE_FUNCTION(, int, amqp_messenger_send_async, AMQP_MESSENGER_HANDLE, messenger_handle, MESSAGE_HANDLE, message, AMQP_MESSENGER_SEND_COMPLETE_CALLBACK, on_messenger_event_send_complete_callback, void*, context);
-MOCKABLE_FUNCTION(, int, amqp_messenger_subscribe_for_messages, AMQP_MESSENGER_HANDLE, messenger_handle, ON_AMQP_MESSENGER_MESSAGE_RECEIVED, on_message_received_callback, void*, context);
-MOCKABLE_FUNCTION(, int, amqp_messenger_unsubscribe_for_messages, AMQP_MESSENGER_HANDLE, messenger_handle);
-MOCKABLE_FUNCTION(, int, amqp_messenger_send_message_disposition, AMQP_MESSENGER_HANDLE, messenger_handle, AMQP_MESSENGER_MESSAGE_DISPOSITION_INFO*, disposition_info, AMQP_MESSENGER_DISPOSITION_RESULT, disposition_result);
-MOCKABLE_FUNCTION(, int, amqp_messenger_get_send_status, AMQP_MESSENGER_HANDLE, messenger_handle, AMQP_MESSENGER_SEND_STATUS*, send_status);
-MOCKABLE_FUNCTION(, int, amqp_messenger_start, AMQP_MESSENGER_HANDLE, messenger_handle, SESSION_HANDLE, session_handle);
-MOCKABLE_FUNCTION(, int, amqp_messenger_stop, AMQP_MESSENGER_HANDLE, messenger_handle);
-MOCKABLE_FUNCTION(, void, amqp_messenger_do_work, AMQP_MESSENGER_HANDLE, messenger_handle);
-MOCKABLE_FUNCTION(, void, amqp_messenger_destroy, AMQP_MESSENGER_HANDLE, messenger_handle);
-MOCKABLE_FUNCTION(, int, amqp_messenger_set_option, AMQP_MESSENGER_HANDLE, messenger_handle, const char*, name, void*, value);
-MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, amqp_messenger_retrieve_options, AMQP_MESSENGER_HANDLE, messenger_handle);
-MOCKABLE_FUNCTION(, void, amqp_messenger_destroy_disposition_info, AMQP_MESSENGER_MESSAGE_DISPOSITION_INFO*, disposition_info);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*IOTHUBTRANSPORT_AMQP_AMQP_MESSENGER*/
--- a/iothubtransport_amqp_telemetry_messenger.c Fri May 04 13:22:48 2018 -0700 +++ b/iothubtransport_amqp_telemetry_messenger.c Mon Jun 11 15:38:09 2018 -0700 @@ -14,10 +14,10 @@ #include "azure_uamqp_c/messaging.h" #include "azure_uamqp_c/message_sender.h" #include "azure_uamqp_c/message_receiver.h" -#include "uamqp_messaging.h" -#include "iothub_client_private.h" +#include "internal/uamqp_messaging.h" +#include "internal/iothub_client_private.h" #include "iothub_client_version.h" -#include "iothubtransport_amqp_telemetry_messenger.h" +#include "internal/iothubtransport_amqp_telemetry_messenger.h" #define RESULT_OK 0 #define INDEFINITE_TIME ((time_t)(-1))
--- a/iothubtransport_amqp_telemetry_messenger.h Fri May 04 13:22:48 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-#ifndef IOTHUBTRANSPORT_AMQP_TELEMETRY_MESSENGER
-#define IOTHUBTRANSPORT_AMQP_TELEMETRY_MESSENGER
-
-#include "azure_c_shared_utility/umock_c_prod.h"
-#include "azure_c_shared_utility/optionhandler.h"
-#include "azure_uamqp_c/session.h"
-
-#include "azure_uamqp_c/amqp_definitions_sequence_no.h"
-#include "azure_uamqp_c/amqp_definitions_delivery_number.h"
-
-#include "iothub_client_private.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-static const char* TELEMETRY_MESSENGER_OPTION_EVENT_SEND_TIMEOUT_SECS = "telemetry_event_send_timeout_secs";
-static const char* TELEMETRY_MESSENGER_OPTION_SAVED_OPTIONS = "saved_telemetry_messenger_options";
-
-typedef struct TELEMETRY_MESSENGER_INSTANCE* TELEMETRY_MESSENGER_HANDLE;
-
-typedef enum TELEMETRY_MESSENGER_SEND_STATUS_TAG
-{
- TELEMETRY_MESSENGER_SEND_STATUS_IDLE,
- TELEMETRY_MESSENGER_SEND_STATUS_BUSY
-} TELEMETRY_MESSENGER_SEND_STATUS;
-
-typedef enum TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_TAG
-{
- TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_OK,
- TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_ERROR_CANNOT_PARSE,
- TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_ERROR_FAIL_SENDING,
- TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_ERROR_TIMEOUT,
- TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_MESSENGER_DESTROYED
-} TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT;
-
-typedef enum TELEMETRY_MESSENGER_DISPOSITION_RESULT_TAG
-{
- TELEMETRY_MESSENGER_DISPOSITION_RESULT_NONE,
- TELEMETRY_MESSENGER_DISPOSITION_RESULT_ACCEPTED,
- TELEMETRY_MESSENGER_DISPOSITION_RESULT_REJECTED,
- TELEMETRY_MESSENGER_DISPOSITION_RESULT_RELEASED
-} TELEMETRY_MESSENGER_DISPOSITION_RESULT;
-
-typedef enum TELEMETRY_MESSENGER_STATE_TAG
-{
- TELEMETRY_MESSENGER_STATE_STARTING,
- TELEMETRY_MESSENGER_STATE_STARTED,
- TELEMETRY_MESSENGER_STATE_STOPPING,
- TELEMETRY_MESSENGER_STATE_STOPPED,
- TELEMETRY_MESSENGER_STATE_ERROR
-} TELEMETRY_MESSENGER_STATE;
-
-typedef struct TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO_TAG
-{
- delivery_number message_id;
- char* source;
-} TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO;
-
-typedef void(*ON_TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE)(IOTHUB_MESSAGE_LIST* iothub_message_list, TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT messenger_event_send_complete_result, void* context);
-typedef void(*ON_TELEMETRY_MESSENGER_STATE_CHANGED_CALLBACK)(void* context, TELEMETRY_MESSENGER_STATE previous_state, TELEMETRY_MESSENGER_STATE new_state);
-typedef TELEMETRY_MESSENGER_DISPOSITION_RESULT(*ON_TELEMETRY_MESSENGER_MESSAGE_RECEIVED)(IOTHUB_MESSAGE_HANDLE message, TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO* disposition_info, void* context);
-
-typedef struct TELEMETRY_MESSENGER_CONFIG_TAG
-{
- const char* device_id;
- char* iothub_host_fqdn;
- ON_TELEMETRY_MESSENGER_STATE_CHANGED_CALLBACK on_state_changed_callback;
- void* on_state_changed_context;
-} TELEMETRY_MESSENGER_CONFIG;
-
-#define AMQP_BATCHING_RESERVE_SIZE (1024)
-
-MOCKABLE_FUNCTION(, TELEMETRY_MESSENGER_HANDLE, telemetry_messenger_create, const TELEMETRY_MESSENGER_CONFIG*, messenger_config, const char*, product_info);
-MOCKABLE_FUNCTION(, int, telemetry_messenger_send_async, TELEMETRY_MESSENGER_HANDLE, messenger_handle, IOTHUB_MESSAGE_LIST*, message, ON_TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE, on_messenger_event_send_complete_callback, void*, context);
-MOCKABLE_FUNCTION(, int, telemetry_messenger_subscribe_for_messages, TELEMETRY_MESSENGER_HANDLE, messenger_handle, ON_TELEMETRY_MESSENGER_MESSAGE_RECEIVED, on_message_received_callback, void*, context);
-MOCKABLE_FUNCTION(, int, telemetry_messenger_unsubscribe_for_messages, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
-MOCKABLE_FUNCTION(, int, telemetry_messenger_send_message_disposition, TELEMETRY_MESSENGER_HANDLE, messenger_handle, TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO*, disposition_info, TELEMETRY_MESSENGER_DISPOSITION_RESULT, disposition_result);
-MOCKABLE_FUNCTION(, int, telemetry_messenger_get_send_status, TELEMETRY_MESSENGER_HANDLE, messenger_handle, TELEMETRY_MESSENGER_SEND_STATUS*, send_status);
-MOCKABLE_FUNCTION(, int, telemetry_messenger_start, TELEMETRY_MESSENGER_HANDLE, messenger_handle, SESSION_HANDLE, session_handle);
-MOCKABLE_FUNCTION(, int, telemetry_messenger_stop, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
-MOCKABLE_FUNCTION(, void, telemetry_messenger_do_work, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
-MOCKABLE_FUNCTION(, void, telemetry_messenger_destroy, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
-MOCKABLE_FUNCTION(, int, telemetry_messenger_set_option, TELEMETRY_MESSENGER_HANDLE, messenger_handle, const char*, name, void*, value);
-MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, telemetry_messenger_retrieve_options, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*IOTHUBTRANSPORT_AMQP_TELEMETRY_MESSENGER*/
--- a/iothubtransport_amqp_twin_messenger.c Fri May 04 13:22:48 2018 -0700 +++ b/iothubtransport_amqp_twin_messenger.c Mon Jun 11 15:38:09 2018 -0700 @@ -13,9 +13,9 @@ #include "azure_c_shared_utility/singlylinkedlist.h" #include "azure_uamqp_c/amqp_definitions_fields.h" #include "azure_uamqp_c/messaging.h" -#include "iothub_client_private.h" -#include "iothubtransport_amqp_messenger.h" -#include "iothubtransport_amqp_twin_messenger.h" +#include "internal/iothub_client_private.h" +#include "internal/iothubtransport_amqp_messenger.h" +#include "internal/iothubtransport_amqp_twin_messenger.h" DEFINE_ENUM_STRINGS(TWIN_MESSENGER_SEND_STATUS, TWIN_MESSENGER_SEND_STATUS_VALUES); DEFINE_ENUM_STRINGS(TWIN_REPORT_STATE_RESULT, TWIN_REPORT_STATE_RESULT_VALUES);
--- a/iothubtransport_amqp_twin_messenger.h Fri May 04 13:22:48 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-#ifndef IOTHUBTRANSPORT_AMQP_TWIN_MESSENGER
-#define IOTHUBTRANSPORT_AMQP_TWIN_MESSENGER
-
-#include "azure_c_shared_utility/macro_utils.h"
-#include "azure_c_shared_utility/umock_c_prod.h"
-#include "azure_c_shared_utility/optionhandler.h"
-#include "azure_uamqp_c/session.h"
-#include "iothub_client_private.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- typedef struct TWIN_MESSENGER_INSTANCE* TWIN_MESSENGER_HANDLE;
-
- #define TWIN_MESSENGER_SEND_STATUS_VALUES \
- TWIN_MESSENGER_SEND_STATUS_IDLE, \
- TWIN_MESSENGER_SEND_STATUS_BUSY
-
- DEFINE_ENUM(TWIN_MESSENGER_SEND_STATUS, TWIN_MESSENGER_SEND_STATUS_VALUES);
-
- #define TWIN_REPORT_STATE_RESULT_VALUES \
- TWIN_REPORT_STATE_RESULT_SUCCESS, \
- TWIN_REPORT_STATE_RESULT_ERROR, \
- TWIN_REPORT_STATE_RESULT_CANCELLED
-
- DEFINE_ENUM(TWIN_REPORT_STATE_RESULT, TWIN_REPORT_STATE_RESULT_VALUES);
-
- #define TWIN_REPORT_STATE_REASON_VALUES \
- TWIN_REPORT_STATE_REASON_NONE, \
- TWIN_REPORT_STATE_REASON_INTERNAL_ERROR, \
- TWIN_REPORT_STATE_REASON_FAIL_SENDING, \
- TWIN_REPORT_STATE_REASON_TIMEOUT, \
- TWIN_REPORT_STATE_REASON_INVALID_RESPONSE, \
- TWIN_REPORT_STATE_REASON_MESSENGER_DESTROYED
-
- DEFINE_ENUM(TWIN_REPORT_STATE_REASON, TWIN_REPORT_STATE_REASON_VALUES);
-
- #define TWIN_MESSENGER_STATE_VALUES \
- TWIN_MESSENGER_STATE_STARTING, \
- TWIN_MESSENGER_STATE_STARTED, \
- TWIN_MESSENGER_STATE_STOPPING, \
- TWIN_MESSENGER_STATE_STOPPED, \
- TWIN_MESSENGER_STATE_ERROR
-
- DEFINE_ENUM(TWIN_MESSENGER_STATE, TWIN_MESSENGER_STATE_VALUES);
-
- #define TWIN_UPDATE_TYPE_VALUES \
- TWIN_UPDATE_TYPE_PARTIAL, \
- TWIN_UPDATE_TYPE_COMPLETE
-
- DEFINE_ENUM(TWIN_UPDATE_TYPE, TWIN_UPDATE_TYPE_VALUES);
-
- typedef void(*TWIN_MESSENGER_STATE_CHANGED_CALLBACK)(void* context, TWIN_MESSENGER_STATE previous_state, TWIN_MESSENGER_STATE new_state);
- typedef void(*TWIN_MESSENGER_REPORT_STATE_COMPLETE_CALLBACK)(TWIN_REPORT_STATE_RESULT result, TWIN_REPORT_STATE_REASON reason, int status_code, const void* context);
- typedef void(*TWIN_STATE_UPDATE_CALLBACK)(TWIN_UPDATE_TYPE update_type, const char* payload, size_t size, const void* context);
-
- typedef struct TWIN_MESSENGER_CONFIG_TAG
- {
- const char* client_version;
- const char* device_id;
- char* iothub_host_fqdn;
- TWIN_MESSENGER_STATE_CHANGED_CALLBACK on_state_changed_callback;
- void* on_state_changed_context;
- } TWIN_MESSENGER_CONFIG;
-
- MOCKABLE_FUNCTION(, TWIN_MESSENGER_HANDLE, twin_messenger_create, const TWIN_MESSENGER_CONFIG*, messenger_config);
- MOCKABLE_FUNCTION(, int, twin_messenger_report_state_async, TWIN_MESSENGER_HANDLE, twin_msgr_handle, CONSTBUFFER_HANDLE, data, TWIN_MESSENGER_REPORT_STATE_COMPLETE_CALLBACK, on_report_state_complete_callback, const void*, context);
- MOCKABLE_FUNCTION(, int, twin_messenger_subscribe, TWIN_MESSENGER_HANDLE, twin_msgr_handle, TWIN_STATE_UPDATE_CALLBACK, on_twin_state_update_callback, void*, context);
- MOCKABLE_FUNCTION(, int, twin_messenger_unsubscribe, TWIN_MESSENGER_HANDLE, twin_msgr_handle);
- MOCKABLE_FUNCTION(, int, twin_messenger_get_send_status, TWIN_MESSENGER_HANDLE, twin_msgr_handle, TWIN_MESSENGER_SEND_STATUS*, send_status);
- MOCKABLE_FUNCTION(, int, twin_messenger_start, TWIN_MESSENGER_HANDLE, twin_msgr_handle, SESSION_HANDLE, session_handle);
- MOCKABLE_FUNCTION(, int, twin_messenger_stop, TWIN_MESSENGER_HANDLE, twin_msgr_handle);
- MOCKABLE_FUNCTION(, void, twin_messenger_do_work, TWIN_MESSENGER_HANDLE, twin_msgr_handle);
- MOCKABLE_FUNCTION(, void, twin_messenger_destroy, TWIN_MESSENGER_HANDLE, twin_msgr_handle);
- MOCKABLE_FUNCTION(, int, twin_messenger_set_option, TWIN_MESSENGER_HANDLE, twin_msgr_handle, const char*, name, void*, value);
- MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, twin_messenger_retrieve_options, TWIN_MESSENGER_HANDLE, twin_msgr_handle);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*IOTHUBTRANSPORT_AMQP_TWIN_MESSENGER*/
--- a/iothubtransportamqp.c Fri May 04 13:22:48 2018 -0700
+++ b/iothubtransportamqp.c Mon Jun 11 15:38:09 2018 -0700
@@ -2,7 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include "iothubtransportamqp.h"
-#include "iothubtransport_amqp_common.h"
+#include "internal/iothubtransport_amqp_common.h"
#include "azure_c_shared_utility/tlsio.h"
#include "azure_c_shared_utility/platform.h"
#include "azure_c_shared_utility/xlogging.h"
@@ -61,7 +61,7 @@
return IoTHubTransport_AMQP_Common_ProcessItem(handle, item_type, iothub_item);
}
-static void IoTHubTransportAMQP_DoWork(TRANSPORT_LL_HANDLE handle, IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle)
+static void IoTHubTransportAMQP_DoWork(TRANSPORT_LL_HANDLE handle, IOTHUB_CLIENT_CORE_LL_HANDLE iotHubClientHandle)
{
// Codes_SRS_IOTHUBTRANSPORTAMQP_09_015: [IoTHubTransportAMQP_DoWork shall call into the IoTHubTransport_AMQP_Common_DoWork()]
IoTHubTransport_AMQP_Common_DoWork(handle, iotHubClientHandle);
@@ -120,7 +120,7 @@
return IoTHubTransport_AMQP_Common_SetOption(handle, option, value);
}
-static IOTHUB_DEVICE_HANDLE IoTHubTransportAMQP_Register(TRANSPORT_LL_HANDLE handle, const IOTHUB_DEVICE_CONFIG* device, IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle, PDLIST_ENTRY waitingToSend)
+static IOTHUB_DEVICE_HANDLE IoTHubTransportAMQP_Register(TRANSPORT_LL_HANDLE handle, const IOTHUB_DEVICE_CONFIG* device, IOTHUB_CLIENT_CORE_LL_HANDLE iotHubClientHandle, PDLIST_ENTRY waitingToSend)
{
// Codes_SRS_IOTHUBTRANSPORTAMQP_09_006: [IoTHubTransportAMQP_Register shall register the device by calling into the IoTHubTransport_AMQP_Common_Register().]
return IoTHubTransport_AMQP_Common_Register(handle, device, iotHubClientHandle, waitingToSend);
--- a/iothubtransportamqp_methods.c Fri May 04 13:22:48 2018 -0700
+++ b/iothubtransportamqp_methods.c Mon Jun 11 15:38:09 2018 -0700
@@ -14,7 +14,7 @@
#include "azure_uamqp_c/message_sender.h"
#include "azure_uamqp_c/amqp_definitions_application_properties.h"
-#include "iothubtransportamqp_methods.h"
+#include "internal/iothubtransportamqp_methods.h"
typedef enum SUBSCRIBE_STATE_TAG
{
--- a/iothubtransportamqp_methods.h Fri May 04 13:22:48 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-#ifndef IOTHUBTRANSPORTAMQP_METHODS_H
-#define IOTHUBTRANSPORTAMQP_METHODS_H
-
-#include "azure_uamqp_c/session.h"
-#include "azure_c_shared_utility/buffer_.h"
-#include "azure_c_shared_utility/umock_c_prod.h"
-
-#ifdef __cplusplus
-#include <cstddef>
-
-extern "C"
-{
-#else
-#include <stddef.h>
-#endif
-
- typedef struct IOTHUBTRANSPORT_AMQP_METHOD_TAG* IOTHUBTRANSPORT_AMQP_METHOD_HANDLE;
- typedef struct IOTHUBTRANSPORT_AMQP_METHODS_TAG* IOTHUBTRANSPORT_AMQP_METHODS_HANDLE;
- typedef void(*ON_METHODS_ERROR)(void* context);
- typedef int(*ON_METHOD_REQUEST_RECEIVED)(void* context, const char* method_name, const unsigned char* request, size_t request_size, IOTHUBTRANSPORT_AMQP_METHOD_HANDLE response);
- typedef void(*ON_METHODS_UNSUBSCRIBED)(void* context);
-
- MOCKABLE_FUNCTION(, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransportamqp_methods_create, const char*, hostname, const char*, device_id);
- MOCKABLE_FUNCTION(, void, iothubtransportamqp_methods_destroy, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransport_amqp_methods_handle);
- MOCKABLE_FUNCTION(, int, iothubtransportamqp_methods_subscribe, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransport_amqp_methods_handle,
- SESSION_HANDLE, session_handle, ON_METHODS_ERROR, on_methods_error, void*, on_methods_error_context,
- ON_METHOD_REQUEST_RECEIVED, on_method_request_received, void*, on_method_request_received_context,
- ON_METHODS_UNSUBSCRIBED, on_methods_unsubscribed, void*, on_methods_unsubscribed_context);
- MOCKABLE_FUNCTION(, int, iothubtransportamqp_methods_respond, IOTHUBTRANSPORT_AMQP_METHOD_HANDLE, method_handle,
- const unsigned char*, response, size_t, response_size, int, status_code);
- MOCKABLE_FUNCTION(, void, iothubtransportamqp_methods_unsubscribe, IOTHUBTRANSPORT_AMQP_METHODS_HANDLE, iothubtransport_amqp_methods_handle);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IOTHUBTRANSPORTAMQP_METHODS_H */
--- a/message_queue.c Fri May 04 13:22:48 2018 -0700 +++ b/message_queue.c Mon Jun 11 15:38:09 2018 -0700 @@ -12,7 +12,7 @@ typedef struct MESSAGE_QUEUE_TAG MESSAGE_QUEUE; -#include "message_queue.h" +#include "internal/message_queue.h" #define RESULT_OK 0 #define INDEFINITE_TIME ((time_t)(-1))
--- a/message_queue.h Fri May 04 13:22:48 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,182 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-/** @file message_queue.h
-* @brief A generic message queue.
-*/
-
-#ifndef MESSAGE_QUEUE_H
-#define MESSAGE_QUEUE_H
-
-#include "azure_c_shared_utility/macro_utils.h"
-#include "azure_c_shared_utility/umock_c_prod.h"
-#include "azure_c_shared_utility/optionhandler.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef struct MESSAGE_QUEUE_TAG* MESSAGE_QUEUE_HANDLE;
-typedef void* MQ_MESSAGE_HANDLE;
-typedef void* USER_DEFINED_REASON;
-
-#define MESSAGE_QUEUE_RESULT_STRINGS \
- MESSAGE_QUEUE_SUCCESS, \
- MESSAGE_QUEUE_ERROR, \
- MESSAGE_QUEUE_RETRYABLE_ERROR, \
- MESSAGE_QUEUE_TIMEOUT, \
- MESSAGE_QUEUE_CANCELLED
-
-DEFINE_ENUM(MESSAGE_QUEUE_RESULT, MESSAGE_QUEUE_RESULT_STRINGS);
-
-/**
-* @brief User-provided callback invoked by MESSAGE_QUEUE back to the user when a messages completes being processed.
-*/
-typedef void(*MESSAGE_PROCESSING_COMPLETED_CALLBACK)(MQ_MESSAGE_HANDLE message, MESSAGE_QUEUE_RESULT result, USER_DEFINED_REASON reason, void* user_context);
-
-/**
-* @brief Callback that MUST be invoked by PROCESS_MESSAGE_CALLBACK (user provided) to signal to MESSAGE_QUEUE that a message has been processed.
-* @remarks Besides causing MESSAGE_QUEUE to dequeue the message from its internal lists, causes MESSAGE_PROCESSING_COMPLETED_CALLBACK to be triggered.
-*/
-typedef void(*PROCESS_MESSAGE_COMPLETED_CALLBACK)(MESSAGE_QUEUE_HANDLE message_queue, MQ_MESSAGE_HANDLE message, MESSAGE_QUEUE_RESULT result, USER_DEFINED_REASON reason);
-
-/**
-* @brief User-provided callback invoked by MESSAGE_QUEUE when a messages is ready to be processed, getting internally moved from "pending" to "in-progress".
-*/
-typedef void(*PROCESS_MESSAGE_CALLBACK)(MESSAGE_QUEUE_HANDLE message_queue, MQ_MESSAGE_HANDLE message, PROCESS_MESSAGE_COMPLETED_CALLBACK on_process_message_completed_callback, void* user_context);
-
-typedef struct MESSAGE_QUEUE_CONFIG_TAG
-{
- /**
- * @brief Function that actually process (a.k.a, e.g, sends) a message previously queued.
- *
- * @remarks When MESSAGE_QUEUE is summoned to invoke @c on_process_message_callback (upon call to message_queue_do_work, when a message is moved from the pending to in-progress list),
- * it passes as arguments the MESSAGE_QUEUE handle and a callback function that MUST be invoked by @c on_process_message_callback once it completes.
- * The @c user_context passed is the same provided as argument by the upper layer on @c message_queue_add.
- */
- PROCESS_MESSAGE_CALLBACK on_process_message_callback;
- size_t max_message_enqueued_time_secs;
- size_t max_message_processing_time_secs;
- size_t max_retry_count;
-} MESSAGE_QUEUE_CONFIG;
-
-/**
-* @brief Creates a new instance of MESSAGE_QUEUE.
-*
-* @param config Pointer to an @c MESSAGE_QUEUE_CONFIG structure
-*
-* @returns A non-NULL @c MESSAGE_QUEUE_HANDLE value that is used when invoking other API functions.
-*/
-MOCKABLE_FUNCTION(, MESSAGE_QUEUE_HANDLE, message_queue_create, MESSAGE_QUEUE_CONFIG*, config);
-
-/**
-* @brief Destroys an instance of MESSAGE_QUEUE, releasing all memory it allocated.
-*
-* @remarks All messages still pending to be processed and currently in-progress get bubbled up back to the upper-layer
-* through the @c on_message_processing_completed_callback (passed on the @c MESSAGE_QUEUE_CONFIG instance)
-* with the @c result set as @c MESSAGE_QUEUE_CANCELLED and @c reason set to @c NULL.
-*
-* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
-*/
-MOCKABLE_FUNCTION(, void, message_queue_destroy, MESSAGE_QUEUE_HANDLE, message_queue);
-
-/**
-* @brief Adds a new generic message to MESSAGE_QUEUE's pending list.
-*
-* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
-*
-* @param message A generic message to be queued and then processed (i.e., sent, consolidated, etc).
-*
-* @returns Zero if the no errors occur, non-zero otherwise.
-*/
-MOCKABLE_FUNCTION(, int, message_queue_add, MESSAGE_QUEUE_HANDLE, message_queue, MQ_MESSAGE_HANDLE, message, MESSAGE_PROCESSING_COMPLETED_CALLBACK, on_message_processing_completed_callback, void*, user_context);
-
-/**
-* @brief Causes all messages in-progress to be moved back to the beginning of the pending list.
-*
-* @remarks If on_message_process_completed_callback is invoked for any of message not in in-progress, it is disregarded.
-* Messages are queued back into the pending list in a way they will be sent first when message_queue_do_work is invoked again.
-*
-* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
-*
-* @returns Zero if the no errors occur, non-zero otherwise.
-*/
-MOCKABLE_FUNCTION(, int, message_queue_move_all_back_to_pending, MESSAGE_QUEUE_HANDLE, message_queue);
-
-/**
-* @brief Causes all messages pending to be sent and in-progress to be flushed back to the user through @c on_message_processing_completed_callback.
-*
-* @remarks @c on_message_processing_completed_callback gets invoked with @c result set as MESSAGE_QUEUE_CANCELLED and @c reason set to NULL.
-*
-* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
-*/
-MOCKABLE_FUNCTION(, void, message_queue_remove_all, MESSAGE_QUEUE_HANDLE, message_queue);
-
-/**
-* @brief Informs if there are messages pending to be sent and/or currently in-progress.
-*
-* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
-*
-* @param @c is_empty Set to @c true if there are any messages in pending to be sent and/or currently in-progress, @c false otherwise.
-*
-* @remarks The parameter @c is_empty is only set if no errors occur (like passing a NULL @c message_queue).
-*
-* @returns Zero if the no errors occur, non-zero otherwise.
-*/
-MOCKABLE_FUNCTION(, int, message_queue_is_empty, MESSAGE_QUEUE_HANDLE, message_queue, bool*, is_empty);
-
-/**
-* @brief Causes MESSAGE_QUEUE to go through its list of pending messages and move them to in-progress, as well as trigering retry and timeout controls.
-*
-* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
-*/
-MOCKABLE_FUNCTION(, void, message_queue_do_work, MESSAGE_QUEUE_HANDLE, message_queue);
-
-/**
-* @brief Sets the maximum time, in seconds, a message will be within MESSAGE_QUEUE (in either pending or in-progress lists).
-*
-* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
-*
-* @param seconds Number of seconds to set for this timeout. A value of zero de-activates this timeout control.
-*
-* @returns Zero if the no errors occur, non-zero otherwise.
-*/
-MOCKABLE_FUNCTION(, int, message_queue_set_max_message_enqueued_time_secs, MESSAGE_QUEUE_HANDLE, message_queue, size_t, seconds);
-
-/**
-* @brief Sets the maximum time, in seconds, a message will be in-progress within MESSAGE_QUEUE.
-*
-* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
-*
-* @param seconds Number of seconds to set for this timeout. A value of zero de-activates this timeout control.
-*
-* @returns Zero if the no errors occur, non-zero otherwise.
-*/
-MOCKABLE_FUNCTION(, int, message_queue_set_max_message_processing_time_secs, MESSAGE_QUEUE_HANDLE, message_queue, size_t, seconds);
-
-/**
-* @brief Sets the maximum number of times MESSAGE_QUEUE will try to re-process a message (no counting the initial attempt).
-*
-* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
-*
-* @param max_retry_count The number of times MESSAGE_QUEUE will try to re-process a message.
-*
-* @returns Zero if the no errors occur, non-zero otherwise.
-*/
-MOCKABLE_FUNCTION(, int, message_queue_set_max_retry_count, MESSAGE_QUEUE_HANDLE, message_queue, size_t, max_retry_count);
-
-/**
-* @brief Retrieves a blob with all the options currently set in the instance of MESSAGE_QUEUE.
-*
-* @param message_queue A @c MESSAGE_QUEUE_HANDLE obtained using message_queue_create.
-*
-* @returns A non-NULL @c OPTIONHANDLER_HANDLE if no errors occur, or NULL otherwise.
-*/
-MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, message_queue_retrieve_options, MESSAGE_QUEUE_HANDLE, message_queue);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*MESSAGE_QUEUE_H*/
--- a/uamqp_messaging.c Fri May 04 13:22:48 2018 -0700 +++ b/uamqp_messaging.c Mon Jun 11 15:38:09 2018 -0700 @@ -10,7 +10,7 @@ #include <inttypes.h> #endif -#include "uamqp_messaging.h" +#include "internal/uamqp_messaging.h" #include "azure_c_shared_utility/gballoc.h" #include "azure_c_shared_utility/optimize_size.h" #include "azure_c_shared_utility/xlogging.h"
--- a/uamqp_messaging.h Fri May 04 13:22:48 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-#ifndef UAMQP_MESSAGING_H
-#define UAMQP_MESSAGING_H
-
-#include "iothub_message.h"
-#include "azure_uamqp_c/message.h"
-#include "azure_c_shared_utility/umock_c_prod.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- MOCKABLE_FUNCTION(, int, message_create_IoTHubMessage_from_uamqp_message, MESSAGE_HANDLE, uamqp_message, IOTHUB_MESSAGE_HANDLE*, iothubclient_message);
- MOCKABLE_FUNCTION(, int, message_create_uamqp_encoding_from_iothub_message, MESSAGE_HANDLE, message_batch_container, IOTHUB_MESSAGE_HANDLE, message_handle, BINARY_DATA*, body_binary_data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*UAMQP_MESSAGING_H*/
\ No newline at end of file
