Implementing DHCP client

不问归期 提交于 2019-12-01 08:24:21

The caveat is, you don't have an IP address, you want to obtain one. - most OSs won't allow you to bind/send UDP messages on a NIC w/o an IP address. dhcp clients typically use raw sockets for that purpose/and should set the src address to 0.0.0.0)

Such a raw socket will get all the packets, and your application will not if there's a system dhcp client running

You could look at the source code for an existing DHCP client and learn how it works:

ftp://ftp.isc.org/isc/dhcp/

You may also want to post a relevant snippet of your source code so that people can see exactly how you are trying to do this.

I just forked dhclient as dhcprobe. It is a dhcp client for linux.

It's pretty straightforward to hack and might be a good starting point for your project.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!