nl::Weave::WeaveFabricState

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

Forward declaration of WeaveFabricState.

Summary

Constructors and Destructors

WeaveFabricState(void)

Public types

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

Public attributes

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

Public functions

AddSharedSessionEndNode(uint64_t endNodeId, uint64_t terminatingNodeId, uint16_t keyId)
AddSharedSessionEndNode(WeaveSessionKey *sessionKey, uint64_t endNodeId)
This method adds new end node to the shared end nodes record.
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)
This method finds session key entry.
FindSharedSession(uint64_t terminatingNodeId, WeaveAuthMode authMode, uint8_t encType)
Search the session keys table for an established shared session key that targets the specified terminating node and matches the given auth mode and encryption type.
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)
This method returns all end node IDs that share specified session.
HandleConnectionClosed(WeaveConnection *con)
void
Init(void)
Init(nl::Weave::Profiles::Security::AppKeys::GroupKeyStoreBase *groupKeyStore)
IsFabricAddress(const IPAddress & addr) const
bool
Determines if an IP address represents an address of a node within the local Weave fabric.
IsLocalFabricAddress(const IPAddress & addr) const
bool
Determines if an IP address represents a Weave fabric address for the local node.
IsSharedSession(uint16_t keyId, uint64_t peerNodeId)
bool
This method checks whether secure session associated with the specified peer and keyId is shared.
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)
Restore a previously suspended Weave Security Session from a serialized state.
SelectNodeAddress(uint64_t nodeId, uint16_t subnet) const
Returns an IPAddress containing a Weave ULA for a specified node.
SelectNodeAddress(uint64_t nodeId) const
Returns an IPAddress containing a Weave ULA for a specified node.
SetDelegate(FabricStateDelegate *aDelegate)
void
This method sets the delegate object.
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)
Suspend and serialize the state of an active Weave security session.

Structs

nl::Weave::WeaveFabricState::SessionEndCbCtxt

Public types

PeerIndexType

uint8_t PeerIndexType

SessionEndCbFunct

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

State

 State

Public attributes

AutoCreateKeys

bool AutoCreateKeys

DebugFabricId

uint64_t DebugFabricId

DefaultSubnet

uint16_t DefaultSubnet

FabricId

uint64_t FabricId

GroupKeyStore

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

ListenIPv4Addr

IPAddress ListenIPv4Addr

ListenIPv6Addr

IPAddress ListenIPv6Addr

LocalNodeId

uint64_t LocalNodeId

LogKeys

bool LogKeys

MaxUnencUDPMsgIdRcvd

uint32_t MaxUnencUDPMsgIdRcvd[WEAVE_CONFIG_MAX_PEER_NODES]

MessageLayer

WeaveMessageLayer * MessageLayer

MostRecentlyUsedIndexes

PeerIndexType MostRecentlyUsedIndexes[WEAVE_CONFIG_MAX_PEER_NODES]

NodeId

uint64_t NodeId[WEAVE_CONFIG_MAX_PEER_NODES]

PairingCode

const char * PairingCode

State

uint8_t State

UnencRcvFlags

WeaveSessionState::ReceiveFlagsType UnencRcvFlags[WEAVE_CONFIG_MAX_PEER_NODES]

UseTestKey

bool UseTestKey

Public functions

AddSharedSessionEndNode

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

AddSharedSessionEndNode

WEAVE_ERROR AddSharedSessionEndNode(
  WeaveSessionKey *sessionKey,
  uint64_t endNodeId
)

This method adds new end node to the shared end nodes record.

Details
Parameters
[in] sessionKey
The WeaveSessionKey object representing the session for which the new end node should be added.
[in] endNodeId
The node id of the session end node to be added.
Return Values
WEAVE_ERROR_TOO_MANY_SHARED_SESSION_END_NODES
If there is no free space for a new entry in the shared end nodes list.
WEAVE_NO_ERROR
On success.

AllocSessionKey

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

ClearFabricState

void ClearFabricState(
  void
)

CreateFabric

WEAVE_ERROR CreateFabric(
  void
)

FindSessionKey

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

This method finds session key entry.

Details
Parameters
[in] keyId
Weave key identifier.
[in] peerNodeId
The node identifier of the peer.
[in] create
A boolean value indicating whether new key should be created if the specified key is not found.
[out] retRec
A pointer reference to a WeaveSessionKey object.
Return Values
WEAVE_ERROR_WRONG_KEY_TYPE
If specified key is not a session key type.
WEAVE_ERROR_INVALID_ARGUMENT
If input arguments have wrong values.
WEAVE_ERROR_KEY_NOT_FOUND
If specified key is not found.
WEAVE_ERROR_TOO_MANY_KEYS
If there is no free entry to create new session key.
WEAVE_NO_ERROR
On success.

