A small memory footprint AMQP implimentation

Dependents:   iothub_client_sample_amqp remote_monitoring simplesample_amqp

Committer:
AzureIoTClient
Date:
Fri Jun 30 10:41:22 2017 -0700
Revision:
28:add19eb7defa
Parent:
27:d74f1cea23e1
1.1.18

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 #include <stdlib.h>
Azure.IoT Build 0:6ae2f7bca550 5 #include <string.h>
AzureIoTClient 19:000ab4e6a2c1 6 #include "azure_c_shared_utility/optimize_size.h"
AzureIoTClient 21:f9c433d8e6ca 7 #include "azure_c_shared_utility/gballoc.h"
AzureIoTClient 27:d74f1cea23e1 8 #include "azure_c_shared_utility/xlogging.h"
Azure.IoT Build 0:6ae2f7bca550 9 #include "azure_uamqp_c/sasl_mssbcbs.h"
Azure.IoT Build 0:6ae2f7bca550 10
Azure.IoT Build 0:6ae2f7bca550 11 typedef struct SASL_MSSBCBS_INSTANCE_TAG
Azure.IoT Build 0:6ae2f7bca550 12 {
AzureIoTClient 28:add19eb7defa 13 unsigned char dummy;
Azure.IoT Build 0:6ae2f7bca550 14 } SASL_MSSBCBS_INSTANCE;
Azure.IoT Build 0:6ae2f7bca550 15
Azure.IoT Build 0:6ae2f7bca550 16 static const SASL_MECHANISM_INTERFACE_DESCRIPTION saslmssbcbs_interface =
Azure.IoT Build 0:6ae2f7bca550 17 {
AzureIoTClient 28:add19eb7defa 18 saslmssbcbs_create,
AzureIoTClient 28:add19eb7defa 19 saslmssbcbs_destroy,
AzureIoTClient 28:add19eb7defa 20 saslmssbcbs_get_init_bytes,
AzureIoTClient 28:add19eb7defa 21 saslmssbcbs_get_mechanism_name,
AzureIoTClient 28:add19eb7defa 22 saslmssbcbs_challenge
Azure.IoT Build 0:6ae2f7bca550 23 };
Azure.IoT Build 0:6ae2f7bca550 24
Azure.IoT Build 0:6ae2f7bca550 25 CONCRETE_SASL_MECHANISM_HANDLE saslmssbcbs_create(void* config)
Azure.IoT Build 0:6ae2f7bca550 26 {
AzureIoTClient 6:641a9672db08 27 (void)config;
AzureIoTClient 28:add19eb7defa 28 return malloc(sizeof(SASL_MSSBCBS_INSTANCE));
Azure.IoT Build 0:6ae2f7bca550 29 }
Azure.IoT Build 0:6ae2f7bca550 30
Azure.IoT Build 0:6ae2f7bca550 31 void saslmssbcbs_destroy(CONCRETE_SASL_MECHANISM_HANDLE sasl_mechanism_concrete_handle)
Azure.IoT Build 0:6ae2f7bca550 32 {
AzureIoTClient 28:add19eb7defa 33 if (sasl_mechanism_concrete_handle != NULL)
AzureIoTClient 28:add19eb7defa 34 {
AzureIoTClient 28:add19eb7defa 35 free(sasl_mechanism_concrete_handle);
AzureIoTClient 28:add19eb7defa 36 }
Azure.IoT Build 0:6ae2f7bca550 37 }
Azure.IoT Build 0:6ae2f7bca550 38
Azure.IoT Build 0:6ae2f7bca550 39 int saslmssbcbs_get_init_bytes(CONCRETE_SASL_MECHANISM_HANDLE sasl_mechanism_concrete_handle, SASL_MECHANISM_BYTES* init_bytes)
Azure.IoT Build 0:6ae2f7bca550 40 {
AzureIoTClient 28:add19eb7defa 41 int result;
Azure.IoT Build 0:6ae2f7bca550 42
AzureIoTClient 28:add19eb7defa 43 if (sasl_mechanism_concrete_handle == NULL)
AzureIoTClient 28:add19eb7defa 44 {
AzureIoTClient 28:add19eb7defa 45 result = __FAILURE__;
AzureIoTClient 28:add19eb7defa 46 }
AzureIoTClient 28:add19eb7defa 47 else
AzureIoTClient 28:add19eb7defa 48 {
AzureIoTClient 28:add19eb7defa 49 init_bytes->bytes = NULL;
AzureIoTClient 28:add19eb7defa 50 init_bytes->length = 0;
Azure.IoT Build 0:6ae2f7bca550 51
AzureIoTClient 28:add19eb7defa 52 result = 0;
AzureIoTClient 28:add19eb7defa 53 }
Azure.IoT Build 0:6ae2f7bca550 54
AzureIoTClient 28:add19eb7defa 55 return result;
Azure.IoT Build 0:6ae2f7bca550 56 }
Azure.IoT Build 0:6ae2f7bca550 57
Azure.IoT Build 0:6ae2f7bca550 58 const char* saslmssbcbs_get_mechanism_name(CONCRETE_SASL_MECHANISM_HANDLE sasl_mechanism)
Azure.IoT Build 0:6ae2f7bca550 59 {
AzureIoTClient 28:add19eb7defa 60 const char* result;
Azure.IoT Build 0:6ae2f7bca550 61
AzureIoTClient 28:add19eb7defa 62 if (sasl_mechanism == NULL)
AzureIoTClient 28:add19eb7defa 63 {
AzureIoTClient 28:add19eb7defa 64 result = NULL;
AzureIoTClient 28:add19eb7defa 65 }
AzureIoTClient 28:add19eb7defa 66 else
AzureIoTClient 28:add19eb7defa 67 {
AzureIoTClient 28:add19eb7defa 68 result = "MSSBCBS";
AzureIoTClient 28:add19eb7defa 69 }
Azure.IoT Build 0:6ae2f7bca550 70
AzureIoTClient 28:add19eb7defa 71 return result;
Azure.IoT Build 0:6ae2f7bca550 72 }
Azure.IoT Build 0:6ae2f7bca550 73
Azure.IoT Build 0:6ae2f7bca550 74 int saslmssbcbs_challenge(CONCRETE_SASL_MECHANISM_HANDLE concrete_sasl_mechanism, const SASL_MECHANISM_BYTES* challenge_bytes, SASL_MECHANISM_BYTES* response_bytes)
Azure.IoT Build 0:6ae2f7bca550 75 {
AzureIoTClient 17:923575db8b2d 76 (void)concrete_sasl_mechanism;
AzureIoTClient 17:923575db8b2d 77 (void)challenge_bytes;
AzureIoTClient 17:923575db8b2d 78 (void)response_bytes;
AzureIoTClient 28:add19eb7defa 79 return 0;
Azure.IoT Build 0:6ae2f7bca550 80 }
Azure.IoT Build 0:6ae2f7bca550 81
Azure.IoT Build 0:6ae2f7bca550 82 const SASL_MECHANISM_INTERFACE_DESCRIPTION* saslmssbcbs_get_interface(void)
Azure.IoT Build 0:6ae2f7bca550 83 {
AzureIoTClient 28:add19eb7defa 84 return &saslmssbcbs_interface;
Azure.IoT Build 0:6ae2f7bca550 85 }