29const std::vector<uint16_t> DHCP_SPECIFIC_OPTIONS = {
44const size_t BOOT_VENDOR_SPACE_SIZE = 64;
47const size_t BOOT_MIN_SIZE = Pkt4::DHCPV4_PKT_HDR_LEN + BOOT_VENDOR_SPACE_SIZE;
50static_assert(BOOT_MIN_SIZE == 300,
"BOOT_MIN_SIZE is not 300");
70 if (status == CalloutHandle::NEXT_STEP_DROP) {
79 if (handle.
getStatus() != CalloutHandle::NEXT_STEP_SKIP) {
87 query->addClass(
"BOOTP");
91 .arg(query->getLabel());
99 }
catch (
const std::exception& ex) {
103 .arg(query->getRemoteAddr().toText())
104 .arg(query->getLocalAddr().toText())
105 .arg(query->getIface())
109 StatsMgr::instance().addValue(
"pkt4-parse-failed",
110 static_cast<int64_t
>(1));
111 StatsMgr::instance().addValue(
"pkt4-receive-drop",
112 static_cast<int64_t
>(1));
114 handle.
setStatus(CalloutHandle::NEXT_STEP_DROP);
120 handle.
setStatus(CalloutHandle::NEXT_STEP_SKIP);
134 if (status == CalloutHandle::NEXT_STEP_DROP) {
143 if (!query->inClass(
"BOOTP")) {
151 if (status == CalloutHandle::NEXT_STEP_SKIP) {
155 for (uint16_t code : DHCP_SPECIFIC_OPTIONS) {
156 while (response->delOption(code))
163 .arg(response->getLabel());
169 if (size < BOOT_MIN_SIZE) {
170 size_t delta = BOOT_MIN_SIZE - size;
171 std::vector<uint8_t> zeros(delta, 0);
174 }
catch (
const std::exception& ex) {
176 .arg(response->getLabel())
181 handle.
setStatus(CalloutHandle::NEXT_STEP_SKIP);
190 const std::string& proc_name = Daemon::getProcName();
191 if (proc_name !=
"kea-dhcp4") {
193 <<
", expected kea-dhcp4");
int load(LibraryHandle &)
This function is called when the library is loaded.
int multi_threading_compatible()
This function is called to retrieve the multi-threading compatibility.
int pkt4_send(CalloutHandle &handle)
This callout is called at the "pkt4_send" hook.
int unload()
This function is called when the library is unloaded.
int buffer4_receive(CalloutHandle &handle)
This callout is called at the "buffer4_receive" hook.
const isc::log::MessageID BOOTP_LOAD
const isc::log::MessageID BOOTP_PACKET_UNPACK_FAILED
const isc::log::MessageID BOOTP_PACKET_PACK
const isc::log::MessageID BOOTP_UNLOAD
const isc::log::MessageID BOOTP_PACKET_OPTIONS_SKIPPED
const isc::log::MessageID BOOTP_BOOTP_QUERY
const isc::log::MessageID BOOTP_PACKET_PACK_FAIL
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown if a function is called in a prohibited way.
A generic exception that is thrown when an unexpected error condition occurs.
Exception thrown during option unpacking This exception is thrown when an error has occurred,...
Per-packet callout handle.
CalloutNextStep
Specifies allowed next steps.
CalloutNextStep getStatus() const
Returns the next processing step.
void setStatus(const CalloutNextStep next)
Sets the next processing step.
void getArgument(const std::string &name, T &value) const
Get argument.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
void writeData(const void *data, size_t len)
Copy an arbitrary length of data into the buffer.
size_t getLength() const
Return the length of data written in the buffer.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
isc::log::Logger bootp_logger("bootp-hooks")
@ DHO_DHCP_MAX_MESSAGE_SIZE
@ DHO_DHCP_REBINDING_TIME
@ DHO_DHCP_SERVER_IDENTIFIER
@ DHO_DHCP_CLIENT_IDENTIFIER
@ DHO_DHCP_REQUESTED_ADDRESS
@ DHO_DHCP_OPTION_OVERLOAD
@ DHO_DHCP_PARAMETER_REQUEST_LIST
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
@ DHCP_NOTYPE
Message Type option missing.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
Defines the logger used by the top-level component of kea-lfc.