summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/ipsend
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1998-06-20 18:29:38 +0000
committerpeter <peter@FreeBSD.org>1998-06-20 18:29:38 +0000
commitb9ddfe987f1e375cfb3a976c7b73c1ed9bde8cb0 (patch)
treed8de5e580b20b03678d9eff9a6c3978fc37bd2e4 /contrib/ipfilter/ipsend
parentdc2ce9cb96fb984f6bcec8117c0e4d20afad851f (diff)
parent9529c38ad8859b9f325867d97f266101f2c4dca3 (diff)
downloadFreeBSD-src-b9ddfe987f1e375cfb3a976c7b73c1ed9bde8cb0.zip
FreeBSD-src-b9ddfe987f1e375cfb3a976c7b73c1ed9bde8cb0.tar.gz
This commit was generated by cvs2svn to compensate for changes in r37074,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/ipfilter/ipsend')
-rw-r--r--contrib/ipfilter/ipsend/README2
-rw-r--r--contrib/ipfilter/ipsend/ip.c5
-rw-r--r--contrib/ipfilter/ipsend/ipresend.14
-rw-r--r--contrib/ipfilter/ipsend/ipsend.12
-rw-r--r--contrib/ipfilter/ipsend/ipsend.55
-rw-r--r--contrib/ipfilter/ipsend/iptests.c179
6 files changed, 95 insertions, 102 deletions
diff --git a/contrib/ipfilter/ipsend/README b/contrib/ipfilter/ipsend/README
index 6898cdd..198556d 100644
--- a/contrib/ipfilter/ipsend/README
+++ b/contrib/ipfilter/ipsend/README
@@ -5,4 +5,4 @@ http://coombs.anu.edu.au/~avalon/ip-filter.html
Patches, bugs, etc, please send to:
-darrenr@cyber.com.au
+darrenr@pobox.com
diff --git a/contrib/ipfilter/ipsend/ip.c b/contrib/ipfilter/ipsend/ip.c
index 459c09b..6914924 100644
--- a/contrib/ipfilter/ipsend/ip.c
+++ b/contrib/ipfilter/ipsend/ip.c
@@ -7,7 +7,7 @@
*/
#if !defined(lint)
static const char sccsid[] = "%W% %G% (C)1995";
-static const char rcsid[] = "@(#)$Id: ip.c,v 2.0.2.11.2.2 1997/11/28 03:36:47 darrenr Exp $";
+static const char rcsid[] = "@(#)$Id: ip.c,v 2.0.2.11.2.3 1997/12/21 12:17:37 darrenr Exp $";
#endif
#include <errno.h>
#include <stdio.h>
@@ -117,7 +117,6 @@ int frag;
last_gw.s_addr = gwip.s_addr;
iplen = ip->ip_len;
ip->ip_len = htons(iplen);
- ip->ip_off = htons(ip->ip_off);
if (!(frag & 2)) {
if (!ip->ip_v)
ip->ip_v = IPVERSION;
@@ -260,7 +259,7 @@ struct in_addr gwip;
i = sizeof(struct tcpiphdr) / sizeof(long);
- if ((ti->ti_flags == TH_SYN) && !ip->ip_off &&
+ if ((ti->ti_flags == TH_SYN) && !ntohs(ip->ip_off) &&
(lbuf[i] != htonl(0x020405b4))) {
lbuf[i] = htonl(0x020405b4);
bcopy((char *)ip + hlen + thlen, (char *)ip + hlen + thlen + 4,
diff --git a/contrib/ipfilter/ipsend/ipresend.1 b/contrib/ipfilter/ipsend/ipresend.1
index 40f9825..448fa41 100644
--- a/contrib/ipfilter/ipsend/ipresend.1
+++ b/contrib/ipfilter/ipsend/ipresend.1
@@ -92,8 +92,6 @@ option combinations:
.B \-X
The input file is composed of text descriptions of IP packets.
.TP
-.SH FILES
-.DT
.SH SEE ALSO
snoop(1m), tcpdump(8), etherfind(8c), ipftest(1), ipresend(1), iptest(1), bpf(4), dlpi(7p)
.SH DIAGNOSTICS
@@ -103,5 +101,5 @@ Needs to be run as root.
.PP
Not all of the input formats are sufficiently capable of introducing a
wide enough variety of packets for them to be all useful in testing.
-If you find any, please send email to me at darrenr@cyber.com.au
+If you find any, please send email to me at darrenr@pobox.com
diff --git a/contrib/ipfilter/ipsend/ipsend.1 b/contrib/ipfilter/ipsend/ipsend.1
index d99038d..6554e58 100644
--- a/contrib/ipfilter/ipsend/ipsend.1
+++ b/contrib/ipfilter/ipsend/ipsend.1
@@ -106,4 +106,4 @@ ipsend(1), ipresend(1), iptest(1), protocols(4), bpf(4), dlpi(7p)
Needs to be run as root.
.SH BUGS
.PP
-If you find any, please send email to me at darrenr@cyber.com.au
+If you find any, please send email to me at darrenr@pobox.com
diff --git a/contrib/ipfilter/ipsend/ipsend.5 b/contrib/ipfilter/ipsend/ipsend.5
index b6a3e04..9fa4593 100644
--- a/contrib/ipfilter/ipsend/ipsend.5
+++ b/contrib/ipfilter/ipsend/ipsend.5
@@ -392,7 +392,10 @@ Address mask request.
.B maskrep
Address mask reply.
.SH FILES
+/etc/hosts
+.br
/etc/protocols
+.br
/etc/services
-/etc/hosts
.SH SEE ALSO
+ipsend(1), iptest(1), hosts(5), protocols(5), services(5)
diff --git a/contrib/ipfilter/ipsend/iptests.c b/contrib/ipfilter/ipsend/iptests.c
index f12dbad..16c830a 100644
--- a/contrib/ipfilter/ipsend/iptests.c
+++ b/contrib/ipfilter/ipsend/iptests.c
@@ -7,7 +7,7 @@
*/
#if !defined(lint)
static const char sccsid[] = "%W% %G% (C)1995 Darren Reed";
-static const char rcsid[] = "@(#)$Id: iptests.c,v 2.0.2.13.2.1 1997/11/28 03:37:10 darrenr Exp $";
+static const char rcsid[] = "@(#)$Id: iptests.c,v 2.0.2.13.2.2 1997/12/21 12:17:38 darrenr Exp $";
#endif
#include <stdio.h>
#include <unistd.h>
@@ -98,24 +98,21 @@ int ptest;
ip->ip_p = IPPROTO_UDP;
ip->ip_sum = 0;
u = (udphdr_t *)(ip + 1);
- u->uh_sport = 1;
- u->uh_dport = 9;
+ u->uh_sport = htons(1);
+ u->uh_dport = htons(9);
u->uh_sum = 0;
- u->uh_ulen = sizeof(*u) + 4;
- ip->ip_len = sizeof(*ip) + u->uh_ulen;
+ u->uh_ulen = htons(sizeof(*u) + 4);
+ ip->ip_len = sizeof(*ip) + ntohs(u->uh_ulen);
len = ip->ip_len;
nfd = initdevice(dev, u->uh_sport, 1);
- u->uh_sport = htons(u->uh_sport);
- u->uh_dport = htons(u->uh_dport);
- u->uh_ulen = htons(u->uh_ulen);
if (!ptest || (ptest == 1)) {
/*
* Part1: hl < len
*/
ip->ip_id = 0;
printf("1.1. sending packets with ip_hl < ip_len\n");
- for (i = 0; i < ((sizeof(*ip) + u->uh_ulen) >> 2); i++) {
+ for (i = 0; i < ((sizeof(*ip) + ntohs(u->uh_ulen)) >> 2); i++) {
ip->ip_hl = i >> 2;
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d\r", i);
@@ -131,7 +128,7 @@ int ptest;
*/
ip->ip_id = 0;
printf("1.2. sending packets with ip_hl > ip_len\n");
- for (; i < ((sizeof(*ip) * 2 + u->uh_ulen) >> 2); i++) {
+ for (; i < ((sizeof(*ip) * 2 + ntohs(u->uh_ulen)) >> 2); i++) {
ip->ip_hl = i >> 2;
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d\r", i);
@@ -181,10 +178,8 @@ int ptest;
ip->ip_id = 0;
ip->ip_v = IPVERSION;
i = ip->ip_len + 1;
- ip->ip_len = htons(ip->ip_len);
- ip->ip_off = htons(ip->ip_off);
printf("1.5.0 ip_len < packet size (size++, long packets)\n");
- for (; i < (ntohs(ip->ip_len) * 2); i++) {
+ for (; i < (ip->ip_len * 2); i++) {
ip->ip_id = htons(id++);
ip->ip_sum = 0;
ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
@@ -197,7 +192,7 @@ int ptest;
printf("1.5.1 ip_len < packet size (ip_len-, short packets)\n");
for (i = len; i > 0; i--) {
ip->ip_id = htons(id++);
- ip->ip_len = htons(i);
+ ip->ip_len = i;
ip->ip_sum = 0;
ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
(void) send_ether(nfd, (char *)ip, len, gwip);
@@ -216,7 +211,7 @@ int ptest;
printf("1.6.0 ip_len > packet size (increase ip_len)\n");
for (i = len + 1; i < (len * 2); i++) {
ip->ip_id = htons(id++);
- ip->ip_len = htons(i);
+ ip->ip_len = i;
ip->ip_sum = 0;
ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2);
(void) send_ether(nfd, (char *)ip, len, gwip);
@@ -225,7 +220,7 @@ int ptest;
PAUSE();
}
putchar('\n');
- ip->ip_len = htons(len);
+ ip->ip_len = len;
printf("1.6.1 ip_len > packet size (size--, short packets)\n");
for (i = len; i > 0; i--) {
ip->ip_id = htons(id++);
@@ -288,7 +283,7 @@ int ptest;
* about that here.
*/
ip->ip_p = IPPROTO_ICMP;
- ip->ip_off = IP_MF;
+ ip->ip_off = htons(IP_MF);
u->uh_dport = htons(9);
ip->ip_id = htons(id++);
printf("1.8.1 63k packet + 1k fragment at offset 0x1ffe\n");
@@ -299,14 +294,14 @@ int ptest;
ip->ip_len = MIN(768 + 20, mtu - 68);
i = 512;
for (; i < (63 * 1024 + 768); i += 768) {
- ip->ip_off = IP_MF | (i >> 3);
+ ip->ip_off = htons(IP_MF | (i >> 3));
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
fflush(stdout);
PAUSE();
}
ip->ip_len = 896 + 20;
- ip->ip_off = (i >> 3);
+ ip->ip_off = htons(i >> 3);
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
putchar('\n');
@@ -319,7 +314,7 @@ int ptest;
* about that here. (Lossage here)
*/
ip->ip_p = IPPROTO_ICMP;
- ip->ip_off = IP_MF;
+ ip->ip_off = htons(IP_MF);
u->uh_dport = htons(9);
ip->ip_id = htons(id++);
printf("1.8.2 63k packet + 1k fragment at offset 0x1ffe\n");
@@ -333,7 +328,7 @@ int ptest;
ip->ip_len = MIN(768 + 20, mtu - 68);
i = 512;
for (; i < (63 * 1024 + 768); i += 768) {
- ip->ip_off = IP_MF | (i >> 3);
+ ip->ip_off = htons(IP_MF | (i >> 3));
if ((rand() & 0x1f) != 0) {
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
@@ -343,7 +338,7 @@ int ptest;
PAUSE();
}
ip->ip_len = 896 + 20;
- ip->ip_off = (i >> 3);
+ ip->ip_off = htons(i >> 3);
if ((rand() & 0x1f) != 0) {
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
@@ -359,7 +354,7 @@ int ptest;
* about that here.
*/
ip->ip_p = IPPROTO_ICMP;
- ip->ip_off = IP_MF;
+ ip->ip_off = htons(IP_MF);
u->uh_dport = htons(9);
ip->ip_id = htons(id++);
printf("1.8.3 33k packet\n");
@@ -370,14 +365,14 @@ int ptest;
ip->ip_len = MIN(768 + 20, mtu - 68);
i = 512;
for (; i < (32 * 1024 + 768); i += 768) {
- ip->ip_off = IP_MF | (i >> 3);
+ ip->ip_off = htons(IP_MF | (i >> 3));
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
fflush(stdout);
PAUSE();
}
ip->ip_len = 896 + 20;
- ip->ip_off = (i >> 3);
+ ip->ip_off = htons(i >> 3);
(void) send_ip(nfd, mtu, ip, gwip, 1);
printf("%d\r", i);
putchar('\n');
@@ -391,7 +386,7 @@ int ptest;
* Part9: off & 0x8000 == 0x8000
*/
ip->ip_id = 0;
- ip->ip_off = 0x8000;
+ ip->ip_off = htons(0x8000);
printf("1.9. ip_off & 0x8000 == 0x8000\n");
(void) send_ip(nfd, mtu, ip, gwip, 1);
fflush(stdout);
@@ -440,7 +435,7 @@ int ptest;
u_char *s;
s = (u_char *)(ip + 1);
- nfd = initdevice(dev, 1, 1);
+ nfd = initdevice(dev, htons(1), 1);
ip->ip_hl = 6;
ip->ip_len = ip->ip_hl << 2;
@@ -539,7 +534,7 @@ int ptest;
ip->ip_sum = 0;
ip->ip_len = sizeof(*ip) + sizeof(*icp);
icp = (struct icmp *)((char *)ip + (ip->ip_hl << 2));
- nfd = initdevice(dev, 1, 1);
+ nfd = initdevice(dev, htons(1), 1);
if (!ptest || (ptest == 1)) {
/*
@@ -731,20 +726,20 @@ int ptest;
ip->ip_p = IPPROTO_UDP;
ip->ip_sum = 0;
u = (udphdr_t *)((char *)ip + (ip->ip_hl << 2));
- u->uh_sport = 1;
- u->uh_dport = 1;
- u->uh_ulen = sizeof(*u) + 4;
+ u->uh_sport = htons(1);
+ u->uh_dport = htons(1);
+ u->uh_ulen = htons(sizeof(*u) + 4);
nfd = initdevice(dev, u->uh_sport, 1);
if (!ptest || (ptest == 1)) {
/*
* Test 1. ulen > packet
*/
- u->uh_ulen = sizeof(*u) + 4;
- ip->ip_len = (ip->ip_hl << 2) + u->uh_ulen;
+ u->uh_ulen = htons(sizeof(*u) + 4);
+ ip->ip_len = (ip->ip_hl << 2) + ntohs(u->uh_ulen);
printf("4.1 UDP uh_ulen > packet size - short packets\n");
- for (i = u->uh_ulen * 2; i > sizeof(*u) + 4; i--) {
- u->uh_ulen = i;
+ for (i = ntohs(u->uh_ulen) * 2; i > sizeof(*u) + 4; i--) {
+ u->uh_ulen = htons(i);
(void) send_udp(nfd, 1500, ip, gwip);
printf("%d\r", i);
fflush(stdout);
@@ -757,10 +752,10 @@ int ptest;
/*
* Test 2. ulen < packet
*/
- u->uh_ulen = sizeof(*u) + 4;
- ip->ip_len = (ip->ip_hl << 2) + u->uh_ulen;
+ u->uh_ulen = htons(sizeof(*u) + 4);
+ ip->ip_len = (ip->ip_hl << 2) + ntohs(u->uh_ulen);
printf("4.2 UDP uh_ulen < packet size - short packets\n");
- for (i = u->uh_ulen * 2; i > sizeof(*u) + 4; i--) {
+ for (i = ntohs(u->uh_ulen) * 2; i > sizeof(*u) + 4; i--) {
ip->ip_len = i;
(void) send_udp(nfd, 1500, ip, gwip);
printf("%d\r", i);
@@ -776,7 +771,7 @@ int ptest;
* sport = 32768, sport = 65535
*/
u->uh_ulen = sizeof(*u) + 4;
- ip->ip_len = (ip->ip_hl << 2) + u->uh_ulen;
+ ip->ip_len = (ip->ip_hl << 2) + ntohs(u->uh_ulen);
printf("4.3.1 UDP sport = 0\n");
u->uh_sport = 0;
(void) send_udp(nfd, 1500, ip, gwip);
@@ -784,26 +779,26 @@ int ptest;
fflush(stdout);
PAUSE();
printf("4.3.2 UDP sport = 1\n");
- u->uh_sport = 1;
+ u->uh_sport = htons(1);
(void) send_udp(nfd, 1500, ip, gwip);
printf("1\n");
fflush(stdout);
PAUSE();
printf("4.3.3 UDP sport = 32767\n");
- u->uh_sport = 32767;
+ u->uh_sport = htons(32767);
(void) send_udp(nfd, 1500, ip, gwip);
printf("32767\n");
fflush(stdout);
PAUSE();
printf("4.3.4 UDP sport = 32768\n");
- u->uh_sport = 32768;
+ u->uh_sport = htons(32768);
(void) send_udp(nfd, 1500, ip, gwip);
printf("32768\n");
putchar('\n');
fflush(stdout);
PAUSE();
printf("4.3.5 UDP sport = 65535\n");
- u->uh_sport = 65535;
+ u->uh_sport = htons(65535);
(void) send_udp(nfd, 1500, ip, gwip);
printf("65535\n");
fflush(stdout);
@@ -815,9 +810,9 @@ int ptest;
* Test 4: dport = 0, dport = 1, dport = 32767
* dport = 32768, dport = 65535
*/
- u->uh_ulen = sizeof(*u) + 4;
- u->uh_sport = 1;
- ip->ip_len = (ip->ip_hl << 2) + u->uh_ulen;
+ u->uh_ulen = ntohs(sizeof(*u) + 4);
+ u->uh_sport = htons(1);
+ ip->ip_len = (ip->ip_hl << 2) + ntohs(u->uh_ulen);
printf("4.4.1 UDP dport = 0\n");
u->uh_dport = 0;
(void) send_udp(nfd, 1500, ip, gwip);
@@ -825,25 +820,25 @@ int ptest;
fflush(stdout);
PAUSE();
printf("4.4.2 UDP dport = 1\n");
- u->uh_dport = 1;
+ u->uh_dport = htons(1);
(void) send_udp(nfd, 1500, ip, gwip);
printf("1\n");
fflush(stdout);
PAUSE();
printf("4.4.3 UDP dport = 32767\n");
- u->uh_dport = 32767;
+ u->uh_dport = htons(32767);
(void) send_udp(nfd, 1500, ip, gwip);
printf("32767\n");
fflush(stdout);
PAUSE();
printf("4.4.4 UDP dport = 32768\n");
- u->uh_dport = 32768;
+ u->uh_dport = htons(32768);
(void) send_udp(nfd, 1500, ip, gwip);
printf("32768\n");
fflush(stdout);
PAUSE();
printf("4.4.5 UDP dport = 65535\n");
- u->uh_dport = 65535;
+ u->uh_dport = htons(65535);
(void) send_udp(nfd, 1500, ip, gwip);
printf("65535\n");
fflush(stdout);
@@ -856,7 +851,7 @@ int ptest;
* sizeof(ip_t)
*/
printf("4.5 UDP 20 <= MTU <= 32\n");
- for (i = sizeof(*ip); i <= u->uh_ulen; i++) {
+ for (i = sizeof(*ip); i <= ntohs(u->uh_ulen); i++) {
(void) send_udp(nfd, i, ip, gwip);
printf("%d\r", i);
fflush(stdout);
@@ -885,12 +880,12 @@ int ptest;
t->th_x2 = 0;
#endif
t->th_off = 0;
- t->th_sport = 1;
- t->th_dport = 1;
- t->th_win = 4096;
+ t->th_sport = htons(1);
+ t->th_dport = htons(1);
+ t->th_win = htons(4096);
t->th_urp = 0;
t->th_sum = 0;
- t->th_seq = 1;
+ t->th_seq = htonl(1);
t->th_ack = 0;
ip->ip_len = sizeof(ip_t) + sizeof(tcphdr_t);
nfd = initdevice(dev, t->th_sport, 1);
@@ -919,37 +914,37 @@ int ptest;
* seq = 0xa000000, seq = 0xffffffff
*/
printf("5.2.1 TCP seq = 0\n");
- t->th_seq = 0;
+ t->th_seq = htonl(0);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.2.2 TCP seq = 1\n");
- t->th_seq = 1;
+ t->th_seq = htonl(1);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.2.3 TCP seq = 0x7fffffff\n");
- t->th_seq = 0x7fffffff;
+ t->th_seq = htonl(0x7fffffff);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.2.4 TCP seq = 0x80000000\n");
- t->th_seq = 0x80000000;
+ t->th_seq = htonl(0x80000000);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.2.5 TCP seq = 0xc0000000\n");
- t->th_seq = 0xc0000000;
+ t->th_seq = htonl(0xc0000000);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.2.6 TCP seq = 0xffffffff\n");
- t->th_seq = 0xffffffff;
+ t->th_seq = htonl(0xffffffff);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
@@ -968,31 +963,31 @@ int ptest;
PAUSE();
printf("5.3.2 TCP ack = 1\n");
- t->th_ack = 1;
+ t->th_ack = htonl(1);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.3.3 TCP ack = 0x7fffffff\n");
- t->th_ack = 0x7fffffff;
+ t->th_ack = htonl(0x7fffffff);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.3.4 TCP ack = 0x80000000\n");
- t->th_ack = 0x80000000;
+ t->th_ack = htonl(0x80000000);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.3.5 TCP ack = 0xc0000000\n");
- t->th_ack = 0xc0000000;
+ t->th_ack = htonl(0xc0000000);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.3.6 TCP ack = 0xffffffff\n");
- t->th_ack = 0xffffffff;
+ t->th_ack = htonl(0xffffffff);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
@@ -1004,19 +999,19 @@ int ptest;
* Test 4: win = 0, win = 32768, win = 65535
*/
printf("5.4.1 TCP win = 0\n");
- t->th_seq = 0;
+ t->th_seq = htonl(0);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.4.2 TCP win = 32768\n");
- t->th_seq = 0x7fff;
+ t->th_seq = htonl(0x7fff);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.4.3 TCP win = 65535\n");
- t->th_win = 0xffff;
+ t->th_win = htons(0xffff);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
@@ -1061,7 +1056,7 @@ int ptest;
}
KMCPY(&tcb, tcbp, sizeof(tcb));
ti.ti_win = tcb.rcv_adv;
- ti.ti_seq = tcb.snd_nxt - 1;
+ ti.ti_seq = htonl(tcb.snd_nxt - 1);
ti.ti_ack = tcb.rcv_nxt;
if (!ptest || (ptest == 5)) {
@@ -1075,7 +1070,7 @@ int ptest;
(void) send_tcp(nfd, mtu, ip, gwip);
PAUSE();
- t->th_seq = tcb.snd_nxt;
+ t->th_seq = htonl(tcb.snd_nxt);
ip->ip_len = sizeof(ip_t) + sizeof(tcphdr_t) + 1;
t->th_urp = htons(0x7fff);
(void) send_tcp(nfd, mtu, ip, gwip);
@@ -1086,7 +1081,7 @@ int ptest;
t->th_urp = htons(0xffff);
(void) send_tcp(nfd, mtu, ip, gwip);
PAUSE();
- t->th_urp = htons(0);
+ t->th_urp = 0;
t->th_flags &= ~TH_URG;
ip->ip_len = sizeof(ip_t) + sizeof(tcphdr_t);
}
@@ -1112,8 +1107,8 @@ int ptest;
}
skip_five_and_six:
#endif
- t->th_seq = 1;
- t->th_ack = 1;
+ t->th_seq = htonl(1);
+ t->th_ack = htonl(1);
t->th_off = 0;
if (!ptest || (ptest == 7)) {
@@ -1129,32 +1124,32 @@ skip_five_and_six:
PAUSE();
printf("5.7.2 TCP sport = 1\n");
- t->th_sport = 1;
+ t->th_sport = htons(1);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.7.3 TCP sport = 32767\n");
- t->th_sport = 32767;
+ t->th_sport = htons(32767);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.7.4 TCP sport = 32768\n");
- t->th_sport = 32768;
+ t->th_sport = htons(32768);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.7.5 TCP sport = 65535\n");
- t->th_sport = 65535;
+ t->th_sport = htons(65535);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
}
if (!ptest || (ptest == 8)) {
- t->th_sport = 1;
+ t->th_sport = htons(1);
t->th_flags = TH_SYN;
/*
* Test 8: dport = 0, dport = 1, dport = 32767
@@ -1167,25 +1162,25 @@ skip_five_and_six:
PAUSE();
printf("5.8.2 TCP dport = 1\n");
- t->th_dport = 1;
+ t->th_dport = htons(1);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.8.3 TCP dport = 32767\n");
- t->th_dport = 32767;
+ t->th_dport = htons(32767);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.8.4 TCP dport = 32768\n");
- t->th_dport = 32768;
+ t->th_dport = htons(32768);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
printf("5.8.5 TCP dport = 65535\n");
- t->th_dport = 65535;
+ t->th_dport = htons(65535);
(void) send_tcp(nfd, mtu, ip, gwip);
fflush(stdout);
PAUSE();
@@ -1229,14 +1224,12 @@ int ptest;
ip->ip_p = IPPROTO_UDP;
ip->ip_sum = 0;
u = (udphdr_t *)(ip + 1);
- u->uh_sport = 1;
- u->uh_dport = 9;
+ u->uh_sport = htons(1);
+ u->uh_dport = htons(9);
u->uh_sum = 0;
nfd = initdevice(dev, u->uh_sport, 1);
- u->uh_sport = htons(u->uh_sport);
- u->uh_dport = htons(u->uh_dport);
- u->uh_ulen = 7168;
+ u->uh_ulen = htons(7168);
printf("6. Exhaustive mbuf test.\n");
printf(" Send 7k packet in 768 & 128 byte fragments, 128 times.\n");
@@ -1247,7 +1240,7 @@ int ptest;
*/
ip->ip_len = sizeof(*ip) + 768 + sizeof(*u);
ip->ip_hl = sizeof(*ip) >> 2;
- ip->ip_off = IP_MF;
+ ip->ip_off = htons(IP_MF);
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d %d\r", i, 0);
fflush(stdout);
@@ -1256,7 +1249,7 @@ int ptest;
* And again using 128 byte chunks.
*/
ip->ip_len = sizeof(*ip) + 128 + sizeof(*u);
- ip->ip_off = IP_MF;
+ ip->ip_off = htons(IP_MF);
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d %d\r", i, 0);
fflush(stdout);
@@ -1264,7 +1257,7 @@ int ptest;
for (j = 768; j < 3584; j += 768) {
ip->ip_len = sizeof(*ip) + 768;
- ip->ip_off = IP_MF|(j>>3);
+ ip->ip_off = htons(IP_MF|(j>>3));
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d %d\r", i, j);
fflush(stdout);
@@ -1272,7 +1265,7 @@ int ptest;
ip->ip_len = sizeof(*ip) + 128;
for (k = j - 768; k < j; k += 128) {
- ip->ip_off = IP_MF|(k>>3);
+ ip->ip_off = htons(IP_MF|(k>>3));
(void) send_ip(nfd, 1500, ip, gwip, 1);
printf("%d %d\r", i, k);
fflush(stdout);
@@ -1326,7 +1319,7 @@ int ptest;
for (s = (u_char *)pip, j = 0; j < sizeof(tbuf); j++, s++)
*s = (rand() >> 13) & 0xff;
pip->ip_v = IPVERSION;
- pip->ip_off &= 0xc000;
+ pip->ip_off &= htons(0xc000);
bcopy((char *)&ip->ip_dst, (char *)&pip->ip_dst,
sizeof(struct in_addr));
pip->ip_sum = 0;
OpenPOWER on IntegriCloud