Fix coverity warnings in VOM and VAPI
[vpp.git] / src / vpp-api / vom / route_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/route_domain.hpp"
17
18 namespace VOM {
19
20 route_domain::create_cmd::create_cmd(HW::item<bool>& item,
21                                      l3_proto_t proto,
22                                      route::table_id_t id)
23   : rpc_cmd(item)
24   , m_id(id)
25   , m_proto(proto)
26 {
27 }
28
29 bool
30 route_domain::create_cmd::operator==(const create_cmd& other) const
31 {
32   return (m_id == other.m_id);
33 }
34
35 rc_t
36 route_domain::create_cmd::issue(connection& con)
37 {
38   msg_t req(con.ctx(), std::ref(*this));
39
40   auto& payload = req.get_request().get_payload();
41   payload.table_id = m_id;
42   payload.is_add = 1;
43   payload.is_ipv6 = m_proto.is_ipv6();
44
45   VAPI_CALL(req.execute());
46
47   m_hw_item.set(wait());
48
49   return (rc_t::OK);
50 }
51
52 std::string
53 route_domain::create_cmd::to_string() const
54 {
55   std::ostringstream s;
56   s << "ip-table-create: " << m_hw_item.to_string() << " id:" << m_id
57     << " af:" << m_proto.to_string();
58
59   return (s.str());
60 }
61
62 route_domain::delete_cmd::delete_cmd(HW::item<bool>& item,
63                                      l3_proto_t proto,
64                                      route::table_id_t id)
65   : rpc_cmd(item)
66   , m_id(id)
67   , m_proto(proto)
68 {
69 }
70
71 bool
72 route_domain::delete_cmd::operator==(const delete_cmd& other) const
73 {
74   return (m_id == other.m_id);
75 }
76
77 rc_t
78 route_domain::delete_cmd::issue(connection& con)
79 {
80   msg_t req(con.ctx(), std::ref(*this));
81
82   auto& payload = req.get_request().get_payload();
83   payload.table_id = m_id;
84   payload.is_add = 0;
85   payload.is_ipv6 = m_proto.is_ipv6();
86
87   VAPI_CALL(req.execute());
88
89   wait();
90   m_hw_item.set(rc_t::NOOP);
91
92   return (rc_t::OK);
93 }
94
95 std::string
96 route_domain::delete_cmd::to_string() const
97 {
98   std::ostringstream s;
99   s << "ip-table-delete: " << m_hw_item.to_string() << " id:" << m_id
100     << " af:" << m_proto.to_string();
101
102   return (s.str());
103 }
104 }
105 /*
106  * fd.io coding-style-patch-verification: ON
107  *
108  * Local Variables:
109  * eval: (c-set-style "mozilla")
110  * End:
111  */