2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-05 00:15:17 +00:00

[5073a] Code almost finished (still need tests and doc)

This commit is contained in:
Francis Dupont
2017-09-20 21:33:52 +02:00
parent 042c0b6fc8
commit 6a4d93f046
15 changed files with 187 additions and 585 deletions

View File

@@ -9,6 +9,7 @@
#include <dhcp/duid.h>
#include <dhcp/hwaddr.h>
#include <dhcp/iface_mgr.h>
#include <dhcp/libdhcp++.h>
#include <dhcp/option4_addrlst.h>
#include <dhcp/option_int.h>
#include <dhcp/option_int_array.h>
@@ -960,6 +961,9 @@ Dhcpv4Srv::processPacket(Pkt4Ptr& query, Pkt4Ptr& rsp) {
// class information.
classifyPacket(query);
// Now it is classified the deferred unpacking can be done.
deferredUnpack(query);
// Check whether the message should be further processed or discarded.
// There is no need to log anything here. This function logs by itself.
if (!accept(query)) {
@@ -2819,6 +2823,61 @@ void Dhcpv4Srv::classifyPacket(const Pkt4Ptr& pkt) {
}
}
void
Dhcpv4Srv::deferredUnpack(Pkt4Ptr& query)
{
// Iterate on the list of deferred option codes
BOOST_FOREACH(const uint16_t& code, query->deferredOptions()) {
OptionDefinitionPtr def;
// Iterate on client classes
const ClientClasses& classes = query->getClasses();
for (ClientClasses::const_iterator cclass = classes.begin();
cclass != classes.end(); ++cclass) {
// Get the client class definition for this class
const ClientClassDefPtr& ccdef =
CfgMgr::instance().getCurrentCfg()->
getClientClassDictionary()->findClass(*cclass);
// If not found skip it
if (!ccdef) {
continue;
}
// If there is no option definition skip it
if (!ccdef->getCfgOptionDef()) {
continue;
}
def = ccdef->getCfgOptionDef()->get(DHCP4_OPTION_SPACE, code);
// Stop at the first client class with a defition
if (def) {
break;
}
}
// If not found try the global definition
if (!def) {
def = LibDHCP::getOptionDef(DHCP4_OPTION_SPACE, code);
}
if (!def) {
def = LibDHCP::getRuntimeOptionDef(DHCP4_OPTION_SPACE, code);
}
// Option 43 has a last resort definition
if ((code == DHO_VENDOR_ENCAPSULATED_OPTIONS) && !def) {
def = LibDHCP::last_resort_option43_def;
}
// If not defined go to the next option
if (!def) {
continue;
}
// Get the existing option for its content and remove all
const OptionBuffer buf = query->getOption(code)->getData();
while (query->delOption(code)) {
/* continue */
}
// Unpack the option and add it
OptionPtr opt = def->optionFactory(Option::V4, code,
buf.cbegin(), buf.cend());
query->addOption(opt);
}
}
void
Dhcpv4Srv::startD2() {
D2ClientMgr& d2_mgr = CfgMgr::instance().getD2ClientMgr();