FD.io VPP  v18.07-rc0-415-g6c78436
Vector Packet Processing
arp_proxy_binding.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_ARP_PROXY_BINDING_H__
17 #define __VOM_ARP_PROXY_BINDING_H__
18 
19 #include "vom/arp_proxy_config.hpp"
20 #include "vom/hw.hpp"
21 #include "vom/inspect.hpp"
22 #include "vom/interface.hpp"
23 #include "vom/object_base.hpp"
24 #include "vom/om.hpp"
25 #include "vom/singular_db.hpp"
26 
27 namespace VOM {
28 /**
29  * A representation of LLDP client configuration on an interface
30  */
32 {
33 public:
34  /**
35  * Construct a new object matching the desried state
36  */
37  arp_proxy_binding(const interface& itf);
38 
39  /**
40  * Copy Constructor
41  */
43 
44  /**
45  * Destructor
46  */
48 
49  /**
50  * Return the 'singular' of the LLDP binding that matches this object
51  */
52  std::shared_ptr<arp_proxy_binding> singular() const;
53 
54  /**
55  * convert to string format for debug purposes
56  */
57  std::string to_string() const;
58 
59  /**
60  * Dump all LLDP bindings into the stream provided
61  */
62  static void dump(std::ostream& os);
63 
64 private:
65  /**
66  * Class definition for listeners to OM events
67  */
69  {
70  public:
71  event_handler();
72  virtual ~event_handler() = default;
73 
74  /**
75  * Handle a populate event
76  */
77  void handle_populate(const client_db::key_t& key);
78 
79  /**
80  * Handle a replay event
81  */
82  void handle_replay();
83 
84  /**
85  * Show the object in the Singular DB
86  */
87  void show(std::ostream& os);
88 
89  /**
90  * Get the sortable Id of the listener
91  */
92  dependency_t order() const;
93  };
94 
95  /**
96  * event_handler to register with OM
97  */
98  static event_handler m_evh;
99 
100  /**
101  * Enquue commonds to the VPP command Q for the update
102  */
103  void update(const arp_proxy_binding& obj);
104 
105  /**
106  * Find or add LLDP binding to the OM
107  */
108  static std::shared_ptr<arp_proxy_binding> find_or_add(
109  const arp_proxy_binding& temp);
110 
111  /*
112  * It's the OM class that calls singular()
113  */
114  friend class OM;
115 
116  /**
117  * It's the singular_db class that calls replay()
118  */
119  friend class singular_db<interface::key_t, arp_proxy_binding>;
120 
121  /**
122  * Sweep/reap the object if still stale
123  */
124  void sweep(void);
125 
126  /**
127  * replay the object to create it in hardware
128  */
129  void replay(void);
130 
131  /**
132  * A reference counting pointer to the interface on which LLDP config
133  * resides. By holding the reference here, we can guarantee that
134  * this object will outlive the interface
135  */
136  const std::shared_ptr<interface> m_itf;
137 
138  /**
139  * HW configuration for the binding. The bool representing the
140  * do/don't bind.
141  */
142  HW::item<bool> m_binding;
143 
144  /**
145  * A map of all ArpProxy bindings keyed against the interface.
146  */
147  static singular_db<interface::key_t, arp_proxy_binding> m_db;
148 };
149 };
150 
151 /*
152  * fd.io coding-style-patch-verification: ON
153  *
154  * Local Variables:
155  * eval: (c-set-style "mozilla")
156  * End:
157  */
158 
159 #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
A HW::item is data that is either to be written to or read from VPP/HW.
Definition: hw.hpp:43
std::shared_ptr< arp_proxy_binding > singular() const
Return the &#39;singular&#39; of the LLDP binding that matches this object.
static void dump(std::ostream &os)
Dump all LLDP bindings into the stream provided.
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
A representation of LLDP client configuration on an interface.
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
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
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
~arp_proxy_binding()
Destructor.
arp_proxy_binding(const interface &itf)
Construct a new object matching the desried state.