LCOV - code coverage report
Current view: top level - bfd - bfd_common.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 5 10 50.0 %
Date: 2026-06-08 02:02:55 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2014 CodiLime, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #include "bfd/bfd_common.h"
       6             : 
       7             : #include <string>
       8             : #include <boost/bimap.hpp>
       9             : #include <boost/bimap/unordered_set_of.hpp>
      10             : #include <boost/optional.hpp>
      11             : #include <boost/assign/list_of.hpp>
      12             : 
      13             : namespace BFD {
      14             : typedef boost::bimap<BFDState, std::string> BFDStateNames;
      15             : 
      16             : static BFDStateNames kBFDStateNames =
      17             :         boost::assign::list_of<BFDStateNames::relation>
      18             :         (kAdminDown, std::string("AdminDown"))
      19             :         (kDown,      std::string("Down"))
      20             :         (kInit,      std::string("Init"))
      21             :         (kUp,        std::string("Up"));
      22             : 
      23          76 : std::ostream &operator<<(std::ostream &out, BFDState state) {
      24             :     try {
      25          76 :         out << kBFDStateNames.left.at(state);
      26           0 :     } catch (std::out_of_range &) {
      27           0 :         out << "Unknown";
      28           0 :     }
      29             : 
      30          76 :     return out;
      31             : }
      32             : 
      33          10 : boost::optional<BFDState> BFDStateFromString(const std::string& str) {
      34             :     try {
      35          10 :         return boost::optional<BFDState>(kBFDStateNames.right.at(str));
      36           0 :     } catch (std::out_of_range &) {}
      37             : 
      38           0 :     return boost::optional<BFDState>();
      39             : }
      40             : 
      41             : const int kMinimalPacketLength = 24;
      42             : const TimeInterval kIdleTxInterval = boost::posix_time::seconds(1);
      43             : boost::random::taus88 randomGen;
      44             : }  // namespace BFD

Generated by: LCOV version 1.14