LCOV - code coverage report
Current view: top level - vnsw/agent/cmn - agent_cmn.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 8 13 61.5 %
Date: 2026-11-09 02:10:49 Functions: 1 2 50.0 %
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             : #ifndef vnsw_agent_cmn_hpp
       7             : #define vnsw_agent_cmn_hpp
       8             : 
       9             : #include <sys/socket.h>
      10             : #include <netinet/in.h>
      11             : #include <arpa/inet.h>
      12             : #include <unistd.h>
      13             : 
      14             : #include <boost/intrusive_ptr.hpp>
      15             : #include <boost/bind/bind.hpp>
      16             : #include <boost/uuid/uuid.hpp>
      17             : #include <boost/uuid/uuid_io.hpp>
      18             : #include <boost/uuid/nil_generator.hpp>
      19             : 
      20             : #include <io/event_manager.h>
      21             : #include <db/db.h>
      22             : #include <db/db_entry.h>
      23             : #include <db/db_table.h>
      24             : #include <db/db_table_partition.h>
      25             : #include <db/db_table_walker.h>
      26             : 
      27             : #include <base/address.h>
      28             : #include <base/logging.h>
      29             : #include <base/task.h>
      30             : #include <base/task_trigger.h>
      31             : #include <base/task_annotations.h>
      32             : #include <base/dependency.h>
      33             : #include <base/lifetime.h>
      34             : 
      35             : #include <ifmap/ifmap_agent_parser.h>
      36             : #include <ifmap/ifmap_agent_table.h>
      37             : 
      38             : #include <sandesh/sandesh_trace.h>
      39             : #include <sandesh/common/vns_constants.h>
      40             : 
      41             : #include <cmn/agent.h>
      42             : #include <cmn/agent_db.h>
      43             : #include <cmn/event_notifier.h>
      44             : 
      45             : #include <stdio.h>
      46             : #include <execinfo.h>
      47             : #include <dlfcn.h>
      48             : #include <cxxabi.h>
      49             : 
      50             : using namespace boost::placeholders;
      51             : 
      52             : static inline bool UnregisterDBTable(DBTable *table,
      53             :                                      DBTableBase::ListenerId id) {
      54             :     table->Unregister(id);
      55             :     return true;
      56             : }
      57             : 
      58             : static inline TaskTrigger *SafeDBUnregister(DBTable *table,
      59             :                                             DBTableBase::ListenerId id) {
      60             :     TaskTrigger *trigger =
      61             :            new TaskTrigger(boost::bind(&UnregisterDBTable, table, id),
      62             :                TaskScheduler::GetInstance()->GetTaskId("db::DBTable"), 0);
      63             :     trigger->Set();
      64             :     return trigger;
      65             : }
      66             : 
      67        8098 : static inline void CfgUuidSet(uint64_t ms_long, uint64_t ls_long,
      68             :                               boost::uuids::uuid &u) {
      69       72882 :     for (int i = 0; i < 8; i++) {
      70       64784 :         u.data[7 - i] = ms_long & 0xFF;
      71       64784 :         ms_long = ms_long >> 8;
      72             :     }
      73             : 
      74       72882 :     for (int i = 0; i < 8; i++) {
      75       64784 :         u.data[15 - i] = ls_long & 0xFF;
      76       64784 :         ls_long = ls_long >> 8;
      77             :     }
      78        8098 : }
      79             : 
      80           0 : static inline void CloseTaskFds(void) {
      81           0 :     int max_open_fds = sysconf(_SC_OPEN_MAX);
      82             :     int fd;
      83           0 :     for(fd = 3; fd < max_open_fds; fd++)
      84           0 :         close(fd);
      85           0 : }
      86             : 
      87             : extern SandeshTraceBufferPtr OperConfigTraceBuf;
      88             : 
      89             : #define OPER_IFMAP_TRACE(obj, ...)\
      90             : do {\
      91             :    Oper##obj::TraceMsg(OperConfigTraceBuf, __FILE__, __LINE__, __VA_ARGS__);\
      92             : } while (false)
      93             : 
      94             : #define IFMAP_ERROR(obj, ...)\
      95             : do {\
      96             :     if (LoggingDisabled()) break;\
      97             :     obj::Send(g_vns_constants.CategoryNames.find(Category::IFMAP_AGENT)->second,\
      98             :               SandeshLevel::SYS_ERR, __FILE__, __LINE__, ##__VA_ARGS__);\
      99             : } while (false)
     100             : 
     101             : std::string AgentBackTrace(int skip);
     102             : #endif // vnsw_agent_cmn_hpp

Generated by: LCOV version 1.14