Getting 4.2bsd to work with subnets

Root Boy Jim rbj at uunet.UU.NET
Tue Feb 26 16:16:08 AEST 1991


In article <1991Feb22.115215.26645 at newcastle.ac.uk> d9015t at colman.newcastle.ac.uk (J.P.O'Broin) writes:
>This machine runs 4.2nix, a 4.2bsd copy, and I am trying to link it up
>to the Ethernet. We run a class B network (ie. xxx.yyy.zzz.station id), 
>and hence we're subnetted. 
>I understand that 4.2bsd doesn't understand subnets (and hence there is
>no obvious way of setting netmask using ifconfig), but our network is
>fairly static, and we want to link to a specific gatway. Can I setup 
>the machine for this.

I had to do this once. The solution is to pretend that all
non-Class-A addresses (and you really only care about one,
localhost 127.0.0.1) are Class C addresses.

You need to modify netinet/in.c. In it you will find routines which
(staticly) rip apart (or build) addresses based on their class.

Get a copy of the 4.2 source file from someone (I don't have it, but
it's freely redistributable), and disassemble the routines that seem to
use these macros. Then patch them to do the right thing.

Here is an excerpt from the Tahoe distribution. The 4.2 code
will not have the loop looking for subnets at the bottom.

My changes are conditional on the symbol FAKESUBNET.

/*
 * Return the network number from an internet address.
 */
u_long
in_netof(in)
        struct in_addr in;
{
        register u_long i = ntohl(in.s_addr);
        register u_long net;
        register struct in_ifaddr *ia;

        if (IN_CLASSA(i))
                net = i & IN_CLASSA_NET;
#ifndef FAKESUBNET				/*FAKESUBNET*/
        else if (IN_CLASSB(i))
                net = i & IN_CLASSB_NET;
        else if (IN_CLASSC(i))
                net = i & IN_CLASSC_NET;
        else
                return (0);
#else						/*FAKESUBNET*/
	else					/*FAKESUBNET*/
                net = i & IN_CLASSC_NET;	/*FAKESUBNET*/
#endif						/*FAKESUBNET*/

        /*
         * Check whether network is a subnet;
         * if so, return subnet number.
         */
        for (ia = in_ifaddr; ia; ia = ia->ia_next)
                if (net == ia->ia_net)
                        return (i & ia->ia_subnetmask);
        return (net);
}


-- 
		[rbj at uunet 1] stty sane
		unknown mode: sane



More information about the Comp.unix.wizards mailing list