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_CONFIG_CMDS_H__
17 #define __VOM_DHCP_CONFIG_CMDS_H__
19 #include "vom/dhcp_config.hpp"
20 #include "vom/event_cmd.hpp"
22 #include <vapi/dhcp.api.vapi.hpp>
23 #include <vapi/vpe.api.vapi.hpp>
26 namespace dhcp_config_cmds {
29 * A command class that binds the DHCP config to the interface
31 class bind_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Dhcp_client_config>
37 bind_cmd(HW::item<bool>& item,
39 const std::string& hostname,
40 const l2_address_t& client_id,
41 bool set_braodcast_flag = false);
44 * Issue the command to VPP/HW
46 rc_t issue(connection& con);
48 * convert to string format for debug purposes
50 std::string to_string() const;
53 * Comparison operator - only used for UT
55 bool operator==(const bind_cmd& i) const;
59 * Reference to the HW::item of the interface to bind
61 const handle_t& m_itf;
64 * The DHCP client's hostname
66 const std::string m_hostname;
69 * The DHCP client's ID
71 const l2_address_t m_client_id;
74 * Flag to control the setting the of DHCP discover's broadcast flag
76 const bool m_set_broadcast_flag;
80 * A cmd class that Unbinds Dhcp Config from an interface
83 : public rpc_cmd<HW::item<bool>, rc_t, 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_config::event_listener& el);
131 * Issue the command to VPP/HW - subscribe to DHCP events
133 rc_t issue(connection& con);
136 * Retire the command - unsubscribe
138 void retire(connection& con);
140 * convert to string format for debug purposes
142 std::string to_string() const;
145 * Comparison operator - only used for UT
147 bool operator==(const events_cmd& i) const;
150 * called in the VAPI RX thread when data is available.
157 * The listner of this command
159 dhcp_config::event_listener& m_listener;
165 * fd.io coding-style-patch-verification: ON
168 * eval: (c-set-style "mozilla")