Integrate obuspa 8.0.1.9.

This commit is contained in:
Markus Gothe 2024-07-31 18:38:53 +02:00
parent f161417d64
commit 834921f50b

View file

@ -5,7 +5,7 @@
#endif
+#ifdef OBUSPA_CONTROLLER_MTP_VERIFY
+bool DEVICE_CONTROLLER_IsMTPAllowed(char *endpoint_id, mtp_reply_to_t *mrt);
+bool DEVICE_CONTROLLER_IsMTPAllowed(char *endpoint_id, mtp_conn_t *mpc);
+#endif
+
#ifndef REMOVE_USP_BROKER
@ -26,12 +26,12 @@
+** This function is used by ValidateUspRecord() to determine whether to process a received USP message
+**
+** \param endpoint_id - Endpoint ID of controller that sent a USP message
+** \param mrt - pointer to structure specifying on which MTP the message was received
+** \param mpc - pointer to structure specifying on which MTP the message was received
+**
+** \return true if the MTP is allowed, false otherwise
+**
+**************************************************************************/
+bool DEVICE_CONTROLLER_IsMTPAllowed(char *endpoint_id, mtp_reply_to_t *mrt)
+bool DEVICE_CONTROLLER_IsMTPAllowed(char *endpoint_id, mtp_conn_t *mpc)
+{
+ controller_t *cont = FindEnabledControllerByEndpointId(endpoint_id);
+ controller_mtp_t *mtp;
@ -42,18 +42,18 @@
+ return false;
+ }
+
+ mtp = FindFirstEnabledMtp(cont, mrt->protocol);
+ mtp = FindFirstEnabledMtp(cont, mpc->protocol);
+
+#ifdef ENABLE_WEBSOCKETS
+ // Allow websocket server if no other MTP is configured
+ if ((mrt->protocol == kMtpProtocol_WebSockets) && (mrt->wsserv_conn_id != INVALID))
+ if ((mpc->protocol == kMtpProtocol_WebSockets) && (mpc->ws.serv_conn_id != INVALID))
+ {
+ return mtp == NULL;
+ }
+#endif
+
+ // Disallow if there is no MTP configured with matching protocol
+ if ((mtp == NULL) || (mtp->protocol != mrt->protocol))
+ if ((mtp == NULL) || (mtp->protocol != mpc->protocol))
+ {
+ return false;
+ }
@ -63,7 +63,7 @@
+ {
+#ifndef DISABLE_STOMP
+ case kMtpProtocol_STOMP:
+ return mtp->stomp_connection_instance == mrt->stomp_instance;
+ return mtp->stomp_connection_instance == mpc->stomp.instance;
+#endif
+
+#ifdef ENABLE_COAP
@ -73,12 +73,12 @@
+
+#ifdef ENABLE_MQTT
+ case kMtpProtocol_MQTT:
+ return mtp->mqtt_connection_instance == mrt->mqtt_instance;
+ return mtp->mqtt_connection_instance == mpc->mqtt.instance;
+#endif
+
+#ifdef ENABLE_WEBSOCKETS
+ case kMtpProtocol_WebSockets:
+ return (mrt->wsclient_cont_instance == cont->instance) && (mrt->wsclient_mtp_instance == mtp->instance);
+ return (mpc->ws.client_cont_instance == cont->instance) && (mpc->ws.client_mtp_instance == mtp->instance);
+#endif
+ default:
+ TERMINATE_BAD_CASE(mtp->protocol);
@ -100,7 +100,7 @@
+#ifdef OBUSPA_CONTROLLER_MTP_VERIFY
+ // Exit if the controller is not allowed to use the MTP on which the message was received
+ if (DEVICE_CONTROLLER_IsMTPAllowed(rec->from_id, mrt) == false)
+ if (DEVICE_CONTROLLER_IsMTPAllowed(rec->from_id, mtpc) == false)
+ {
+ USP_ERR_SetMessage("%s: Ignoring message from endpoint_id=%s (unauthorized MTP)", __FUNCTION__, rec->from_id);
+ return USP_ERR_PERMISSION_DENIED;