Add mosquitto_plugin_set_info()

This allows plugins to tell the broker their name and version.
This commit is contained in:
Roger A. Light
2021-09-07 23:13:06 +01:00
parent aa29b45e70
commit 3413001d47
19 changed files with 137 additions and 7 deletions
@@ -43,6 +43,8 @@ Contributors:
#include "mqtt_protocol.h"
#define TS_BUF_LEN (14+1) // 14 characters in unix epoch (ms) is ≈16 Nov 5138
#define PLUGIN_NAME "add-properties"
#define PLUGIN_VERSION "1.0"
static mosquitto_plugin_id_t *mosq_pid = NULL;
@@ -106,6 +108,7 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
UNUSED(opt_count);
mosq_pid = identifier;
mosquitto_plugin_set_info(identifier, PLUGIN_NAME, PLUGIN_VERSION);
return mosquitto_callback_register(mosq_pid, MOSQ_EVT_MESSAGE, callback_message, NULL, NULL);
}
@@ -42,6 +42,9 @@ Contributors:
#include "mosquitto.h"
#include "mqtt_protocol.h"
#define PLUGIN_NAME "auth-by-ip"
#define PLUGIN_VERSION "1.0"
static mosquitto_plugin_id_t *mosq_pid = NULL;
static int basic_auth_callback(int event, void *event_data, void *userdata)
@@ -80,6 +83,7 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
UNUSED(opt_count);
mosq_pid = identifier;
mosquitto_plugin_set_info(identifier, PLUGIN_NAME, PLUGIN_VERSION);
return mosquitto_callback_register(mosq_pid, MOSQ_EVT_BASIC_AUTH, basic_auth_callback, NULL, NULL);
}
@@ -19,6 +19,9 @@
#include "mosquitto.h"
#include "mqtt_protocol.h"
#define PLUGIN_NAME "client-properties"
#define PLUGIN_VERSION "1.0"
#define UNUSED(A) (void)(A)
static mosquitto_plugin_id_t *mosq_pid = NULL;
@@ -57,6 +60,7 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
UNUSED(opt_count);
mosq_pid = identifier;
mosquitto_plugin_set_info(identifier, PLUGIN_NAME, PLUGIN_VERSION);
return mosquitto_callback_register(mosq_pid, MOSQ_EVT_MESSAGE, callback_message, NULL, NULL);
}
@@ -40,6 +40,9 @@ Contributors:
#include "mosquitto.h"
#include "mqtt_protocol.h"
#define PLUGIN_NAME "connection-state"
#define PLUGIN_VERSION "1.0"
#define UNUSED(A) (void)(A)
static mosquitto_plugin_id_t *mosq_pid = NULL;
@@ -115,6 +118,7 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
UNUSED(opt_count);
mosq_pid = identifier;
mosquitto_plugin_set_info(identifier, PLUGIN_NAME, PLUGIN_VERSION);
rc = mosquitto_callback_register(mosq_pid, MOSQ_EVT_CONNECT, connect_callback, NULL, NULL);
if(rc) return rc;
@@ -44,6 +44,9 @@ Contributors:
#include "mosquitto.h"
#include "mqtt_protocol.h"
#define PLUGIN_NAME "delayed-auth"
#define PLUGIN_VERSION "1.0"
#ifndef UNUSED
# define UNUSED(A) (void)(A)
#endif
@@ -156,6 +159,7 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
UNUSED(opt_count);
mosq_pid = identifier;
mosquitto_plugin_set_info(identifier, PLUGIN_NAME, PLUGIN_VERSION);
rc = mosquitto_callback_register(mosq_pid, MOSQ_EVT_BASIC_AUTH, basic_auth_callback, NULL, NULL);
if(rc) return rc;
@@ -37,6 +37,9 @@ Contributors:
#include "mosquitto.h"
#include "mqtt_protocol.h"
#define PLUGIN_NAME "force-retain"
#define PLUGIN_VERSION "1.0"
#define UNUSED(A) (void)(A)
static mosquitto_plugin_id_t *mosq_pid = NULL;
@@ -72,6 +75,7 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
UNUSED(opt_count);
mosq_pid = identifier;
mosquitto_plugin_set_info(identifier, PLUGIN_NAME, PLUGIN_VERSION);
return mosquitto_callback_register(mosq_pid, MOSQ_EVT_MESSAGE, callback_message, NULL, NULL);
}
@@ -38,6 +38,9 @@ Contributors:
#include "mosquitto.h"
#include "mqtt_protocol.h"
#define PLUGIN_NAME "message-timestamp"
#define PLUGIN_VERSION "1.0"
static mosquitto_plugin_id_t *mosq_pid = NULL;
static int callback_message(int event, void *event_data, void *userdata)
@@ -76,6 +79,7 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
UNUSED(opt_count);
mosq_pid = identifier;
mosquitto_plugin_set_info(identifier, PLUGIN_NAME, PLUGIN_VERSION);
return mosquitto_callback_register(mosq_pid, MOSQ_EVT_MESSAGE, callback_message, NULL, NULL);
}
@@ -40,6 +40,9 @@ Contributors:
#include "mosquitto.h"
#include "mqtt_protocol.h"
#define PLUGIN_NAME "payload-modification"
#define PLUGIN_VERSION "1.0"
#define UNUSED(A) (void)(A)
static mosquitto_plugin_id_t *mosq_pid = NULL;
@@ -99,6 +102,7 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
UNUSED(opt_count);
mosq_pid = identifier;
mosquitto_plugin_set_info(identifier, PLUGIN_NAME, PLUGIN_VERSION);
return mosquitto_callback_register(mosq_pid, MOSQ_EVT_MESSAGE, callback_message, NULL, NULL);
}
@@ -10,6 +10,9 @@
#include "mosquitto.h"
#include "mqtt_protocol.h"
#define PLUGIN_NAME "print-ip-on-publish"
#define PLUGIN_VERSION "1.0"
static mosquitto_plugin_id_t *mosq_pid = NULL;
static char my_topic[] = "troublesome/topic";
@@ -46,6 +49,7 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
UNUSED(opt_count);
mosq_pid = identifier;
mosquitto_plugin_set_info(identifier, PLUGIN_NAME, PLUGIN_VERSION);
return mosquitto_callback_register(mosq_pid, MOSQ_EVT_MESSAGE, message_callback, NULL, NULL);
}