Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 May 1996 22:49:42 -0500
From:      Jim Fleming <JimFleming@unety.net>
To:        "'FreeBSD-hackers@freebsd.org'" <FreeBSD-hackers@freebsd.org>
Subject:   IPv8 Tutorial #1: Minimal IPv8 hack
Message-ID:  <01BB3A0B.FC5C9DC0@webster.unety.net>

next in thread | raw e-mail | index | archive | help

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 *);
<<<INSERT HERE>>>
	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...;-)





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?01BB3A0B.FC5C9DC0>