FD.io VPP  v19.08-27-gf4dcae4
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  */
143  friend class singular_db<key_t, igmp_binding>;
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: ON
177  *
178  * Local Variables:
179  * eval: (c-set-style "mozilla")
180  * End:
181  */
182 
183 #endif
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::shared_ptr< interface > itf() const
Return the matching&#39;singular&#39; of the interface.
A representation of IGMP binding on an interface.
std::string to_string() const
convert to string format for debug purposes
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
const key_t key() const
Get the object&#39;s key.
A representation of an interface in VPP.
Definition: interface.hpp:41
Class definition for listeners to OM events.
Definition: om.hpp:284
inspect command handler Handler
Definition: inspect.hpp:54
~igmp_binding()
Destructor.
void event_handler(void *tls_async)
Definition: tls_async.c:340
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
std::shared_ptr< igmp_binding > singular() const
Return the &#39;singular&#39; of the IGMP binding that matches this object.
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
static void dump(std::ostream &os)
Dump all IGMP bindings into the stream provided.
bool operator==(const igmp_binding &l) const
Equal operator.
interface::key_t key_t
A binding is tied to a given interface, hence its key is that of the interface.
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
igmp_binding(const interface &itf)
Construct a new object matching the desried state.
static std::shared_ptr< igmp_binding > find(const key_t &k)
Find a listen from its key.
std::string key_t
The key for interface&#39;s key.
Definition: interface.hpp:56