import udevmand

Signed-off-by: John Crispin <[email protected]>
This commit is contained in:
John Crispin
2020-05-29 12:37:40 +02:00
commit d94c726a58
15 changed files with 2641 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#include "udevmand.h"
void
ethers_init(void)
{
char buf[512], *p;
int ret;
FILE *f;
f = fopen("/etc/ethers", "r");
if (!f)
return;
while (fgets(buf, sizeof(buf), f)) {
uint8_t addr[ETH_ALEN];
struct mac *mac;
p = strtok(buf, " \t\n");
ret = sscanf(p, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
&addr[0], &addr[1], &addr[2], &addr[3], &addr[4], &addr[5]);
if (ret != 6)
continue;
p = strtok(NULL, " \t\n");
if (!p)
continue;
mac = mac_find(addr);
mac->ethers = strdup(p);
ULOG_INFO("new ethers " MAC_FMT" %s\n", MAC_VAR(addr), p);
}
fclose(f);
}