|
Greenbone Vulnerability Management Libraries 22.32.0
|
Protos for MQTT handling. More...
#include <MQTTClient.h>#include <glib.h>

Go to the source code of this file.
Macros | |
| #define | AUTH_MQTT 1 |
Functions | |
| int | mqtt_init (const char *) |
| Init MQTT communication. | |
| int | mqtt_init_auth (const char *, const char *, const char *) |
| Init MQTT communication. | |
| gboolean | mqtt_is_initialized (void) |
| Get the global init status. | |
| void | mqtt_reset (void) |
| Destroy MQTTClient handle and free mqtt_t. | |
| int | mqtt_publish (const char *, const char *) |
| Publish a message on topic using the global client. | |
| int | mqtt_publish_single_message_auth (const char *, const char *, const char *, const char *, const char *) |
| Send a single message with credentials. | |
| int | mqtt_publish_single_message (const char *, const char *, const char *) |
| Send a single message. | |
| int | mqtt_subscribe (const char *) |
| subscribes to a single topic. | |
| int | mqtt_retrieve_message (char **, int *, char **, int *, const unsigned int) |
| wait for a given timeout in ms to retrieve any message of subscribed topics | |
| int | mqtt_unsubscribe (const char *) |
| unsubscribe a single topic. | |
Protos for MQTT handling.
Definition in file mqtt.h.
| int mqtt_init | ( | const char * | server_uri | ) |
Init MQTT communication.
| server_uri | Server URI |
Definition at line 361 of file mqtt.c.
References mqtt_init_auth().

| int mqtt_init_auth | ( | const char * | server_uri, |
| const char * | username, | ||
| const char * | password ) |
Init MQTT communication.
| server_uri | Server URI |
| username | Username |
| password | Password |
Definition at line 375 of file mqtt.c.
References mqtt_t::client_id, mqtt_connect(), mqtt_get_global_password(), mqtt_get_global_server_uri(), mqtt_get_global_username(), mqtt_set_client_id(), mqtt_set_global_client(), mqtt_set_global_password(), mqtt_set_global_server_uri(), mqtt_set_global_username(), and mqtt_set_initialized_status().
Referenced by mqtt_init(), and mqtt_reinit().


| gboolean mqtt_is_initialized | ( | void | ) |
Get the global init status.
Definition at line 69 of file mqtt.c.
References mqtt_initialized.
| int mqtt_publish | ( | const char * | topic, |
| const char * | msg ) |
Publish a message on topic using the global client.
| topic | topic |
| msg | message |
Definition at line 498 of file mqtt.c.
References mqtt_client_publish(), mqtt_get_global_client(), and mqtt_reinit().

| int mqtt_publish_single_message | ( | const char * | server_uri_in, |
| const char * | topic, | ||
| const char * | msg ) |
Send a single message.
This functions creates a mqtt handle, connects, sends the message, closes the connection and destroys the handler. This function should not be chosen for repeated and frequent messaging. Its meant for error messages and the likes emitted by openvas.
| server_uri_in | Server URI |
| topic | Topic to publish to |
| msg | Message to publish |
Definition at line 527 of file mqtt.c.
References mqtt_publish_single_message_auth().

| int mqtt_publish_single_message_auth | ( | const char * | server_uri_in, |
| const char * | username_in, | ||
| const char * | passwd_in, | ||
| const char * | topic, | ||
| const char * | msg ) |
Send a single message with credentials.
This functions creates a mqtt handle, connects, sends the message, closes the connection and destroys the handler. This function should not be chosen for repeated and frequent messaging. Its meant for error messages and the likes emitted by openvas.
| server_uri_in | Server URI |
| username_in | Username |
| passwd_in | Password |
| topic | Topic to publish to |
| msg | Message to publish |
Definition at line 550 of file mqtt.c.
References mqtt_client_data_destroy(), mqtt_client_destroy(), mqtt_client_publish(), mqtt_connect(), mqtt_disconnect(), mqtt_get_global_password(), mqtt_get_global_server_uri(), mqtt_get_global_username(), and mqtt_set_client_id().
Referenced by mqtt_publish_single_message().


| void mqtt_reset | ( | void | ) |
Destroy MQTTClient handle and free mqtt_t.
Definition at line 212 of file mqtt.c.
References mqtt_client_data_destroy(), mqtt_client_destroy(), mqtt_get_global_client(), and mqtt_set_global_client().

| int mqtt_retrieve_message | ( | char ** | topic, |
| int * | topic_len, | ||
| char ** | payload, | ||
| int * | payload_len, | ||
| const unsigned int | timeout ) |
wait for a given timeout in ms to retrieve any message of subscribed topics
This function performs a synchronous receive of incoming messages. Using this function allows a single-threaded client subscriber application to be written. When called, this function blocks until the next message arrives or the specified timeout expires.
Important note: The application must free() the memory allocated to the topic and payload when processing is complete.
| [out] | topic | The address of a pointer to a topic. This function allocates the memory for the topic and returns it to the application by setting topic to point to the topic. |
| [out] | topic_len | The length of the topic. |
| [out] | payload | The address of a pointer to the received message. This function allocates the memory for the payload and returns it to the application by setting payload to point to the received message. The pointer is set to NULL if the timeout expires. |
| [out] | payload_len | The length of the payload. |
| timeout | The length of time to wait for a message in milliseconds. |
Definition at line 837 of file mqtt.c.
References mqtt_get_global_client(), and mqtt_retrieve_message_r().

| int mqtt_subscribe | ( | const char * | topic | ) |
subscribes to a single topic.
mqtt_subscribe uses global mqtt_t to subscribe with global qos to given topic.
To be able to subscribe to a topic the client needs to be connected to a broker. To do that call mqtt_init before mqtt_subscribe.
| topic | Topic to subscribe to |
Definition at line 660 of file mqtt.c.
References mqtt_get_global_client(), mqtt_reinit(), mqtt_subscribe_r(), and QOS.

| int mqtt_unsubscribe | ( | const char * | topic | ) |
unsubscribe a single topic.
This function unsubscribes global client from a given topic.
| topic | Topic to unsubscribe from |
Definition at line 705 of file mqtt.c.
References mqtt_get_global_client(), and mqtt_unsubscribe_r().
