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 = 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
83 class unbind_cmd : public rpc_cmd<HW::item<bool>, vapi::Dhcp_client_config>
89 unbind_cmd(HW::item<bool>& item,
91 const std::string& hostname);
94 * Issue the command to VPP/HW
96 rc_t issue(connection& con);
98 * convert to string format for debug purposes
100 std::string to_string() const;
103 * Comparison operator - only used for UT
105 bool operator==(const unbind_cmd& i) const;
109 * Reference to the HW::item of the interface to unbind
111 const handle_t& m_itf;
114 * The DHCP client's hostname
116 const std::string m_hostname;
120 * A functor class represents our desire to recieve interface events
122 class events_cmd : public event_cmd<vapi::Control_ping, vapi::Dhcp_compl_event>
128 events_cmd(dhcp_client::event_listener& el);
132 * Issue the command to VPP/HW - subscribe to DHCP events
134 rc_t issue(connection& con);
137 * Retire the command - unsubscribe
139 void retire(connection& con);
141 * convert to string format for debug purposes
143 std::string to_string() const;
146 * Comparison operator - only used for UT
148 bool operator==(const events_cmd& i) const;
151 * called in the VAPI RX thread when data is available.
158 * The listner of this command
160 dhcp_client::event_listener& m_listener;
164 * A cmd class that Dumps all the DHCP clients
166 class dump_cmd : public VOM::dump_cmd<vapi::Dhcp_client_dump>
173 dump_cmd(const dump_cmd& d);
176 * Issue the command to VPP/HW
178 rc_t issue(connection& con);
180 * convert to string format for debug purposes
182 std::string to_string() const;
185 * Comparison operator - only used for UT
187 bool operator==(const dump_cmd& i) const;
196 }; // namespace dhcp_client_cmds
200 * fd.io coding-style-patch-verification: ON
203 * eval: (c-set-style "mozilla")