3 void start_arpbind(void) {
6 const char *ipaddr
, *macaddr
;
7 const char *name
, *bind
;
9 nvp
= nv
= strdup(nvram_safe_get("dhcpd_static"));
12 // clear arp table first
15 while ((b
= strsep(&nvp
, ">")) != NULL
) {
17 macaddr<ip.ad.dr.ess<hostname<arpbind>anotherhwaddr<other.ip.addr.ess<othername<arpbind
20 if ((vstrsep(b
, "<", &macaddr
, &ipaddr
, &name
, &bind
)) != 4)
22 if (strchr(macaddr
,',') != NULL
)
24 if (strcmp(bind
,"1") == 0)
25 eval ("arp", "-s", (char *)ipaddr
, (char *)macaddr
);
30 void stop_arpbind(void) {
36 if ((f
= fopen("/proc/net/arp", "r")) != NULL
) {
37 // fgets(buf, sizeof(buf), f); // header
38 while (fgets(buf
, sizeof(buf
), f
)) {
39 if (sscanf(buf
, "%s %*s %*s %*s %*s %*s", ipaddr
) != 1) continue;
40 eval ("arp", "-d", (char *)ipaddr
);