A small memory footprint AMQP implimentation

Dependents:   iothub_client_sample_amqp remote_monitoring simplesample_amqp

Revision:
16:22a72cf8e416
Parent:
15:5db103709f20
Child:
17:923575db8b2d
diff -r 5db103709f20 -r 22a72cf8e416 connection.c
--- a/connection.c	Sun Jan 08 11:12:13 2017 -0800
+++ b/connection.c	Fri Jan 13 18:40:42 2017 -0800
@@ -22,7 +22,7 @@
 /* Codes_SRS_CONNECTION_01_088: [Any data appearing beyond the protocol header MUST match the version indicated by the protocol header.] */
 /* Codes_SRS_CONNECTION_01_015: [Implementations SHOULD NOT expect to be able to reuse open TCP sockets after close performatives have been exchanged.] */
 
-/* Codes_SRS_CONNECTION_01_087: [The protocol header consists of the upper case ASCII letters “AMQP” followed by a protocol id of zero, followed by three unsigned bytes representing the major, minor, and revision of the protocol version (currently 1 (MAJOR), 0 (MINOR), 0 (REVISION)). In total this is an 8-octet sequence] */
+/* Codes_SRS_CONNECTION_01_087: [The protocol header consists of the upper case ASCII letters "AMQP" followed by a protocol id of zero, followed by three unsigned bytes representing the major, minor, and revision of the protocol version (currently 1 (MAJOR), 0 (MINOR), 0 (REVISION)). In total this is an 8-octet sequence] */
 static const unsigned char amqp_header[] = { 'A', 'M', 'Q', 'P', 0, 1, 0, 0 };
 
 typedef enum RECEIVE_FRAME_STATE_TAG
@@ -94,7 +94,7 @@
         connection_instance->on_connection_state_changed(connection_instance->on_connection_state_changed_callback_context, connection_state, previous_state);
     }
 
-    /* Codes_SRS_CONNECTION_01_260: [Each endpoint’s on_connection_state_changed shall be called.] */
+    /* Codes_SRS_CONNECTION_01_260: [Each endpoint's on_connection_state_changed shall be called.] */
     for (i = 0; i < connection_instance->endpoint_count; i++)
     {
         /* Codes_SRS_CONNECTION_01_259: [The callback_context passed in connection_create_endpoint.] */
@@ -106,7 +106,7 @@
 {
     int result;
 
-    /* Codes_SRS_CONNECTION_01_093: [_ When the client opens a new socket connection to a server, it MUST send a protocol header with the client’s preferred protocol version.] */
+    /* Codes_SRS_CONNECTION_01_093: [_ When the client opens a new socket connection to a server, it MUST send a protocol header with the client's preferred protocol version.] */
     /* Codes_SRS_CONNECTION_01_104: [Sending the protocol header shall be done by using xio_send.] */
     if (xio_send(connection_instance->io, amqp_header, sizeof(amqp_header), NULL, NULL) != 0)
     {
@@ -123,7 +123,7 @@
     {
         if (connection_instance->is_trace_on == 1)
         {
-            LOG(LOG_TRACE, LOG_LINE, "-> Header (AMQP 0.1.0.0)");
+            LOG(AZ_LOG_TRACE, LOG_LINE, "-> Header (AMQP 0.1.0.0)");
         }
 
         /* 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.] */
@@ -190,10 +190,10 @@
     AMQP_VALUE descriptor = amqpvalue_get_inplace_descriptor(performative);
     if (descriptor != NULL)
     {
-        LOG(LOG_TRACE, 0, "<- ");
-        LOG(LOG_TRACE, 0, (char*)get_frame_type_as_string(descriptor));
+        LOG(AZ_LOG_TRACE, 0, "<- ");
+        LOG(AZ_LOG_TRACE, 0, (char*)get_frame_type_as_string(descriptor));
         char* performative_as_string = NULL;
-        LOG(LOG_TRACE, LOG_LINE, (performative_as_string = amqpvalue_to_string(performative)));
+        LOG(AZ_LOG_TRACE, LOG_LINE, (performative_as_string = amqpvalue_to_string(performative)));
         if (performative_as_string != NULL)
         {
             amqpalloc_free(performative_as_string);
@@ -210,10 +210,10 @@
     AMQP_VALUE descriptor = amqpvalue_get_inplace_descriptor(performative);
     if (descriptor != NULL)
     {
-        LOG(LOG_TRACE, 0, "-> ");
-        LOG(LOG_TRACE, 0, (char*)get_frame_type_as_string(descriptor));
+        LOG(AZ_LOG_TRACE, 0, "-> ");
+        LOG(AZ_LOG_TRACE, 0, (char*)get_frame_type_as_string(descriptor));
         char* performative_as_string = NULL;
-        LOG(LOG_TRACE, LOG_LINE, (performative_as_string = amqpvalue_to_string(performative)));
+        LOG(AZ_LOG_TRACE, LOG_LINE, (performative_as_string = amqpvalue_to_string(performative)));
         if (performative_as_string != NULL)
         {
             amqpalloc_free(performative_as_string);
@@ -421,7 +421,7 @@
         {
             /* Codes_SRS_CONNECTION_01_213: [When passing the bytes to frame_codec fails, a CLOSE frame shall be sent and the state shall be set to DISCARDING.] */
             /* 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.] */
-            /* Codes_SRS_CONNECTION_01_010: [After writing this frame the peer SHOULD continue to read from the connection until it receives the partner’s close frame ] */
+            /* Codes_SRS_CONNECTION_01_010: [After writing this frame the peer SHOULD continue to read from the connection until it receives the partner's close frame ] */
             connection_set_state(connection_instance, CONNECTION_STATE_DISCARDING);
         }
 
@@ -508,7 +508,7 @@
             {
                 if (connection_instance->is_trace_on == 1)
                 {
-                    LOG(LOG_TRACE, LOG_LINE, "<- Header (AMQP 0.1.0.0)");
+                    LOG(AZ_LOG_TRACE, LOG_LINE, "<- Header (AMQP 0.1.0.0)");
                 }
 
                 connection_set_state(connection_instance, CONNECTION_STATE_HDR_EXCH);
@@ -638,7 +638,7 @@
     CONNECTION_INSTANCE* connection_instance = (CONNECTION_INSTANCE*)context;
     if (connection_instance->is_trace_on == 1)
     {
-        LOG(LOG_TRACE, LOG_LINE, "<- Empty frame");
+        LOG(AZ_LOG_TRACE, LOG_LINE, "<- Empty frame");
     }
     if (tickcounter_get_current_ms(connection_instance->tick_counter, &connection_instance->last_frame_received_time) != 0)
     {
@@ -794,7 +794,7 @@
                         switch (performative_ulong)
                         {
                         default:
-                            LOG(LOG_ERROR, LOG_LINE, "Bad performative: %02x", performative);
+                            LOG(AZ_LOG_ERROR, LOG_LINE, "Bad performative: %02x", performative);
                             break;
 
                         case AMQP_BEGIN:
@@ -1406,7 +1406,7 @@
                     {
                         if (connection->is_trace_on == 1)
                         {
-                            LOG(LOG_TRACE, LOG_LINE, "-> Empty frame");
+                            LOG(AZ_LOG_TRACE, LOG_LINE, "-> Empty frame");
                         }
 
                         connection->last_frame_sent_time = current_ms;