FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
bridge_domain_arp_entry.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_BRIDGE_DOMAIN_ARP_ENTRY_H__
17 #define __VOM_BRIDGE_DOMAIN_ARP_ENTRY_H__
18 
19 #include "vom/bridge_domain.hpp"
20 #include "vom/interface.hpp"
21 #include "vom/singular_db.hpp"
22 #include "vom/types.hpp"
23 
24 namespace VOM {
25 /**
26  * A entry in the ARP termination table of a Bridge Domain
27  */
29 {
30 public:
31  /**
32  * The key for a bridge_domain ARP entry;
33  * the BD, IP address and MAC address
34  */
35  typedef std::pair<bridge_domain::key_t, boost::asio::ip::address> key_t;
36 
37  /**
38  * Construct a bridge domain ARP Entry in the given bridge domain
39  */
41  const boost::asio::ip::address& ip_addr,
42  const mac_address_t& mac);
43 
44  /**
45  * Construct a bridge domain ARP entry in the default table
46  */
48  const mac_address_t& mac);
49 
50  /**
51  * Copy Construct
52  */
54 
55  /**
56  * Destructor
57  */
59 
60  /**
61  * Return the object's key
62  */
63  const key_t key() const;
64 
65  /**
66  * comparison operator
67  */
68  bool operator==(const bridge_domain_arp_entry& bdae) const;
69 
70  /**
71  * Return the matching 'singular instance'
72  */
73  std::shared_ptr<bridge_domain_arp_entry> singular() const;
74 
75  /**
76  * Find the instnace of the bridge_domain domain in the OM
77  */
78  static std::shared_ptr<bridge_domain_arp_entry> find(const key_t& k);
79 
80  /**
81  * Dump all bridge_domain-doamin into the stream provided
82  */
83  static void dump(std::ostream& os);
84 
85  /**
86  * replay the object to create it in hardware
87  */
88  void replay(void);
89 
90  /**
91  * Convert to string for debugging
92  */
93  std::string to_string() const;
94 
95 private:
96  /**
97  * Class definition for listeners to OM events
98  */
100  {
101  public:
102  event_handler();
103  virtual ~event_handler() = default;
104 
105  /**
106  * Handle a populate event
107  */
108  void handle_populate(const client_db::key_t& key);
109 
110  /**
111  * Handle a replay event
112  */
113  void handle_replay();
114 
115  /**
116  * Show the object in the Singular DB
117  */
118  void show(std::ostream& os);
119 
120  /**
121  * Get the sortable Id of the listener
122  */
123  dependency_t order() const;
124  };
125 
126  /**
127  * event_handler to register with OM
128  */
129  static event_handler m_evh;
130 
131  /**
132  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
133  */
134  void update(const bridge_domain_arp_entry& obj);
135 
136  /**
137  * Find or add the instnace of the bridge_domain domain in the OM
138  */
139  static std::shared_ptr<bridge_domain_arp_entry> find_or_add(
140  const bridge_domain_arp_entry& temp);
141 
142  /*
143  * It's the VPPHW class that updates the objects in HW
144  */
145  friend class OM;
146 
147  /**
148  * It's the singular_db class that calls replay()
149  */
150  friend class singular_db<key_t, bridge_domain_arp_entry>;
151 
152  /**
153  * Sweep/reap the object if still stale
154  */
155  void sweep(void);
156 
157  /**
158  * HW configuration for the result of creating the bridge_domain
159  */
160  HW::item<bool> m_hw;
161 
162  /**
163  * The bridge_domain domain the bridge_domain is in.
164  */
165  std::shared_ptr<bridge_domain> m_bd;
166 
167  /**
168  * The IP address
169  */
170  boost::asio::ip::address m_ip_addr;
171 
172  /**
173  * The mac to return
174  */
175  mac_address_t m_mac;
176 
177  /**
178  * A map of all bridge_domains
179  */
181 };
182 
183 std::ostream& operator<<(std::ostream& os,
185 }; // namespace
186 
187 /*
188  * fd.io coding-style-patch-verification: ON
189  *
190  * Local Variables:
191  * eval: (c-set-style "mozilla")
192  * End:
193  */
194 
195 #endif
typedef address
Definition: ip_types.api:30
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 to_string() const
Convert to string for debugging.
bridge_domain_arp_entry(const bridge_domain &bd, const boost::asio::ip::address &ip_addr, const mac_address_t &mac)
Construct a bridge domain ARP Entry in the given bridge domain.
void replay(void)
replay the object to create it in hardware
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
std::shared_ptr< bridge_domain_arp_entry > singular() const
Return the matching &#39;singular instance&#39;.
std::pair< bridge_domain::key_t, boost::asio::ip::address > key_t
The key for a bridge_domain ARP entry; the BD, IP address and MAC address.
A base class for all object_base in the VPP object_base-Model.
Class definition for listeners to OM events.
Definition: om.hpp:284
inspect command handler Handler
Definition: inspect.hpp:54
~bridge_domain_arp_entry()
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
bool operator==(const bridge_domain_arp_entry &bdae) const
comparison operator
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
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
const key_t key() const
Return the object&#39;s key.
Type def of a Ethernet address.
Definition: types.hpp:295
static std::shared_ptr< bridge_domain_arp_entry > find(const key_t &k)
Find the instnace of the bridge_domain domain in the OM.
vl_api_mac_address_t mac
Definition: gbp.api:118
A entry in the ARP termination table of a Bridge Domain.