This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 9c1e3572be9346aa44f7ddb8a17c051a91a7045b
Author: Andrew Stitcher <[email protected]>
AuthorDate: Wed Jun 23 15:07:31 2021 -0400

    PROTON-2451: Use generated code in transport/sasl and message code
---
 c/src/core/message.c   | 160 +++++++++++++++++++++++++++++++++++++++---------
 c/src/core/transport.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++-
 c/src/sasl/sasl.c      |  29 ++++++++-
 3 files changed, 316 insertions(+), 34 deletions(-)

diff --git a/c/src/core/message.c b/c/src/core/message.c
index 092b6fc..55bbb18 100644
--- a/c/src/core/message.c
+++ b/c/src/core/message.c
@@ -26,6 +26,10 @@
 #include "protocol.h"
 #include "util.h"
 
+#ifndef GENERATE_CODEC_CODE
+#include "core/frame_generators.h"
+#endif
+
 #include <proton/link.h>
 #include <proton/object.h>
 #include <proton/codec.h>
@@ -765,6 +769,7 @@ int pn_message_decode(pn_message_t *msg, const char *bytes, 
size_t size)
   return 0;
 }
 
+#ifdef GENERATE_CODEC_CODE
 int pn_message_encode(pn_message_t *msg, char *bytes, size_t *size)
 {
   if (!msg || !bytes || !size || !*size) return PN_ARG_ERR;
@@ -786,6 +791,113 @@ int pn_message_encode(pn_message_t *msg, char *bytes, 
size_t *size)
   pn_data_clear(msg->data);
   return 0;
 }
