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>, rc_t, 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 = false);
45 * Issue the command to VPP/HW
47 rc_t issue(connection& con);
49 * convert to string format for debug purposes
51 std::string to_string() const;
54 * Comparison operator - only used for UT
56 bool operator==(const bind_cmd& i) const;
60 * Reference to the HW::item of the interface to bind
62 const handle_t& m_itf;
65 * The DHCP client's hostname
67 const std::string m_hostname;
70 * The DHCP client's ID
72 const l2_address_t m_client_id;
75 * Flag to control the setting the of DHCP discover's broadcast flag
77 const bool m_set_broadcast_flag;
81 * A cmd class that Unbinds Dhcp Config from an interface
84 : public rpc_cmd<HW::item<bool>, rc_t, vapi::Dhcp_client_config>
90 unbind_cmd(HW::item<bool>& item,
92 const std::string& hostname);
95 * Issue the command to VPP/HW
97 rc_t issue(connection& con);
99 * convert to string format for debug purposes
101 std::string to_string() const;
104 * Comparison operator - only used for UT
106 bool operator==(const unbind_cmd& i) const;
110 * Reference to the HW::item of the interface to unbind
112 const handle_t& m_itf;
115 * The DHCP client's hostname
117 const std::string m_hostname;
121 * A functor class represents our desire to recieve interface events
123 class events_cmd : public event_cmd<vapi::Control_ping, vapi::Dhcp_compl_event>
129 events_cmd(dhcp_client::event_listener& el);
133 * Issue the command to VPP/HW - subscribe to DHCP events
135 rc_t issue(connection& con);
138 * Retire the command - unsubscribe
140 void retire(connection& con);
142 * convert to string format for debug purposes
144 std::string to_string() const;
147 * Comparison operator - only used for UT
149 bool operator==(const events_cmd& i) const;
152 * called in the VAPI RX thread when data is available.
159 * The listner of this command
161 dhcp_client::event_listener& m_listener;
165 * A cmd class that Dumps all the DHCP clients
167 class dump_cmd : public VOM::dump_cmd<vapi::Dhcp_client_dump>
174 dump_cmd(const dump_cmd& d);
177 * Issue the command to VPP/HW
179 rc_t issue(connection& con);
181 * convert to string format for debug purposes
183 std::string to_string() const;
186 * Comparison operator - only used for UT
188 bool operator==(const dump_cmd& i) const;
197 }; // namespace dhcp_client_cmds
201 * fd.io coding-style-patch-verification: ON
204 * eval: (c-set-style "mozilla")