----------------------------------------------------------------------------- Handle a command class message -----------------------------------------------------------------------------
| 2017 | // Handle a command class message |
| 2018 | //----------------------------------------------------------------------------- |
| 2019 | void Node::ApplicationCommandHandler |
| 2020 | ( |
| 2021 | uint8 const* _data, |
| 2022 | bool encrypted |
| 2023 | |
| 2024 | ) |
| 2025 | { |
| 2026 | if( CommandClass* pCommandClass = GetCommandClass( _data[5] ) ) |
| 2027 | { |
| 2028 | if (pCommandClass->IsSecured() && !encrypted) { |
| 2029 | Log::Write( LogLevel_Warning, m_nodeId, "Received a Clear Text Message for the CommandClass %s which is Secured", pCommandClass->GetCommandClassName().c_str()); |
| 2030 | bool drop = true; |
| 2031 | Options::Get()->GetOptionAsBool("EnforceSecureReception", &drop); |
| 2032 | if (drop) { |
| 2033 | Log::Write( LogLevel_Warning, m_nodeId, " Dropping Message"); |
| 2034 | return; |
| 2035 | } else { |
| 2036 | Log::Write( LogLevel_Warning, m_nodeId, " Allowing Message (EnforceSecureReception is not set)"); |
| 2037 | } |
| 2038 | } |
| 2039 | |
| 2040 | pCommandClass->ReceivedCntIncr(); |
| 2041 | if (!pCommandClass->HandleMsg( &_data[6], _data[4] ) ) |
| 2042 | { |
| 2043 | Log::Write( LogLevel_Warning, m_nodeId, "CommandClass %s HandlerMsg Returned False", pCommandClass->GetCommandClassName().c_str()); |
| 2044 | } |
| 2045 | } |
| 2046 | else if( CommandClass* pCommandClass = GetCommandClass( _data[5], true ) ) |
| 2047 | { |
| 2048 | if (pCommandClass->IsSecured() && !encrypted) { |
| 2049 | Log::Write( LogLevel_Warning, m_nodeId, "Received a Clear Text Message for the Advertised CommandClass %s which is Secured", pCommandClass->GetCommandClassName().c_str()); |
| 2050 | bool drop = true; |
| 2051 | Options::Get()->GetOptionAsBool("EnforceSecureReception", &drop); |
| 2052 | if (drop) { |
| 2053 | Log::Write( LogLevel_Warning, m_nodeId, " Dropping Message"); |
| 2054 | return; |
| 2055 | } else { |
| 2056 | Log::Write( LogLevel_Warning, m_nodeId, " Allowing Message (EnforceSecureReception is not set)"); |
| 2057 | } |
| 2058 | } |
| 2059 | |
| 2060 | pCommandClass->ReceivedCntIncr(); |
| 2061 | if (!pCommandClass->HandleIncomingMsg( &_data[6], _data[4] ) ) |
| 2062 | { |
| 2063 | Log::Write (LogLevel_Warning, m_nodeId, "CommandClass %s HandleIncommingMsg returned false", pCommandClass->GetCommandClassName().c_str()); |
| 2064 | } |
| 2065 | } |
| 2066 | else |
| 2067 | { |
| 2068 | if( _data[5] == ControllerReplication::StaticGetCommandClassId() ) |
| 2069 | { |
| 2070 | // This is a controller replication message, and we do not support it. |
| 2071 | // We have to at least acknowledge the message to avoid locking the sending device. |
| 2072 | Log::Write( LogLevel_Info, m_nodeId, "ApplicationCommandHandler - Default acknowledgement of controller replication data" ); |
| 2073 | |
| 2074 | Msg* msg = new Msg( "Replication Command Complete", m_nodeId, REQUEST, FUNC_ID_ZW_REPLICATION_COMMAND_COMPLETE, false ); |
| 2075 | GetDriver()->SendMsg( msg, Driver::MsgQueue_Command ); |
| 2076 | } |
no test coverage detected