vxlan: vxlan/vxlan.api API cleanup
[vpp.git] / extras / vom / vom / l2_vtr_cmds.cpp
1 /*
2  * Copyright (c) 2019 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/l2_vtr_cmds.hpp"
17
18 namespace VOM {
19 namespace l2_vtr_cmds {
20
21 set_cmd::set_cmd(HW::item<l2_vtr::option_t>& item,
22                  const handle_t& itf,
23                  uint16_t tag)
24   : rpc_cmd(item)
25   , m_itf(itf)
26   , m_tag(tag)
27 {
28 }
29
30 bool
31 set_cmd::operator==(const set_cmd& other) const
32 {
33   return (
34     (m_hw_item.data() == other.m_hw_item.data() && m_itf == other.m_itf) &&
35     (m_tag == other.m_tag));
36 }
37
38 rc_t
39 set_cmd::issue(connection& con)
40 {
41   msg_t req(con.ctx(), std::ref(*this));
42
43   auto& payload = req.get_request().get_payload();
44   payload.sw_if_index = m_itf.value();
45   payload.vtr_op = m_hw_item.data().value();
46   payload.push_dot1q = 1;
47   payload.tag1 = m_tag;
48
49   VAPI_CALL(req.execute());
50
51   return (wait());
52 }
53
54 std::string
55 set_cmd::to_string() const
56 {
57   std::ostringstream s;
58   s << "L2-vtr-set: " << m_hw_item.to_string() << " itf:" << m_itf.to_string()
59     << " tag:" << m_tag;
60
61   return (s.str());
62 }
63
64 }; // namespace vtr_cmds
65 }; // namespace VOM
66
67 /*
68  * fd.io coding-style-patch-verification: ON
69  *
70  * Local Variables:
71  * eval: (c-set-style "mozilla")
72  * End:
73  */