This commit is contained in:
Melinda Shore 2013-07-01 08:25:07 -08:00
commit 7b14eda301
6 changed files with 122 additions and 43 deletions

View File

@ -12,10 +12,11 @@ The goals of this implemtation of the getdns API are:
* Provide an open source implementation, in C, of the formally described getdns API described by Paul Hoffman at <http://www.vpnc.org/getdns-api/>
* Initial support for FreeBSD x.y, MS-Windows Ver. X, OSX 10.x, Linux (CentOS/RHEL R6uX, Ubuntu Ver X) via functional "configure" script
* Initial support to include the Android platform
* Include examples and tests as part of the build
* Document code using doxygen
* Leverage github as much as possible for project coordination
* Coding style/standards follow the BSD coding style
* Coding style/standards follow the [BSD coding style](ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/share/misc/style)
* Follow the git flow branching model described at <http://nvie.com/posts/a-successful-git-branching-model/>
* Both synchronous and asynchronous entry points with an early focus on the asynchronous model
@ -36,7 +37,13 @@ Although [libevent](http://libevent.org) is used initially to implement the asyn
Current State of the Implementation
===================================
TBD
We are currently in the early stages of building the API so the code should be considered incomplete. The current target platforms and the personal primarily responsible for ensuring it builds and runs on that platform include:
* Android, Neel Goyal
* FreeBSD, Melinda Shore
* Linux RHEL/CentOS 6.x, Glen Wiley
* MS-Windows 8, Neel Goyal
* OSX 10.8, Glen Wiley
--
end README

View File

@ -0,0 +1,4 @@
Neel Goyal <ngoyal@verisign.com>
Allison Mankin <amankin@verisign.com>
Melinda Shore <melinda.shore@nomountain.net>
Glen Wiley <gwiley@verisign.com>

View File

@ -16,35 +16,35 @@ srcdir = @srcdir@
VPATH = @srcdir@
all clean getdns:
cd src && $(MAKE) $@
cd common && $(MAKE) $@
$(distdir): FORCE
mkdir -p $(distdir)/src
cp $(srcdir)/configure.ac $(distdir)
cp $(srcdir)/configure $(distdir)
cp $(srcdir)/Makefile.in $(distdir)
cp $(srcdir)/src/Makefile.in $(distdir)/src
mkdir -p $(distdir)/src
cp $(srcdir)/configure.ac $(distdir)
cp $(srcdir)/configure $(distdir)
cp $(srcdir)/Makefile.in $(distdir)
cp $(srcdir)/src/Makefile.in $(distdir)/src
distcheck: $(distdir).tar.gz
gzip -cd $(distdir).tar.gz | tar xvf -
cd $(distdir) && ./configure
cd $(distdir) && $(MAKE) all
cd $(distdir) && $(MAKE) check
cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install
cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall
@remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \
if test "$${remaining}" -ne 0; then
echo "@@@ $${remaining} file(s) remaining in stage directory!"; \
exit 1; \
fi
cd $(distdir) && $(MAKE) clean
rm -rf $(distdir)
@echo "*** Package $(distdir).tar.gz is ready for distribution"
gzip -cd $(distdir).tar.gz | tar xvf -
cd $(distdir) && ./configure
cd $(distdir) && $(MAKE) all
cd $(distdir) && $(MAKE) check
cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install
cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall
@remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \
if test "$${remaining}" -ne 0; then
echo "@@@ $${remaining} file(s) remaining in stage directory!"; \
exit 1; \
fi
cd $(distdir) && $(MAKE) clean
rm -rf $(distdir)
@echo "*** Package $(distdir).tar.gz is ready for distribution"
Makefile: Makefile.in config.status
./config.status $@
./config.status $@
configure.status: configure
./config.status --recheck
./config.status --recheck
.PHONY: all clean

View File

@ -1,3 +1,29 @@
/* example-simple-answers.c
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@ -53,7 +79,8 @@ void this_callbackfn(struct getdns_context_t *this_context,
fprintf(stderr, "The callback got a callback_type of %d. Exiting.", this_callback_type);
}
int main()
int
main()
{
/* Create the DNS context for this call */
struct getdns_context_t *this_context = NULL;
@ -96,4 +123,5 @@ int main()
getdns_context_destroy(this_context);
/* Assuming we get here, leave gracefully */
exit(EXIT_SUCCESS);
}
} /* main */
/* example-simple-answers.c */

