123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #include "libbb.h"
- #include <net/if_arp.h>
- #include <net/ethernet.h>
- int FAST_FUNC in_ether(const char *bufp, struct sockaddr *sap)
- {
- char *ptr;
- int i, j;
- unsigned char val;
- unsigned char c;
- sap->sa_family = ARPHRD_ETHER;
- ptr = (char *) sap->sa_data;
- i = ETH_ALEN;
- goto first;
- do {
-
- if (*bufp == ':')
- bufp++;
- first:
- j = val = 0;
- do {
- c = *bufp;
- if (((unsigned char)(c - '0')) <= 9) {
- c -= '0';
- } else if ((unsigned char)((c|0x20) - 'a') <= 5) {
- c = (unsigned char)((c|0x20) - 'a') + 10;
- } else {
- if (j && (c == ':' || c == '\0'))
-
- break;
- return -1;
- }
- ++bufp;
- val <<= 4;
- val += c;
- j ^= 1;
- } while (j);
- *ptr++ = val;
- } while (--i);
-
- return *bufp;
- }
|