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/interface_span_cmds.hpp"
18 DEFINE_VAPI_MSG_IDS_SPAN_API_JSON;
21 namespace interface_span_cmds {
23 config_cmd::config_cmd(HW::item<bool>& item,
24 const handle_t& itf_from,
25 const handle_t& itf_to,
26 const interface_span::state_t& state)
28 , m_itf_from(itf_from)
35 config_cmd::operator==(const config_cmd& o) const
37 return ((m_itf_from == o.m_itf_from) && (m_itf_to == o.m_itf_to) &&
38 (m_state == o.m_state));
42 config_cmd::issue(connection& con)
44 msg_t req(con.ctx(), std::ref(*this));
46 auto& payload = req.get_request().get_payload();
48 payload.sw_if_index_from = m_itf_from.value();
49 payload.sw_if_index_to = m_itf_to.value();
50 payload.state = m_state.value();
52 VAPI_CALL(req.execute());
58 config_cmd::to_string() const
61 s << "itf-span-config: " << m_hw_item.to_string()
62 << " itf-from:" << m_itf_from.to_string()
63 << " itf-to:" << m_itf_to.to_string() << " state:" << m_state.to_string();
68 unconfig_cmd::unconfig_cmd(HW::item<bool>& item,
69 const handle_t& itf_from,
70 const handle_t& itf_to)
72 , m_itf_from(itf_from)
78 unconfig_cmd::operator==(const unconfig_cmd& o) const
80 return ((m_itf_from == o.m_itf_from) && (m_itf_to == o.m_itf_to));
84 unconfig_cmd::issue(connection& con)
86 msg_t req(con.ctx(), std::ref(*this));
88 auto& payload = req.get_request().get_payload();
90 payload.sw_if_index_from = m_itf_from.value();
91 payload.sw_if_index_to = m_itf_to.value();
94 VAPI_CALL(req.execute());
97 m_hw_item.set(rc_t::NOOP);
103 unconfig_cmd::to_string() const
105 std::ostringstream s;
106 s << "itf-span-unconfig: " << m_hw_item.to_string()
107 << " itf-from:" << m_itf_from.to_string()
108 << " itf-to:" << m_itf_to.to_string();
118 dump_cmd::operator==(const dump_cmd& other) const
124 dump_cmd::issue(connection& con)
126 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
128 auto& payload = m_dump->get_request().get_payload();
131 VAPI_CALL(m_dump->execute());
139 dump_cmd::to_string() const
141 return ("interface-span-dump");
144 }; // namespace interface_span_cmds
148 * fd.io coding-style-patch-verification: ON
151 * eval: (c-set-style "mozilla")