2 Copy from glibc, needed for udhcpd.
4 - Rene Rebe <rene@exactcode.de>
6 --- /dev/null 2006-01-02 14:13:10.967999000 +0100
7 +++ diet/libugly/ether_aton.c 2006-01-02 21:37:51.000000000 +0100
9 +/* Copyright (C) 1996,97,98,99,2002 Free Software Foundation, Inc.
10 + This file is part of the GNU C Library.
11 + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
13 + The GNU C Library is free software; you can redistribute it and/or
14 + modify it under the terms of the GNU Lesser General Public
15 + License as published by the Free Software Foundation; either
16 + version 2.1 of the License, or (at your option) any later version.
18 + The GNU C Library is distributed in the hope that it will be useful,
19 + but WITHOUT ANY WARRANTY; without even the implied warranty of
20 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 + Lesser General Public License for more details.
23 + You should have received a copy of the GNU Lesser General Public
24 + License along with the GNU C Library; if not, write to the Free
25 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
30 +#include <net/ethernet.h>
33 +ether_aton_r (const char *asc, struct ether_addr *addr)
37 + for (cnt = 0; cnt < 6; ++cnt)
39 + unsigned int number;
42 + ch = tolower (*asc++);
43 + if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
45 + number = isdigit (ch) ? (ch - '0') : (ch - 'a' + 10);
47 + ch = tolower (*asc);
48 + if ((cnt < 5 && ch != ':') || (cnt == 5 && ch != '\0' && !isspace (ch)))
51 + if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
54 + number += isdigit (ch) ? (ch - '0') : (ch - 'a' + 10);
57 + if (cnt < 5 && ch != ':')
62 + addr->ether_addr_octet[cnt] = (unsigned char) number;
72 +ether_aton (const char *asc)
74 + static struct ether_addr result;
76 + return ether_aton_r (asc, &result);