From owner-freebsd-hackers Sat May 4 20:52:27 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id UAA07268 for hackers-outgoing; Sat, 4 May 1996 20:52:27 -0700 (PDT) Received: from doorstep.unety.net (root@usi-00-10.Naperville.unety.net [204.70.107.30]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id UAA07259 for ; Sat, 4 May 1996 20:52:25 -0700 (PDT) Received: from webster.unety.net (webster.unety.net [206.31.202.8]) by doorstep.unety.net (8.6.9/8.6.9) with SMTP id WAA08246 for ; Sat, 4 May 1996 22:46:05 -0500 Received: by webster.unety.net with Microsoft Mail id <01BB3A0B.FC5C9DC0@webster.unety.net>; Sat, 4 May 1996 22:49:43 -0500 Message-ID: <01BB3A0B.FC5C9DC0@webster.unety.net> From: Jim Fleming To: "'FreeBSD-hackers@freebsd.org'" Subject: IPv8 Tutorial #1: Minimal IPv8 hack Date: Sat, 4 May 1996 22:49:42 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk IPv8 Tutorial #1: Minimal IPv8 Hack --------------------------------------------------- A few people have asked for a minimal hack for FreeBSD to process IPv8 packets in case they arrive at your interface. Here is a very MINIMAL modification that can be added to: /usr/src/sys/netinet/ip_input.c It does not require the IPv8 header files or any other variables or IPv8 routines. 185,205d184 < < /* Detect and fix IPv8 packets */ < if(ip->ip_v & 8){ < if(ip->ip_v & 4){ < /* Drop packets with options */ < ipstat.ips_badvers++; < goto bad; < } < else{ < /* Restore IPv4 version and header length */ < ip->ip_v = 4; < ip->ip_hl = 5; < } < /* Compute a good checksum */ < ip->ip_sum = 0; < ip->ip_sum = in_cksum(m,ip->ip_hl<<2); < } < /* The IPv8 packet is now IPv4 compatible */ < This hack can be placed near line #184. ip = mtod(m, struct ip *); <<>> if (ip->ip_v != IPVERSION) { ipstat.ips_badvers++; goto bad; } This small piece of code checks for IPv8 packets and for any simple IPv8 packet (without options) it fixes the borrowed fields and makes the packet look like a valid IPv4 packet. The IPv4 protocol processing continues and does not know the difference. (see also http://comm.unety.net/US/IL/Naperville/Unir) The above example, is also a good way to test weather you can make source changes and rebuild your kernel. Obviously, more elaborate changes could be added to the system to skip the checksum processing and to handle IPv8 packets with IPv4 options. Those additions are left as an exercise for the reader...;-)