FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
dhcp_config_cmds.hpp
Go to the documentation of this file.
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_DHCP_CONFIG_CMDS_H__
17 #define __VOM_DHCP_CONFIG_CMDS_H__
18 
19 #include "vom/dhcp_config.hpp"
20 #include "vom/event_cmd.hpp"
21 
22 #include <vapi/dhcp.api.vapi.hpp>
23 #include <vapi/vpe.api.vapi.hpp>
24 
25 namespace VOM {
26 namespace dhcp_config_cmds {
27 
28 /**
29  * A command class that binds the DHCP config to the interface
30  */
31 class bind_cmd : public rpc_cmd<HW::item<bool>, rc_t, vapi::Dhcp_client_config>
32 {
33 public:
34  /**
35  * Constructor
36  */
38  const handle_t& itf,
39  const std::string& hostname,
40  const l2_address_t& client_id,
41  bool set_braodcast_flag = false);
42 
43  /**
44  * Issue the command to VPP/HW
45  */
46  rc_t issue(connection& con);
47  /**
48  * convert to string format for debug purposes
49  */
50  std::string to_string() const;
51 
52  /**
53  * Comparison operator - only used for UT
54  */
55  bool operator==(const bind_cmd& i) const;
56 
57 private:
58  /**
59  * Reference to the HW::item of the interface to bind
60  */
61  const handle_t& m_itf;
62 
63  /**
64  * The DHCP client's hostname
65  */
66  const std::string m_hostname;
67 
68  /**
69  * The DHCP client's ID
70  */
71  const l2_address_t m_client_id;
72 
73  /**
74  * Flag to control the setting the of DHCP discover's broadcast flag
75  */
76  const bool m_set_broadcast_flag;
77 };
78 
79 /**
80  * A cmd class that Unbinds Dhcp Config from an interface
81  */
83  : public rpc_cmd<HW::item<bool>, rc_t, vapi::Dhcp_client_config>
84 {
85 public:
86  /**
87  * Constructor
88  */
90  const handle_t& itf,
91  const std::string& hostname);
92 
93  /**
94  * Issue the command to VPP/HW
95  */
96  rc_t issue(connection& con);
97  /**
98  * convert to string format for debug purposes
99  */
100  std::string to_string() const;
101 
102  /**
103  * Comparison operator - only used for UT
104  */
105  bool operator==(const unbind_cmd& i) const;
106 
107 private:
108  /**
109  * Reference to the HW::item of the interface to unbind
110  */
111  const handle_t& m_itf;
112 
113  /**
114  * The DHCP client's hostname
115  */
116  const std::string m_hostname;
117 };
118 
119 /**
120  * A functor class represents our desire to recieve interface events
121  */
122 class events_cmd : public event_cmd<vapi::Control_ping, vapi::Dhcp_compl_event>
123 {
124 public:
125  /**
126  * Constructor
127  */
129 
130  /**
131  * Issue the command to VPP/HW - subscribe to DHCP events
132  */
133  rc_t issue(connection& con);
134 
135  /**
136  * Retire the command - unsubscribe
137  */
138  void retire(connection& con);
139  /**
140  * convert to string format for debug purposes
141  */
142  std::string to_string() const;
143 
144  /**
145  * Comparison operator - only used for UT
146  */
147  bool operator==(const events_cmd& i) const;
148 
149  /**
150  * called in the VAPI RX thread when data is available.
151  */
152  void notify();
153 
154 private:
155  void succeeded() {}
156  /**
157  * The listner of this command
158  */
159  dhcp_config::event_listener& m_listener;
160 };
161 };
162 };
163 
164 /*
165  * fd.io coding-style-patch-verification: ON
166  *
167  * Local Variables:
168  * eval: (c-set-style "mozilla")
169  * End:
170  */
171 
172 #endif
A command class that binds the DHCP config to the interface.
rc_t issue(connection &con)
Issue the command to VPP/HW.
int i
Error codes that VPP will return during a HW write.
Definition: types.hpp:90
Type def of a L2 address as read from VPP.
Definition: types.hpp:342
virtual void succeeded()
Called by the HW Command Q when it is disabled to indicate the command can be considered successful w...
Definition: rpc_cmd.hpp:108
virtual void retire(connection &con)
Retire/cancel a long running command.
Definition: rpc_cmd.hpp:129
A cmd class that Unbinds Dhcp Config from an interface.
A representation of the connection to VPP.
Definition: connection.hpp:33
std::string to_string() const
convert to string format for debug purposes
HW::item< bool > & item()
return the HW item the command updates
Definition: rpc_cmd.hpp:64
A base class for all RPC commands to VPP.
Definition: rpc_cmd.hpp:38
A functor class represents our desire to recieve interface events.
A type declaration of an interface handle in VPP.
Definition: types.hpp:236
bind_cmd(HW::item< bool > &item, const handle_t &itf, const std::string &hostname, const l2_address_t &client_id, bool set_braodcast_flag=false)
Constructor.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
bool operator==(const bind_cmd &i) const
Comparison operator - only used for UT.
An Event command base class.
Definition: event_cmd.hpp:39
A class that listens to DHCP Events.
Definition: dhcp_config.hpp:99