LCOV - code coverage report
Current view: top level - coll_communicator_mgr/rank_graph/rank_table_info - address_info.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 3 3
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 3 3

            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 ADDRESS_INFO_H
      12              : #define ADDRESS_INFO_H
      13              : 
      14              : #include <set>
      15              : #include <string>
      16              : #include <vector>
      17              : #include "nlohmann/json.hpp"
      18              : #include "ip_address.h"
      19              : #include "topo_common_types.h"
      20              : 
      21              : namespace Hccl {
      22              : 
      23              : constexpr unsigned int MIN_VALUE_PLANEID = 0;
      24              : constexpr unsigned int MAX_VALUE_PLANEID = 1024;
      25              : constexpr unsigned int MIN_VALUE_PORT = 1;
      26              : constexpr unsigned int MAX_VALUE_PORT = 16;
      27              : constexpr unsigned int MIN_VALUE_PORT_LENGTH = 1;
      28              : constexpr unsigned int MAX_VALUE_PORT_LENGTH = 32;
      29              : constexpr unsigned int MIN_VALUE_ADDR_LENGRH = 1;
      30              : constexpr unsigned int MAX_VALUE_ADDR_LENGRH = 256;
      31              : constexpr unsigned int MAX_VALUE_BACKUP_ADDR_SIZE = 16;
      32              : 
      33              : class AddressInfo {
      34              : public:
      35         1113 :     AddressInfo() {};
      36         2401 :     ~AddressInfo() {};
      37              : 
      38              :     IpAddress addr;
      39              :     std::vector<IpAddress> backupAddrs;
      40              :     u32 socketPort_{0}; // socket监听端口
      41              :     AddrType addrType;
      42              :     std::set<std::string> ports; // 网口标记
      43              :     std::string planeId{"0"};
      44              :     void Deserialize(const nlohmann::json& addressInfoJson);
      45              :     explicit AddressInfo(BinaryStream& binStream);
      46              :     void GetBinStream(BinaryStream& binStream) const;
      47              :     std::string Describe() const;
      48              :     static void ParseAddrByType(const std::string& addrType, const std::string& address, IpAddress& ipAddress);
      49              :     static void ParseBackupAddrs(
      50              :         const nlohmann::json& backupAddrJson, const std::string& addrType, std::vector<IpAddress>& backupAddrs);
      51              : 
      52              : private:
      53              :     static constexpr int MAX_DISPLAY_LEN = 128;
      54              :     static const std::unordered_map<std::string, AddrType> strToAddrType;
      55              :     void EidToAddr(std::string str);
      56              :     void IPV4ToAddr(std::string str);
      57              :     void IPV6ToAddr(std::string str);
      58              :     void DeserializeBackupAddrs(const nlohmann::json& addressInfoJson, const std::string& addrTypeStr);
      59          317 :     static bool IsStringInAddrType(std::string str) { return strToAddrType.count(str) > 0; }
      60              : };
      61              : 
      62              : } // namespace Hccl
      63              : 
      64              : #endif // ADDRESS_INFO_H
        

Generated by: LCOV version 2.0-1