summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/ipsend
diff options
context:
space:
mode:
authordarrenr <darrenr@FreeBSD.org>1997-04-03 10:22:02 +0000
committerdarrenr <darrenr@FreeBSD.org>1997-04-03 10:22:02 +0000
commitd25503500842fdd0550710a7afb953d1b8f20f00 (patch)
treef687cfed6c59d74a7c81b967eb3caf8a9c5f184e /contrib/ipfilter/ipsend
parent2d94e888ee6d73e6d599e49598a12d8da9f74f69 (diff)
downloadFreeBSD-src-d25503500842fdd0550710a7afb953d1b8f20f00.zip
FreeBSD-src-d25503500842fdd0550710a7afb953d1b8f20f00.tar.gz
Import IP Filter version 3.2alpha4 to bring in working LKM for 2.2
Diffstat (limited to 'contrib/ipfilter/ipsend')
-rw-r--r--contrib/ipfilter/ipsend/44arp.c5
-rw-r--r--contrib/ipfilter/ipsend/arp.c5
-rw-r--r--contrib/ipfilter/ipsend/ip.c21
-rw-r--r--contrib/ipfilter/ipsend/ipresend.c15
-rw-r--r--contrib/ipfilter/ipsend/ipsend.c19
-rw-r--r--contrib/ipfilter/ipsend/ipsend.h64
-rw-r--r--contrib/ipfilter/ipsend/ipsend.sed3
-rw-r--r--contrib/ipfilter/ipsend/ipsopt.c14
-rw-r--r--contrib/ipfilter/ipsend/iptest.c41
-rw-r--r--contrib/ipfilter/ipsend/iptests.c30
-rw-r--r--contrib/ipfilter/ipsend/lsock.c22
-rw-r--r--contrib/ipfilter/ipsend/resend.c14
-rw-r--r--contrib/ipfilter/ipsend/sbpf.c2
-rw-r--r--contrib/ipfilter/ipsend/sdlpi.c3
-rw-r--r--contrib/ipfilter/ipsend/slinux.c3
-rw-r--r--contrib/ipfilter/ipsend/snit.c3
-rw-r--r--contrib/ipfilter/ipsend/sock.c62
17 files changed, 195 insertions, 131 deletions
diff --git a/contrib/ipfilter/ipsend/44arp.c b/contrib/ipfilter/ipsend/44arp.c
index aa42859..f46bc55 100644
--- a/contrib/ipfilter/ipsend/44arp.c
+++ b/contrib/ipfilter/ipsend/44arp.c
@@ -19,6 +19,11 @@
#include <errno.h>
#include <nlist.h>
#include <stdio.h>
+#include <netinet/in.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include "ipsend.h"
+
/*
* lookup host and return
diff --git a/contrib/ipfilter/ipsend/arp.c b/contrib/ipfilter/ipsend/arp.c
index 47f6fce..e010b9b 100644
--- a/contrib/ipfilter/ipsend/arp.c
+++ b/contrib/ipfilter/ipsend/arp.c
@@ -20,6 +20,10 @@ static char sccsid[] = "@(#)arp.c 1.4 1/11/96 (C)1995 Darren Reed";
#include <netinet/in.h>
#include <net/if.h>
#include <net/if_arp.h>
+#include <netinet/in.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include "ipsend.h"
#if defined(__SVR4) || defined(__svr4__)
#define bcopy(a,b,c) memmove(b,a,c)
@@ -67,7 +71,6 @@ char *ether;
struct arpreq ar;
struct sockaddr_in *sin, san;
struct hostent *hp;
- char *inet_ntoa();
int fd;
if (!bcmp(ipsave, ip, 4)) {
diff --git a/contrib/ipfilter/ipsend/ip.c b/contrib/ipfilter/ipsend/ip.c
index 2c7f7ff..1b08222 100644
--- a/contrib/ipfilter/ipsend/ip.c
+++ b/contrib/ipfilter/ipsend/ip.c
@@ -27,17 +27,12 @@ static char sccsid[] = "%W% %G% (C)1995";
#ifndef linux
#include <netinet/if_ether.h>
#include <netinet/ip_var.h>
-#include <netinet/tcpip.h>
-#endif
-#include "ip_compat.h"
-#ifdef linux
-#include "tcpip.h"
#endif
+#include "ipsend.h"
static char *ipbuf = NULL, *ethbuf = NULL;
-extern int arp(), sendip();
u_short chksum(buf,len)
u_short *buf;
@@ -73,7 +68,7 @@ struct in_addr gwip;
bcopy((char *)buf, s + sizeof(*eh), len);
if (gwip.s_addr == last_gw.s_addr)
bcopy(last_arp, (char *)&eh->ether_dhost, 6);
- else if (arp((char *)&gwip, &eh->ether_dhost) == -1)
+ else if (arp((char *)&gwip, (char *)&eh->ether_dhost) == -1)
{
perror("arp");
return -2;
@@ -107,7 +102,7 @@ int frag;
bzero((char *)&eh->ether_shost, sizeof(eh->ether_shost));
if (last_gw.s_addr && (gwip.s_addr == last_gw.s_addr))
bcopy(last_arp, (char *)&eh->ether_dhost, 6);
- else if (arp((char *)&gwip, &eh->ether_dhost) == -1)
+ else if (arp((char *)&gwip, (char *)&eh->ether_dhost) == -1)
{
perror("arp");
return -2;
@@ -129,7 +124,7 @@ int frag;
if (!frag || (sizeof(*eh) + ntohs(ip->ip_len) < mtu))
{
ip->ip_sum = 0;
- ip->ip_sum = chksum(ip, ip->ip_hl << 2);
+ ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
bcopy((char *)ip, ipbuf + sizeof(*eh), ntohs(ip->ip_len));
err = sendip(nfd, ipbuf, sizeof(*eh) + ntohs(ip->ip_len));
@@ -202,7 +197,7 @@ int frag;
ts += hlen;
ip->ip_len = htons(ts);
ip->ip_sum = 0;
- ip->ip_sum = chksum(ip, hlen);
+ ip->ip_sum = chksum((u_short *)ip, hlen);
bcopy((char *)ip, ipbuf + sizeof(*eh), hlen);
bcopy(s + sent, ipbuf + sizeof(*eh) + hlen, ts - hlen);
err = sendip(nfd, ipbuf, sizeof(*eh) + ts);
@@ -268,7 +263,7 @@ struct in_addr gwip;
ti->ti_len = htons(thlen);
ip->ip_len = (ip->ip_hl << 2) + thlen;
ti->ti_sum = 0;
- ti->ti_sum = chksum(ti, thlen + sizeof(ip_t));
+ ti->ti_sum = chksum((u_short *)ti, thlen + sizeof(ip_t));
bcopy((char *)&ti->ti_sport,
(char *)ip + (ip->ip_hl << 2), thlen);
@@ -300,7 +295,7 @@ struct in_addr gwip;
ti->ti_len = htons(thlen);
ip->ip_len = (ip->ip_hl << 2) + thlen;
ti->ti_sum = 0;
- ti->ti_sum = chksum(ti, thlen + sizeof(ip_t));
+ ti->ti_sum = chksum((u_short *)ti, thlen + sizeof(ip_t));
bcopy((char *)&ti->ti_sport,
(char *)ip + (ip->ip_hl << 2), sizeof(udphdr_t));
@@ -321,7 +316,7 @@ struct in_addr gwip;
ic = (struct icmp *)((char *)ip + (ip->ip_hl << 2));
ic->icmp_cksum = 0;
- ic->icmp_cksum = chksum((char *)ic, sizeof(struct icmp));
+ ic->icmp_cksum = chksum((u_short *)ic, sizeof(struct icmp));
return send_ip(nfd, mtu, ip, gwip, 1);
}
diff --git a/contrib/ipfilter/ipsend/ipresend.c b/contrib/ipfilter/ipsend/ipresend.c
index 6fd91bf..9402104a 100644
--- a/contrib/ipfilter/ipsend/ipresend.c
+++ b/contrib/ipfilter/ipsend/ipresend.c
@@ -34,14 +34,8 @@ static char sccsid[] = "%W% %G% (C)1995 Darren Reed";
#include <netinet/ip_icmp.h>
#ifndef linux
#include <netinet/ip_var.h>
-#include <netinet/tcpip.h>
#endif
-#include "ip_compat.h"
-#ifdef linux
-#include <linux/sockios.h>
-#include "tcpip.h"
-#endif
-#include "ipt.h"
+#include "ipsend.h"
extern char *optarg;
@@ -49,7 +43,6 @@ extern int optind;
#ifndef NO_IPF
extern struct ipread snoop, pcap, etherf, iphex, tcpd, iptext;
#endif
-extern int resolve(), ip_resend();
int opts = 0;
#ifndef DEFAULT_DEVICE
@@ -75,7 +68,11 @@ char default_device[] = DEFAULT_DEVICE;
#endif
-void usage(prog)
+static void usage __P((char *));
+int main __P((int, char **));
+
+
+static void usage(prog)
char *prog;
{
fprintf(stderr, "Usage: %s [options] <-r filename|-R filename>\n\
diff --git a/contrib/ipfilter/ipsend/ipsend.c b/contrib/ipfilter/ipsend/ipsend.c
index e45d3ee..4c37557 100644
--- a/contrib/ipfilter/ipsend/ipsend.c
+++ b/contrib/ipfilter/ipsend/ipsend.c
@@ -34,21 +34,13 @@ static char sccsid[] = "@(#)ipsend.c 1.5 12/10/95 (C)1995 Darren Reed";
#include <netinet/ip_icmp.h>
#ifndef linux
#include <netinet/ip_var.h>
-#include <netinet/tcpip.h>
#endif
-#include "ip_compat.h"
-#ifdef linux
-#include <linux/sockios.h>
-#include "tcpip.h"
-#endif
-#include "ipt.h"
+#include "ipsend.h"
extern char *optarg;
extern int optind;
-extern int resolve(), optname(), initdevice(), send_packet();
-
char options[68];
#ifdef linux
char default_device[] = "eth0";
@@ -69,7 +61,12 @@ char default_device[] = "lan0";
#endif
-void usage(prog)
+static void usage __P((char *));
+static void do_icmp __P((ip_t *, char *));
+int main __P((int, char **));
+
+
+static void usage(prog)
char *prog;
{
fprintf(stderr, "Usage: %s [options] dest [flags]\n\
@@ -346,5 +343,5 @@ char **argv;
if (tcp->th_dport)
return do_socket(dev, mtu, ti, gwip);
#endif
- return send_packets(dev, mtu, ti, gwip);
+ return send_packets(dev, mtu, (ip_t *)ti, gwip);
}
diff --git a/contrib/ipfilter/ipsend/ipsend.h b/contrib/ipfilter/ipsend/ipsend.h
new file mode 100644
index 0000000..362e273
--- /dev/null
+++ b/contrib/ipfilter/ipsend/ipsend.h
@@ -0,0 +1,64 @@
+/*
+ * ipsend.h (C) 1997 Darren Reed
+ *
+ * This was written to test what size TCP fragments would get through
+ * various TCP/IP packet filters, as used in IP firewalls. In certain
+ * conditions, enough of the TCP header is missing for unpredictable
+ * results unless the filter is aware that this can happen.
+ *
+ * The author provides this program as-is, with no gaurantee for its
+ * suitability for any specific purpose. The author takes no responsibility
+ * for the misuse/abuse of this program and provides it for the sole purpose
+ * of testing packet filter policies. This file maybe distributed freely
+ * providing it is not modified and that this notice remains in tact.
+ *
+ */
+#ifndef __P
+# ifdef __STDC__
+# define __P(x) x
+# else
+# define __P(x) ()
+# endif
+#endif
+
+#include "ip_compat.h"
+#ifdef linux
+#include <linux/sockios.h>
+#endif
+#include "tcpip.h"
+#include "ipt.h"
+
+extern int resolve __P((char *, char *));
+extern int arp __P((char *, char *));
+extern u_short chksum __P((u_short *, int));
+extern int send_ether __P((int, char *, int, struct in_addr));
+extern int send_ip __P((int, int, ip_t *, struct in_addr, int));
+extern int send_tcp __P((int, int, ip_t *, struct in_addr));
+extern int send_udp __P((int, int, ip_t *, struct in_addr));
+extern int send_icmp __P((int, int, ip_t *, struct in_addr));
+extern int send_packet __P((int, int, ip_t *, struct in_addr));
+extern int send_packets __P((char *, int, ip_t *, struct in_addr));
+extern u_short seclevel __P((char *));
+extern u_long optname __P((char *, char *));
+extern int initdevice __P((char *, int, int));
+extern int sendip __P((int, char *, int));
+#ifdef linux
+extern struct sock *find_tcp __P((int, struct tcpiphdr *));
+#else
+extern struct tcpcb *find_tcp __P((int, struct tcpiphdr *));
+#endif
+extern int ip_resend __P((char *, int, struct ipread *, struct in_addr, char *));
+
+extern void ip_test1 __P((char *, int, ip_t *, struct in_addr, int));
+extern void ip_test2 __P((char *, int, ip_t *, struct in_addr, int));
+extern void ip_test3 __P((char *, int, ip_t *, struct in_addr, int));
+extern void ip_test4 __P((char *, int, ip_t *, struct in_addr, int));
+extern void ip_test5 __P((char *, int, ip_t *, struct in_addr, int));
+extern void ip_test6 __P((char *, int, ip_t *, struct in_addr, int));
+extern void ip_test7 __P((char *, int, ip_t *, struct in_addr, int));
+extern int do_socket __P((char *, int, struct tcpiphdr *, struct in_addr));
+
+extern int openkmem __P((void));
+extern int kmemcpy __P((char *, void *, int));
+
+#define KMCPY(a,b,c) kmemcpy((char *)(a), (void *)(b), (int)(c))
diff --git a/contrib/ipfilter/ipsend/ipsend.sed b/contrib/ipfilter/ipsend/ipsend.sed
new file mode 100644
index 0000000..774c0e2
--- /dev/null
+++ b/contrib/ipfilter/ipsend/ipsend.sed
@@ -0,0 +1,3 @@
+0Æ . Ä,..+ CVS0Í
+.cvsignore0Î44arp.c0Ï Crashable0ÐMakefile0Ñarp.c0Ò
+dlcommon.c0Ódltest.h0Ôin_var.h0Õip.c0Ö ip_compat.h0×ip_var.h0Ø
diff --git a/contrib/ipfilter/ipsend/ipsopt.c b/contrib/ipfilter/ipsend/ipsopt.c
index 75c4f16..8313559 100644
--- a/contrib/ipfilter/ipsend/ipsopt.c
+++ b/contrib/ipfilter/ipsend/ipsopt.c
@@ -18,6 +18,16 @@ static char sccsid[] = "@(#)ipsopt.c 1.2 1/11/96 (C)1995 Darren Reed";
#include <netinet/ip.h>
#include "ip_compat.h"
+
+#ifndef __P
+# ifdef __STDC__
+# define __P(x) x
+# else
+# define __P(x) ()
+# endif
+#endif
+
+
struct ipopt_names {
int on_value;
int on_bit;
@@ -49,6 +59,10 @@ struct ipopt_names secnames[] = {
};
+u_short seclevel __P((char *));
+u_long optname __P((char *, char *));
+
+
u_short seclevel(slevel)
char *slevel;
{
diff --git a/contrib/ipfilter/ipsend/iptest.c b/contrib/ipfilter/ipsend/iptest.c
index c5d48fa..00b51fb 100644
--- a/contrib/ipfilter/ipsend/iptest.c
+++ b/contrib/ipfilter/ipsend/iptest.c
@@ -34,23 +34,16 @@ static char sccsid[] = "%W% %G% (C)1995 Darren Reed";
#include <netinet/ip_icmp.h>
#ifndef linux
#include <netinet/ip_var.h>
-#include <netinet/tcpip.h>
#endif
-#include "ip_compat.h"
#ifdef linux
#include <linux/sockios.h>
-#include "tcpip.h"
#endif
-#include "ipt.h"
+#include "ipsend.h"
extern char *optarg;
extern int optind;
-extern int initdevice(), resolve();
-extern int ip_test1(), ip_test2(), ip_test3(), ip_test4(), ip_test5();
-extern int ip_test6(), ip_test7();
-
char options[68];
#ifdef linux
char default_device[] = "eth0";
@@ -70,9 +63,12 @@ char default_device[] = "lan0";
# endif
#endif
+static void usage __P((char *));
+int main __P((int, char **));
+
-void usage(prog)
-char *prog;
+static void usage(prog)
+char *prog;
{
fprintf(stderr, "Usage: %s [options] dest\n\
\toptions:\n\
@@ -94,8 +90,8 @@ char *prog;
int main(argc, argv)
-int argc;
-char **argv;
+int argc;
+char **argv;
{
struct tcpiphdr *ti;
struct in_addr gwip;
@@ -191,19 +187,26 @@ char **argv;
switch (tests)
{
case 1 :
- return ip_test1(dev, mtu, ti, gwip, pointtest);
+ ip_test1(dev, mtu, (ip_t *)ti, gwip, pointtest);
+ break;
case 2 :
- return ip_test2(dev, mtu, ti, gwip, pointtest);
+ ip_test2(dev, mtu, (ip_t *)ti, gwip, pointtest);
+ break;
case 3 :
- return ip_test3(dev, mtu, ti, gwip, pointtest);
+ ip_test3(dev, mtu, (ip_t *)ti, gwip, pointtest);
+ break;
case 4 :
- return ip_test4(dev, mtu, ti, gwip, pointtest);
+ ip_test4(dev, mtu, (ip_t *)ti, gwip, pointtest);
+ break;
case 5 :
- return ip_test5(dev, mtu, ti, gwip, pointtest);
+ ip_test5(dev, mtu, (ip_t *)ti, gwip, pointtest);
+ break;
case 6 :
- return ip_test6(dev, mtu, ti, gwip, pointtest);
+ ip_test6(dev, mtu, (ip_t *)ti, gwip, pointtest);
+ break;
case 7 :
- return ip_test7(dev, mtu, ti, gwip, pointtest);
+ ip_test7(dev, mtu, (ip_t *)ti, gwip, pointtest);
+ break;
default :
break;
}
diff --git a/contrib/ipfilter/ipsend/iptests.c b/contrib/ipfilter/ipsend/iptests.c
index b9da7b2..4de99c4 100644
--- a/contrib/ipfilter/ipsend/iptests.c
+++ b/contrib/ipfilter/ipsend/iptests.c
@@ -52,23 +52,15 @@ static char sccsid[] = "%W% %G% (C)1995 Darren Reed";
#include <netinet/in_pcb.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
-#include "ip_compat.h"
-#ifdef linux
-#include "tcpip.h"
-#else
-#include <netinet/tcpip.h>
# if defined(__SVR4) || defined(__svr4__)
#include <sys/sysmacros.h>
# endif
-#endif
+#include "ipsend.h"
+
#define PAUSE() tv.tv_sec = 0; tv.tv_usec = 10000; \
(void) select(0, NULL, NULL, NULL, &tv)
-extern int send_ip(), send_tcp(), send_udp(), send_icmp(), send_ether();
-extern int initdevice(), kmemcpy();
-extern u_short chksum();
-extern struct tcpcb *find_tcp();
void ip_test1(dev, mtu, ip, gwip, ptest)
char *dev;
@@ -178,8 +170,8 @@ int ptest;
for (; i < (ntohs(ip->ip_len) * 2); i++) {
ip->ip_id = htons(id++);
ip->ip_sum = 0;
- ip->ip_sum = chksum(ip, ip->ip_hl << 2);
- (void) send_ether(nfd, ip, i, gwip);
+ ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
+ (void) send_ether(nfd, (char *)ip, i, gwip);
printf("%d\r", i);
fflush(stdout);
PAUSE();
@@ -190,8 +182,8 @@ int ptest;
ip->ip_id = htons(id++);
ip->ip_len = htons(i);
ip->ip_sum = 0;
- ip->ip_sum = chksum(ip, ip->ip_hl << 2);
- (void) send_ether(nfd, ip, len, gwip);
+ ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
+ (void) send_ether(nfd, (char *)ip, len, gwip);
printf("%d\r", i);
fflush(stdout);
PAUSE();
@@ -209,8 +201,8 @@ int ptest;
ip->ip_id = htons(id++);
ip->ip_len = htons(i);
ip->ip_sum = 0;
- ip->ip_sum = chksum(ip, ip->ip_hl << 2);
- (void) send_ether(nfd, ip, len, gwip);
+ ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
+ (void) send_ether(nfd, (char *)ip, len, gwip);
printf("%d\r", i);
fflush(stdout);
PAUSE();
@@ -221,8 +213,8 @@ int ptest;
for (i = len; i > 0; i--) {
ip->ip_id = htons(id++);
ip->ip_sum = 0;
- ip->ip_sum = chksum(ip, ip->ip_hl << 2);
- (void) send_ether(nfd, ip, i, gwip);
+ ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
+ (void) send_ether(nfd, (char *)ip, i, gwip);
printf("%d\r", i);
fflush(stdout);
PAUSE();
@@ -1043,7 +1035,7 @@ int ptest;
printf("Can't find PCB\n");
goto skip_five_and_six;
}
- kmemcpy((char*)&tcb, (void *)t, sizeof(tcb));
+ KMCPY(&tcb, t, sizeof(tcb));
ti.ti_win = tcb.rcv_adv;
ti.ti_seq = tcb.snd_nxt - 1;
ti.ti_ack = tcb.rcv_nxt;
diff --git a/contrib/ipfilter/ipsend/lsock.c b/contrib/ipfilter/ipsend/lsock.c
index 89b6ab7..5cc3122 100644
--- a/contrib/ipfilter/ipsend/lsock.c
+++ b/contrib/ipfilter/ipsend/lsock.c
@@ -48,8 +48,7 @@ static char sccsid[] = "@(#)lsock.c 1.2 1/11/96 (C)1995 Darren Reed";
#if LINUX < 0103
#include <net/inet/sock.h>
#endif
-#include "ip_compat.h"
-#include "tcpip.h"
+#include "ipsend.h"
int nproc;
struct task_struct *proc;
@@ -108,21 +107,20 @@ struct task_struct *getproc()
fprintf(stderr, "nlist(%#x) == %d\n", names, n);
return NULL;
}
- if (kmemcpy((char *)&nproc, (void *)names[1].n_value,
- sizeof(nproc)) == -1)
+ 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 (kmemcpy((char *)&v, (void *)names[0].n_value, sizeof(v)) == -1)
+ 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 (kmemcpy((char *)pp, (void *)v, siz) == -1)
+ if (KMCPY(pp, v, siz) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) proc\n",
v, pp, siz);
@@ -131,8 +129,7 @@ struct task_struct *getproc()
proc = (struct task_struct *)malloc(siz);
for (n = 0; n < NR_TASKS; n++)
{
- if (kmemcpy((char *)(proc + n), (void *)pp[n],
- sizeof(*proc)) == -1)
+ if (KMCPY((proc + n), pp[n], sizeof(*proc)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) proc\n",
pp[n], proc + n, sizeof(*proc));
@@ -167,15 +164,14 @@ struct tcpiphdr *ti;
fs = p->files;
o = (struct file **)calloc(1, sizeof(*o) * (fs->count + 1));
- if (kmemcpy((char *)o, (void *)fs->fd,
- (fs->count + 1) * sizeof(*o)) == -1)
+ 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 (kmemcpy((char *)f, (void *)o[fd], sizeof(*f)) == -1)
+ if (KMCPY(f, o[fd], sizeof(*f)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) - o[fd] - failed\n",
o[fd], f, sizeof(*f));
@@ -183,7 +179,7 @@ struct tcpiphdr *ti;
}
i = (struct inode *)calloc(1, sizeof(*i));
- if (kmemcpy((char *)i, (void *)f->f_inode, sizeof(*i)) == -1)
+ 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));
@@ -247,7 +243,7 @@ int flags;
perror("connect");
return -1;
}
- kmemcpy((char*)&sk, (void *)s, sizeof(sk));
+ KMCPY(&sk, s, sizeof(sk));
ti->ti_win = sk.window;
ti->ti_seq = sk.sent_seq - 1;
ti->ti_ack = sk.rcv_ack_seq;
diff --git a/contrib/ipfilter/ipsend/resend.c b/contrib/ipfilter/ipsend/resend.c
index 59ed75e..84d3215 100644
--- a/contrib/ipfilter/ipsend/resend.c
+++ b/contrib/ipfilter/ipsend/resend.c
@@ -28,22 +28,16 @@ static char sccsid[] = "@(#)resend.c 1.3 1/11/96 (C)1995 Darren Reed";
#include <netinet/ip_icmp.h>
#ifndef linux
#include <netinet/ip_var.h>
-#include <netinet/tcpip.h>
#include <netinet/if_ether.h>
#endif
-#include "ip_compat.h"
-#ifdef linux
-#include <linux/sockios.h>
-#include "tcpip.h"
-#endif
-#include "ipt.h"
+#include "ipsend.h"
static u_char buf[65536]; /* 1 big packet */
+static void printpacket __P((ip_t *));
-extern int initdevice(), arp(), sendip();
-void printpacket(ip)
+static void printpacket(ip)
ip_t *ip;
{
tcphdr_t *t;
@@ -119,7 +113,7 @@ char *datain;
bcopy(ip, (char *)(eh + 1), len);
printpacket(ip);
- if (sendip(wfd, eh, sizeof(*eh) + len) == -1)
+ if (sendip(wfd, (char *)eh, sizeof(*eh) + len) == -1)
{
perror("send_packet");
break;
diff --git a/contrib/ipfilter/ipsend/sbpf.c b/contrib/ipfilter/ipsend/sbpf.c
index 5eb9d9b..dd781ab 100644
--- a/contrib/ipfilter/ipsend/sbpf.c
+++ b/contrib/ipfilter/ipsend/sbpf.c
@@ -36,7 +36,7 @@
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
-#include <netinet/tcpip.h>
+#include "ipsend.h"
#if !defined(lint) && defined(LIBC_SCCS)
static char sbpf[] = "@(#)sbpf.c 1.3 8/25/95 (C)1995 Darren Reed";
diff --git a/contrib/ipfilter/ipsend/sdlpi.c b/contrib/ipfilter/ipsend/sdlpi.c
index eabd61e..94d71ae 100644
--- a/contrib/ipfilter/ipsend/sdlpi.c
+++ b/contrib/ipfilter/ipsend/sdlpi.c
@@ -36,9 +36,8 @@
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
-#include <netinet/tcpip.h>
-#include "ip_compat.h"
+#include "ipsend.h"
#if !defined(lint) && defined(LIBC_SCCS)
static char snitid[] = "@(#)sdlpi.c 1.3 10/30/95 (C)1995 Darren Reed";
diff --git a/contrib/ipfilter/ipsend/slinux.c b/contrib/ipfilter/ipsend/slinux.c
index 1767dfe..7e4c7bf 100644
--- a/contrib/ipfilter/ipsend/slinux.c
+++ b/contrib/ipfilter/ipsend/slinux.c
@@ -28,8 +28,7 @@
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
-#include "ip_compat.h"
-#include "tcpip.h"
+#include "ipsend.h"
#if !defined(lint) && defined(LIBC_SCCS)
static char sccsid[] = "@(#)slinux.c 1.2 8/25/95";
diff --git a/contrib/ipfilter/ipsend/snit.c b/contrib/ipfilter/ipsend/snit.c
index d022192..e738fdb 100644
--- a/contrib/ipfilter/ipsend/snit.c
+++ b/contrib/ipfilter/ipsend/snit.c
@@ -38,7 +38,8 @@
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/tcp.h>
-#include <netinet/tcpip.h>
+
+#include "ipsend.h"
#if !defined(lint) && defined(LIBC_SCCS)
static char snitid[] = "@(#)snit.c 1.5 1/11/96 (C)1995 Darren Reed";
diff --git a/contrib/ipfilter/ipsend/sock.c b/contrib/ipfilter/ipsend/sock.c
index 58949c5..b753426 100644
--- a/contrib/ipfilter/ipsend/sock.c
+++ b/contrib/ipfilter/ipsend/sock.c
@@ -53,13 +53,11 @@ static char sccsid[] = "@(#)sock.c 1.2 1/11/96 (C)1995 Darren Reed";
#include <netinet/in_pcb.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
-#include <netinet/tcpip.h>
+#include "ipsend.h"
int nproc;
struct proc *proc;
-extern int initdevice(), send_tcp();
-
#ifndef KMEM
# ifdef _PATH_KMEM
# define KMEM _PATH_KMEM
@@ -77,9 +75,17 @@ extern int initdevice(), send_tcp();
# define KERNEL "/vmunix"
#endif
+
+#if BSD < 199103
+static struct proc *getproc __P((void));
+#else
+static struct kinfo_proc *getproc __P((void));
+#endif
+
+
int kmemcpy(buf, pos, n)
char *buf;
-off_t pos;
+void *pos;
int n;
{
static int kfd = -1;
@@ -87,7 +93,7 @@ int n;
if (kfd == -1)
kfd = open(KMEM, O_RDONLY);
- if (lseek(kfd, pos, SEEK_SET) == -1)
+ if (lseek(kfd, (off_t)pos, SEEK_SET) == -1)
{
perror("lseek");
return -1;
@@ -107,7 +113,7 @@ struct nlist names[3] = {
};
#if BSD < 199103
-struct proc *getproc()
+static struct proc *getproc()
{
struct proc *p;
pid_t pid = getpid();
@@ -119,21 +125,20 @@ struct proc *getproc()
fprintf(stderr, "nlist(%#x) == %d\n", names, n);
return NULL;
}
- if (kmemcpy((char *)&nproc, (off_t)names[1].n_value,
- sizeof(nproc)) == -1)
+ 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 proc);
- if (kmemcpy((char *)&p, (off_t)names[0].n_value, sizeof(p)) == -1)
+ if (KMCPY(&p, names[0].n_value, sizeof(p)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) proc\n",
names[0].n_value, &p, sizeof(p));
return NULL;
}
proc = (struct proc *)malloc(siz);
- if (kmemcpy((char *)proc, (off_t)p, siz) == -1)
+ if (KMCPY(proc, p, siz) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) proc\n",
p, proc, siz);
@@ -167,22 +172,21 @@ struct tcpiphdr *ti;
return NULL;
up = (struct user *)malloc(sizeof(*up));
- if (kmemcpy((char *)up, (off_t)p->p_uarea, sizeof(*up)) == -1)
+ if (KMCPY(up, p->p_uarea, sizeof(*up)) == -1)
{
fprintf(stderr, "read(%#x,%#x) failed\n", p, p->p_uarea);
return NULL;
}
o = (struct file **)calloc(1, sizeof(*o) * (up->u_lastfile + 1));
- if (kmemcpy((char *)o, (off_t)up->u_ofile,
- (up->u_lastfile + 1) * sizeof(*o)) == -1)
+ if (KMCPY(o, up->u_ofile, (up->u_lastfile + 1) * sizeof(*o)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) - u_ofile - failed\n",
up->u_ofile_arr, o, sizeof(*o));
return NULL;
}
f = (struct file *)calloc(1, sizeof(*f));
- if (kmemcpy((char *)f, (off_t)o[fd], sizeof(*f)) == -1)
+ if (KMCPY(f, o[fd], sizeof(*f)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) - o[fd] - failed\n",
up->u_ofile_arr[fd], f, sizeof(*f));
@@ -190,7 +194,7 @@ struct tcpiphdr *ti;
}
s = (struct socket *)calloc(1, sizeof(*s));
- if (kmemcpy((char *)s, (off_t)f->f_data, sizeof(*s)) == -1)
+ if (KMCPY(s, f->f_data, sizeof(*s)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) - f_data - failed\n",
o[fd], s, sizeof(*s));
@@ -198,7 +202,7 @@ struct tcpiphdr *ti;
}
i = (struct inpcb *)calloc(1, sizeof(*i));
- if (kmemcpy((char *)i, (off_t)s->so_pcb, sizeof(*i)) == -1)
+ if (KMCPY(i, s->so_pcb, sizeof(*i)) == -1)
{
fprintf(stderr, "kvm_read(%#x,%#x,%d) - so_pcb - failed\n",
s->so_pcb, i, sizeof(*i));
@@ -206,7 +210,7 @@ struct tcpiphdr *ti;
}
t = (struct tcpcb *)calloc(1, sizeof(*t));
- if (kmemcpy((char *)t, (off_t)i->inp_ppcb, sizeof(*t)) == -1)
+ if (KMCPY(t, i->inp_ppcb, sizeof(*t)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) - inp_ppcb - failed\n",
i->inp_ppcb, t, sizeof(*t));
@@ -215,7 +219,7 @@ struct tcpiphdr *ti;
return (struct tcpcb *)i->inp_ppcb;
}
#else
-struct kinfo_proc *getproc()
+static struct kinfo_proc *getproc()
{
static struct kinfo_proc kp;
pid_t pid = getpid();
@@ -251,7 +255,7 @@ struct tcpiphdr *ti;
return NULL;
fd = (struct filedesc *)malloc(sizeof(*fd));
- if (kmemcpy((char *)fd, (void *)p->kp_proc.p_fd, sizeof(*fd)) == -1)
+ if (KMCPY(fd, p->kp_proc.p_fd, sizeof(*fd)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx) failed\n",
(u_long)p, (u_long)p->kp_proc.p_fd);
@@ -259,15 +263,14 @@ struct tcpiphdr *ti;
}
o = (struct file **)calloc(1, sizeof(*o) * (fd->fd_lastfile + 1));
- if (kmemcpy((char *)o, (void *)fd->fd_ofiles,
- (fd->fd_lastfile + 1) * sizeof(*o)) == -1)
+ if (KMCPY(o, fd->fd_ofiles, (fd->fd_lastfile + 1) * sizeof(*o)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx,%d) - u_ofile - failed\n",
(u_long)fd->fd_ofiles, (u_long)o, sizeof(*o));
return NULL;
}
f = (struct file *)calloc(1, sizeof(*f));
- if (kmemcpy((char *)f, (void *)o[tfd], sizeof(*f)) == -1)
+ if (KMCPY(f, o[tfd], sizeof(*f)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx,%d) - o[tfd] - failed\n",
(u_long)o[tfd], (u_long)f, sizeof(*f));
@@ -275,7 +278,7 @@ struct tcpiphdr *ti;
}
s = (struct socket *)calloc(1, sizeof(*s));
- if (kmemcpy((char *)s, (void *)f->f_data, sizeof(*s)) == -1)
+ if (KMCPY(s, f->f_data, sizeof(*s)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx,%d) - f_data - failed\n",
(u_long)f->f_data, (u_long)s, sizeof(*s));
@@ -283,7 +286,7 @@ struct tcpiphdr *ti;
}
i = (struct inpcb *)calloc(1, sizeof(*i));
- if (kmemcpy((char *)i, (void *)s->so_pcb, sizeof(*i)) == -1)
+ if (KMCPY(i, s->so_pcb, sizeof(*i)) == -1)
{
fprintf(stderr, "kvm_read(%#lx,%#lx,%d) - so_pcb - failed\n",
(u_long)s->so_pcb, (u_long)i, sizeof(*i));
@@ -291,7 +294,7 @@ struct tcpiphdr *ti;
}
t = (struct tcpcb *)calloc(1, sizeof(*t));
- if (kmemcpy((char *)t, (void *)i->inp_ppcb, sizeof(*t)) == -1)
+ if (KMCPY(t, i->inp_ppcb, sizeof(*t)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx,%d) - inp_ppcb - failed\n",
(u_long)i->inp_ppcb, (u_long)t, sizeof(*t));
@@ -301,12 +304,11 @@ struct tcpiphdr *ti;
}
#endif /* BSD < 199301 */
-int do_socket(dev, mtu, ti, gwip, flags)
+int do_socket(dev, mtu, ti, gwip)
char *dev;
int mtu;
struct tcpiphdr *ti;
struct in_addr gwip;
-int flags;
{
struct sockaddr_in rsin, lsin;
struct tcpcb *t, tcb;
@@ -340,7 +342,7 @@ int flags;
(void) getsockname(fd, (struct sockaddr *)&lsin, &len);
ti->ti_sport = lsin.sin_port;
printf("sport %d\n", ntohs(lsin.sin_port));
- nfd = initdevice(dev, ntohs(lsin.sin_port));
+ nfd = initdevice(dev, ntohs(lsin.sin_port), 1);
if (!(t = find_tcp(fd, ti)))
return -1;
@@ -356,12 +358,12 @@ int flags;
perror("connect");
return -1;
}
- kmemcpy((char*)&tcb, (void *)t, sizeof(tcb));
+ KMCPY(&tcb, t, sizeof(tcb));
ti->ti_win = tcb.rcv_adv;
ti->ti_seq = tcb.snd_nxt - 1;
ti->ti_ack = tcb.rcv_nxt;
- if (send_tcp(nfd, mtu, ti, gwip, TH_SYN) == -1)
+ if (send_tcp(nfd, mtu, (ip_t *)ti, gwip) == -1)
return -1;
(void)write(fd, "Hello World\n", 12);
sleep(2);
OpenPOWER on IntegriCloud