#include "utils.h"
static int quit = 0;
+static unsigned char macaddr[6];
static void usage(FILE *out)
{
} else {
if(sizeof(buf) - ret < sizeof(pi)) {
/* Drop */
+ } else if((ret < 12) || !memcmp(macaddr, buf + 6, 6)) {
+ /* Drop looped back */
} else {
memmove(buf + sizeof(pi), buf, ret);
pi.flags = 0;
strncpy(rb.ifr_name, name, IFNAMSIZ);
if(ioctl(fd, TUNSETIFF, &rb))
return(-1);
+ if(ioctl(fd, SIOCGIFHWADDR, &rb))
+ return(-1);
+ memcpy(macaddr, rb.ifr_hwaddr.sa_data, 6);
return(fd);
}
dst.sin_family = AF_INET;
dst.sin_addr = group;
dst.sin_port = htons(port);
+ syslog(LOG_INFO, "bridge created with MAC %02x:%02x:%02x:%02x:%02x:%02x", macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]);
bridge(sock, tap, (struct sockaddr *)&dst, sizeof(dst));
syslog(LOG_INFO, "exiting");