LCOV - code coverage report
Current view: top level - ifmap - ifmap_update.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 83 97 85.6 %
Date: 2026-11-23 02:04:52 Functions: 24 29 82.8 %
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 "ifmap/ifmap_update.h"
       7             : 
       8             : #include "base/time_util.h"
       9             : #include "ifmap/ifmap_node.h"
      10             : 
      11           0 : IFMapObjectPtr::IFMapObjectPtr()
      12           0 :     : type(NIL) {
      13           0 :       u.ptr = NULL;
      14           0 : }
      15             : 
      16        3031 : IFMapObjectPtr::IFMapObjectPtr(IFMapNode *node)
      17        3031 :     : type(NODE) {
      18        3031 :       u.node = node;
      19        3031 : }
      20             : 
      21        3326 : IFMapObjectPtr::IFMapObjectPtr(IFMapLink *link)
      22        3326 :     : type(LINK) {
      23        3326 :       u.link = link;
      24        3326 : }
      25             : 
      26        1580 : void IFMapListEntry::set_queue_insert_at_to_now() {
      27        1580 :     queue_insert_at = UTCTimestampUsec();
      28        1580 : }
      29             : 
      30           0 : std::string IFMapListEntry::queue_insert_ago_str() {
      31           0 :     return duration_usecs_to_string(UTCTimestampUsec() - queue_insert_at);
      32             : }
      33             : 
      34         629 : IFMapUpdate::IFMapUpdate(IFMapNode *node, bool positive)
      35             :     : IFMapListEntry(positive ? UPDATE : DEL),
      36         629 :       data_(node) {
      37         629 : }
      38             : 
      39         586 : IFMapUpdate::IFMapUpdate(IFMapLink *link, bool positive)
      40             :     : IFMapListEntry(positive ? UPDATE : DEL),
      41         586 :       data_(link) {
      42         586 : }
      43             : 
      44         891 : std::string IFMapUpdate::ConfigName() {
      45         891 :     std::string name;
      46         891 :     if (data().type == IFMapObjectPtr::NODE) {
      47         433 :         IFMapNode *node = data().u.node;
      48         433 :         name = node->ToString();
      49         458 :     } else if (data().type == IFMapObjectPtr::LINK) {
      50         458 :         IFMapLink *link = data().u.link;
      51         458 :         name = link->ToString();
      52             :     }
      53         891 :     return name;
      54           0 : }
      55             : 
      56           0 : std::string IFMapUpdate::ToString() {
      57           0 :     return TypeToString() + ":" + ConfigName();
      58             : }
      59             : 
      60        1797 : void IFMapUpdate::AdvertiseReset(const BitSet &set) {
      61        1797 :     advertise_.Reset(set);
      62        1797 : }
      63             : 
      64        1108 : void IFMapUpdate::AdvertiseOr(const BitSet &set) {
      65        1108 :     advertise_ |= set;
      66        1108 : }
      67             : 
      68         163 : void IFMapUpdate::SetAdvertise(const BitSet &set) {
      69         163 :     advertise_ = set;
      70         163 : }
      71             : 
      72         217 : IFMapMarker::IFMapMarker()
      73         217 :     : IFMapListEntry(MARKER) {
      74         217 : }
      75             : 
      76          51 : std::string IFMapMarker::ToString() {
      77         102 :     return std::string("Marker:") + mask.ToNumberedString();
      78             : }
      79             : 
      80        2402 : IFMapState::IFMapState(IFMapNode *node)
      81        2402 :     : sig_(kInvalidSig), data_(node), crc_(0) {
      82        2402 : }
      83             : 
      84        2740 : IFMapState::IFMapState(IFMapLink *link)
      85        2740 :     : sig_(kInvalidSig), data_(link), crc_(0) {
      86        2740 : }
      87             : 
      88        5142 : IFMapState::~IFMapState() {
      89        5142 :     assert(update_list_.empty());
      90        5142 : }
      91             : 
      92       15188 : IFMapUpdate *IFMapState::GetUpdate(IFMapListEntry::EntryType type) {
      93       15188 :     for (UpdateList::iterator iter = update_list_.begin();
      94       33810 :          iter != update_list_.end(); ++iter) {
      95        3051 :         IFMapUpdate *update = iter.operator->();
      96        3051 :         if (update->type == type) {
      97        1334 :             return update;
      98             :         }
      99             :     }
     100       13854 :     return NULL;
     101             : }
     102             : 
     103        1173 : void IFMapState::Insert(IFMapUpdate *update) {
     104        1173 :     update_list_.push_front(*update);
     105        1173 : }
     106             : 
     107        1139 : void IFMapState::Remove(IFMapUpdate *update) {
     108        2278 :     update_list_.erase(update_list_.s_iterator_to(*update));
     109        1139 : }
     110             : 
     111          67 : IFMapNode *IFMapState::GetIFMapNode() const {
     112          67 :     if (data_.IsNode()) {
     113          67 :         return data_.u.node;
     114             :     } else {
     115           0 :         return NULL;
     116             :     }
     117             : }
     118             : 
     119           0 : IFMapLink *IFMapState::GetIFMapLink() const {
     120           0 :     if (data_.IsLink()) {
     121           0 :         return data_.u.link;
     122             :     } else {
     123           0 :         return NULL;
     124             :     }
     125             : }
     126             : 
     127        2402 : IFMapNodeState::IFMapNodeState(IFMapNode *node)
     128        2402 :     : IFMapState(node) {
     129        2402 : }
     130             : 
     131          95 : bool IFMapNodeState::HasDependents() const {
     132          95 :     return !dependents_.empty();
     133             : }
     134             : 
     135        2740 : IFMapLinkState::IFMapLinkState(IFMapLink *link)
     136        2740 :     : IFMapState(link), left_(link), right_(link) {
     137        2740 : }
     138             : 
     139        2742 : void IFMapLinkState::SetDependency(IFMapNodeState *first,
     140             :                                    IFMapNodeState *second) {
     141        2742 :     left_.reset(first);
     142        2742 :     right_.reset(second);
     143        2742 : }
     144             : 
     145          37 : void IFMapLinkState::RemoveDependency() {
     146          37 :     left_.clear();
     147          37 :     right_.clear();
     148          37 : }
     149             : 
     150         626 : bool IFMapLinkState::HasDependency() const {
     151         626 :     return left_.get() != NULL;
     152             : }
     153             : 

Generated by: LCOV version 1.14