Skip to content

Commit

Permalink
[linux] add ThreadStackManager for Linux Device layer
Browse files Browse the repository at this point in the history
  • Loading branch information
gjc13 committed Jun 30, 2020
1 parent e5f93b4 commit 7507cfe
Show file tree
Hide file tree
Showing 17 changed files with 862 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@
path = third_party/openthread/repo
url = https://github.com/openthread/openthread
ignore = dirty
[submodule "third_party/ot-br-posix/repo"]
path = third_party/ot-br-posix/repo
url = https://github.com/openthread/ot-br-posix.git
ignore = dirty
47 changes: 47 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,52 @@ if test "${nl_cv_build_tests}" = "yes"; then
fi
fi

#
# otbr-client
#

AC_ARG_ENABLE(otbr-client,
[AS_HELP_STRING([--enable-otbr-client], [Enable OpenThread Linux client])],
[
case "${enableval}" in
no|yes)
enable_otbr_client=${enableval}
;;
*)
AC_MSG_ERROR([Invalid value ${enableval} for --enable-java])
;;
esac
],
[ enable_otbr_client="no" ]
)

AC_MSG_NOTICE("enable_otbr_client=${enable_otbr_client}")

if test "${enable_otbr_client}" = "yes"; then
maybe_otbr_client_dirstem="ot-br-posix"
otbr_client_dirstem="third_party/${maybe_otbr_client_dirstem}/repo"

AC_MSG_NOTICE([attempting to create internal ${otbrclient_dirstem}])

${MAKE-make} --no-print-directory -C ${srcdir} -f Makefile-bootstrap ${otbr_client_dirstem}

if test $? -ne 0; then
AC_MSG_ERROR([failed to create ${otbr_client_dirstem}. Please check your network connection or the correctness of 'repos.conf'])
fi

# otbrclient requires dbus
PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.4)
AC_SUBST([DBUS_CFLAGS])
AC_SUBST([DBUS_LIBS])
else
maybe_otbr_client_dirstem=
fi

AC_SUBST(OTBR_CLIENT_SUBDIRS, [${maybe_otbr_client_dirstem}])
AM_CONDITIONAL([CHIP_WITH_OTBR_CLIENT], [test "${enable_otbr_client}" != "no"])

#
# Nlunit-test
Expand Down Expand Up @@ -2147,6 +2193,7 @@ examples/Makefile
third_party/Makefile
third_party/lwip/Makefile
third_party/mbedtls/Makefile
third_party/ot-br-posix/Makefile
src/Makefile
src/include/Makefile
src/app/Makefile
Expand Down
5 changes: 5 additions & 0 deletions repos.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@
url = https://github.com/openthread/openthread.git
branch = master
update = none
[submodule "ot-br-posix"]
path = third_party/ot-br-posix/repo
url = https://github.com/openthread/ot-br-posix.git
branch = master
update = none
1 change: 1 addition & 0 deletions scripts/setup/linux/install_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ apt-get install -fy \
libssl-dev \
unzip \
wget \
libdbus-1-dev \
libmbedtls-dev

if [[ ! -f 'ci-cache-persistent/openssl/open_ssl_1.1.1f_installed' ]]; then
Expand Down
2 changes: 2 additions & 0 deletions src/include/platform/PlatformManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class PlatformManagerImpl;
class ConnectivityManagerImpl;
class ConfigurationManagerImpl;
class TraitManager;
class ThreadStackManagerImpl;
class TimeSyncManager;
namespace Internal {
class FabricProvisioningServer;
Expand Down Expand Up @@ -97,6 +98,7 @@ class PlatformManager
friend class ConnectivityManagerImpl;
friend class ConfigurationManagerImpl;
friend class TraitManager;
friend class ThreadStackManagerImpl;
friend class TimeSyncManager;
friend class Internal::FabricProvisioningServer;
friend class Internal::ServiceProvisioningServer;
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/ThreadStackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ThreadStackManager
void LockThreadStack(void);
bool TryLockThreadStack(void);
void UnlockThreadStack(void);
bool HaveRouteToAddress(const IPAddress & destAddr);
bool HaveRouteToAddress(const Inet::IPAddress & destAddr);
CHIP_ERROR GetAndLogThreadStatsCounters(void);
CHIP_ERROR GetAndLogThreadTopologyMinimal(void);
CHIP_ERROR GetAndLogThreadTopologyFull(void);
Expand Down
74 changes: 74 additions & 0 deletions src/include/platform/internal/DeviceNetworkInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2018 Nest Labs, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef DEVICE_NETWORK_INFO_H
#define DEVICE_NETWORK_INFO_H

#include <stdint.h>

namespace chip {
namespace DeviceLayer {
namespace Internal {

/**
* Ids for well-known network provision types.
*/
enum
{
kThreadNetworkId = 1,
kWiFiStationNetworkId = 2,
kMaxThreadNetworkNameLength = 16,
kThreadExtendedPANIdLength = 8,
kThreadMeshPrefixLength = 8,
kThreadNetworkKeyLength = 16,
kThreadPSKcLength = 16,
kThreadChannel_NotSpecified = UINT8_MAX,
kThreadPANId_NotSpecified = UINT16_MAX,
};

class DeviceNetworkInfo
{
public:
// ---- Thread-specific Fields ----
char ThreadNetworkName[kMaxThreadNetworkNameLength + 1];
/**< The Thread network name as a NULL-terminated string. */
uint8_t ThreadExtendedPANId[kThreadExtendedPANIdLength];
/**< The Thread extended PAN ID. */
uint8_t ThreadMeshPrefix[kThreadMeshPrefixLength];
/**< The Thread mesh prefix. */
uint8_t ThreadNetworkKey[kThreadNetworkKeyLength];
/**< The Thread master network key (NOT NULL-terminated). */
uint8_t ThreadPSKc[kThreadPSKcLength];
/**< The Thread pre-shared commissioner key (NOT NULL-terminated). */
uint16_t ThreadPANId; /**< The 16-bit Thread PAN ID, or kThreadPANId_NotSpecified */
uint8_t ThreadChannel; /**< The Thread channel (currently [11..26]), or kThreadChannel_NotSpecified */

struct
{
bool ThreadExtendedPANId : 1;
bool ThreadMeshPrefix : 1;
bool ThreadPSKc : 1;
} FieldPresent;
};

} // namespace Internal
} // namespace DeviceLayer
} // namespace chip

#endif // DEVICE_NETWORK_INFO_H
Loading

0 comments on commit 7507cfe

Please sign in to comment.