LCOV - code coverage report
Current view: top level - bgp - bgp_peer_key.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 19 26 73.1 %
Date: 2026-06-18 01:51:13 Functions: 5 6 83.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #include "bgp/bgp_peer_key.h"
       6             : 
       7             : 
       8             : #include "base/string_util.h"
       9             : #include "bgp/bgp_config.h"
      10             : 
      11             : using boost::asio::ip::address;
      12             : using boost::system::error_code;
      13             : using boost::uuids::nil_generator;
      14             : using std::exception;
      15             : 
      16       17347 : BgpPeerKey::BgpPeerKey() {
      17             :     nil_generator nil;
      18       17346 :     uuid = nil();
      19       17345 : }
      20             : 
      21       30750 : BgpPeerKey::BgpPeerKey(const BgpNeighborConfig *config) {
      22       30750 :     error_code ec;
      23       30750 :     endpoint.address(config->peer_address());
      24       30750 :     endpoint.port(config->port());
      25             : 
      26       30750 :     if (!config->uuid().empty()) {
      27             : #if defined(__EXCEPTIONS)
      28             :     try {
      29             : #endif
      30       29388 :         uuid = StringToUuid(config->uuid());
      31             : #if defined(__EXCEPTIONS)
      32           0 :     } catch (exception &ex) {
      33             :         nil_generator nil;
      34           0 :         uuid = nil();
      35           0 :     }
      36             : #endif
      37             :     } else {
      38             :         boost::uuids::nil_generator nil;
      39        1362 :         uuid = nil();
      40             :     }
      41       30750 : }
      42             : 
      43       53171 : bool BgpPeerKey::operator<(const BgpPeerKey &rhs) const {
      44       53171 :     if (endpoint != rhs.endpoint) {
      45        3705 :         return (endpoint < rhs.endpoint);
      46             :     }
      47       49466 :     return uuid < rhs.uuid;
      48             : }
      49             : 
      50           0 : bool BgpPeerKey::operator>(const BgpPeerKey &rhs) const {
      51           0 :     if (endpoint != rhs.endpoint) {
      52           0 :         return (endpoint > rhs.endpoint);
      53             :     }
      54           0 :     return uuid > rhs.uuid;
      55             : }
      56             : 
      57       17065 : bool BgpPeerKey::operator==(const BgpPeerKey &rhs) const {
      58       17065 :     return (endpoint == rhs.endpoint && uuid == rhs.uuid);
      59             : }
      60             : 
      61       10060 : bool BgpPeerKey::operator!=(const BgpPeerKey &rhs) const {
      62       10060 :     return (endpoint != rhs.endpoint || uuid != rhs.uuid);
      63             : }

Generated by: LCOV version 1.14