A small memory footprint AMQP implimentation

Dependents:   iothub_client_sample_amqp remote_monitoring simplesample_amqp

Committer:
AzureIoTClient
Date:
Thu Oct 04 09:16:13 2018 -0700
Revision:
47:365a93fdb5bb
Parent:
46:01f7ca900e07
1.2.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_uamqp_c/amqpvalue.h"
Azure.IoT Build 0:6ae2f7bca550 8
Azure.IoT Build 0:6ae2f7bca550 9 #ifdef __cplusplus
Azure.IoT Build 0:6ae2f7bca550 10 extern "C" {
Azure.IoT Build 0:6ae2f7bca550 11 #include <cstdint>
Azure.IoT Build 0:6ae2f7bca550 12 #include <cstddef>
Azure.IoT Build 0:6ae2f7bca550 13 #else
Azure.IoT Build 0:6ae2f7bca550 14 #include <stdint.h>
Azure.IoT Build 0:6ae2f7bca550 15 #include <stddef.h>
Azure.IoT Build 0:6ae2f7bca550 16 #include <stdbool.h>
Azure.IoT Build 0:6ae2f7bca550 17 #endif /* __cplusplus */
Azure.IoT Build 0:6ae2f7bca550 18
AzureIoTClient 10:19ce00951771 19 #include "azure_c_shared_utility/umock_c_prod.h"
AzureIoTClient 10:19ce00951771 20
Azure.IoT Build 0:6ae2f7bca550 21 typedef struct PAYLOAD_TAG
Azure.IoT Build 0:6ae2f7bca550 22 {
AzureIoTClient 28:add19eb7defa 23 const unsigned char* bytes;
AzureIoTClient 28:add19eb7defa 24 size_t length;
Azure.IoT Build 0:6ae2f7bca550 25 } PAYLOAD;
Azure.IoT Build 0:6ae2f7bca550 26
Azure.IoT Build 0:6ae2f7bca550 27 /* Codes_SRS_FRAME_CODEC_01_016: [The type code indicates the format and purpose of the frame.] */
Azure.IoT Build 0:6ae2f7bca550 28 /* 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 29 /* Codes_SRS_FRAME_CODEC_01_070: [The type code indicates the format and purpose of the frame.] */
Azure.IoT Build 0:6ae2f7bca550 30 /* 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 31 /* Codes_SRS_FRAME_CODEC_01_018: [A type code of 0x00 indicates that the frame is an AMQP frame.] */
Azure.IoT Build 0:6ae2f7bca550 32 /* Codes_SRS_FRAME_CODEC_01_072: [A type code of 0x00 indicates that the frame is an AMQP frame.] */
AzureIoTClient 28:add19eb7defa 33 #define FRAME_TYPE_AMQP (uint8_t)0x00
Azure.IoT Build 0:6ae2f7bca550 34
Azure.IoT Build 0:6ae2f7bca550 35 /* Codes_SRS_FRAME_CODEC_01_073: [A type code of 0x01 indicates that the frame is a SASL frame] */
Azure.IoT Build 0:6ae2f7bca550 36 /* Codes_SRS_FRAME_CODEC_01_019: [A type code of 0x01 indicates that the frame is a SASL frame] */
AzureIoTClient 28:add19eb7defa 37 #define FRAME_TYPE_SASL (uint8_t)0x01
Azure.IoT Build 0:6ae2f7bca550 38
AzureIoTClient 28:add19eb7defa 39 typedef struct FRAME_CODEC_INSTANCE_TAG* FRAME_CODEC_HANDLE;
AzureIoTClient 28:add19eb7defa 40 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);
AzureIoTClient 28:add19eb7defa 41 typedef void(*ON_FRAME_CODEC_ERROR)(void* context);
AzureIoTClient 28:add19eb7defa 42 typedef void(*ON_BYTES_ENCODED)(void* context, const unsigned char* bytes, size_t length, bool encode_complete);
Azure.IoT Build 0:6ae2f7bca550 43
AzureIoTClient 28:add19eb7defa 44 MOCKABLE_FUNCTION(, FRAME_CODEC_HANDLE, frame_codec_create, ON_FRAME_CODEC_ERROR, on_frame_codec_error, void*, callback_context);
AzureIoTClient 28:add19eb7defa 45 MOCKABLE_FUNCTION(, void, frame_codec_destroy, FRAME_CODEC_HANDLE, frame_codec);
AzureIoTClient 28:add19eb7defa 46 MOCKABLE_FUNCTION(, int, frame_codec_set_max_frame_size, FRAME_CODEC_HANDLE, frame_codec, uint32_t, max_frame_size);
AzureIoTClient 28:add19eb7defa 47 MOCKABLE_FUNCTION(, int, frame_codec_subscribe, FRAME_CODEC_HANDLE, frame_codec, uint8_t, type, ON_FRAME_RECEIVED, on_frame_received, void*, callback_context);
AzureIoTClient 28:add19eb7defa 48 MOCKABLE_FUNCTION(, int, frame_codec_unsubscribe, FRAME_CODEC_HANDLE, frame_codec, uint8_t, type);
AzureIoTClient 28:add19eb7defa 49 MOCKABLE_FUNCTION(, int, frame_codec_receive_bytes, FRAME_CODEC_HANDLE, frame_codec, const unsigned char*, buffer, size_t, size);
AzureIoTClient 28:add19eb7defa 50 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, on_bytes_encoded, void*, callback_context);
AzureIoTClient 46:01f7ca900e07 51
Azure.IoT Build 0:6ae2f7bca550 52 #ifdef __cplusplus
Azure.IoT Build 0:6ae2f7bca550 53 }
Azure.IoT Build 0:6ae2f7bca550 54 #endif /* __cplusplus */
Azure.IoT Build 0:6ae2f7bca550 55
Azure.IoT Build 0:6ae2f7bca550 56 #endif /* FRAME_CODEC_H */