Skip to main content

Name

is_valid_IP — Determines whether or not string is a valid IP address

Synopsis

#include "dns.h"

| int **is_valid_IP** ( | string, |   | |   | family, |   | |   | address); |   |

const char * <var class="pdparam">string</var>; u_int8_t * <var class="pdparam">family</var>; struct in6_addr * <var class="pdparam">address</var>;

Description

Determines whether or not string is a valid IP address.

Parameters

string

The string to be validated.

family

As a side effect, this address will be populated with one of the following values: AF_INET, AF_INET6, or AF_UNSPEC.

The following typedef applies to the u_int8_t data type:

typedef uint8_t u_int8_t;

address

An address of the system struct struct in6_addr. As a side effect, this address will be populated with either struct in6_addr (AF_INET6) data or struct in_addr (AF_INET) data. If family is AF_INET, then the caller should cast the value of address to a struct in_addr in order to access the data structure for an IPv4 address.

Return Values

This is a Boolean function that returns 1 if string is valid IP address and 0 otherwise. If the string validates, then address will have struct in6_addr data.

Threading

It is legal to call this function in any thread.

See Also

Was this page helpful?