b3038017e06f6a3e4237d22776a9464fe07308b1
[vpp.git] / extras / vom / vom / lldp_binding_cmds.hpp
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 #ifndef __VOM_LLDP_BINDING_CMDS_H__
17 #define __VOM_LLDP_BINDING_CMDS_H__
18
19 #include "vom/dump_cmd.hpp"
20 #include "vom/lldp_binding.hpp"
21 #include "vom/rpc_cmd.hpp"
22
23 #include <vapi/lldp.api.vapi.hpp>
24
25 namespace VOM {
26 namespace lldp_binding_cmds {
27
28 /**
29 *A command class that binds the LLDP config to the interface
30 */
31 class bind_cmd
32   : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_lldp>
33 {
34 public:
35   /**
36    * Constructor
37    */
38   bind_cmd(HW::item<bool>& item,
39            const handle_t& itf,
40            const std::string& port_desc);
41
42   /**
43    * Issue the command to VPP/HW
44    */
45   rc_t issue(connection& con);
46   /**
47    * convert to string format for debug purposes
48    */
49   std::string to_string() const;
50
51   /**
52    * Comparison operator - only used for UT
53    */
54   bool operator==(const bind_cmd& i) const;
55
56 private:
57   /**
58    * Reference to the HW::item of the interface to bind
59    */
60   const handle_t& m_itf;
61
62   /**
63    * The LLDP client's hostname
64    */
65   const std::string m_port_desc;
66 };
67
68 /**
69  * A cmd class that Unbinds Lldp Config from an interface
70  */
71 class unbind_cmd
72   : public rpc_cmd<HW::item<bool>, rc_t, vapi::Sw_interface_set_lldp>
73 {
74 public:
75   /**
76    * Constructor
77    */
78   unbind_cmd(HW::item<bool>& item, const handle_t& itf);
79
80   /**
81    * Issue the command to VPP/HW
82    */
83   rc_t issue(connection& con);
84   /**
85    * convert to string format for debug purposes
86    */
87   std::string to_string() const;
88
89   /**
90    * Comparison operator - only used for UT
91    */
92   bool operator==(const unbind_cmd& i) const;
93
94 private:
95   /**
96    * Reference to the HW::item of the interface to unbind
97    */
98   const handle_t& m_itf;
99 };
100
101 }; // namespace lldp_binding_cmds
102 }; // naemspace VOM
103
104 /*
105  * fd.io coding-style-patch-verification: ON
106  *
107  * Local Variables:
108  * eval: (c-set-style "mozilla")
109  * End:
110  */
111
112 #endif