|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
22 namespace dhcp_client_cmds {
33 , m_client_id(client_id)
42 return ((m_itf == other.m_itf) && (m_hostname == other.m_hostname));
48 msg_t req(
con.ctx(), std::ref(*
this));
50 auto& payload = req.get_request().get_payload();
52 payload.client.sw_if_index = m_itf.
value();
53 payload.client.pid = getpid();
54 payload.client.want_dhcp_event = 1;
55 payload.client.set_broadcast_flag = m_set_broadcast_flag;
56 payload.client.dscp =
to_api(m_dscp);
58 memset(payload.client.hostname, 0,
sizeof(payload.client.hostname));
59 memcpy(payload.client.hostname, m_hostname.c_str(),
60 std::min(
sizeof(payload.client.hostname), m_hostname.length()));
62 memset(payload.client.id, 0,
sizeof(payload.client.id));
63 payload.client.id[0] = 1;
64 std::copy_n(begin(m_client_id.
bytes),
65 std::min(
sizeof(payload.client.id), m_client_id.
bytes.size()),
66 payload.client.id + 1);
78 <<
" itf:" << m_itf.
to_string() <<
" hostname:" << m_hostname
79 <<
" client_id:[" << m_client_id <<
"] "
97 return ((m_itf == other.m_itf) && (m_hostname == other.m_hostname));
103 msg_t req(
con.ctx(), std::ref(*
this));
105 auto& payload = req.get_request().get_payload();
107 payload.client.sw_if_index = m_itf.
value();
108 payload.client.pid = getpid();
109 payload.client.want_dhcp_event = 0;
111 memcpy(payload.client.hostname, m_hostname.c_str(),
112 std::min(
sizeof(payload.client.hostname), m_hostname.length()));
125 std::ostringstream s;
127 <<
" itf:" << m_itf.
to_string() <<
" hostname:" << m_hostname;
171 for (
auto& msg : *
this) {
172 auto& payload = msg.get_payload();
177 (uint8_t*)&payload.lease.host_address.un,
178 payload.lease.mask_width);
179 std::shared_ptr<interface> itf =
interface::find(payload.lease.sw_if_index);
182 std::shared_ptr<dhcp_client::lease_t> ev =
183 std::make_shared<dhcp_client::lease_t>(
184 s, itf,
from_bytes(0, (uint8_t*)&payload.lease.router_address.un),
185 pfx,
reinterpret_cast<const char*
>(payload.lease.hostname),
192 << payload.lease.sw_if_index;
202 return (
"dhcp-events");
230 return (
"dhcp-client-dump");
vapi::Dhcp_client_dump msg_t
A cmd class that Dumps all the DHCP clients.
rc_t wait()
Wait on the commands promise.
void set(const rc_t &rc)
Set the HW return code - should only be called from the family of Command objects.
The VPP Object Model (VOM) library.
std::vector< uint8_t > bytes
Underlying bytes array - filled from least to most significant.
const static rc_t OK
The HW write was successfull.
vapi::Event_registration< vapi::Dhcp_compl_event > reg_t
const static log_level_t INFO
uint32_t value() const
get the value of the handle
void retire(connection &con)
Retire the command - unsubscribe.
A base class for all RPC commands to VPP.
void notify()
called in the VAPI RX thread when data is available.
boost::asio::ip::address from_bytes(uint8_t is_ip6, const uint8_t *bytes)
Convert a VPP byte stinrg into a boost addresss.
A functor class represents our desire to recieve interface events.
A command class that binds the DHCP config to the interface.
std::string to_string() const
convert to string format for debug purposes
HW::item< bool > & m_hw_item
A reference to an object's HW::item that the command will update.
std::unique_ptr< vapi::Dhcp_client_dump > m_dump
The VAPI event registration.
#define VAPI_CALL(_stmt)
Convenince wrapper macro for error handling in VAPI sends.
DEFINE_VAPI_MSG_IDS_DHCP_API_JSON
An Event command base class.
A representation of the connection to VPP.
virtual void handle_dhcp_event(std::shared_ptr< lease_t > e)=0
listener's virtual function invoked when a DHCP event is available to read
rc_t wait()
Wait for the issue of the command to complete.
const static rc_t NOOP
The HW write/update action was/has not been attempted.
std::string to_string() const
convert to string format for debug purposes
bool operator==(const events_cmd &i) const
Comparison operator - only used for UT.
A type declaration of an interface handle in VPP.
static const state_t & from_vpp(int i)
std::string to_string() const
convert to string format for debug purposes
bind_cmd(HW::item< bool > &item, const handle_t &itf, const std::string &hostname, const l2_address_t &client_id, bool set_braodcast_flag, const ip_dscp_t &dscp)
Constructor.
A class that listens to DHCP Events.
A cmd class that Unbinds Dhcp Config from an interface.
std::unique_ptr< vapi::Event_registration< vapi::Dhcp_compl_event > > m_reg
The VAPI event registration.
vapi_enum_ip_neighbor_flags to_api(const neighbour::flags_t &f)
unbind_cmd(HW::item< bool > &item, const handle_t &itf, const std::string &hostname)
Constructor.
vapi::Dhcp_client_config msg_t
convenient typedef
const std::string & to_string() const
convert to string format for debug purposes
Type def of a L2 address as read from VPP.
std::string to_string() const
convert to string format for debug purposes
void flush()
flush/free all the events thus far reeived.
Type def of a Ethernet address.
rc_t issue(connection &con)
Issue the command to VPP/HW.
bool operator==(const bind_cmd &i) const
Comparison operator - only used for UT.
std::string to_string() const
convert to string format for debug purposes
std::string to_string() const
convert to string format for debug purposes
bool operator==(const dump_cmd &i) const
Comparison operator - only used for UT.
events_cmd(dhcp_client::event_listener &el)
Constructor.
Error codes that VPP will return during a HW write.
const static log_level_t ERROR
rc_t issue(connection &con)
Issue the command to VPP/HW - subscribe to DHCP events.
bool operator==(const unbind_cmd &i) const
Comparison operator - only used for UT.
rc_t issue(connection &con)
Issue the command to VPP/HW.
static std::shared_ptr< interface > find(const handle_t &h)
The the singular instance of the interface in the DB by handle.
rc_t issue(connection &con)
Issue the command to VPP/HW.