[ref]同步711

This commit is contained in:
shi_jq 2025-03-13 11:03:03 +08:00
parent 639b32bdf2
commit 5f9e992d7c
13 changed files with 3629 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,319 @@
/*
Copyright (c) 2012-2020 Roger Light <roger@atchoo.org>
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
and Eclipse Distribution License v1.0 which accompany this distribution.
The Eclipse Public License is available at
http://www.eclipse.org/legal/epl-v10.html
and the Eclipse Distribution License is available at
http://www.eclipse.org/org/documents/edl-v10.php.
Contributors:
Roger Light - initial implementation and documentation.
*/
#ifndef MOSQUITTO_PLUGIN_H
#define MOSQUITTO_PLUGIN_H
#ifdef __cplusplus
extern "C" {
#endif
#define MOSQ_AUTH_PLUGIN_VERSION 4
#define MOSQ_ACL_NONE 0x00
#define MOSQ_ACL_READ 0x01
#define MOSQ_ACL_WRITE 0x02
#define MOSQ_ACL_SUBSCRIBE 0x04
#include <stdbool.h>
#include <stdint.h>
struct mosquitto;
struct mosquitto_opt {
char *key;
char *value;
};
struct mosquitto_auth_opt {
char *key;
char *value;
};
struct mosquitto_acl_msg {
const char *topic;
const void *payload;
long payloadlen;
int qos;
bool retain;
};
/*
* To create an authentication plugin you must include this file then implement
* the functions listed in the "Plugin Functions" section below. The resulting
* code should then be compiled as a shared library. Using gcc this can be
* achieved as follows:
*
* gcc -I<path to mosquitto_plugin.h> -fPIC -shared plugin.c -o plugin.so
*
* On Mac OS X:
*
* gcc -I<path to mosquitto_plugin.h> -fPIC -shared plugin.c -undefined dynamic_lookup -o plugin.so
*
* Authentication plugins can implement one or both of authentication and
* access control. If your plugin does not wish to handle either of
* authentication or access control it should return MOSQ_ERR_PLUGIN_DEFER. In
* this case, the next plugin will handle it. If all plugins return
* MOSQ_ERR_PLUGIN_DEFER, the request will be denied.
*
* For each check, the following flow happens:
*
* * The default password file and/or acl file checks are made. If either one
* of these is not defined, then they are considered to be deferred. If either
* one accepts the check, no further checks are made. If an error occurs, the
* check is denied
* * The first plugin does the check, if it returns anything other than
* MOSQ_ERR_PLUGIN_DEFER, then the check returns immediately. If the plugin
* returns MOSQ_ERR_PLUGIN_DEFER then the next plugin runs its check.
* * If the final plugin returns MOSQ_ERR_PLUGIN_DEFER, then access will be
* denied.
*/
/* =========================================================================
*
* Helper Functions
*
* ========================================================================= */
/* There are functions that are available for plugin developers to use in
* mosquitto_broker.h, including logging and accessor functions.
*/
/* =========================================================================
*
* Plugin Functions
*
* You must implement these functions in your plugin.
*
* ========================================================================= */
/*
* Function: mosquitto_auth_plugin_version
*
* The broker will call this function immediately after loading the plugin to
* check it is a supported plugin version. Your code must simply return
* MOSQ_AUTH_PLUGIN_VERSION.
*/
int mosquitto_auth_plugin_version(void);
/*
* Function: mosquitto_auth_plugin_init
*
* Called after the plugin has been loaded and <mosquitto_auth_plugin_version>
* has been called. This will only ever be called once and can be used to
* initialise the plugin.
*
* Parameters:
*
* user_data : The pointer set here will be passed to the other plugin
* functions. Use to hold connection information for example.
* opts : Pointer to an array of struct mosquitto_opt, which
* provides the plugin options defined in the configuration file.
* opt_count : The number of elements in the opts array.
*
* Return value:
* Return 0 on success
* Return >0 on failure.
*/
int mosquitto_auth_plugin_init(void **user_data, struct mosquitto_opt *opts, int opt_count);
/*
* Function: mosquitto_auth_plugin_cleanup
*
* Called when the broker is shutting down. This will only ever be called once
* per plugin.
* Note that <mosquitto_auth_security_cleanup> will be called directly before
* this function.
*
* Parameters:
*
* user_data : The pointer provided in <mosquitto_auth_plugin_init>.
* opts : Pointer to an array of struct mosquitto_opt, which
* provides the plugin options defined in the configuration file.
* opt_count : The number of elements in the opts array.
*
* Return value:
* Return 0 on success
* Return >0 on failure.
*/
int mosquitto_auth_plugin_cleanup(void *user_data, struct mosquitto_opt *opts, int opt_count);
/*
* Function: mosquitto_auth_security_init
*
* This function is called in two scenarios:
*
* 1. When the broker starts up.
* 2. If the broker is requested to reload its configuration whilst running. In
* this case, <mosquitto_auth_security_cleanup> will be called first, then
* this function will be called. In this situation, the reload parameter
* will be true.
*
* Parameters:
*
* user_data : The pointer provided in <mosquitto_auth_plugin_init>.
* opts : Pointer to an array of struct mosquitto_opt, which
* provides the plugin options defined in the configuration file.
* opt_count : The number of elements in the opts array.
* reload : If set to false, this is the first time the function has
* been called. If true, the broker has received a signal
* asking to reload its configuration.
*
* Return value:
* Return 0 on success
* Return >0 on failure.
*/
int mosquitto_auth_security_init(void *user_data, struct mosquitto_opt *opts, int opt_count, bool reload);
/*
* Function: mosquitto_auth_security_cleanup
*
* This function is called in two scenarios:
*
* 1. When the broker is shutting down.
* 2. If the broker is requested to reload its configuration whilst running. In
* this case, this function will be called, followed by
* <mosquitto_auth_security_init>. In this situation, the reload parameter
* will be true.
*
* Parameters:
*
* user_data : The pointer provided in <mosquitto_auth_plugin_init>.
* opts : Pointer to an array of struct mosquitto_opt, which
* provides the plugin options defined in the configuration file.
* opt_count : The number of elements in the opts array.
* reload : If set to false, this is the first time the function has
* been called. If true, the broker has received a signal
* asking to reload its configuration.
*
* Return value:
* Return 0 on success
* Return >0 on failure.
*/
int mosquitto_auth_security_cleanup(void *user_data, struct mosquitto_opt *opts, int opt_count, bool reload);
/*
* Function: mosquitto_auth_acl_check
*
* Called by the broker when topic access must be checked. access will be one
* of:
* MOSQ_ACL_SUBSCRIBE when a client is asking to subscribe to a topic string.
* This differs from MOSQ_ACL_READ in that it allows you to
* deny access to topic strings rather than by pattern. For
* example, you may use MOSQ_ACL_SUBSCRIBE to deny
* subscriptions to '#', but allow all topics in
* MOSQ_ACL_READ. This allows clients to subscribe to any
* topic they want, but not discover what topics are in use
* on the server.
* MOSQ_ACL_READ when a message is about to be sent to a client (i.e. whether
* it can read that topic or not).
* MOSQ_ACL_WRITE when a message has been received from a client (i.e. whether
* it can write to that topic or not).
*
* Return:
* MOSQ_ERR_SUCCESS if access was granted.
* MOSQ_ERR_ACL_DENIED if access was not granted.
* MOSQ_ERR_UNKNOWN for an application specific error.
* MOSQ_ERR_PLUGIN_DEFER if your plugin does not wish to handle this check.
*/
int mosquitto_auth_acl_check(void *user_data, int access, struct mosquitto *client, const struct mosquitto_acl_msg *msg);
/*
* Function: mosquitto_auth_unpwd_check
*
* This function is OPTIONAL. Only include this function in your plugin if you
* are making basic username/password checks.
*
* Called by the broker when a username/password must be checked.
*
* Return:
* MOSQ_ERR_SUCCESS if the user is authenticated.
* MOSQ_ERR_AUTH if authentication failed.
* MOSQ_ERR_UNKNOWN for an application specific error.
* MOSQ_ERR_PLUGIN_DEFER if your plugin does not wish to handle this check.
*/
int mosquitto_auth_unpwd_check(void *user_data, struct mosquitto *client, const char *username, const char *password);
/*
* Function: mosquitto_psk_key_get
*
* This function is OPTIONAL. Only include this function in your plugin if you
* are making TLS-PSK checks.
*
* Called by the broker when a client connects to a listener using TLS/PSK.
* This is used to retrieve the pre-shared-key associated with a client
* identity.
*
* Examine hint and identity to determine the required PSK (which must be a
* hexadecimal string with no leading "0x") and copy this string into key.
*
* Parameters:
* user_data : the pointer provided in <mosquitto_auth_plugin_init>.
* hint : the psk_hint for the listener the client is connecting to.
* identity : the identity string provided by the client
* key : a string where the hex PSK should be copied
* max_key_len : the size of key
*
* Return value:
* Return 0 on success.
* Return >0 on failure.
* Return MOSQ_ERR_PLUGIN_DEFER if your plugin does not wish to handle this check.
*/
int mosquitto_auth_psk_key_get(void *user_data, struct mosquitto *client, const char *hint, const char *identity, char *key, int max_key_len);
/*
* Function: mosquitto_auth_start
*
* This function is OPTIONAL. Only include this function in your plugin if you
* are making extended authentication checks.
*
* Parameters:
* user_data : the pointer provided in <mosquitto_auth_plugin_init>.
* method : the authentication method
* reauth : this is set to false if this is the first authentication attempt
* on a connection, set to true if the client is attempting to
* reauthenticate.
* data_in : pointer to authentication data, or NULL
* data_in_len : length of data_in, in bytes
* data_out : if your plugin wishes to send authentication data back to the
* client, allocate some memory using malloc or friends and set
* data_out. The broker will free the memory after use.
* data_out_len : Set the length of data_out in bytes.
*
* Return value:
* Return MOSQ_ERR_SUCCESS if authentication was successful.
* Return MOSQ_ERR_AUTH_CONTINUE if the authentication is a multi step process and can continue.
* Return MOSQ_ERR_AUTH if authentication was valid but did not succeed.
* Return any other relevant positive integer MOSQ_ERR_* to produce an error.
*/
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);
int mosquitto_auth_continue(void *user_data, struct mosquitto *client, const char *method, const void *data_in, uint16_t data_in_len, void **data_out, uint16_t *data_out_len);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,146 @@
/*
Copyright (c) 2010-2019 Roger Light <roger@atchoo.org>
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
and Eclipse Distribution License v1.0 which accompany this distribution.
The Eclipse Public License is available at
http://www.eclipse.org/legal/epl-v10.html
and the Eclipse Distribution License is available at
http://www.eclipse.org/org/documents/edl-v10.php.
Contributors:
Roger Light - initial implementation and documentation.
*/
#ifndef MOSQUITTOPP_H
#define MOSQUITTOPP_H
#if defined(_WIN32) && !defined(LIBMOSQUITTO_STATIC)
# ifdef mosquittopp_EXPORTS
# define mosqpp_EXPORT __declspec(dllexport)
# else
# define mosqpp_EXPORT __declspec(dllimport)
# endif
#else
# define mosqpp_EXPORT
#endif
#if defined(__GNUC__) || defined(__clang__)
# define DEPRECATED __attribute__ ((deprecated))
#else
# define DEPRECATED
#endif
#include <cstdlib>
#include <mosquitto.h>
#include <time.h>
namespace mosqpp {
mosqpp_EXPORT const char * DEPRECATED strerror(int mosq_errno);
mosqpp_EXPORT const char * DEPRECATED connack_string(int connack_code);
mosqpp_EXPORT int DEPRECATED sub_topic_tokenise(const char *subtopic, char ***topics, int *count);
mosqpp_EXPORT int DEPRECATED sub_topic_tokens_free(char ***topics, int count);
mosqpp_EXPORT int DEPRECATED lib_version(int *major, int *minor, int *revision);
mosqpp_EXPORT int DEPRECATED lib_init();
mosqpp_EXPORT int DEPRECATED lib_cleanup();
mosqpp_EXPORT int DEPRECATED topic_matches_sub(const char *sub, const char *topic, bool *result);
mosqpp_EXPORT int DEPRECATED validate_utf8(const char *str, int len);
mosqpp_EXPORT int DEPRECATED subscribe_simple(
struct mosquitto_message **messages,
int msg_count,
bool retained,
const char *topic,
int qos=0,
const char *host="localhost",
int port=1883,
const char *client_id=NULL,
int keepalive=60,
bool clean_session=true,
const char *username=NULL,
const char *password=NULL,
const struct libmosquitto_will *will=NULL,
const struct libmosquitto_tls *tls=NULL);
mosqpp_EXPORT int DEPRECATED subscribe_callback(
int (*callback)(struct mosquitto *, void *, const struct mosquitto_message *),
void *userdata,
const char *topic,
int qos=0,
bool retained=true,
const char *host="localhost",
int port=1883,
const char *client_id=NULL,
int keepalive=60,
bool clean_session=true,
const char *username=NULL,
const char *password=NULL,
const struct libmosquitto_will *will=NULL,
const struct libmosquitto_tls *tls=NULL);
/*
* Class: mosquittopp
*
* A mosquitto client class. This is a C++ wrapper class for the mosquitto C
* library. Please see mosquitto.h for details of the functions.
*/
class mosqpp_EXPORT DEPRECATED mosquittopp {
private:
struct mosquitto *m_mosq;
public:
DEPRECATED mosquittopp(const char *id=NULL, bool clean_session=true);
virtual ~mosquittopp();
int DEPRECATED reinitialise(const char *id, bool clean_session);
int DEPRECATED socket();
int DEPRECATED will_set(const char *topic, int payloadlen=0, const void *payload=NULL, int qos=0, bool retain=false);
int DEPRECATED will_clear();
int DEPRECATED username_pw_set(const char *username, const char *password=NULL);
int DEPRECATED connect(const char *host, int port=1883, int keepalive=60);
int DEPRECATED connect_async(const char *host, int port=1883, int keepalive=60);
int DEPRECATED connect(const char *host, int port, int keepalive, const char *bind_address);
int DEPRECATED connect_async(const char *host, int port, int keepalive, const char *bind_address);
int DEPRECATED reconnect();
int DEPRECATED reconnect_async();
int DEPRECATED disconnect();
int DEPRECATED publish(int *mid, const char *topic, int payloadlen=0, const void *payload=NULL, int qos=0, bool retain=false);
int DEPRECATED subscribe(int *mid, const char *sub, int qos=0);
int DEPRECATED unsubscribe(int *mid, const char *sub);
void DEPRECATED reconnect_delay_set(unsigned int reconnect_delay, unsigned int reconnect_delay_max, bool reconnect_exponential_backoff);
int DEPRECATED max_inflight_messages_set(unsigned int max_inflight_messages);
void DEPRECATED message_retry_set(unsigned int message_retry);
void DEPRECATED user_data_set(void *userdata);
int DEPRECATED tls_set(const char *cafile, const char *capath=NULL, const char *certfile=NULL, const char *keyfile=NULL, int (*pw_callback)(char *buf, int size, int rwflag, void *userdata)=NULL);
int DEPRECATED tls_opts_set(int cert_reqs, const char *tls_version=NULL, const char *ciphers=NULL);
int DEPRECATED tls_insecure_set(bool value);
int DEPRECATED tls_psk_set(const char *psk, const char *identity, const char *ciphers=NULL);
int DEPRECATED opts_set(enum mosq_opt_t option, void *value);
int DEPRECATED loop(int timeout=-1, int max_packets=1);
int DEPRECATED loop_misc();
int DEPRECATED loop_read(int max_packets=1);
int DEPRECATED loop_write(int max_packets=1);
int DEPRECATED loop_forever(int timeout=-1, int max_packets=1);
int DEPRECATED loop_start();
int DEPRECATED loop_stop(bool force=false);
bool DEPRECATED want_write();
int DEPRECATED threaded_set(bool threaded=true);
int DEPRECATED socks5_set(const char *host, int port=1080, const char *username=NULL, const char *password=NULL);
// names in the functions commented to prevent unused parameter warning
virtual void on_connect(int /*rc*/) {return;}
virtual void on_connect_with_flags(int /*rc*/, int /*flags*/) {return;}
virtual void on_disconnect(int /*rc*/) {return;}
virtual void on_publish(int /*mid*/) {return;}
virtual void on_message(const struct mosquitto_message * /*message*/) {return;}
virtual void on_subscribe(int /*mid*/, int /*qos_count*/, const int * /*granted_qos*/) {return;}
virtual void on_unsubscribe(int /*mid*/) {return;}
virtual void on_log(int /*level*/, const char * /*str*/) {return;}
virtual void on_error() {return;}
};
}
#endif

