diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-03-10 14:49:21 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-03-10 14:49:49 +0100 |
commit | 4860a84c768f1b85ec3b45e020a1d550b448ccae (patch) | |
tree | 992459912ad4cbbe91fecd65a7f341b4ac96445f /econserv.c | |
parent | 3abd448fd6d9171515a4951cc6a629b0ff83ddd4 (diff) | |
download | econ-4860a84c768f1b85ec3b45e020a1d550b448ccae.tar.gz econ-4860a84c768f1b85ec3b45e020a1d550b448ccae.tar.bz2 econ-4860a84c768f1b85ec3b45e020a1d550b448ccae.zip |
util: Add sock_get_hwaddr
And use it in econserv, instead of the hardcoded lookup for tap0.
Diffstat (limited to 'econserv.c')
-rw-r--r-- | econserv.c | 17 |
1 files changed, 3 insertions, 14 deletions
@@ -14,12 +14,9 @@ #include <sys/types.h> #include <sys/socket.h> -#include <sys/ioctl.h> #include <sys/select.h> #include <sys/uio.h> #include <unistd.h> -#include <net/if.h> -#include <net/if_arp.h> #include <netinet/in.h> #include "econproto.h" @@ -100,18 +97,10 @@ struct ecs { static void get_hwaddr(struct ecs *ecs) { - struct ifreq ifreq; - char *m = &ifreq.ifr_hwaddr.sa_data[0]; + uint8_t *m; - memset(&ifreq, 0, sizeof ifreq); - - strcpy(ifreq.ifr_name, "tap0"); - ioctl(ecs->fd, SIOCGIFHWADDR, &ifreq); - assert(ifreq.ifr_hwaddr.sa_family == ARPHRD_ETHER); -#if 0 - printf("hwaddr: %02hhx-%02hhx-%02hhx-%02hhx-%02hhx-%02hhx\n", - m[0], m[1], m[2], m[3], m[4], m[5]); -#endif + m = sock_get_hwaddr(ecs->fd); + assert(m != NULL); memcpy(ecs->proj_uniq, m, 6); } |