[Kea-users] Parsing Option 82

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

[Kea-users] Parsing Option 82

Gokulakrishnan Gopalakrishnan
I'm trying to print and parse Option 82 but I couldn't understand the format in which it is received. My 'option->toText()' print this
type=082, len=024:,
options:
  type=001, len=014: 01:0c:45:74:68:65:72:6e:65:74:31:2f:32:39
  type=002, len=006: 04:62:73:56:13:bc

Can someone help me to understand this value?

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] Parsing Option 82

Christian Kratzer
Hi,

On Tue, 4 Jul 2017, Gokulakrishnan Gopalakrishnan wrote:
> I'm trying to print and parse Option 82 but I couldn't understand the
> format in which it is received. My 'option->toText()' print this
> type=082, len=024:,
> options:
>  type=001, len=014: 01:0c:45:74:68:65:72:6e:65:74:31:2f:32:39
>  type=002, len=006: 04:62:73:56:13:bc
>
> Can someone help me to understand this value?

Option82 has suboptions as defined in: https://tools.ietf.org/rfc/rfc3046.txt

Suboption 1 is circuit-id.

Suboption 2 is remote-id.

So you seem to have a circuit-id of: 01:0c:45:74:68:65:72:6e:65:74:31:2f:32:39 and a remote-id of: 04:62:73:56:13:bc.

Also they seem to be binary.

They could also be in ascii.

Depends on the relay agent inserting the options.

Greetings
Christian

--
Christian Kratzer                   CK Software GmbH
Email:   [hidden email]               Wildberger Weg 24/2
Phone:   +49 7032 893 997 - 0       D-71126 Gaeufelden
Fax:     +49 7032 893 997 - 9       HRB 245288, Amtsgericht Stuttgart
Mobile:  +49 171 1947 843           Geschaeftsfuehrer: Christian Kratzer
Web:     http://www.cksoft.de/
_______________________________________________
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] Parsing Option 82

Itay Rozenberg
In reply to this post by Gokulakrishnan Gopalakrishnan
 

Greetings

 

 

Type 001 – circuit_id - hex, you need to convert it to ascii. (try it on this web site: http://www.rapidtables.com/convert/number/hex-to-ascii.htm )

Type 002 – remote_id - Mac address

Each of them can be hex or mac address.

 

Try this:

std::string hexToAscii(std::string c) {

        int length = c.length();

        std::string newString;

        for (int i = 0; i < length; i+=2) {

                std::string byte = c.substr(i, 2);

                char chr = (char)(int)strtol(byte.c_str(), NULL, 16);

                newString.push_back(chr);

        }

        return newString;

}

 

 

 

OptionPtr rai = query4_ptr->getOption(DHO_DHCP_AGENT_OPTIONS);

        if (rai) {

                OptionPtr circuit_id_opt = rai->getOption(RAI_OPTION_AGENT_CIRCUIT_ID);

                if (circuit_id_opt) {

                        string cid = hexToAscii(circuit_id_opt->toHexString().substr(2));

                }

        }

 

For the other one (remote_id) use getOption(RAI_OPTION_AGENT_CIRCUIT_ID).

 

itay

 

From: Kea-users [[hidden email]] On Behalf Of Gokulakrishnan Gopalakrishnan
Sent: Tuesday, July 4, 2017 2:20 PM
To: [hidden email]
Subject: [Kea-users] Parsing Option 82

 

I'm trying to print and parse Option 82 but I couldn't understand the format in which it is received. My 'option->toText()' print this

type=082, len=024:,
options:
  type=001, len=014: 01:0c:45:74:68:65:72:6e:65:74:31:2f:32:39
  type=002, len=006: 04:62:73:56:13:bc

 

Can someone help me to understand this value?

 

Thanks,

Gokul

------------------------------------------------------------
This message contains information that may be confidential or privileged.
If you are not the intended recipient, you may not use, copy or disclose
to anyone any of the information in this message. If you have received
this message and are not the intended recipient, kindly notify the sender
and delete this message from your computer.


_______________________________________________
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] Parsing Option 82

Itay Rozenberg

For the other one (remote_id) use getOption(RAI_OPTION_AGENT_REMOTE_ID).

 

 

From: Kea-users [mailto:[hidden email]] On Behalf Of Itay Rozenberg
Sent: Tuesday, July 4, 2017 5:23 PM
To: 'Gokulakrishnan Gopalakrishnan'
Cc: '[hidden email]'
Subject: Re: [Kea-users] Parsing Option 82

 

 

Greetings

 

 

