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 61fff0bca0017ed0175d148a61038a5e5d3d26e3 Author: Andrew Stitcher <[email protected]> AuthorDate: Tue Nov 2 13:41:36 2021 +0000 PROTON-2451: Remove conditional compilation for AMQP frame handling Remove all the code with the old frame handling and leave only the new frame handling. --- c/CMakeLists.txt | 6 - c/src/core/engine-internal.h | 4 - c/src/core/framing.c | 14 -- c/src/core/message.c | 167 ----------------- c/src/core/post_frame.c | 79 --------- c/src/core/transport.c | 414 +------------------------------------------ c/src/sasl/sasl.c | 98 +--------- 7 files changed, 4 insertions(+), 778 deletions(-) diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt index 4ffe079..a6cdda3 100644 --- a/c/CMakeLists.txt +++ b/c/CMakeLists.txt @@ -114,11 +114,6 @@ add_custom_target( ${CMAKE_CURRENT_BINARY_DIR}/src/core/frame_consumers.h ) -option (ENABLE_GENERATED_CODEC "Use automatically generated codec code" ON) -if (NOT ENABLE_GENERATED_CODEC) - add_compile_definitions(GENERATE_CODEC_CODE) -endif () - file (GLOB_RECURSE source_files "src/*.h" "src/*.c" "src/*.cpp") foreach (sfile ${source_files}) @@ -266,7 +261,6 @@ set (qpid-proton-core src/core/types.c src/core/framing.c - src/core/post_frame.c src/core/value_dump.c src/core/codec.c diff --git a/c/src/core/engine-internal.h b/c/src/core/engine-internal.h index 3bfa64a..500be12 100644 --- a/c/src/core/engine-internal.h +++ b/c/src/core/engine-internal.h @@ -165,10 +165,6 @@ struct pn_transport_t { /* scratch area */ -#ifdef GENERATE_CODEC_CODE - pn_data_t *args; - pn_data_t *output_args; -#endif pn_buffer_t *frame; // frame under construction // Temporary - ?? diff --git a/c/src/core/framing.c b/c/src/core/framing.c index 41b176b..79ead83 100644 --- a/c/src/core/framing.c +++ b/c/src/core/framing.c @@ -158,17 +158,3 @@ int pn_framing_send_sasl(pn_transport_t *transport, pn_bytes_t performative) transport->output_frames_ct += 1; return 0; } - -#ifdef GENERATE_CODEC_CODE -ssize_t pn_framing_recv_amqp(pn_data_t *args, pn_logger_t *logger, const pn_bytes_t bytes) -{ - pn_data_clear(args); - ssize_t dsize = pn_data_decode(args, bytes.start, bytes.size); - if (dsize < 0) { - PN_LOG_MSG_DATA(logger, PN_SUBSYSTEM_AMQP, PN_LEVEL_ERROR, bytes, - "Error decoding frame: %s %s\n", pn_code(dsize), pn_error_text(pn_data_error(args))); - } - - return dsize; -} -#endif diff --git a/c/src/core/message.c b/c/src/core/message.c index 6773b7f..9f0d7e5 100644 --- a/c/src/core/message.c +++ b/c/src/core/message.c @@ -27,10 +27,8 @@ #include "protocol.h" #include "util.h" -#ifndef GENERATE_CODEC_CODE #include "core/frame_generators.h" #include "core/frame_consumers.h" -#endif #include <proton/link.h> #include <proton/object.h> @@ -63,9 +61,6 @@ struct pn_message_t { pn_data_t *annotations; pn_data_t *properties; pn_data_t *body; -#ifdef GENERATE_CODEC_CODE - pn_data_t *data; -#endif pn_error_t *error; pn_sequence_t group_sequence; @@ -153,9 +148,6 @@ void pn_message_finalize(void *obj) pn_free(msg->reply_to_group_id); pni_msgid_clear(&msg->id); pni_msgid_clear(&msg->correlation_id); -#ifdef GENERATE_CODEC_CODE - pn_data_free(msg->data); -#endif if (msg->id_deprecated) pn_data_free(msg->id_deprecated); if (msg->correlation_id_deprecated) pn_data_free(msg->correlation_id_deprecated); pn_data_free(msg->instructions); @@ -405,9 +397,6 @@ static pn_message_t *pni_message_new(size_t size) msg->reply_to_group_id = pn_string(NULL); msg->inferred = false; -#ifdef GENERATE_CODEC_CODE - msg->data = pn_data(16); -#endif msg->id_deprecated = NULL; msg->correlation_id_deprecated = NULL; msg->instructions = pn_data(16); @@ -463,9 +452,6 @@ void pn_message_clear(pn_message_t *msg) msg->group_sequence = 0; pn_string_clear(msg->reply_to_group_id); msg->inferred = false; -#ifdef GENERATE_CODEC_CODE - pn_data_clear(msg->data); -#endif pn_data_clear(msg->id_deprecated); pn_data_clear(msg->correlation_id_deprecated); pn_data_clear(msg->instructions); @@ -769,133 +755,6 @@ int pn_message_set_reply_to_group_id(pn_message_t *msg, const char *reply_to_gro return pn_string_set(msg->reply_to_group_id, reply_to_group_id); } -#ifdef GENERATE_CODEC_CODE -int pn_message_decode(pn_message_t *msg, const char *bytes, size_t size) -{ - assert(msg && bytes && size); - - pn_message_clear(msg); - - while (size) { - pn_data_clear(msg->data); - ssize_t used = pn_data_decode(msg->data, bytes, size); - if (used < 0) - return pn_error_format(msg->error, used, "data error: %s", - pn_error_text(pn_data_error(msg->data))); - size -= used; - bytes += used; - bool scanned; - uint64_t desc; - int err = pn_data_scan(msg->data, "D?L.", &scanned, &desc); - if (err) return pn_error_format(msg->error, err, "data error: %s", - pn_error_text(pn_data_error(msg->data))); - if (!scanned) { - desc = 0; - } - - pn_data_rewind(msg->data); - pn_data_next(msg->data); - pn_data_enter(msg->data); - pn_data_next(msg->data); - - switch (desc) { - case HEADER: { - bool priority_q; - uint8_t priority; - err = pn_data_scan(msg->data, "D.[o?BIoI]", - &msg->durable, - &priority_q, &priority, - &msg->ttl, - &msg->first_acquirer, - &msg->delivery_count); - if (err) return pn_error_format(msg->error, err, "data error: %s", - pn_error_text(pn_data_error(msg->data))); - msg->priority = priority_q ? priority : HEADER_PRIORITY_DEFAULT; - break; - } - case PROPERTIES: - { - pn_bytes_t user_id, address, subject, reply_to, ctype, cencoding, - group_id, reply_to_group_id; - pn_atom_t id; - pn_atom_t correlation_id; - err = pn_data_scan(msg->data, "D.[azSSSassttSIS]", &id, - &user_id, &address, &subject, &reply_to, - &correlation_id, &ctype, &cencoding, - &msg->expiry_time, &msg->creation_time, &group_id, - &msg->group_sequence, &reply_to_group_id); - if (err) return pn_error_format(msg->error, err, "data error: %s", - pn_error_text(pn_data_error(msg->data))); - pni_msgid_fix_interop(&id); - pn_message_set_id(msg, id); - err = pn_string_set_bytes(msg->user_id, user_id); - if (err) return pn_error_format(msg->error, err, "error setting user_id"); - err = pn_string_setn(msg->address, address.start, address.size); - if (err) return pn_error_format(msg->error, err, "error setting address"); - err = pn_string_setn(msg->subject, subject.start, subject.size); - if (err) return pn_error_format(msg->error, err, "error setting subject"); - err = pn_string_setn(msg->reply_to, reply_to.start, reply_to.size); - if (err) return pn_error_format(msg->error, err, "error setting reply_to"); - pni_msgid_fix_interop(&correlation_id); - pn_message_set_correlation_id(msg, correlation_id); - err = pn_string_setn(msg->content_type, ctype.start, ctype.size); - if (err) return pn_error_format(msg->error, err, "error setting content_type"); - err = pn_string_setn(msg->content_encoding, cencoding.start, - cencoding.size); - if (err) return pn_error_format(msg->error, err, "error setting content_encoding"); - err = pn_string_setn(msg->group_id, group_id.start, group_id.size); - if (err) return pn_error_format(msg->error, err, "error setting group_id"); - err = pn_string_setn(msg->reply_to_group_id, reply_to_group_id.start, - reply_to_group_id.size); - if (err) return pn_error_format(msg->error, err, "error setting reply_to_group_id"); - } - break; - case DELIVERY_ANNOTATIONS: - pn_data_clear(msg->instructions); - err = pn_data_scan(msg->data, "D.C", msg->instructions); - pn_data_rewind(msg->instructions); - if (err) return err; - break; - case MESSAGE_ANNOTATIONS: - pn_data_clear(msg->annotations); - err = pn_data_scan(msg->data, "D.C", msg->annotations); - pn_data_rewind(msg->annotations); - if (err) return err; - break; - case APPLICATION_PROPERTIES: - pn_data_clear(msg->properties); - err = pn_data_scan(msg->data, "D.C", msg->properties); - pn_data_rewind(msg->properties); - if (err) return err; - break; - case DATA: - case AMQP_SEQUENCE: - msg->inferred = true; - pn_data_clear(msg->body); - err = pn_data_scan(msg->data, "D.C", msg->body); - pn_data_rewind(msg->body); - if (err) return err; - break; - case AMQP_VALUE: - msg->inferred = false; - pn_data_clear(msg->body); - err = pn_data_scan(msg->data, "D.C", msg->body); - pn_data_rewind(msg->body); - if (err) return err; - break; - case FOOTER: - break; - default: - err = pn_data_copy(msg->body, msg->data); - if (err) return err; - break; - } - } - - pn_data_clear(msg->data); - return 0; -} -#else int pn_message_decode(pn_message_t *msg, const char *bytes, size_t size) { assert(msg && bytes && size); @@ -1002,31 +861,6 @@ int pn_message_decode(pn_message_t *msg, const char *bytes, size_t size) } return 0; } -#endif - -#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; - pn_data_clear(msg->data); - pn_message_data(msg, msg->data); - size_t remaining = *size; - ssize_t encoded = pn_data_encode(msg->data, bytes, remaining); - if (encoded < 0) { - if (encoded == PN_OVERFLOW) { - return encoded; - } else { - return pn_error_format(msg->error, encoded, "data error: %s", - pn_error_text(pn_data_error(msg->data))); - } - } - bytes += encoded; - remaining -= encoded; - *size -= remaining; - 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; @@ -1134,7 +968,6 @@ int pn_message_encode(pn_message_t *msg, char *bytes, size_t *isize) *isize = total; return 0; } -#endif int pn_message_data(pn_message_t *msg, pn_data_t *data) { diff --git a/c/src/core/post_frame.c b/c/src/core/post_frame.c deleted file mode 100644 index f910427..0000000 --- a/c/src/core/post_frame.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -#include "proton/codec.h" -#include "proton/logger.h" -#include "proton/object.h" -#include "proton/type_compat.h" - -#include "buffer.h" -#include "engine-internal.h" -#include "framing.h" -#include "dispatch_actions.h" - -#ifdef GENERATE_CODEC_CODE -static inline struct out {int err; pn_bytes_t bytes;} pn_vfill_performative(pn_buffer_t *frame_buf, pn_data_t *output_args, const char *fmt, va_list ap) -{ - pn_data_clear(output_args); - int err = pn_data_vfill(output_args, fmt, ap); - if (err) { - return (struct out){err, pn_bytes_null}; - } - -encode_performatives: - pn_buffer_clear( frame_buf ); - pn_rwbytes_t buf = pn_buffer_memory( frame_buf ); - buf.size = pn_buffer_available( frame_buf ); - - ssize_t wr = pn_data_encode( output_args, buf.start, buf.size ); - if (wr < 0) { - if (wr == PN_OVERFLOW) { - pn_buffer_ensure( frame_buf, pn_buffer_available( frame_buf ) * 2 ); - goto encode_performatives; - } - return (struct out){wr, pn_bytes_null}; - } - return (struct out){0, {.size = wr, .start = buf.start}}; -} - -static inline void pn_log_fill_error(pn_logger_t *logger, pn_data_t *data, int error, const char *fmt) { - if (pn_error_code(pn_data_error(data))) { - pn_logger_logf(logger, PN_SUBSYSTEM_AMQP, PN_LEVEL_ERROR, - "error posting frame: %s, %s: %s", fmt, pn_code(error), - pn_error_text(pn_data_error(data))); - } else { - pn_logger_logf(logger, PN_SUBSYSTEM_AMQP, PN_LEVEL_ERROR, - "error posting frame: %s", pn_code(error)); - } -} - -pn_bytes_t pn_fill_performative(pn_transport_t *transport, const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - struct out out = pn_vfill_performative(transport->frame, transport->output_args, fmt, ap); - va_end(ap); - if (out.err){ - pn_log_fill_error(&transport->logger, transport->output_args, out.err, fmt); - } - return out.bytes; -} -#endif diff --git a/c/src/core/transport.c b/c/src/core/transport.c index f197ad9..b885e38 100644 --- a/c/src/core/transport.c +++ b/c/src/core/transport.c @@ -21,10 +21,8 @@ #include "engine-internal.h" #include "framing.h" -#ifndef GENERATE_CODEC_CODE #include "core/frame_generators.h" #include "core/frame_consumers.h" -#endif #include "memory.h" #include "platform/platform.h" #include "platform/platform_fmt.h" @@ -410,10 +408,6 @@ static void pn_transport_initialize(void *object) transport->tracer = NULL; transport->sasl = NULL; transport->ssl = NULL; -#ifdef GENERATE_CODEC_CODE - transport->args = pn_data(16); - transport->output_args = pn_data(16); -#endif transport->frame = pn_buffer(PN_TRANSPORT_INITIAL_FRAME_SIZE); transport->input_frames_ct = 0; transport->output_frames_ct = 0; @@ -667,10 +661,6 @@ static void pn_transport_finalize(void *object) pn_free(transport->remote_channels); pni_mem_subdeallocate(pn_class(transport), transport, transport->input_buf); pni_mem_subdeallocate(pn_class(transport), transport, transport->output_buf); -#ifdef GENERATE_CODEC_CODE - pn_data_free(transport->args); - pn_data_free(transport->output_args); -#endif pn_buffer_free(transport->frame); pn_free(transport->context); pn_buffer_free(transport->output_buffer); @@ -908,21 +898,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, - id, - tag->size, tag->start, - message_format, - settled, settled, - more_flag, more_flag, - (bool)code, code, state, - resume, resume, - aborted, aborted, - batchable, batchable); -#else - /* "DL[IIzI?o?on?DLC?o?o?o]" */ + /* "DL[IIzI?o?on?DLC?o?o?o]" */ pn_bytes_t performative = pn_amqp_encode_DLEIIzIQoQonQDLCQoQoQoe(transport->frame, TRANSFER, handle, @@ -935,7 +911,6 @@ static int pni_post_amqp_transfer_frame(pn_transport_t *transport, uint16_t ch, resume, resume, aborted, aborted, batchable, batchable); -#endif if (!performative.start) { return PN_ERR; } @@ -983,14 +958,9 @@ 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); } @@ -1083,21 +1053,6 @@ int pn_do_open(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, pn_data_clear(transport->remote_desired_capabilities); pn_data_clear(transport->remote_properties); -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - int err = pn_data_scan(args, "D.[?S?S?I?HI..CCC]", - &container_q, &remote_container, - &hostname_q, &remote_hostname, - &remote_max_frame_q, &remote_max_frame, - &remote_channel_max_q, &remote_channel_max, - &transport->remote_idle_timeout, - transport->remote_offered_capabilities, - transport->remote_desired_capabilities, - transport->remote_properties); - if (err) return err; -#else pn_amqp_decode_DqEQSQSQIQHIqqCCCe(payload, &container_q, &remote_container, &hostname_q, &remote_hostname, @@ -1107,7 +1062,6 @@ int pn_do_open(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, transport->remote_offered_capabilities, transport->remote_desired_capabilities, transport->remote_properties); -#endif /* * The default value is already stored in the variable. * But the scanner zeroes out values if it does not @@ -1148,15 +1102,7 @@ int pn_do_begin(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, uint16_t remote_channel; pn_sequence_t next; -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - int err = pn_data_scan(args, "D.[?HI]", &reply, &remote_channel, &next); - if (err) return err; -#else pn_amqp_decode_DqEQHIe(payload, &reply, &remote_channel, &next); -#endif // AMQP 1.0 section 2.7.1 - if the peer doesn't honor our channel_max -- // express our displeasure by closing the connection with a framing error. @@ -1274,24 +1220,6 @@ int pn_do_attach(pn_transport_t *transport, uint8_t frame_type, uint16_t channel uint8_t snd_settle_mode, rcv_settle_mode; uint64_t max_msgsz; bool has_props; - -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - pn_data_t *rem_props = pn_data(0); - int err = pn_data_scan(args, "D.[SIo?B?BD.[SIsIo.s]D.[SIsIo]..IL..?C]", &name, &handle, - &is_sender, - &snd_settle, &snd_settle_mode, - &rcv_settle, &rcv_settle_mode, - &source, &src_dr, &src_exp, &src_timeout, &src_dynamic, &dist_mode, - &target, &tgt_dr, &tgt_exp, &tgt_timeout, &tgt_dynamic, - &idc, &max_msgsz, &has_props, rem_props); - if (err) { - pn_free(rem_props); - return err; - } -#else pn_data_t *rem_props = pn_data(0); pn_amqp_decode_DqESIoQBQBDqESIsIoqseDqESIsIoeqqILqqQCe(payload, &name, &handle, @@ -1301,7 +1229,6 @@ int pn_do_attach(pn_transport_t *transport, uint8_t frame_type, uint16_t channel &source, &src_dr, &src_exp, &src_timeout, &src_dynamic, &dist_mode, &target, &tgt_dr, &tgt_exp, &tgt_timeout, &tgt_dynamic, &idc, &max_msgsz, &has_props, rem_props); -#endif char strbuf[128]; // avoid malloc for most link names char *strheap = (name.size >= sizeof(strbuf)) ? (char *) malloc(name.size + 1) : NULL; char *strname = strheap ? strheap : strbuf; @@ -1364,12 +1291,7 @@ int pn_do_attach(pn_transport_t *transport, uint8_t frame_type, uint16_t channel pn_terminus_set_dynamic(rtgt, tgt_dynamic); } else { uint64_t code = 0; -#ifdef GENERATE_CODEC_CODE - err = pn_data_scan(args, "D.[.....D..DL....]", &code); - if (err) return err; -#else pn_amqp_decode_DqEqqqqqDqqDLqqqqe(payload, &code); -#endif if (code == COORDINATOR) { pn_terminus_set_type(rtgt, PN_COORDINATOR); } else if (code == TARGET) { @@ -1389,21 +1311,11 @@ int pn_do_attach(pn_transport_t *transport, uint8_t frame_type, uint16_t channel pn_data_clear(link->remote_source.outcomes); pn_data_clear(link->remote_source.capabilities); -#ifdef GENERATE_CODEC_CODE - err = pn_data_scan(args, "D.[.....D.[.....C.C.CC]", - link->remote_source.properties, - link->remote_source.filter, - link->remote_source.outcomes, - link->remote_source.capabilities); - - if (err) return err; -#else pn_amqp_decode_DqEqqqqqDqEqqqqqCqCqCCee(payload, link->remote_source.properties, link->remote_source.filter, link->remote_source.outcomes, link->remote_source.capabilities); -#endif pn_data_rewind(link->remote_source.properties); pn_data_rewind(link->remote_source.filter); @@ -1415,25 +1327,12 @@ int pn_do_attach(pn_transport_t *transport, uint8_t frame_type, uint16_t channel if (pn_terminus_get_type(&link->remote_target) == PN_COORDINATOR) { // coordinator target only has a capabilities field -#ifdef GENERATE_CODEC_CODE - err = pn_data_scan(args, "D.[.....D..D.[C]...]", - link->remote_target.capabilities); - if (err) return err; -#else pn_amqp_decode_DqEqqqqqDqqDqECeqqqe(payload, link->remote_target.capabilities); -#endif } else { -#ifdef GENERATE_CODEC_CODE - err = pn_data_scan(args, "D.[.....D..D.[.....CC]", - link->remote_target.properties, - link->remote_target.capabilities); - if (err) return err; -#else pn_amqp_decode_DqEqqqqqDqqDqEqqqqqCCee(payload, link->remote_target.properties, link->remote_target.capabilities); -#endif } pn_data_rewind(link->remote_target.properties); @@ -1476,22 +1375,11 @@ int pn_do_transfer(pn_transport_t *transport, uint8_t frame_type, uint16_t chann bool resume, aborted, batchable; uint64_t type; -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - pn_data_clear(transport->disp_data); - int err = pn_data_scan(args, "D.[I?Iz.?oo.D?LCooo]", &handle, &id_present, &id, &tag, - &settled_set, &settled, &more, &has_type, &type, transport->disp_data, - &resume, &aborted, &batchable); - if (err) return err; -#else pn_bytes_t disp_data; size_t dsize = pn_amqp_decode_DqEIQIzqQooqDQLRoooe(payload, &handle, &id_present, &id, &tag, &settled_set, &settled, &more, &has_type, &type, &disp_data, &resume, &aborted, &batchable); -#endif payload.size -= dsize; payload.start += dsize; @@ -1553,18 +1441,11 @@ int pn_do_transfer(pn_transport_t *transport, uint8_t frame_type, uint16_t chann "sequencing error, expected delivery-id %u, got %u", state->id, id); } -#ifdef GENERATE_CODEC_CODE - if (has_type) { - delivery->remote.type = type; - pn_data_copy(delivery->remote.data, transport->disp_data); - } -#else if (has_type) { delivery->remote.type = type; pn_data_clear(delivery->remote.data); pn_data_decode(delivery->remote.data, disp_data.start, disp_data.size); } -#endif link->state.delivery_count++; link->state.link_credit--; link->queued++; @@ -1620,19 +1501,9 @@ int pn_do_flow(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, uint32_t handle; bool inext_init, handle_init, dcount_init, drain; -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - int err = pn_data_scan(args, "D.[?IIII?I?II.o]", &inext_init, &inext, &iwin, - &onext, &owin, &handle_init, &handle, &dcount_init, - &delivery_count, &link_credit, &drain); - if (err) return err; -#else pn_amqp_decode_DqEQIIIIQIQIIqoe(payload, &inext_init, &inext, &iwin, &onext, &owin, &handle_init, &handle, &dcount_init, &delivery_count, &link_credit, &drain); -#endif pn_session_t *ssn = pni_channel_state(transport, channel); if (!ssn) { @@ -1692,92 +1563,10 @@ static void pn_condition_set(pn_condition_t *condition, pn_bytes_t cond, pn_byte pn_string_setn(condition->description, desc.start, desc.size); } -#ifdef GENERATE_CODEC_CODE -#define SCAN_ERROR_DEFAULT ("D.[D.[sSC]") -#define SCAN_ERROR_DETACH ("D.[..D.[sSC]") -#define SCAN_ERROR_DISP ("[D.[sSC]") - -static int pn_scan_error(pn_data_t *data, pn_condition_t *condition, const char *fmt) -{ - pn_bytes_t cond; - pn_bytes_t desc; - pn_condition_clear(condition); - int err = pn_data_scan(data, fmt, &cond, &desc, pn_condition_info(condition)); - if (err) return err; - pn_condition_set(condition, cond,desc); - pn_data_rewind(pn_condition_info(condition)); - return 0; -} -#endif - static inline bool sequence_lte(pn_sequence_t a, pn_sequence_t b) { return b-a <= INT32_MAX; } -#ifdef GENERATE_CODEC_CODE -static int pni_do_delivery_disposition(pn_transport_t * transport, pn_delivery_t *delivery, bool settled, bool remote_data, bool type_init, uint64_t type) { - pn_disposition_t *remote = &delivery->remote; - - if (type_init) remote->type = type; - - if (remote_data) { - switch (type) { - case PN_RECEIVED: - pn_data_rewind(transport->disp_data); - pn_data_next(transport->disp_data); - pn_data_enter(transport->disp_data); - - if (pn_data_next(transport->disp_data)) { - remote->section_number = pn_data_get_uint(transport->disp_data); - } - if (pn_data_next(transport->disp_data)) { - remote->section_offset = pn_data_get_ulong(transport->disp_data); - } - break; - - case PN_ACCEPTED: - break; - - case PN_REJECTED: { - int err = pn_scan_error(transport->disp_data, &remote->condition, SCAN_ERROR_DISP); - - if (err) return err; - break; - } - case PN_RELEASED: - break; - - case PN_MODIFIED: - pn_data_rewind(transport->disp_data); - pn_data_next(transport->disp_data); - pn_data_enter(transport->disp_data); - - if (pn_data_next(transport->disp_data)) { - remote->failed = pn_data_get_bool(transport->disp_data); - } - if (pn_data_next(transport->disp_data)) { - remote->undeliverable = pn_data_get_bool(transport->disp_data); - } - pn_data_narrow(transport->disp_data); - pn_data_clear(remote->data); - pn_data_appendn(remote->annotations, transport->disp_data, 1); - pn_data_widen(transport->disp_data); - break; - - default: - pn_data_copy(remote->data, transport->disp_data); - break; - } - } - - remote->settled = settled; - delivery->updated = true; - pn_work_update(transport->connection, delivery); - - pn_collector_put(transport->connection->collector, PN_OBJECT, delivery, PN_DELIVERY); - return 0; -} -#else static int pni_do_delivery_disposition(pn_transport_t * transport, pn_delivery_t *delivery, bool settled, bool remote_data, bool type_init, uint64_t type, pn_bytes_t disp_data) { pn_disposition_t *remote = &delivery->remote; @@ -1842,30 +1631,15 @@ static int pni_do_delivery_disposition(pn_transport_t * transport, pn_delivery_t pn_collector_put(transport->connection->collector, PN_OBJECT, delivery, PN_DELIVERY); return 0; } -#endif int pn_do_disposition(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, pn_bytes_t payload) { bool role; pn_sequence_t first, last; bool last_init, settled; -#ifdef GENERATE_CODEC_CODE - bool type_init; - uint64_t type = 0; - pn_data_clear(transport->disp_data); - - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - int err = pn_data_scan(args, "D.[oI?IoD?LC]", &role, &first, &last_init, - &last, &settled, &type_init, &type, - transport->disp_data); - if (err) return err; -#else pn_bytes_t disp_data; pn_amqp_decode_DqEoIQIoRe(payload, &role, &first, &last_init, &last, &settled, &disp_data); -#endif if (!last_init) last = first; pn_session_t *ssn = pni_channel_state(transport, channel); @@ -1884,39 +1658,6 @@ int pn_do_disposition(pn_transport_t *transport, uint8_t frame_type, uint16_t ch deliveries = &ssn->state.incoming; } -#ifdef GENERATE_CODEC_CODE - pn_data_rewind(transport->disp_data); - bool remote_data = (pn_data_next(transport->disp_data) && - pn_data_get_list(transport->disp_data) > 0); - - // Do some validation of received first and last values - // TODO: We should really also clamp the first value here, but we're not keeping track of the earliest - // unsettled delivery sequence no - last = sequence_lte(last, deliveries->next) ? last : deliveries->next; - - // If there are fewer deliveries in the session than the range then look at every delivery in the session - // otherwise look at every delivery_id in the disposition performative - pn_hash_t *dh = deliveries->deliveries; - if (last-first+1 >= pn_hash_size(dh)) { - for (pn_handle_t entry = pn_hash_head(dh); entry!=0 ; entry = pn_hash_next(dh, entry)) { - pn_sequence_t key = pn_hash_key(dh, entry); - if (sequence_lte(first, key) && sequence_lte(key, last)) { - pn_delivery_t *delivery = (pn_delivery_t*) pn_hash_value(dh, entry); - int err = pni_do_delivery_disposition(transport, delivery, settled, remote_data, type_init, type); - if (err) return err; - } - } - } else { - for (pn_sequence_t id = first; sequence_lte(id, last); ++id) { - pn_delivery_t *delivery = pni_delivery_map_get(deliveries, id); - if (delivery) { - int err = pni_do_delivery_disposition(transport, delivery, settled, remote_data, type_init, type); - if (err) return err; - } - } - } - -#else bool type_init; uint64_t type; bool remote_data; @@ -1947,7 +1688,6 @@ int pn_do_disposition(pn_transport_t *transport, uint8_t frame_type, uint16_t ch } } } -#endif return 0; } @@ -1956,16 +1696,8 @@ int pn_do_detach(pn_transport_t *transport, uint8_t frame_type, uint16_t channel uint32_t handle; bool closed; -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - int err = pn_data_scan(args, "D.[Io]", &handle, &closed); - if (err) return err; -#else pn_bytes_t error_condition; pn_amqp_decode_DqEIoRe(payload, &handle, &closed, &error_condition); -#endif pn_session_t *ssn = pni_channel_state(transport, channel); if (!ssn) { @@ -1976,10 +1708,6 @@ int pn_do_detach(pn_transport_t *transport, uint8_t frame_type, uint16_t channel return pn_do_error(transport, "amqp:invalid-field", "no such handle: %u", handle); } -#ifdef GENERATE_CODEC_CODE - err = pn_scan_error(args, &link->endpoint.remote_condition, SCAN_ERROR_DETACH); - if (err) return err; -#else pn_bytes_t cond; pn_bytes_t desc; pn_condition_t* condition = &link->endpoint.remote_condition; @@ -1987,7 +1715,6 @@ int pn_do_detach(pn_transport_t *transport, uint8_t frame_type, uint16_t channel pn_amqp_decode_DqEsSCe(error_condition, &cond, &desc, pn_condition_info(condition)); pn_condition_set(condition, cond, desc); pn_data_rewind(pn_condition_info(condition)); -#endif if (closed) { @@ -2008,13 +1735,6 @@ int pn_do_end(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, p return pn_do_error(transport, "amqp:not-allowed", "no such channel: %u", channel); } -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - int err = pn_scan_error(args, &ssn->endpoint.remote_condition, SCAN_ERROR_DEFAULT); - if (err) return err; -#else pn_bytes_t cond; pn_bytes_t desc; pn_condition_t* condition = &ssn->endpoint.remote_condition; @@ -2022,7 +1742,6 @@ int pn_do_end(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, p pn_amqp_decode_DqEDqEsSCee(payload, &cond, &desc, pn_condition_info(condition)); pn_condition_set(condition, cond, desc); pn_data_rewind(pn_condition_info(condition)); -#endif PN_SET_REMOTE(ssn->endpoint.state, PN_REMOTE_CLOSED); pn_collector_put(transport->connection->collector, PN_OBJECT, ssn, PN_SESSION_REMOTE_CLOSE); pni_unmap_remote_channel(ssn); @@ -2033,13 +1752,6 @@ int pn_do_close(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, { pn_connection_t *conn = transport->connection; -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - int err = pn_scan_error(args, &transport->remote_condition, SCAN_ERROR_DEFAULT); - if (err) return err; -#else pn_bytes_t cond; pn_bytes_t desc; pn_condition_t* condition = &transport->remote_condition; @@ -2047,7 +1759,6 @@ int pn_do_close(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, pn_amqp_decode_DqEDqEsSCee(payload, &cond, &desc, pn_condition_info(condition)); pn_condition_set(condition, cond, desc); pn_data_rewind(pn_condition_info(condition)); -#endif transport->close_rcvd = true; PN_SET_REMOTE(conn->endpoint.state, PN_REMOTE_CLOSED); pn_collector_put(transport->connection->collector, PN_OBJECT, conn, PN_CONNECTION_REMOTE_CLOSE); @@ -2137,20 +1848,6 @@ 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), - // 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); -#else /* "DL[SS?I?H?InnMMC]" */ pn_bytes_t buf = pn_amqp_encode_DLESSQIQHQInnMMCe(transport->frame, OPEN, cid ? cid : "", @@ -2164,7 +1861,6 @@ static int pni_process_conn_setup(pn_transport_t *transport, pn_endpoint_t *endp 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; @@ -2241,20 +1937,12 @@ 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); } } @@ -2307,27 +1995,6 @@ 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, - 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); -#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), @@ -2348,43 +2015,9 @@ static int pni_process_link_setup(pn_transport_t *transport, pn_endpoint_t *endp 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, - 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); -#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), @@ -2417,7 +2050,6 @@ static int pni_process_link_setup(pn_transport_t *transport, pn_endpoint_t *endp 0, link->max_message_size, link->properties); -#endif int err = pn_framing_send_amqp(transport, ssn_state->local_channel, buf); if (err) return err; } @@ -2433,17 +2065,6 @@ 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, - 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); -#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, @@ -2454,7 +2075,6 @@ 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); -#endif return pn_framing_send_amqp(transport, ssn->state.local_channel, buf); } @@ -2481,14 +2101,6 @@ 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, @@ -2496,7 +2108,6 @@ static int pni_flush_disp(pn_transport_t *transport, pn_session_t *ssn) 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; @@ -2527,18 +2138,11 @@ 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); } @@ -2772,18 +2376,11 @@ 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); @@ -2855,14 +2452,9 @@ 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); @@ -2937,12 +2529,8 @@ 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 65571d8..09a3496 100644 --- a/c/src/sasl/sasl.c +++ b/c/src/sasl/sasl.c @@ -22,13 +22,11 @@ #include "sasl-internal.h" #include "core/autodetect.h" -#include "core/framing.h" -#ifndef GENERATE_CODEC_CODE #include "core/consumers.h" +#include "core/engine-internal.h" +#include "core/framing.h" #include "core/frame_generators.h" #include "core/frame_consumers.h" -#endif -#include "core/engine-internal.h" #include "core/util.h" #include "platform/platform_fmt.h" #include "protocol.h" @@ -490,12 +488,8 @@ 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; @@ -509,12 +503,8 @@ 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); @@ -522,12 +512,8 @@ 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); } @@ -537,12 +523,8 @@ 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); } @@ -552,12 +534,8 @@ 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) { @@ -924,16 +902,7 @@ int pn_do_init(pn_transport_t *transport, uint8_t frame_type, uint16_t channel, pn_bytes_t mech; pn_bytes_t recv; -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - - int err = pn_data_scan(args, "D.[sz]", &mech, &recv); - if (err) return err; -#else pn_amqp_decode_DqEsze(payload, &mech, &recv); -#endif sasl->selected_mechanism = pn_strndup(mech.start, mech.size); // We need to filter out a supplied mech in in the inclusion list @@ -964,43 +933,6 @@ int pn_do_mechanisms(pn_transport_t *transport, uint8_t frame_type, uint16_t cha pn_string_t *mechs = pn_string(""); -#ifdef GENERATE_CODEC_CODE - // Try array of symbols for mechanism list - bool array = false; - - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - - // This scanning relies on pn_data_scan leaving the pn_data_t cursors - // where they are after finishing the scan - int err = pn_data_scan(args, "D.[?@[", &array); - if (err) return err; - - if (array) { - // Now keep checking for end of array and pull a symbol - while(pn_data_next(args)) { - pn_bytes_t s = pn_data_get_symbol(args); - if (pni_sasl_client_included_mech(sasl->included_mechanisms, s)) { - pn_string_addf(mechs, "%.*s ", (int)s.size, s.start); - } - } - - if (pn_string_size(mechs)) { - pn_string_buffer(mechs)[pn_string_size(mechs)-1] = 0; - } - } else { - // No array of symbols; try single symbol - pn_data_rewind(args); - pn_bytes_t symbol; - int err = pn_data_scan(args, "D.[s]", &symbol); - if (err) return err; - - if (pni_sasl_client_included_mech(sasl->included_mechanisms, symbol)) { - pn_string_setn(mechs, symbol.start, symbol.size); - } - } -#else pn_bytes_t subpayload; pn_amqp_decode_DqERe(payload, &subpayload); pni_consumer_t consumer = make_consumer_from_bytes(subpayload); @@ -1043,7 +975,6 @@ int pn_do_mechanisms(pn_transport_t *transport, uint8_t frame_type, uint16_t cha pn_string_setn(mechs, symbol.start, symbol.size); } } -#endif if (!(pni_sasl_impl_init_client(transport) && pn_string_size(mechs) && @@ -1070,15 +1001,7 @@ int pn_do_challenge(pn_transport_t *transport, uint8_t frame_type, uint16_t chan pn_bytes_t recv; -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - int err = pn_data_scan(args, "D.[z]", &recv); - if (err) return err; -#else pn_amqp_decode_DqEze(payload, &recv); -#endif pni_sasl_impl_process_challenge(transport, &recv); @@ -1099,15 +1022,7 @@ int pn_do_response(pn_transport_t *transport, uint8_t frame_type, uint16_t chann pn_bytes_t recv; -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - int err = pn_data_scan(args, "D.[z]", &recv); - if (err) return err; -#else pn_amqp_decode_DqEze(payload, &recv); -#endif pni_sasl_impl_process_response(transport, &recv); @@ -1129,15 +1044,8 @@ int pn_do_outcome(pn_transport_t *transport, uint8_t frame_type, uint16_t channe uint8_t outcome; pn_bytes_t recv; -#ifdef GENERATE_CODEC_CODE - pn_data_t *args = transport->args; - ssize_t dsize = pn_framing_recv_amqp(args, &transport->logger, payload); - if (dsize < 0) return dsize; - int err = pn_data_scan(args, "D.[Bz]", &outcome, &recv); - if (err) return err; -#else pn_amqp_decode_DqEBze(payload, &outcome, &recv); -#endif + // Preset the outcome to what the server sent us - the plugin can alter this. // In practise the plugin processing here should only fail because it fails // to authenticate the server id after the server authenticates our user. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
