mirror of
https://github.com/outbackdingo/udevmand.git
synced 2026-08-25 14:53:42 +00:00
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user