From 4ee6941188e53f98efa414790f154daa2ee39afc Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 19 Sep 2018 11:13:50 +0100 Subject: [PATCH] Primitive v5 CONNACK support - no properties. --- lib/mosquitto_internal.h | 2 +- src/send_connack.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/mosquitto_internal.h b/lib/mosquitto_internal.h index d416eccb..b49bcff7 100644 --- a/lib/mosquitto_internal.h +++ b/lib/mosquitto_internal.h @@ -116,7 +116,7 @@ enum mosquitto__protocol { mosq_p_mqtt31 = 1, mosq_p_mqtt311 = 2, mosq_p_mqtts = 3, - mosq_p_mqtt5 = 4, + mosq_p_mqtt5 = 5, }; enum mosquitto__threaded_state { diff --git a/src/send_connack.c b/src/send_connack.c index 2a15ae3d..3bb6ea7c 100644 --- a/src/send_connack.c +++ b/src/send_connack.c @@ -39,7 +39,12 @@ int send__connack(struct mosquitto *context, int ack, int result) if(!packet) return MOSQ_ERR_NOMEM; packet->command = CONNACK; - packet->remaining_length = 2; + if(context->protocol == mosq_p_mqtt5){ + /* FIXME - proper property support */ + packet->remaining_length = 3; + }else{ + packet->remaining_length = 2; + } rc = packet__alloc(packet); if(rc){ mosquitto__free(packet); @@ -47,6 +52,9 @@ int send__connack(struct mosquitto *context, int ack, int result) } packet->payload[packet->pos+0] = ack; packet->payload[packet->pos+1] = result; + if(context->protocol == mosq_p_mqtt5){ + packet->payload[packet->pos+2] = 0; + } return packet__queue(context, packet); }