+#else
+int pn_message_encode(pn_message_t *msg, char *bytes, size_t *isize)
+{
+  size_t remaining = *isize;
+  size_t last_size = 0;
+  size_t total = 0;
+
+  /* "DL[?o?B?I?o?I]" */
+  last_size = pn_amqp_encode_bytes_DLEQoQBQIQoQIe(bytes, remaining, HEADER,
+                        msg->durable, msg->durable,
+                         msg->priority!=HEADER_PRIORITY_DEFAULT, msg->priority,
+                         (bool)msg->ttl, msg->ttl,
+                         msg->first_acquirer, msg->first_acquirer,
+                         (bool)msg->delivery_count, msg->delivery_count);
+  if (last_size > remaining) return PN_OVERFLOW;
+
+  remaining -= last_size;
+  bytes += last_size;
+  total += last_size;
+
+
+  if (pn_data_size(msg->instructions)) {
+    pn_data_rewind(msg->instructions);
+    last_size = pn_amqp_encode_bytes_DLC(bytes, remaining, 
DELIVERY_ANNOTATIONS, msg->instructions);
+    if (last_size > remaining) return PN_OVERFLOW;
+
+    remaining -= last_size;
+    bytes += last_size;
+    total += last_size;
+  }
+
+  if (pn_data_size(msg->annotations)) {
+    pn_data_rewind(msg->annotations);
+    last_size = pn_amqp_encode_bytes_DLC(bytes, remaining, 
MESSAGE_ANNOTATIONS, msg->annotations);
+    if (last_size > remaining) return PN_OVERFLOW;
+
+    remaining -= last_size;
+    bytes += last_size;
+    total += last_size;
+  }
+
+  /* "DL[CzSSSCss?t?tS?IS]" */
+  last_size = pn_amqp_encode_bytes_DLECzSSSCssQtQtSQISe(bytes, remaining, 
PROPERTIES,
+                     msg->id,
+                     pn_string_size(msg->user_id), pn_string_get(msg->user_id),
+                     pn_string_get(msg->address),
+                     pn_string_get(msg->subject),
+                     pn_string_get(msg->reply_to),
+                     msg->correlation_id,
+                     pn_string_get(msg->content_type),
+                     pn_string_get(msg->content_encoding),
+                     (bool)msg->expiry_time, msg->expiry_time,
+                     (bool)msg->creation_time, msg->creation_time,
+                     pn_string_get(msg->group_id),
+                     /*
+                      * As a heuristic, null out group_sequence if there is no 
group_id and
+                      * group_sequence is 0. In this case it is extremely 
unlikely we want
+                      * group semantics
+                      */
+                     (bool)pn_string_get(msg->group_id) || 
(bool)msg->group_sequence , msg->group_sequence,
+                     pn_string_get(msg->reply_to_group_id));
+  if (last_size > remaining) return PN_OVERFLOW;
+
+  remaining -= last_size;
+  bytes += last_size;
+  total += last_size;
+
+  if (pn_data_size(msg->properties)) {
+    pn_data_rewind(msg->properties);
+    last_size = pn_amqp_encode_bytes_DLC(bytes, remaining, 
APPLICATION_PROPERTIES, msg->properties);
+    if (last_size > remaining) return PN_OVERFLOW;
+
+    remaining -= last_size;
+    bytes += last_size;
+    total += last_size;
+  }
+
+  if (pn_data_size(msg->body)) {
+    pn_data_rewind(msg->body);
+    pn_data_next(msg->body);
+    pn_type_t body_type = pn_data_type(msg->body);
+    pn_data_rewind(msg->body);
+
+    uint64_t descriptor = AMQP_VALUE;
+    if (msg->inferred) {
+      switch (body_type) {
+        case PN_BINARY:
+          descriptor = DATA;
+          break;
+        case PN_LIST:
+          descriptor = AMQP_SEQUENCE;
+          break;
+        default:
+          break;
+      }
+    }
+    last_size = pn_amqp_encode_bytes_DLC(bytes, remaining, descriptor, 
msg->body);
+    if (last_size > remaining) return PN_OVERFLOW;
+
+    remaining -= last_size;
+    bytes += last_size;
+    total += last_size;
+  }
+  *isize = total;
+  return 0;
+}
+#endif
 
 int pn_message_data(pn_message_t *msg, pn_data_t *data)
 {
@@ -801,27 +913,19 @@ int pn_message_data(pn_message_t *msg, pn_data_t *data)
                            pn_error_text(pn_data_error(data)));
 
   if (pn_data_size(msg->instructions)) {
-    pn_data_put_described(data);
-    pn_data_enter(data);
-    pn_data_put_ulong(data, DELIVERY_ANNOTATIONS);
     pn_data_rewind(msg->instructions);
-    err = pn_data_append(data, msg->instructions);
+    err = pn_data_fill(data, "DLC", DELIVERY_ANNOTATIONS, msg->instructions);
     if (err)
       return pn_error_format(msg->error, err, "data error: %s",
                              pn_error_text(pn_data_error(data)));
-    pn_data_exit(data);
   }
 
   if (pn_data_size(msg->annotations)) {
-    pn_data_put_described(data);
-    pn_data_enter(data);
-    pn_data_put_ulong(data, MESSAGE_ANNOTATIONS);
     pn_data_rewind(msg->annotations);
-    err = pn_data_append(data, msg->annotations);
+    err = pn_data_fill(data, "DLC", MESSAGE_ANNOTATIONS, msg->annotations);
     if (err)
       return pn_error_format(msg->error, err, "data error: %s",
                              pn_error_text(pn_data_error(data)));
-    pn_data_exit(data);
   }
 
   err = pn_data_fill(data, "DL[CzSSSCss?t?tS?IS]", PROPERTIES,
@@ -848,41 +952,37 @@ int pn_message_data(pn_message_t *msg, pn_data_t *data)
                            pn_error_text(pn_data_error(data)));
 
   if (pn_data_size(msg->properties)) {
-    pn_data_put_described(data);
-    pn_data_enter(data);
-    pn_data_put_ulong(data, APPLICATION_PROPERTIES);
     pn_data_rewind(msg->properties);
-    err = pn_data_append(data, msg->properties);
+    err = pn_data_fill(data, "DLC", APPLICATION_PROPERTIES, msg->properties);
     if (err)
       return pn_error_format(msg->error, err, "data error: %s",
                              pn_error_text(pn_data_error(data)));
-    pn_data_exit(data);
   }
 
   if (pn_data_size(msg->body)) {
     pn_data_rewind(msg->body);
     pn_data_next(msg->body);
     pn_type_t body_type = pn_data_type(msg->body);
-    pn_data_rewind(msg->body);
 
-    pn_data_put_described(data);
-    pn_data_enter(data);
+    uint64_t descriptor = AMQP_VALUE;
     if (msg->inferred) {
       switch (body_type) {
-      case PN_BINARY:
-        pn_data_put_ulong(data, DATA);
-        break;
-      case PN_LIST:
-        pn_data_put_ulong(data, AMQP_SEQUENCE);
-        break;
-      default:
-        pn_data_put_ulong(data, AMQP_VALUE);
-        break;
+        case PN_BINARY:
+          descriptor = DATA;
+          break;
+        case PN_LIST:
+          descriptor = AMQP_SEQUENCE;
+          break;
+        default:
+          break;
       }
-    } else {
-      pn_data_put_ulong(data, AMQP_VALUE);
     }
-    pn_data_append(data, msg->body);
+
+    pn_data_rewind(msg->body);
+    err = pn_data_fill(data, "DLC", descriptor, msg->body);
+    if (err)
+      return pn_error_format(msg->error, err, "data error: %s",
+                             pn_error_text(pn_data_error(data)));
   }
   return 0;
 }
