FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
arp_proxy_config.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_CONFIG_H__
17 #define __VOM_ARP_PROXY_CONFIG_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 client configuration on an interface
28  */
30 {
31 public:
32  /**
33  * Key type
34  */
35  typedef std::pair<boost::asio::ip::address_v4, boost::asio::ip::address_v4>
37 
38  /**
39  * Construct a new object matching the desried state
40  */
41  arp_proxy_config(const boost::asio::ip::address_v4& low,
42  const boost::asio::ip::address_v4& high);
43 
44  /**
45  * Copy Constructor
46  */
48 
49  /**
50  * Destructor
51  */
53 
54  /**
55  * Return the 'singular' of the LLDP config that matches this object
56  */
57  std::shared_ptr<arp_proxy_config> singular() const;
58 
59  /**
60  * convert to string format for debug purposes
61  */
62  std::string to_string() const;
63 
64  /**
65  * Dump all LLDP configs into the stream provided
66  */
67  static void dump(std::ostream& os);
68 
69 private:
70  /**
71  * Class definition for listeners to OM events
72  */
74  {
75  public:
76  event_handler();
77  virtual ~event_handler() = default;
78 
79  /**
80  * Handle a populate event
81  */
82  void handle_populate(const client_db::key_t& key);
83 
84  /**
85  * Handle a replay event
86  */
87  void handle_replay();
88 
89  /**
90  * Show the object in the Singular DB
91  */
92  void show(std::ostream& os);
93 
94  /**
95  * Get the sortable Id of the listener
96  */
97  dependency_t order() const;
98  };
99 
100  /**
101  * event_handler to register with OM
102  */
103  static event_handler m_evh;
104 
105  /**
106  * Enquue commonds to the VPP command Q for the update
107  */
108  void update(const arp_proxy_config& obj);
109 
110  /**
111  * Find or add LLDP config to the OM
112  */
113  static std::shared_ptr<arp_proxy_config> find_or_add(
114  const arp_proxy_config& temp);
115 
116  /*
117  * It's the OM class that calls singular()
118  */
119  friend class OM;
120 
121  /**
122  * It's the singular_db class that calls replay()
123  */
125 
126  /**
127  * Sweep/reap the object if still stale
128  */
129  void sweep(void);
130 
131  /**
132  * replay the object to create it in hardware
133  */
134  void replay(void);
135 
136  /**
137  * Address range
138  */
139  const boost::asio::ip::address_v4 m_low;
140  const boost::asio::ip::address_v4 m_high;
141 
142  /**
143  * A map of all ArpProxy configs keyed against the interface.
144  */
145  static singular_db<arp_proxy_config::key_t, arp_proxy_config> m_db;
146 
147  /**
148  * HW configuration for the config. The bool representing the
149  * do/don't configured/unconfigured.
150  */
151  HW::item<bool> m_config;
152 };
153 
154 std::ostream& operator<<(std::ostream& os, const arp_proxy_config::key_t& key);
155 };
156 
157 /*
158  * fd.io coding-style-patch-verification: OFF
159  *
160  * Local Variables:
161  * eval: (c-set-style "mozilla")
162  * End:
163  */
164 
165 #endif
VOM::arp_proxy_config::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: arp_proxy_config.cpp:75
VOM::HW::item
A HW::item is data that is either to be written to or read from VPP/HW.
Definition: hw.hpp:44
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::arp_proxy_config::singular
std::shared_ptr< arp_proxy_config > singular() const
Return the 'singular' of the LLDP config that matches this object.
Definition: arp_proxy_config.cpp:99
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::arp_proxy_config::arp_proxy_config
arp_proxy_config(const boost::asio::ip::address_v4 &low, const boost::asio::ip::address_v4 &high)
Construct a new object matching the desried state.
Definition: arp_proxy_config.cpp:27
VOM::OM::listener
Class definition for listeners to OM events.
Definition: om.hpp:284
key
typedef key
Definition: ipsec_types.api:91
VOM::arp_proxy_config::dump
static void dump(std::ostream &os)
Dump all LLDP configs into the stream provided.
Definition: arp_proxy_config.cpp:61
VOM::arp_proxy_config
A representation of LLDP client configuration on an interface.
Definition: arp_proxy_config.hpp:29
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
low
vl_api_ip4_address_t low
Definition: arp.api:36
VOM::arp_proxy_config::key_t
std::pair< boost::asio::ip::address_v4, boost::asio::ip::address_v4 > key_t
Key type.
Definition: arp_proxy_config.hpp:36
inspect.hpp
singular_db.hpp
VOM::arp_proxy_config::~arp_proxy_config
~arp_proxy_config()
Destructor.
Definition: arp_proxy_config.cpp:42
VOM::singular_db
A Database to store the unique 'singular' instances of a single object type.
Definition: singular_db.hpp:33
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
object_base.hpp
string
const char *const string
Definition: cJSON.h:172