Line data Source code
1 : /*
2 : *
3 : * Copyright (c) 2023 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 : #pragma once
20 :
21 : #include <app/icd/client/ICDClientInfo.h>
22 : #include <app/icd/client/ICDClientStorage.h>
23 :
24 : namespace chip {
25 : namespace app {
26 :
27 : class RefreshKeySender;
28 :
29 : /// Callbacks for check in protocol
30 : /**
31 : * @brief The application implementing an ICD client should inherit the CheckInDelegate and implement the listed callbacks
32 : */
33 : class DLL_EXPORT CheckInDelegate
34 : {
35 : public:
36 1 : virtual ~CheckInDelegate() {}
37 :
38 : /**
39 : * @brief Callback used to let the application know that a check-in message was received and validated.
40 : *
41 : * @param[in] clientInfo - ICDClientInfo object representing the state associated with the
42 : node that sent the check-in message.
43 : */
44 : virtual void OnCheckInComplete(const ICDClientInfo & clientInfo) = 0;
45 :
46 : /**
47 : * @brief Callback used to let the application know that a key refresh is
48 : * needed to avoid counter rollover problems.
49 : *
50 : * The implementer of this function should create a new RefreshKeySender object. This object will be tied to the specific key
51 : * refresh process and will not be used by the caller after that particular key refresh process has ended, regardless of success
52 : * or failure.
53 : *
54 : * The caller guarantees that if a non-null RefreshKeySender pointer is returned, it will call OnKeyRefreshDone
55 : * at some point, and pass it the returned pointer.
56 : *
57 : * If the callee is unable to provide the RefreshKeySender object, that indicates key
58 : * refresh is not possible until the callee is able to provide the required resources.
59 : *
60 : * @param[in] clientInfo - ICDClientInfo object representing the state associated with the
61 : * node that sent the check-in message. The callee can use the clientInfo to determine the type of key
62 : * to generate.
63 : * @param[in] clientStorage - ICDClientStorage object stores the updated ICDClientInfo after re-registration into
64 : * persistent storage.
65 : * @return RefreshKeySender - pointer to RefreshKeySender object
66 : */
67 : virtual RefreshKeySender * OnKeyRefreshNeeded(ICDClientInfo & clientInfo, ICDClientStorage * clientStorage) = 0;
68 :
69 : /**
70 : * @brief Callback used to let the application know that the re-registration process is done. This callback will be called for
71 : * both success and failure cases. On failure, the callee should take appropriate corrective action based on the error.
72 : *
73 : * @param[in] refreshKeySender - pointer to the RefreshKeySender object that was used for the key refresh process. The caller
74 : * will NOT use this pointer any more.
75 : * @param[in] error - CHIP_NO_ERROR indicates successful re-registration using the new key
76 : * Other errors indicate the failure reason.
77 : */
78 : virtual void OnKeyRefreshDone(RefreshKeySender * refreshKeySender, CHIP_ERROR error) = 0;
79 : };
80 :
81 : } // namespace app
82 : } // namespace chip
|