diff --git a/contrib/ipfilter/ipsend/larp.c b/contrib/ipfilter/ipsend/larp.c deleted file mode 100644 index 5b79f7376a12..000000000000 --- a/contrib/ipfilter/ipsend/larp.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $FreeBSD$ */ - -/* - * larp.c (C) 1995-1998 Darren Reed - * - * See the IPFILTER.LICENCE file for details on licencing. - * - */ -#if !defined(lint) -static const char sccsid[] = "@(#)larp.c 1.1 8/19/95 (C)1995 Darren Reed"; -static const char rcsid[] = "@(#)$Id$"; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ip_compat.h" -#include "iplang/iplang.h" - -/* - * lookup host and return - * its IP address in address - * (4 bytes) - */ -int resolve(host, address) - char *host, *address; -{ - struct hostent *hp; - u_long add; - - add = inet_addr(host); - if (add == -1) - { - if (!(hp = gethostbyname(host))) - { - fprintf(stderr, "unknown host: %s\n", host); - return -1; - } - bcopy((char *)hp->h_addr, (char *)address, 4); - return 0; - } - bcopy((char*)&add, address, 4); - return 0; -} - -/* - * ARP for the MAC address corresponding - * to the IP address. This taken from - * some BSD program, I cant remember which. - */ -int arp(ip, ether) - char *ip; - char *ether; -{ - static int s = -1; - struct arpreq ar; - struct sockaddr_in *sin; - char *inet_ntoa(); - -#ifdef IP_SEND - if (arp_getipv4(ip, ether) == 0) - return 0; -#endif - bzero((char *)&ar, sizeof(ar)); - sin = (struct sockaddr_in *)&ar.arp_pa; - sin->sin_family = AF_INET; - bcopy(ip, (char *)&sin->sin_addr.s_addr, 4); - - if (s == -1) - if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) - { - perror("arp: socket"); - return -1; - } - - if (ioctl(s, SIOCGARP, (caddr_t)&ar) == -1) - { - fprintf(stderr, "(%s):", inet_ntoa(sin->sin_addr)); - if (errno != ENXIO) - perror("SIOCGARP"); - return -1; - } - - bcopy(ar.arp_ha.sa_data, ether, 6); - return 0; -} diff --git a/contrib/ipfilter/ipsend/linux.h b/contrib/ipfilter/ipsend/linux.h deleted file mode 100644 index e738f3ba426a..000000000000 --- a/contrib/ipfilter/ipsend/linux.h +++ /dev/null @@ -1,19 +0,0 @@ -/* $FreeBSD$ */ - -/* - * Copyright (C) 2012 by Darren Reed. - * - * This code may be freely distributed as long as it retains this notice - * and is not changed in any way. The author accepts no responsibility - * for the use of this software. I hate legaleese, don't you ? - * - * @(#)linux.h 1.1 8/19/95 - */ - -#include -#ifdef MODULE -#include -#include -#endif /* MODULE */ - -#include "ip_compat.h" diff --git a/contrib/ipfilter/ipsend/lsock.c b/contrib/ipfilter/ipsend/lsock.c deleted file mode 100644 index 245b2924ca06..000000000000 --- a/contrib/ipfilter/ipsend/lsock.c +++ /dev/null @@ -1,259 +0,0 @@ -/* $FreeBSD$ */ - -/* - * lsock.c (C) 1995-1998 Darren Reed - * - * See the IPFILTER.LICENCE file for details on licencing. - * - */ -#if !defined(lint) -static const char sccsid[] = "@(#)lsock.c 1.2 1/11/96 (C)1995 Darren Reed"; -static const char rcsid[] = "@(#)$Id$"; -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define __KERNEL__ -#if LINUX >= 0200 -# undef UINT_MAX -# undef INT_MAX -# undef ULONG_MAX -# undef LONG_MAX -# include -#endif -#include -#if LINUX >= 0200 -#include "linux/netdevice.h" -#include "net/sock.h" -#endif -#undef __KERNEL__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if LINUX < 0200 -#include -#endif -#include "ipsend.h" - -int nproc; -struct task_struct *proc; - -#ifndef KMEM -# ifdef _PATH_KMEM -# define KMEM _PATH_KMEM -# endif -#endif -#ifndef KMEM -# define KMEM "/dev/kmem" -#endif -#ifndef KERNEL -# define KERNEL "/System.map" -#endif - -int kmemcpy(buf, pos, n) - char *buf; - void *pos; - int n; -{ - static int kfd = -1; - - if (kfd == -1) - kfd = open(KMEM, O_RDONLY); - - if (lseek(kfd, (off_t)pos, SEEK_SET) == -1) - { - perror("lseek"); - return -1; - } - if (read(kfd, buf, n) == -1) - { - perror("read"); - return -1; - } - return n; -} - -struct nlist names[3] = { - { "_task" }, - { "_nr_tasks" }, - { NULL } - }; - -struct task_struct *getproc() -{ - struct task_struct *p, **pp; - void *v; - pid_t pid = getpid(); - int siz, n; - - n = nlist(KERNEL, names); - if (n != 0) - { - fprintf(stderr, "nlist(%#x) == %d\n", names, n); - return NULL; - } - if (KMCPY(&nproc, names[1].n_value, sizeof(nproc)) == -1) - { - fprintf(stderr, "read nproc (%#x)\n", names[1].n_value); - return NULL; - } - siz = nproc * sizeof(struct task_struct *); - if (KMCPY(&v, names[0].n_value, sizeof(v)) == -1) - { - fprintf(stderr, "read(%#x,%#x,%d) proc\n", - names[0].n_value, &v, sizeof(v)); - return NULL; - } - pp = (struct task_struct **)malloc(siz); - if (KMCPY(pp, v, siz) == -1) - { - fprintf(stderr, "read(%#x,%#x,%d) proc\n", - v, pp, siz); - return NULL; - } - proc = (struct task_struct *)malloc(siz); - for (n = 0; n < NR_TASKS; n++) - { - if (KMCPY((proc + n), pp[n], sizeof(*proc)) == -1) - { - fprintf(stderr, "read(%#x,%#x,%d) proc\n", - pp[n], proc + n, sizeof(*proc)); - return NULL; - } - } - - p = proc; - - for (n = NR_TASKS; n; n--, p++) - if (p->pid == pid) - break; - if (!n) - return NULL; - - return p; -} - - -struct sock *find_tcp(fd, ti) - int fd; - struct tcpiphdr *ti; -{ - struct sock *s; - struct inode *i; - struct files_struct *fs; - struct task_struct *p; - struct file *f, **o; - - if (!(p = getproc())) - return NULL; - - fs = p->files; - o = (struct file **)calloc(fs->count + 1, sizeof(*o)); - if (KMCPY(o, fs->fd, (fs->count + 1) * sizeof(*o)) == -1) - { - fprintf(stderr, "read(%#x,%#x,%d) - fd - failed\n", - fs->fd, o, sizeof(*o)); - return NULL; - } - f = (struct file *)calloc(1, sizeof(*f)); - if (KMCPY(f, o[fd], sizeof(*f)) == -1) - { - fprintf(stderr, "read(%#x,%#x,%d) - o[fd] - failed\n", - o[fd], f, sizeof(*f)); - return NULL; - } - - i = (struct inode *)calloc(1, sizeof(*i)); - if (KMCPY(i, f->f_inode, sizeof(*i)) == -1) - { - fprintf(stderr, "read(%#x,%#x,%d) - f_inode - failed\n", - f->f_inode, i, sizeof(*i)); - return NULL; - } - return i->u.socket_i.data; -} - -int do_socket(dev, mtu, ti, gwip) - char *dev; - int mtu; - struct tcpiphdr *ti; - struct in_addr gwip; -{ - struct sockaddr_in rsin, lsin; - struct sock *s, sk; - int fd, nfd, len; - - printf("Dest. Port: %d\n", ti->ti_dport); - - fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd == -1) - { - perror("socket"); - return -1; - } - - if (fcntl(fd, F_SETFL, FNDELAY) == -1) - { - perror("fcntl"); - return -1; - } - - bzero((char *)&lsin, sizeof(lsin)); - lsin.sin_family = AF_INET; - bcopy((char *)&ti->ti_src, (char *)&lsin.sin_addr, - sizeof(struct in_addr)); - if (bind(fd, (struct sockaddr *)&lsin, sizeof(lsin)) == -1) - { - perror("bind"); - return -1; - } - len = sizeof(lsin); - (void) getsockname(fd, (struct sockaddr *)&lsin, &len); - ti->ti_sport = lsin.sin_port; - printf("sport %d\n", ntohs(lsin.sin_port)); - nfd = initdevice(dev, 0); - if (nfd == -1) - return -1; - - if (!(s = find_tcp(fd, ti))) - return -1; - - bzero((char *)&rsin, sizeof(rsin)); - rsin.sin_family = AF_INET; - bcopy((char *)&ti->ti_dst, (char *)&rsin.sin_addr, - sizeof(struct in_addr)); - rsin.sin_port = ti->ti_dport; - if (connect(fd, (struct sockaddr *)&rsin, sizeof(rsin)) == -1 && - errno != EINPROGRESS) - { - perror("connect"); - return -1; - } - KMCPY(&sk, s, sizeof(sk)); - ti->ti_win = sk.window; - ti->ti_seq = sk.sent_seq - 1; - ti->ti_ack = sk.rcv_ack_seq; - ti->ti_flags = TH_SYN; - - if (send_tcp(nfd, mtu, (ip_t *)ti, gwip) == -1) - return -1; - (void)write(fd, "Hello World\n", 12); - sleep(2); - close(fd); - return 0; -} diff --git a/contrib/ipfilter/ipsend/sirix.c b/contrib/ipfilter/ipsend/sirix.c deleted file mode 100644 index 3b565b19220c..000000000000 --- a/contrib/ipfilter/ipsend/sirix.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $FreeBSD$ */ - -/* - * (C)opyright 1992-1998 Darren Reed. - * (C)opyright 1997 Marc Boucher. - * - * See the IPFILTER.LICENCE file for details on licencing. - * - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include "ipsend.h" -#include - -#if !defined(lint) && defined(LIBC_SCCS) -static char sirix[] = "@(#)sirix.c 1.0 10/9/97 (C)1997 Marc Boucher"; -#endif - - -int initdevice(char *device, int tout) -{ - int fd; - struct sockaddr_raw sr; - - if ((fd = socket(PF_RAW, SOCK_RAW, RAWPROTO_DRAIN)) < 0) - { - perror("socket(PF_RAW, SOCK_RAW, RAWPROTO_DRAIN)"); - return -1; - } - - memset(&sr, 0, sizeof(sr)); - sr.sr_family = AF_RAW; - sr.sr_port = ETHERTYPE_IP; - strncpy(sr.sr_ifname, device, sizeof(sr.sr_ifname)); - if (bind(fd, &sr, sizeof(sr)) < 0) - { - perror("bind AF_RAW"); - close(fd); - return -1; - } - return fd; -} - - -/* - * output an IP packet - */ -int sendip(int fd, char *pkt, int len) -{ - struct sockaddr_raw sr; - int srlen = sizeof(sr); - struct ifreq ifr; - struct ether_header *eh = (struct ether_header *)pkt; - - if (getsockname(fd, &sr, &srlen) == -1) - { - perror("getsockname"); - return -1; - } - - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, sr.sr_ifname, sizeof ifr.ifr_name); - - if (ioctl(fd, SIOCGIFADDR, &ifr) == -1) - { - perror("ioctl SIOCGIFADDR"); - return -1; - } - - memcpy(eh->ether_shost, ifr.ifr_addr.sa_data, sizeof(eh->ether_shost)); - - if (write(fd, pkt, len) == -1) - { - perror("send"); - return -1; - } - - return len; -} diff --git a/contrib/ipfilter/ipsend/slinux.c b/contrib/ipfilter/ipsend/slinux.c deleted file mode 100644 index 7405d5e503a5..000000000000 --- a/contrib/ipfilter/ipsend/slinux.c +++ /dev/null @@ -1,92 +0,0 @@ -/* $FreeBSD$ */ - -/* - * (C)opyright 1992-1998 Darren Reed. (from tcplog) - * - * See the IPFILTER.LICENCE file for details on licencing. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ipsend.h" - -#if !defined(lint) -static const char sccsid[] = "@(#)slinux.c 1.2 8/25/95"; -static const char rcsid[] = "@(#)$Id$"; -#endif - -#define CHUNKSIZE 8192 -#define BUFSPACE (4*CHUNKSIZE) - -/* - * Be careful to only include those defined in the flags option for the - * interface are included in the header size. - */ - -static int timeout; -static char *eth_dev = NULL; - - -int initdevice(dev, spare) - char *dev; - int spare; -{ - int fd; - - eth_dev = strdup(dev); - if ((fd = socket(AF_INET, SOCK_PACKET, htons(ETHERTYPE_IP))) == -1) - { - perror("socket(SOCK_PACKET)"); - exit(-1); - } - - return fd; -} - - -/* - * output an IP packet onto a fd opened for /dev/nit - */ -int sendip(fd, pkt, len) - int fd, len; - char *pkt; -{ - struct sockaddr s; - struct ifreq ifr; - - strncpy(ifr.ifr_name, eth_dev, sizeof(ifr.ifr_name)); - if (ioctl(fd, SIOCGIFHWADDR, &ifr) == -1) - { - perror("SIOCGIFHWADDR"); - return -1; - } - bcopy(ifr.ifr_hwaddr.sa_data, pkt + 6, 6); - s.sa_family = ETHERTYPE_IP; - strncpy(s.sa_data, eth_dev, sizeof(s.sa_data)); - - if (sendto(fd, pkt, len, 0, &s, sizeof(s)) == -1) - { - perror("send"); - return -1; - } - - return len; -}