Date: Wed, 24 Oct 2001 10:30:01 -0700 (PDT) From: Ruslan Ermilov <ru@FreeBSD.ORG> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/31476: ifconfig's lladdr is ethernet specific Message-ID: <200110241730.f9OHU1m67834@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/31476; it has been noted by GNATS. From: Ruslan Ermilov <ru@FreeBSD.ORG> To: tinguely@web.cs.ndsu.nodak.edu Cc: FreeBSD-gnats-submit@FreeBSD.ORG, tinguely@rrnet.com Subject: Re: bin/31476: ifconfig's lladdr is ethernet specific Date: Wed, 24 Oct 2001 20:25:17 +0300 On Wed, Oct 24, 2001 at 10:02:50AM -0500, tinguely@web.cs.ndsu.nodak.edu wrote: > > ifconfig's lladdr feature that allows the setting of the link-level > address on an interface. lladdr is documented to not be > ethernet-specific, but the implementation uses ether_aton() which > requires the link level address to be EXACTLY ETHER_ADDR_LEN in > length. > [...] > I added a routine to ifconfig called generic_atoi that will > allow abitraty length link-level addresses. generic_atoi() will > assume ETHER_ADDR_LEN length if the caller does not include > an integer to get the count of octets in the specified link-level > address. > Can't we just use link_addr(3) for that? Here's the patch (lightly tested) for RELENG_4: Index: ifconfig.c =================================================================== RCS file: /home/ncvs/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.51.2.13 diff -u -p -r1.51.2.13 ifconfig.c --- ifconfig.c 2001/08/20 18:38:41 1.51.2.13 +++ ifconfig.c 2001/10/24 17:24:09 @@ -1066,17 +1066,24 @@ setiflladdr(val, dummy, s, afp) int s; const struct afswtch *afp; { - struct ether_addr *ea; + char *newval; + struct sockaddr_dl sdl; - ea = ether_aton(val); - if (ea == NULL) { + if ((newval = malloc(strlen(val) + 1)) == NULL) + errx(1, "malloc failed"); + newval[0] = ':'; + strcpy(newval + 1, val); + sdl.sdl_len = sizeof(sdl); + link_addr(newval, &sdl); + free(newval); + if (sdl.sdl_alen > sizeof(ifr.ifr_addr.sa_data)) { warn("malformed link-level address"); return; } strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); - ifr.ifr_addr.sa_len = ETHER_ADDR_LEN; + ifr.ifr_addr.sa_len = sdl.sdl_alen; ifr.ifr_addr.sa_family = AF_LINK; - bcopy(ea, ifr.ifr_addr.sa_data, ETHER_ADDR_LEN); + bcopy(LLADDR(&sdl), ifr.ifr_addr.sa_data, sdl.sdl_alen); if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ifr) < 0) warn("ioctl (set lladdr)"); Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200110241730.f9OHU1m67834>