diff --git a/c/src/core/transport.c b/c/src/core/transport.c
index de63431..9c5bf99 100644
--- a/c/src/core/transport.c
+++ b/c/src/core/transport.c
@@ -21,6 +21,9 @@
 
 #include "engine-internal.h"
 #include "framing.h"
+#ifndef GENERATE_CODEC_CODE
+#include "core/frame_generators.h"
+#endif
 #include "memory.h"
 #include "platform/platform.h"
 #include "platform/platform_fmt.h"
@@ -901,6 +904,7 @@ static int pni_post_amqp_transfer_frame(pn_transport_t 
*transport, uint16_t ch,
 
   // create performative, assuming 'more' flag need not change
  compute_performatives:;
+#ifdef GENERATE_CODEC_CODE
   pn_bytes_t performative =
     pn_fill_performative(transport, "DL[IIzI?o?on?DLC?o?o?o]", TRANSFER,
                          handle,
@@ -913,6 +917,21 @@ static int pni_post_amqp_transfer_frame(pn_transport_t 
*transport, uint16_t ch,
                          resume, resume,
                          aborted, aborted,
                          batchable, batchable);
+#else
+    /* "DL[IIzI?o?on?DLC?o?o?o]" */
+  pn_bytes_t performative =
+    pn_amqp_encode_DLEIIzIQoQonQDLCQoQoQoe(transport->frame, TRANSFER,
+                         handle,
+                         id,
+                         tag->size, tag->start,
+                         message_format,
+                         settled, settled,
+                         more_flag, more_flag,
+                         (bool)code, code, state,
+                         resume, resume,
+                         aborted, aborted,
+                         batchable, batchable);
+#endif
   if (!performative.start) {
     return PN_ERR;
   }
@@ -960,9 +979,14 @@ static int pni_post_close(pn_transport_t *transport, 
pn_condition_t *cond)
     description = pn_condition_get_description(cond);
     info = pn_condition_info(cond);
   }
-
+#ifdef GENERATE_CODEC_CODE
   pn_bytes_t buf = pn_fill_performative(transport, "DL[?DL[sSC]]", CLOSE,
                        (bool) condition, ERROR, condition, description, info);
+#else
+  /* "DL[?DL[sSC]]" */
+  pn_bytes_t buf = pn_amqp_encode_DLEQDLEsSCee(transport->frame, CLOSE,
+                       (bool) condition, ERROR, condition, description, info);
+#endif
   return pn_framing_send_amqp(transport, 0, buf);
 }
 
