21 namespace dhcp_config_cmds {
25 const std::string& hostname,
27 bool set_broadcast_flag)
30 , m_hostname(hostname)
31 , m_client_id(client_id)
32 , m_set_broadcast_flag(set_broadcast_flag)
39 return ((m_itf == other.m_itf) && (m_hostname == other.m_hostname));
45 msg_t req(con.
ctx(), std::ref(*
this));
47 auto& payload = req.get_request().get_payload();
48 payload.sw_if_index = m_itf.
value();
50 payload.pid = getpid();
51 payload.want_dhcp_event = 1;
52 payload.set_broadcast_flag = m_set_broadcast_flag;
54 memset(payload.hostname, 0,
sizeof(payload.hostname));
55 memcpy(payload.hostname, m_hostname.c_str(),
56 std::min(
sizeof(payload.hostname), m_hostname.length()));
58 memset(payload.client_id, 0,
sizeof(payload.client_id));
59 payload.client_id[0] = 1;
60 std::copy_n(begin(m_client_id.
bytes),
61 std::min(
sizeof(payload.client_id), m_client_id.
bytes.size()),
62 payload.client_id + 1);
76 <<
" itf:" << m_itf.
to_string() <<
" hostname:" << m_hostname;
83 const std::string& hostname)
86 , m_hostname(hostname)
93 return ((m_itf == other.m_itf) && (m_hostname == other.m_hostname));
99 msg_t req(con.
ctx(), std::ref(*
this));
101 auto& payload = req.get_request().get_payload();
102 payload.sw_if_index = m_itf.
value();
104 payload.pid = getpid();
105 payload.want_dhcp_event = 0;
107 memcpy(payload.hostname, m_hostname.c_str(),
108 std::min(
sizeof(payload.hostname), m_hostname.length()));
121 std::ostringstream s;
123 <<
" itf:" << m_itf.
to_string() <<
" hostname:" << m_hostname;
168 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
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.
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.
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.