aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-05-10 23:24:25 -0700
committerGitHub <noreply@github.com>2021-05-10 23:24:25 -0700
commita4d4d018809694be087c41d3c801490c74905536 (patch)
treef95941a1d3b91b76e18dc34ae0f2ea1d816aa647 /src
parent57b831c0172b336aa842d09514d7c7201231656c (diff)
downloadot-br-posix-a4d4d018809694be087c41d3c801490c74905536.tar.gz
submodule: bump third_party/openthread/repo from `5b6654d` to `0f65243` (#839)
Bumps [third_party/openthread/repo](https://github.com/openthread/openthread) from `5b6654d` to `0f65243`. - [Commits](https://github.com/openthread/openthread/compare/5b6654d0bccaad436193a08a79a545e8a22b64a0...0f65243d6338308c7571d066ac08ad2ff0cc9f18) Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'src')
-rw-r--r--src/web/web-service/ot_client.cpp22
-rw-r--r--src/web/web-service/ot_client.hpp12
-rw-r--r--src/web/web-service/wpan_service.cpp16
3 files changed, 33 insertions, 17 deletions
diff --git a/src/web/web-service/ot_client.cpp b/src/web/web-service/ot_client.cpp
index 501153bb..7eb862d4 100644
--- a/src/web/web-service/ot_client.cpp
+++ b/src/web/web-service/ot_client.cpp
@@ -48,15 +48,22 @@
#include "utils/strcpy_utils.hpp"
// Temporary solution before posix platform header files are cleaned up.
-#ifndef OPENTHREAD_POSIX_APP_SOCKET_NAME
-#define OPENTHREAD_POSIX_APP_SOCKET_NAME "/tmp/openthread.sock"
+#ifndef OPENTHREAD_POSIX_DAEMON_SOCKET_NAME
+#ifdef __linux__
+#define OPENTHREAD_POSIX_CONFIG_DAEMON_SOCKET_BASENAME "/run/openthread-%s"
+#else
+#define OPENTHREAD_POSIX_CONFIG_DAEMON_SOCKET_BASENAME "/tmp/openthread-%s"
+#endif
+#define OPENTHREAD_POSIX_DAEMON_SOCKET_NAME OPENTHREAD_POSIX_CONFIG_DAEMON_SOCKET_BASENAME ".sock"
#endif
namespace otbr {
namespace Web {
-OpenThreadClient::OpenThreadClient(void)
- : mTimeout(kDefaultTimeout)
+OpenThreadClient::OpenThreadClient(const char *aNetifName)
+
+ : mNetifName(aNetifName)
+ , mTimeout(kDefaultTimeout)
, mSocket(-1)
{
}
@@ -85,7 +92,12 @@ bool OpenThreadClient::Connect(void)
memset(&sockname, 0, sizeof(struct sockaddr_un));
sockname.sun_family = AF_UNIX;
- strcpy_safe(sockname.sun_path, sizeof(sockname.sun_path), OPENTHREAD_POSIX_APP_SOCKET_NAME);
+ ret = snprintf(sockname.sun_path, sizeof(sockname.sun_path), OPENTHREAD_POSIX_DAEMON_SOCKET_NAME, mNetifName);
+
+ VerifyOrExit(ret >= 0 && static_cast<size_t>(ret) < sizeof(sockname.sun_path), {
+ errno = EINVAL;
+ ret = -1;
+ });
ret = connect(mSocket, reinterpret_cast<const struct sockaddr *>(&sockname), sizeof(struct sockaddr_un));
diff --git a/src/web/web-service/ot_client.hpp b/src/web/web-service/ot_client.hpp
index 03ce3957..193046f6 100644
--- a/src/web/web-service/ot_client.hpp
+++ b/src/web/web-service/ot_client.hpp
@@ -70,8 +70,11 @@ public:
/**
* This constructor creates an OpenThread client.
*
+ * @param[in] aNetifName The Thread network interface name.
+ *
*/
- OpenThreadClient(void);
+ OpenThreadClient(const char *aNetifName);
+
/**
* This destructor destories an OpenThread client.
*
@@ -124,9 +127,10 @@ private:
kDefaultTimeout = 800, ///< Default timeout(ms) waiting for a command finish.
};
- char mBuffer[kBufferSize];
- int mTimeout; /// Timeout in milliseconds
- int mSocket;
+ const char *mNetifName;
+ char mBuffer[kBufferSize];
+ int mTimeout; /// Timeout in milliseconds
+ int mSocket;
};
} // namespace Web
diff --git a/src/web/web-service/wpan_service.cpp b/src/web/web-service/wpan_service.cpp
index 2234d777..b18e934c 100644
--- a/src/web/web-service/wpan_service.cpp
+++ b/src/web/web-service/wpan_service.cpp
@@ -61,7 +61,7 @@ std::string WpanService::HandleJoinNetworkRequest(const std::string &aJoinReques
std::string prefix;
bool defaultRoute;
int ret = kWpanStatus_Ok;
- otbr::Web::OpenThreadClient client;
+ otbr::Web::OpenThreadClient client(mIfName);
VerifyOrExit(client.Connect(), ret = kWpanStatus_SetFailed);
@@ -116,7 +116,7 @@ std::string WpanService::HandleFormNetworkRequest(const std::string &aFormReques
uint64_t extPanId;
bool defaultRoute;
int ret = kWpanStatus_Ok;
- otbr::Web::OpenThreadClient client;
+ otbr::Web::OpenThreadClient client(mIfName);
VerifyOrExit(client.Connect(), ret = kWpanStatus_SetFailed);
@@ -173,7 +173,7 @@ std::string WpanService::HandleAddPrefixRequest(const std::string &aAddPrefixReq
std::string prefix;
bool defaultRoute;
int ret = kWpanStatus_Ok;
- otbr::Web::OpenThreadClient client;
+ otbr::Web::OpenThreadClient client(mIfName);
VerifyOrExit(client.Connect(), ret = kWpanStatus_SetFailed);
@@ -212,7 +212,7 @@ std::string WpanService::HandleDeletePrefixRequest(const std::string &aDeleteReq
std::string response;
std::string prefix;
int ret = kWpanStatus_Ok;
- otbr::Web::OpenThreadClient client;
+ otbr::Web::OpenThreadClient client(mIfName);
VerifyOrExit(client.Connect(), ret = kWpanStatus_SetFailed);
@@ -247,7 +247,7 @@ std::string WpanService::HandleStatusRequest()
Json::FastWriter jsonWriter;
std::string response, networkName, extPanId, propertyValue;
int ret = kWpanStatus_Ok;
- otbr::Web::OpenThreadClient client;
+ otbr::Web::OpenThreadClient client(mIfName);
char * rval;
networkInfo["WPAN service"] = "uninitialized";
@@ -390,7 +390,7 @@ std::string WpanService::HandleAvailableNetworkRequest()
Json::FastWriter jsonWriter;
std::string response;
int ret = kWpanStatus_Ok;
- otbr::Web::OpenThreadClient client;
+ otbr::Web::OpenThreadClient client(mIfName);
VerifyOrExit(client.Connect(), ret = kWpanStatus_ScanFailed);
VerifyOrExit((mNetworksCount = client.Scan(mNetworks, sizeof(mNetworks) / sizeof(mNetworks[0]))) > 0,
@@ -426,7 +426,7 @@ exit:
int WpanService::GetWpanServiceStatus(std::string &aNetworkName, std::string &aExtPanId) const
{
int status = kWpanStatus_Ok;
- otbr::Web::OpenThreadClient client;
+ otbr::Web::OpenThreadClient client(mIfName);
const char * rval;
VerifyOrExit(client.Connect(), status = kWpanStatus_Uninitialized);
@@ -470,7 +470,7 @@ std::string WpanService::HandleCommission(const std::string &aCommissionRequest)
pskd = root["pskd"].asString();
{
- otbr::Web::OpenThreadClient client;
+ otbr::Web::OpenThreadClient client(mIfName);
VerifyOrExit(client.Connect(), ret = kWpanStatus_Uninitialized);