FindSharedSession

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

Search the session keys table for an established shared session key that targets the specified terminating node and matches the given auth mode and encryption type.

Details
Parameters
[in] terminatingNodeId
The node identifier of the session terminator.
[in] authMode
The desired session authentication mode.
[in] encType
The desired message encryption type.
Return Values
WeaveSessionKey
* A pointer to a WeaveSessionKey object representing the matching shared session; or NULL if no matching session was found.

GetFabricState

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

GetPassword

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
)

This method returns all end node IDs that share specified session.

Details
Parameters
[in] sessionKey
A pointer to the session key object.
[in] endNodeIds
A pointer to buffer of node IDs.
[in] endNodeIdsMaxCount
The maximum number of node IDs that can fit in the buffer.
[out] endNodeIdsCount
Number of found end node IDs that share specified session.
Return Values
WEAVE_ERROR_BUFFER_TOO_SMALL
If provided end node Ids buffer is not big enough.
WEAVE_NO_ERROR
On success.

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 

Determines if an IP address represents an address of a node within the local Weave fabric.

IsLocalFabricAddress

bool IsLocalFabricAddress(
  const IPAddress & addr
) const 

Determines if an IP address represents a Weave fabric address for the local node.

IsSharedSession

bool IsSharedSession(
  uint16_t keyId,
  uint64_t peerNodeId
)

This method checks whether secure session associated with the specified peer and keyId is shared.

Details
Parameters
[in] keyId
The session key identifier.
[in] peerNodeId
The node identifier of the peer.
Return Values
bool
Whether or not specified session is shared.

JoinExistingFabric

WEAVE_ERROR JoinExistingFabric(
  const uint8_t *fabricState,
  uint32_t fabricStateLen
)

RegisterSessionEndCallback

WEAVE_ERROR RegisterSessionEndCallback(
  SessionEndCbCtxt *sessionEndCb
)

RemoveIdleSessionKeys

bool RemoveIdleSessionKeys()

RemoveSessionKey

WEAVE_ERROR RemoveSessionKey(
  uint16_t keyId,
  uint64_t peerNodeId
)

RemoveSessionKey

void RemoveSessionKey(
  WeaveSessionKey *sessionKey,
  bool wasIdle
)

RemoveSharedSessionEndNodes

void RemoveSharedSessionEndNodes(
  const WeaveSessionKey *sessionKey
)

RestoreSession

WEAVE_ERROR RestoreSession(
  uint8_t *serializedSession,
  uint16_t serializedSessionLen
)

Restore a previously suspended Weave Security Session from a serialized state.

SelectNodeAddress

IPAddress SelectNodeAddress(
  uint64_t nodeId,
  uint16_t subnet
) const 

Returns an IPAddress containing a Weave ULA for a specified node.

This variant allows for a subnet to be specified.

Details
Parameters
[in] nodeId
The Node ID number of the node in question.
[in] subnet
The desired subnet of the ULA.
Return Values
IPAddress
An IPAddress object.

SelectNodeAddress

IPAddress SelectNodeAddress(
  uint64_t nodeId
) const 

Returns an IPAddress containing a Weave ULA for a specified node.

This variant uses the local node's default subnet.

Details
Parameters
[in] nodeId
The Node ID number of the node in question.
Return Values
IPAddress
An IPAddress object.

SetDelegate

void SetDelegate(
  FabricStateDelegate *aDelegate
)

This method sets the delegate object.

The callback methods of delegate are invoked whenever the FabricId is changed, i.e., when we join/create a fabric, or when we leave a fabric (clear fabric state)

If the delegate is previously set, then a second call to this method will overwrite the previous delegate.

Details
Parameters
[in] aDelegate
The delegate object. It can be NULL if no delegate is required.

SetSessionKey

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

SetSessionKey

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

Shutdown

WEAVE_ERROR Shutdown(
  void
)

SuspendSession

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

Suspend and serialize the state of an active Weave security session.

Serializes the state of an identified Weave security session into the supplied buffer and suspends the session such that no further messages can be sent or received.

This method is intended to be used by devices that do not retain RAM while sleeping, allowing them to persist the state of an active session and thereby avoid the need to re-establish the session when they wake.

WeaveFabricState

 WeaveFabricState(
  void
)