Commit f3f7a4d9 authored by Ondrej Sury's avatar Ondrej Sury

Imported Upstream version 1.3.0

parents
This diff is collapsed.
Copyright (c) 2005,2006, NLnetLabs
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of NLnetLabs nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
# Standard installation pathnames
# See the file LICENSE for the license
SHELL = @SHELL@
VERSION = @PACKAGE_VERSION@
version_info = @LIBTOOL_VERSION_INFO@
srcdir = @srcdir@
basesrcdir = $(shell basename `pwd`)
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
mandir = @mandir@
datarootdir = @datarootdir@
datadir = @datadir@
libdir = @libdir@
includedir = @includedir@
doxygen = @doxygen@
glibtool = @glibtool@
libtool = ./libtool
ifdef glibtool
libtool = $(glibtool)
endif
CC = @CC@
CPPFLAGS = @CPPFLAGS@ @DEFS@ -I. -I$(srcdir)
CFLAGS = @CFLAGS@ -I. -I$(srcdir)
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
LIBOBJS = @LIBOBJS@
RUNTIME_PATH = @RUNTIME_PATH@
DATE = $(shell date +%Y%m%d)
LIBTOOL = $(libtool) --tag=CC
LINT = splint
LINTFLAGS = +quiet -weak -warnposix -unrecog -Din_addr_t=uint32_t -Du_int=unsigned -Du_char=uint8_t -preproc -D__u16=uint16_t
INSTALL = $(srcdir)/install-sh
LIBDNS_SOURCES = rdata.c util.c rr.c packet.c wire2host.c \
host2str.c buffer.c str2host.c tsig.c resolver.c \
net.c host2wire.c dname.c dnssec.c dnssec_verify.c \
keys.c higher.c rr_functions.c parse.c update.c \
error.c zone.c dnssec_zone.c dnssec_sign.c rbtree.c
LIBDNS_HEADERS = $(srcdir)/ldns/error.h \
$(srcdir)/ldns/packet.h \
$(srcdir)/ldns/common.h \
$(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h \
$(srcdir)/ldns/wire2host.h \
$(srcdir)/ldns/host2str.h \
$(srcdir)/ldns/host2wire.h \
$(srcdir)/ldns/str2host.h \
$(srcdir)/ldns/buffer.h \
$(srcdir)/ldns/resolver.h \
$(srcdir)/ldns/net.h \
$(srcdir)/ldns/dname.h \
$(srcdir)/ldns/dnssec.h \
$(srcdir)/ldns/dnssec_verify.h \
$(srcdir)/ldns/dnssec_sign.h \
$(srcdir)/ldns/keys.h \
$(srcdir)/ldns/higher.h \
$(srcdir)/ldns/parse.h \
$(srcdir)/ldns/rr_functions.h \
$(srcdir)/ldns/ldns.h \
$(srcdir)/ldns/zone.h \
$(srcdir)/ldns/dnssec_zone.h \
$(srcdir)/ldns/update.h \
$(srcdir)/ldns/tsig.h \
$(srcdir)/ldns/rbtree.h
LIBDNS_OBJECTS = $(LIBDNS_SOURCES:.c=.o) $(LIBOBJS)
LIBDNS_LOBJECTS = $(LIBDNS_SOURCES:.c=.lo) $(LIBOBJS:.o=.lo)
ALL_SOURCES = $(LIBDNS_SOURCES)
COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS)
COMP_LIB = $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(CFLAGS) $(LDFLAGS)
LINK_LIB = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -version-number $(version_info) -no-undefined
%.o: $(srcdir)/%.c $(LIBDNS_HEADERS) ldns/util.h ldns/config.h
$(COMP_LIB) -c $> $<
.PHONY: clean realclean docclean manpages doc lint all lib
.PHONY: install uninstall install-doc uninstall-doc
.PHONY: install-h uninstall-h install-lib uninstall-lib
all: copy-headers lib linktest
linktest: $(srcdir)/linktest.c $(LIBDNS_HEADERS) ldns/util.h ldns/config.h libldns.la
$(LIBTOOL) --mode=link $(CC) $(srcdir)/linktest.c $(CPPFLAGS) $(CFLAGS) -lldns -o linktest
lib: libldns.la
if [ ! -d lib ] ; then ln -s .libs lib ; fi ;
libldns.la: $(LIBDNS_OBJECTS)
$(LINK_LIB) -o libldns.la $(LIBDNS_LOBJECTS) -rpath $(libdir) $(RUNTIME_PATH)
$(addprefix include/ldns/, $(notdir $(LIBDNS_HEADERS))): include/ldns/%.h: $(srcdir)/ldns/%.h
@if [ ! -d include ] ; then ($(INSTALL) -d include || echo "include exists") ; fi ;
@if [ ! -d include/ldns ] ; then (cd include; ln -s ../ldns ./ldns || echo "include/ldns exists") ; fi ;
MVPROG=/bin/cp $(INSTALL) -m 644 $< ./include/ldns/
copy-headers: $(addprefix include/ldns/, $(notdir $(LIBDNS_HEADERS)))
mancheck:
sh -c 'find . -name \*.\[13\] -exec troff -z {} \;' 2>&1 | sed "s/^\.\///" | sed "s/\(:[0\-9]\+:\)/\1 warning:/g"
doxygen: manpages
$(INSTALL) -d doc
ifdef doxygen
# if we are not in base we need to copy some html files too
if [ ! -e doc/header.html ] ; then \
MVPROG=/bin/cp $(INSTALL) -m 644 $(srcdir)/doc/header.html doc/ ; \
fi ;
$(doxygen) $(srcdir)/libdns.doxygen
endif
manpages: $(srcdir)/doc/function_manpages
$(INSTALL) -d doc
cat $(srcdir)/ldns/*.h | $(srcdir)/doc/doxyparse.pl -m $(srcdir)/doc/function_manpages 2>&1 | \
grep -v ^doxygen | grep -v ^cat > doc/ldns_manpages
install: install-h install-lib install-manpages
uninstall: uninstall-manpages uninstall-h uninstall-lib
destclean: uninstall
install-manpages: manpages
${INSTALL} -d $(DESTDIR)$(mandir)/man3
cp -Rp doc/man/man3/* $(DESTDIR)$(mandir)/man3/
uninstall-manpages:
for i in `cat doc/ldns_manpages`; do \
rm -f $(DESTDIR)$(mandir)/man3/$$i.3 ; done
rmdir -p $(DESTDIR)$(mandir)/man3
install-h: lib
$(INSTALL) -m 755 -d $(DESTDIR)$(includedir)/ldns
for i in $(LIBDNS_HEADERS); do \
MVPROG=/bin/cp $(INSTALL) -m 644 $$i $(DESTDIR)$(includedir)/ldns/; done
MVPROG=/bin/cp $(INSTALL) -m 644 include/ldns/util.h $(DESTDIR)$(includedir)/ldns/
uninstall-h:
for i in $(LIBDNS_HEADERS); do \
rm -f $(DESTDIR)$(includedir)/$$i; done
[ ! -d $(DESTDIR)$(includedir)/ldns ] || rmdir -p $(DESTDIR)$(includedir)/ldns
exit 0
install-lib: lib
$(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
$(LIBTOOL) --mode=install cp libldns.la $(DESTDIR)$(libdir)
$(LIBTOOL) --mode=finish $(DESTDIR)$(libdir)
uninstall-lib:
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libldns.la
rmdir -p $(DESTDIR)$(libdir)
clean:
rm -f *.o *.d *.lo
rm -f *~
rm -rf autom4te.cache/
rm -f tags
rm -f *.key
rm -f *.ds
rm -f *.private
rm -rf include/
rm -f lib
rm -rf .libs
rm -f linktest
distclean: clean docclean libclean
rm -f ltmain.sh
realclean: clean docclean libclean
rm -f config.status
rm -f config.log
rm -f Makefile
rm -f ldns/config.h.in
rm -f ldns/config.h
rm -f ldns/util.h
rm -f config.h.in
rm -f configure
rm -f config.sub
rm -f config.guess
rm -f ltmain.sh
docclean:
rm -rf doc/html/
rm -rf doc/man/
rm -rf doc/latex/
rm -f doc/*.txt
rm -f doc/*.tex
rm -f doc/ldns_manpages
libclean:
$(LIBTOOL) --mode clean rm -f libldns.la
$(LIBTOOL) --mode clean rm -f libldns.a
$(LIBTOOL) --mode clean rm -f libldns.so
$(LIBTOOL) --mode clean rm -f libldns.so.*
rm -rf *.lo
rm -rf .libs
rm -rf libtool
## No need for changes here
lint:
for i in $(LIBDNS_SOURCES); do \
$(LINT) $(LINTFLAGS) -I. -I$(srcdir) $(srcdir)/$$i ; \
if [ $$? -ne 0 ] ; then exit 1 ; fi ; \
done
tags: $(srcdir)/*.c ldns/*.[ch]
ctags -f $(srcdir)/tags $(srcdir)/*.[ch] ldns/*.[ch]
b64_pton$U.o: $(srcdir)/compat/b64_pton.c
$(COMP_LIB) -c $(srcdir)/compat/b64_pton.c -o $@
b64_ntop$U.o: $(srcdir)/compat/b64_ntop.c
$(COMP_LIB) -c $(srcdir)/compat/b64_ntop.c -o $@
b32_pton$U.o: $(srcdir)/compat/b32_pton.c
$(COMP_LIB) -c $(srcdir)/compat/b32_pton.c -o $@
b32_ntop$U.o: $(srcdir)/compat/b32_ntop.c
$(COMP_LIB) -c $(srcdir)/compat/b32_ntop.c -o $@
malloc$U.o: $(srcdir)/compat/malloc.c
$(COMP_LIB) -c $(srcdir)/compat/malloc.c -o $@
realloc$U.o: $(srcdir)/compat/realloc.c
$(COMP_LIB) -c $(srcdir)/compat/realloc.c -o $@
timegm$U.o: $(srcdir)/compat/timegm.c
$(COMP_LIB) -c $(srcdir)/compat/timegm.c -o $@
isblank$U.o: $(srcdir)/compat/isblank.c
$(COMP_LIB) -c $(srcdir)/compat/isblank.c -o $@
strlcpy$U.o: $(srcdir)/compat/strlcpy.c
$(COMP_LIB) -c $(srcdir)/compat/strlcpy.c -o $@
memmove$U.o: $(srcdir)/compat/memmove.c
$(COMP_LIB) -c $(srcdir)/compat/memmove.c -o $@
inet_pton$U.o: $(srcdir)/compat/inet_pton.c
$(COMP_LIB) -c $(srcdir)/compat/inet_pton.c -o $@
inet_aton$U.o: $(srcdir)/compat/inet_aton.c
$(COMP_LIB) -c $(srcdir)/compat/inet_aton.c -o $@
inet_ntop$U.o: $(srcdir)/compat/inet_ntop.c
$(COMP_LIB) -c $(srcdir)/compat/inet_ntop.c -o $@
snprintf$U.o: $(srcdir)/compat/snprintf.c
$(COMP_LIB) -c $(srcdir)/compat/snprintf.c -o $@
fake-rfc2553$U.o: $(srcdir)/compat/fake-rfc2553.c
$(COMP_LIB) -c $(srcdir)/compat/fake-rfc2553.c -o $@
gmtime_r$U.o: $(srcdir)/compat/gmtime_r.c
$(COMP_LIB) -c $(srcdir)/compat/gmtime_r.c -o $@
ctime_r$U.o: $(srcdir)/compat/ctime_r.c
$(COMP_LIB) -c $(srcdir)/compat/ctime_r.c -o $@
# Automatic dependencies.
%.d: $(srcdir)/%.c
$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< \
| sed '\''s!\(.*\)\.o[ :]*!$(dir $@)\1.o $@ : !g'\'' > $@; \
[ -s $@ ] || rm -f $@'
allclean: test-clean clean
test-clean:
tpkg -b test clean
#-include $(ALL_SOURCES:.c=.d)
Contents:
REQUIREMENTS
INSTALLATION
libdns
examples
drill
INFORMATION FOR SPECIFIC OPERATING SYSTEMS
Mac OS X
Solaris
Project page:
http://www.nlnetlabs.nl/ldns/
On that page you can also subscribe to the ldns mailing list.
* Development
ldns is mainly developed on Linux and FreeBSD. It is regularly tested to
compile on other systems like Solaris and Mac OS X.
REQUIREMENTS
- OpenSSL (Optional, but needed for features like DNSSEC)
- libpcap (Optional, but needed for examples/ldns-dpa)
- (GNU) libtool (in OSX, that's glibtool, not libtool)
- GNU make
INSTALLATION
1. Unpack the tarball
2. cd ldns-<VERSION>
3. ./configure
4. gmake (it needs gnu make to compile, on systems where GNU make is the
default you can just use 'make')
5. sudo gmake install
6. Optional. (cd examples; ./configure; gmake), make example programs included.
7. Optional. (cd drill; ./configure; gmake; gmake install), to build drill.
You can configure and compile it in a separate build directory.
* Examples
There are some examples and dns related tools in the examples/ directory.
These can be built with:
1. cd examples/
2 autoreconf
3. ./configure [--with-ldns=<path to ldns installation or build>]
4. gmake
* Drill
Drill can be built with:
1. cd drill/
2. autoreconf
3. ./configure [--with-ldns=<path to ldns installation or build>]
4. gmake
Note that you need to set LD_LIBRARY_PATH if you want to run the binaries
and you have not installed the library to a system directory. You can use
the make target all-static for the examples to run them if you don't want to
install the library.
* Building from subversion repository
If you are building from the repository you will need to have (gnu)
autotools like libtool and autoreconf installed. A list of all the commands
needed to build everything can be found in README.svn. Note that the actual
commands may be a little bit different on your machine. Most notable, you'll need to run libtoolize (or glibtoolize), if you skip this step, you'll get an error about missing config.sub.
* Developers
ldns is developed by the ldns team at NLnet Labs. This team currently
consists of:
o Jelte Jansen
o Miek Gieben
o Wouter Wijngaards
* Credits
We have received patches from the following people, thanks!
o Erik Rozendaal
o Håkan Olsson
o Jakob Schlyter
o Paul Wouters
o Simon Vallet
o Ondřej Surý
IFORMATION FOR SPECIFIC OPERATING SYSTEMS
MAC OS X
For MACOSX 10.4 and later, it seems that you have to set the
MACOSX_DEPLOYMENT_TARGET environment variable to 10.4 before running
make. Apparently it defaults to 10.1.
This appears to be a known problem in 10.2 to 10.4, see:
http://developer.apple.com/qa/qa2001/qa1233.html
for more information.
SOLARIS
In Solaris multi-architecture systems (that have both 32-bit and
64-bit support), it can be a bit taxing to convince the system to
compile in 64-bit mode. Jakob Schlyter has kindly contributed a build
script that sets the right build and link options. You can find it in
contrib/build-solaris.sh
ldns - snapshot releases
Snapshot releases are not official released. They can be released to
interested parties for development.
Snapshots can be recognized from the date in the the tar file name.
They should not be used for packaging in distributions.
# The ldns subversion repository can found at:
# www.nlnetlabs.nl/ldns/svn/
# small list of commands to build all on a linux system
# libtoolize is needed for most other targets
libtoolize -c
autoreconf
./configure
make
make doc # needs doxygen for the html pages
(cd examples && autoreconf && ./configure && make)
(cd drill && autoreconf && ./configure && make)
(cd pcat && autoreconf && ./configure && make)
(cd examples/nsd-test && autoreconf && ./configure && make)
This diff is collapsed.
/*
* buffer.c -- generic memory buffer .
*
* Copyright (c) 2001-2008, NLnet Labs. All rights reserved.
*
* See LICENSE for the license.
*
*/
#include <ldns/config.h>
#include <ldns/ldns.h>
#include <ldns/buffer.h>
ldns_buffer *
ldns_buffer_new(size_t capacity)
{
ldns_buffer *buffer = LDNS_MALLOC(ldns_buffer);
if (!buffer) {
return NULL;
}
buffer->_data = (uint8_t *) LDNS_XMALLOC(uint8_t, capacity);
if (!buffer->_data) {
LDNS_FREE(buffer);
return NULL;
}
buffer->_position = 0;
buffer->_limit = buffer->_capacity = capacity;
buffer->_fixed = 0;
buffer->_status = LDNS_STATUS_OK;
ldns_buffer_invariant(buffer);
return buffer;
}
void
ldns_buffer_new_frm_data(ldns_buffer *buffer, void *data, size_t size)
{
assert(data != NULL);
buffer->_position = 0;
buffer->_limit = buffer->_capacity = size;
buffer->_data = LDNS_XMALLOC(uint8_t, size);
memcpy(buffer->_data, data, size);
buffer->_fixed = 0;
buffer->_status = LDNS_STATUS_OK;
ldns_buffer_invariant(buffer);
}
bool
ldns_buffer_set_capacity(ldns_buffer *buffer, size_t capacity)
{
void *data;
ldns_buffer_invariant(buffer);
assert(buffer->_position <= capacity);
data = (uint8_t *) LDNS_XREALLOC(buffer->_data, uint8_t, capacity);
if (!data) {
buffer->_status = LDNS_STATUS_MEM_ERR;
return false;
} else {
buffer->_data = data;
buffer->_limit = buffer->_capacity = capacity;
return true;
}
}
bool
ldns_buffer_reserve(ldns_buffer *buffer, size_t amount)
{
ldns_buffer_invariant(buffer);
assert(!buffer->_fixed);
if (buffer->_capacity < buffer->_position + amount) {
size_t new_capacity = buffer->_capacity * 3 / 2;
if (new_capacity < buffer->_position + amount) {
new_capacity = buffer->_position + amount;
}
if (!ldns_buffer_set_capacity(buffer, new_capacity)) {
buffer->_status = LDNS_STATUS_MEM_ERR;
return false;
}
}
buffer->_limit = buffer->_capacity;
return true;
}
int
ldns_buffer_printf(ldns_buffer *buffer, const char *format, ...)
{
va_list args;
int written = 0;
size_t remaining;
if (ldns_buffer_status_ok(buffer)) {
ldns_buffer_invariant(buffer);
assert(buffer->_limit == buffer->_capacity);
remaining = ldns_buffer_remaining(buffer);
va_start(args, format);
written = vsnprintf((char *) ldns_buffer_current(buffer), remaining,
format, args);
va_end(args);
if (written == -1) {
buffer->_status = LDNS_STATUS_INTERNAL_ERR;
return -1;
} else if ((size_t) written >= remaining) {
if (!ldns_buffer_reserve(buffer, (size_t) written + 1)) {
buffer->_status = LDNS_STATUS_MEM_ERR;
return -1;
}
va_start(args, format);
written = vsnprintf((char *) ldns_buffer_current(buffer),
ldns_buffer_remaining(buffer), format, args);
va_end(args);
if (written == -1) {
buffer->_status = LDNS_STATUS_INTERNAL_ERR;
return -1;
}
}
buffer->_position += written;
}
return written;
}
void
ldns_buffer_free(ldns_buffer *buffer)
{
if (!buffer) {
return;
}
LDNS_FREE(buffer->_data);
LDNS_FREE(buffer);
}
void *
ldns_buffer_export(ldns_buffer *buffer)
{
buffer->_fixed = 1;
return buffer->_data;
}
int
ldns_bgetc(ldns_buffer *buffer)
{
if (!ldns_buffer_available_at(buffer, buffer->_position, sizeof(uint8_t))) {
ldns_buffer_set_position(buffer, ldns_buffer_limit(buffer));
/* ldns_buffer_rewind(buffer);*/
return EOF;
}
return (int)ldns_buffer_read_u8(buffer);
}
void
ldns_buffer_copy(ldns_buffer* result, ldns_buffer* from)
{
size_t tocopy = ldns_buffer_limit(from);
if(tocopy > ldns_buffer_capacity(result))
tocopy = ldns_buffer_capacity(result);
ldns_buffer_clear(result);
ldns_buffer_write(result, ldns_buffer_begin(from), tocopy);
ldns_buffer_flip(result);
}
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (c) 1996, 1998 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
/*
* Portions Copyright (c) 1995 by International Business Machines, Inc.
*
* International Business Machines, Inc. (hereinafter called IBM) grants
* permission under its copyrights to use, copy, modify, and distribute this
* Software with or without fee, provided that the above copyright notice and
* all paragraphs of this notice appear in all copies, and that the name of IBM
* not be used in connection with the marketing of any product incorporating
* the Software or modifications thereof, without specific, written prior
* permission.
*
* To the extent it has a right to do so, IBM grants an immunity from suit
* under its patents, if any, for the use, sale or manufacture of products to
* the extent that such products are used for performing Domain Name System
* dynamic updates in TCP/IP networks by means of the Software. No immunity is
* granted for any product per se or for any other function of any product.
*
* THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
* DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#include <ldns/config.h>
#include <ldns/ldns.h>
#include <sys/types.h>
#include <sys/param.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Assert(Cond) if (!(Cond)) abort()
static const char Base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char Pad64 = '=';
/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
The following encoding technique is taken from RFC 1521 by Borenstein
and Freed. It is reproduced here in a slightly edited form for
convenience.
A 65-character subset of US-ASCII is used, enabling 6 bits to be
represented per printable character. (The extra 65th character, "=",
is used to signify a special processing function.)
The encoding process represents 24-bit groups of input bits as output
strings of 4 encoded characters. Proceeding from left to right, a
24-bit input group is formed by concatenating 3 8-bit input groups.
These 24 bits are then treated as 4 concatenated 6-bit groups, each
of which is translated into a single digit in the base64 alphabet.
Each 6-bit group is used as an index into an array of 64 printable
characters. The character referenced by the index is placed in the
output string.