Pankaj Garg | a04576d | 2021-11-08 15:04:13 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright (c) 2020-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 contains definitions for DeviceProxy base class. The objects of this |
| 22 | * class will be used by applications to interact with peer CHIP devices. |
| 23 | * The class provides mechanism to construct, send and receive messages to and |
| 24 | * from the corresponding CHIP devices. |
| 25 | */ |
| 26 | |
| 27 | #pragma once |
| 28 | |
| 29 | #include <app/CommandSender.h> |
Pankaj Garg | a04576d | 2021-11-08 15:04:13 -0800 | [diff] [blame] | 30 | #include <lib/core/CHIPCallback.h> |
| 31 | #include <lib/core/CHIPCore.h> |
| 32 | #include <lib/support/DLLUtil.h> |
Boris Zbarsky | e42b533 | 2023-03-14 00:13:25 -0400 | [diff] [blame] | 33 | #include <system/SystemClock.h> |
Pankaj Garg | a04576d | 2021-11-08 15:04:13 -0800 | [diff] [blame] | 34 | |
| 35 | namespace chip { |
| 36 | |
| 37 | class DLL_EXPORT DeviceProxy |
| 38 | { |
| 39 | public: |
| 40 | virtual ~DeviceProxy() {} |
| 41 | DeviceProxy() {} |
| 42 | |
| 43 | /** |
Pankaj Garg | a04576d | 2021-11-08 15:04:13 -0800 | [diff] [blame] | 44 | * Mark any open session with the device as expired. |
| 45 | */ |
Michael Spang | 6387049 | 2022-06-28 08:41:08 -0400 | [diff] [blame] | 46 | virtual void Disconnect() = 0; |
Pankaj Garg | a04576d | 2021-11-08 15:04:13 -0800 | [diff] [blame] | 47 | |
| 48 | virtual NodeId GetDeviceId() const = 0; |
| 49 | |
C Freeman | 8ee96e4 | 2022-01-21 11:43:45 -0500 | [diff] [blame] | 50 | virtual CHIP_ERROR SendCommands(app::CommandSender * commandObj, chip::Optional<System::Clock::Timeout> timeout = NullOptional); |
Pankaj Garg | a04576d | 2021-11-08 15:04:13 -0800 | [diff] [blame] | 51 | |
Pankaj Garg | a04576d | 2021-11-08 15:04:13 -0800 | [diff] [blame] | 52 | virtual Messaging::ExchangeManager * GetExchangeManager() const = 0; |
| 53 | |
| 54 | virtual chip::Optional<SessionHandle> GetSecureSession() const = 0; |
| 55 | |
C Freeman | 09a4921 | 2022-01-24 21:19:43 -0500 | [diff] [blame] | 56 | virtual CHIP_ERROR SetPeerId(ByteSpan rcac, ByteSpan noc) { return CHIP_ERROR_NOT_IMPLEMENTED; } |
| 57 | |
Boris Zbarsky | e42b533 | 2023-03-14 00:13:25 -0400 | [diff] [blame] | 58 | /** |
| 59 | * Facilities for keeping track of the latest point we can expect the |
| 60 | * fail-safe to last through. These timestamp values use the monotonic clock. |
| 61 | */ |
| 62 | void SetFailSafeExpirationTimestamp(System::Clock::Timestamp timestamp) { mFailSafeExpirationTimestamp = timestamp; } |
| 63 | System::Clock::Timestamp GetFailSafeExpirationTimestamp() const { return mFailSafeExpirationTimestamp; } |
Pankaj Garg | a04576d | 2021-11-08 15:04:13 -0800 | [diff] [blame] | 64 | |
Kevin Coppock | 2d6bb3a | 2022-05-31 08:54:33 -0500 | [diff] [blame] | 65 | /** |
| 66 | * @brief |
| 67 | * This function returns the attestation challenge for the secure session. |
| 68 | * |
| 69 | * @param[out] attestationChallenge The output for the attestationChallenge |
| 70 | * |
| 71 | * @return CHIP_ERROR CHIP_NO_ERROR on success, or CHIP_ERROR_INVALID_ARGUMENT if no secure session is active |
| 72 | */ |
Kevin Coppock | 9111757 | 2022-06-01 11:58:16 -0500 | [diff] [blame] | 73 | virtual CHIP_ERROR GetAttestationChallenge(ByteSpan & attestationChallenge); |
Kevin Coppock | 2d6bb3a | 2022-05-31 08:54:33 -0500 | [diff] [blame] | 74 | |
Pankaj Garg | a04576d | 2021-11-08 15:04:13 -0800 | [diff] [blame] | 75 | protected: |
| 76 | virtual bool IsSecureConnected() const = 0; |
| 77 | |
Boris Zbarsky | e42b533 | 2023-03-14 00:13:25 -0400 | [diff] [blame] | 78 | System::Clock::Timestamp mFailSafeExpirationTimestamp = System::Clock::kZero; |
Pankaj Garg | a04576d | 2021-11-08 15:04:13 -0800 | [diff] [blame] | 79 | }; |
| 80 | |
Pankaj Garg | a04576d | 2021-11-08 15:04:13 -0800 | [diff] [blame] | 81 | } // namespace chip |