aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbuytenh <buytenh>2001-11-17 17:40:33 +0000
committerbuytenh <buytenh>2001-11-17 17:40:33 +0000
commit09931257ce527e6e631471645bdeec2d5e0bd7bd (patch)
tree2d6dbe571085a81c0898575c387f020d76b14f51
parent005eaefe92c3d5d23c8a8246a2a42e16e84cbb83 (diff)
downloadbridge-utils-09931257ce527e6e631471645bdeec2d5e0bd7bd.tar.gz
Removed 'tap'; people really should be using vtund for this.
-rw-r--r--misc/Makefile6
-rw-r--r--misc/README15
-rw-r--r--misc/tap.c148
3 files changed, 1 insertions, 168 deletions
diff --git a/misc/Makefile b/misc/Makefile
index 5216d45..e05bfe3 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -1,16 +1,12 @@
CC=gcc
CFLAGS=-Wall -g
-all: bidi tap
+all: bidi
clean:
rcsclean *
rm -f *~
rm -f bidi
- rm -f tap
bidi: bidi.c
$(CC) $(CFLAGS) -o $@ $<
-
-tap: tap.c
- $(CC) $(CFLAGS) -o $@ $<
diff --git a/misc/README b/misc/README
index 272300e..32c93bf 100644
--- a/misc/README
+++ b/misc/README
@@ -8,18 +8,3 @@ bidi.c A quick-and-dirty hack that allows you to 'connect'
The command-line arguments are the names of the
ethertaps to be connected together.
-
-
-tap.c Another quick-and-dirty hack which will let you
- connect different machine's ethertaps together over
- the network. This program works over raw IP, protocol
- number 97. RFC 1700 lists IP proto 97 as ethernet
- encapsulation; I have never seen the standard for
- this, I'm just guessing at the encapsulation being
- performed. So this program is potentially in violation
- of a standard; USE ONLY FOR TESTING!
-
- The first command-line argument is the name of the
- ethertap to use, the following command-line arguments
- are the hostnames of the machines to forward frames
- to.
diff --git a/misc/tap.c b/misc/tap.c
deleted file mode 100644
index 8ed2601..0000000
--- a/misc/tap.c
+++ /dev/null
@@ -1,148 +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 <netdb.h>
-#include <string.h>
-#include <netinet/in.h>
-#include <sys/poll.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#define MAXREMOTE 128
-
-struct sockaddr_in6 localaddr;
-int numremote;
-struct sockaddr_in6 remoteaddr[MAXREMOTE];
-int sock;
-int tap;
-char *tapdevice;
-
-
-
-int getaddr(const char *hostname, struct sockaddr_in6 *in)
-{
- struct hostent *he;
-
- in->sin6_port = 0;
-
- if ((he = gethostbyname2(hostname, AF_INET6)) != NULL) {
- in->sin6_family = he->h_addrtype;
- memcpy(in->sin6_addr.s6_addr, he->h_addr_list[0], he->h_length);
- return 0;
- }
-
- if ((he = gethostbyname2(hostname, AF_INET)) != NULL) {
- in->sin6_family = AF_INET6;
- memset(in->sin6_addr.s6_addr, 0, 10);
- in->sin6_addr.s6_addr[10] = 0;
- in->sin6_addr.s6_addr[11] = 0;
- memcpy(in->sin6_addr.s6_addr + 12, he->h_addr_list[0], he->h_length);
- return 0;
- }
-
- return 1;
-}
-
-void handle()
-{
- struct pollfd pfd[2];
-
- pfd[0].fd = tap;
- pfd[0].events = POLLIN;
- pfd[1].fd = sock;
- pfd[1].events = POLLIN;
-
- while (1) {
- unsigned char buf[2048];
- int len;
-
- if (poll(pfd, 2, -1) <= 0) {
- perror("poll");
- break;
- }
-
- if (pfd[0].revents & POLLIN) {
- int i;
-
- if ((len = read(pfd[0].fd, buf, 2048)) < 0) {
- perror("read");
- break;
- }
- for (i=0;i<numremote;i++)
- if (sendto(pfd[1].fd, buf+2, len-2, 0,
- &remoteaddr[i],
- sizeof(remoteaddr[i])) < 0) {
- perror("sendto");
- break;
- }
- }
-
- if (pfd[1].revents & POLLIN) {
- if ((len = read(pfd[1].fd, buf+2, 2046)) < 0) {
- perror("read");
- break;
- }
- if (write(pfd[0].fd, buf, len+2) < 0) {
- perror("write");
- break;
- }
- }
- }
-
- shutdown(sock, 2);
-}
-
-int main(int argc, char *argv[])
-{
- int i;
-
- if (argc < 4) {
- fprintf(stderr, "syntax: %s <tapdevice> <localaddr or ::> <remotename>\n", argv[0]);
- return 1;
- }
-
- tapdevice = argv[1];
-
- if (getaddr(argv[2], &localaddr)) {
- fprintf (stderr, "Can't resolve local hostname/address %s\n",
- argv[2]);
- return 1;
- }
-
- numremote = argc - 3;
- for (i=3;i<argc;i++)
- if (getaddr(argv[i], &remoteaddr[i-3])) {
- fprintf(stderr,
- "can't resolve hostname %s\n",
- argv[i]);
- return 1;
- }
-
- if ((tap = open(tapdevice, O_RDWR)) < 0) {
- perror("open");
- return 1;
- }
-
- if ((sock = socket(AF_INET6, SOCK_RAW, 97)) < 0) {
- perror("socket");
- return 1;
- }
-
- if (bind(sock, &localaddr, sizeof(localaddr)) < 0) {
- perror("bind");
- return 1;
- }
-
- handle();
-
- return 0;
-}