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)
34 create_cmd::operator==(const create_cmd& other) const
36 return (m_name == other.m_name);
40 create_cmd::operator()(vapi::Pipe_create& reply)
42 auto& payload = reply.get_response().get_payload();
44 VOM_LOG(log_level_t::DEBUG) << to_string() << " " << payload.retval;
46 const rc_t& rc = rc_t::from_vpp_retval(payload.retval);
48 m_hdl_pair = { pipe::handle_pair_t(payload.pipe_sw_if_index[0],
49 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)
93 delete_cmd::operator==(const delete_cmd& other) const
95 return (m_hw_item == other.m_hw_item);
99 delete_cmd::issue(connection& con)
101 msg_t req(con.ctx(), std::ref(*this));
103 VAPI_CALL(req.execute());
106 m_hw_item.set(rc_t::NOOP);
107 m_hdl_pair.set(rc_t::NOOP);
115 delete_cmd::to_string() const
117 return ("pipe-delete");
121 dump_cmd::operator==(const dump_cmd& other) const
127 dump_cmd::issue(connection& con)
129 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
131 VAPI_CALL(m_dump->execute());
139 dump_cmd::to_string() const
141 return ("pipe-dump");
144 } // namespace pipe_cmds
148 * fd.io coding-style-patch-verification: ON
151 * eval: (c-set-style "mozilla")