diff options
author | shemminger <shemminger> | 2004-05-11 22:38:41 +0000 |
---|---|---|
committer | shemminger <shemminger> | 2004-05-11 22:38:41 +0000 |
commit | 113e87de0647d42b5c941ac567a022cb59214510 (patch) | |
tree | 4c69c434684eb8f8f9d02a23385bfd953ce5dcdf | |
parent | cf09a9b8f5b1d234ecdd1bfb768c91d959fb7637 (diff) | |
download | bridge-utils-113e87de0647d42b5c941ac567a022cb59214510.tar.gz |
Cleanup old directory
-rw-r--r-- | misc/Makefile | 10 | ||||
-rw-r--r-- | misc/README | 10 | ||||
-rw-r--r-- | misc/bidi.c | 97 |
3 files changed, 0 insertions, 117 deletions
diff --git a/misc/Makefile b/misc/Makefile deleted file mode 100644 index 1bcebec..0000000 --- a/misc/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -CC=gcc -CFLAGS=-Wall -g - -all: bidi - -clean: - rm -f bidi - -bidi: bidi.c - $(CC) $(CFLAGS) -o $@ $< diff --git a/misc/README b/misc/README deleted file mode 100644 index 32c93bf..0000000 --- a/misc/README +++ /dev/null @@ -1,10 +0,0 @@ -Files in this directory: - -bidi.c A quick-and-dirty hack that allows you to 'connect' - multiple file descriptors together (everything - received on one fd will be sent out to all the other - fds). Works great for tying ethertaps together (for - testing stp protocol interaction et al.). - - The command-line arguments are the names of the - ethertaps to be connected together. diff --git a/misc/bidi.c b/misc/bidi.c deleted file mode 100644 index b143f2f..0000000 --- a/misc/bidi.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <fcntl.h> -#include <sys/poll.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -char *names[1024]; -int numfds; -struct pollfd pfd[1024]; - -void rcvd_packet(int index, unsigned char *buf, int len) -{ - int i; - int dmp; - - printf("%s: %i\n", names[index], len); - dmp = (len + 15) >> 4; - if (dmp > 8) - dmp = 8; - - for (i=0;i<dmp;i++) { - int j; - - for (j=0;j<16;j++) - printf("%.2x ", buf[(i<<4)|j]); - - printf("\n"); - } - - printf("\n"); -} - -void loop() -{ - while (1) { - int i; - - if (poll(pfd, numfds, -1) < 0) { - perror("poll"); - break; - } - - for (i=0;i<numfds;i++) { - unsigned char buf[2048]; - int j; - int len; - - if (!(pfd[i].revents & POLLIN)) - continue; - - if ((len = read(pfd[i].fd, buf, 2048)) < 0) - continue; - - rcvd_packet(i, buf, len); - for (j=0;j<numfds;j++) - if (i != j) - write(pfd[j].fd, buf, len); - } - } -} - -void openfds(int argc, char *argv[]) -{ - int i; - - numfds = 0; - for (i=1;i<argc;i++) { - int fd; - - if ((fd = open(argv[i], O_RDWR)) < 0) { - perror("open"); - continue; - } - - names[numfds] = argv[i]; - pfd[numfds].fd = fd; - pfd[numfds].events = POLLIN; - numfds++; - } -} - -int main(int argc, char *argv[]) -{ - openfds(argc, argv); - loop(); - - return 0; -} |