diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /net/core/utils.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'net/core/utils.c')
-rw-r--r-- | net/core/utils.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/net/core/utils.c b/net/core/utils.c index f41854470539..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> |
@@ -75,7 +76,7 @@ __be32 in_aton(const char *str) | |||
75 | str++; | 76 | str++; |
76 | } | 77 | } |
77 | } | 78 | } |
78 | return(htonl(l)); | 79 | return htonl(l); |
79 | } | 80 | } |
80 | EXPORT_SYMBOL(in_aton); | 81 | EXPORT_SYMBOL(in_aton); |
81 | 82 | ||
@@ -92,18 +93,19 @@ EXPORT_SYMBOL(in_aton); | |||
92 | 93 | ||
93 | static inline int xdigit2bin(char c, int delim) | 94 | static inline int xdigit2bin(char c, int delim) |
94 | { | 95 | { |
96 | int val; | ||
97 | |||
95 | if (c == delim || c == '\0') | 98 | if (c == delim || c == '\0') |
96 | return IN6PTON_DELIM; | 99 | return IN6PTON_DELIM; |
97 | if (c == ':') | 100 | if (c == ':') |
98 | return IN6PTON_COLON_MASK; | 101 | return IN6PTON_COLON_MASK; |
99 | if (c == '.') | 102 | if (c == '.') |
100 | return IN6PTON_DOT; | 103 | return IN6PTON_DOT; |
101 | if (c >= '0' && c <= '9') | 104 | |
102 | return (IN6PTON_XDIGIT | IN6PTON_DIGIT| (c - '0')); | 105 | val = hex_to_bin(c); |
103 | if (c >= 'a' && c <= 'f') | 106 | if (val >= 0) |
104 | return (IN6PTON_XDIGIT | (c - 'a' + 10)); | 107 | return val | IN6PTON_XDIGIT | (val < 10 ? IN6PTON_DIGIT : 0); |
105 | if (c >= 'A' && c <= 'F') | 108 | |
106 | return (IN6PTON_XDIGIT | (c - 'A' + 10)); | ||
107 | if (delim == -1) | 109 | if (delim == -1) |
108 | return IN6PTON_DELIM; | 110 | return IN6PTON_DELIM; |
109 | return IN6PTON_UNKNOWN; | 111 | return IN6PTON_UNKNOWN; |
@@ -295,3 +297,27 @@ void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, | |||
295 | csum_unfold(*sum))); | 297 | csum_unfold(*sum))); |
296 | } | 298 | } |
297 | 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); | ||