Subject: bin/4215: ipsend sends non-IP packets on little-endian machines
To: None <gnats-bugs@gnats.netbsd.org>
From: Dave Huang <khym@bga.com>
List: netbsd-bugs
Date: 10/03/1997 17:44:23
>Number:         4215
>Category:       bin
>Synopsis:       ipsend sends non-IP packets on little-endian machines
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct  3 16:05:02 1997
>Last-Modified:
>Originator:     Dave Huang
>Organization:
Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 21 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Release:        NetBSD-current as of October 3, 1997
>Environment:
	
System: NetBSD dahan.metonymy.com 1.2G NetBSD 1.2G (SPIFF) #135: Tue Sep 30 23:32:15 CDT 1997 khym@dahan.metonymy.com:/usr/src.local/sys/arch/i386/compile/SPIFF i386


>Description:
ipsend doesn't convert ETHERTYPE_IP into network byte order before
sending it out the wire, so it ends up sending stuff like:
     17:40:08.576649 0:a0:24:1:de:fa sap 00 > 0:a0:24:1:de:fa sap 45 I (s=0,r=10,P) len=16
                         0000 0000 3c00 6865 0a01 0142 0a01 0142
instead of:
     17:40:10.296121 10.1.1.66 > 10.1.1.66: ip-proto-0 0

>How-To-Repeat:
Watch the network with tcpdump while sending packets with ipsend. e.g.

tcpdump -i ep0&
ipsend -d ep0 10.1.1.66

>Fix:
--- /usr/src/usr.sbin/ipf/ipsend/ip.c	Mon Sep 22 06:32:26 1997
+++ ip.c	Sat Sep 27 17:34:47 1997
@@ -73,7 +73,7 @@
 		perror("arp");
 		return -2;
 	    }
-	eh->ether_type = ETHERTYPE_IP;
+	eh->ether_type = htons(ETHERTYPE_IP);
 	last_gw.s_addr = gwip.s_addr;
 	err = sendip(nfd, s, sizeof(*eh) + len);
 	return err;
@@ -108,7 +108,7 @@
 		return -2;
 	    }
 	bcopy((char *)&eh->ether_dhost, last_arp, sizeof(last_arp));
-	eh->ether_type = ETHERTYPE_IP;
+	eh->ether_type = htons(ETHERTYPE_IP);
 
 	bcopy((char *)ip, (char *)&ipsv, sizeof(*ip));
 	last_gw.s_addr = gwip.s_addr;

>Audit-Trail:
>Unformatted: