blob: 1b9dc1cff99fb2d676d8fab1998558bb4f6b9476 [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/bridge_domain_cmds.hpp"
Neale Ranns812ed392017-10-16 04:20:13 -070017
18DEFINE_VAPI_MSG_IDS_L2_API_JSON;
19
20namespace VOM {
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070021namespace bridge_domain_cmds {
22create_cmd::create_cmd(HW::item<uint32_t>& item)
Neale Ranns812ed392017-10-16 04:20:13 -070023 : rpc_cmd(item)
24{
25}
26
27bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070028create_cmd::operator==(const create_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -070029{
30 return (m_hw_item.data() == other.m_hw_item.data());
31}
32
33rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070034create_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -070035{
36 msg_t req(con.ctx(), std::ref(*this));
37
38 auto& payload = req.get_request().get_payload();
39 payload.bd_id = m_hw_item.data();
40 payload.flood = 1;
41 payload.uu_flood = 1;
42 payload.forward = 1;
43 payload.learn = 1;
44 payload.arp_term = 1;
45 payload.mac_age = 0;
46 payload.is_add = 1;
47
48 VAPI_CALL(req.execute());
49
50 m_hw_item.set(wait());
51
52 return (rc_t::OK);
53}
54
55std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070056create_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -070057{
58 std::ostringstream s;
59 s << "bridge-domain-create: " << m_hw_item.to_string();
60
61 return (s.str());
62}
63
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070064delete_cmd::delete_cmd(HW::item<uint32_t>& item)
Neale Ranns812ed392017-10-16 04:20:13 -070065 : rpc_cmd(item)
66{
67}
68
69bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070070delete_cmd::operator==(const delete_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -070071{
72 return (m_hw_item == other.m_hw_item);
73}
74
75rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070076delete_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -070077{
78 msg_t req(con.ctx(), std::ref(*this));
79
80 auto& payload = req.get_request().get_payload();
81 payload.bd_id = m_hw_item.data();
82 payload.is_add = 0;
83
84 VAPI_CALL(req.execute());
85
86 wait();
87 m_hw_item.set(rc_t::NOOP);
88
89 return (rc_t::OK);
90}
91
92std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -070093delete_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -070094{
95 std::ostringstream s;
96 s << "bridge-domain-delete: " << m_hw_item.to_string();
97
98 return (s.str());
99}
100
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700101dump_cmd::dump_cmd()
Neale Ranns812ed392017-10-16 04:20:13 -0700102{
103}
104
105bool
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700106dump_cmd::operator==(const dump_cmd& other) const
Neale Ranns812ed392017-10-16 04:20:13 -0700107{
108 return (true);
109}
110
111rc_t
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700112dump_cmd::issue(connection& con)
Neale Ranns812ed392017-10-16 04:20:13 -0700113{
114 m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
115
116 auto& payload = m_dump->get_request().get_payload();
117 payload.bd_id = ~0;
118
119 VAPI_CALL(m_dump->execute());
120
121 wait();
122
123 return rc_t::OK;
124}
125
126std::string
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700127dump_cmd::to_string() const
Neale Ranns812ed392017-10-16 04:20:13 -0700128{
129 return ("bridge-domain-dump");
130}
131}
Neale Ranns9ef1c0a2017-11-03 04:39:05 -0700132}
Neale Ranns812ed392017-10-16 04:20:13 -0700133
134/*
135 * fd.io coding-style-patch-verification: ON
136 *
137 * Local Variables:
138 * eval: (c-set-style "mozilla")
139 * End:
140 */