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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Gokulakrishnan Gopalakrishnan
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

_______________________________________________
Kea-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/kea-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Steve Teusch

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:[hidden email]] On Behalf Of Gokulakrishnan Gopalakrishnan
Sent: Thursday, July 20, 2017 5:14 PM
To: [hidden email]
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


_______________________________________________
Kea-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/kea-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Francis Dupont
In reply to this post by Gokulakrishnan Gopalakrishnan
Gokulakrishnan Gopalakrishnan writes:
> 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?

=> first there is no good reason to change the order (only the RAI and of
course the END options have a specific position).
Second to do this you need a hook (BTW you can copy the Kea code packing
messages as it has already what you can need). Perhaps there is a hook
doing this available somewhere (you are not the first asking this).

Regards

Francis Dupont <[hidden email]>
_______________________________________________
Kea-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/kea-users
Loading...