A small memory footprint AMQP implimentation

Dependents:   iothub_client_sample_amqp remote_monitoring simplesample_amqp

Committer:
AzureIoTClient
Date:
Fri Sep 09 13:37:56 2016 -0700
Revision:
10:19ce00951771
Parent:
6:641a9672db08
Child:
21:f9c433d8e6ca
1.0.10

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 FRAME_CODEC_H
Azure.IoT Build 0:6ae2f7bca550 5 #define FRAME_CODEC_H
Azure.IoT Build 0:6ae2f7bca550 6
Azure.IoT Build 0:6ae2f7bca550 7 #include "azure_c_shared_utility/xio.h"
Azure.IoT Build 0:6ae2f7bca550 8 #include "azure_uamqp_c/amqpvalue.h"
Azure.IoT Build 0:6ae2f7bca550 9
Azure.IoT Build 0:6ae2f7bca550 10 #ifdef __cplusplus
Azure.IoT Build 0:6ae2f7bca550 11 extern "C" {
Azure.IoT Build 0:6ae2f7bca550 12 #include <cstdint>
Azure.IoT Build 0:6ae2f7bca550 13 #include <cstddef>
Azure.IoT Build 0:6ae2f7bca550 14 #include <cstdbool>
Azure.IoT Build 0:6ae2f7bca550 15 #else
Azure.IoT Build 0:6ae2f7bca550 16 #include <stdint.h>
Azure.IoT Build 0:6ae2f7bca550 17 #include <stddef.h>
Azure.IoT Build 0:6ae2f7bca550 18 #include <stdbool.h>
Azure.IoT Build 0:6ae2f7bca550 19 #endif /* __cplusplus */
Azure.IoT Build 0:6ae2f7bca550 20
AzureIoTClient 10:19ce00951771 21 #include "azure_c_shared_utility/umock_c_prod.h"
AzureIoTClient 10:19ce00951771 22
Azure.IoT Build 0:6ae2f7bca550 23 typedef struct PAYLOAD_TAG
Azure.IoT Build 0:6ae2f7bca550 24 {
Azure.IoT Build 0:6ae2f7bca550 25 const unsigned char* bytes;
AzureIoTClient 6:641a9672db08 26 size_t length;
Azure.IoT Build 0:6ae2f7bca550 27 } PAYLOAD;
Azure.IoT Build 0:6ae2f7bca550 28
Azure.IoT Build 0:6ae2f7bca550 29 /* Codes_SRS_FRAME_CODEC_01_016: [The type code indicates the format and purpose of the frame.] */
Azure.IoT Build 0:6ae2f7bca550 30 /* Codes_SRS_FRAME_CODEC_01_017: [The subsequent bytes in the frame header MAY be interpreted differently depending on the type of the frame.] */
Azure.IoT Build 0:6ae2f7bca550 31 /* Codes_SRS_FRAME_CODEC_01_070: [The type code indicates the format and purpose of the frame.] */
Azure.IoT Build 0:6ae2f7bca550 32 /* Codes_SRS_FRAME_CODEC_01_071: [The subsequent bytes in the frame header MAY be interpreted differently depending on the type of the frame.] */
Azure.IoT Build 0:6ae2f7bca550 33 /* Codes_SRS_FRAME_CODEC_01_018: [A type code of 0x00 indicates that the frame is an AMQP frame.] */
Azure.IoT Build 0:6ae2f7bca550 34 /* Codes_SRS_FRAME_CODEC_01_072: [A type code of 0x00 indicates that the frame is an AMQP frame.] */
Azure.IoT Build 0:6ae2f7bca550 35 #define FRAME_TYPE_AMQP (uint8_t)0x00
Azure.IoT Build 0:6ae2f7bca550 36
Azure.IoT Build 0:6ae2f7bca550 37 /* Codes_SRS_FRAME_CODEC_01_073: [A type code of 0x01 indicates that the frame is a SASL frame] */
Azure.IoT Build 0:6ae2f7bca550 38 /* Codes_SRS_FRAME_CODEC_01_019: [A type code of 0x01 indicates that the frame is a SASL frame] */
Azure.IoT Build 0:6ae2f7bca550 39 #define FRAME_TYPE_SASL (uint8_t)0x01
Azure.IoT Build 0:6ae2f7bca550 40
Azure.IoT Build 0:6ae2f7bca550 41 typedef struct FRAME_CODEC_INSTANCE_TAG* FRAME_CODEC_HANDLE;
Azure.IoT Build 0:6ae2f7bca550 42 typedef void(*ON_FRAME_RECEIVED)(void* context, const unsigned char* type_specific, uint32_t type_specific_size, const unsigned char* frame_body, uint32_t frame_body_size);
Azure.IoT Build 0:6ae2f7bca550 43 typedef void(*ON_FRAME_CODEC_ERROR)(void* context);
Azure.IoT Build 0:6ae2f7bca550 44 typedef void(*ON_BYTES_ENCODED)(void* context, const unsigned char* bytes, size_t length, bool encode_complete);
Azure.IoT Build 0:6ae2f7bca550 45
AzureIoTClient 10:19ce00951771 46 MOCKABLE_FUNCTION(, FRAME_CODEC_HANDLE, frame_codec_create, ON_FRAME_CODEC_ERROR, on_frame_codec_error, void*, callback_context);
AzureIoTClient 10:19ce00951771 47 MOCKABLE_FUNCTION(, void, frame_codec_destroy, FRAME_CODEC_HANDLE, frame_codec);
AzureIoTClient 10:19ce00951771 48 MOCKABLE_FUNCTION(, int, frame_codec_set_max_frame_size, FRAME_CODEC_HANDLE, frame_codec, uint32_t, max_frame_size);
AzureIoTClient 10:19ce00951771 49 MOCKABLE_FUNCTION(, int, frame_codec_subscribe, FRAME_CODEC_HANDLE, frame_codec, uint8_t, type, ON_FRAME_RECEIVED, on_frame_received, void*, callback_context);
AzureIoTClient 10:19ce00951771 50 MOCKABLE_FUNCTION(, int, frame_codec_unsubscribe, FRAME_CODEC_HANDLE, frame_codec, uint8_t, type);
AzureIoTClient 10:19ce00951771 51 MOCKABLE_FUNCTION(, int, frame_codec_receive_bytes, FRAME_CODEC_HANDLE, frame_codec, const unsigned char*, buffer, size_t, size);
AzureIoTClient 10:19ce00951771 52 MOCKABLE_FUNCTION(, int, frame_codec_encode_frame, FRAME_CODEC_HANDLE, frame_codec, uint8_t, type, const PAYLOAD*, payloads, size_t, payload_count, const unsigned char*, type_specific_bytes, uint32_t, type_specific_size, ON_BYTES_ENCODED, encoded_bytes, void*, callback_context);
Azure.IoT Build 0:6ae2f7bca550 53
Azure.IoT Build 0:6ae2f7bca550 54 #ifdef __cplusplus
Azure.IoT Build 0:6ae2f7bca550 55 }
Azure.IoT Build 0:6ae2f7bca550 56 #endif /* __cplusplus */
Azure.IoT Build 0:6ae2f7bca550 57
Azure.IoT Build 0:6ae2f7bca550 58 #endif /* FRAME_CODEC_H */