From 1d3d78add473e1a406deea371a474ab1a2bc8059 Mon Sep 17 00:00:00 2001 From: kevlo Date: Fri, 21 Jan 2000 15:39:59 +0000 Subject: [PATCH] This is a 4.4BSD program that implements, in userland, third-party proxy ARP. In a nutshell, this lets you proxy-ARP an arbitrary IP address to an arbitrary MAC address, from any machine on the network. This is useful if your router doesn't do proxy ARP, or does it only in an all-or-none fashion. This code will not work outside of 4.4BSD (it relies on BPF). Furthermore, it won't run on most 4.4BSD operating systems, because a problem with the standard BPF implementation (try spoofing your source ethernet frame address on NetBSD). See: http://www.enteract.com/~tqbf --- net/arpcatch/Makefile | 15 ++++ net/arpcatch/files/md5 | 3 + net/arpcatch/patches/patch-aa | 146 ++++++++++++++++++++++++++++++++++ net/arpcatch/pkg/COMMENT | 1 + net/arpcatch/pkg/DESCR | 36 +++++++++ net/arpcatch/pkg/PLIST | 1 + 6 files changed, 202 insertions(+) create mode 100644 net/arpcatch/Makefile create mode 100644 net/arpcatch/files/md5 create mode 100644 net/arpcatch/patches/patch-aa create mode 100644 net/arpcatch/pkg/COMMENT create mode 100644 net/arpcatch/pkg/DESCR create mode 100644 net/arpcatch/pkg/PLIST diff --git a/net/arpcatch/Makefile b/net/arpcatch/Makefile new file mode 100644 index 00000000000..c24826dc5c6 --- /dev/null +++ b/net/arpcatch/Makefile @@ -0,0 +1,15 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2000/01/21 15:39:59 kevlo Exp $ + +DISTNAME= arpcatch +PKGNAME= arpcatch +CATEGORIES= net +MASTER_SITES= http://www.enteract.com/~tqbf/ + +MAINTAINER= ports@openbsd.org + +WRKSRC= ${WRKDIR}/${PKGNAME} + +ALL_TARGET= +INSTALL_TARGET= install + +.include diff --git a/net/arpcatch/files/md5 b/net/arpcatch/files/md5 new file mode 100644 index 00000000000..cf2201bc97a --- /dev/null +++ b/net/arpcatch/files/md5 @@ -0,0 +1,3 @@ +MD5 (arpcatch.tar.gz) = 84efc3846cbac3f9d26fac3df58ab779 +RMD160 (arpcatch.tar.gz) = cbbdb9677bd88bea8cd65bc0d62bfa307fd47a90 +SHA1 (arpcatch.tar.gz) = 612fc70b2cd46a16852d0b7a8b128a31cca9d569 diff --git a/net/arpcatch/patches/patch-aa b/net/arpcatch/patches/patch-aa new file mode 100644 index 00000000000..fc7a5e79737 --- /dev/null +++ b/net/arpcatch/patches/patch-aa @@ -0,0 +1,146 @@ +diff -u Makefile.orig Makefile +--- Makefile.orig Tue Aug 19 02:54:00 1997 ++++ Makefile Fri Jan 21 06:02:32 2000 +@@ -1,4 +1,5 @@ +-CFLAGS= -g ++CC=gcc ++CFLAGS= -g -Wall + LDFLAGS= + LIBS= -lpcap + TARGET= aproxyd +diff -u arpcatch.c.orig arpcatch.c +--- arpcatch.c.orig Fri Aug 22 06:57:01 1997 ++++ arpcatch.c Fri Jan 21 07:12:04 2000 +@@ -37,6 +37,7 @@ + } + } + ++ printf("Starting on %s interface\n",device); + if(!(at = read_config(configfile))) { + perror("config file read"); + exit(errno); +@@ -50,6 +51,7 @@ + read_loop(fd, at); + + perror("read"); ++return 1; + } + + /* needs cleaning up */ +@@ -63,7 +65,6 @@ + struct ether_addr *ea; + struct ether_arp *ah; + +- struct in_addr foo; + + for(;;) { + struct in_addr ia; +@@ -129,7 +130,7 @@ + + fd = bpf_open(device); + if(fd < 0) { +- perror("bpf open"); ++ fprintf(stderr,"Error initializing bpf filter\nExiting..\n"); + exit(errno); + } + +diff -u arpcatch.h.orig arpcatch.h +--- arpcatch.h.orig Tue Aug 19 03:51:02 1997 ++++ arpcatch.h Fri Jan 21 07:08:36 2000 +@@ -5,6 +5,7 @@ + + #include + #include ++#include + #include + #include + #include +@@ -12,6 +13,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -25,8 +27,6 @@ + + #include + #include +-#include +-#include + #include + + #include "list.h" +@@ -76,5 +76,12 @@ + int bpf_promisc(int, int); + + table_t *read_config(char *); ++void chop(char *); ++void *NEW(const int); ++u_long resolve(char *); ++ ++int arp_send(int, u_long *, u_long *, struct ether_addr *, struct ether_addr *); ++ ++ + + #endif +diff -u bpf.c.orig bpf.c +--- bpf.c.orig Tue Aug 19 03:38:20 1997 ++++ bpf.c Fri Jan 21 06:53:13 2000 +@@ -47,21 +47,26 @@ + + do { + snprintf(file, PATH_MAX, "/dev/bpf%d", i++); +- if((fd = open(file, O_RDWR)) < 0) +- continue; +- } while(errno == EBUSY && fd < 0); ++ fd = open(file, O_RDWR); ++ } while(fd < 0 && errno == EBUSY); + +- if(fd < 0) ++ if(fd < 0) { ++ perror("bpf open"); + return(-1); ++ } + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, device, 15); + +- if(bpf_setbuf(fd, DEFAULT_BUFLEN) < 0) ++ if(bpf_setbuf(fd, DEFAULT_BUFLEN) < 0) { ++ perror("bpf setbuf"); + return(-2); ++ } + +- if(ioctl(fd, BIOCSETIF, (char *) &ifr) < 0) ++ if(ioctl(fd, BIOCSETIF, (char *) &ifr) < 0) { ++ perror("bpf ioctl"); + return(-3); ++ } + + return(fd); + } +diff -u config.c.orig arpcatch/config.c +--- config.c.orig Mon Nov 24 16:18:54 1997 ++++ config.c Fri Jan 21 06:07:06 2000 +@@ -1,7 +1,6 @@ + #include "arpcatch.h" + #include + #include +-#include + + static list_t *add_host(char *buffer, list_t *hosts); + static int add_proxy(char *buffer, table_t *at); +diff -u libtqbf.c.orig arpcatch/libtqbf.c +--- libtqbf.c.orig Tue Aug 19 02:02:13 1997 ++++ libtqbf.c Fri Jan 21 06:55:56 2000 +@@ -349,8 +349,6 @@ + int jday (int month, int day, int year) { + int c, ya, jd; + +- int brit_jd = 2361222; +- + if (month > 2) + month -= 3; + else diff --git a/net/arpcatch/pkg/COMMENT b/net/arpcatch/pkg/COMMENT new file mode 100644 index 00000000000..8f8e7a11ef3 --- /dev/null +++ b/net/arpcatch/pkg/COMMENT @@ -0,0 +1 @@ +Userland arp-proxy daemon diff --git a/net/arpcatch/pkg/DESCR b/net/arpcatch/pkg/DESCR new file mode 100644 index 00000000000..2dca0f92c86 --- /dev/null +++ b/net/arpcatch/pkg/DESCR @@ -0,0 +1,36 @@ + +ARP-catch +1997 Thomas H. Ptacek +------------------------------------------------------------------------ + +This is a 4.4BSD program that implements, in userland, third-party +proxy ARP. In a nutshell, this lets you proxy-ARP an arbitrary IP +address to an arbitrary MAC address, from any machine on the network. +This is useful if your router doesn't do proxy ARP, or does it only +in an all-or-none fashion. + +This code will not work outside of 4.4BSD (it relies on BPF). Furthermore, +it won't run on most 4.4BSD operating systems, because a problem with the +standard BPF implementation (try spoofing your source ethernet frame +address on NetBSD). I've made available an LKM that "fixes" the problem on +FreeBSD 3.0; you can find it at http://www.enteract.com/~tqbf. + +There's not much to document here. The program is a daemon, and reads +a config file. The config file consists of "router" and "proxy" lines; a +"router" line gives a symbolic name for a MAC address, ie: + +router gateway de:ad:be:ef:ca:fe + +... and a "proxy" line maps an IP address to a router name or a MAC +address, ie: + +proxy 10.100.200.1 gateway +proxy 10.100.200.2 ab:ad:ca:fe:00:11 + +This is fairly esoteric stuff; read the code if you need to know more. + +If you have problems, questions, comments, bitches, etc, feel free to mail +me at + + + diff --git a/net/arpcatch/pkg/PLIST b/net/arpcatch/pkg/PLIST new file mode 100644 index 00000000000..4fe9ac295c1 --- /dev/null +++ b/net/arpcatch/pkg/PLIST @@ -0,0 +1 @@ +sbin/aproxyd