View File

@ -29,6 +29,13 @@ else {
2、qmake输出的检测信息见qmake_info_ubuntu18.txt文件
#############
caodingfa 2023/4/10
麒麟操作系统记录参考ubuntu18的编译
QtAV.zip应该不是官方原版因为src/libQtAV.pro第一行的配置是windows下的所以需要区分平台
win32 {
QMAKE_LFLAGS += /OPT:NOREF
}
------------------------------------------------------------------------------------------------
2020/10/27

View File

@ -1,3 +1,12 @@
caodingfa
说明:
1、avbuild是一个编译ffmpeg的工具可以不用这个工具编译
2、windows版本可以从此网址下载社区预编译版 https://web.archive.org/web/20200918193047/https://ffmpeg.zeranoe.com/builds/
3、linux应该可以使用安装版暂时未验证
4、Linux也可以尝试avbuild的预编译版https://github.com/wang-bin/avbuild/wiki/Build-Windows-UWP,-Phone,-Desktop-on-Windows
5、ubuntu版本可以参见下面ubuntu18的编译过程直接解压FFmpeg其它库不需要编译
##########################################################
干宇航 2020-02-18
构建方法
0. 安装msys2

View File

@ -0,0 +1 @@
在官方ec9519a0e71354d4b2cd027f8a67d2c86797e626 2023-10-13版本上修改

View File

@ -0,0 +1,25 @@
CentOS
下载wget https://mosquitto.org/files/source/mosquitto-1.6.10.tar.gz 或 https://mosquitto.org/files/source/
编译安装:
tar zxvf mosquitto-1.6.10.tar.gz
cd mosquitto-1.6.10
make -j2 && make install
原文链接https://blog.csdn.net/Dontla/article/details/129345907
Windows:
Mosquitto是MQTT协议的服务器的开源实现支持版本5.0、3.1.1和3.1。
下面四个文件在mosquitto的目录下拷贝
libssl-3-x64.dll
libcrypto-3-x64.dll
mosquitto.dll
mosquittopp.dll
下面一个文件从C:Windows\System32下拷贝
vcruntime140_1.dll
社区页面http://mqtt.org/
MQTT v3.1.1标准https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html
MQTT v5.0标准https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html

View File

@ -0,0 +1,38 @@
官网 https://www.open62541.org/
编译成动态库进行使用--BUILD_SHARED_LIBS
windows编译
1.需要安装python3
2.configure配置cmake选择 Visual Studio 14 2015 工具链的默认编译器编译
3.BUILD_SHARED_LIBS 打开此选项.然后generate
4.open project
5.解决方案重新生成获取open62541.dll
6.所有引入的头文件都在需要按照从open62541文件夹层级拷贝
linux编译如果没有ccmake则手动更改cmakelist
1.发行版的Linux都带有python3
2.在源码目录创建build
3.ccmake ..
4. BUILD_SHARED_LIBS 打开这个选项
5.cmake ..
6.make
7.获取open62541.so
8.所有引入的头文件都在需要按照从open62541文件夹层级拷贝
由于不同平台生成出来的config.h,宏定义使用逻辑有所不同,需要修改一下
/**
* Architecture
* ------------
* Define one of the following. */
下修改为以下代码
#if defined _WIN32 || defined __CYGWIN__
#define UA_ARCHITECTURE_WIN32
#else
#define UA_ARCHITECTURE_POSIX
#endif

View File

@ -0,0 +1,70 @@
openDNP3编译说明
官方说明网站https://dnp3.github.io/docs/guide/3.0.0/
一、window编译
编译要求https://dnp3.github.io/docs/guide/3.0.0/build/requirements/
1. 手动拉下asio-asio-1-16-0、exe4cpp、ser4cpp
编译环境CMake3.31.5 visual studio 2015 机器选择X64
原本是cmake能够手动拉下以上依赖的zip文件详情查看deps下的cmake1文件但是不知道为什么该环境下拉不
下来导致编译失败后采取手动拉取并放置在deps文件下
2. 编译配置
配置后请先后点挤 Configure、Generate 生成相应文件后点击Open ProJect 打开Visual Studio 2015 进行相应库编
二、在欧拉系统用下的编译
就不要手动拉取以上依赖的外库直接cmake就行
注意cmake版本有要求 3.11以上
cmake[yuanxin@localhost ~]$ cd /home/yuanxin/pack/opendnp3/
[yuanxin@localhost opendnp3]$ ls
CHANGELOG.md CMakeLists.txt config deps generation LICENSE
NOTICE
'openDNP3'$'\261\340\322\353''˵'$'\303\367''.pdf' README.md
cmake codecov.yml cpp dotnet java profile
[yuanxin@localhost opendnp3]$ mkdir build
[yuanxin@localhost opendnp3]$ cd build/
[yuanxin@localhost build]$ ls
[yuanxin@localhost build]$ ccmake ..
[yuanxin@localhost build]$ cmake ..
-- The C compiler identification is GNU 10.3.1
-- The CXX compiler identification is GNU 10.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found clang-format: /usr/bin/clang-format
-- clang-tidy not found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yuanxin/pack/opendnp3/build
[yuanxin@localhost build]$ ccmake ..
[yuanxin@localhost build]$ ls CPackConfig.cmake CPackSourceConfig.cmake
CMakeCache.txt CMakeFiles cmake_install.cmake
cpp _deps Makefile
[yuanxin@localhost build]$ make