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-09 02:10:49 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        3047 : IFMapObjectPtr::IFMapObjectPtr(IFMapNode *node)
      17        3047 :     : type(NODE) {
      18        3047 :       u.node = node;
      19        3047 : }
      20             : 
      21        3341 : IFMapObjectPtr::IFMapObjectPtr(IFMapLink *link)
      22        3341 :     : type(LINK) {
      23        3341 :       u.link = link;
      24        3341 : }
      25             : 
      26        1579 : void IFMapListEntry::set_queue_insert_at_to_now() {
      27        1579 :     queue_insert_at = UTCTimestampUsec();
      28        1579 : }
      29             : 
      30           0 : std::string IFMapListEntry::queue_insert_ago_str() {
      31           0 :     return duration_usecs_to_string(UTCTimestampUsec() - queue_insert_at);
      32             : }
      33             : 
      34         628 : IFMapUpdate::IFMapUpdate(IFMapNode *node, bool positive)
      35             :     : IFMapListEntry(positive ? UPDATE : DEL),
      36         628 :       data_(node) {
      37         628 : }
      38             : 
      39         586 : IFMapUpdate::IFMapUpdate(IFMapLink *link, bool positive)
      40             :     : IFMapListEntry(positive ? UPDATE : DEL),
      41         586 :       data_(link) {
      42         586 : }
      43             : 
      44         890 : std::string IFMapUpdate::ConfigName() {
      45         890 :     std::string name;
      46         890 :     if (data().type == IFMapObjectPtr::NODE) {
      47         432 :         IFMapNode *node = data().u.node;
      48         432 :         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         890 :     return name;
      54           0 : }
      55             : 
      56           0 : std::string IFMapUpdate::ToString() {
      57           0 :     return TypeToString() + ":" + ConfigName();
      58             : }
      59             : 
      60        1796 : void IFMapUpdate::AdvertiseReset(const BitSet &set) {
      61        1796 :     advertise_.Reset(set);
      62        1796 : }
      63             : 
      64        1108 : void IFMapUpdate::AdvertiseOr(const BitSet &set) {
      65        1108 :     advertise_ |= set;
      66        1108 : }
      67             : 
      68         162 : void IFMapUpdate::SetAdvertise(const BitSet &set) {
      69         162 :     advertise_ = set;
      70         162 : }
      71             : 
      72         217 : IFMapMarker::IFMapMarker()
      73         217 :     : IFMapListEntry(MARKER) {
      74         217 : }
      75             : 
      76          50 : std::string IFMapMarker::ToString() {
      77         100 :     return std::string("Marker:") + mask.ToNumberedString();
      78             : }
      79             : 
      80        2419 : IFMapState::IFMapState(IFMapNode *node)
      81        2419 :     : sig_(kInvalidSig), data_(node), crc_(0) {
      82        2419 : }
      83             : 
      84        2755 : IFMapState::IFMapState(IFMapLink *link)
      85        2755 :     : sig_(kInvalidSig), data_(link), crc_(0) {
      86        2755 : }
      87             : 
      88        5174 : IFMapState::~IFMapState() {
      89        5174 :     assert(update_list_.empty());
      90        5174 : }
      91             : 
      92       15350 : IFMapUpdate *IFMapState::GetUpdate(IFMapListEntry::EntryType type) {
      93       15350 :     for (UpdateList::iterator iter = update_list_.begin();
      94       34132 :          iter != update_list_.end(); ++iter) {
      95        3050 :         IFMapUpdate *update = iter.operator->();
      96        3050 :         if (update->type == type) {
      97        1334 :             return update;
      98             :         }
      99             :     }
     100       14016 :     return NULL;
     101             : }
     102             : 
     103        1172 : void IFMapState::Insert(IFMapUpdate *update) {
     104        1172 :     update_list_.push_front(*update);
     105        1172 : }
     106             : 
     107        1138 : void IFMapState::Remove(IFMapUpdate *update) {
     108        2276 :     update_list_.erase(update_list_.s_iterator_to(*update));
     109        1138 : }
     110             : 
     111          68 : IFMapNode *IFMapState::GetIFMapNode() const {
     112          68 :     if (data_.IsNode()) {
     113          68 :         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        2419 : IFMapNodeState::IFMapNodeState(IFMapNode *node)
     128        2419 :     : IFMapState(node) {
     129        2419 : }
     130             : 
     131         176 : bool IFMapNodeState::HasDependents() const {
     132         176 :     return !dependents_.empty();
     133             : }
     134             : 
     135        2755 : IFMapLinkState::IFMapLinkState(IFMapLink *link)
     136        2755 :     : IFMapState(link), left_(link), right_(link) {
     137        2755 : }
     138             : 
     139        2757 : void IFMapLinkState::SetDependency(IFMapNodeState *first,
     140             :                                    IFMapNodeState *second) {
     141        2757 :     left_.reset(first);
     142        2757 :     right_.reset(second);
     143        2757 : }
     144             : 
     145          55 : void IFMapLinkState::RemoveDependency() {
     146          55 :     left_.clear();
     147          55 :     right_.clear();
     148          55 : }
     149             : 
     150         627 : bool IFMapLinkState::HasDependency() const {
     151         627 :     return left_.get() != NULL;
     152             : }
     153             : 

Generated by: LCOV version 1.14