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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef __VOM_DHCP_CLIENT_CMDS_H__
17 #define __VOM_DHCP_CLIENT_CMDS_H__
19 #include "vom/dhcp_client.hpp"
20 #include "vom/dump_cmd.hpp"
21 #include "vom/event_cmd.hpp"
23 #include <vapi/dhcp.api.vapi.hpp>
24 #include <vapi/vpe.api.vapi.hpp>
27 namespace dhcp_client_cmds {
30 * A command class that binds the DHCP config to the interface
32 class bind_cmd : public rpc_cmd<HW::item<bool>, vapi::Dhcp_client_config>
38 bind_cmd(HW::item<bool>& item,
40 const std::string& hostname,
41 const l2_address_t& client_id,
42 bool set_braodcast_flag,
43 const ip_dscp_t& dscp);
46 * Issue the command to VPP/HW
48 rc_t issue(connection& con);
50 * convert to string format for debug purposes
52 std::string to_string() const;
55 * Comparison operator - only used for UT
57 bool operator==(const bind_cmd& i) const;
61 * Reference to the HW::item of the interface to bind
63 const handle_t& m_itf;
66 * The DHCP client's hostname
68 const std::string m_hostname;
71 * The DHCP client's ID
73 const l2_address_t m_client_id;
76 * Flag to control the setting the of DHCP discover's broadcast flag
78 const bool m_set_broadcast_flag;
83 const ip_dscp_t& m_dscp;
87 * A cmd class that Unbinds Dhcp Config from an interface
89 class unbind_cmd : public rpc_cmd<HW::item<bool>, vapi::Dhcp_client_config>
95 unbind_cmd(HW::item<bool>& item,
97 const std::string& hostname);
100 * Issue the command to VPP/HW
102 rc_t issue(connection& con);
104 * convert to string format for debug purposes
106 std::string to_string() const;
109 * Comparison operator - only used for UT
111 bool operator==(const unbind_cmd& i) const;
115 * Reference to the HW::item of the interface to unbind
117 const handle_t& m_itf;
120 * The DHCP client's hostname
122 const std::string m_hostname;
126 * A functor class represents our desire to recieve interface events
128 class events_cmd : public event_cmd<vapi::Control_ping, vapi::Dhcp_compl_event>
134 events_cmd(dhcp_client::event_listener& el);
138 * Issue the command to VPP/HW - subscribe to DHCP events
140 rc_t issue(connection& con);
143 * Retire the command - unsubscribe
145 void retire(connection& con);
147 * convert to string format for debug purposes
149 std::string to_string() const;
152 * Comparison operator - only used for UT
154 bool operator==(const events_cmd& i) const;
157 * called in the VAPI RX thread when data is available.
164 * The listner of this command
166 dhcp_client::event_listener& m_listener;
170 * A cmd class that Dumps all the DHCP clients
172 class dump_cmd : public VOM::dump_cmd<vapi::Dhcp_client_dump>
179 dump_cmd(const dump_cmd& d);
182 * Issue the command to VPP/HW
184 rc_t issue(connection& con);
186 * convert to string format for debug purposes
188 std::string to_string() const;
191 * Comparison operator - only used for UT
193 bool operator==(const dump_cmd& i) const;
202 }; // namespace dhcp_client_cmds
206 * fd.io coding-style-patch-verification: ON
209 * eval: (c-set-style "mozilla")