2 * Copyright (c) 2018 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/pipe_cmds.hpp"
18 DEFINE_VAPI_MSG_IDS_PIPE_API_JSON;
23 create_cmd::create_cmd(HW::item<handle_t>& item,
24 const std::string& name,
26 HW::item<pipe::handle_pair_t>& ends)
27 : interface::create_cmd<vapi::Pipe_create>(item, name)
29 , m_instance(instance)
33 create_cmd::operator==(const create_cmd& other) const
35 return (m_name == other.m_name);
39 create_cmd::operator()(vapi::Pipe_create& reply)
41 auto& payload = reply.get_response().get_payload();
43 VOM_LOG(log_level_t::DEBUG) << to_string() << " " << payload.retval;
45 const rc_t& rc = rc_t::from_vpp_retval(payload.retval);
47 m_hdl_pair = { pipe::handle_pair_t(
48 static_cast<handle_t>(payload.pipe_sw_if_index[0]),
49 static_cast<handle_t>(payload.pipe_sw_if_index[1])),
52 fulfill(HW::item<handle_t>(payload.sw_if_index, rc));
57 create_cmd::issue(connection& con)
59 msg_t req(con.ctx(), std::ref(*this));
61 auto& payload = req.get_request().get_payload();
63 payload.is_specified = 1;
64 payload.user_instance = m_instance;
66 VAPI_CALL(req.execute());
68 if (rc_t::OK == wait()) {
76 create_cmd::to_string() const
80 s << "pipe-create: " << m_name << " instance:" << m_instance;
85 delete_cmd::delete_cmd(HW::item<handle_t>& item,
86 HW::item<pipe::handle_pair_t>& end_pair)
87 : interface::delete_cmd<vapi::Pipe_delete>(item)
88 , m_hdl_pair(end_pair)
92 delete_cmd::operator==(const delete_cmd& other) const
94 return (m_hw_item == other.m_hw_item);
98 delete_cmd::issue(connection& con)
100 msg_t req(con.ctx(), std::ref(*this));
102 VAPI_CALL(req.execute());
105 m_hw_item.set(rc_t::NOOP);
106 m_hdl_pair.set(rc_t::NOOP);
114 delete_cmd::to_string() const
116 return ("pipe-delete");
120 dump_cmd::operator==(const dump_cmd& other) const
126 dump_cmd::issue(connection& con)
128 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
130 VAPI_CALL(m_dump->execute());
138 dump_cmd::to_string() const
140 return ("pipe-dump");
143 } // namespace pipe_cmds
147 * fd.io coding-style-patch-verification: ON
150 * eval: (c-set-style "mozilla")