GBP: add allowed ethertypes to contracts
[vpp.git] / extras / vom / vom / gbp_bridge_domain_cmds.cpp
1 /*
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/gbp_bridge_domain_cmds.hpp"
17
18 namespace VOM {
19 namespace gbp_bridge_domain_cmds {
20
21 create_cmd::create_cmd(HW::item<uint32_t>& item,
22                        const handle_t bvi,
23                        const handle_t uu_fwd)
24   : rpc_cmd(item)
25   , m_bvi(bvi)
26   , m_uu_fwd(uu_fwd)
27 {
28 }
29
30 bool
31 create_cmd::operator==(const create_cmd& other) const
32 {
33   return ((m_hw_item.data() == other.m_hw_item.data()) &&
34           (m_bvi == other.m_bvi) && (m_uu_fwd == other.m_uu_fwd));
35 }
36
37 rc_t
38 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
44   payload.bd.bd_id = m_hw_item.data();
45   payload.bd.bvi_sw_if_index = m_bvi.value();
46   payload.bd.uu_fwd_sw_if_index = m_uu_fwd.value();
47
48   VAPI_CALL(req.execute());
49
50   return (wait());
51 }
52
53 std::string
54 create_cmd::to_string() const
55 {
56   std::ostringstream s;
57   s << "gbp-bridge-domain: " << m_hw_item.to_string()
58     << " bvi:" << m_bvi.to_string() << " uu-fwd:" << m_uu_fwd.to_string();
59
60   return (s.str());
61 }
62
63 delete_cmd::delete_cmd(HW::item<uint32_t>& item)
64   : rpc_cmd(item)
65 {
66 }
67
68 bool
69 delete_cmd::operator==(const delete_cmd& other) const
70 {
71   return (m_hw_item.data() == other.m_hw_item.data());
72 }
73
74 rc_t
75 delete_cmd::issue(connection& con)
76 {
77   msg_t req(con.ctx(), std::ref(*this));
78
79   auto& payload = req.get_request().get_payload();
80
81   payload.bd_id = m_hw_item.data();
82
83   VAPI_CALL(req.execute());
84
85   wait();
86   m_hw_item.set(rc_t::NOOP);
87
88   return rc_t::OK;
89 }
90
91 std::string
92 delete_cmd::to_string() const
93 {
94   std::ostringstream s;
95   s << "gbp-bridge-domain: " << m_hw_item.to_string();
96
97   return (s.str());
98 }
99
100 bool
101 dump_cmd::operator==(const dump_cmd& other) const
102 {
103   return (true);
104 }
105
106 rc_t
107 dump_cmd::issue(connection& con)
108 {
109   m_dump.reset(new msg_t(con.ctx(), std::ref(*this)));
110
111   VAPI_CALL(m_dump->execute());
112
113   wait();
114
115   return rc_t::OK;
116 }
117
118 std::string
119 dump_cmd::to_string() const
120 {
121   return ("gbp-bridge-domain-dump");
122 }
123
124 }; // namespace gbp_bridge_domain_cmds
125 }; // namespace VOM
126
127 /*
128  * fd.io coding-style-patch-verification: ON
129  *
130  * Local Variables:
131  * eval: (c-set-style "mozilla")
132  * End:
133  */