diff --git a/include/neu_adapter.h b/include/neu_adapter.h index 508872bb..1eed5e4d 100644 --- a/include/neu_adapter.h +++ b/include/neu_adapter.h @@ -83,9 +83,6 @@ typedef enum neu_reqresp_type { NEU_REQRESP_GET_SUB_GRP_CONFIGS, NEU_REQRESP_SUB_GRP_CONFIGS_RESP, NEU_REQRESP_VALIDATE_TAG, - NEU_REQRESP_GET_LIC_VAL, - NEU_REQRESP_LIC_VAL, - NEU_REQRESP_UPDATE_LIC, } neu_reqresp_type_e; typedef uint32_t neu_node_id_t; @@ -142,7 +139,6 @@ typedef enum neu_node_type { NEU_NODE_TYPE_MQTT, NEU_NODE_TYPE_STREAM_PROCESSOR, NEU_NODE_TYPE_APP, - NEU_NODE_TYPE_LICENSE, NEU_NODE_TYPE_FUNCTIONAL, NEU_NODE_TYPE_MAX, } neu_node_type_e; @@ -320,24 +316,6 @@ typedef struct neu_reqresp_sub_grp_configs { vector_t *sub_grp_configs; } neu_reqresp_sub_grp_configs_t; -/* NEU_REQRESP_GET_LIC_VAL */ -typedef struct { - const char *lic_fname; // don't take ownership - const char *key_name; // don't take ownership -} neu_reqresp_get_lic_val_t; - -/* NEU_REQRESP_LIC_VAL */ -typedef struct { - const char * lic_fname; // don't take ownership - const char * key_name; // don't take ownership - neu_data_val_t *val; -} neu_reqresp_lic_val_t; - -/* NEU_REQRESP_UPDATE_LIC */ -typedef struct { - const char *lic_fname; // don't take ownership -} neu_reqresp_update_lic_t; - typedef enum neu_adapter_ctl { NEU_ADAPTER_CTL_START = 0, NEU_ADAPTER_CTL_STOP, @@ -382,7 +360,6 @@ typedef enum neu_event_type { NEU_EVENT_ADD_TAGS, NEU_EVENT_UPDATE_TAGS, NEU_EVENT_DEL_TAGS, - NEU_EVENT_LIC_UPDATED, } neu_event_type_e; typedef struct neu_event_notify { @@ -404,11 +381,6 @@ typedef struct neu_event_tags { char * grp_config_name; } neu_event_tags_t; -typedef struct { - neu_node_id_t node_id; - const char * lic_fname; // don't take ownership -} neu_event_lic_updated_t; - /** * definition enum and structure for neuron config */ diff --git a/include/neu_license.h b/include/neu_license.h deleted file mode 100644 index 031e8e06..00000000 --- a/include/neu_license.h +++ /dev/null @@ -1,62 +0,0 @@ -/** - * NEURON IIoT System for Industry 4.0 - * Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - **/ - -#ifndef __NEU_LICENSE_H__ -#define __NEU_LICENSE_H__ - -#define NEURON_LIC_DIR "cert" -#define NEURON_LIC_FNAME "neuron.lic" - -// License type -// Type: string -#define NEURON_LIC_KEY_LICENSE_TYPE "1.3.6.1.4.1.52509.10" - -// Max number of plugins. -// Type: integer, non-negative -#define NEURON_LIC_KEY_PLUGINS_NUM_MAX "1.3.6.1.4.1.52509.11" - -// Max number of nodes. -// Type: integer, non-negative -#define NEURON_LIC_KEY_NODES_NUM_MAX "1.3.6.1.4.1.52509.12" - -// Max number of tags globally. -// Type: integer, non-negative -#define NEURON_LIC_KEY_TAGS_NUM_MAX "1.3.6.1.4.1.52509.13" - -// If modbus_plus_tcp plugin enabled. -// Type: integer, 0 | 1 -#define NEURON_LIC_KEY_MODBUS_PLUS_TCP_ENABLED "1.3.6.1.4.1.52509.14" - -// If modbus_rtu plugin enabled -// Type: integer, 0 | 1 -#define NEURON_LIC_KEY_MODBUS_RTU_ENABLED "1.3.6.1.4.1.52509.15" - -// If opcua plugin enabled -// Type: integer, 0 | 1 -#define NEURON_LIC_KEY_OPCUA_ENABLED "1.3.6.1.4.1.52509.16" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif // __NEU_LICENSE_H__ diff --git a/include/neu_plugin.h b/include/neu_plugin.h index d42a3d96..18e00ae6 100644 --- a/include/neu_plugin.h +++ b/include/neu_plugin.h @@ -114,8 +114,6 @@ void neu_plugin_send_write_cmd(neu_plugin_t *plugin, uint32_t event_id, neu_node_id_t node_id, neu_taggrp_config_t *grp_configs, neu_data_val_t * data); -void neu_plugin_send_lic_cmd(neu_plugin_t *plugin, uint32_t event_id, - const char *license_fname, const char *key); void neu_plugin_response_trans_data(neu_plugin_t * plugin, neu_taggrp_config_t *grp_config, neu_data_val_t *data, uint32_t event_id); @@ -134,9 +132,6 @@ int neu_plugin_notify_event_del_tags(neu_plugin_t *plugin, uint32_t event_id, int neu_plugin_notify_event_update_tags(neu_plugin_t *plugin, uint32_t event_id, neu_node_id_t node_id, const char * grp_config_name); -int neu_plugin_notify_event_update_lic(neu_plugin_t *plugin, uint32_t event_id, - neu_node_id_t node_id, - const char * lic_fname); intptr_t neu_system_del_plugin(neu_plugin_t *plugin, plugin_id_t plugin_id); intptr_t neu_system_update_plugin(neu_plugin_t *plugin, plugin_kind_e kind, diff --git a/include/neuron.h b/include/neuron.h index f9f196f8..d0e5d9c6 100644 --- a/include/neuron.h +++ b/include/neuron.h @@ -27,7 +27,6 @@ extern "C" { #include "neu_adapter.h" #include "neu_base64.h" #include "neu_file.h" -#include "neu_license.h" #include "neu_list.h" #include "neu_log.h" #include "neu_panic.h" diff --git a/plugins/sample/plugin_sample_app.c b/plugins/sample/plugin_sample_app.c index 76abde44..3b9efcf9 100644 --- a/plugins/sample/plugin_sample_app.c +++ b/plugins/sample/plugin_sample_app.c @@ -24,7 +24,6 @@ #include #include -#include "neu_license.h" #include "neuron.h" const neu_plugin_module_t neu_plugin_module; @@ -317,14 +316,6 @@ get_grp_configs_retry: usleep(500000); log_info("Restart a node(%d)", dst_node_id); neu_plugin_node_ctl(plugin, dst_node_id, NEU_ADAPTER_CTL_START); - - /* example of get license key value */ - neu_plugin_send_lic_cmd(plugin, plugin_get_event_id(plugin), - NEURON_LIC_FNAME, NEURON_LIC_KEY_LICENSE_TYPE); - log_info("Send get license:`%s` key:`%s`", NEURON_LIC_FNAME, - NEURON_LIC_KEY_LICENSE_TYPE); - usleep(500000); - return NULL; } @@ -539,30 +530,6 @@ static int sample_app_plugin_request(neu_plugin_t *plugin, neu_request_t *req) break; } - case NEU_REQRESP_LIC_VAL: { - char * val = NULL; - neu_reqresp_lic_val_t *lic_val = req->buf; - assert(req->buf_len == sizeof(neu_reqresp_lic_val_t)); - if (NULL != lic_val->val) { - neu_dvalue_get_ref_cstr(lic_val->val, &val); - } - log_info("sample app receive license:`%s` key:`%s`, val:`%s`", - lic_val->lic_fname, lic_val->key_name, val); - break; - } - - case NEU_REQRESP_UPDATE_LIC: { - neu_reqresp_update_lic_t *lic_update = req->buf; - assert(req->buf_len == sizeof(*lic_update)); - log_info("sample app receive license update request:`%s`", - lic_update->lic_fname); - neu_plugin_send_lic_cmd(plugin, plugin_get_event_id(plugin), - NEURON_LIC_FNAME, NEURON_LIC_KEY_LICENSE_TYPE); - log_info("Send get license:`%s` key:`%s`", NEURON_LIC_FNAME, - NEURON_LIC_KEY_LICENSE_TYPE); - break; - } - default: break; } diff --git a/src/adapter/adapter.c b/src/adapter/adapter.c index c30b0977..fdfc4788 100644 --- a/src/adapter/adapter.c +++ b/src/adapter/adapter.c @@ -923,24 +923,6 @@ static void adapter_loop(void *arg) break; } - case MSG_EVENT_LIC_UPDATED: { - neu_event_lic_updated_t *lic_event = msg_get_buf_ptr(pay_msg); - neu_reqresp_update_lic_t lic_update = {}; - lic_update.lic_fname = lic_event->lic_fname; - - const neu_plugin_intf_funs_t *intf_funs; - neu_request_t req; - - intf_funs = adapter->plugin_module->intf_funs; - req.req_id = adapter_get_req_id(adapter); - req.req_type = NEU_REQRESP_UPDATE_LIC; - req.sender_id = 0; - req.buf_len = sizeof(lic_update); - req.buf = &lic_update; - intf_funs->request(adapter->plugin, &req); - break; - } - case MSG_CMD_SUBSCRIBE_NODE: { subscribe_node_cmd_t *cmd_ptr; cmd_ptr = (subscribe_node_cmd_t *) msg_get_buf_ptr(pay_msg); @@ -1109,48 +1091,6 @@ static void adapter_loop(void *arg) break; } - case MSG_CMD_GET_LIC_VAL: { - get_lic_val_cmd_t *cmd_ptr = msg_get_buf_ptr(pay_msg); - - const neu_plugin_intf_funs_t *intf_funs; - neu_request_t req; - neu_reqresp_get_lic_val_t lic_req; - - lic_req.lic_fname = cmd_ptr->lic_fname; - lic_req.key_name = cmd_ptr->key_name; - - intf_funs = adapter->plugin_module->intf_funs; - req.req_id = cmd_ptr->req_id; - req.req_type = NEU_REQRESP_GET_LIC_VAL; - req.sender_id = cmd_ptr->sender_id; - req.buf_len = sizeof(lic_req); - req.buf = (void *) &lic_req; - intf_funs->request(adapter->plugin, &req); - break; - } - - case MSG_DATA_LIC_RESP: { - lic_val_resp_t *lic_resp = msg_get_buf_ptr(pay_msg); - - const neu_plugin_intf_funs_t *intf_funs; - neu_request_t req; - neu_reqresp_lic_val_t lic_val; - - lic_val.lic_fname = lic_resp->lic_fname; - lic_val.key_name = lic_resp->key_name; - lic_val.val = lic_resp->val; // don't take ownership - - intf_funs = adapter->plugin_module->intf_funs; - req.req_id = lic_resp->req_id; - req.req_type = NEU_REQRESP_LIC_VAL; - req.sender_id = 0; - req.buf_len = sizeof(lic_val); - req.buf = (void *) &lic_val; - intf_funs->request(adapter->plugin, &req); - neu_dvalue_free(lic_val.val); - break; - } - case MSG_CMD_EXIT_LOOP: { uint32_t exit_code; @@ -1596,19 +1536,6 @@ static int adapter_command(neu_adapter_t *adapter, neu_request_t *cmd, break; } - case NEU_REQRESP_GET_LIC_VAL: { - neu_reqresp_get_lic_val_t *lic_req = cmd->buf; - get_lic_val_cmd_t lic_cmd = {}; - lic_cmd.sender_id = to_node_id(adapter, adapter->id); - lic_cmd.req_id = cmd->req_id; - lic_cmd.lic_fname = lic_req->lic_fname; - lic_cmd.key_name = lic_req->key_name; - - ADAPTER_SEND_BUF(adapter, rv, MSG_CMD_GET_LIC_VAL, &lic_cmd, - sizeof(lic_cmd)); - break; - } - default: rv = -1; break; @@ -1730,34 +1657,6 @@ static int adapter_response(neu_adapter_t *adapter, neu_response_t *resp) break; } - case NEU_REQRESP_LIC_VAL: { - neu_reqresp_lic_val_t *lic_val = resp->buf; - assert(resp->buf_len == sizeof(*lic_val)); - - lic_val_resp_t lic_resp; - lic_resp.recver_id = resp->recver_id; - lic_resp.req_id = resp->req_id; - lic_resp.lic_fname = lic_val->lic_fname; - lic_resp.key_name = lic_val->key_name; - lic_resp.val = lic_val->val; // ownership transferred - - nng_msg *msg = nng_msg_inplace_from_buf(MSG_DATA_LIC_RESP, &lic_resp, - sizeof(lic_resp)); - if (NULL == msg) { - log_error("unable to allocate NEU_REQRESP_LIC_VAL message."); - neu_dvalue_free(lic_resp.val); - break; - } - - rv = nng_sendmsg(adapter->sock, msg, 0); - if (0 != rv) { - neu_dvalue_free(lic_resp.val); - nng_msg_free(msg); - log_error("fail to send NEU_REQRESP_LIC_VAL message."); - } - break; - } - default: break; } @@ -1794,12 +1693,6 @@ static int adapter_event_notify(neu_adapter_t * adapter, break; } - case NEU_EVENT_LIC_UPDATED: { - ADAPTER_SEND_BUF(adapter, rv, MSG_EVENT_LIC_UPDATED, event->buf, - event->buf_len); - break; - } - default: break; } diff --git a/src/adapter/adapter_info.h b/src/adapter/adapter_info.h index c6578ca6..7d20d2f5 100644 --- a/src/adapter/adapter_info.h +++ b/src/adapter/adapter_info.h @@ -31,7 +31,6 @@ typedef enum adapter_type { ADAPTER_TYPE_MQTT, ADAPTER_TYPE_STREAM_PROCESSOR, ADAPTER_TYPE_APP, - ADAPTER_TYPE_LICENSE, ADAPTER_TYPE_FUNCTIONAL, ADAPTER_TYPE_MAX, } adapter_type_e; diff --git a/src/base/neu_plugin_common.c b/src/base/neu_plugin_common.c index 3efe65c0..81f9603c 100644 --- a/src/base/neu_plugin_common.c +++ b/src/base/neu_plugin_common.c @@ -301,18 +301,6 @@ void neu_plugin_send_write_cmd(neu_plugin_t *plugin, uint32_t event_id, PLUGIN_SEND_CMD(plugin, NEU_REQRESP_WRITE_DATA, write_req, event_id) } -void neu_plugin_send_lic_cmd(neu_plugin_t *plugin, uint32_t event_id, - const char *license_fname, const char *key) -{ - - neu_reqresp_get_lic_val_t lic_req = { - .lic_fname = license_fname, - .key_name = key, - }; - - PLUGIN_SEND_CMD(plugin, NEU_REQRESP_GET_LIC_VAL, lic_req, event_id) -} - static inline int plugin_notify_tags_event(neu_plugin_t * plugin, uint32_t event_id, neu_event_type_e type, @@ -363,27 +351,6 @@ int neu_plugin_notify_event_update_tags(neu_plugin_t *plugin, uint32_t event_id, node_id, grp_config_name); } -int neu_plugin_notify_event_update_lic(neu_plugin_t *plugin, uint32_t event_id, - neu_node_id_t node_id, - const char * lic_fname) -{ - neu_event_lic_updated_t lic_event = { - .node_id = node_id, - .lic_fname = lic_fname, - }; - - neu_event_notify_t event = { - .event_id = event_id, - .type = NEU_EVENT_LIC_UPDATED, - .buf = &lic_event, - .buf_len = sizeof(lic_event), - }; - - neu_plugin_common_t *plugin_common = neu_plugin_to_plugin_common(plugin); - return plugin_common->adapter_callbacks->event_notify( - plugin_common->adapter, &event); -} - void neu_plugin_response_trans_data(neu_plugin_t * plugin, neu_taggrp_config_t *grp_config, neu_data_val_t *data, uint32_t event_id) diff --git a/src/core/message.h b/src/core/message.h index 9dfe1eb6..907e98de 100644 --- a/src/core/message.h +++ b/src/core/message.h @@ -39,7 +39,6 @@ typedef enum msg_type { MSG_CMD_SUBSCRIBE_NODE, MSG_CMD_UNSUBSCRIBE_NODE, MSG_CMD_GROUP_CONFIG_CHANGED, - MSG_CMD_GET_LIC_VAL, MSG_CMD_PERSISTENCE_LOAD, MSG_CMD_EXIT_LOOP, MSG_CMD_RESP_PONG, // response pong for ping @@ -76,14 +75,12 @@ typedef enum msg_type { MSG_EVENT_ADD_TAGS, MSG_EVENT_UPDATE_TAGS, MSG_EVENT_DEL_TAGS, - MSG_EVENT_LIC_UPDATED, MSG_TYPE_EVENT_END, MSG_TYPE_DATA_START = 0x3000, MSG_DATA_NEURON_TRANS_DATA = MSG_TYPE_DATA_START, MSG_DATA_READ_RESP, MSG_DATA_WRITE_RESP, - MSG_DATA_LIC_RESP, MSG_TYPE_DATA_END, // User customer message types @@ -156,14 +153,6 @@ typedef struct grp_config_changed_cmd { neu_node_id_t dst_node_id; } grp_config_changed_cmd_t; -/* MSG_CMD_GET_LIC_VAL */ -typedef struct { - adapter_id_t sender_id; - uint32_t req_id; - const char * lic_fname; // don't take ownership - const char * key_name; // don't take ownership -} get_lic_val_cmd_t; - /* MSG_EVENT_GROUP_CONFIG_CHANGED */ typedef struct grp_config_changed_event { neu_taggrp_config_t *grp_config; @@ -195,15 +184,6 @@ typedef struct write_data_resp { uint32_t req_id; } write_data_resp_t; -/* MSG_DATA_LIC_RESP */ -typedef struct { - adapter_id_t recver_id; - uint32_t req_id; - const char * lic_fname; // don't take ownership - const char * key_name; // don't take ownership - neu_data_val_t *val; -} lic_val_resp_t; - typedef struct message message_t; // get size of message diff --git a/src/core/neu_manager.c b/src/core/neu_manager.c index 37c785ed..7e2eefed 100644 --- a/src/core/neu_manager.c +++ b/src/core/neu_manager.c @@ -95,7 +95,6 @@ static const char *const manager_url = "inproc://neu_manager"; #define WEBSERVER_PLUGIN_LIB_NAME "libplugin-webserver-proxy.so" #define MQTT_PLUGIN_LIB_NAME "libplugin-mqtt.so" #define MODBUS_TCP_PLUGIN_LIB_NAME "libplugin-modbus-tcp.so" -#define LICENSE_PLUGIN_LIB_NAME "libplugin-license.so" #endif @@ -107,7 +106,6 @@ static const char *const manager_url = "inproc://neu_manager"; // definition for adapter names #define DEFAULT_DASHBOARD_ADAPTER_NAME "default-dashboard-adapter" #define DEFAULT_PERSIST_ADAPTER_NAME "default-persist-adapter" -#define DEFAULT_LICENSE_ADAPTER_NAME "default-license-adapter" #define WEBSERVER_ADAPTER_NAME "webserver-adapter" #define ADAPTER_NAME_MAX_LEN 90 @@ -1022,8 +1020,6 @@ static void manager_loop(void *arg) nng_mtx_lock(manager->adapters_mtx); adapter_reg_entity_t *persist_reg_entity = find_reg_adapter_by_name( &manager->reg_adapters, DEFAULT_PERSIST_ADAPTER_NAME); - adapter_reg_entity_t *license_reg_entity = find_reg_adapter_by_name( - &manager->reg_adapters, DEFAULT_LICENSE_ADAPTER_NAME); nng_mtx_unlock(manager->adapters_mtx); nng_pipe persist_pipe = persist_reg_entity->adapter_pipe; @@ -1281,25 +1277,6 @@ static void manager_loop(void *arg) break; } - case MSG_EVENT_LIC_UPDATED: { - neu_event_lic_updated_t *lic_event = msg_get_buf_ptr(pay_msg); - - nng_mtx_lock(manager->adapters_mtx); - adapter_reg_entity_t *reg_entity = find_reg_adapter_by_id( - &manager->reg_adapters, lic_event->node_id); - nng_mtx_unlock(manager->adapters_mtx); - - nng_pipe msg_pipe = reg_entity->adapter_pipe; - rv = manager_send_msg_to_pipe(manager, msg_pipe, - MSG_EVENT_LIC_UPDATED, lic_event, - sizeof(*lic_event)); - if (0 == rv) { - log_info("Forward license update event to pipe: %d", msg_pipe); - } - - break; - } - case MSG_CMD_SUBSCRIBE_NODE: { subscribe_node_cmd_t *cmd_ptr = msg_get_buf_ptr(pay_msg); rv = neu_manager_subscribe_node(manager, cmd_ptr); @@ -1383,41 +1360,6 @@ static void manager_loop(void *arg) break; } - case MSG_CMD_GET_LIC_VAL: { - if (NULL == license_reg_entity) { - log_warn("Drop license command due to no license adapter"); - break; - } - nng_pipe lic_pipe = license_reg_entity->adapter_pipe; - msg_type_e msg_type = msg_get_type(pay_msg); - void * buf = msg_get_buf_ptr(pay_msg); - size_t size = msg_get_buf_len(pay_msg); - rv = manager_send_msg_to_pipe(manager, lic_pipe, msg_type, buf, - size); - if (0 == rv) { - log_info("Forward license command to pipe: %d", lic_pipe); - } - break; - } - - case MSG_DATA_LIC_RESP: { - lic_val_resp_t *lic_resp = msg_get_buf_ptr(pay_msg); - - nng_mtx_lock(manager->adapters_mtx); - adapter_reg_entity_t *reg_entity = find_reg_adapter_by_id( - &manager->reg_adapters, lic_resp->recver_id); - nng_mtx_unlock(manager->adapters_mtx); - - nng_pipe msg_pipe = reg_entity->adapter_pipe; - rv = manager_send_msg_to_pipe(manager, msg_pipe, MSG_DATA_LIC_RESP, - lic_resp, sizeof(*lic_resp)); - if (0 == rv) { - log_info("Forward license val resp to pipe: %d", msg_pipe); - } - - break; - } - default: log_warn("Receive a not supported message(type: %d)", msg_get_type(pay_msg)); @@ -1563,10 +1505,6 @@ static adapter_type_e adapter_type_from_node_type(neu_node_type_e node_type) adapter_type = ADAPTER_TYPE_APP; break; - case NEU_NODE_TYPE_LICENSE: - adapter_type = ADAPTER_TYPE_LICENSE; - break; - case NEU_NODE_TYPE_FUNCTIONAL: adapter_type = ADAPTER_TYPE_FUNCTIONAL; break;