[Kea-users] Force DHCP option in response
Arne Baeumler
arne+kea at br0tkasten.de
Thu Jul 6 15:06:23 UTC 2017
Hi Francis,
thank you for your hint.
I was already trying to write a hook appending Option 43 to the Pkt
instead of the PRL ... ;-)
Below is the main part of the hook (in case someone else might have the
same issue).
Any recommendations or improvements?
#include <hooks/hooks.h>
#include <dhcp/pkt4.h>
#include <dhcp/option_int_array.h>
using namespace isc::dhcp;
using namespace isc::hooks;
extern "C" {
int pkt4_receive(CalloutHandle &handle) {
Pkt4Ptr query4_ptr;
handle.getArgument("query4",query4_ptr);
// retrieve Parameter Request List (PRL)
OptionUint8ArrayPtr prl =
boost::dynamic_pointer_cast<OptionUint8Array>(query4_ptr->getOption(DHO_DHCP_PARAMETER_REQUEST_LIST));
// check if PRL already contains option 43
const std::vector<uint8_t>& prl_vector =
prl->getValues();
for(int i=0; i < prl_vector.size(); i++) {
if(prl_vector[i] ==
DHO_VENDOR_ENCAPSULATED_OPTIONS) {
// skip if option 43 is already present
return(CalloutHandle::NEXT_STEP_CONTINUE);
}
}
// append option 43 to PRL
prl->addValue(DHO_VENDOR_ENCAPSULATED_OPTIONS);
return(CalloutHandle::NEXT_STEP_CONTINUE);
}
}
--
Kind regards
Arne
More information about the Kea-users
mailing list