22 singular_db<const nat_binding::key_t, nat_binding> nat_binding::m_db;
57 : m_binding(o.m_binding)
68 m_db.release(
key(),
this);
74 return (make_tuple(m_itf->key(), m_dir, m_proto));
80 return ((
key() == n.
key()) && (m_zone == n.m_zone));
90 m_binding, m_itf->handle(), m_zone));
93 m_binding, m_itf->handle(), m_zone));
98 m_binding, m_itf->handle(), m_zone));
108 nat_binding::replay()
114 m_binding, m_itf->handle(), m_zone));
117 m_binding, m_itf->handle(), m_zone));
122 m_binding, m_itf->handle(), m_zone));
140 m_binding, m_itf->handle(), m_zone));
143 m_binding, m_itf->handle(), m_zone));
148 m_binding, m_itf->handle(), m_zone));
159 std::ostringstream s;
160 s <<
"nat-binding:[" << m_itf->to_string()
162 <<
" zone:" << m_zone.
to_string() <<
"]";
167 std::shared_ptr<nat_binding>
170 return (m_db.find_or_add(temp.
key(), temp));
173 std::shared_ptr<nat_binding>
176 return (m_db.find(key));
179 std::shared_ptr<nat_binding>
182 return find_or_add(*
this);
194 os <<
"[" << std::get<0>(
key) <<
", " << std::get<1>(key) <<
", " 195 << std::get<2>(
key) <<
"]";
207 nat_binding::event_handler::handle_replay()
215 std::shared_ptr<nat_binding_cmds::dump_input_44_cmd> icmd =
216 std::make_shared<nat_binding_cmds::dump_input_44_cmd>();
221 for (
auto& record : *icmd) {
222 auto& payload = record.get_payload();
232 << payload.sw_if_index;
236 std::shared_ptr<nat_binding_cmds::dump_output_44_cmd> ocmd =
237 std::make_shared<nat_binding_cmds::dump_output_44_cmd>();
242 for (
auto& record : *ocmd) {
243 auto& payload = record.get_payload();
252 << payload.sw_if_index;
256 std::shared_ptr<nat_binding_cmds::dump_input_66_cmd> i6cmd =
257 std::make_shared<nat_binding_cmds::dump_input_66_cmd>();
262 for (
auto& record : *i6cmd) {
263 auto& payload = record.get_payload();
272 << payload.sw_if_index;
278 nat_binding::event_handler::order()
const ~nat_binding()
Destructor.
static const zone_t OUTSIDE
Deny Zone.
void db_dump(const DB &db, std::ostream &os)
Print each of the objects in the DB into the stream provided.
A template base class for all enum types.
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
static std::shared_ptr< interface > find(const handle_t &h)
The the singular instance of the interface in the DB by handle.
A functor class that binds a NAT configuration to an output interface.
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
static rc_t write()
Write/Execute all commands hitherto enqueued.
An L3 protocol can be used to construct a prefix that is used to match packets are part of a route...
A Class representing the binding of an L2 interface to a bridge-domain and the properties of that bin...
static const direction_t INPUT
Permit Direction.
nat_binding(const interface &itf, const direction_t &dir, const l3_proto_t &proto, const zone_t &zone)
Construct a new object matching the desried state.
static const l3_proto_t IPV4
static const zone_t INSIDE
Permit Zone.
static const l3_proto_t IPV6
bool operator==(const nat_binding &n) const
Comparison operator - for UT.
const key_t key() const
Return the binding's key.
zone_t(int v, const std::string s)
Constructor.
static void dump(std::ostream &os)
Dump all nat_bindings into the stream provided.
A representation of an interface in VPP.
std::string to_string() const
convert to string format for debug purposes
std::shared_ptr< nat_binding > singular() const
Return the 'singular instance' of the L2 config that matches this object.
static rc_t commit(const client_db::key_t &key, const OBJ &obj)
Make the State in VPP reflect the expressed desired state.
void event_handler(void *tls_async)
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
static void enqueue(cmd *f)
Enqueue A command for execution.
static const log_level_t ERROR
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
Then L2/objects that bind to interfaces, BD, ACLS, etc.
The VPP Object Model (VOM) library.
static std::shared_ptr< nat_binding > find(const key_t &key)
Static function to find the bridge_domain in the model.
static const direction_t OUTPUT
Deny Direction.
const std::string & to_string() const
convert to string format for debug purposes
std::tuple< interface::key_t, direction_t, l3_proto_t > key_t
The key for a NAT Binding.
A cmd class that unbinds a NAT configuration from an output interface.
static const zone_t & from_vpp(u8 is_inside)
static bool register_listener(listener *listener)
Register a listener of events.