@@ -1891,6 +1915,7 @@ static int pni_process_conn_setup(pn_transport_t 
*transport, pn_endpoint_t *endp
       pn_connection_t *connection = (pn_connection_t *) endpoint;
       const char *cid = pn_string_get(connection->container);
       pni_calculate_channel_max(transport);
+#ifdef GENERATE_CODEC_CODE
       pn_bytes_t buf = pn_fill_performative(transport, "DL[SS?I?H?InnMMC]", 
OPEN,
                               cid ? cid : "",
                               pn_string_get(connection->hostname),
@@ -1903,6 +1928,21 @@ static int pni_process_conn_setup(pn_transport_t 
*transport, pn_endpoint_t *endp
                               connection->offered_capabilities,
                               connection->desired_capabilities,
                               connection->properties);
+#else
+      /*  "DL[SS?I?H?InnMMC]" */
+      pn_bytes_t buf = pn_amqp_encode_DLESSQIQHQInnMMCe(transport->frame, OPEN,
+                              cid ? cid : "",
+                              pn_string_get(connection->hostname),
+                              // TODO: This is messy, because we also have to 
allow local_max_frame_ to be 0 to mean unlimited
+                              // otherwise flow control goes wrong
+                              transport->local_max_frame!=0 && 
transport->local_max_frame!=OPEN_MAX_FRAME_SIZE_DEFAULT,
+                              transport->local_max_frame,
+                              
transport->channel_max!=OPEN_CHANNEL_MAX_DEFAULT, transport->channel_max,
+                              (bool)idle_timeout, idle_timeout,
+                              connection->offered_capabilities,
+                              connection->desired_capabilities,
+                              connection->properties);
+#endif
       int err = pn_framing_send_amqp(transport, 0, buf);
       if (err) return err;
       transport->open_sent = true;
@@ -1979,11 +2019,20 @@ static int pni_process_ssn_setup(pn_transport_t 
*transport, pn_endpoint_t *endpo
       }
       state->incoming_window = pni_session_incoming_window(ssn);
       state->outgoing_window = pni_session_outgoing_window(ssn);
+#ifdef GENERATE_CODEC_CODE
       pn_bytes_t buf = pn_fill_performative(transport, "DL[?HIII]", BEGIN,
                     ((int16_t) state->remote_channel >= 0), 
state->remote_channel,
                     state->outgoing_transfer_count,
                     state->incoming_window,
                     state->outgoing_window);
+#else
+      /* "DL[?HIII]" */
+      pn_bytes_t buf = pn_amqp_encode_DLEQHIIIe(transport->frame, BEGIN,
+                    ((int16_t) state->remote_channel >= 0), 
state->remote_channel,
+                    state->outgoing_transfer_count,
+                    state->incoming_window,
+                    state->outgoing_window);
+#endif
       pn_framing_send_amqp(transport, state->local_channel, buf);
     }
   }