Type 001 – circuit_id - hex, you need to convert it to ascii. (try it on this web site: http://www.rapidtables.com/convert/number/hex-to-ascii.htm )

Type 002 – remote_id - Mac address

Each of them can be hex or mac address.

 

Try this:

std::string hexToAscii(std::string c) {

        int length = c.length();

        std::string newString;

        for (int i = 0; i < length; i+=2) {

                std::string byte = c.substr(i, 2);

                char chr = (char)(int)strtol(byte.c_str(), NULL, 16);

                newString.push_back(chr);

        }

        return newString;

}

 

 

 

OptionPtr rai = query4_ptr->getOption(DHO_DHCP_AGENT_OPTIONS);

        if (rai) {

                OptionPtr circuit_id_opt = rai->getOption(RAI_OPTION_AGENT_CIRCUIT_ID);

                if (circuit_id_opt) {

                        string cid = hexToAscii(circuit_id_opt->toHexString().substr(2));

                }

        }

 

For the other one (remote_id) use getOption(RAI_OPTION_AGENT_CIRCUIT_ID).

 

itay

 

From: Kea-users [[hidden email]] On Behalf Of Gokulakrishnan Gopalakrishnan
Sent: Tuesday, July 4, 2017 2:20 PM
To: [hidden email]
Subject: [Kea-users] Parsing Option 82

 

I'm trying to print and parse Option 82 but I couldn't understand the format in which it is received. My 'option->toText()' print this

type=082, len=024:,
options:
  type=001, len=014: 01:0c:45:74:68:65:72:6e:65:74:31:2f:32:39
  type=002, len=006: 04:62:73:56:13:bc

 

Can someone help me to understand this value?

 

Thanks,

Gokul

Banner
Powered by U‑BTech XTRABANNER

[hidden email]

------------------------------------------------------------
This message contains information that may be confidential or privileged.
If you are not the intended recipient, you may not use, copy or disclose
to anyone any of the information in this message. If you have received
this message and are not the intended recipient, kindly notify the sender
and delete this message from your computer.

------------------------------------------------------------
This message contains information that may be confidential or privileged.
If you are not the intended recipient, you may not use, copy or disclose
to anyone any of the information in this message. If you have received
this message and are not the intended recipient, kindly notify the sender
and delete this message from your computer.


_______________________________________________
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] Parsing Option 82

Gokulakrishnan Gopalakrishnan
Thanks Christian, Itay. It helps!

On Tue, Jul 4, 2017 at 8:21 PM, Itay Rozenberg <[hidden email]> wrote:

For the other one (remote_id) use getOption(RAI_OPTION_AGENT_REMOTE_ID).

 

 

From: Kea-users [mailto:[hidden email]] On Behalf Of Itay Rozenberg
Sent: Tuesday, July 4, 2017 5:23 PM
To: 'Gokulakrishnan Gopalakrishnan'
Cc: '[hidden email]'
Subject: Re: [Kea-users] Parsing Option 82

 

 

Greetings

 

 

Type 001 – circuit_id - hex, you need to convert it to ascii. (try it on this web site: http://www.rapidtables.com/convert/number/hex-to-ascii.htm )

Type 002 – remote_id - Mac address

Each of them can be hex or mac address.

 

Try this:

std::string hexToAscii(std::string c) {

        int length = c.length();

        std::string newString;

        for (int i = 0; i < length; i+=2) {

                std::string byte = c.substr(i, 2);

                char chr = (char)(int)strtol(byte.c_str(), NULL, 16);

                newString.push_back(chr);

        }

        return newString;

}

 

 

 

OptionPtr rai = query4_ptr->getOption(DHO_DHCP_AGENT_OPTIONS);

        if (rai) {

                OptionPtr circuit_id_opt = rai->getOption(RAI_OPTION_AGENT_CIRCUIT_ID);

                if (circuit_id_opt) {

                        string cid = hexToAscii(circuit_id_opt->toHexString().substr(2));

                }

        }

 

For the other one (remote_id) use getOption(RAI_OPTION_AGENT_CIRCUIT_ID).

 

itay

 

From: Kea-users [[hidden email]] On Behalf Of Gokulakrishnan Gopalakrishnan
Sent: Tuesday, July 4, 2017 2:20 PM
To: [hidden email]
Subject: [Kea-users] Parsing Option 82

 

I'm trying to print and parse Option 82 but I couldn't understand the format in which it is received. My 'option->toText()' print this

type=082, len=024:,
options:
  type=001, len=014: 01:0c:45:74:68:65:72:6e:65:74:31:2f:32:39
  type=002, len=006: 04:62:73:56:13:bc

 

Can someone help me to understand this value?

 

Thanks,

Gokul

Banner
Powered by U‑BTech XTRABANNER

[hidden email]

------------------------------------------------------------
This message contains information that may be confidential or privileged.
If you are not the intended recipient, you may not use, copy or disclose
to anyone any of the information in this message. If you have received
this message and are not the intended recipient, kindly notify the sender
and delete this message from your computer.

------------------------------------------------------------
This message contains information that may be confidential or privileged.
If you are not the intended recipient, you may not use, copy or disclose
to anyone any of the information in this message. If you have received
this message and are not the intended recipient, kindly notify the sender
and delete this message from your computer.



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