Coverage Report

Created: 2025-08-28 06:31

/src/connectedhomeip/src/protocols/secure_channel/SessionEstablishmentDelegate.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 *
3
 *    Copyright (c) 2021 Project CHIP Authors
4
 *    All rights reserved.
5
 *
6
 *    Licensed under the Apache License, Version 2.0 (the "License");
7
 *    you may not use this file except in compliance with the License.
8
 *    You may obtain a copy of the License at
9
 *
10
 *        http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 *    Unless required by applicable law or agreed to in writing, software
13
 *    distributed under the License is distributed on an "AS IS" BASIS,
14
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 *    See the License for the specific language governing permissions and
16
 *    limitations under the License.
17
 */
18
19
/**
20
 *    @file
21
 *      This file defines the Delegate class that contains callbacks to
22
 *      establish a secure session and update status of the session establishment process.
23
 *
24
 */
25
26
#pragma once
27
28
#include <system/SystemClock.h>
29
#include <system/SystemPacketBuffer.h>
30
#include <transport/Session.h>
31
#include <transport/raw/MessageHeader.h>
32
#include <transport/raw/PeerAddress.h>
33
34
namespace chip {
35
36
enum class SessionEstablishmentStage : uint8_t
37
{
38
    kUnknown          = 0,
39
    kNotInKeyExchange = 1,
40
    kSentSigma1       = 2,
41
    kReceivedSigma1   = 3,
42
    kSentSigma2       = 4,
43
    kReceivedSigma2   = 5,
44
    kSentSigma3       = 6,
45
    kReceivedSigma3   = 7,
46
};
47
48
class DLL_EXPORT SessionEstablishmentDelegate
49
{
50
public:
51
    /**
52
     *   Called when session establishment fails with an error.  This will be
53
     *   called at most once per session establishment and will not be called if
54
     *   OnSessionEstablished is called.
55
     *
56
     *   This overload of OnSessionEstablishmentError is not called directly.
57
     *   It's only called from the default implementation of the two-argument
58
     *   overload.
59
     */
60
0
    virtual void OnSessionEstablishmentError(CHIP_ERROR error) {}
61
62
    /**
63
     *   Called when session establishment fails with an error and state at the
64
     *   failure. This will be called at most once per session establishment and
65
     *   will not be called if OnSessionEstablished is called.
66
     */
67
    virtual void OnSessionEstablishmentError(CHIP_ERROR error, SessionEstablishmentStage stage)
68
1.52k
    {
69
1.52k
        OnSessionEstablishmentError(error);
70
1.52k
    }
71
72
    /**
73
     *   Called on start of session establishment process
74
     */
75
0
    virtual void OnSessionEstablishmentStarted() {}
76
77
    /**
78
     *   Called when the new secure session has been established.  This is
79
     *   mututally exclusive with OnSessionEstablishmentError for a give session
80
     *   establishment.
81
     */
82
0
    virtual void OnSessionEstablished(const SessionHandle & session) {}
83
84
    /**
85
     * Called when the responder has responded with a "busy" status code and
86
     * provided a requested delay.
87
     *
88
     * This call will be followed by an OnSessionEstablishmentError with
89
     * CHIP_ERROR_BUSY as the error.
90
     */
91
0
    virtual void OnResponderBusy(System::Clock::Milliseconds16 requestedDelay) {}
92
93
0
    virtual ~SessionEstablishmentDelegate() {}
94
};
95
96
} // namespace chip