Line data Source code
1 : /* 2 : * Copyright (c) 2022 Project CHIP Authors 3 : * 4 : * Licensed under the Apache License, Version 2.0 (the "License"); 5 : * you may not use this file except in compliance with the License. 6 : * You may obtain a copy of the License at 7 : * 8 : * http://www.apache.org/licenses/LICENSE-2.0 9 : * 10 : * Unless required by applicable law or agreed to in writing, software 11 : * distributed under the License is distributed on an "AS IS" BASIS, 12 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 : * See the License for the specific language governing permissions and 14 : * limitations under the License. 15 : */ 16 : 17 : #pragma once 18 : 19 : #include <messaging/ExchangeMessageDispatch.h> 20 : #include <protocols/secure_channel/Constants.h> 21 : 22 : namespace chip { 23 : namespace Messaging { 24 : 25 : class EphemeralExchangeDispatch : public ExchangeMessageDispatch 26 : { 27 : public: 28 13 : static ExchangeMessageDispatch & Instance() 29 : { 30 13 : static EphemeralExchangeDispatch instance; 31 13 : return instance; 32 : } 33 : 34 6 : EphemeralExchangeDispatch() {} 35 6 : ~EphemeralExchangeDispatch() override {} 36 : 37 : protected: 38 13 : bool MessagePermitted(Protocols::Id protocol, uint8_t type) override 39 : { 40 : // Only permit StandaloneAck 41 26 : return (protocol == Protocols::SecureChannel::Id && 42 26 : type == to_underlying(Protocols::SecureChannel::MsgType::StandaloneAck)); 43 : } 44 : 45 0 : bool IsEncryptionRequired() const override 46 : { 47 : // This function should not be called at all 48 0 : VerifyOrDie(false); 49 : return false; 50 : } 51 : }; 52 : 53 : } // namespace Messaging 54 : } // namespace chip