- 论坛徽章:
- 0
|
busybox的udhcpd中有这些相关的信息,通过向该进程发送SIGUSR1信号,然后从相应的文件中读取数据。该文件可以在udhcpd中的配置文件中设定,以下是一个配置文件示例:- start 192.168.1.100
- end 192.168.1.200
- interface eth0
- option subnet 255.255.255.0
- option dns xxx.xxx.xxx.xxx
- option router 192.168.1.1
- option lease 86400
- lease_file /var/udhcpd.leases
复制代码 其中lease_file所指向的文件保存了所有连接到ap的pc或相关设备的mac及ip等相关信息。
参考示例:- FILE *fp = NULL;
- struct dhcpAddr {
- unsigned char hostname[16];
- unsigned char mac[16];
- unsigned long ip;
- unsigned long expires;
- } lease;
- system("killall -q -USR1 udhcpd");
- fp = fopen("/var/udhcpd.leases", "r");
- if (NULL == fp)
- return -1;
- while (fread(&lease, 1, sizeof(lease), fp) == sizeof(lease)) {
- .....
- }
复制代码 其它相关的自行实现吧! |
|