src/rdkafka_broker.c
static void
rd_kafka_broker_handle_SaslHandshake (rd_kafka_t *rk,
				      rd_kafka_broker_t *rkb,
				      rd_kafka_resp_err_t err,
				      rd_kafka_buf_t *rkbuf,
				      rd_kafka_buf_t *request,
				      void *opaque) {
        const int log_decode_errors = LOG_ERR;
	int32_t MechCnt;
	int16_t ErrorCode;
	int i = 0;
	char *mechs = "(n/a)";
	size_t msz, mof = 0;

	if (err == RD_KAFKA_RESP_ERR__DESTROY)
		return;

        if (err)
                goto err;

	rd_kafka_buf_read_i16(rkbuf, &ErrorCode);
        rd_kafka_buf_read_i32(rkbuf, &MechCnt);

	/* Build a CSV string of supported mechanisms. */
	msz = RD_MIN(511, MechCnt * 32);
	mechs = rd_alloca(msz);
	*mechs = '\0';

	for (i = 0 ; i < MechCnt ; i++) {
		rd_kafkap_str_t mech;
		rd_kafka_buf_read_str(rkbuf, &mech);

		mof += rd_snprintf(mechs+mof, msz-mof, "%s%.*s",
				   i ? ",":"", RD_KAFKAP_STR_PR(&mech));

		if (mof >= msz)
			break;
        }

	rd_rkb_dbg(rkb,
		   PROTOCOL | RD_KAFKA_DBG_SECURITY | RD_KAFKA_DBG_BROKER,
		   "SASLMECHS", "Broker supported SASL mechanisms: %s",
		   mechs);

	if (ErrorCode) {
		err = ErrorCode;
		goto err;
	}

	/* Circle back to connect_auth() to start proper AUTH state. */
	rd_kafka_broker_connect_auth(rkb);
	return;

 err_parse:
        err = rkbuf->rkbuf_err;
 err:
	rd_kafka_broker_fail(rkb, LOG_ERR,
			     RD_KAFKA_RESP_ERR__AUTHENTICATION,
			     "SASL %s mechanism handshake failed: %s: "
			     "broker's supported mechanisms: %s",
                             rkb->rkb_rk->rk_conf.sasl.mechanisms,
			     rd_kafka_err2str(err), mechs);
}
/**
 * @brief Parses and handles SaslMechanism response, transitions
 *        the broker state.
 *
 */
@brief Parses and handles SaslMechanism response, transitions
the broker state.
@brief Parses and handles SaslMechanism response transitions the broker state .
static void
rd_kafka_broker_handle_SaslHandshake (rd_kafka_t *rk,
				      rd_kafka_broker_t *rkb,
				      rd_kafka_resp_err_t err,
				      rd_kafka_buf_t *rkbuf,
				      rd_kafka_buf_t *request,
				      void *opaque) {
        const int log_decode_errors = LOG_ERR;
	int32_t MechCnt;
	int16_t ErrorCode;
	int i = 0;
	char *mechs = "(n/a)";
	size_t msz, mof = 0;
	if (err == RD_KAFKA_RESP_ERR__DESTROY)
		return;
        if (err)
                goto err;
	rd_kafka_buf_read_i16(rkbuf, &ErrorCode);
        rd_kafka_buf_read_i32(rkbuf, &MechCnt);
	msz = RD_MIN(511, MechCnt * 32);
	mechs = rd_alloca(msz);
	*mechs = '\0';
	for (i = 0 ; i < MechCnt ; i++) {
		rd_kafkap_str_t mech;
		rd_kafka_buf_read_str(rkbuf, &mech);
		mof += rd_snprintf(mechs+mof, msz-mof, "%s%.*s",
				   i ? ",":"", RD_KAFKAP_STR_PR(&mech));
		if (mof >= msz)
			break;
        }
	rd_rkb_dbg(rkb,
		   PROTOCOL | RD_KAFKA_DBG_SECURITY | RD_KAFKA_DBG_BROKER,
		   "SASLMECHS", "Broker supported SASL mechanisms: %s",
		   mechs);
	if (ErrorCode) {
		err = ErrorCode;
		goto err;
	}
	rd_kafka_broker_connect_auth(rkb);
	return;
 err_parse:
        err = rkbuf->rkbuf_err;
 err:
	rd_kafka_broker_fail(rkb, LOG_ERR,
			     RD_KAFKA_RESP_ERR__AUTHENTICATION,
			     "SASL %s mechanism handshake failed: %s: "
			     "broker's supported mechanisms: %s",
                             rkb->rkb_rk->rk_conf.sasl.mechanisms,
			     rd_kafka_err2str(err), mechs);
}
static void rd_kafka_broker_handle_SaslHandshake ( rd_kafka_t * rk , rd_kafka_broker_t * rkb , rd_kafka_resp_err_t err , rd_kafka_buf_t * rkbuf , rd_kafka_buf_t * request , void * opaque ) { const int log_decode_errors = LOG_ERR ; int32_t MechCnt ; int16_t ErrorCode ; int i = 0 ; char * mechs = " " ; size_t msz , mof = 0 ; if ( err == RD_KAFKA_RESP_ERR__DESTROY ) return ; if ( err ) goto err ; rd_kafka_buf_read_i16 ( rkbuf , & ErrorCode ) ; rd_kafka_buf_read_i32 ( rkbuf , & MechCnt ) ; msz = RD_MIN ( 511 , MechCnt * 32 ) ; mechs = rd_alloca ( msz ) ; * mechs = ' \0 ' ; for ( i = 0 ; i < MechCnt ; i ++ ) { rd_kafkap_str_t mech ; rd_kafka_buf_read_str ( rkbuf , & mech ) ; mof += rd_snprintf ( mechs + mof , msz - mof , " " , i ? " " : " " , RD_KAFKAP_STR_PR ( & mech ) ) ; if ( mof >= msz ) break ; } rd_rkb_dbg ( rkb , PROTOCOL | RD_KAFKA_DBG_SECURITY | RD_KAFKA_DBG_BROKER , " " , " " , mechs ) ; if ( ErrorCode ) { err = ErrorCode ; goto err ; } rd_kafka_broker_connect_auth ( rkb ) ; return ; err_parse : err = rkbuf -> rkbuf_err ; err : rd_kafka_broker_fail ( rkb , LOG_ERR , RD_KAFKA_RESP_ERR__AUTHENTICATION , " " " " , rkb -> rkb_rk -> rk_conf . sasl . mechanisms , rd_kafka_err2str ( err ) , mechs ) ; }
@brief Parses and handles SaslMechanism response, transitions
        the broker state.
@brief Parses and handles SaslMechanism response transitions the broker state .
/* Build a CSV string of supported mechanisms. */ /* Circle back to connect_auth() to start proper AUTH state. */