21 namespace dhcp_config_cmds {
25 const std::string& hostname,
29 , m_hostname(hostname)
30 , m_client_id(client_id)
37 return ((m_itf == other.m_itf) && (m_hostname == other.m_hostname));
43 msg_t req(con.
ctx(), std::ref(*
this));
45 auto& payload = req.get_request().get_payload();
46 payload.sw_if_index = m_itf.
value();
48 payload.pid = getpid();
49 payload.want_dhcp_event = 1;
51 memset(payload.hostname, 0,
sizeof(payload.hostname));
52 memcpy(payload.hostname, m_hostname.c_str(),
53 std::min(
sizeof(payload.hostname), m_hostname.length()));
55 memset(payload.client_id, 0,
sizeof(payload.client_id));
56 payload.client_id[0] = 1;
57 std::copy_n(begin(m_client_id.
bytes),
58 std::min(
sizeof(payload.client_id), m_client_id.
bytes.size()),
59 payload.client_id + 1);
73 <<
" itf:" << m_itf.
to_string() <<
" hostname:" << m_hostname;
80 const std::string& hostname)
83 , m_hostname(hostname)
90 return ((m_itf == other.m_itf) && (m_hostname == other.m_hostname));
96 msg_t req(con.
ctx(), std::ref(*
this));
98 auto& payload = req.get_request().get_payload();
99 payload.sw_if_index = m_itf.
value();
101 payload.pid = getpid();
102 payload.want_dhcp_event = 0;
104 memcpy(payload.hostname, m_hostname.c_str(),
105 std::min(
sizeof(payload.hostname), m_hostname.length()));
118 std::ostringstream s;
120 <<
" itf:" << m_itf.
to_string() <<
" hostname:" << m_hostname;
165 return (
"dhcp-events");
static const rc_t NOOP
The HW write/update action was/has not been attempted.
HW::item< bool > & m_hw_item
A reference to an object's HW::item that the command will update.
unbind_cmd(HW::item< bool > &item, const handle_t &itf, const std::string &hostname)
Constructor.
A command class that binds the DHCP config to the interface.
uint32_t value() const
get the value of the handle
bind_cmd(HW::item< bool > &item, const handle_t &itf, const std::string &hostname, const l2_address_t &client_id)
Constructor.
virtual void handle_dhcp_event(dhcp_config_cmds::events_cmd *cmd)=0
listener's virtual function invoked when a DHCP event is available to read
rc_t issue(connection &con)
Issue the command to VPP/HW.
Error codes that VPP will return during a HW write.
std::string to_string() const
convert to string format for debug purposes
Type def of a L2 address as read from VPP.
events_cmd(dhcp_config::event_listener &el)
Constructor.
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
A cmd class that Unbinds Dhcp Config from an interface.
A representation of the connection to VPP.
rc_t issue(connection &con)
Issue the command to VPP/HW.
std::string to_string() const
convert to string format for debug purposes
HW::item< bool > & item()
return the HW item the command updates
void notify()
called in the VAPI RX thread when data is available.
A base class for all RPC commands to VPP.
bool operator==(const events_cmd &i) const
Comparison operator - only used for UT.
void retire(connection &con)
Retire the command - unsubscribe.
std::vector< uint8_t > bytes
Underlying bytes array - filled from least to most significant.
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
A functor class represents our desire to recieve interface events.
std::unique_ptr< vapi::Event_registration< vapi::Dhcp_compl_event > > m_reg
The VAPI event registration.
A type declaration of an interface handle in VPP.
vapi::Event_registration< vapi::Dhcp_compl_event > reg_t
static const rc_t OK
The HW write was successfull.
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
The VPP Object Model (VOM) library.
bool operator==(const bind_cmd &i) const
Comparison operator - only used for UT.
void set(const rc_t &rc)
Set the HW return code - should only be called from the family of Command objects.
vapi::Dhcp_client_config msg_t
convenient typedef
An Event command base class.
std::string to_string() const
convert to string format for debug purposes
rc_t issue(connection &con)
Issue the command to VPP/HW - subscribe to DHCP events.
A class that listens to DHCP Events.
DEFINE_VAPI_MSG_IDS_DHCP_API_JSON
rc_t wait()
Wait on the commands promise.
bool operator==(const unbind_cmd &i) const
Comparison operator - only used for UT.