Exemple #1
0
/******************************************************************************
 *                                                                            *
 * Function: iprange_parse                                                    *
 *                                                                            *
 * Purpose: parse IP address (v4 or v6) into IP range structure               *
 *                                                                            *
 * Parameters: iprange - [OUT] the IP range                                   *
 *             address - [IN] the IP address                                  *
 *                                                                            *
 * Return value: SUCCEED - the IP range was successfully parsed               *
 *               FAIL    - otherwise                                          *
 *                                                                            *
 ******************************************************************************/
int	iprange_parse(zbx_iprange_t *iprange, const char *address)
{
	if (NULL != strchr(address, '.'))
		return iprangev4_parse(iprange, address);
	else
		return iprangev6_parse(iprange, address);
}
/******************************************************************************
 *                                                                            *
 * Function: iprange_parse                                                    *
 *                                                                            *
 * Purpose: parse IP address (v4 or v6) into IP range structure               *
 *                                                                            *
 * Parameters: iprange - [OUT] the IP range                                   *
 *             address - [IN] the IP address                                  *
 *                                                                            *
 * Return value: SUCCEED - the IP range was successfully parsed               *
 *               FAIL    - otherwise                                          *
 *                                                                            *
 ******************************************************************************/
int	iprange_parse(zbx_iprange_t *iprange, const char *address)
{
	/* ignore leading whitespace characters */
	while (SUCCEED == iprange_is_whitespace_character(*address))
		address++;

	if (NULL != strchr(address, '.'))
		return iprangev4_parse(iprange, address);
	else
		return iprangev6_parse(iprange, address);
}