forked from home-assistant/addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
silabs-multiprotocol: Update to upstream REST API (home-assistant#3067)
* silabs-multiprotocol: Update to upstream REST API Update the local patches to use the upstream REST API variant. This is a breaking change and requires an Home Assistant Core update. * Update major version since this is an API break * Correct Core requirements
- Loading branch information
Showing
16 changed files
with
1,231 additions
and
463 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
silabs-multiprotocol/0001-dataset-add-otDatasetUpdateTlvs-API-8871.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
From b60d9aaaee4f72b403c55684bb8464e27b12b3c1 Mon Sep 17 00:00:00 2001 | ||
Message-Id: <b60d9aaaee4f72b403c55684bb8464e27b12b3c1.1685020982.git.stefan@agner.ch> | ||
From: Jonathan Hui <[email protected]> | ||
Date: Wed, 15 Mar 2023 18:36:39 -0700 | ||
Subject: [PATCH] [dataset] add `otDatasetUpdateTlvs` API (#8871) | ||
|
||
--- | ||
include/openthread/dataset.h | 27 +++++++++++++++++++++++++++ | ||
src/core/api/dataset_api.cpp | 29 +++++++++++++++++++++++++++++ | ||
2 files changed, 56 insertions(+) | ||
|
||
diff --git a/include/openthread/dataset.h b/include/openthread/dataset.h | ||
index 3edf952ba..04bb874bc 100644 | ||
--- a/include/openthread/dataset.h | ||
+++ b/include/openthread/dataset.h | ||
@@ -594,6 +594,33 @@ otError otNetworkNameFromString(otNetworkName *aNetworkName, const char *aNameSt | ||
*/ | ||
otError otDatasetParseTlvs(const otOperationalDatasetTlvs *aDatasetTlvs, otOperationalDataset *aDataset); | ||
|
||
+/** | ||
+ * Converts a given Operational Dataset to `otOperationalDatasetTlvs`. | ||
+ * | ||
+ * @param[in] aDataset An Operational dataset to convert to TLVs. | ||
+ * @param[out] aDatasetTlvs A pointer to dataset TLVs to return the result. | ||
+ * | ||
+ * @retval OT_ERROR_NONE Successfully converted @p aDataset and updated @p aDatasetTlvs. | ||
+ * @retval OT_ERROR_INVALID_ARGS @p aDataset is invalid, does not contain active or pending timestamps. | ||
+ * | ||
+ */ | ||
+otError otDatasetConvertToTlvs(const otOperationalDataset *aDataset, otOperationalDatasetTlvs *aDatasetTlvs); | ||
+ | ||
+/** | ||
+ * Updates a given Operational Dataset. | ||
+ * | ||
+ * @p aDataset contains the fields to be updated and their new value. | ||
+ * | ||
+ * @param[in] aDataset Specifies the set of types and values to update. | ||
+ * @param[in,out] aDatasetTlvs A pointer to dataset TLVs to update. | ||
+ * | ||
+ * @retval OT_ERROR_NONE Successfully updated @p aDatasetTlvs. | ||
+ * @retval OT_ERROR_INVALID_ARGS @p aDataset contains invalid values. | ||
+ * @retval OT_ERROR_NO_BUFS Not enough space space in @p aDatasetTlvs to apply the update. | ||
+ * | ||
+ */ | ||
+otError otDatasetUpdateTlvs(const otOperationalDataset *aDataset, otOperationalDatasetTlvs *aDatasetTlvs); | ||
+ | ||
/** | ||
* @} | ||
* | ||
diff --git a/src/core/api/dataset_api.cpp b/src/core/api/dataset_api.cpp | ||
index f8d14f608..075ae3abd 100644 | ||
--- a/src/core/api/dataset_api.cpp | ||
+++ b/src/core/api/dataset_api.cpp | ||
@@ -168,3 +168,32 @@ otError otDatasetParseTlvs(const otOperationalDatasetTlvs *aDatasetTlvs, otOpera | ||
exit: | ||
return error; | ||
} | ||
+ | ||
+otError otDatasetConvertToTlvs(const otOperationalDataset *aDataset, otOperationalDatasetTlvs *aDatasetTlvs) | ||
+{ | ||
+ Error error = kErrorNone; | ||
+ MeshCoP::Dataset dataset; | ||
+ | ||
+ AssertPointerIsNotNull(aDatasetTlvs); | ||
+ | ||
+ SuccessOrExit(error = dataset.SetFrom(AsCoreType(aDataset))); | ||
+ dataset.ConvertTo(*aDatasetTlvs); | ||
+ | ||
+exit: | ||
+ return error; | ||
+} | ||
+ | ||
+otError otDatasetUpdateTlvs(const otOperationalDataset *aDataset, otOperationalDatasetTlvs *aDatasetTlvs) | ||
+{ | ||
+ Error error = kErrorNone; | ||
+ MeshCoP::Dataset dataset; | ||
+ | ||
+ AssertPointerIsNotNull(aDatasetTlvs); | ||
+ | ||
+ dataset.SetFrom(*aDatasetTlvs); | ||
+ SuccessOrExit(error = dataset.SetFrom(AsCoreType(aDataset))); | ||
+ dataset.ConvertTo(*aDatasetTlvs); | ||
+ | ||
+exit: | ||
+ return error; | ||
+} | ||
-- | ||
2.40.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
From c2dc2a9940d1f9809403d4dfb28e1f942ef90bab Mon Sep 17 00:00:00 2001 | ||
Message-Id: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1673530580[email protected]> | ||
Message-Id: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160[email protected]> | ||
From: Stefan Agner <[email protected]> | ||
Date: Fri, 16 Dec 2022 06:20:03 +0100 | ||
Subject: [PATCH 01/10] [web/rest] listen on IPv6 addresses as well (#1659) | ||
Subject: [PATCH] [web/rest] listen on IPv6 addresses as well (#1659) | ||
|
||
Make the Web and REST API listen on IPv4 and IPv6 by default. | ||
|
||
|
@@ -78,5 +78,5 @@ index e5f47f52c2..c49047dc89 100644 | |
std::unique_ptr<otbr::Web::WebServer> sServer(nullptr); | ||
|
||
-- | ||
2.39.0 | ||
2.40.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
From 9a624b0ce0f5565a94663693f7690367c95c9d9b Mon Sep 17 00:00:00 2001 | ||
Message-Id: <9a624b0ce0f5565a94663693f7690367c95c9d9b.1673530580[email protected]> | ||
In-Reply-To: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1673530580[email protected]> | ||
References: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1673530580[email protected]> | ||
Message-Id: <9a624b0ce0f5565a94663693f7690367c95c9d9b.1684999160[email protected]> | ||
In-Reply-To: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160[email protected]> | ||
References: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160[email protected]> | ||
From: Stefan Agner <[email protected]> | ||
Date: Fri, 16 Dec 2022 07:34:07 +0100 | ||
Subject: [PATCH 02/10] [rest] add active dataset API (#1658) | ||
Subject: [PATCH] [rest] add active dataset API (#1658) | ||
|
||
Support setting active dataset using HTTP PUT method. The body | ||
needs to be formatted as a hex string representing the operational | ||
|
@@ -210,5 +210,5 @@ index c20d9c1699..addc7d2cbb 100644 | |
kStatusMethodNotAllowed = 405, | ||
kStatusRequestTimeout = 408, | ||
-- | ||
2.39.0 | ||
2.40.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
From 1fd0572e7ceeb0f7dff59f7a9bdbe8519fb332ec Mon Sep 17 00:00:00 2001 | ||
Message-Id: <1fd0572e7ceeb0f7dff59f7a9bdbe8519fb332ec.1673530580[email protected]> | ||
In-Reply-To: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1673530580[email protected]> | ||
References: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1673530580[email protected]> | ||
Message-Id: <1fd0572e7ceeb0f7dff59f7a9bdbe8519fb332ec.1684999160[email protected]> | ||
In-Reply-To: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160[email protected]> | ||
References: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160[email protected]> | ||
From: Stefan Agner <[email protected]> | ||
Date: Tue, 20 Dec 2022 07:22:01 +0100 | ||
Subject: [PATCH 03/10] [rest] use map for HTTP headers (#1665) | ||
Subject: [PATCH] [rest] use map for HTTP headers (#1665) | ||
|
||
(cherry picked from commit 2ff52570fdb1a2daa7c93e0aae7e6cb551322252) | ||
--- | ||
|
@@ -91,5 +91,5 @@ index ecfe98f4de..8ae24ffe30 100644 | |
|
||
} // namespace rest | ||
-- | ||
2.39.0 | ||
2.40.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
From 2e2f6018e1ae48432f5b9eec97f7ca737a3cd871 Mon Sep 17 00:00:00 2001 | ||
Message-Id: <2e2f6018e1ae48432f5b9eec97f7ca737a3cd871.1673530580[email protected]> | ||
In-Reply-To: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1673530580[email protected]> | ||
References: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1673530580[email protected]> | ||
Message-Id: <2e2f6018e1ae48432f5b9eec97f7ca737a3cd871.1684999160[email protected]> | ||
In-Reply-To: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160[email protected]> | ||
References: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160[email protected]> | ||
From: Stefan Agner <[email protected]> | ||
Date: Thu, 22 Dec 2022 16:34:59 +0100 | ||
Subject: [PATCH 05/10] [web] bump to latest Simple-Web-Server version (#1667) | ||
Subject: [PATCH] [web] bump to latest Simple-Web-Server version (#1667) | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset=UTF-8 | ||
Content-Transfer-Encoding: 8bit | ||
|
@@ -10280,5 +10280,5 @@ index 0000000000..cac7dfa442 | |
+ | ||
+#endif // SIMPLE_WEB_UTILITY_HPP | ||
-- | ||
2.39.0 | ||
2.40.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
From 8959300846adcd0d8dc43c553d54cbc753a7c942 Mon Sep 17 00:00:00 2001 | ||
Message-Id: <8959300846adcd0d8dc43c553d54cbc753a7c942.1673530580[email protected]> | ||
In-Reply-To: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1673530580[email protected]> | ||
References: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1673530580[email protected]> | ||
Message-Id: <8959300846adcd0d8dc43c553d54cbc753a7c942.1684999160[email protected]> | ||
In-Reply-To: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160[email protected]> | ||
References: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160[email protected]> | ||
From: Stefan Agner <[email protected]> | ||
Date: Fri, 23 Dec 2022 04:00:41 +0100 | ||
Subject: [PATCH 06/10] [rest] allow to specify REST listen address (#1670) | ||
Subject: [PATCH] [rest] allow to specify REST listen address (#1670) | ||
|
||
Allow to bind to a specific address to listen to for REST requests. This | ||
allows to limit access to the REST interface e.g. from localhost only. | ||
|
@@ -202,5 +202,5 @@ index 9a5a49ca4a..97e36b37e0 100644 | |
bool SetFdNonblocking(int32_t fd); | ||
|
||
-- | ||
2.39.0 | ||
2.40.1 | ||
|
33 changes: 33 additions & 0 deletions
33
silabs-multiprotocol/0007-rest-remove-superfluous-space-in-HTTP-status-line-17.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
From edcd1f6a875cbbde5803662c595a7485da14d391 Mon Sep 17 00:00:00 2001 | ||
Message-Id: <edcd1f6a875cbbde5803662c595a7485da14d391.1684999160.git.stefan@agner.ch> | ||
In-Reply-To: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160.git.stefan@agner.ch> | ||
References: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160.git.stefan@agner.ch> | ||
From: Stefan Agner <[email protected]> | ||
Date: Tue, 17 Jan 2023 19:31:59 +0100 | ||
Subject: [PATCH] [rest] remove superfluous space in HTTP status line (#1713) | ||
|
||
A space is already added in Response::Serialize(). According to the HTTP | ||
specification there should only be a single space between the protcol | ||
version and the status code. | ||
|
||
(cherry picked from commit 10a181ee914eb9641eaf416e3747a0a360a41ede) | ||
--- | ||
src/rest/response.cpp | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/src/rest/response.cpp b/src/rest/response.cpp | ||
index 2cdfc80ea5..bcf63a6c31 100644 | ||
--- a/src/rest/response.cpp | ||
+++ b/src/rest/response.cpp | ||
@@ -45,7 +45,7 @@ Response::Response(void) | ||
, mComplete(false) | ||
{ | ||
// HTTP protocol | ||
- mProtocol = "HTTP/1.1 "; | ||
+ mProtocol = "HTTP/1.1"; | ||
|
||
// Pre-defined headers | ||
mHeaders["Content-Type"] = OT_REST_RESPONSE_CONTENT_TYPE_JSON; | ||
-- | ||
2.40.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
From 65a87b8e2beabccf22fe5fc27cacb98dd9ba05dc Mon Sep 17 00:00:00 2001 | ||
Message-Id: <65a87b8e2beabccf22fe5fc27cacb98dd9ba05dc.1673530580[email protected]> | ||
In-Reply-To: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1673530580[email protected]> | ||
References: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1673530580[email protected]> | ||
From fcfe69e94666fb8a21fcb0c474f7d350a5790cbf Mon Sep 17 00:00:00 2001 | ||
Message-Id: <fcfe69e94666fb8a21fcb0c474f7d350a5790cbf.1684999160[email protected]> | ||
In-Reply-To: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160[email protected]> | ||
References: <c2dc2a9940d1f9809403d4dfb28e1f942ef90bab.1684999160[email protected]> | ||
From: Stefan Agner <[email protected]> | ||
Date: Thu, 12 Jan 2023 14:35:04 +0100 | ||
Subject: [PATCH 10/10] [rest] explicitly set Connection header to close | ||
Date: Thu, 2 Mar 2023 03:12:46 +0100 | ||
Subject: [PATCH] [rest] explicitly set Connection header to close (#1774) | ||
|
||
By default, HTTP 1.1 connections should stay open after a transaction. | ||
However, that is not how the current REST server implementation behaves: | ||
|
@@ -13,23 +13,25 @@ server. | |
|
||
Set the Connection header to "close" to tell the client about this | ||
behavior. | ||
|
||
(cherry picked from commit 0e8af359120ee051314c1afb2bec2107c5bdf38d) | ||
--- | ||
src/rest/response.cpp | 2 ++ | ||
1 file changed, 2 insertions(+) | ||
|
||
diff --git a/src/rest/response.cpp b/src/rest/response.cpp | ||
index 540a0840e0..5c08fd77b4 100644 | ||
index bcf63a6c31..2fd536c546 100644 | ||
--- a/src/rest/response.cpp | ||
+++ b/src/rest/response.cpp | ||
@@ -35,6 +35,7 @@ | ||
@@ -36,6 +36,7 @@ | ||
"Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, " \ | ||
"Access-Control-Request-Headers" | ||
#define OT_REST_RESPONSE_ACCESS_CONTROL_ALLOW_METHOD "GET, OPTIONS, POST, PUT" | ||
#define OT_REST_RESPONSE_ACCESS_CONTROL_ALLOW_METHOD "GET" | ||
+#define OT_REST_RESPONSE_CONNECTION "close" | ||
|
||
namespace otbr { | ||
namespace rest { | ||
@@ -51,6 +52,7 @@ Response::Response(void) | ||
@@ -52,6 +53,7 @@ Response::Response(void) | ||
mHeaders["Access-Control-Allow-Origin"] = OT_REST_RESPONSE_ACCESS_CONTROL_ALLOW_ORIGIN; | ||
mHeaders["Access-Control-Allow-Methods"] = OT_REST_RESPONSE_ACCESS_CONTROL_ALLOW_METHOD; | ||
mHeaders["Access-Control-Allow-Headers"] = OT_REST_RESPONSE_ACCESS_CONTROL_ALLOW_HEADERS; | ||
|
@@ -38,5 +40,5 @@ index 540a0840e0..5c08fd77b4 100644 | |
|
||
void Response::SetComplete() | ||
-- | ||
2.39.0 | ||
2.40.1 | ||
|
Oops, something went wrong.