Esempio n. 1
0
nsapi_error_t NetworkStack::gethostbyname(const char *name, SocketAddress *address, nsapi_version_t version)
{
    if (name[0] == '\0') {
        return NSAPI_ERROR_PARAMETER;
    }

    // check for simple ip addresses
    if (address->set_ip_address(name)) {
        if (version != NSAPI_UNSPEC && address->get_ip_version() != version) {
            return NSAPI_ERROR_DNS_FAILURE;
        }

        return NSAPI_ERROR_OK;
    }

    // if the version is unspecified, try to guess the version from the
    // ip address of the underlying stack
    if (version == NSAPI_UNSPEC) {
        SocketAddress testaddress;
        if (testaddress.set_ip_address(this->get_ip_address())) {
            version = testaddress.get_ip_version();
        }
    }

    return nsapi_dns_query(this, name, address, version);
}
Esempio n. 2
0
// Default NetworkStack operations
int NetworkStack::gethostbyname(SocketAddress *address, const char *name)
{
    return nsapi_dns_query(this, address, name);
}