5

I would like to ask if there is a way to read DHCP option in Qt or c++ (Qt would be better) on linux. I have my own cups backend and would like to read option 9 - LPR Servers (all of the listed IP addresses) and use it as device uri.

So I want to know how to get specific (or all) option(s) informations from the DHCP lease.

I've looked to Qt's documentation but wasn't able to find anything useful and couldn't find any c++ libraries for linux.

user3840048
  • 141
  • 1
  • 9

2 Answers2

4

I had exactly the same problem. I have found a library called Libcrafter which has a lot of features including DHCP support. There is a good example of DHCP usage in their examples. It is example #8.

Dávid Kaya
  • 924
  • 4
  • 17
0

This requirement is quite specific. I don't know there's such individual library for mere DHCP options.

So my suggestion is that, down one DHCP implementation(http://en.wikipedia.org/wiki/Comparison_of_DHCP_server_software), study how it handles the options.

Take dnsmasq_2.72 as an example, in file src/dhcp-common.c, there's function lookup_dhcp_opt().

Qiu Yangfan
  • 871
  • 11
  • 25