/* Determines the length of the MQTT connect packet that would be produced using the supplied connect options.  */
static int connect_length(mqtt_packet_connect_data_t *options)
/* Determines the length of the MQTT connect packet that would be produced using the supplied connect options.  */
static int connect_length(mqtt_packet_connect_data_t *options)
{
	int len = 0;
	FUNC_ENTRY;
	if (options->MQTTVersion == 3)
		len = 12;
	else if (options->MQTTVersion == 4)
		len = 10;
	len += mqtt_strlen(options->clientID)+2;
	if (options->willFlag)
		len += mqtt_strlen(options->will.topicName)+2 + mqtt_strlen(options->will.message)+2;
	if (options->username.cstring || options->username.lenstring.data)
		len += mqtt_strlen(options->username)+2;
	if (options->password.cstring || options->password.lenstring.data)
		len += mqtt_strlen(options->password)+2;
	FUNC_EXIT_RC(len);
	return len;
}