Called by the broker when topic access must be checked.
mosq_plugin_EXPORT int mosquitto_auth_acl_check( void * user_data, int access, struct mosquitto * client, const struct mosquitto_acl_msg * msg )
Called when the broker is shutting down.
mosq_plugin_EXPORT int mosquitto_auth_plugin_cleanup( void * user_data, struct mosquitto_opt * opts, int opt_count )
Called after the plugin has been loaded and mosquitto_auth_plugin_version has been called.
mosq_plugin_EXPORT int mosquitto_auth_plugin_init( void ** user_data, struct mosquitto_opt * opts, int opt_count )
The broker will call this function immediately after loading the plugin to check it is a supported plugin version.
mosq_plugin_EXPORT int mosquitto_auth_plugin_version( void )
1.
mosq_plugin_EXPORT int mosquitto_auth_security_cleanup( void * user_data, struct mosquitto_opt * opts, int opt_count, bool reload )
1.
mosq_plugin_EXPORT int mosquitto_auth_security_init( void * user_data, struct mosquitto_opt * opts, int opt_count, bool reload )
This function is OPTIONAL.
mosq_plugin_EXPORT int mosquitto_auth_start( void * user_data, struct mosquitto * client, const char * method, bool reauth, const void * data_in, uint16_t data_in_len, void ** data_out, uint16_t * data_out_len )
This function is OPTIONAL.
mosq_plugin_EXPORT int mosquitto_auth_unpwd_check( void * user_data, struct mosquitto * client, const char * username, const char * password )
Publish a message from within a plugin.
mosq_EXPORT int mosquitto_broker_publish( const char * clientid, const char * topic, int payloadlen, void * payload, int qos, bool retain, mosquitto_property * properties )
Publish a message from within a plugin.
mosq_EXPORT int mosquitto_broker_publish_copy( const char * clientid, const char * topic, int payloadlen, const void * payload, int qos, bool retain, mosquitto_property * properties )
Register a callback for an event.
mosq_EXPORT int mosquitto_callback_register( mosquitto_plugin_id_t * identifier, int event, MOSQ_FUNC_generic_callback cb_func, const void * event_data, void * userdata )
Unregister a previously registered callback function.
mosq_EXPORT int mosquitto_callback_unregister( mosquitto_plugin_id_t * identifier, int event, MOSQ_FUNC_generic_callback cb_func, const void * event_data )
mosq_EXPORT void *mosquitto_calloc( size_t nmemb, size_t size )
Retrieve the IP address of the client as a string.
mosq_EXPORT const char *mosquitto_client_address( const struct mosquitto * client )
If TLS support is enabled, return the certificate provided by a client as an X509 pointer from openssl.
mosq_EXPORT void *mosquitto_client_certificate( const struct mosquitto * client )
Retrieve the clean session flag value for a client.
mosq_EXPORT bool mosquitto_client_clean_session( const struct mosquitto * client )
Retrieve the client id associated with a client.
mosq_EXPORT const char *mosquitto_client_id( const struct mosquitto * client )
Retrieve the keepalive value for a client.
mosq_EXPORT int mosquitto_client_keepalive( const struct mosquitto * client )
mp_mqtt (MQTT over TCP) mp_mqttsn (MQTT-SN) mp_websockets (MQTT over Websockets)
mosq_EXPORT int mosquitto_client_protocol( const struct mosquitto * client )
mosq_EXPORT int mosquitto_client_protocol_version( const struct mosquitto * client )
Retrieve the number of subscriptions that have been made by a client.
mosq_EXPORT int mosquitto_client_sub_count( const struct mosquitto * client )
Retrieve the username associated with a client.
mosq_EXPORT const char *mosquitto_client_username( const struct mosquitto * client )
Call to obtain a const string description of an MQTT connection result.
libmosq_EXPORT const char *mosquitto_connack_string( int connack_code )
Connect to an MQTT broker.
libmosq_EXPORT int mosquitto_connect( struct mosquitto * mosq, const char * host, int port, int keepalive )
Connect to an MQTT broker.
libmosq_EXPORT int mosquitto_connect_async( struct mosquitto * mosq, const char * host, int port, int keepalive )
Connect to an MQTT broker.
libmosq_EXPORT int mosquitto_connect_bind( struct mosquitto * mosq, const char * host, int port, int keepalive, const char * bind_address )
Connect to an MQTT broker.
libmosq_EXPORT int mosquitto_connect_bind_async( struct mosquitto * mosq, const char * host, int port, int keepalive, const char * bind_address )
Connect to an MQTT broker.
libmosq_EXPORT int mosquitto_connect_bind_v5( struct mosquitto * mosq, const char * host, int port, int keepalive, const char * bind_address, const mosquitto_property * properties )
Set the connect callback.
libmosq_EXPORT void mosquitto_connect_callback_set( struct mosquitto * mosq, void (*on_connect)(struct mosquitto *, void *, int) )
Connect to an MQTT broker.
libmosq_EXPORT int mosquitto_connect_srv( struct mosquitto * mosq, const char * host, int keepalive, const char * bind_address )
Set the connect callback.
libmosq_EXPORT void mosquitto_connect_v5_callback_set( struct mosquitto * mosq, void (*on_connect)(struct mosquitto *, void *, int, int, const mosquitto_property *props) )
Set the connect callback.
libmosq_EXPORT void mosquitto_connect_with_flags_callback_set( struct mosquitto * mosq, void (*on_connect)(struct mosquitto *, void *, int, int) )
Use to free memory associated with a mosquitto client instance.
libmosq_EXPORT void mosquitto_destroy( struct mosquitto * mosq )
Disconnect from the broker.
libmosq_EXPORT int mosquitto_disconnect( struct mosquitto * mosq )
Set the disconnect callback.
libmosq_EXPORT void mosquitto_disconnect_callback_set( struct mosquitto * mosq, void (*on_disconnect)(struct mosquitto *, void *, int) )
Disconnect from the broker, with attached MQTT properties.
libmosq_EXPORT int mosquitto_disconnect_v5( struct mosquitto * mosq, int reason_code, const mosquitto_property * properties )
Set the disconnect callback.
libmosq_EXPORT void mosquitto_disconnect_v5_callback_set( struct mosquitto * mosq, void (*on_disconnect)(struct mosquitto *, void *, int, const mosquitto_property *) )
mosq_EXPORT void mosquitto_free( void * mem )
Used to set integer options for the client.
libmosq_EXPORT int mosquitto_int_option( struct mosquitto * mosq, enum mosq_opt_t option, int value )
Forcefully disconnect a client from the broker.
mosq_EXPORT int mosquitto_kick_client_by_clientid( const char * clientid, bool with_will )
Forcefully disconnect a client from the broker.
mosq_EXPORT int mosquitto_kick_client_by_username( const char * username, bool with_will )
Call to free resources associated with the library.
libmosq_EXPORT int mosquitto_lib_cleanup( void )
Must be called before any other mosquitto functions.
libmosq_EXPORT int mosquitto_lib_init( void )
Can be used to obtain version information for the mosquitto library.
libmosq_EXPORT int mosquitto_lib_version( int * major, int * minor, int * revision )
Set the logging callback.
libmosq_EXPORT void mosquitto_log_callback_set( struct mosquitto * mosq, void (*on_log)(struct mosquitto *, void *, int, const char *) )
Write a log message using the broker configured logging.
mosq_EXPORT void mosquitto_log_printf( int level, const char * fmt, ... )
The main network loop for the client.
libmosq_EXPORT int mosquitto_loop( struct mosquitto * mosq, int timeout, int max_packets )
This function call loop() for you in an infinite blocking loop.
libmosq_EXPORT int mosquitto_loop_forever( struct mosquitto * mosq, int timeout, int max_packets )
Carry out miscellaneous operations required as part of the network loop.
libmosq_EXPORT int mosquitto_loop_misc( struct mosquitto * mosq )
Carry out network read operations.
libmosq_EXPORT int mosquitto_loop_read( struct mosquitto * mosq, int max_packets )
This is part of the threaded client interface.
libmosq_EXPORT int mosquitto_loop_start( struct mosquitto * mosq )
This is part of the threaded client interface.
libmosq_EXPORT int mosquitto_loop_stop( struct mosquitto * mosq, bool force )
Carry out network write operations.
libmosq_EXPORT int mosquitto_loop_write( struct mosquitto * mosq, int max_packets )
mosq_EXPORT void *mosquitto_malloc( size_t size )
This function is deprected.
libmosq_EXPORT int mosquitto_max_inflight_messages_set( struct mosquitto * mosq, unsigned int max_inflight_messages )
Set the message callback.
libmosq_EXPORT void mosquitto_message_callback_set( struct mosquitto * mosq, void (*on_message)(struct mosquitto *, void *, const struct mosquitto_message *) )
Copy the contents of a mosquitto message to another message.
libmosq_EXPORT int mosquitto_message_copy( struct mosquitto_message * dst, const struct mosquitto_message * src )
Completely free a mosquitto_message struct.
libmosq_EXPORT void mosquitto_message_free( struct mosquitto_message ** message )
Free a mosquitto_message struct contents, leaving the struct unaffected.
libmosq_EXPORT void mosquitto_message_free_contents( struct mosquitto_message * message )
This function now has no effect.
libmosq_EXPORT void mosquitto_message_retry_set( struct mosquitto * mosq, unsigned int message_retry )
Set the message callback.
libmosq_EXPORT void mosquitto_message_v5_callback_set( struct mosquitto * mosq, void (*on_message)(struct mosquitto *, void *, const struct mosquitto_message *, const mosquitto_property *) )
Create a new mosquitto client instance.
libmosq_EXPORT struct mosquitto *mosquitto_new( const char * id, bool clean_session, void * obj )
Used to set options for the client.
libmosq_EXPORT int mosquitto_opts_set( struct mosquitto * mosq, enum mosq_opt_t option, void * value )
Called when the broker is shutting down.
mosq_plugin_EXPORT int mosquitto_plugin_cleanup( void * userdata, struct mosquitto_opt * options, int option_count )
Called after the plugin has been loaded and mosquitto_plugin_version has been called.
mosq_plugin_EXPORT int mosquitto_plugin_init( mosquitto_plugin_id_t * identifier, void ** userdata, struct mosquitto_opt * options, int option_count )
The broker will attempt to call this function immediately after loading the plugin to check it is a supported plugin version.
mosq_plugin_EXPORT int mosquitto_plugin_version( int supported_version_count, const int * supported_versions )
Add a new binary property to a property list.
libmosq_EXPORT int mosquitto_property_add_binary( mosquitto_property ** proplist, int identifier, const void * value, uint16_t len )
Add a new byte property to a property list.
libmosq_EXPORT int mosquitto_property_add_byte( mosquitto_property ** proplist, int identifier, uint8_t value )
Add a new int16 property to a property list.
libmosq_EXPORT int mosquitto_property_add_int16( mosquitto_property ** proplist, int identifier, uint16_t value )
Add a new int32 property to a property list.
libmosq_EXPORT int mosquitto_property_add_int32( mosquitto_property ** proplist, int identifier, uint32_t value )
Add a new string property to a property list.
libmosq_EXPORT int mosquitto_property_add_string( mosquitto_property ** proplist, int identifier, const char * value )
Add a new string pair property to a property list.
libmosq_EXPORT int mosquitto_property_add_string_pair( mosquitto_property ** proplist, int identifier, const char * name, const char * value )
Add a new varint property to a property list.
libmosq_EXPORT int mosquitto_property_add_varint( mosquitto_property ** proplist, int identifier, uint32_t value )
Check whether a list of properties are valid for a particular command, whether there are duplicates, and whether the values are valid where possible.
libmosq_EXPORT int mosquitto_property_check_all( int command, const mosquitto_property * properties )
Check whether a property identifier is valid for the given command.
libmosq_EXPORT int mosquitto_property_check_command( int command, int identifier )
libmosq_EXPORT int mosquitto_property_copy_all( mosquitto_property ** dest, const mosquitto_property * src )
Free all properties from a list of properties.
libmosq_EXPORT void mosquitto_property_free_all( mosquitto_property ** properties )
Return the property identifier for a single property.
libmosq_EXPORT int mosquitto_property_identifier( const mosquitto_property * property )
Return the property name as a string for a property identifier.
libmosq_EXPORT const char *mosquitto_property_identifier_to_string( int identifier )
Return the next property in a property list.
libmosq_EXPORT const mosquitto_property *mosquitto_property_next( const mosquitto_property * proplist )
Read a binary property value from a property.
libmosq_EXPORT const mosquitto_property *mosquitto_property_read_binary( const mosquitto_property * proplist, int identifier, void ** value, uint16_t * len, bool skip_first )
Attempt to read a byte property matching an identifier, from a property list or single property.
libmosq_EXPORT const mosquitto_property *mosquitto_property_read_byte( const mosquitto_property * proplist, int identifier, uint8_t * value, bool skip_first )
Read an int16 property value from a property.
libmosq_EXPORT const mosquitto_property *mosquitto_property_read_int16( const mosquitto_property * proplist, int identifier, uint16_t * value, bool skip_first )
Read an int32 property value from a property.
libmosq_EXPORT const mosquitto_property *mosquitto_property_read_int32( const mosquitto_property * proplist, int identifier, uint32_t * value, bool skip_first )
Read a string property value from a property.
libmosq_EXPORT const mosquitto_property *mosquitto_property_read_string( const mosquitto_property * proplist, int identifier, char ** value, bool skip_first )
Read a string pair property value pair from a property.
libmosq_EXPORT const mosquitto_property *mosquitto_property_read_string_pair( const mosquitto_property * proplist, int identifier, char ** name, char ** value, bool skip_first )
Read a varint property value from a property.
libmosq_EXPORT const mosquitto_property *mosquitto_property_read_varint( const mosquitto_property * proplist, int identifier, uint32_t * value, bool skip_first )
Check whether a topic to be used for publishing is valid.
libmosq_EXPORT int mosquitto_pub_topic_check( const char * topic )
Check whether a topic to be used for publishing is valid.
libmosq_EXPORT int mosquitto_pub_topic_check2( const char * topic, size_t topiclen )
Publish a message on a given topic.
libmosq_EXPORT int mosquitto_publish( struct mosquitto * mosq, int * mid, const char * topic, int payloadlen, const void * payload, int qos, bool retain )
Set the publish callback.
libmosq_EXPORT void mosquitto_publish_callback_set( struct mosquitto * mosq, void (*on_publish)(struct mosquitto *, void *, int) )
Publish a message on a given topic, with attached MQTT properties.
libmosq_EXPORT int mosquitto_publish_v5( struct mosquitto * mosq, int * mid, const char * topic, int payloadlen, const void * payload, int qos, bool retain, const mosquitto_property * properties )
Set the publish callback.
libmosq_EXPORT void mosquitto_publish_v5_callback_set( struct mosquitto * mosq, void (*on_publish)(struct mosquitto *, void *, int, int, const mosquitto_property *) )
mosq_EXPORT void *mosquitto_realloc( void * ptr, size_t size )
Call to obtain a const string description of an MQTT reason code.
libmosq_EXPORT const char *mosquitto_reason_string( int reason_code )
Reconnect to a broker.
libmosq_EXPORT int mosquitto_reconnect( struct mosquitto * mosq )
Reconnect to a broker.
libmosq_EXPORT int mosquitto_reconnect_async( struct mosquitto * mosq )
Control the behaviour of the client when it has unexpectedly disconnected in mosquitto_loop_forever or after mosquitto_loop_start.
libmosq_EXPORT int mosquitto_reconnect_delay_set( struct mosquitto * mosq, unsigned int reconnect_delay, unsigned int reconnect_delay_max, bool reconnect_exponential_backoff )
This function allows an existing mosquitto client to be reused.
libmosq_EXPORT int mosquitto_reinitialise( struct mosquitto * mosq, const char * id, bool clean_session, void * obj )
Set the username for a client.
mosq_EXPORT int mosquitto_set_username( struct mosquitto * client, const char * username )
Return the socket handle for a mosquitto instance.
libmosq_EXPORT int mosquitto_socket( struct mosquitto * mosq )
Configure the client to use a SOCKS5 proxy when connecting.
libmosq_EXPORT int mosquitto_socks5_set( struct mosquitto * mosq, const char * host, int port, const char * username, const char * password )
Retrieve a pointer to the SSL structure used for TLS connections in this client.
libmosq_EXPORT void *mosquitto_ssl_get( struct mosquitto * mosq )
mosq_EXPORT char *mosquitto_strdup( const char * s )
Call to obtain a const string description of a mosquitto error number.
libmosq_EXPORT const char *mosquitto_strerror( int mosq_errno )
Used to set const char* options for the client.
libmosq_EXPORT int mosquitto_string_option( struct mosquitto * mosq, enum mosq_opt_t option, const char * value )
Take a string input representing an MQTT command and convert it to the libmosquitto integer representation.
libmosq_EXPORT int mosquitto_string_to_command( const char * str, int * cmd )
Parse a property name string and convert to a property identifier and data type.
libmosq_EXPORT int mosquitto_string_to_property_info( const char * propname, int * identifier, int * type )
Check whether a topic to be used for subscribing is valid.
libmosq_EXPORT int mosquitto_sub_topic_check( const char * topic )
Check whether a topic to be used for subscribing is valid.
libmosq_EXPORT int mosquitto_sub_topic_check2( const char * topic, size_t topiclen )
Tokenise a topic or subscription string into an array of strings representing the topic hierarchy.
libmosq_EXPORT int mosquitto_sub_topic_tokenise( const char * subtopic, char *** topics, int * count )
Free memory that was allocated in mosquitto_sub_topic_tokenise.
libmosq_EXPORT int mosquitto_sub_topic_tokens_free( char *** topics, int count )
Subscribe to a topic.
libmosq_EXPORT int mosquitto_subscribe( struct mosquitto * mosq, int * mid, const char * sub, int qos )
Helper function to make subscribing to a topic and processing some messages very straightforward.
libmosq_EXPORT int mosquitto_subscribe_callback( int (*callback)(struct mosquitto *, void *, const struct mosquitto_message *), void * userdata, const char * topic, int qos, const char * host, int port, const char * client_id, int keepalive, bool clean_session, const char * username, const char * password, const struct libmosquitto_will * will, const struct libmosquitto_tls * tls )
Set the subscribe callback.
libmosq_EXPORT void mosquitto_subscribe_callback_set( struct mosquitto * mosq, void (*on_subscribe)(struct mosquitto *, void *, int, int, const int *) )
Subscribe to multiple topics.
libmosq_EXPORT int mosquitto_subscribe_multiple( struct mosquitto * mosq, int * mid, int sub_count, char *const *const sub, int qos, int options, const mosquitto_property * properties )
Helper function to make subscribing to a topic and retrieving some messages very straightforward.
libmosq_EXPORT int mosquitto_subscribe_simple( struct mosquitto_message ** messages, int msg_count, bool want_retained, const char * topic, int qos, const char * host, int port, const char * client_id, int keepalive, bool clean_session, const char * username, const char * password, const struct libmosquitto_will * will, const struct libmosquitto_tls * tls )
Subscribe to a topic, with attached MQTT properties.
libmosq_EXPORT int mosquitto_subscribe_v5( struct mosquitto * mosq, int * mid, const char * sub, int qos, int options, const mosquitto_property * properties )
Set the subscribe callback.
libmosq_EXPORT void mosquitto_subscribe_v5_callback_set( struct mosquitto * mosq, void (*on_subscribe)(struct mosquitto *, void *, int, int, const int *, const mosquitto_property *) )
Used to tell the library that your application is using threads, but not using mosquitto_loop_start.
libmosq_EXPORT int mosquitto_threaded_set( struct mosquitto * mosq, bool threaded )
Configure verification of the server hostname in the server certificate.
libmosq_EXPORT int mosquitto_tls_insecure_set( struct mosquitto * mosq, bool value )
Set advanced SSL/TLS options.
libmosq_EXPORT int mosquitto_tls_opts_set( struct mosquitto * mosq, int cert_reqs, const char * tls_version, const char * ciphers )
Configure the client for pre-shared-key based TLS support.
libmosq_EXPORT int mosquitto_tls_psk_set( struct mosquitto * mosq, const char * psk, const char * identity, const char * ciphers )
Configure the client for certificate based SSL/TLS support.
libmosq_EXPORT int mosquitto_tls_set( struct mosquitto * mosq, const char * cafile, const char * capath, const char * certfile, const char * keyfile, int (*pw_callback)(char *buf, int size, int rwflag, void *userdata) )
Check whether a topic matches a subscription.
libmosq_EXPORT int mosquitto_topic_matches_sub( const char * sub, const char * topic, bool * result )
Check whether a topic matches a subscription.
libmosq_EXPORT int mosquitto_topic_matches_sub2( const char * sub, size_t sublen, const char * topic, size_t topiclen, bool * result )
Unsubscribe from a topic.
libmosq_EXPORT int mosquitto_unsubscribe( struct mosquitto * mosq, int * mid, const char * sub )
Set the unsubscribe callback.
libmosq_EXPORT void mosquitto_unsubscribe_callback_set( struct mosquitto * mosq, void (*on_unsubscribe)(struct mosquitto *, void *, int) )
Unsubscribe from multiple topics.
libmosq_EXPORT int mosquitto_unsubscribe_multiple( struct mosquitto * mosq, int * mid, int sub_count, char *const *const sub, const mosquitto_property * properties )
Unsubscribe from a topic, with attached MQTT properties.
libmosq_EXPORT int mosquitto_unsubscribe_v5( struct mosquitto * mosq, int * mid, const char * sub, const mosquitto_property * properties )
Set the unsubscribe callback.
libmosq_EXPORT void mosquitto_unsubscribe_v5_callback_set( struct mosquitto * mosq, void (*on_unsubscribe)(struct mosquitto *, void *, int, const mosquitto_property *) )
When mosquitto_new is called, the pointer given as the “obj” parameter will be passed to the callbacks as user data.
libmosq_EXPORT void mosquitto_user_data_set( struct mosquitto * mosq, void * obj )
Retrieve the “userdata” variable for a mosquitto client.
libmosq_EXPORT void *mosquitto_userdata( struct mosquitto * mosq )
Configure username and password for a mosquitto instance.
libmosq_EXPORT int mosquitto_username_pw_set( struct mosquitto * mosq, const char * username, const char * password )
Helper function to validate whether a UTF-8 string is valid, according to the UTF-8 spec and the MQTT additions.
libmosq_EXPORT int mosquitto_validate_utf8( const char * str, int len )
Used to set void* options for the client.
libmosq_EXPORT int mosquitto_void_option( struct mosquitto * mosq, enum mosq_opt_t option, void * value )
Returns true if there is data ready to be written on the socket.
libmosq_EXPORT bool mosquitto_want_write( struct mosquitto * mosq )
Remove a previously configured will.
libmosq_EXPORT int mosquitto_will_clear( struct mosquitto * mosq )
Configure will information for a mosquitto instance.
libmosq_EXPORT int mosquitto_will_set( struct mosquitto * mosq, const char * topic, int payloadlen, const void * payload, int qos, bool retain )
Configure will information for a mosquitto instance, with attached properties.
libmosq_EXPORT int mosquitto_will_set_v5( struct mosquitto * mosq, const char * topic, int payloadlen, const void * payload, int qos, bool retain, mosquitto_property * properties )