Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Apr 2002 10:01:33 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        freebsd-stable@freebsd.org
Cc:        Ruslan Ermilov <ru@freebsd.org>
Subject:   Ethernet address format changes.
Message-ID:  <200204051801.g35I1Xl52628@apollo.backplane.com>

next in thread | raw e-mail | index | archive | help
    It would appear that someone has changed ifconfig() to use ether_ntoa()
    when printing an interface's MAC address.  In 4.x.

    Unfortunately, this has had the side effect of changing the format
    from %02x:%02x:%02x:%02x:%02x:%20x to %x:%x:%x:%x:%x:%x.  The new 
    format is non-standard.  I will occassionally see it printed in a
    physical label attached to a machine, but I've never seen anything
    other then %02x displayed on a computer until now.

    I just got an email from a friend of mine who indicated that the
    change broke a bunch of his scripts.  I would not be surprised if
    this change breaks other people's scripts as well.

    I would either like to fix ether_ntoa(), or back-out the change that
    was made to ifconfig.  Since the change Ruslan made to ifconfig seems
    reasonable, my suggested fix to ether_ntoa() is shown below.

    Comments?

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>

Index: net/ether_addr.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/net/ether_addr.c,v
retrieving revision 1.10.2.4
diff -u -r1.10.2.4 ether_addr.c
--- net/ether_addr.c	7 Mar 2002 03:33:23 -0000	1.10.2.4
+++ net/ether_addr.c	5 Apr 2002 17:57:16 -0000
@@ -111,15 +111,15 @@
  * Convert a binary representation of an ethernet address to
  * an ASCII string.
  */
-char
-*ether_ntoa(n)
+char *ether_ntoa(n)
 	const struct ether_addr *n;
 {
         int i;
 	static char a[18];
 
-        i = sprintf(a,"%x:%x:%x:%x:%x:%x",n->octet[0],n->octet[1],n->octet[2],
-                                          n->octet[3],n->octet[4],n->octet[5]);
+        i = sprintf(a,"%02x:%02x:%02x:%02x:%02x:%02x",
+			n->octet[0],n->octet[1],n->octet[2],
+			n->octet[3],n->octet[4],n->octet[5]);
         if (i < 11)
                 return (NULL);
         return ((char *)&a);

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




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