27 const std::vector<uint16_t> DHCP_SPECIFIC_OPTIONS = {
42 const size_t BOOT_VENDOR_SPACE_SIZE = 64;
45 const size_t BOOT_MIN_SIZE = Pkt4::DHCPV4_PKT_HDR_LEN + BOOT_VENDOR_SPACE_SIZE;
48 static_assert(BOOT_MIN_SIZE == 300,
"BOOT_MIN_SIZE is not 300");
68 if (status == CalloutHandle::NEXT_STEP_DROP) {
77 if (handle.
getStatus() != CalloutHandle::NEXT_STEP_SKIP) {
85 query->addClass(
"BOOTP");
89 .arg(query->getLabel());
97 }
catch (
const std::exception& ex) {
101 .arg(query->getRemoteAddr().toText())
102 .arg(query->getLocalAddr().toText())
103 .arg(query->getIface())
107 StatsMgr::instance().addValue(
"pkt4-parse-failed",
108 static_cast<int64_t>(1));
109 StatsMgr::instance().addValue(
"pkt4-receive-drop",
110 static_cast<int64_t>(1));
112 handle.
setStatus(CalloutHandle::NEXT_STEP_DROP);
118 handle.
setStatus(CalloutHandle::NEXT_STEP_SKIP);
132 if (status == CalloutHandle::NEXT_STEP_DROP) {
141 if (!query->inClass(
"BOOTP")) {
149 if (status == CalloutHandle::NEXT_STEP_SKIP) {
153 for (uint16_t code : DHCP_SPECIFIC_OPTIONS) {
154 while (response->delOption(code))
161 .arg(response->getLabel());
167 if (size < BOOT_MIN_SIZE) {
168 size_t delta = BOOT_MIN_SIZE - size;
169 std::vector<uint8_t> zeros(delta, 0);
172 }
catch (
const std::exception& ex) {
174 .arg(response->getLabel())
179 handle.
setStatus(CalloutHandle::NEXT_STEP_SKIP);
int pkt4_send(CalloutHandle &handle)
This callout is called at the "pkt4_send" hook.
void setStatus(const CalloutNextStep next)
Sets the next processing step.
int load(LibraryHandle &)
This function is called when the library is loaded.
Message Type option missing.
const int DBGLVL_TRACE_BASIC
Trace basic operations.
const isc::log::MessageID BOOTP_BOOTP_QUERY
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Exception thrown during option unpacking This exception is thrown when an error has occurred...
const isc::log::MessageID BOOTP_PACKET_PACK
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
const isc::log::MessageID BOOTP_LOAD
const isc::log::MessageID BOOTP_PACKET_PACK_FAIL
void writeData(const void *data, size_t len)
Copy an arbitrary length of data into the buffer.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
int unload()
This function is called when the library is unloaded.
Per-packet callout handle.
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
CalloutNextStep
Specifies allowed next steps.
const isc::log::MessageID BOOTP_UNLOAD
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The OutputBuffer class is a buffer abstraction for manipulating mutable data.
int buffer4_receive(CalloutHandle &handle)
This callout is called at the "buffer4_receive" hook.
Defines the logger used by the top-level component of kea-dhcp-ddns.
A generic exception that is thrown if a function is called in a prohibited way.
#define LOG_DEBUG(LOGGER, LEVEL, MESSAGE)
Macro to conveniently test debug output and log it.
void getArgument(const std::string &name, T &value) const
Get argument.
isc::log::Logger bootp_logger("bootp-hooks")
const isc::log::MessageID BOOTP_PACKET_OPTIONS_SKIPPED
size_t getLength() const
Return the length of data written in the buffer.
int multi_threading_compatible()
This function is called to retrieve the multi-threading compatibility.
const isc::log::MessageID BOOTP_PACKET_UNPACK_FAILED
CalloutNextStep getStatus() const
Returns the next processing step.