#include <stdlib.h>#include <ctype.h>#include <byteswap.h>#include <gpxe/in.h>#include <gpxe/timer.h>Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| int | inet_aton (const char *cp, struct in_addr *inp) |
| unsigned long | strtoul (const char *p, char **endp, int base) |
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| int inet_aton | ( | const char * | cp, | |
| struct in_addr * | inp | |||
| ) |
Definition at line 16 of file misc.c.
References htonl, in_addr::s_addr, and strtoul().
Referenced by numeric_resolv(), slam_parse_multicast_address(), storef_ipv4(), and tftp_process_multicast().
00016 { 00017 const char *p = cp; 00018 const char *digits_start; 00019 unsigned long ip = 0; 00020 unsigned long val; 00021 int j; 00022 for(j = 0; j <= 3; j++) { 00023 digits_start = p; 00024 val = strtoul(p, ( char ** ) &p, 10); 00025 if ((p == digits_start) || (val > 255)) return 0; 00026 if ( ( j < 3 ) && ( *(p++) != '.' ) ) return 0; 00027 ip = (ip << 8) | val; 00028 } 00029 if ( *p == '\0' ) { 00030 inp->s_addr = htonl(ip); 00031 return 1; 00032 } 00033 return 0; 00034 }
| unsigned long strtoul | ( | const char * | p, | |
| char ** | endp, | |||
| int | base | |||
| ) |
Definition at line 36 of file misc.c.
References isspace().
Referenced by aoe_parse_root_path(), bzimage_parse_cmdline(), ftp_parse_value(), http_rx_content_length(), http_rx_response(), ib_srp_parse_byte_string(), ib_srp_parse_integer(), inet_aton(), iscsi_handle_chap_c_value(), iscsi_handle_chap_i_value(), iscsi_handle_chap_r_value(), iscsi_handle_targetaddress_value(), iscsi_parse_root_path(), mac_address_from_string_specs(), parse_setting_tag(), pxebs_exec(), scsi_parse_lun(), slam_parse_multicast_address(), sleep_exec(), storef_hex(), storef_int(), tftp_process_blksize(), tftp_process_multicast(), tftp_process_tsize(), uri_decode(), and uri_port().
00036 { 00037 unsigned long ret = 0; 00038 unsigned int charval; 00039 00040 while ( isspace ( *p ) ) 00041 p++; 00042 00043 if ( base == 0 ) { 00044 base = 10; 00045 if ( *p == '0' ) { 00046 p++; 00047 base = 8; 00048 if ( ( *p | 0x20 ) == 'x' ) { 00049 p++; 00050 base = 16; 00051 } 00052 } 00053 } 00054 00055 while ( 1 ) { 00056 charval = *p; 00057 if ( charval >= 'a' ) { 00058 charval = ( charval - 'a' + 10 ); 00059 } else if ( charval >= 'A' ) { 00060 charval = ( charval - 'A' + 10 ); 00061 } else if ( charval <= '9' ) { 00062 charval = ( charval - '0' ); 00063 } 00064 if ( charval >= ( unsigned int ) base ) 00065 break; 00066 ret = ( ( ret * base ) + charval ); 00067 p++; 00068 } 00069 00070 if ( endp ) 00071 *endp = ( char * ) p; 00072 00073 return ( ret ); 00074 }
1.5.7.1