mosquitto_broker.h

Summary
mosquitto_broker.h
Functions
mosquitto_log_printfWrite a log message using the broker configured logging.
mosquitto_client_addressRetrieve the IP address of the client as a string.
mosquitto_client_clean_sessionRetrieve the clean session flag value for a client.
mosquitto_client_idRetrieve the client id associated with a client.
mosquitto_client_keepaliveRetrieve the keepalive value for a client.
mosquitto_client_certificateIf TLS support is enabled, return the certificate provided by a client as an X509 pointer from openssl.
mosquitto_client_protocolmp_mqtt (MQTT over TCP) mp_mqttsn (MQTT-SN) mp_websockets (MQTT over Websockets)
mosquitto_client_sub_countRetrieve the number of subscriptions that have been made by a client.
mosquitto_client_usernameRetrieve the username associated with a client.
mosquitto_set_usernameSet the username for a client.

Functions

mosquitto_log_printf

void mosquitto_log_printf(int level,
const char *fmt,
 ...)

Write a log message using the broker configured logging.

Parameters

levelLog message priority.  Can currently be one of:

MOSQ_LOG_INFO MOSQ_LOG_NOTICE MOSQ_LOG_WARNING MOSQ_LOG_ERR MOSQ_LOG_DEBUG MOSQ_LOG_SUBSCRIBE (not recommended for use by plugins) MOSQ_LOG_UNSUBSCRIBE (not recommended for use by plugins)

These values are defined in mosquitto.h.

fmt, ...printf style format and arguments.

mosquitto_client_address

const char *mosquitto_client_address(const struct mosquitto *client)

Retrieve the IP address of the client as a string.

mosquitto_client_clean_session

bool mosquitto_client_clean_session(const struct mosquitto *client)

Retrieve the clean session flag value for a client.

mosquitto_client_id

const char *mosquitto_client_id(const struct mosquitto *client)

Retrieve the client id associated with a client.

mosquitto_client_keepalive

int mosquitto_client_keepalive(const struct mosquitto *client)

Retrieve the keepalive value for a client.

mosquitto_client_certificate

void *mosquitto_client_certificate(const struct mosquitto *client)

If TLS support is enabled, return the certificate provided by a client as an X509 pointer from openssl.  If the client did not provide a certificate, then NULL will be returned.  This function will only ever return a non-NULL value if the `require_certificate` option is set to true.

If TLS is not supported, this function will always return NULL.

mosquitto_client_protocol

int mosquitto_client_protocol(const struct mosquitto *client)

Retrieve the protocol with which the client has connected.  Can be one of

mp_mqtt (MQTT over TCP) mp_mqttsn (MQTT-SN) mp_websockets (MQTT over Websockets)

mosquitto_client_sub_count

int mosquitto_client_sub_count(const struct mosquitto *client)

Retrieve the number of subscriptions that have been made by a client.

mosquitto_client_username

const char *mosquitto_client_username(const struct mosquitto *client)

Retrieve the username associated with a client.

mosquitto_set_username

int mosquitto_set_username(struct mosquitto *client,
const char *username)

Set the username for a client.

This removes and replaces the current username for a client and hence updates its access.

username can be NULL, in which case the client will become anonymous, but must not be zero length.

In the case of error, the client will be left with its original username.

Returns

MOSQ_ERR_SUCCESSon success
MOSQ_ERR_INVALif client is NULL, or if username is zero length
MOSQ_ERR_NOMEMon out of memory
void mosquitto_log_printf(int level,
const char *fmt,
 ...)
Write a log message using the broker configured logging.
const char *mosquitto_client_address(const struct mosquitto *client)
Retrieve the IP address of the client as a string.
bool mosquitto_client_clean_session(const struct mosquitto *client)
Retrieve the clean session flag value for a client.
const char *mosquitto_client_id(const struct mosquitto *client)
Retrieve the client id associated with a client.
int mosquitto_client_keepalive(const struct mosquitto *client)
Retrieve the keepalive value for a client.
void *mosquitto_client_certificate(const struct mosquitto *client)
If TLS support is enabled, return the certificate provided by a client as an X509 pointer from openssl.
int mosquitto_client_protocol(const struct mosquitto *client)
mp_mqtt (MQTT over TCP) mp_mqttsn (MQTT-SN) mp_websockets (MQTT over Websockets)
int mosquitto_client_sub_count(const struct mosquitto *client)
Retrieve the number of subscriptions that have been made by a client.
const char *mosquitto_client_username(const struct mosquitto *client)
Retrieve the username associated with a client.
int mosquitto_set_username(struct mosquitto *client,
const char *username)
Set the username for a client.
Close