Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef COMMON_COMMON_INC_TSD_VERSION_VERIFY_H
12 : #define COMMON_COMMON_INC_TSD_VERSION_VERIFY_H
13 :
14 : #include <set>
15 : #include <atomic>
16 : #include "proto/tsd_message.pb.h"
17 : namespace tsd {
18 : class VersionVerify {
19 : public:
20 130 : VersionVerify() : peerVersion_(0U){};
21 :
22 129 : ~VersionVerify() = default;
23 :
24 : /**
25 : * @ingroup VersionVerify
26 : * @param [in] peerVersionInfo : client version info
27 : * @brief check whether client and server can establish communication
28 : */
29 : bool PeerVersionCheck(const HDCMessage::VersionInfo& peerVersionInfo);
30 :
31 : /**
32 : * @ingroup VersionVerify
33 : * @param [in] msgType : communication type
34 : * @brief check whether this type of communication can be understood by server
35 : */
36 : bool SpecialFeatureCheck(const HDCMessage::MsgType& msgType);
37 :
38 : /**
39 : * @ingroup VersionVerify
40 : * @param [in] peerVersionInfo : client version info
41 : * @brief parse and save version info send from client
42 : */
43 : void ParseVersionInfo(const HDCMessage::VersionInfo& peerVersionInfo);
44 :
45 : /**
46 : * @ingroup VersionVerify
47 : * @param [in] msg : message send by client
48 : * @brief add version info to message which client will send to server
49 : */
50 : void SetVersionInfo(HDCMessage& msg) const;
51 :
52 : private:
53 : uint32_t peerVersion_; // used for hdc communication;
54 : std::map<HDCMessage::MsgType, std::set<std::string>> peerFeatureList_;
55 : std::map<HDCMessage::MsgType, bool> alreadyCheckedList_;
56 : };
57 : } // namespace tsd
58 : #endif // COMMON_COMMON_INC_TSD_VERSION_VERIFY_H
|