2013-07-15 17:43:30 -05:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* /brief getdns core functions
|
2013-10-17 18:45:25 -05:00
|
|
|
*
|
2013-07-15 17:43:30 -05:00
|
|
|
* This is the meat of the API
|
|
|
|
* Originally taken from the getdns API description pseudo implementation.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/* The MIT License (MIT)
|
|
|
|
* Copyright (c) 2013 Verisign, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2013-10-17 18:45:25 -05:00
|
|
|
*
|
2013-07-15 17:43:30 -05:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
2013-10-17 18:45:25 -05:00
|
|
|
*
|
2013-07-15 17:43:30 -05:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2013-08-15 09:16:15 -05:00
|
|
|
#include <getdns/getdns.h>
|
2013-10-18 12:55:31 -05:00
|
|
|
#include <getdns/getdns_error.h>
|
2013-08-09 16:04:25 -05:00
|
|
|
#include <stdio.h>
|
2013-10-17 18:45:25 -05:00
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <util-internal.h>
|
2013-07-15 17:43:30 -05:00
|
|
|
|
|
|
|
/* stuff to make it compile pedantically */
|
|
|
|
#define UNUSED_PARAM(x) ((void)(x))
|
|
|
|
|
|
|
|
char *
|
2013-11-05 14:03:44 -06:00
|
|
|
getdns_convert_dns_name_to_fqdn(char *name_from_dns_response)
|
|
|
|
{
|
|
|
|
UNUSED_PARAM(name_from_dns_response);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-07-15 17:43:30 -05:00
|
|
|
|
|
|
|
char *
|
2013-11-05 14:03:44 -06:00
|
|
|
getdns_convert_fqdn_to_dns_name(char *fqdn_as_string)
|
|
|
|
{
|
|
|
|
UNUSED_PARAM(fqdn_as_string);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-07-15 17:43:30 -05:00
|
|
|
|
|
|
|
char *
|
2013-11-05 14:03:44 -06:00
|
|
|
getdns_convert_ulabel_to_alabel(char *ulabel)
|
|
|
|
{
|
|
|
|
UNUSED_PARAM(ulabel);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-07-15 17:43:30 -05:00
|
|
|
|
|
|
|
char *
|
2013-11-05 14:03:44 -06:00
|
|
|
getdns_convert_alabel_to_ulabel(char *alabel)
|
|
|
|
{
|
|
|
|
UNUSED_PARAM(alabel);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-07-15 17:43:30 -05:00
|
|
|
|
|
|
|
char *
|
2013-11-05 14:03:44 -06:00
|
|
|
getdns_display_ip_address(struct getdns_bindata
|
|
|
|
*bindata_of_ipv4_or_ipv6_address)
|
2013-10-17 18:45:25 -05:00
|
|
|
{
|
2013-11-05 14:03:44 -06:00
|
|
|
char buff[256];
|
|
|
|
if (!bindata_of_ipv4_or_ipv6_address ||
|
|
|
|
bindata_of_ipv4_or_ipv6_address->size == 0 ||
|
|
|
|
!bindata_of_ipv4_or_ipv6_address->data) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (bindata_of_ipv4_or_ipv6_address->size == 4) {
|
|
|
|
const char *ipStr = inet_ntop(AF_INET,
|
|
|
|
bindata_of_ipv4_or_ipv6_address->data,
|
|
|
|
buff,
|
|
|
|
256);
|
|
|
|
if (ipStr) {
|
|
|
|
return strdup(ipStr);
|
|
|
|
}
|
|
|
|
} else if (bindata_of_ipv4_or_ipv6_address->size == 16) {
|
|
|
|
const char *ipStr = inet_ntop(AF_INET6,
|
|
|
|
bindata_of_ipv4_or_ipv6_address->data,
|
|
|
|
buff,
|
|
|
|
256);
|
|
|
|
if (ipStr) {
|
|
|
|
return strdup(ipStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
2013-10-17 18:45:25 -05:00
|
|
|
}
|
2013-07-15 17:43:30 -05:00
|
|
|
|
2013-07-19 15:19:22 -05:00
|
|
|
getdns_return_t
|
|
|
|
getdns_strerror(getdns_return_t err, char *buf, size_t buflen)
|
|
|
|
{
|
2013-11-05 14:03:44 -06:00
|
|
|
getdns_return_t retval = GETDNS_RETURN_GOOD;
|
2013-07-19 15:19:22 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
const char *err_str = getdns_get_errorstr_by_id(err);
|
|
|
|
if (!err_str) {
|
|
|
|
return GETDNS_RETURN_GENERIC_ERROR;
|
|
|
|
}
|
2013-07-19 15:19:22 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
snprintf(buf, buflen, "%s", err_str);
|
2013-07-19 15:19:22 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
return retval;
|
|
|
|
} /* getdns_strerror */
|
2013-07-19 15:19:22 -05:00
|
|
|
|
2013-07-15 17:43:30 -05:00
|
|
|
/* getdns_core_only.c */
|