On 29/05/2019 22:32, Dave M wrote: > My problem is with the hook. I want to dynamically assign the boot-file > and server based on MAC address and model information (option 43, > suboption 9) and potentially software version (option 43, suboption 6). > > I will therefore need to extract these in pkt4_receive and then replace > the boot-file and server according to my logic in pkt4_send. > > I just don't know how to retrieve and parse the suboptions in option 43. > Would anybody have sample code showing how I can extract these? Questions about hooks development are generally better addressed at kea-dev.
You may want to take a look at src/bin/dhcp4/tests/vendor_opts_unittest.cc and possibly also at src/lib/dhcp/tests/option_vendor_unittest.cc Overall, you can do something similar to this: // check if there's option 43 in the packet. Option4Ptr opt43 = pkt->getOption(DHO_VENDOR_ENCAPSULATED_OPTIONS); if (!opt43) { return; } // Get suboption 6 from the option 43. Option4Ptr subopt6 = opt43->getOption(6); // If you have option definitions, you may want to try casting to // specific type. That way you'll be able to use type specific, such // as getValue() returning a string for OptionString. boost::shared_ptr<OptionVendor> str_subopt6 = boost::dynamic_pointer_cast<OptionString>(subopt6); if (str_subopt6) { cout << "opt 43,subopt 6 value is " << str_subopt6->getValue() << endl; } You may want to take a look at src/lib/dhcp/option_*.h files. Hope that helps, Tomek _______________________________________________ Kea-users mailing list Kea-users@lists.isc.org https://lists.isc.org/mailman/listinfo/kea-users