nl::Weave::WeaveFabricState

#include <src/lib/core/WeaveFabricState.h>

WeaveFabricState 的向前声明。

摘要

构造函数和构造函数

WeaveFabricState(void)

公共类型

PeerIndexType typedef
uint8_t
SessionEndCbFunct)(uint16_t keyId, uint64_t peerNodeId, void *context) typedef
void(*
State 枚举

公共属性

AutoCreateKeys
bool
DebugFabricId
uint64_t
DefaultSubnet
uint16_t
FabricId
uint64_t
GroupKeyStore
ListenIPv4Addr
IPAddress
ListenIPv6Addr
IPAddress
LocalNodeId
uint64_t
LogKeys
bool
MaxUnencUDPMsgIdRcvd[WEAVE_CONFIG_MAX_PEER_NODES]
uint32_t
MessageLayer
MostRecentlyUsedIndexes[WEAVE_CONFIG_MAX_PEER_NODES]
PeerIndexType
NodeId[WEAVE_CONFIG_MAX_PEER_NODES]
uint64_t
PairingCode
const char *
State
uint8_t
UnencRcvFlags[WEAVE_CONFIG_MAX_PEER_NODES]
WeaveSessionState::ReceiveFlagsType
UseTestKey
bool

公共函数

AddSharedSessionEndNode(uint64_t endNodeId, uint64_t terminatingNodeId, uint16_t keyId)
AddSharedSessionEndNode(WeaveSessionKey *sessionKey, uint64_t endNodeId)
此方法会将新的端点添加到共享端点节点记录。
AllocSessionKey(uint64_t peerNodeId, uint16_t keyId, WeaveConnection *boundCon, WeaveSessionKey *& sessionKey)
ClearFabricState(void)
void
CreateFabric(void)
FindSessionKey(uint16_t keyId, uint64_t peerNodeId, bool create, WeaveSessionKey *& retRec)
此方法可查找会话密钥条目。
FindSharedSession(uint64_t terminatingNodeId, WeaveAuthMode authMode, uint8_t encType)
在会话密钥表中搜索以指定的终止节点为目标且与指定身份验证模式和加密类型匹配的既定共享会话密钥。
GetFabricState(uint8_t *buf, uint32_t bufSize, uint32_t & fabricStateLen)
GetPassword(uint8_t pwSrc, const char *& ps, uint16_t & pwLen)
GetSessionKey(uint16_t keyId, uint64_t peerNodeId, WeaveSessionKey *& outSessionKey)
GetSessionState(uint64_t remoteNodeId, uint16_t keyId, uint8_t encType, WeaveConnection *con, WeaveSessionState & outSessionState)
GetSharedSessionEndNodeIds(const WeaveSessionKey *sessionKey, uint64_t *endNodeIds, uint8_t endNodeIdsBufSize, uint8_t & endNodeIdsCount)
此方法会返回共享指定会话的所有终端节点 ID。
HandleConnectionClosed(WeaveConnection *con)
void
Init(void)
Init(nl::Weave::Profiles::Security::AppKeys::GroupKeyStoreBase *groupKeyStore)
IsFabricAddress(const IPAddress & addr) const
bool
确定 IP 地址是否代表本地 Weave 结构中节点的地址。
IsLocalFabricAddress(const IPAddress & addr) const
bool
确定 IP 地址是否代表本地节点的 Weave 结构地址。
IsSharedSession(uint16_t keyId, uint64_t peerNodeId)
bool
此方法可检查是否共享了与指定对等方和 keyId 关联的安全会话。
JoinExistingFabric(const uint8_t *fabricState, uint32_t fabricStateLen)
RegisterSessionEndCallback(SessionEndCbCtxt *sessionEndCb)
RemoveIdleSessionKeys()
bool
RemoveSessionKey(uint16_t keyId, uint64_t peerNodeId)
RemoveSessionKey(WeaveSessionKey *sessionKey, bool wasIdle)
void
RemoveSharedSessionEndNodes(const WeaveSessionKey *sessionKey)
void
RestoreSession(uint8_t *serializedSession, uint16_t serializedSessionLen)
从序列化状态恢复之前暂停的 Weave 安全会话。
SelectNodeAddress(uint64_t nodeId, uint16_t subnet) const
返回包含指定节点的 Weave ULA 的 IP 地址。
SelectNodeAddress(uint64_t nodeId) const
返回包含指定节点的 Weave ULA 的 IP 地址。
SetDelegate(FabricStateDelegate *aDelegate)
void
此方法可设置委托对象。
SetSessionKey(uint16_t keyId, uint64_t peerNodeId, uint8_t encType, WeaveAuthMode authMode, const WeaveEncryptionKey *encKey)
SetSessionKey(WeaveSessionKey *sessionKey, uint8_t encType, WeaveAuthMode authMode, const WeaveEncryptionKey *encKey)
Shutdown(void)
SuspendSession(uint16_t keyId, uint64_t peerNodeId, uint8_t *buf, uint16_t bufSize, uint16_t & serializedSessionLen)
暂停和序列化活跃 Weave 安全会话的状态。

结构体

nl::Weave::WeaveFabricState::SessionEndCbCtxt

公共类型

对等索引类型

uint8_t PeerIndexType

会话结束函数

void(* SessionEndCbFunct)(uint16_t keyId, uint64_t peerNodeId, void *context)

状态

 State

公共属性

自动创建密钥

bool AutoCreateKeys

DebugFabricId

uint64_t DebugFabricId

默认子网

uint16_t DefaultSubnet

FabricId

uint64_t FabricId

群组密钥库

nl::Weave::Profiles::Security::AppKeys::GroupKeyStoreBase * GroupKeyStore

ListenIPv4Addr 类中的方法

IPAddress ListenIPv4Addr

ListenIPv6Addr 类中的方法

IPAddress ListenIPv6Addr

LocalNodeId 类中的方法

uint64_t LocalNodeId

日志密钥

bool LogKeys

MaxUnencUDPMsgIdRcvd

uint32_t MaxUnencUDPMsgIdRcvd[WEAVE_CONFIG_MAX_PEER_NODES]

消息层

WeaveMessageLayer * MessageLayer

最近使用的索引

PeerIndexType MostRecentlyUsedIndexes[WEAVE_CONFIG_MAX_PEER_NODES]

NodeId

uint64_t NodeId[WEAVE_CONFIG_MAX_PEER_NODES]

配对码

const char * PairingCode

状态

uint8_t State

UnencRcv 标志

WeaveSessionState::ReceiveFlagsType UnencRcvFlags[WEAVE_CONFIG_MAX_PEER_NODES]

使用测试密钥

bool UseTestKey

公共函数

添加共享会话结束节点

WEAVE_ERROR AddSharedSessionEndNode(
  uint64_t endNodeId,
  uint64_t terminatingNodeId,
  uint16_t keyId
)

添加共享会话结束节点

WEAVE_ERROR AddSharedSessionEndNode(
  WeaveSessionKey *sessionKey,
  uint64_t endNodeId
)

此方法会将新的端点添加到共享端点节点记录。

详细信息
参数
[in] sessionKey
表示应为其添加新结束节点的会话的 WeaveSessionKey 对象。
[in] endNodeId
要添加的会话结束节点的节点 ID。
返回值
WEAVE_ERROR_TOO_MANY_SHARED_SESSION_END_NODES
如果共享结束节点列表中没有可用于创建新条目的可用空间。
WEAVE_NO_ERROR
成功时。

AllcSession 键

WEAVE_ERROR AllocSessionKey(
  uint64_t peerNodeId,
  uint16_t keyId,
  WeaveConnection *boundCon,
  WeaveSessionKey *& sessionKey
)

ClearFabricState

void ClearFabricState(
  void
)

创建 Fabric

WEAVE_ERROR CreateFabric(
  void
)

查找会话密钥

WEAVE_ERROR FindSessionKey(
  uint16_t keyId,
  uint64_t peerNodeId,
  bool create,
  WeaveSessionKey *& retRec
)

此方法可查找会话密钥条目。

详细信息
参数
[in] keyId
编织密钥标识符。
[in] peerNodeId
对等体的节点标识符。
[in] create
一个布尔值,指示如果找不到指定的键,是否应创建新键。
[out] retRec
WeaveSessionKey 对象的指针引用。
返回值
WEAVE_ERROR_WRONG_KEY_TYPE
如果指定的密钥不是会话密钥类型。
WEAVE_ERROR_INVALID_ARGUMENT
输入参数的值不正确时。
WEAVE_ERROR_KEY_NOT_FOUND
如果找不到指定的键。
WEAVE_ERROR_TOO_MANY_KEYS
如果没有用于创建新会话密钥的免费条目。
WEAVE_NO_ERROR
成功时。

查找共享会话

WeaveSessionKey * FindSharedSession(
  uint64_t terminatingNodeId,
  WeaveAuthMode authMode,
  uint8_t encType
)

在会话密钥表中搜索以指定的终止节点为目标且与指定身份验证模式和加密类型匹配的既定共享会话密钥。

详细信息
参数
[in] terminatingNodeId
会话终止符的节点标识符。
[in] authMode
所需的会话身份验证模式。
[in] encType
所需的消息加密类型。
返回值
WeaveSessionKey
* 指向 WeaveSessionKey 对象的指针,表示匹配的共享会话;如果未找到匹配的会话,则返回 NULL。

GetFabricState

WEAVE_ERROR GetFabricState(
  uint8_t *buf,
  uint32_t bufSize,
  uint32_t & fabricStateLen
)

获取密码

WEAVE_ERROR GetPassword(
  uint8_t pwSrc,
  const char *& ps,
  uint16_t & pwLen
)

GetSessionKey

WEAVE_ERROR GetSessionKey(
  uint16_t keyId,
  uint64_t peerNodeId,
  WeaveSessionKey *& outSessionKey
)

GetSessionState 类中的方法

WEAVE_ERROR GetSessionState(
  uint64_t remoteNodeId,
  uint16_t keyId,
  uint8_t encType,
  WeaveConnection *con,
  WeaveSessionState & outSessionState
)

GetSharedSessionEndNodeIds

WEAVE_ERROR GetSharedSessionEndNodeIds(
  const WeaveSessionKey *sessionKey,
  uint64_t *endNodeIds,
  uint8_t endNodeIdsBufSize,
  uint8_t & endNodeIdsCount
)

此方法会返回共享指定会话的所有终端节点 ID。

详细信息
参数
[in] sessionKey
指向会话密钥对象的指针。
[in] endNodeIds
指向节点 ID 缓冲区的指针。
[in] endNodeIdsMaxCount
可存放在缓冲区中的节点 ID 的数量上限。
[out] endNodeIdsCount
找到的共享指定会话的结束节点 ID 的数量。
返回值
WEAVE_ERROR_BUFFER_TOO_SMALL
如果提供的结束节点 ID 缓冲区不够大,
WEAVE_NO_ERROR
成功时。

HandleConnectionClosed

void HandleConnectionClosed(
  WeaveConnection *con
)

Init

WEAVE_ERROR Init(
  void
)

Init

WEAVE_ERROR Init(
  nl::Weave::Profiles::Security::AppKeys::GroupKeyStoreBase *groupKeyStore
)

IsFabricAddress

bool IsFabricAddress(
  const IPAddress & addr
) const 

确定 IP 地址是否代表本地 Weave 结构中节点的地址。

IsLocalFabricAddress

bool IsLocalFabricAddress(
  const IPAddress & addr
) const 

确定 IP 地址是否代表本地节点的 Weave 结构地址。

IsSharedSession

bool IsSharedSession(
  uint16_t keyId,
  uint64_t peerNodeId
)

此方法可检查是否共享了与指定对等方和 keyId 关联的安全会话。

详细信息
参数
[in] keyId
会话密钥标识符。
[in] peerNodeId
对等体的节点标识符。
返回值
bool
是否共享指定的会话。

加入现有的 Fabric

WEAVE_ERROR JoinExistingFabric(
  const uint8_t *fabricState,
  uint32_t fabricStateLen
)

RegisterSessionEndCallback

WEAVE_ERROR RegisterSessionEndCallback(
  SessionEndCbCtxt *sessionEndCb
)

移除会话键

bool RemoveIdleSessionKeys()

移除会话密钥

WEAVE_ERROR RemoveSessionKey(
  uint16_t keyId,
  uint64_t peerNodeId
)

移除会话密钥

void RemoveSessionKey(
  WeaveSessionKey *sessionKey,
  bool wasIdle
)

移除共享会话结束节点

void RemoveSharedSessionEndNodes(
  const WeaveSessionKey *sessionKey
)

恢复会话

WEAVE_ERROR RestoreSession(
  uint8_t *serializedSession,
  uint16_t serializedSessionLen
)

从序列化状态恢复之前暂停的 Weave 安全会话。

SelectNodeAddress

IPAddress SelectNodeAddress(
  uint64_t nodeId,
  uint16_t subnet
) const 

返回包含指定节点的 Weave ULA 的 IP 地址。

此变体允许指定子网。

详细信息
参数
[in] nodeId
相关节点的节点 ID 号。
[in] subnet
ULA 所需的子网。
返回值
IPAddress
IPAddress 对象。

SelectNodeAddress

IPAddress SelectNodeAddress(
  uint64_t nodeId
) const 

返回包含指定节点的 Weave ULA 的 IP 地址。

此变体使用本地节点的默认子网。

详细信息
参数
[in] nodeId
相关节点的节点 ID 号。
返回值
IPAddress
IPAddress 对象。

设置代理

void SetDelegate(
  FabricStateDelegate *aDelegate
)

此方法可设置委托对象。

每当更改 FabricId 时(即,当我们加入/创建结构时,或当我们退出架构(清除结构状态)时),都会调用代理的回调方法

如果 delegate 先前已设置,则对此方法的第二次调用将覆盖之前的 delegate。

详细信息
参数
[in] aDelegate
代理对象。如果不需要委托,可以为 NULL。

设置会话密钥

WEAVE_ERROR SetSessionKey(
  uint16_t keyId,
  uint64_t peerNodeId,
  uint8_t encType,
  WeaveAuthMode authMode,
  const WeaveEncryptionKey *encKey
)

设置会话密钥

WEAVE_ERROR SetSessionKey(
  WeaveSessionKey *sessionKey,
  uint8_t encType,
  WeaveAuthMode authMode,
  const WeaveEncryptionKey *encKey
)

关机

WEAVE_ERROR Shutdown(
  void
)

SuspendSession

WEAVE_ERROR SuspendSession(
  uint16_t keyId,
  uint64_t peerNodeId,
  uint8_t *buf,
  uint16_t bufSize,
  uint16_t & serializedSessionLen
)

暂停和序列化活跃 Weave 安全会话的状态。

将已识别的 Weave 安全会话的状态序列化到提供的缓冲区,并暂停会话,这样就不能再发送或接收消息。

该方法适用于那些在休眠时未保留 RAM 的设备,从而可让它们保留活动会话的状态,从而避免在唤醒时重新建立会话。

WeaveFabricState

 WeaveFabricState(
  void
)