diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2011-05-07 19:00:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-05-09 15:10:49 -0400 |
commit | 4940fc889e1e63667a15243028ddcd84d471cd8e (patch) | |
tree | c52bb193d0ad4f13e0f617748ed1db297261f521 /include/linux | |
parent | 99f823f98fb981b55c663a3783c3d2293958ece4 (diff) |
net: add mac_pton() for parsing MAC address
mac_pton() parses MAC address in form XX:XX:XX:XX:XX:XX and only in that form.
mac_pton() doesn't dirty result until it's sure string representation is valid.
mac_pton() doesn't care about characters _after_ last octet,
it's up to caller to deal with it.
mac_pton() diverges from 0/-E return value convention.
Target usage:
if (!mac_pton(str, whatever->mac))
return -EINVAL;
/* ->mac being u8 [ETH_ALEN] is filled at this point. */
/* optionally check str[3 * ETH_ALEN - 1] for termination */
Use mac_pton() in pktgen and netconsole for start.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/if_ether.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h index be69043d2896..0f1325d98295 100644 --- a/include/linux/if_ether.h +++ b/include/linux/if_ether.h | |||
@@ -136,6 +136,7 @@ int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr); | |||
136 | extern struct ctl_table ether_table[]; | 136 | extern struct ctl_table ether_table[]; |
137 | #endif | 137 | #endif |
138 | 138 | ||
139 | int mac_pton(const char *s, u8 *mac); | ||
139 | extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len); | 140 | extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len); |
140 | 141 | ||
141 | #endif | 142 | #endif |