View File

@ -1,3 +1,30 @@
/* example-synchronous.c
*
* 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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
*
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@ -5,30 +32,41 @@
#include <inttypes.h>
#include <getdns_core_only.h>
int main()
int
main()
{
getdns_return_t this_ret; /* Holder for all function returns */
getdns_return_t context_create_return;
struct getdns_list *just_the_addresses_ptr;
size_t *num_addresses_ptr = NULL;
size_t rec_count;
struct getdns_dict *this_address;
struct getdns_bindata *this_address_data;
struct getdns_context_t *this_context = NULL;
uint32_t *this_error = NULL;
struct getdns_dict *this_extensions = NULL;
const char *this_name = "www.example.com";
uint8_t this_request_type = GETDNS_RRTYPE_A;
struct getdns_dict *this_response = NULL;
uint32_t this_response_length;
getdns_return_t this_ret;
/* Create the DNS context for this call */
struct getdns_context_t *this_context = NULL;
getdns_return_t context_create_return = getdns_context_create(&this_context, true);
context_create_return = getdns_context_create(&this_context, true);
if (context_create_return != GETDNS_RETURN_GOOD)
{
fprintf(stderr, "Trying to create the context failed: %d", context_create_return);
return(GETDNS_RETURN_GENERIC_ERROR);
}
/* Set up the getdns_sync_request call */
const char * this_name = "www.example.com";
uint8_t this_request_type = GETDNS_RRTYPE_A;
/* Get the A and AAAA records */
struct getdns_dict * this_extensions = getdns_dict_create();
this_extensions = getdns_dict_create();
this_ret = getdns_dict_set_int(this_extensions, "return_both_v4_and_v6", GETDNS_EXTENSION_TRUE);
if (this_ret != GETDNS_RETURN_GOOD)
{
fprintf(stderr, "Trying to set an extension do both IPv4 and IPv6 failed: %d", this_ret);
return(GETDNS_RETURN_GENERIC_ERROR);
}
uint32_t this_response_length;
struct getdns_dict * this_response = NULL;
/* Make the call */
getdns_return_t dns_request_return = getdns_general_sync(this_context, this_name, this_request_type,
@ -41,33 +79,31 @@ int main()
else
{
/* Be sure the search returned something */
uint32_t * this_error = NULL;
this_ret = getdns_dict_get_int(this_response, "status", this_error); // Ignore any error
if (this_error && (*this_error != GETDNS_RESPSTATUS_GOOD)) // If the search didn't return "good"
{
fprintf(stderr, "The search had no results, and a return value of %d. Exiting.", *this_error);
return(GETDNS_RETURN_GENERIC_ERROR);
}
struct getdns_list * just_the_addresses_ptr;
this_ret = getdns_dict_get_list(this_response, "just_address_answers", &just_the_addresses_ptr); // Ignore any error
size_t * num_addresses_ptr = NULL;
this_ret = getdns_list_get_length(just_the_addresses_ptr, num_addresses_ptr); // Ignore any error
/* Go through each record */
if (num_addresses_ptr) {
for ( size_t rec_count = 0; rec_count <= *num_addresses_ptr; ++rec_count )
for (rec_count = 0; rec_count <= *num_addresses_ptr; ++rec_count )
{
struct getdns_dict * this_address;
this_ret = getdns_list_get_dict(just_the_addresses_ptr, rec_count, &this_address); // Ignore any error
/* Just print the address */
struct getdns_bindata * this_address_data;
this_ret = getdns_dict_get_bindata(this_address, "address_data", &this_address_data); // Ignore any error
printf("The address is %s", getdns_display_ip_address(this_address_data));
}
}
}
/* Clean up */
getdns_context_destroy(this_context);
getdns_free_sync_request_memory(this_response);
/* Assuming we get here, leave gracefully */
exit(EXIT_SUCCESS);
}
} /* main */
/* example-synchronous.c */

View File

@ -1,3 +1,6 @@
/* getdns_core_only.c
*/
#include <getdns_libevent.h>
/* stuff to make it compile pedantically */
@ -401,3 +404,4 @@ getdns_extension_set_libevent_base(
)
{ UNUSED_PARAM(context); UNUSED_PARAM(this_event_base); return GETDNS_RETURN_GOOD; }
/* getdns_core_only.c */