From c5483f81db512ee674c289d6d2c3ef93840c786b Mon Sep 17 00:00:00 2001 From: Vivek Kumar Dutta Date: Wed, 10 Jul 2024 14:07:27 +0530 Subject: [PATCH] obuspa: Integrate v8.0.5 --- obuspa/Makefile | 4 +- .../0001-validate-controller-mtp.patch | 16 +-- .../0002-supress-group-get-error.patch | 35 +----- obuspa/patches/0008-fix_cmake_warning.patch | 10 -- obuspa/patches/0011-max_controllers.patch | 6 +- .../patches/0012-check_mqtt_host_alive.patch | 102 ------------------ .../0013-mqtt-retry-param-change.patch | 76 ------------- .../0014-persist-connack-clientid.patch | 78 -------------- 8 files changed, 11 insertions(+), 316 deletions(-) delete mode 100644 obuspa/patches/0008-fix_cmake_warning.patch delete mode 100644 obuspa/patches/0012-check_mqtt_host_alive.patch delete mode 100644 obuspa/patches/0013-mqtt-retry-param-change.patch delete mode 100644 obuspa/patches/0014-persist-connack-clientid.patch diff --git a/obuspa/Makefile b/obuspa/Makefile index 4e788e946..391c2307d 100644 --- a/obuspa/Makefile +++ b/obuspa/Makefile @@ -5,13 +5,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=obuspa -PKG_VERSION:=8.0.1.11 +PKG_VERSION:=8.0.5.1 LOCAL_DEV:=0 ifneq ($(LOCAL_DEV),1) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/obuspa.git -PKG_SOURCE_VERSION:=cfa6c48dea74707e098b09745b2c9f989accd714 +PKG_SOURCE_VERSION:=4a8ed311b32c543f6a717586a68f909f9af35537 PKG_MAINTAINER:=Vivek Dutta PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_MIRROR_HASH:=skip diff --git a/obuspa/patches/0001-validate-controller-mtp.patch b/obuspa/patches/0001-validate-controller-mtp.patch index 169ee852c..2ba05be5a 100644 --- a/obuspa/patches/0001-validate-controller-mtp.patch +++ b/obuspa/patches/0001-validate-controller-mtp.patch @@ -1,10 +1,8 @@ -diff --git a/src/core/device.h b/src/core/device.h -index 5e367b7..db154a5 100644 --- a/src/core/device.h +++ b/src/core/device.h -@@ -330,6 +330,10 @@ int DEVICE_MTP_ValidateMqttReference(dm_req_t *req, char *value); - void DEVICE_CONTROLLER_SetRolesFromMqtt(int mqtt_instance, int role_instance); - char *DEVICE_CONTROLLER_GetControllerTopic(int mqtt_instance); +@@ -336,6 +336,10 @@ void DEVICE_CONTROLLER_SetInheritedRole( + int DEVICE_CONTROLLER_CountEnabledWebsockClientConnections(void); + #endif +#ifdef OBUSPA_CONTROLLER_MTP_VERIFY +bool DEVICE_CONTROLLER_IsMTPAllowed(char *endpoint_id, mtp_reply_to_t *mrt); @@ -13,11 +11,9 @@ index 5e367b7..db154a5 100644 #ifndef REMOVE_USP_BROKER int DEVICE_SUBSCRIPTION_RouteNotification(Usp__Msg *usp, int instance); bool DEVICE_SUBSCRIPTION_MarkVendorLayerSubs(int broker_instance, subs_notify_t notify_type, char *path, int group_id); -diff --git a/src/core/device_controller.c b/src/core/device_controller.c -index 97ca11d..19c91f1 100644 --- a/src/core/device_controller.c +++ b/src/core/device_controller.c -@@ -952,6 +952,78 @@ int DEVICE_CONTROLLER_QueueBinaryMessage(mtp_send_item_t *msi, char *endpoint_id +@@ -967,6 +967,78 @@ int DEVICE_CONTROLLER_QueueBinaryMessage return USP_ERR_OK; } @@ -96,11 +92,9 @@ index 97ca11d..19c91f1 100644 /*********************************************************************//** ** ** DEVICE_CONTROLLER_IsMTPConfigured -diff --git a/src/core/msg_handler.c b/src/core/msg_handler.c -index 2a04d39..0b3074b 100644 --- a/src/core/msg_handler.c +++ b/src/core/msg_handler.c -@@ -1206,6 +1206,15 @@ int ValidateUspRecord(UspRecord__Record *rec, mtp_conn_t *mtpc) +@@ -1210,6 +1210,15 @@ int ValidateUspRecord(UspRecord__Record usp_service_instance = USP_BROKER_GetUspServiceInstance(rec->from_id, 0); #endif diff --git a/obuspa/patches/0002-supress-group-get-error.patch b/obuspa/patches/0002-supress-group-get-error.patch index 0f087e9a1..72b9de5ed 100644 --- a/obuspa/patches/0002-supress-group-get-error.patch +++ b/obuspa/patches/0002-supress-group-get-error.patch @@ -1,6 +1,6 @@ --- a/src/core/cli_server.c +++ b/src/core/cli_server.c -@@ -758,10 +758,6 @@ int ExecuteCli_Get(char *arg1, char *arg +@@ -785,10 +785,6 @@ int ExecuteCli_Get(char *arg1, char *arg USP_ASSERT(gge->value != NULL); SendCliResponse("%s => %s\n", gge->path, gge->value); } @@ -11,36 +11,3 @@ } GROUP_GET_VECTOR_Destroy(&ggv); ---- a/src/core/handle_get.c -+++ b/src/core/handle_get.c -@@ -260,26 +260,16 @@ void FormPathExprResponse(int get_expr_i - return; - } - -- // If there was an error in getting any of the parameters associated with the path expression, -- // then just add the first error, without any of the parameter values, for this path expression result -- for (i=0; i < gi->num_entries; i++) -- { -- gge = &ggv->vector[gi->index + i]; -- if (gge->err_code != USP_ERR_OK) -- { -- (void)AddGetResp_ReqPathRes(resp, path_expr, gge->err_code, gge->err_msg); -- return; -- } -- } -- - // If the code gets here, then the value of all parameters were retrieved successfully, so add their values to the result_params - req_path_result = AddGetResp_ReqPathRes(resp, path_expr, USP_ERR_OK, ""); - for (i=0; i < gi->num_entries; i++) - { - gge = &ggv->vector[gi->index + i]; - -- // Simple format contains a resolved_path_result for every object (and sub object) -- AddResolvedPathResult(req_path_result, gge->path, gge->value); -+ if (gge->err_code == USP_ERR_OK) { -+ // Simple format contains a resolved_path_result for every object (and sub object) -+ AddResolvedPathResult(req_path_result, gge->path, gge->value); -+ } - } - } - diff --git a/obuspa/patches/0008-fix_cmake_warning.patch b/obuspa/patches/0008-fix_cmake_warning.patch deleted file mode 100644 index c2d0d573c..000000000 --- a/obuspa/patches/0008-fix_cmake_warning.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/src/protobuf-c/protobuf-c.c -+++ b/src/protobuf-c/protobuf-c.c -@@ -1926,6 +1926,7 @@ repeated_field_pack_to_buffer(const Prot - buffer->append(buffer, rv, scratch); - tmp = pack_buffer_packed_payload(field, count, array, buffer); - assert(tmp == payload_len); -+ (void)tmp; // Keep cmake production build happy - return rv + payload_len; - } else { - size_t siz; diff --git a/obuspa/patches/0011-max_controllers.patch b/obuspa/patches/0011-max_controllers.patch index 0858032d2..82cf2cdf1 100644 --- a/obuspa/patches/0011-max_controllers.patch +++ b/obuspa/patches/0011-max_controllers.patch @@ -1,6 +1,6 @@ --- a/src/core/mqtt.c +++ b/src/core/mqtt.c -@@ -233,6 +233,8 @@ void HandleMqttDisconnect(mqtt_client_t +@@ -241,6 +241,8 @@ void AddConnackSubscription(mqtt_client_ #define DEFINE_MQTT_TrustCertVerifyCallbackIndex(index) \ int MQTT_TrustCertVerifyCallback_##index (int preverify_ok, X509_STORE_CTX *x509_ctx) \ {\ @@ -9,7 +9,7 @@ return DEVICE_SECURITY_TrustCertVerifyCallbackWithCertChain(preverify_ok, x509_ctx, &mqtt_clients[index].cert_chain);\ } -@@ -243,6 +245,11 @@ DEFINE_MQTT_TrustCertVerifyCallbackIndex +@@ -251,6 +253,11 @@ DEFINE_MQTT_TrustCertVerifyCallbackIndex DEFINE_MQTT_TrustCertVerifyCallbackIndex(2); DEFINE_MQTT_TrustCertVerifyCallbackIndex(3); DEFINE_MQTT_TrustCertVerifyCallbackIndex(4); @@ -21,7 +21,7 @@ // Add more, with incrementing indexes here, if you change MAX_MQTT_CLIENTS //------------------------------------------------------------------------------------ -@@ -253,10 +260,15 @@ ssl_verify_callback_t* mqtt_verify_callb +@@ -261,10 +268,15 @@ ssl_verify_callback_t* mqtt_verify_callb MQTT_TrustCertVerifyCallbackIndex(2), MQTT_TrustCertVerifyCallbackIndex(3), MQTT_TrustCertVerifyCallbackIndex(4), diff --git a/obuspa/patches/0012-check_mqtt_host_alive.patch b/obuspa/patches/0012-check_mqtt_host_alive.patch deleted file mode 100644 index 39501b4be..000000000 --- a/obuspa/patches/0012-check_mqtt_host_alive.patch +++ /dev/null @@ -1,102 +0,0 @@ ---- a/src/core/mqtt.c -+++ b/src/core/mqtt.c -@@ -63,6 +63,8 @@ - - #include - -+#include -+ - // Defines for MQTT Property Values - #define PUBLISH 0x30 - #define CONTENT_TYPE 3 -@@ -2192,6 +2194,75 @@ exit: - } - } - -+static int _check_host_rechability(CURL *handle, curl_infotype type, char *data, size_t size, void *userp) -+{ -+ bool *palive = (bool *)userp; -+ -+ USP_ASSERT(palive != NULL); -+ switch(type) { -+ case CURLINFO_HEADER_OUT: -+ case CURLINFO_HEADER_IN: -+ *palive = true; -+ break; -+ case CURLINFO_TEXT: -+ { -+ USP_LOG_Debug("CURL DATA:: [%s]", data); -+ if (strstr(data, "Connected to ") != NULL) { -+ *palive = true; -+ } -+ break; -+ } -+ default: -+ break; -+ } -+ -+ return 0; -+} -+ -+int check_mqtt_host_reachability(mqtt_client_t *client) -+{ -+ CURL *curl; -+ mqtt_conn_params_t *cparam = &client->conn_params; -+ char buffer[128] = {0}; -+ int ret = USP_ERR_INTERNAL_ERROR; -+ bool is_alive = false; -+ -+ curl = curl_easy_init(); -+ if(curl) { -+ USP_SNPRINTF(buffer, 128, "mqtt://%s:%d", cparam->host, cparam->port); -+ curl_easy_setopt(curl, CURLOPT_URL, buffer); -+ -+ if (strlen(cparam->username) > 0) { -+ curl_easy_setopt(curl, CURLOPT_USERNAME, cparam->username); -+ } -+ -+ if (strlen(cparam->password) > 0) { -+ curl_easy_setopt(curl, CURLOPT_PASSWORD, cparam->password); -+ } -+ -+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); -+ curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &is_alive); -+ curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, _check_host_rechability); -+ -+ /* complete within 2 seconds */ -+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2L); -+ -+ ret = curl_easy_perform(curl); -+ /* Check for errors */ -+ if(ret == CURLE_OK || ret == CURLE_URL_MALFORMAT || is_alive == true) { -+ USP_LOG_Debug("CURL MQTT host %s, ret %d, alive %d ...", buffer, ret, is_alive); -+ ret = USP_ERR_OK; -+ } else { -+ USP_LOG_Info("# CURL MQTT host %s unreachable: %d=>%s ...", buffer, ret, curl_easy_strerror(ret)); -+ } -+ -+ /* always cleanup */ -+ curl_easy_cleanup(curl); -+ } -+ -+ return ret; -+} -+ - /*********************************************************************//** - ** - ** PerformMqttClientConnect -@@ -2261,6 +2332,14 @@ int PerformMqttClientConnect(mqtt_client - keep_alive = 5; - } - -+ // Below function is a workaround to check the host reachability with a timeout -+ // mosquitto_connect_* API block the thread for 2 mins if host is not reachable, -+ // which halts other clients connectivity -+ err = check_mqtt_host_reachability(client); -+ if (err != USP_ERR_OK) { -+ err = USP_ERR_INTERNAL_ERROR; -+ goto exit; -+ } - // Release the access mutex temporarily whilst performing the connect call - // We do this to prevent the data model thread from potentially being blocked, whilst the connect call is taking place - OS_UTILS_UnlockMutex(&mqtt_access_mutex); diff --git a/obuspa/patches/0013-mqtt-retry-param-change.patch b/obuspa/patches/0013-mqtt-retry-param-change.patch deleted file mode 100644 index 491f3608e..000000000 --- a/obuspa/patches/0013-mqtt-retry-param-change.patch +++ /dev/null @@ -1,76 +0,0 @@ -diff --git a/src/core/device_mqtt.c b/src/core/device_mqtt.c -index 7438e59..231d941 100755 ---- a/src/core/device_mqtt.c -+++ b/src/core/device_mqtt.c -@@ -1612,14 +1612,23 @@ int NotifyChange_MQTTRequestProblemInfo(dm_req_t *req, char *value) - int NotifyChange_MQTTConnectRetryTime(dm_req_t *req, char *value) - { - mqtt_conn_params_t *mp; -+ bool schedule_reconnect = false; - - // Determine mqtt client to be updated - mp = FindMqttParamsByInstance(inst1); - USP_ASSERT(mp != NULL); - - // Set the new value. -+ if ((mp->retry.connect_retrytime != val_uint) && (mp->enable)) { -+ schedule_reconnect = true; -+ } -+ - mp->retry.connect_retrytime = val_uint; - -+ if (schedule_reconnect) { -+ ScheduleMqttReconnect(mp); -+ } -+ - return USP_ERR_OK; - } - -@@ -1638,14 +1647,23 @@ int NotifyChange_MQTTConnectRetryTime(dm_req_t *req, char *value) - int NotifyChange_MQTTConnectRetryIntervalMultiplier(dm_req_t *req, char *value) - { - mqtt_conn_params_t *mp; -+ bool schedule_reconnect = false; - - // Determine mqtt client to be updated - mp = FindMqttParamsByInstance(inst1); - USP_ASSERT(mp != NULL); - -+ if ((mp->retry.interval_multiplier != val_int) && (mp->enable)) { -+ schedule_reconnect = true; -+ } -+ - // Set the new value. - mp->retry.interval_multiplier = val_int; - -+ if (schedule_reconnect) { -+ ScheduleMqttReconnect(mp); -+ } -+ - return USP_ERR_OK; - } - -@@ -1664,14 +1682,23 @@ int NotifyChange_MQTTConnectRetryIntervalMultiplier(dm_req_t *req, char *value) - int NotifyChange_MQTTConnectRetryMaxInterval(dm_req_t *req, char *value) - { - mqtt_conn_params_t *mp; -+ bool schedule_reconnect = false; - - // Determine mqtt client to be updated - mp = FindMqttParamsByInstance(inst1); - USP_ASSERT(mp != NULL); - -+ if ((mp->retry.max_interval != val_uint) && (mp->enable)) { -+ schedule_reconnect = true; -+ } -+ - // Set the new value. - mp->retry.max_interval = val_uint; - -+ if (schedule_reconnect) { -+ ScheduleMqttReconnect(mp); -+ } -+ - return USP_ERR_OK; - } - diff --git a/obuspa/patches/0014-persist-connack-clientid.patch b/obuspa/patches/0014-persist-connack-clientid.patch deleted file mode 100644 index e7fa5e944..000000000 --- a/obuspa/patches/0014-persist-connack-clientid.patch +++ /dev/null @@ -1,78 +0,0 @@ ---- a/src/core/mqtt.c -+++ b/src/core/mqtt.c -@@ -55,6 +55,8 @@ - #include "retry_wait.h" - #include "text_utils.h" - #include "msg_handler.h" -+#include "data_model.h" -+#include "usp_api.h" - - #include - #include -@@ -2517,6 +2519,37 @@ exit: - - /*********************************************************************//** - ** -+** handle_db_set_client_id -+** -+** Allows the caller to set client Id in DB from the data model thread -+** -+** \param arg1 - pointer to the client id path -+** \param arg2 - pointer to the client id value -+** -+** \return None -+** -+**************************************************************************/ -+void handle_db_set_client_id(void *arg1, void *arg2) -+{ -+ if ((arg1 == NULL) || (arg2 == NULL)) { -+ USP_SAFE_FREE(arg1); -+ USP_SAFE_FREE(arg2); -+ return; -+ } -+ -+ char *param_path = (char *)arg1; -+ char *param_val = (char *)arg2; -+ -+ if (USP_ERR_OK != DATA_MODEL_SetParameterInDatabase(param_path, param_val)) { -+ USP_LOG_Debug("%s: Failed to set %s=>%s from CONNACK", __FUNCTION__, param_path, param_val); -+ } -+ -+ USP_SAFE_FREE(param_path); -+ USP_SAFE_FREE(param_val); -+} -+ -+/*********************************************************************//** -+** - ** ConnectV5Callback - ** - ** Called by Libmosquitto when the CONNACK packet is received on an MQTTv5 connection -@@ -2590,8 +2623,26 @@ void ConnectV5Callback(struct mosquitto - &client_id_ptr, false /* skip first */) != NULL) - { - USP_LOG_Debug("%s: Received client_id: \"%s\"", __FUNCTION__, client_id_ptr); -- USP_SAFE_FREE(client->conn_params.client_id); -- client->conn_params.client_id = USP_STRDUP(client_id_ptr); -+ -+ if (client->conn_params.client_id == NULL || strcmp(client->conn_params.client_id, client_id_ptr) != 0) { -+ USP_SAFE_FREE(client->conn_params.client_id); -+ client->conn_params.client_id = USP_STRDUP(client_id_ptr); -+ -+ // Persist client id from CONNACK in DB -+ char buf[128] = {0}, *param_path = NULL, *param_val = NULL; -+ -+ snprintf(buf, 128, "Device.MQTT.Client.%d.ClientID", instance); -+ -+ param_path = USP_STRDUP(buf); -+ param_val = USP_STRDUP(client_id_ptr); -+ -+ if (USP_ERR_OK != USP_PROCESS_DoWork(handle_db_set_client_id, param_path, param_val)) { -+ USP_LOG_Debug("%s: Failed to schedule set in data model thread for client id from CONNACK", __FUNCTION__); -+ USP_SAFE_FREE(param_path); -+ USP_SAFE_FREE(param_val); -+ } -+ } -+ - free(client_id_ptr); - } -