~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to net/core/utils.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <linux/ratelimit.h>
28
28
 
29
29
#include <net/sock.h>
 
30
#include <net/net_ratelimit.h>
30
31
 
31
32
#include <asm/byteorder.h>
32
33
#include <asm/system.h>
296
297
                                csum_unfold(*sum)));
297
298
}
298
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);