aboutsummaryrefslogtreecommitdiffstats
path: root/lib/vsprintf.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2010-01-07 06:43:50 -0500
committerDavid S. Miller <davem@davemloft.net>2010-01-07 19:58:08 -0500
commitbc7259a2ce764ea16200eb9e53f6e136e918d065 (patch)
treefd8dede3d068f151051b49ee5efd6d147c518dca /lib/vsprintf.c
parentcf30273bea4a9d368a31869ccc6ad618e4413b66 (diff)
lib/vsprintf.c: Add %pMF to format FDDI bit reversed MAC addresses
On Mon, 2010-01-04 at 23:43 +0000, Maciej W. Rozycki wrote: > The example below shows an address, and the sequence of bits or symbols > that would be transmitted when the address is used in the Source Address > or Destination Address fields on the MAC header. The transmission line > shows the address bits in the order transmitted, from left to right. For > IEEE 802 LANs these correspond to actual bits on the medium. The FDDI > symbols line shows how the FDDI PHY sends the address bits as encoded > symbols. > > MSB: 35:7B:12:00:00:01 > Canonical: AC-DE-48-00-00-80 > Transmission: 00110101 01111011 00010010 00000000 00000000 00000001 > FDDI Symbols: 35 7B 12 00 00 01" > > Please note that this address has its group bit clear. > > This notation is also defined in the "FDDI MEDIA ACCESS CONTROL-2 > (MAC-2)" (X3T9/92-120) document although that book does not have a need > to use the MSB form and it's skipped. Adds 6 bytes to object size for x86 New: $ size lib/vsprintf.o text data bss dec hex filename 8664 0 2 8666 21da lib/vsprintf.o $ size lib/vsprintf.o text data bss dec hex filename 8658 0 2 8660 21d4 lib/vsprintf.o Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/vsprintf.c')
-rw-r--r--lib/vsprintf.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d4996cf46eb6..dc48d2b32ebd 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -25,6 +25,7 @@
25#include <linux/kallsyms.h> 25#include <linux/kallsyms.h>
26#include <linux/uaccess.h> 26#include <linux/uaccess.h>
27#include <linux/ioport.h> 27#include <linux/ioport.h>
28#include <linux/bitrev.h>
28#include <net/addrconf.h> 29#include <net/addrconf.h>
29 30
30#include <asm/page.h> /* for PAGE_SIZE */ 31#include <asm/page.h> /* for PAGE_SIZE */
@@ -681,11 +682,21 @@ static char *mac_address_string(char *buf, char *end, u8 *addr,
681 char mac_addr[sizeof("xx:xx:xx:xx:xx:xx")]; 682 char mac_addr[sizeof("xx:xx:xx:xx:xx:xx")];
682 char *p = mac_addr; 683 char *p = mac_addr;
683 int i; 684 int i;
685 bool bitrev;
686 char separator;
687
688 if (fmt[1] == 'F') { /* FDDI canonical format */
689 bitrev = true;
690 separator = '-';
691 } else {
692 bitrev = false;
693 separator = ':';
694 }
684 695
685 for (i = 0; i < 6; i++) { 696 for (i = 0; i < 6; i++) {
686 p = pack_hex_byte(p, addr[i]); 697 p = pack_hex_byte(p, bitrev ? bitrev8(addr[i]) : addr[i]);
687 if (fmt[0] == 'M' && i != 5) 698 if (fmt[0] == 'M' && i != 5)
688 *p++ = ':'; 699 *p++ = separator;
689 } 700 }
690 *p = '\0'; 701 *p = '\0';
691 702
@@ -896,6 +907,10 @@ static char *uuid_string(char *buf, char *end, const u8 *addr,
896 * - 'M' For a 6-byte MAC address, it prints the address in the 907 * - 'M' For a 6-byte MAC address, it prints the address in the
897 * usual colon-separated hex notation 908 * usual colon-separated hex notation
898 * - 'm' For a 6-byte MAC address, it prints the hex address without colons 909 * - 'm' For a 6-byte MAC address, it prints the hex address without colons
910 * - 'MF' For a 6-byte MAC FDDI address, it prints the address
911 * with a dash-separated hex notation with bit reversed bytes
912 * - 'mF' For a 6-byte MAC FDDI address, it prints the address
913 * in hex notation without separators with bit reversed bytes
899 * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way 914 * - 'I' [46] for IPv4/IPv6 addresses printed in the usual way
900 * IPv4 uses dot-separated decimal without leading 0's (1.2.3.4) 915 * IPv4 uses dot-separated decimal without leading 0's (1.2.3.4)
901 * IPv6 uses colon separated network-order 16 bit hex with leading 0's 916 * IPv6 uses colon separated network-order 16 bit hex with leading 0's
@@ -939,6 +954,7 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
939 return resource_string(buf, end, ptr, spec, fmt); 954 return resource_string(buf, end, ptr, spec, fmt);
940 case 'M': /* Colon separated: 00:01:02:03:04:05 */ 955 case 'M': /* Colon separated: 00:01:02:03:04:05 */
941 case 'm': /* Contiguous: 000102030405 */ 956 case 'm': /* Contiguous: 000102030405 */
957 /* [mM]F (FDDI, bit reversed) */
942 return mac_address_string(buf, end, ptr, spec, fmt); 958 return mac_address_string(buf, end, ptr, spec, fmt);
943 case 'I': /* Formatted IP supported 959 case 'I': /* Formatted IP supported
944 * 4: 1.2.3.4 960 * 4: 1.2.3.4