A small memory footprint AMQP implimentation
Dependents: iothub_client_sample_amqp remote_monitoring simplesample_amqp
azure_uamqp_c/frame_codec.h@0:6ae2f7bca550, 2016-04-08 (annotated)
- Committer:
- Azure.IoT Build
- Date:
- Fri Apr 08 12:01:10 2016 -0700
- Revision:
- 0:6ae2f7bca550
- Child:
- 5:ae49385aff34
1.0.4
Who changed what in which revision?
User | Revision | Line number | New 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_c_shared_utility/xlogging.h" |
Azure.IoT Build | 0:6ae2f7bca550 | 9 | #include "azure_uamqp_c/amqpvalue.h" |
Azure.IoT Build | 0:6ae2f7bca550 | 10 | |
Azure.IoT Build | 0:6ae2f7bca550 | 11 | #ifdef __cplusplus |
Azure.IoT Build | 0:6ae2f7bca550 | 12 | extern "C" { |
Azure.IoT Build | 0:6ae2f7bca550 | 13 | #include <cstdint> |
Azure.IoT Build | 0:6ae2f7bca550 | 14 | #include <cstddef> |
Azure.IoT Build | 0:6ae2f7bca550 | 15 | #include <cstdbool> |
Azure.IoT Build | 0:6ae2f7bca550 | 16 | #else |
Azure.IoT Build | 0:6ae2f7bca550 | 17 | #include <stdint.h> |
Azure.IoT Build | 0:6ae2f7bca550 | 18 | #include <stddef.h> |
Azure.IoT Build | 0:6ae2f7bca550 | 19 | #include <stdbool.h> |
Azure.IoT Build | 0:6ae2f7bca550 | 20 | #endif /* __cplusplus */ |
Azure.IoT Build | 0:6ae2f7bca550 | 21 | |
Azure.IoT Build | 0:6ae2f7bca550 | 22 | typedef struct PAYLOAD_TAG |
Azure.IoT Build | 0:6ae2f7bca550 | 23 | { |
Azure.IoT Build | 0:6ae2f7bca550 | 24 | const unsigned char* bytes; |
Azure.IoT Build | 0:6ae2f7bca550 | 25 | uint32_t length; |
Azure.IoT Build | 0:6ae2f7bca550 | 26 | } PAYLOAD; |
Azure.IoT Build | 0:6ae2f7bca550 | 27 | |
Azure.IoT Build | 0:6ae2f7bca550 | 28 | /* Codes_SRS_FRAME_CODEC_01_016: [The type code indicates the format and purpose of the frame.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 29 | /* 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 | 30 | /* Codes_SRS_FRAME_CODEC_01_070: [The type code indicates the format and purpose of the frame.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 31 | /* 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 | 32 | /* Codes_SRS_FRAME_CODEC_01_018: [A type code of 0x00 indicates that the frame is an AMQP frame.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 33 | /* Codes_SRS_FRAME_CODEC_01_072: [A type code of 0x00 indicates that the frame is an AMQP frame.] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 34 | #define FRAME_TYPE_AMQP (uint8_t)0x00 |
Azure.IoT Build | 0:6ae2f7bca550 | 35 | |
Azure.IoT Build | 0:6ae2f7bca550 | 36 | /* Codes_SRS_FRAME_CODEC_01_073: [A type code of 0x01 indicates that the frame is a SASL frame] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 37 | /* Codes_SRS_FRAME_CODEC_01_019: [A type code of 0x01 indicates that the frame is a SASL frame] */ |
Azure.IoT Build | 0:6ae2f7bca550 | 38 | #define FRAME_TYPE_SASL (uint8_t)0x01 |
Azure.IoT Build | 0:6ae2f7bca550 | 39 | |
Azure.IoT Build | 0:6ae2f7bca550 | 40 | typedef struct FRAME_CODEC_INSTANCE_TAG* FRAME_CODEC_HANDLE; |
Azure.IoT Build | 0:6ae2f7bca550 | 41 | 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 | 42 | typedef void(*ON_FRAME_CODEC_ERROR)(void* context); |
Azure.IoT Build | 0:6ae2f7bca550 | 43 | typedef void(*ON_BYTES_ENCODED)(void* context, const unsigned char* bytes, size_t length, bool encode_complete); |
Azure.IoT Build | 0:6ae2f7bca550 | 44 | |
Azure.IoT Build | 0:6ae2f7bca550 | 45 | extern FRAME_CODEC_HANDLE frame_codec_create(ON_FRAME_CODEC_ERROR on_frame_codec_error, void* callback_context, LOGGER_LOG logger_log); |
Azure.IoT Build | 0:6ae2f7bca550 | 46 | extern void frame_codec_destroy(FRAME_CODEC_HANDLE frame_codec); |
Azure.IoT Build | 0:6ae2f7bca550 | 47 | extern int frame_codec_set_max_frame_size(FRAME_CODEC_HANDLE frame_codec, uint32_t max_frame_size); |
Azure.IoT Build | 0:6ae2f7bca550 | 48 | extern int frame_codec_subscribe(FRAME_CODEC_HANDLE frame_codec, uint8_t type, ON_FRAME_RECEIVED on_frame_received, void* callback_context); |
Azure.IoT Build | 0:6ae2f7bca550 | 49 | extern int frame_codec_unsubscribe(FRAME_CODEC_HANDLE frame_codec, uint8_t type); |
Azure.IoT Build | 0:6ae2f7bca550 | 50 | extern int frame_codec_receive_bytes(FRAME_CODEC_HANDLE frame_codec, const unsigned char* buffer, size_t size); |
Azure.IoT Build | 0:6ae2f7bca550 | 51 | extern 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 | 52 | |
Azure.IoT Build | 0:6ae2f7bca550 | 53 | #ifdef __cplusplus |
Azure.IoT Build | 0:6ae2f7bca550 | 54 | } |
Azure.IoT Build | 0:6ae2f7bca550 | 55 | #endif /* __cplusplus */ |
Azure.IoT Build | 0:6ae2f7bca550 | 56 | |
Azure.IoT Build | 0:6ae2f7bca550 | 57 | #endif /* FRAME_CODEC_H */ |