1 /**************************************************************************
3 **************************************************************************/
8 #include <gpxe/timer.h>
10 /**************************************************************************
11 INET_ATON - Convert an ascii x.x.x.x to binary form
12 **************************************************************************/
13 int inet_aton ( const char *cp
, struct in_addr
*inp
) {
15 const char *digits_start
;
19 for(j
= 0; j
<= 3; j
++) {
21 val
= strtoul(p
, ( char ** ) &p
, 10);
22 if ((p
== digits_start
) || (val
> 255)) return 0;
23 if ( ( j
< 3 ) && ( *(p
++) != '.' ) ) return 0;
27 inp
->s_addr
= htonl(ip
);
33 int isspace ( int c
) {
47 unsigned long strtoul ( const char *p
, char **endp
, int base
) {
48 unsigned long ret
= 0;
51 while ( isspace ( *p
) )
59 if ( ( *p
| 0x20 ) == 'x' ) {
68 if ( charval
>= 'a' ) {
69 charval
= ( charval
- 'a' + 10 );
70 } else if ( charval
>= 'A' ) {
71 charval
= ( charval
- 'A' + 10 );
72 } else if ( charval
<= '9' ) {
73 charval
= ( charval
- '0' );
75 if ( charval
>= ( unsigned int ) base
)
77 ret
= ( ( ret
* base
) + charval
);