FD.io VPP  v18.07.1-19-g511ce25
Vector Packet Processing
lldp_global.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __VOM_LLDP_GLOBAL_H__
17 #define __VOM_LLDP_GLOBAL_H__
18 
19 #include "vom/hw.hpp"
20 #include "vom/inspect.hpp"
21 #include "vom/object_base.hpp"
22 #include "vom/om.hpp"
23 #include "vom/singular_db.hpp"
24 
25 namespace VOM {
26 /**
27  * A representation of LLDP global configuration
28  */
29 class lldp_global : public object_base
30 {
31 public:
32  /**
33  * The key for the global conifugration is the 'system' namse
34  */
35  typedef std::string key_t;
36 
37  /**
38  * Construct a new object matching the desried state
39  */
40  lldp_global(const std::string& system_name,
41  uint32_t tx_hold,
42  uint32_t tx_interval);
43 
44  /**
45  * Copy Constructor
46  */
47  lldp_global(const lldp_global& o);
48 
49  /**
50  * Destructor
51  */
52  ~lldp_global();
53 
54  /**
55  * Get this objects key
56  */
57  const key_t& key() const;
58 
59  /**
60  * Comparison operator
61  */
62  bool operator==(const lldp_global& l) const;
63 
64  /**
65  * Return the 'singular' of the LLDP global that matches this object
66  */
67  std::shared_ptr<lldp_global> singular() const;
68 
69  /**
70  * convert to string format for debug purposes
71  */
72  std::string to_string() const;
73 
74  /**
75  * Dump all LLDP globals into the stream provided
76  */
77  static void dump(std::ostream& os);
78 
79  /**
80  * Find LLDP global config from its key
81  */
82  static std::shared_ptr<lldp_global> find(const key_t& k);
83 
84 private:
85  /**
86  * Class definition for listeners to OM events
87  */
89  {
90  public:
91  event_handler();
92  virtual ~event_handler() = default;
93 
94  /**
95  * Handle a populate event
96  */
97  void handle_populate(const client_db::key_t& key);
98 
99  /**
100  * Handle a replay event
101  */
102  void handle_replay();
103 
104  /**
105  * Show the object in the Singular DB
106  */
107  void show(std::ostream& os);
108 
109  /**
110  * Get the sortable Id of the listener
111  */
112  dependency_t order() const;
113  };
114 
115  /**
116  * event_handler to register with OM
117  */
118  static event_handler m_evh;
119 
120  /**
121  * Enquue commonds to the VPP command Q for the update
122  */
123  void update(const lldp_global& obj);
124 
125  /**
126  * Find or add LLDP global to the OM
127  */
128  static std::shared_ptr<lldp_global> find_or_add(const lldp_global& temp);
129 
130  /*
131  * It's the OM class that calls singular()
132  */
133  friend class OM;
134 
135  /**
136  * It's the singular_db class that calls replay()
137  */
138  friend class singular_db<key_t, lldp_global>;
139 
140  /**
141  * Sweep/reap the object if still stale
142  */
143  void sweep(void);
144 
145  /**
146  * replay the object to create it in hardware
147  */
148  void replay(void);
149 
150  /**
151  * The system name
152  */
153  const std::string m_system_name;
154 
155  /**
156  * TX timer configs
157  */
158  uint32_t m_tx_hold;
159  uint32_t m_tx_interval;
160 
161  /**
162  * HW globaluration for the binding. The bool representing the
163  * do/don't bind.
164  */
165  HW::item<bool> m_binding;
166 
167  /**
168  * A map of all Lldp globals keyed against the system name.
169  * there needs to be some sort of key, that will do.
170  */
172 };
173 };
174 
175 /*
176  * fd.io coding-style-patch-verification: ON
177  *
178  * Local Variables:
179  * eval: (c-set-style "mozilla")
180  * End:
181  */
182 
183 #endif
const key_t & key() const
Get this objects key.
Definition: lldp_global.cpp:53
static void dump(std::ostream &os)
Dump all LLDP globals into the stream provided.
Definition: lldp_global.cpp:72
bool operator==(const lldp_global &l) const
Comparison operator.
Definition: lldp_global.cpp:59
std::shared_ptr< lldp_global > singular() const
Return the &#39;singular&#39; of the LLDP global that matches this object.
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
Definition: client_db.hpp:51
std::string key_t
The key for the global conifugration is the &#39;system&#39; namse.
Definition: lldp_global.hpp:35
std::string to_string() const
convert to string format for debug purposes
Definition: lldp_global.cpp:87
A representation of LLDP global configuration.
Definition: lldp_global.hpp:29
static std::shared_ptr< lldp_global > find(const key_t &k)
Find LLDP global config from its key.
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
lldp_global(const std::string &system_name, uint32_t tx_hold, uint32_t tx_interval)
Construct a new object matching the desried state.
Definition: lldp_global.cpp:28
Class definition for listeners to OM events.
Definition: om.hpp:284
inspect command handler Handler
Definition: inspect.hpp:54
void event_handler(void *tls_async)
Definition: tls_async.c:311
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
Definition: types.hpp:43
The interface to writing objects into VPP OM.
Definition: om.hpp:140
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
~lldp_global()
Destructor.
Definition: lldp_global.cpp:44
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105