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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #include "vom/acl_binding.hpp"
17 #include "vom/acl_binding_cmds.hpp"
23 l2_binding::event_handler::order() const
25 return (dependency_t::BINDING);
29 l2_binding::event_handler::event_handler()
31 /* hack to get this function instantiated */
34 OM::register_listener(this);
35 inspect::register_handler({ "l2-acl-binding" }, "L2 ACL bindings", this);
40 l2_binding::event_handler::handle_populate(const client_db::key_t& key)
42 /* hack to get this function instantiated */
46 * dump VPP Bridge domains
48 std::shared_ptr<binding_cmds::l2_dump_cmd> cmd =
49 std::make_shared<binding_cmds::l2_dump_cmd>();
54 for (auto& record : *cmd) {
55 auto& payload = record.get_payload();
57 std::shared_ptr<interface> itf = interface::find(payload.sw_if_index);
60 for (int ii = 0; ii < payload.count; ii++) {
61 std::shared_ptr<l2_list> acl = l2_list::find(payload.acls[ii]);
64 l2_binding binding(direction_t::INPUT, *itf, *acl);
65 OM::commit(key, binding);
67 VOM_LOG(log_level_t::ERROR) << "no ACL id:" << payload.acls[ii];
71 VOM_LOG(log_level_t::ERROR) << "no interface:" << payload.sw_if_index;
78 l3_binding::event_handler::order() const
80 return (dependency_t::BINDING);
84 l3_binding::event_handler::event_handler()
86 /* hack to get this function instantiated */
89 OM::register_listener(this);
90 inspect::register_handler({ "l3-acl-binding" }, "L3 ACL bindings", this);
95 l3_binding::event_handler::handle_populate(const client_db::key_t& key)
97 /* hack to get this function instantiated */
100 std::shared_ptr<binding_cmds::l3_dump_cmd> cmd =
101 std::make_shared<binding_cmds::l3_dump_cmd>();
106 for (auto& record : *cmd) {
107 auto& payload = record.get_payload();
109 std::shared_ptr<interface> itf = interface::find(payload.sw_if_index);
110 uint8_t n_input = payload.n_input;
113 for (int ii = 0; ii < payload.count; ii++) {
114 std::shared_ptr<l3_list> acl = l3_list::find(payload.acls[ii]);
118 l3_binding binding(direction_t::INPUT, *itf, *acl);
120 OM::commit(key, binding);
122 l3_binding binding(direction_t::OUTPUT, *itf, *acl);
123 OM::commit(key, binding);
126 VOM_LOG(log_level_t::ERROR) << "no ACL id:" << payload.acls[ii];
130 VOM_LOG(log_level_t::ERROR) << "no interface:" << payload.sw_if_index;
137 l3_binding::update(const binding& obj)
140 HW::enqueue(new binding_cmds::l3_bind_cmd(
141 m_binding, m_direction, m_itf->handle(), m_acl->handle()));
148 l3_binding::sweep(void)
151 HW::enqueue(new binding_cmds::l3_unbind_cmd(
152 m_binding, m_direction, m_itf->handle(), m_acl->handle()));
159 l3_binding::replay(void)
162 HW::enqueue(new binding_cmds::l3_bind_cmd(
163 m_binding, m_direction, m_itf->handle(), m_acl->handle()));
169 l2_binding::update(const binding& obj)
172 HW::enqueue(new binding_cmds::l2_bind_cmd(
173 m_binding, m_direction, m_itf->handle(), m_acl->handle()));
180 l2_binding::sweep(void)
183 HW::enqueue(new binding_cmds::l2_unbind_cmd(
184 m_binding, m_direction, m_itf->handle(), m_acl->handle()));
191 l2_binding::replay(void)
194 HW::enqueue(new binding_cmds::l2_bind_cmd(
195 m_binding, m_direction, m_itf->handle(), m_acl->handle()));
201 operator<<(std::ostream& os,
202 const std::pair<direction_t, interface::key_t>& key)
204 os << "[" << key.first.to_string() << " " << key.second << "]";
211 * fd.io coding-style-patch-verification: ON
214 * eval: (c-set-style "mozilla")