blob: 990af069a90f759a409e6a7c716fe659062dd72d [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
16#include "vom/bridge_domain_entry.hpp"
17
18namespace VOM {
19bridge_domain_entry::create_cmd::create_cmd(HW::item<bool>& item,
20 const mac_address_t& mac,
21 uint32_t bd,
22 handle_t tx_itf)
23 : rpc_cmd(item)
24 , m_mac(mac)
25 , m_bd(bd)
26 , m_tx_itf(tx_itf)
27{
28}
29
30bool
31bridge_domain_entry::create_cmd::operator==(const create_cmd& other) const
32{
33 return ((m_mac == other.m_mac) && (m_tx_itf == other.m_tx_itf) &&
34 (m_bd == other.m_bd));
35}
36
37rc_t
38bridge_domain_entry::create_cmd::issue(connection& con)
39{
40 msg_t req(con.ctx(), std::ref(*this));
41
42 auto& payload = req.get_request().get_payload();
43 payload.bd_id = m_bd;
44 payload.is_add = 1;
Neale Rannsf29e85f2017-11-01 03:29:13 -070045 m_mac.to_bytes(payload.mac, 6);
Neale Ranns812ed392017-10-16 04:20:13 -070046 payload.sw_if_index = m_tx_itf.value();
47
48 VAPI_CALL(req.execute());
49
50 m_hw_item.set(wait());
51
52 return rc_t::OK;
53}
54
55std::string
56bridge_domain_entry::create_cmd::to_string() const
57{
58 std::ostringstream s;
59 s << "bridge-domain-entry-create: " << m_hw_item.to_string() << " bd:" << m_bd
60 << " mac:" << m_mac.to_string() << " tx:" << m_tx_itf;
61
62 return (s.str());
63}
64
65bridge_domain_entry::delete_cmd::delete_cmd(HW::item<bool>& item,
66 const mac_address_t& mac,
67 uint32_t bd)
68 : rpc_cmd(item)
69 , m_mac(mac)
70 , m_bd(bd)
71{
72}
73
74bool
75bridge_domain_entry::delete_cmd::operator==(const delete_cmd& other) const
76{
77 return ((m_mac == other.m_mac) && (m_bd == other.m_bd));
78}
79
80rc_t
81bridge_domain_entry::delete_cmd::issue(connection& con)
82{
83 msg_t req(con.ctx(), std::ref(*this));
84
85 auto& payload = req.get_request().get_payload();
86 payload.bd_id = m_bd;
87 payload.is_add = 1;
Neale Rannsf29e85f2017-11-01 03:29:13 -070088 m_mac.to_bytes(payload.mac, 6);
Neale Ranns812ed392017-10-16 04:20:13 -070089 payload.sw_if_index = ~0;
90
91 VAPI_CALL(req.execute());
92
93 wait();
94 m_hw_item.set(rc_t::NOOP);
95
96 return rc_t::OK;
97}
98
99std::string
100bridge_domain_entry::delete_cmd::to_string() const
101{
102 std::ostringstream s;
103 s << "bridge-domain-entry-delete: " << m_hw_item.to_string() << " bd:" << m_bd
104 << " mac:" << m_mac.to_string();
105
106 return (s.str());
107}
108
109bridge_domain_entry::dump_cmd::dump_cmd()
110{
111}
112
113bool
114bridge_domain_entry::dump_cmd::operator==(const dump_cmd& other) const
115{
116 return (true);
117}
118
119rc_t
120bridge_domain_entry::dump_cmd::issue(connection& con)
121{
122 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
123
124 auto& payload = m_dump->get_request().get_payload();
125 payload.bd_id = ~0;
126
127 VAPI_CALL(m_dump->execute());
128
129 wait();
130
131 return rc_t::OK;
132}
133
134std::string
135bridge_domain_entry::dump_cmd::to_string() const
136{
137 return ("bridge-domain-entry-dump");
138}
139}
140
141/*
142 * fd.io coding-style-patch-verification: ON
143 *
144 * Local Variables:
145 * eval: (c-set-style "mozilla")
146 * End:
147 */