Dolda2000 GitWeb
/
mctap.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8cac990
)
Drop looped packets.
master
author
Fredrik Tolf
<fredrik@dolda2000.com>
Sat, 9 Aug 2008 20:28:46 +0000
(22:28 +0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Sat, 9 Aug 2008 20:35:53 +0000
(22:35 +0200)
src/mctap.c
patch
|
blob
|
blame
|
history
diff --git
a/src/mctap.c
b/src/mctap.c
index
9d183f9
..
24efc12
100644
(file)
--- a/
src/mctap.c
+++ b/
src/mctap.c
@@
-17,6
+17,7
@@
#include "utils.h"
static int quit = 0;
#include "utils.h"
static int quit = 0;
+static unsigned char macaddr[6];
static void usage(FILE *out)
{
static void usage(FILE *out)
{
@@
-145,6
+146,8
@@
static void bridge(int sock, int tap, struct sockaddr *dst, socklen_t dstlen)
} else {
if(sizeof(buf) - ret < sizeof(pi)) {
/* Drop */
} 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;
} else {
memmove(buf + sizeof(pi), buf, ret);
pi.flags = 0;
@@
-189,6
+192,9
@@
static int maketap(char *name)
strncpy(rb.ifr_name, name, IFNAMSIZ);
if(ioctl(fd, TUNSETIFF, &rb))
return(-1);
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);
}
return(fd);
}
@@
-308,6
+314,7
@@
int main(int argc, char **argv)
dst.sin_family = AF_INET;
dst.sin_addr = group;
dst.sin_port = htons(port);
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");
bridge(sock, tap, (struct sockaddr *)&dst, sizeof(dst));
syslog(LOG_INFO, "exiting");