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: 17 26 65.4 %
Date: 2026-11-23 02:04:52 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             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #include "bgp/bgp_peer_key.h"
       7             : 
       8             : 
       9             : #include "base/string_util.h"
      10             : #include "bgp/bgp_config.h"
      11             : 
      12             : using boost::asio::ip::address;
      13             : using boost::system::error_code;
      14             : using boost::uuids::nil_generator;
      15             : using std::exception;
      16             : 
      17        1856 : BgpPeerKey::BgpPeerKey() {
      18             :     nil_generator nil;
      19        1856 :     uuid = nil();
      20        1856 : }
      21             : 
      22         400 : BgpPeerKey::BgpPeerKey(const BgpNeighborConfig *config) {
      23         400 :     error_code ec;
      24         400 :     endpoint.address(config->peer_address());
      25         400 :     endpoint.port(config->port());
      26             : 
      27         400 :     if (!config->uuid().empty()) {
      28             : #if defined(__EXCEPTIONS)
      29             :     try {
      30             : #endif
      31         400 :         uuid = StringToUuid(config->uuid());
      32             : #if defined(__EXCEPTIONS)
      33           0 :     } catch (exception &ex) {
      34             :         nil_generator nil;
      35           0 :         uuid = nil();
      36           0 :     }
      37             : #endif
      38             :     } else {
      39             :         boost::uuids::nil_generator nil;
      40           0 :         uuid = nil();
      41             :     }
      42         400 : }
      43             : 
      44         719 : bool BgpPeerKey::operator<(const BgpPeerKey &rhs) const {
      45         719 :     if (endpoint != rhs.endpoint) {
      46           0 :         return (endpoint < rhs.endpoint);
      47             :     }
      48         719 :     return uuid < rhs.uuid;
      49             : }
      50             : 
      51           0 : bool BgpPeerKey::operator>(const BgpPeerKey &rhs) const {
      52           0 :     if (endpoint != rhs.endpoint) {
      53           0 :         return (endpoint > rhs.endpoint);
      54             :     }
      55           0 :     return uuid > rhs.uuid;
      56             : }
      57             : 
      58         166 : bool BgpPeerKey::operator==(const BgpPeerKey &rhs) const {
      59         166 :     return (endpoint == rhs.endpoint && uuid == rhs.uuid);
      60             : }
      61             : 
      62         132 : bool BgpPeerKey::operator!=(const BgpPeerKey &rhs) const {
      63         132 :     return (endpoint != rhs.endpoint || uuid != rhs.uuid);
      64             : }

Generated by: LCOV version 1.14