Subject: Re: Fw: Changing MAC addresses on ethernet interfaces?
To: None <tech-net@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-net
Date: 01/16/2001 23:48:48
In article <20010116112800.Z475@dr-evil.shagadelic.org>,
Jason R Thorpe <thorpej@zembu.com> wrote:
>On Tue, Jan 16, 2001 at 01:55:44PM -0500, Andrew Gillham wrote:
>
> > > Is anyone planning to add a mechanism to override the UAA on an
> > > ethernet card?
>
>I just whipped up a patch that should allow this in -current, but
>it's tedious to use without some other changes... but, here it is:
This will only work if we make struct ifaddr use struct sockaddr_storage
It currently uses struct sockaddr and struct sockaddr_dl does not fit in
it [by one byte; argh!]
christos
>Index: if_ethersubr.c
>===================================================================
>RCS file: /cvsroot/syssrc/sys/net/if_ethersubr.c,v
>retrieving revision 1.74
>diff -c -r1.74 if_ethersubr.c
>*** if_ethersubr.c 2000/12/26 23:54:34 1.74
>--- if_ethersubr.c 2001/01/16 19:27:02
>***************
>*** 1148,1153 ****
>--- 1148,1171 ----
> case SIOCSIFADDR:
> ifp->if_flags |= IFF_UP;
> switch (ifa->ifa_addr->sa_family) {
>+ case AF_LINK:
>+ {
>+ struct sockaddr_dl *sdl =
>+ (struct sockaddr_dl *) ifa->ifa_addr;
>+
>+ if (sdl->sdl_type != IFT_ETHER ||
>+ sdl->sdl_alen != ifp->if_addrlen) {
>+ error = EINVAL;
>+ break;
>+ }
>+
>+ memcpy(LLADDR(ifp->if_sadl), LLADDR(sdl),
>+ ifp->if_addrlen);
>+
>+ /* Set new address. */
>+ error = (*ifp->if_init)(ifp);
>+ break;
>+ }
> #ifdef INET
> case AF_INET:
> if ((error = (*ifp->if_init)(ifp)) != 0)
>
>--
> -- Jason R. Thorpe <thorpej@zembu.com>