Azure IoT / azure_uamqp_c

Dependents:   iothub_client_sample_amqp remote_monitoring simplesample_amqp

Committer:
Azure.IoT Build
Date:
Fri Apr 08 12:01:10 2016 -0700
Revision:
0:6ae2f7bca550
Child:
1:eab586236bfe
1.0.4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Azure.IoT Build 0:6ae2f7bca550 1 // Copyright (c) Microsoft. All rights reserved.
Azure.IoT Build 0:6ae2f7bca550 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
Azure.IoT Build 0:6ae2f7bca550 3
Azure.IoT Build 0:6ae2f7bca550 4 #ifndef CONNECTION_H
Azure.IoT Build 0:6ae2f7bca550 5 #define CONNECTION_H
Azure.IoT Build 0:6ae2f7bca550 6
Azure.IoT Build 0:6ae2f7bca550 7 #include <stddef.h>
Azure.IoT Build 0:6ae2f7bca550 8 #include <stdint.h>
Azure.IoT Build 0:6ae2f7bca550 9 #include "azure_uamqp_c/amqp_frame_codec.h"
Azure.IoT Build 0:6ae2f7bca550 10 #include "azure_uamqp_c/amqp_definitions.h"
Azure.IoT Build 0:6ae2f7bca550 11
Azure.IoT Build 0:6ae2f7bca550 12 #ifdef __cplusplus
Azure.IoT Build 0:6ae2f7bca550 13 extern "C" {
Azure.IoT Build 0:6ae2f7bca550 14 #endif /* __cplusplus */
Azure.IoT Build 0:6ae2f7bca550 15
Azure.IoT Build 0:6ae2f7bca550 16 typedef struct CONNECTION_INSTANCE_TAG* CONNECTION_HANDLE;
Azure.IoT Build 0:6ae2f7bca550 17 typedef struct ENDPOINT_INSTANCE_TAG* ENDPOINT_HANDLE;
Azure.IoT Build 0:6ae2f7bca550 18
Azure.IoT Build 0:6ae2f7bca550 19 typedef enum CONNECTION_STATE_TAG
Azure.IoT Build 0:6ae2f7bca550 20 {
Azure.IoT Build 0:6ae2f7bca550 21 /* Codes_SRS_CONNECTION_01_039: [START In this state a connection exists, but nothing has been sent or received. This is the state an implementation would be in immediately after performing a socket connect or socket accept.] */
Azure.IoT Build 0:6ae2f7bca550 22 CONNECTION_STATE_START,
Azure.IoT Build 0:6ae2f7bca550 23
Azure.IoT Build 0:6ae2f7bca550 24 /* Codes_SRS_CONNECTION_01_040: [HDR RCVD In this state the connection header has been received from the peer but a connection header has not been sent.] */
Azure.IoT Build 0:6ae2f7bca550 25 CONNECTION_STATE_HDR_RCVD,
Azure.IoT Build 0:6ae2f7bca550 26
Azure.IoT Build 0:6ae2f7bca550 27 /* Codes_SRS_CONNECTION_01_041: [HDR SENT In this state the connection header has been sent to the peer but no connection header has been received.] */
Azure.IoT Build 0:6ae2f7bca550 28 CONNECTION_STATE_HDR_SENT,
Azure.IoT Build 0:6ae2f7bca550 29
Azure.IoT Build 0:6ae2f7bca550 30 /* Codes_SRS_CONNECTION_01_042: [HDR EXCH In this state the connection header has been sent to the peer and a connection header has been received from the peer.] */
Azure.IoT Build 0:6ae2f7bca550 31 CONNECTION_STATE_HDR_EXCH,
Azure.IoT Build 0:6ae2f7bca550 32
Azure.IoT Build 0:6ae2f7bca550 33 /* Codes_SRS_CONNECTION_01_043: [OPEN PIPE In this state both the connection header and the open frame have been sent but nothing has been received.] */
Azure.IoT Build 0:6ae2f7bca550 34 CONNECTION_STATE_OPEN_PIPE,
Azure.IoT Build 0:6ae2f7bca550 35
Azure.IoT Build 0:6ae2f7bca550 36 /* Codes_SRS_CONNECTION_01_044: [OC PIPE In this state, the connection header, the open frame, any pipelined connection traffic, and the close frame have been sent but nothing has been received.] */
Azure.IoT Build 0:6ae2f7bca550 37 CONNECTION_STATE_OC_PIPE,
Azure.IoT Build 0:6ae2f7bca550 38
Azure.IoT Build 0:6ae2f7bca550 39 /* Codes_SRS_CONNECTION_01_045: [OPEN RCVD In this state the connection headers have been exchanged. An open frame has been received from the peer but an open frame has not been sent.] */
Azure.IoT Build 0:6ae2f7bca550 40 CONNECTION_STATE_OPEN_RCVD,
Azure.IoT Build 0:6ae2f7bca550 41
Azure.IoT Build 0:6ae2f7bca550 42 /* Codes_SRS_CONNECTION_01_046: [OPEN SENT In this state the connection headers have been exchanged. An open frame has been sent to the peer but no open frame has yet been received.] */
Azure.IoT Build 0:6ae2f7bca550 43 CONNECTION_STATE_OPEN_SENT,
Azure.IoT Build 0:6ae2f7bca550 44
Azure.IoT Build 0:6ae2f7bca550 45 /* Codes_SRS_CONNECTION_01_047: [CLOSE PIPE In this state the connection headers have been exchanged. An open frame, any pipelined connection traffic, and the close frame have been sent but no open frame has yet been received from the peer.] */
Azure.IoT Build 0:6ae2f7bca550 46 CONNECTION_STATE_CLOSE_PIPE,
Azure.IoT Build 0:6ae2f7bca550 47
Azure.IoT Build 0:6ae2f7bca550 48 /* Codes_SRS_CONNECTION_01_048: [OPENED In this state the connection header and the open frame have been both sent and received.] */
Azure.IoT Build 0:6ae2f7bca550 49 CONNECTION_STATE_OPENED,
Azure.IoT Build 0:6ae2f7bca550 50
Azure.IoT Build 0:6ae2f7bca550 51 /* Codes_SRS_CONNECTION_01_049: [CLOSE RCVD In this state a close frame has been received indicating that the peer has initiated an AMQP close.] */
Azure.IoT Build 0:6ae2f7bca550 52 CONNECTION_STATE_CLOSE_RCVD,
Azure.IoT Build 0:6ae2f7bca550 53
Azure.IoT Build 0:6ae2f7bca550 54 /* Codes_SRS_CONNECTION_01_053: [CLOSE SENT In this state a close frame has been sent to the peer. It is illegal to write anything more onto the connection, however there could potentially still be incoming frames.] */
Azure.IoT Build 0:6ae2f7bca550 55 CONNECTION_STATE_CLOSE_SENT,
Azure.IoT Build 0:6ae2f7bca550 56
Azure.IoT Build 0:6ae2f7bca550 57 /* Codes_SRS_CONNECTION_01_055: [DISCARDING The DISCARDING state is a variant of the CLOSE SENT state where the close is triggered by an error.] */
Azure.IoT Build 0:6ae2f7bca550 58 CONNECTION_STATE_DISCARDING,
Azure.IoT Build 0:6ae2f7bca550 59
Azure.IoT Build 0:6ae2f7bca550 60 /* Codes_SRS_CONNECTION_01_057: [END In this state it is illegal for either endpoint to write anything more onto the connection. The connection can be safely closed and discarded.] */
Azure.IoT Build 0:6ae2f7bca550 61 CONNECTION_STATE_END
Azure.IoT Build 0:6ae2f7bca550 62 } CONNECTION_STATE;
Azure.IoT Build 0:6ae2f7bca550 63
Azure.IoT Build 0:6ae2f7bca550 64 typedef void(*ON_ENDPOINT_FRAME_RECEIVED)(void* context, AMQP_VALUE performative, uint32_t frame_payload_size, const unsigned char* payload_bytes);
Azure.IoT Build 0:6ae2f7bca550 65 typedef void(*ON_CONNECTION_STATE_CHANGED)(void* context, CONNECTION_STATE new_connection_state, CONNECTION_STATE previous_connection_state);
Azure.IoT Build 0:6ae2f7bca550 66 typedef bool(*ON_NEW_ENDPOINT)(void* context, ENDPOINT_HANDLE new_endpoint);
Azure.IoT Build 0:6ae2f7bca550 67
Azure.IoT Build 0:6ae2f7bca550 68 extern CONNECTION_HANDLE connection_create(XIO_HANDLE io, const char* hostname, const char* container_id, ON_NEW_ENDPOINT on_new_endpoint, void* callback_context);
Azure.IoT Build 0:6ae2f7bca550 69 extern CONNECTION_HANDLE connection_create2(XIO_HANDLE xio, const char* hostname, const char* container_id, ON_NEW_ENDPOINT on_new_endpoint, void* callback_context, ON_CONNECTION_STATE_CHANGED on_connection_state_changed, void* on_connection_state_changed_context, ON_IO_ERROR on_io_error, void* on_io_error_context, LOGGER_LOG logger);
Azure.IoT Build 0:6ae2f7bca550 70 extern void connection_destroy(CONNECTION_HANDLE connection);
Azure.IoT Build 0:6ae2f7bca550 71 extern int connection_open(CONNECTION_HANDLE connection);
Azure.IoT Build 0:6ae2f7bca550 72 extern int connection_listen(CONNECTION_HANDLE connection);
Azure.IoT Build 0:6ae2f7bca550 73 extern int connection_close(CONNECTION_HANDLE connection, const char* condition_value, const char* description);
Azure.IoT Build 0:6ae2f7bca550 74 extern int connection_set_max_frame_size(CONNECTION_HANDLE connection, uint32_t max_frame_size);
Azure.IoT Build 0:6ae2f7bca550 75 extern int connection_get_max_frame_size(CONNECTION_HANDLE connection, uint32_t* max_frame_size);
Azure.IoT Build 0:6ae2f7bca550 76 extern int connection_set_channel_max(CONNECTION_HANDLE connection, uint16_t channel_max);
Azure.IoT Build 0:6ae2f7bca550 77 extern int connection_get_channel_max(CONNECTION_HANDLE connection, uint16_t* channel_max);
Azure.IoT Build 0:6ae2f7bca550 78 extern int connection_set_idle_timeout(CONNECTION_HANDLE connection, milliseconds idle_timeout);
Azure.IoT Build 0:6ae2f7bca550 79 extern int connection_get_idle_timeout(CONNECTION_HANDLE connection, milliseconds* idle_timeout);
Azure.IoT Build 0:6ae2f7bca550 80 extern int connection_get_remote_max_frame_size(CONNECTION_HANDLE connection, uint32_t* remote_max_frame_size);
Azure.IoT Build 0:6ae2f7bca550 81 extern void connection_dowork(CONNECTION_HANDLE connection);
Azure.IoT Build 0:6ae2f7bca550 82 extern ENDPOINT_HANDLE connection_create_endpoint(CONNECTION_HANDLE connection);
Azure.IoT Build 0:6ae2f7bca550 83 extern int connection_start_endpoint(ENDPOINT_HANDLE endpoint, ON_ENDPOINT_FRAME_RECEIVED on_frame_received, ON_CONNECTION_STATE_CHANGED on_connection_state_changed, void* context);
Azure.IoT Build 0:6ae2f7bca550 84 extern int connection_endpoint_get_incoming_channel(ENDPOINT_HANDLE endpoint, uint16_t* incoming_channel);
Azure.IoT Build 0:6ae2f7bca550 85 extern void connection_destroy_endpoint(ENDPOINT_HANDLE endpoint);
Azure.IoT Build 0:6ae2f7bca550 86 extern int connection_encode_frame(ENDPOINT_HANDLE endpoint, const AMQP_VALUE performative, PAYLOAD* payloads, size_t payload_count, ON_SEND_COMPLETE on_send_complete, void* callback_context);
Azure.IoT Build 0:6ae2f7bca550 87
Azure.IoT Build 0:6ae2f7bca550 88 #ifdef __cplusplus
Azure.IoT Build 0:6ae2f7bca550 89 }
Azure.IoT Build 0:6ae2f7bca550 90 #endif /* __cplusplus */
Azure.IoT Build 0:6ae2f7bca550 91
Azure.IoT Build 0:6ae2f7bca550 92 #endif /* CONNECTION_H */