blob: b04798aba83e5d7f319a269b35f8c061f7130881 [file] [log] [blame]
Neale Ranns812ed392017-10-16 04:20:13 -07001/*
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:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
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.
14 */
15
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070016#include "vom/interface_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070017#include "vom/cmd.hpp"
18
19DEFINE_VAPI_MSG_IDS_VPE_API_JSON;
20DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON;
21DEFINE_VAPI_MSG_IDS_AF_PACKET_API_JSON;
22DEFINE_VAPI_MSG_IDS_TAP_API_JSON;
Neale Ranns4ef42262018-02-20 08:10:44 -080023DEFINE_VAPI_MSG_IDS_VHOST_USER_API_JSON;
Neale Ranns812ed392017-10-16 04:20:13 -070024DEFINE_VAPI_MSG_IDS_STATS_API_JSON;
25
26namespace VOM {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070027namespace interface_cmds {
28loopback_create_cmd::loopback_create_cmd(HW::item<handle_t>& item,
29 const std::string& name)
Neale Ranns812ed392017-10-16 04:20:13 -070030 : create_cmd(item, name)
31{
32}
33
34rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070035loopback_create_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -070036{
37 msg_t req(con.ctx(), std::ref(*this));
38
39 VAPI_CALL(req.execute());
40
41 m_hw_item = wait();
42
43 if (m_hw_item.rc() == rc_t::OK) {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070044 insert_interface();
Neale Ranns812ed392017-10-16 04:20:13 -070045 }
46
47 return rc_t::OK;
48}
49std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070050loopback_create_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -070051{
52 std::ostringstream s;
53 s << "loopback-itf-create: " << m_hw_item.to_string() << " name:" << m_name;
54
55 return (s.str());
56}
57
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070058af_packet_create_cmd::af_packet_create_cmd(HW::item<handle_t>& item,
59 const std::string& name)
Neale Ranns812ed392017-10-16 04:20:13 -070060 : create_cmd(item, name)
61{
62}
63
64rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070065af_packet_create_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -070066{
67 msg_t req(con.ctx(), std::ref(*this));
68
69 auto& payload = req.get_request().get_payload();
70
71 payload.use_random_hw_addr = 1;
72 memset(payload.host_if_name, 0, sizeof(payload.host_if_name));
73 memcpy(payload.host_if_name, m_name.c_str(),
74 std::min(m_name.length(), sizeof(payload.host_if_name)));
75
76 VAPI_CALL(req.execute());
77
78 m_hw_item = wait();
79
80 if (m_hw_item.rc() == rc_t::OK) {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070081 insert_interface();
Neale Ranns812ed392017-10-16 04:20:13 -070082 }
83
84 return rc_t::OK;
85}
86std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070087af_packet_create_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -070088{
89 std::ostringstream s;
90 s << "af-packet-itf-create: " << m_hw_item.to_string() << " name:" << m_name;
91
92 return (s.str());
93}
94
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070095tap_create_cmd::tap_create_cmd(HW::item<handle_t>& item,
96 const std::string& name)
Neale Ranns812ed392017-10-16 04:20:13 -070097 : create_cmd(item, name)
98{
99}
100
101rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700102tap_create_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700103{
104 msg_t req(con.ctx(), std::ref(*this));
105
106 auto& payload = req.get_request().get_payload();
107
108 memset(payload.tap_name, 0, sizeof(payload.tap_name));
109 memcpy(payload.tap_name, m_name.c_str(),
110 std::min(m_name.length(), sizeof(payload.tap_name)));
111 payload.use_random_mac = 1;
112
113 VAPI_CALL(req.execute());
114
115 m_hw_item = wait();
116
117 if (m_hw_item.rc() == rc_t::OK) {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700118 insert_interface();
Neale Ranns812ed392017-10-16 04:20:13 -0700119 }
120
121 return rc_t::OK;
122}
123
124std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700125tap_create_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700126{
127 std::ostringstream s;
128 s << "tap-intf-create: " << m_hw_item.to_string() << " name:" << m_name;
129
130 return (s.str());
131}
132
Neale Ranns4ef42262018-02-20 08:10:44 -0800133vhost_create_cmd::vhost_create_cmd(HW::item<handle_t>& item,
134 const std::string& name,
135 const std::string& tag)
136 : create_cmd(item, name)
137 , m_tag(tag)
138{
139}
140
141rc_t
142vhost_create_cmd::issue(connection& con)
143{
144 msg_t req(con.ctx(), std::ref(*this));
145
146 auto& payload = req.get_request().get_payload();
147 memset(payload.sock_filename, 0, sizeof(payload.sock_filename));
148 memcpy(payload.sock_filename, m_name.c_str(),
149 std::min(m_name.length(), sizeof(payload.sock_filename)));
150 memset(payload.tag, 0, sizeof(payload.tag));
151
152 if (!m_tag.empty())
153 memcpy(payload.tag, m_tag.c_str(),
154 std::min(m_tag.length(), sizeof(payload.tag)));
155
156 payload.is_server = 1;
157 payload.use_custom_mac = 0;
158 payload.renumber = 0;
159
160 VAPI_CALL(req.execute());
161
162 m_hw_item = wait();
163
Mohsin Kazmi3a758b02018-02-27 14:05:15 +0100164 if (m_hw_item.rc() == rc_t::OK) {
165 insert_interface();
166 }
167
Neale Ranns4ef42262018-02-20 08:10:44 -0800168 return rc_t::OK;
169}
170
171std::string
172vhost_create_cmd::to_string() const
173{
174 std::ostringstream s;
175 s << "vhost-intf-create: " << m_hw_item.to_string() << " name:" << m_name
176 << " tag:" << m_tag;
177
178 return (s.str());
179}
180
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700181loopback_delete_cmd::loopback_delete_cmd(HW::item<handle_t>& item)
Neale Ranns812ed392017-10-16 04:20:13 -0700182 : delete_cmd(item)
183{
184}
185
186rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700187loopback_delete_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700188{
189 msg_t req(con.ctx(), std::ref(*this));
190
191 auto& payload = req.get_request().get_payload();
192 payload.sw_if_index = m_hw_item.data().value();
193
194 VAPI_CALL(req.execute());
195
196 wait();
197 m_hw_item.set(rc_t::NOOP);
198
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700199 remove_interface();
Neale Ranns812ed392017-10-16 04:20:13 -0700200 return rc_t::OK;
201}
202
203std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700204loopback_delete_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700205{
206 std::ostringstream s;
207 s << "loopback-itf-delete: " << m_hw_item.to_string();
208
209 return (s.str());
210}
211
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700212af_packet_delete_cmd::af_packet_delete_cmd(HW::item<handle_t>& item,
213 const std::string& name)
Neale Ranns812ed392017-10-16 04:20:13 -0700214 : delete_cmd(item, name)
215{
216}
217
218rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700219af_packet_delete_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700220{
221 msg_t req(con.ctx(), std::ref(*this));
222
223 auto& payload = req.get_request().get_payload();
224 memset(payload.host_if_name, 0, sizeof(payload.host_if_name));
225 memcpy(payload.host_if_name, m_name.c_str(),
226 std::min(m_name.length(), sizeof(payload.host_if_name)));
227
228 VAPI_CALL(req.execute());
229
230 wait();
231 m_hw_item.set(rc_t::NOOP);
232
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700233 remove_interface();
Neale Ranns812ed392017-10-16 04:20:13 -0700234 return rc_t::OK;
235}
236std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700237af_packet_delete_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700238{
239 std::ostringstream s;
240 s << "af_packet-itf-delete: " << m_hw_item.to_string();
241
242 return (s.str());
243}
244
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700245tap_delete_cmd::tap_delete_cmd(HW::item<handle_t>& item)
Neale Ranns812ed392017-10-16 04:20:13 -0700246 : delete_cmd(item)
247{
248}
249
250rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700251tap_delete_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700252{
253 // finally... call VPP
254
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700255 remove_interface();
Neale Ranns812ed392017-10-16 04:20:13 -0700256 return rc_t::OK;
257}
258std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700259tap_delete_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700260{
261 std::ostringstream s;
262 s << "tap-itf-delete: " << m_hw_item.to_string();
263
264 return (s.str());
265}
266
Neale Ranns4ef42262018-02-20 08:10:44 -0800267vhost_delete_cmd::vhost_delete_cmd(HW::item<handle_t>& item,
268 const std::string& name)
269 : delete_cmd(item, name)
270{
271}
272
273rc_t
274vhost_delete_cmd::issue(connection& con)
275{
276 msg_t req(con.ctx(), std::ref(*this));
277
278 auto& payload = req.get_request().get_payload();
279 payload.sw_if_index = m_hw_item.data().value();
280
281 VAPI_CALL(req.execute());
282
283 wait();
284
285 return rc_t::OK;
286}
287std::string
288vhost_delete_cmd::to_string() const
289{
290 std::ostringstream s;
291 s << "vhost-itf-delete: " << m_hw_item.to_string() << " name:" << m_name;
292
293 return (s.str());
294}
295
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700296state_change_cmd::state_change_cmd(HW::item<interface::admin_state_t>& state,
297 const HW::item<handle_t>& hdl)
Neale Ranns812ed392017-10-16 04:20:13 -0700298 : rpc_cmd(state)
299 , m_hdl(hdl)
300{
301}
302
303bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700304state_change_cmd::operator==(const state_change_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -0700305{
306 return ((m_hdl == other.m_hdl) && (m_hw_item == other.m_hw_item));
307}
308
309rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700310state_change_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700311{
312 msg_t req(con.ctx(), std::ref(*this));
313
314 auto& payload = req.get_request().get_payload();
315 payload.sw_if_index = m_hdl.data().value();
316 payload.admin_up_down = m_hw_item.data().value();
317
318 VAPI_CALL(req.execute());
319
320 m_hw_item.set(wait());
321
322 return rc_t::OK;
323}
324
325std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700326state_change_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700327{
328 std::ostringstream s;
329 s << "itf-state-change: " << m_hw_item.to_string()
330 << " hdl:" << m_hdl.to_string();
331 return (s.str());
332}
333
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700334set_table_cmd::set_table_cmd(HW::item<route::table_id_t>& table,
335 const l3_proto_t& proto,
336 const HW::item<handle_t>& hdl)
Neale Ranns812ed392017-10-16 04:20:13 -0700337 : rpc_cmd(table)
338 , m_hdl(hdl)
339 , m_proto(proto)
340{
341}
342
343bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700344set_table_cmd::operator==(const set_table_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -0700345{
346 return ((m_hdl == other.m_hdl) && (m_proto == other.m_proto) &&
347 (m_hw_item == other.m_hw_item));
348}
349
350rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700351set_table_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700352{
353 msg_t req(con.ctx(), std::ref(*this));
354
355 auto& payload = req.get_request().get_payload();
356 payload.sw_if_index = m_hdl.data().value();
357 payload.is_ipv6 = m_proto.is_ipv6();
358 payload.vrf_id = m_hw_item.data();
359
360 VAPI_CALL(req.execute());
361
362 m_hw_item.set(wait());
363
364 return (rc_t::OK);
365}
366
367std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700368set_table_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700369{
370 std::ostringstream s;
371 s << "itf-set-table: " << m_hw_item.to_string()
372 << " proto:" << m_proto.to_string() << " hdl:" << m_hdl.to_string();
373 return (s.str());
374}
375
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700376set_mac_cmd::set_mac_cmd(HW::item<l2_address_t>& mac,
377 const HW::item<handle_t>& hdl)
Neale Ranns812ed392017-10-16 04:20:13 -0700378 : rpc_cmd(mac)
379 , m_hdl(hdl)
380{
381}
382
383bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700384set_mac_cmd::operator==(const set_mac_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -0700385{
386 return ((m_hdl == other.m_hdl) && (m_hw_item == other.m_hw_item));
387}
388
389rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700390set_mac_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700391{
392 msg_t req(con.ctx(), std::ref(*this));
393
394 auto& payload = req.get_request().get_payload();
395 payload.sw_if_index = m_hdl.data().value();
396 m_hw_item.data().to_mac().to_bytes(payload.mac_address,
397 sizeof(payload.mac_address));
398
399 VAPI_CALL(req.execute());
400
401 m_hw_item.set(wait());
402
403 return (rc_t::OK);
404}
405
406std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700407set_mac_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700408{
409 std::ostringstream s;
410 s << "itf-set-mac: " << m_hw_item.to_string() << " hdl:" << m_hdl.to_string();
411 return (s.str());
412}
413
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700414events_cmd::events_cmd(interface::event_listener& el)
Neale Ranns812ed392017-10-16 04:20:13 -0700415 : event_cmd(el.status())
416 , m_listener(el)
417{
418}
419
420bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700421events_cmd::operator==(const events_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -0700422{
423 return (true);
424}
425
426rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700427events_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700428{
429 /*
430 * First set the call back to handle the interface events
431 */
432 m_reg.reset(new reg_t(con.ctx(), std::ref(*(static_cast<event_cmd*>(this)))));
433
434 /*
435 * then send the request to enable them
436 */
437 msg_t req(con.ctx(), std::ref(*(static_cast<rpc_cmd*>(this))));
438
439 auto& payload = req.get_request().get_payload();
440 payload.enable_disable = 1;
441 payload.pid = getpid();
442
443 VAPI_CALL(req.execute());
444
445 wait();
446
Neale Rannsa2ee0292017-11-28 22:29:13 -0800447 return (rc_t::OK);
Neale Ranns812ed392017-10-16 04:20:13 -0700448}
449
450void
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700451events_cmd::retire(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700452{
453 /*
454 * disable interface events.
455 */
456 msg_t req(con.ctx(), std::ref(*(static_cast<rpc_cmd*>(this))));
457
458 auto& payload = req.get_request().get_payload();
459 payload.enable_disable = 0;
460 payload.pid = getpid();
461
462 VAPI_CALL(req.execute());
463
464 wait();
465}
466
467void
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700468events_cmd::notify()
Neale Ranns812ed392017-10-16 04:20:13 -0700469{
470 m_listener.handle_interface_event(this);
471}
472
473std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700474events_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700475{
476 return ("itf-events");
477}
478
479/**
480 * Interface statistics
481 */
Neale Rannsa2ee0292017-11-28 22:29:13 -0800482stats_enable_cmd::stats_enable_cmd(interface::stat_listener& el,
483 const handle_t& handle)
Neale Ranns812ed392017-10-16 04:20:13 -0700484 : event_cmd(el.status())
485 , m_listener(el)
Mohsin Kazmi5a4f96a2017-11-20 10:23:47 +0100486 , m_swifindex(handle)
Neale Ranns812ed392017-10-16 04:20:13 -0700487{
488}
489
490bool
Neale Rannsa2ee0292017-11-28 22:29:13 -0800491stats_enable_cmd::operator==(const stats_enable_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -0700492{
493 return (true);
494}
495
496rc_t
Neale Rannsa2ee0292017-11-28 22:29:13 -0800497stats_enable_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700498{
499 /*
Mohsin Kazmi5a4f96a2017-11-20 10:23:47 +0100500 * First set the call back to handle the interface stats
501 */
Neale Ranns812ed392017-10-16 04:20:13 -0700502 m_reg.reset(new reg_t(con.ctx(), std::ref(*(static_cast<event_cmd*>(this)))));
Neale Ranns812ed392017-10-16 04:20:13 -0700503
504 /*
Mohsin Kazmi5a4f96a2017-11-20 10:23:47 +0100505 * then send the request to enable them
506 */
507 msg_t req(con.ctx(), 1, std::ref(*(static_cast<rpc_cmd*>(this))));
Neale Ranns812ed392017-10-16 04:20:13 -0700508
509 auto& payload = req.get_request().get_payload();
510 payload.enable_disable = 1;
511 payload.pid = getpid();
Mohsin Kazmi5a4f96a2017-11-20 10:23:47 +0100512 payload.num = 1;
Neale Ranns812ed392017-10-16 04:20:13 -0700513
Mohsin Kazmi5a4f96a2017-11-20 10:23:47 +0100514 payload.sw_ifs[0] = m_swifindex.value();
Neale Ranns812ed392017-10-16 04:20:13 -0700515
516 VAPI_CALL(req.execute());
517
518 wait();
519
Neale Rannsa2ee0292017-11-28 22:29:13 -0800520 return (rc_t::OK);
Neale Ranns812ed392017-10-16 04:20:13 -0700521}
522
523void
Neale Rannsa2ee0292017-11-28 22:29:13 -0800524stats_enable_cmd::retire(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700525{
Mohsin Kazmi5a4f96a2017-11-20 10:23:47 +0100526 /*
527 * disable interface stats.
528 */
529 msg_t req(con.ctx(), 1, std::ref(*(static_cast<rpc_cmd*>(this))));
530
531 auto& payload = req.get_request().get_payload();
532 payload.enable_disable = 0;
533 payload.pid = getpid();
534 payload.num = 1;
535 payload.sw_ifs[0] = m_swifindex.value();
536
537 VAPI_CALL(req.execute());
538
539 wait();
Neale Ranns812ed392017-10-16 04:20:13 -0700540}
541
542void
Neale Rannsa2ee0292017-11-28 22:29:13 -0800543stats_enable_cmd::notify()
Neale Ranns812ed392017-10-16 04:20:13 -0700544{
545 m_listener.handle_interface_stat(this);
546}
547
548std::string
Neale Rannsa2ee0292017-11-28 22:29:13 -0800549stats_enable_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700550{
Neale Rannsa2ee0292017-11-28 22:29:13 -0800551 std::ostringstream s;
552 s << "itf-stats-enable itf:" << m_swifindex.to_string();
553 return (s.str());
Neale Ranns812ed392017-10-16 04:20:13 -0700554}
555
Neale Rannsa2ee0292017-11-28 22:29:13 -0800556stats_disable_cmd::stats_disable_cmd(const handle_t& handle)
557 : rpc_cmd(m_res)
558 , m_swifindex(handle)
559{
560}
561
562bool
563stats_disable_cmd::operator==(const stats_disable_cmd& other) const
564{
565 return (true);
566}
567
568rc_t
569stats_disable_cmd::issue(connection& con)
570{
571 /*
572 * then send the request to enable them
573 */
574 msg_t req(con.ctx(), 1, std::ref(*this));
575
576 auto& payload = req.get_request().get_payload();
577 payload.enable_disable = 0;
578 payload.pid = getpid();
579 payload.num = 1;
580
581 payload.sw_ifs[0] = m_swifindex.value();
582
583 VAPI_CALL(req.execute());
584
585 wait();
586
587 return (rc_t::OK);
588}
589
590std::string
591stats_disable_cmd::to_string() const
592{
593 std::ostringstream s;
594 s << "itf-stats-disable itf:" << m_swifindex.to_string();
595 return (s.str());
596}
597
Neale Ranns4ef42262018-02-20 08:10:44 -0800598dump_cmd::dump_cmd()
599{
600}
601
Neale Ranns812ed392017-10-16 04:20:13 -0700602bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700603dump_cmd::operator==(const dump_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -0700604{
605 return (true);
606}
607
608rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700609dump_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700610{
611 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
612
613 auto& payload = m_dump->get_request().get_payload();
614 payload.name_filter_valid = 0;
615
616 VAPI_CALL(m_dump->execute());
617
618 wait();
619
620 return rc_t::OK;
621}
622
623std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700624dump_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700625{
626 return ("itf-dump");
627}
628
Neale Ranns4ef42262018-02-20 08:10:44 -0800629vhost_dump_cmd::vhost_dump_cmd()
630{
631}
632
633bool
634vhost_dump_cmd::operator==(const vhost_dump_cmd& other) const
635{
636 return (true);
637}
638
639rc_t
640vhost_dump_cmd::issue(connection& con)
641{
642 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
643
644 VAPI_CALL(m_dump->execute());
645
646 wait();
647
648 return rc_t::OK;
649}
650
651std::string
652vhost_dump_cmd::to_string() const
653{
654 return ("vhost-itf-dump");
655}
656
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700657set_tag::set_tag(HW::item<handle_t>& item, const std::string& name)
Neale Ranns812ed392017-10-16 04:20:13 -0700658 : rpc_cmd(item)
659 , m_name(name)
660{
661}
662
663rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700664set_tag::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700665{
666 msg_t req(con.ctx(), std::ref(*this));
667
668 auto& payload = req.get_request().get_payload();
669 payload.is_add = 1;
670 payload.sw_if_index = m_hw_item.data().value();
671 memcpy(payload.tag, m_name.c_str(), m_name.length());
672
673 VAPI_CALL(req.execute());
674
675 wait();
676
677 return rc_t::OK;
678}
679std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700680set_tag::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700681{
682 std::ostringstream s;
683 s << "itf-set-tag: " << m_hw_item.to_string() << " name:" << m_name;
684
685 return (s.str());
686}
687
688bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700689set_tag::operator==(const set_tag& o) const
Neale Ranns812ed392017-10-16 04:20:13 -0700690{
691 return ((m_name == o.m_name) && (m_hw_item.data() == o.m_hw_item.data()));
692}
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700693}; // namespace interface_cmds
694}; // namespace VOM
695
Neale Ranns812ed392017-10-16 04:20:13 -0700696/*
697 * fd.io coding-style-patch-verification: ON
698 *
699 * Local Variables:
700 * eval: (c-set-style "mozilla")
701 * End:
702 */