Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[middleware] Add function for mqtt init status #567

Merged
merged 2 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,33 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [21.10] (unreleased)
## [Middleware] (unmerged)

### Added

- Add support for volatile keys. [#460](https://github.com/greenbone/gvm-libs/pull/460)
- Possibility to use lcrypt with `$6$` (sha512) for authentication [484](https://github.com/greenbone/gvm-libs/pull/484)
- Add function to perform an alive test and get the amount of alive hosts. [495](https://github.com/greenbone/gvm-libs/pull/495)
- Add functions for sentry integration. [#502](https://github.com/greenbone/gvm-libs/pull/502) [#506](https://github.com/greenbone/gvm-libs/pull/506)
- Add basic support for mqtt.
Original
[#505](https://github.com/greenbone/gvm-libs/pull/505)
[#511](https://github.com/greenbone/gvm-libs/pull/511).
Reintroduction after Rebase
[#538](https://github.com/greenbone/gvm-libs/pull/538)
- Add function for mqtt init status [#567](https://github.com/greenbone/gvm-libs/pull/567)

### Changed

- Refactor MQTT handling [#562](https://github.com/greenbone/gvm-libs/pull/562)

### Fixed
### Removed

## [21.10] (unreleased)

### Added

- Add support for volatile keys. [#460](https://github.com/greenbone/gvm-libs/pull/460)
- Possibility to use lcrypt with `$6$` (sha512) for authentication [484](https://github.com/greenbone/gvm-libs/pull/484)
- Add function to perform an alive test and get the amount of alive hosts. [495](https://github.com/greenbone/gvm-libs/pull/495)
- Add functions for sentry integration. [#502](https://github.com/greenbone/gvm-libs/pull/502) [#506](https://github.com/greenbone/gvm-libs/pull/506)

### Changed
### Fixed
Expand Down
26 changes: 24 additions & 2 deletions util/mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@

#include "uuidutils.h" /* gvm_uuid_make */

#include <glib.h>

#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "lib mqtt"

Expand All @@ -58,6 +56,29 @@ typedef struct

static const char *global_server_uri = NULL;
static mqtt_t *global_mqtt_client = NULL;
static gboolean mqtt_initialized = FALSE;

/**
* @brief Set the global init status.

* @param Status Status of initialization.
*/
static void
mqtt_set_initialized_status (gboolean status)
{
mqtt_initialized = status;
}

/**
* @brief Get the global init status.
*
* @return Initialization status of mqtt handling.
*/
gboolean
mqtt_is_initialized ()
{
return mqtt_initialized;
}

/**
* @brief Set the global mqtt server URI.
Expand Down Expand Up @@ -324,6 +345,7 @@ mqtt_init (const char *server_uri)
mqtt_connect (mqtt, global_server_uri);

mqtt_set_global_client (mqtt);
mqtt_set_initialized_status (TRUE);

g_debug ("%s: end", __func__);
return 0;
Expand Down
4 changes: 4 additions & 0 deletions util/mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
#define _GVM_MQTT_H

#include <MQTTClient.h>
#include <glib.h>

int
mqtt_init (const char *);

gboolean
mqtt_is_initialized ();

void
mqtt_reset ();

Expand Down