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 |
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 |
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 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:, Can someone help me to understand this value? Thanks, Gokul ------------------------------------------------------------ _______________________________________________ Kea-users mailing list [hidden email] https://lists.isc.org/mailman/listinfo/kea-users |
For the other one (remote_id) use getOption(RAI_OPTION_AGENT_REMOTE_ID). From: Kea-users [mailto:[hidden email]]
On Behalf Of Itay Rozenberg 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 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:, Can someone help me to understand this value? Thanks, Gokul ------------------------------------------------------------ ------------------------------------------------------------ _______________________________________________ Kea-users mailing list [hidden email] https://lists.isc.org/mailman/listinfo/kea-users |
Thanks Christian, Itay. It helps! On Tue, Jul 4, 2017 at 8:21 PM, Itay Rozenberg <[hidden email]> wrote:
_______________________________________________ Kea-users mailing list [hidden email] https://lists.isc.org/mailman/listinfo/kea-users |
Free forum by Nabble | Edit this page |