LCOV - code coverage report
Current view: top level - vnsw/agent/services/multicast/agent_map - patricia_map.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 11 11 100.0 %
Date: 2026-08-03 02:19:58 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #ifndef vnsw_agent_patricia_map_h
       6             : #define vnsw_agent_patricia_map_h
       7             : 
       8             : #include "base/patricia.h"
       9             : 
      10             : #include <stdint.h>
      11             : 
      12             : class PatriciaNode {
      13             : public:
      14       21970 :     PatriciaNode(int klen, int koffset, void *knode, const void *key_ptr) :
      15       21970 :             klen_(klen), koffset_(koffset), knode_(knode), key_ptr_(key_ptr) {
      16       21970 :     }
      17             : 
      18             :     class Key {
      19             :     public:
      20      213816 :         static std::size_t BitLength(const PatriciaNode *key) {
      21      213816 :             return key->klen_*8;
      22             :         }
      23             : 
      24      333974 :         static char ByteValue(const PatriciaNode *key, std::size_t i) {
      25      333974 :             const char *ch = (const char *)key->key_ptr_;
      26      333974 :             return ch[key->koffset_ + key->klen_ - i - 1];
      27             :         }
      28             :     };
      29             : 
      30             :     int klen_;
      31             :     int koffset_;
      32             :     void *knode_;
      33             :     const void *key_ptr_;
      34             :     Patricia::Node node_;
      35             : };
      36             : 
      37             : template <class D, Patricia::Node D::* P, class K>
      38             : class PatriciaMap : public Patricia::Tree<D, P, K> {
      39             : public:
      40        6473 :     PatriciaMap(uint16_t klen, uint8_t koffset) :
      41        6473 :                 Patricia::Tree<D, P, K>(), klen_(klen), koffset_(koffset) {
      42        6473 :     }
      43             : 
      44             :     uint16_t klen_;
      45             :     uint8_t koffset_;
      46             : };
      47             : 
      48             : typedef PatriciaMap<PatriciaNode, &PatriciaNode::node_, PatriciaNode::Key> PatriciaMapTable;
      49             : 
      50             : #endif /* vnsw_agent_patricia_map_h */

Generated by: LCOV version 1.14