MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / SetSecuredClasses

Method SetSecuredClasses

cpp/src/Node.cpp:1681–1796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1679
1680
1681void Node::SetSecuredClasses
1682(
1683 uint8 const* _data,
1684 uint8 const _length,
1685 uint32 const _instance
1686)
1687{
1688 uint32 i;
1689 m_secured = true;
1690 Log::Write( LogLevel_Info, m_nodeId, " Secured command classes for node %d (instance %d):", m_nodeId, _instance );
1691 if (!GetDriver()->isNetworkKeySet()) {
1692 Log::Write (LogLevel_Warning, m_nodeId, " Secured Command Classes cannot be enabled as Network Key is not set");
1693 return;
1694 }
1695
1696
1697 bool afterMark = false;
1698 for( i=0; i<_length; ++i )
1699 {
1700 if( _data[i] == 0xef )
1701 {
1702 // COMMAND_CLASS_MARK.
1703 // Marks the end of the list of supported command classes. The remaining classes
1704 // are those that can be controlled by the device. These classes are created
1705 // without values. Messages received cause notification events instead.
1706 afterMark = true;
1707 continue;
1708 }
1709 /* Check if this is a CC that is already registered with the node */
1710 if (CommandClass *pCommandClass = GetCommandClass(_data[i], afterMark))
1711 {
1712 /* if it was specified the he NIF frame, and came in as part of the Security SupportedReport message
1713 * then it can support both Clear Text and Secured Comms. So do a check first
1714 */
1715 if (pCommandClass->IsInNIF()) {
1716 /* if the CC Supports Security and our SecurityStrategy says we should encrypt it, then mark it as encrypted */
1717 if (pCommandClass->IsSecureSupported() && (ShouldSecureCommandClass(_data[i]) == SecurityStrategy_Supported )) {
1718 pCommandClass->SetSecured();
1719 Log::Write( LogLevel_Info, m_nodeId, " %s (Secured) - %s", pCommandClass->GetCommandClassName().c_str(), pCommandClass->IsInNIF() ? "InNIF": "NotInNIF");
1720 }
1721 /* if it wasn't in the NIF frame, then it will only support Secured Comms. */
1722 } else {
1723 if (pCommandClass->IsSecureSupported()) {
1724 pCommandClass->SetSecured();
1725 Log::Write( LogLevel_Info, m_nodeId, " %s (Secured) - %s", pCommandClass->GetCommandClassName().c_str(), pCommandClass->IsInNIF() ? "InNIF": "NotInNIF");
1726 }
1727 }
1728 if (_instance > 1) {
1729 /* we need to get the endpoint from the Security CC, to map over to the target CC if this
1730 * is triggered by a SecurityCmd_SupportedReport from a instance
1731 */
1732 CommandClass *secc = GetCommandClass(Security::StaticGetCommandClassId(), false);
1733 int ep = secc->GetEndPoint(_instance);
1734 pCommandClass->SetEndPoint(_instance, ep);
1735 pCommandClass->SetInstance(_instance);
1736 }
1737 }
1738 /* it might be a new CC we havn't seen as part of the NIF. In that case

Callers 1

HandleSupportedReportMethod · 0.80

Calls 11

WriteFunction · 0.85
ShouldSecureCommandClassFunction · 0.85
isNetworkKeySetMethod · 0.80
SetSecuredMethod · 0.80
SetStaticRequestMethod · 0.80
IsSecuredMethod · 0.80
c_strMethod · 0.45
GetCommandClassNameMethod · 0.45
SetInstanceMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected