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_list.hpp"
17 #include "vom/logger.hpp"
23 l2_list::event_handler::handle_populate(const client_db::key_t& key)
25 /* hack to get this function instantiated */
29 * dump VPP Bridge domains
31 std::shared_ptr<l2_list::dump_cmd> cmd(new l2_list::dump_cmd());
36 for (auto& record : *cmd) {
37 auto& payload = record.get_payload();
39 const handle_t hdl(payload.acl_index);
40 l2_list acl(hdl, std::string(reinterpret_cast<const char*>(payload.tag)));
42 for (unsigned int ii = 0; ii < payload.count; ii++) {
43 const route::prefix_t pfx(payload.r[ii].is_ipv6,
44 payload.r[ii].src_ip_addr,
45 payload.r[ii].src_ip_prefix_len);
46 l2_rule rule(ii, action_t::from_int(payload.r[ii].is_permit), pfx,
47 { payload.r[ii].src_mac }, { payload.r[ii].src_mac_mask });
51 VOM_LOG(log_level_t::DEBUG) << "dump: " << acl.to_string();
54 * Write each of the discovered ACLs into the OM,
55 * but disable the HW Command q whilst we do, so that no
56 * commands are sent to VPP
64 l3_list::event_handler::handle_populate(const client_db::key_t& key)
66 /* hack to get this function instantiated */
70 * dump VPP Bridge domains
72 std::shared_ptr<l3_list::dump_cmd> cmd(new l3_list::dump_cmd());
77 for (auto& record : *cmd) {
78 auto& payload = record.get_payload();
80 const handle_t hdl(payload.acl_index);
81 l3_list acl(hdl, std::string(reinterpret_cast<const char*>(payload.tag)));
83 for (unsigned int ii = 0; ii < payload.count; ii++) {
84 const route::prefix_t src(payload.r[ii].is_ipv6,
85 payload.r[ii].src_ip_addr,
86 payload.r[ii].src_ip_prefix_len);
87 const route::prefix_t dst(payload.r[ii].is_ipv6,
88 payload.r[ii].dst_ip_addr,
89 payload.r[ii].dst_ip_prefix_len);
90 l3_rule rule(ii, action_t::from_int(payload.r[ii].is_permit), src, dst);
94 VOM_LOG(log_level_t::DEBUG) << "dump: " << acl.to_string();
97 * Write each of the discovered ACLs into the OM,
98 * but disable the HW Command q whilst we do, so that no
99 * commands are sent to VPP
101 OM::commit(key, acl);
108 * fd.io coding-style-patch-verification: ON
111 * eval: (c-set-style "mozilla")