I would like to write a program that from an interface with a MAC address, sends a DHCP request and gets back the IP address, the gateway, the mask and the broadcast address from the DHCP server.
I used this implementation of a DHCP client, but it only gives the IP address and the gateway addresses.
I read about DHCP message format and I didn't find a mask or broadcast fileds. However, when using dhcpclient command line, I can see using ifconfig that the interface has a mask and broadcast addresses, as below:
arm@arm-desktop:~/dhclient wlp2s0
arm@arm-desktop:~/ifconfig wlp2s0
wlp2s0 Link encap:Ethernet HWaddr 54:da:d0:15:4b:04
inet addr:153.179.154.55 Bcast:153.179.169.255 Mask:255.255.240.0
inet6 addr: fe80::2037:c031:5db1:445c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:113 errors:0 dropped:0 overruns:0 frame:0
TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:112130 (112.1 KB) TX bytes:9520 (9.5 KB)
Could somebody tell me how this information is acquired?