[Kea-users] Extracting vendor-specific suboptions in hooks

Michael Gugino gugino.michael at yahoo.com
Fri Jul 12 18:25:08 UTC 2019


 My approach was to modify the bootp information in pkt4_send to replace whatever was put there: https://github.com/michaelgugino/kea-pxe-replace-mod/blob/master/src/pkt4_send.cc(Note: I'm not reading option 43 data, but if I was, I might do the same thing.  If that data isn't accessible in pkt4_send, I'd use a temp file based on mac to store this data and do the manipulation to the bootp bits in pkt4_send)



    On Friday, July 12, 2019, 10:07:11 AM EDT, Ola Thoresen <ola at nytt.no> wrote:  
 
 Hi,

I have a, rather old now, hook that you might want to look at.

https://github.com/Olen/kea_hooks

Please fork it and take over the project if you want to. As I don't 
maintain any kea installations any longer, I have not updated it since a 
really early version of Kea.



On 12.07.2019 15:50, Tomek Mrugalski wrote:
> 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 at lists.isc.org
> https://lists.isc.org/mailman/listinfo/kea-users
_______________________________________________
Kea-users mailing list
Kea-users at lists.isc.org
https://lists.isc.org/mailman/listinfo/kea-users
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/kea-users/attachments/20190712/9461144b/attachment.html>


More information about the Kea-users mailing list