@@ -2036,6 +2085,7 @@ static int pni_process_link_setup(pn_transport_t 
*transport, pn_endpoint_t *endp
       pni_map_local_handle(link);
       const pn_distribution_mode_t dist_mode = (pn_distribution_mode_t) 
link->source.distribution_mode;
       if (link->target.type == PN_COORDINATOR) {
+#ifdef GENERATE_CODEC_CODE
         pn_bytes_t buf = pn_fill_performative(transport, 
"DL[SIoBB?DL[SIsIoC?sCnCC]DL[C]nnI]", ATTACH,
                                 pn_string_get(link->name),
                                 state->local_handle,
@@ -2055,9 +2105,32 @@ static int pni_process_link_setup(pn_transport_t 
*transport, pn_endpoint_t *endp
                                 link->source.capabilities,
                                 COORDINATOR, link->target.capabilities,
                                 0);
+#else
+        /* "DL[SIoBB?DL[SIsIoC?sCnCC]DL[C]nnI]" */
+        pn_bytes_t buf = 
pn_amqp_encode_DLESIoBBQDLESIsIoCQsCnCCeDLECennIe(transport->frame, ATTACH,
+                                pn_string_get(link->name),
+                                state->local_handle,
+                                endpoint->type == RECEIVER,
+                                link->snd_settle_mode,
+                                link->rcv_settle_mode,
+                                (bool) link->source.type, SOURCE,
+                                pn_string_get(link->source.address),
+                                link->source.durability,
+                                expiry_symbol(&link->source),
+                                link->source.timeout,
+                                link->source.dynamic,
+                                link->source.properties,
+                                (dist_mode != PN_DIST_MODE_UNSPECIFIED), 
dist_mode2symbol(dist_mode),
+                                link->source.filter,
+                                link->source.outcomes,
+                                link->source.capabilities,
+                                COORDINATOR, link->target.capabilities,
+                                0);
+#endif
         int err = pn_framing_send_amqp(transport, ssn_state->local_channel, 
buf);
         if (err) return err;
       } else {
+#ifdef GENERATE_CODEC_CODE
         pn_bytes_t buf = pn_fill_performative(transport, 
"DL[SIoBB?DL[SIsIoC?sCnMM]?DL[SIsIoCM]nnILnnC]", ATTACH,
                                 pn_string_get(link->name),
                                 state->local_handle,
@@ -2089,6 +2162,40 @@ static int pni_process_link_setup(pn_transport_t 
*transport, pn_endpoint_t *endp
                                 0,
                                 link->max_message_size,
                                 link->properties);
+#else
+        /* "DL[SIoBB?DL[SIsIoC?sCnMM]?DL[SIsIoCM]nnILnnC]" */
+        pn_bytes_t buf = 
pn_amqp_encode_DLESIoBBQDLESIsIoCQsCnMMeQDLESIsIoCMennILnnCe(transport->frame, 
ATTACH,
+                                pn_string_get(link->name),
+                                state->local_handle,
+                                endpoint->type == RECEIVER,
+                                link->snd_settle_mode,
+                                link->rcv_settle_mode,
+
+                                (bool) link->source.type, SOURCE,
+                                pn_string_get(link->source.address),
+                                link->source.durability,
+                                expiry_symbol(&link->source),
+                                link->source.timeout,
+                                link->source.dynamic,
+                                link->source.properties,
+                                (dist_mode != PN_DIST_MODE_UNSPECIFIED), 
dist_mode2symbol(dist_mode),
+                                link->source.filter,
+                                link->source.outcomes,
+                                link->source.capabilities,
+
+                                (bool) link->target.type, TARGET,
+                                pn_string_get(link->target.address),
+                                link->target.durability,
+                                expiry_symbol(&link->target),
+                                link->target.timeout,
+                                link->target.dynamic,
+                                link->target.properties,
+                                link->target.capabilities,
+
+                                0,
+                                link->max_message_size,
+                                link->properties);
+#endif
         int err = pn_framing_send_amqp(transport, ssn_state->local_channel, 
buf);
         if (err) return err;
       }
@@ -2104,6 +2211,7 @@ static int pni_post_flow(pn_transport_t *transport, 
pn_session_t *ssn, pn_link_t
   ssn->state.outgoing_window = pni_session_outgoing_window(ssn);
   bool linkq = (bool) link;
   pn_link_state_t *state = &link->state;
+#ifdef GENERATE_CODEC_CODE
   pn_bytes_t buf = pn_fill_performative(transport, "DL[?IIII?I?I?In?o]", FLOW,
                        (int16_t) ssn->state.remote_channel >= 0, 
ssn->state.incoming_transfer_count,
                        ssn->state.incoming_window,
@@ -2113,6 +2221,18 @@ static int pni_post_flow(pn_transport_t *transport, 
pn_session_t *ssn, pn_link_t
                        linkq, linkq ? state->delivery_count : 0,
                        linkq, linkq ? state->link_credit : 0,
                        linkq, linkq ? link->drain : false);
+#else
+  /* "DL[?IIII?I?I?In?o]" */
+  pn_bytes_t buf = pn_amqp_encode_DLEQIIIIQIQIQInQoe(transport->frame, FLOW,
+                       (int16_t) ssn->state.remote_channel >= 0, 
ssn->state.incoming_transfer_count,
+                       ssn->state.incoming_window,
+                       ssn->state.outgoing_transfer_count,
+                       ssn->state.outgoing_window,
+                       linkq, linkq ? state->local_handle : 0,
+                       linkq, linkq ? state->delivery_count : 0,
+                       linkq, linkq ? state->link_credit : 0,
+                       linkq, linkq ? link->drain : false);
+#endif
   return pn_framing_send_amqp(transport, ssn->state.local_channel, buf);
 }
 
@@ -2139,12 +2259,22 @@ static int pni_flush_disp(pn_transport_t *transport, 
pn_session_t *ssn)
   uint64_t code = ssn->state.disp_code;
   bool settled = ssn->state.disp_settled;
   if (ssn->state.disp) {
+#ifdef GENERATE_CODEC_CODE
     pn_bytes_t buf = pn_fill_performative(transport, "DL[oI?I?o?DL[]]", 
DISPOSITION,
                             ssn->state.disp_type,
                             ssn->state.disp_first,
                             ssn->state.disp_last!=ssn->state.disp_first, 
ssn->state.disp_last,
                             settled, settled,
                             (bool)code, code);
+#else
+    /* "DL[oI?I?o?DL[]]" */
+    pn_bytes_t buf = pn_amqp_encode_DLEoIQIQoQDLEee(transport->frame, 
DISPOSITION,
+                            ssn->state.disp_type,
+                            ssn->state.disp_first,
+                            ssn->state.disp_last!=ssn->state.disp_first, 
ssn->state.disp_last,
+                            settled, settled,
+                            (bool)code, code);
+#endif
     int err = pn_framing_send_amqp(transport, ssn->state.local_channel, buf);
     if (err) return err;
     ssn->state.disp_type = 0;
@@ -2175,10 +2305,18 @@ static int pni_post_disp(pn_transport_t *transport, 
pn_delivery_t *delivery)
   if (!pni_disposition_batchable(&delivery->local)) {
     pn_data_clear(transport->disp_data);
     PN_RETURN_IF_ERROR(pni_disposition_encode(&delivery->local, 
transport->disp_data));
+#ifdef GENERATE_CODEC_CODE
     pn_bytes_t buf = pn_fill_performative(transport, "DL[oIn?o?DLC]", 
DISPOSITION,
       role, state->id,
       delivery->local.settled, delivery->local.settled,
       (bool)code, code, transport->disp_data);
+#else
+    /* "DL[oIn?o?DLC]" */
+    pn_bytes_t buf = pn_amqp_encode_DLEoInQoQDLCe(transport->frame,DISPOSITION,
+      role, state->id,
+      delivery->local.settled, delivery->local.settled,
+      (bool)code, code, transport->disp_data);
+#endif
     return pn_framing_send_amqp(transport, ssn->state.local_channel, buf);
   }
 
@@ -2412,11 +2550,18 @@ static int pni_process_link_teardown(pn_transport_t 
*transport, pn_endpoint_t *e
         description = pn_condition_get_description(&endpoint->condition);
         info = pn_condition_info(&endpoint->condition);
       }
-
+#ifdef GENERATE_CODEC_CODE
       pn_bytes_t buf = pn_fill_performative(transport, "DL[I?o?DL[sSC]]", 
DETACH,
                                             state->local_handle,
                                             !link->detached, !link->detached,
                                             (bool)name, ERROR, name, 
description, info);
+#else
+      /* "DL[I?o?DL[sSC]]" */
+      pn_bytes_t buf = pn_amqp_encode_DLEIQoQDLEsSCee(transport->frame, DETACH,
+                                            state->local_handle,
+                                            !link->detached, !link->detached,
+                                            (bool)name, ERROR, name, 
description, info);
+#endif
       int err = pn_framing_send_amqp(transport, ssn_state->local_channel, buf);
       if (err) return err;
       pni_unmap_local_handle(link);
@@ -2488,9 +2633,14 @@ static int pni_process_ssn_teardown(pn_transport_t 
*transport, pn_endpoint_t *en
         description = pn_condition_get_description(&endpoint->condition);
         info = pn_condition_info(&endpoint->condition);
       }
-
+#ifdef GENERATE_CODEC_CODE
       pn_bytes_t buf = pn_fill_performative(transport, "DL[?DL[sSC]]", END,
                               (bool) name, ERROR, name, description, info);
+#else
+      /* "DL[?DL[sSC]]" */
+      pn_bytes_t buf = pn_amqp_encode_DLEQDLEsSCee(transport->frame, END,
+                              (bool) name, ERROR, name, description, info);
+#endif
       int err = pn_framing_send_amqp(transport, state->local_channel, buf);
       if (err) return err;
       pni_unmap_local_channel(session);
@@ -2565,7 +2715,12 @@ static void pn_error_amqp(pn_transport_t* transport, 
unsigned int layer)
 {
   if (!transport->close_sent) {
     if (!transport->open_sent) {
+#ifdef GENERATE_CODEC_CODE
       pn_bytes_t buf = pn_fill_performative(transport, "DL[S]", OPEN, "");
+#else
+      /* "DL[S]" */
+      pn_bytes_t buf = pn_amqp_encode_DLESe(transport->frame, OPEN, "");
+#endif
       pn_framing_send_amqp(transport, 0, buf);
     }
 
diff --git a/c/src/sasl/sasl.c b/c/src/sasl/sasl.c
index 80ffad8..1e853b8 100644
--- a/c/src/sasl/sasl.c
+++ b/c/src/sasl/sasl.c
@@ -23,6 +23,9 @@
 
 #include "core/autodetect.h"
 #include "core/framing.h"
+#ifndef GENERATE_CODEC_CODE
+#include "core/frame_generators.h"
+#endif
 #include "core/engine-internal.h"
 #include "core/util.h"
 #include "platform/platform_fmt.h"
@@ -485,7 +488,12 @@ static void pni_post_sasl_frame(pn_transport_t *transport)
   while (sasl->desired_state > sasl->last_state) {
     switch (desired_state) {
     case SASL_POSTED_INIT: {
+#ifdef GENERATE_CODEC_CODE
       pn_bytes_t buf = pn_fill_performative(transport, "DL[szS]", SASL_INIT, 
sasl->selected_mechanism, out.size, out.start, sasl->local_fqdn);
+#else
+      /* GENERATE_CODEC_CODE: "DL[szS]" */
+      pn_bytes_t buf = pn_amqp_encode_DLEszSe(transport->frame, SASL_INIT, 
sasl->selected_mechanism, out.size, out.start, sasl->local_fqdn);
+#endif
       pn_framing_send_sasl(transport, buf);
       pni_emit(transport);
       break;
@@ -499,8 +507,12 @@ static void pni_post_sasl_frame(pn_transport_t *transport)
       if (mechlist) {
         pni_split_mechs(mechlist, sasl->included_mechanisms, mechs, &count);
       }
-
+#ifdef GENERATE_CODEC_CODE
       pn_bytes_t buf = pn_fill_performative(transport, "DL[@T[*s]]", 
SASL_MECHANISMS, PN_SYMBOL, count, mechs);
+#else
+      /* GENERATE_CODEC_CODE: "DL[@T[*s]]" */
+      pn_bytes_t buf = pn_amqp_encode_DLEATEjsee(transport->frame, 
SASL_MECHANISMS, PN_SYMBOL, count, mechs);
+#endif
       free(mechlist);
       pn_framing_send_sasl(transport, buf);
       pni_emit(transport);
@@ -508,7 +520,12 @@ static void pni_post_sasl_frame(pn_transport_t *transport)
     }
     case SASL_POSTED_RESPONSE:
       if (sasl->last_state != SASL_POSTED_RESPONSE) {
+#ifdef GENERATE_CODEC_CODE
         pn_bytes_t buf = pn_fill_performative(transport, "DL[Z]", 
SASL_RESPONSE, out.size, out.start);
+#else
+        /* "DL[Z]" */
+        pn_bytes_t buf = pn_amqp_encode_DLEZe(transport->frame, SASL_RESPONSE, 
out.size, out.start);
+#endif
         pn_framing_send_sasl(transport, buf);
         pni_emit(transport);
       }
@@ -518,7 +535,12 @@ static void pni_post_sasl_frame(pn_transport_t *transport)
         desired_state = SASL_POSTED_MECHANISMS;
         continue;
       } else if (sasl->last_state != SASL_POSTED_CHALLENGE) {
+#ifdef GENERATE_CODEC_CODE
         pn_bytes_t buf = pn_fill_performative(transport, "DL[Z]", 
SASL_CHALLENGE, out.size, out.start);
+#else
+        /* "DL[Z]" */
+        pn_bytes_t buf = pn_amqp_encode_DLEZe(transport->frame, 
SASL_CHALLENGE, out.size, out.start);
+#endif
         pn_framing_send_sasl(transport, buf);
         pni_emit(transport);
       }
@@ -528,7 +550,12 @@ static void pni_post_sasl_frame(pn_transport_t *transport)
         desired_state = SASL_POSTED_MECHANISMS;
         continue;
       }
+#ifdef GENERATE_CODEC_CODE
       pn_bytes_t buf = pn_fill_performative(transport, "DL[Bz]", SASL_OUTCOME, 
sasl->outcome, out.size, out.start);
+#else
+      /* "DL[Bz]" */
+      pn_bytes_t buf = pn_amqp_encode_DLEBze(transport->frame, SASL_OUTCOME, 
sasl->outcome, out.size, out.start);
+#endif
       pn_framing_send_sasl(transport, buf);
       pni_emit(transport);
       if (sasl->outcome!=PN_SASL_OK) {

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to