All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bruno Randolf <bruno@thinktube.com>
To: netdev@vger.kernel.org
Cc: jgarzik@pobox.com, linux-wireless@vger.kernel.org,
	linville@tuxdriver.com
Subject: [PATCH] add macro for printing mac addresses
Date: Fri, 15 Feb 2008 19:48:05 +0900	[thread overview]
Message-ID: <20080215104804.9870.15722.stgit@one> (raw)

is there any chance to include a macro like this for printing mac addresses?

its advantage is that it can be used without the need to declare buffers for
print_mac(), for example:

printk("mac address: " MAC_FMT, MAC_ADDR(addr));

Signed-off-by: Bruno Randolf <bruno@thinktube.com>
---

 include/linux/if_ether.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)


diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 5f92977..b9a6fb2 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -127,6 +127,15 @@ extern struct ctl_table ether_table[];
  *	Display a 6 byte device address (MAC) in a readable format.
  */
 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
+
+#define MAC_ADDR(addr) \
+    ((unsigned char *)(addr))[0], \
+    ((unsigned char *)(addr))[1], \
+    ((unsigned char *)(addr))[2], \
+    ((unsigned char *)(addr))[3], \
+    ((unsigned char *)(addr))[4], \
+    ((unsigned char *)(addr))[5]
+
 extern char *print_mac(char *buf, const u8 *addr);
 #define DECLARE_MAC_BUF(var) char var[18] __maybe_unused
 


WARNING: multiple messages have this Message-ID (diff)
From: Bruno Randolf <bruno-L9ZBdB2wSWtl57MIdRCFDg@public.gmane.org>
To: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: jgarzik-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org
Subject: [PATCH] add macro for printing mac addresses
Date: Fri, 15 Feb 2008 19:48:05 +0900	[thread overview]
Message-ID: <20080215104804.9870.15722.stgit@one> (raw)

is there any chance to include a macro like this for printing mac addresses?

its advantage is that it can be used without the need to declare buffers for
print_mac(), for example:

printk("mac address: " MAC_FMT, MAC_ADDR(addr));

Signed-off-by: Bruno Randolf <bruno-L9ZBdB2wSWtl57MIdRCFDg@public.gmane.org>
---

 include/linux/if_ether.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)


diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 5f92977..b9a6fb2 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -127,6 +127,15 @@ extern struct ctl_table ether_table[];
  *	Display a 6 byte device address (MAC) in a readable format.
  */
 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
+
+#define MAC_ADDR(addr) \
+    ((unsigned char *)(addr))[0], \
+    ((unsigned char *)(addr))[1], \
+    ((unsigned char *)(addr))[2], \
+    ((unsigned char *)(addr))[3], \
+    ((unsigned char *)(addr))[4], \
+    ((unsigned char *)(addr))[5]
+
 extern char *print_mac(char *buf, const u8 *addr);
 #define DECLARE_MAC_BUF(var) char var[18] __maybe_unused
 

             reply	other threads:[~2008-02-15 10:48 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-15 10:48 Bruno Randolf [this message]
2008-02-15 10:48 ` [PATCH] add macro for printing mac addresses Bruno Randolf
2008-02-15 10:58 ` David Miller
2008-02-15 17:42   ` [PATCH] net/8021q/vlan_dev.c - Use print_mac Joe Perches
2008-02-15 17:42     ` Joe Perches
2008-02-18  7:35     ` David Miller
2008-02-18 15:19     ` Patrick McHardy
2008-02-18 18:31       ` Joe Perches
2008-02-18 18:31         ` Joe Perches
2008-02-18 21:31         ` Patrick McHardy
2008-02-18 21:31           ` Patrick McHardy
2008-02-18 20:55       ` David Miller
2008-02-18 21:17         ` Patrick McHardy
2008-02-18 21:17           ` Patrick McHardy
2008-02-19  0:43           ` David Miller
2008-02-19  0:43             ` David Miller
2008-02-19  0:50             ` David Miller
2008-02-19  0:50               ` David Miller
2008-02-19  1:03               ` Joe Perches
2008-02-19  1:03                 ` Joe Perches
2008-02-19  1:30                 ` Philip Craig
2008-02-19  1:30                   ` Philip Craig
2008-02-19  3:23                 ` David Miller
2008-02-19  3:23                   ` David Miller
2008-02-19 11:48               ` Patrick McHardy
2008-02-15 17:42   ` [PATCH 2/2] Remove MAC_FMT Joe Perches
2008-02-15 17:42     ` Joe Perches
2008-02-18  7:35     ` David Miller
2008-02-15 12:54 ` [PATCH] add macro for printing mac addresses Johannes Berg
2008-02-15 12:54   ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080215104804.9870.15722.stgit@one \
    --to=bruno@thinktube.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.