Fixes MAC addr formatting
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 22 Jan 2014 18:59:50 +0000 (10:59 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 22 Jan 2014 19:13:15 +0000 (11:13 -0800)
This is actually really important.  etherbind eventually calls
netifread, and translates the string back and forth.  So writing it out
in decimal then reading it back as hex resulted in some messed up
bindings, where our card thought it had the wrong address.  Ah, strings.

kern/drivers/dev/ether.c
kern/src/net/netif.c

index 3649c59..29eb3f7 100644 (file)
@@ -706,7 +706,7 @@ etherreset(void)
                                register_dev_irq(ether->irq, ether->interrupt, ether);
 
                        i = snprintf(buf, sizeof(buf),
-                                    "#l%d: %s: %dMbps port 0x%lx irq %lu", ctlrno,
+                                    "#l%d: %s: %dMbps port 0x%x irq %u", ctlrno,
                                     ether->type, ether->netif.mbps, ether->port,
                                     ether->irq);
                        /* Looks like this is for printing MMIO addrs */
@@ -719,7 +719,7 @@ etherreset(void)
                                              ether->size);
                        #endif
                        i += snprintf(buf + i, sizeof(buf) - i,
-                                     ": %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
+                                     ": %02.2x:%02.2x:%02.2x:%02.2x:%02.2x:%02.2x",
                                      ether->ea[0], ether->ea[1], ether->ea[2],
                                      ether->ea[3], ether->ea[4], ether->ea[5]);
                        snprintf(buf + i, sizeof(buf) - i, "\n");
index cb985f2..57c430b 100644 (file)
@@ -237,7 +237,7 @@ netifread(struct netif *nif, struct chan *c, void *a, long n, uint32_t offset)
                j += snprintf(p+j, READSTR-j, "mbps: %d\n", nif->mbps);
                j += snprintf(p+j, READSTR-j, "addr: ");
                for(i = 0; i < nif->alen; i++)
-                       j += snprintf(p+j, READSTR-j, "%2.2u", nif->addr[i]);
+                       j += snprintf(p+j, READSTR-j, "%02.2x", nif->addr[i]);
                snprintf(p+j, READSTR-j, "\n");
                n = readstr(offset, a, n, p);
                kfree(p);
@@ -248,7 +248,7 @@ netifread(struct netif *nif, struct chan *c, void *a, long n, uint32_t offset)
                        return 0;
                j = 0;
                for(i = 0; i < nif->alen; i++)
-                       j += snprintf(p+j, READSTR-j, "%2.2u", nif->addr[i]);
+                       j += snprintf(p+j, READSTR-j, "%02.2x", nif->addr[i]);
                n = readstr(offset, a, n, p);
                kfree(p);
                return n;