diff options
Diffstat (limited to 'net/core/utils.c')
-rw-r--r-- | net/core/utils.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/net/core/utils.c b/net/core/utils.c index 5fea0ab21902..386e263f6066 100644 --- a/net/core/utils.c +++ b/net/core/utils.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/ratelimit.h> | 27 | #include <linux/ratelimit.h> |
28 | 28 | ||
29 | #include <net/sock.h> | 29 | #include <net/sock.h> |
30 | #include <net/net_ratelimit.h> | ||
30 | 31 | ||
31 | #include <asm/byteorder.h> | 32 | #include <asm/byteorder.h> |
32 | #include <asm/system.h> | 33 | #include <asm/system.h> |
@@ -296,3 +297,27 @@ void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, | |||
296 | csum_unfold(*sum))); | 297 | csum_unfold(*sum))); |
297 | } | 298 | } |
298 | EXPORT_SYMBOL(inet_proto_csum_replace4); | 299 | EXPORT_SYMBOL(inet_proto_csum_replace4); |
300 | |||
301 | int mac_pton(const char *s, u8 *mac) | ||
302 | { | ||
303 | int i; | ||
304 | |||
305 | /* XX:XX:XX:XX:XX:XX */ | ||
306 | if (strlen(s) < 3 * ETH_ALEN - 1) | ||
307 | return 0; | ||
308 | |||
309 | /* Don't dirty result unless string is valid MAC. */ | ||
310 | for (i = 0; i < ETH_ALEN; i++) { | ||
311 | if (!strchr("0123456789abcdefABCDEF", s[i * 3])) | ||
312 | return 0; | ||
313 | if (!strchr("0123456789abcdefABCDEF", s[i * 3 + 1])) | ||
314 | return 0; | ||
315 | if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':') | ||
316 | return 0; | ||
317 | } | ||
318 | for (i = 0; i < ETH_ALEN; i++) { | ||
319 | mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]); | ||
320 | } | ||
321 | return 1; | ||
322 | } | ||
323 | EXPORT_SYMBOL(mac_pton); | ||