[Kea-users] Changing the order of DHCP Options in DHCP Offer Packet

Steve Teusch steve.teusch at rtr.guru
Thu Jul 20 08:25:24 UTC 2017


Gokul,

I ran into the same problem 2 weeks ago.

I did a modification to the source code but I am told by Francis that it can be implemented in the hooks library, which I plan on doing.  Anyways, my mod was this if you need it right away:

//replacing method in libdhcp++.cc to move options 53,54,51 to the top
void
LibDHCP::packOptions4(isc::util::OutputBuffer& buf,
                     const OptionCollection& options) {
    OptionPtr agent;
    OptionPtr end;

                //BEGINNING BLOCK I ADDED
                //DHO_DHCP_MESSAGE_TYPE = 53
                //DHO_DHCP_SERVER_IDENTIFIER  =54
                //DHO_DHCP_LEASE_TIME =51
                OptionPtr type;
                OptionPtr id;
                OptionPtr leaset;
    for (OptionCollection::const_iterator it = options.begin();
         it != options.end(); ++it) {

        // type, id, leaset options must be last.
        switch (it->first) {
                                                case DHO_DHCP_MESSAGE_TYPE:
                                                                type = it->second;
                                                                break;
                                                case DHO_DHCP_SERVER_IDENTIFIER:
                                                                id = it->second;
                                                                break;
                                                case DHO_DHCP_LEASE_TIME:
                                                                leaset = it->second;
                                                                break;
        }
    }

                if (type){
                                type->pack(buf);
                }
                if (id){
                                id->pack(buf);
                }
                if (leaset){
                                leaset->pack(buf);
                }
                //ENDING BLOCK I ADDED
    for (OptionCollection::const_iterator it = options.begin();
         it != options.end(); ++it) {

        // RAI and END options must be last.
        switch (it->first) {
            case DHO_DHCP_AGENT_OPTIONS:
                agent = it->second;
                break;
            case DHO_END:
                end = it->second;
                break;
                                                case DHO_DHCP_MESSAGE_TYPE:  //ALSO ADDED
                                                                break;
                                                case DHO_DHCP_SERVER_IDENTIFIER:  //ALSO ADDED
                                                                break;
                                                case DHO_DHCP_LEASE_TIME:  //ALSO ADDED
                                                                break;
            default:
                it->second->pack(buf);
                break;
        }
    }

    // Add the RAI option if it exists.
    if (agent) {
       agent->pack(buf);
    }

    // And at the end the END option.
    if (end)  {
       end->pack(buf);
    }
}


From: Kea-users [mailto:kea-users-bounces at lists.isc.org] On Behalf Of Gokulakrishnan Gopalakrishnan
Sent: Thursday, July 20, 2017 5:14 PM
To: kea-users at lists.isc.org
Subject: [Kea-users] Changing the order of DHCP Options in DHCP Offer Packet

I'm intercepting the DHCP Offer packet and reading the DHCP options present in it. The options are present in the ascending order of its number.
I want to change the order in which the options are packed in the DHCP Offer. Can someone help it?

Thanks,
Gokul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/kea-users/attachments/20170720/952ab6cd/attachment.htm>


More information about the Kea-users mailing list