summaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorFrancis Dupont <fdupont@isc.org>2022-07-31 21:16:53 +0200
committerFrancis Dupont <fdupont@isc.org>2022-08-03 15:26:10 +0200
commita63c5824e05b57fb1f59eda94a53599eee79be4d (patch)
tree2f7b88b2585679298ac4dd8bd5d46a8477fc4b43 /src/bin
parent[#2517] Revamped option sending (diff)
downloadkea-a63c5824e05b57fb1f59eda94a53599eee79be4d.tar.xz
kea-a63c5824e05b57fb1f59eda94a53599eee79be4d.zip
[#2517] Adding multiple requested vendor options
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/dhcp6/dhcp6_srv.cc38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index 118ba2128e..ffd5e8388b 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -1523,7 +1523,7 @@ Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer,
}
}
- // Special cases for vendor class. Vendor options are done later.
+ // Special cases for vendor class and options.
if (requested_opts.count(D6O_VENDOR_CLASS) > 0) {
set<uint32_t> vendor_ids;
for (auto opt : answer->getOptions(D6O_VENDOR_CLASS)) {
@@ -1559,6 +1559,42 @@ Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer,
}
}
}
+
+ if (requested_opts.count(D6O_VENDOR_OPTS) > 0) {
+ set<uint32_t> vendor_ids;
+ for (auto opt : answer->getOptions(D6O_VENDOR_OPTS)) {
+ if (opt.first != D6O_VENDOR_OPTS) {
+ continue;
+ }
+ OptionVendorPtr vendor_opts;
+ vendor_opts = boost::dynamic_pointer_cast<OptionVendor>(opt.second);
+ if (vendor_opts) {
+ int32_t vendor_id = vendor_opts->getVendorId();
+ static_cast<void>(vendor_ids.insert(vendor_id));
+ }
+ }
+ // Iterate on the configured option list
+ for (CfgOptionList::const_iterator copts = co_list.begin();
+ copts != co_list.end(); ++copts) {
+ for (OptionDescriptor desc : (*copts)->getList(DHCP6_OPTION_SPACE,
+ D6O_VENDOR_OPTS)) {
+ if (!desc.option_) {
+ continue;
+ }
+ OptionVendorPtr vendor_opts =
+ boost::dynamic_pointer_cast<OptionVendor>(desc.option_);
+ if (!vendor_opts) {
+ continue;
+ }
+ // Is the vendor id already in the response?
+ if (vendor_ids.count(vendor_opts->getVendorId()) > 0) {
+ continue;
+ }
+ // Got it: add it.
+ answer->addOption(desc.option_);
+ }
+ }
+ }
}
void