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 14 : static ExchangeMessageDispatch & Instance()
29 : {
30 14 : static EphemeralExchangeDispatch instance;
31 14 : return instance;
32 : }
33 :
34 7 : EphemeralExchangeDispatch() {}
35 7 : ~EphemeralExchangeDispatch() override {}
36 :
37 : protected:
38 14 : bool MessagePermitted(Protocols::Id protocol, uint8_t type) override
39 : {
40 : // Only permit StandaloneAck
41 28 : return (protocol == Protocols::SecureChannel::Id &&
42 28 : 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
|