FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
igmp_binding.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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_IGMP_BINDING_H__
17 #define __VOM_IGMP_BINDING_H__
18 
19 #include "vom/hw.hpp"
20 #include "vom/inspect.hpp"
21 #include "vom/interface.hpp"
22 #include "vom/object_base.hpp"
23 #include "vom/om.hpp"
24 #include "vom/singular_db.hpp"
25 
26 namespace VOM {
27 /**
28  * A representation of IGMP binding on an interface
29  */
30 class igmp_binding : public object_base
31 {
32 public:
33  /**
34  * A binding is tied to a given interface, hence its key is
35  * that of the interface
36  */
38 
39  /**
40  * Construct a new object matching the desried state
41  */
42  igmp_binding(const interface& itf);
43 
44  /**
45  * Copy Constructor
46  */
47  igmp_binding(const igmp_binding& o);
48 
49  /**
50  * Destructor
51  */
52  ~igmp_binding();
53 
54  /**
55  * Equal operator
56  */
57  bool operator==(const igmp_binding& l) const;
58 
59  /**
60  * Get the object's key
61  */
62  const key_t key() const;
63 
64  /**
65  * Return the 'singular' of the IGMP binding that matches this object
66  */
67  std::shared_ptr<igmp_binding> singular() const;
68 
69  /**
70  * convert to string format for debug purposes
71  */
72  std::string to_string() const;
73 
74  /**
75  * Return the matching'singular' of the interface
76  */
77  std::shared_ptr<interface> itf() const;
78 
79  /**
80  * Dump all IGMP bindings into the stream provided
81  */
82  static void dump(std::ostream& os);
83 
84  /**
85  * Find a listen from its key
86  */
87  static std::shared_ptr<igmp_binding> find(const key_t& k);
88 
89 private:
90  /**
91  * Class definition for listeners to OM events
92  */
94  {
95  public:
96  event_handler();
97  virtual ~event_handler() = default;
98 
99  /**
100  * Handle a populate event
101  */
102  void handle_populate(const client_db::key_t& key);
103 
104  /**
105  * Handle a replay event
106  */
107  void handle_replay();
108 
109  /**
110  * Show the object in the Singular DB
111  */
112  void show(std::ostream& os);
113 
114  /**
115  * Get the sortable Id of the listener
116  */
117  dependency_t order() const;
118  };
119 
120  /**
121  * event_handler to register with OM
122  */
123  static event_handler m_evh;
124 
125  /**
126  * Enquue commonds to the VPP command Q for the update
127  */
128  void update(const igmp_binding& obj);
129 
130  /**
131  * Find or add IGMP binding to the OM
132  */
133  static std::shared_ptr<igmp_binding> find_or_add(const igmp_binding& temp);
134 
135  /*
136  * It's the OM class that calls singular()
137  */
138  friend class OM;
139 
140  /**
141  * It's the singular_db class that calls replay()
142  */
144 
145  /**
146  * Sweep/reap the object if still stale
147  */
148  void sweep(void);
149 
150  /**
151  * replay the object to create it in hardware
152  */
153  void replay(void);
154 
155  /**
156  * A reference counting pointer to the interface on which IGMP config
157  * resides. By holding the reference here, we can guarantee that
158  * this object will outlive the interface
159  */
160  const std::shared_ptr<interface> m_itf;
161 
162  /**
163  * HW configuration for the binding. The bool representing the
164  * do/don't bind.
165  */
166  HW::item<bool> m_binding;
167 
168  /**
169  * A map of all IGMP bindings keyed against the interface.
170  */
172 };
173 };
174 
175 /*
176  * fd.io coding-style-patch-verification: OFF
177  *
178  * Local Variables:
179  * eval: (c-set-style "mozilla")
180  * End:
181  */
182 
183 #endif
VOM::HW::item< bool >
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::dependency_t
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
om.hpp
VOM::igmp_binding::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: igmp_binding.cpp:83
VOM::OM
The interface to writing objects into VPP OM.
Definition: om.hpp:140
VOM::inspect::command_handler
inspect command handler Handler
Definition: inspect.hpp:54
VOM::OM::listener
Class definition for listeners to OM events.
Definition: om.hpp:284
VOM::igmp_binding::key
const key_t key() const
Get the object's key.
Definition: igmp_binding.cpp:54
VOM::interface
A representation of an interface in VPP.
Definition: interface.hpp:41
hw.hpp
VOM::client_db::key_t
const typedef 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
VOM::igmp_binding::~igmp_binding
~igmp_binding()
Destructor.
Definition: igmp_binding.cpp:41
inspect.hpp
singular_db.hpp
VOM::igmp_binding
A representation of IGMP binding on an interface.
Definition: igmp_binding.hpp:30
interface.hpp
VOM::singular_db
A Database to store the unique 'singular' instances of a single object type.
Definition: singular_db.hpp:33
VOM::igmp_binding::singular
std::shared_ptr< igmp_binding > singular() const
Return the 'singular' of the IGMP binding that matches this object.
Definition: igmp_binding.cpp:115
VOM::igmp_binding::find
static std::shared_ptr< igmp_binding > find(const key_t &k)
Find a listen from its key.
Definition: igmp_binding.cpp:109
VOM::igmp_binding::dump
static void dump(std::ostream &os)
Dump all IGMP bindings into the stream provided.
Definition: igmp_binding.cpp:69
VOM::igmp_binding::key_t
interface::key_t key_t
A binding is tied to a given interface, hence its key is that of the interface.
Definition: igmp_binding.hpp:37
VOM::interface::key_t
std::string key_t
The key for interface's key.
Definition: interface.hpp:56
show
void show(char *chroot_path, int verbose)
Definition: svmtool.c:104
event_handler
void event_handler(void *tls_async)
Definition: tls_async.c:334
VOM::object_base
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
VOM::igmp_binding::igmp_binding
igmp_binding(const interface &itf)
Construct a new object matching the desried state.
Definition: igmp_binding.cpp:29
VOM::igmp_binding::itf
std::shared_ptr< interface > itf() const
Return the matching'singular' of the interface.
Definition: igmp_binding.cpp:121
object_base.hpp
VOM::igmp_binding::operator==
bool operator==(const igmp_binding &l) const
Equal operator.
Definition: igmp_binding.cpp:48
string
const char *const string
Definition: cJSON.h:172