mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 05:02:10 +00:00
Merge branch 'master' into smgmaster
This commit is contained in:
@@ -263,6 +263,19 @@
|
||||
/js/nsprpub/pr/tests/dll/Makefile
|
||||
/js/src/jsautocfg.h
|
||||
/js/src/perlconnect/Makefile.PL
|
||||
/ldns/Makefile
|
||||
/ldns/doc/ldns_manpages
|
||||
/ldns/include/
|
||||
/ldns/ldns/config.h
|
||||
/ldns/ldns/net.h
|
||||
/ldns/ldns/util.h
|
||||
/ldns/lib
|
||||
/ldns/libtool
|
||||
/ldns/linktest
|
||||
/ldns/linktest.dSYM/
|
||||
/ldns/packaging/ldns-config
|
||||
/ldns/packaging/libldns.pc
|
||||
/ldns-1.6.9/
|
||||
/libdingaling/Makefile
|
||||
/libdingaling/Makefile.in
|
||||
/libdingaling/aclocal.m4
|
||||
@@ -346,6 +359,7 @@
|
||||
/libg722_1/tests/Makefile
|
||||
/libg722_1/tests/Makefile.in
|
||||
/libg722_1/tests/regression_tests.sh
|
||||
/libg722_1/g722_1.pc
|
||||
/libsndfile/Cfg/compile
|
||||
/libsndfile/Cfg/config.guess
|
||||
/libsndfile/Cfg/config.sub
|
||||
@@ -1126,3 +1140,6 @@ BuildLog*.htm
|
||||
/win32/celt/*/*/libcelt.log
|
||||
/win32/libg722_1/*/*/libg722_1.log
|
||||
/win32/libshout/*/*/libshout.log
|
||||
openssl_manifest.rc
|
||||
libeay32_manifest.rc
|
||||
ssleay32_manifest.rc
|
||||
|
||||
+167
-54
@@ -31,6 +31,24 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
/* Use select on windows and poll everywhere else.
|
||||
Select is the devil. Especially if you are doing a lot of small socket connections.
|
||||
If your FD number is bigger than 1024 you will silently create memory corruption.
|
||||
|
||||
If you have build errors on your platform because you don't have poll find a way to detect it and #define ESL_USE_SELECT and #undef ESL_USE_POLL
|
||||
All of this will be upgraded to autoheadache eventually.
|
||||
*/
|
||||
|
||||
/* TBD for win32 figure out how to tell if you have WSAPoll (vista or higher) and use it when available by #defining ESL_USE_WSAPOLL (see below) */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define FD_SETSIZE 8192
|
||||
#define ESL_USE_SELECT
|
||||
#else
|
||||
#define ESL_USE_POLL
|
||||
#endif
|
||||
|
||||
#include <esl.h>
|
||||
#ifndef WIN32
|
||||
#define closesocket(x) close(x)
|
||||
@@ -42,6 +60,10 @@
|
||||
#pragma warning (default:6386)
|
||||
#endif
|
||||
|
||||
#ifdef ESL_USE_POLL
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Written by Marc Espie, public domain */
|
||||
#define ESL_CTYPE_NUM_CHARS 256
|
||||
@@ -614,6 +636,143 @@ ESL_DECLARE(esl_status_t) esl_listen(const char *host, esl_port_t port, esl_list
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* USE WSAPoll on vista or higher */
|
||||
#ifdef ESL_USE_WSAPOLL
|
||||
ESL_DECLARE(int) esl_wait_sock(esl_socket_t sock, uint32_t ms, esl_poll_t flags)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ESL_USE_SELECT
|
||||
#ifdef WIN32
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 6262 ) /* warning C6262: Function uses '98348' bytes of stack: exceeds /analyze:stacksize'16384'. Consider moving some data to heap */
|
||||
#endif
|
||||
ESL_DECLARE(int) esl_wait_sock(esl_socket_t sock, uint32_t ms, esl_poll_t flags)
|
||||
{
|
||||
int s = 0, r = 0;
|
||||
fd_set rfds;
|
||||
fd_set wfds;
|
||||
fd_set efds;
|
||||
struct timeval tv;
|
||||
|
||||
FD_ZERO(&rfds);
|
||||
FD_ZERO(&wfds);
|
||||
FD_ZERO(&efds);
|
||||
|
||||
/* Wouldn't you rather know?? */
|
||||
assert(sock <= FD_SETSIZE);
|
||||
|
||||
|
||||
if ((flags & ESL_POLL_READ)) {
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4127 )
|
||||
FD_SET(sock, &rfds);
|
||||
#pragma warning( pop )
|
||||
#else
|
||||
FD_SET(sock, &rfds);
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((flags & ESL_POLL_WRITE)) {
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4127 )
|
||||
FD_SET(sock, &wfds);
|
||||
#pragma warning( pop )
|
||||
#else
|
||||
FD_SET(sock, &wfds);
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((flags & ESL_POLL_ERROR)) {
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4127 )
|
||||
FD_SET(sock, &efds);
|
||||
#pragma warning( pop )
|
||||
#else
|
||||
FD_SET(sock, &efds);
|
||||
#endif
|
||||
}
|
||||
|
||||
tv.tv_sec = ms / 1000;
|
||||
tv.tv_usec = (ms % 1000) * ms;
|
||||
|
||||
s = select(sock + 1, (flags & ESL_POLL_READ) ? &rfds : NULL, (flags & ESL_POLL_WRITE) ? &wfds : NULL, (flags & ESL_POLL_ERROR) ? &efds : NULL, &tv);
|
||||
|
||||
if (s < 0) {
|
||||
r = s;
|
||||
} else if (s > 0) {
|
||||
if ((flags & ESL_POLL_READ) && FD_ISSET(sock, &rfds)) {
|
||||
r |= ESL_POLL_READ;
|
||||
}
|
||||
|
||||
if ((flags & ESL_POLL_WRITE) && FD_ISSET(sock, &wfds)) {
|
||||
r |= ESL_POLL_WRITE;
|
||||
}
|
||||
|
||||
if ((flags & ESL_POLL_ERROR) && FD_ISSET(sock, &efds)) {
|
||||
r |= ESL_POLL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
|
||||
}
|
||||
#ifdef WIN32
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ESL_USE_POLL
|
||||
ESL_DECLARE(int) esl_wait_sock(esl_socket_t sock, uint32_t ms, esl_poll_t flags)
|
||||
{
|
||||
struct pollfd pfds[2] = { { 0 } };
|
||||
int s = 0, r = 0;
|
||||
|
||||
pfds[0].fd = sock;
|
||||
|
||||
if ((flags & ESL_POLL_READ)) {
|
||||
pfds[0].events |= POLLIN;
|
||||
}
|
||||
|
||||
if ((flags & ESL_POLL_WRITE)) {
|
||||
pfds[0].events |= POLLOUT;
|
||||
}
|
||||
|
||||
if ((flags & ESL_POLL_ERROR)) {
|
||||
pfds[0].events |= POLLERR;
|
||||
}
|
||||
|
||||
s = poll(pfds, 1, ms);
|
||||
|
||||
if (s < 0) {
|
||||
r = s;
|
||||
} else if (s > 0) {
|
||||
if ((pfds[0].revents & POLLIN)) {
|
||||
r |= ESL_POLL_READ;
|
||||
}
|
||||
if ((pfds[0].revents & POLLOUT)) {
|
||||
r |= ESL_POLL_WRITE;
|
||||
}
|
||||
if ((pfds[0].revents & POLLERR)) {
|
||||
r |= ESL_POLL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char *host, esl_port_t port, const char *user, const char *password, uint32_t timeout)
|
||||
{
|
||||
char sendbuf[256];
|
||||
@@ -681,30 +840,17 @@ ESL_DECLARE(esl_status_t) esl_connect_timeout(esl_handle_t *handle, const char *
|
||||
rval = connect(handle->sock, (struct sockaddr*)&handle->sockaddr, sizeof(handle->sockaddr));
|
||||
|
||||
if (timeout) {
|
||||
fd_set wfds;
|
||||
struct timeval tv;
|
||||
int r;
|
||||
|
||||
tv.tv_sec = timeout / 1000;
|
||||
tv.tv_usec = (timeout % 1000) * 1000;
|
||||
FD_ZERO(&wfds);
|
||||
#ifdef WIN32
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4127 )
|
||||
FD_SET(handle->sock, &wfds);
|
||||
#pragma warning( pop )
|
||||
#else
|
||||
FD_SET(handle->sock, &wfds);
|
||||
#endif
|
||||
|
||||
r = select(handle->sock + 1, NULL, &wfds, NULL, &tv);
|
||||
r = esl_wait_sock(handle->sock, timeout, ESL_POLL_WRITE);
|
||||
|
||||
if (r <= 0) {
|
||||
snprintf(handle->err, sizeof(handle->err), "Connection timed out");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!FD_ISSET(handle->sock, &wfds)) {
|
||||
if (!(r & ESL_POLL_WRITE)) {
|
||||
snprintf(handle->err, sizeof(handle->err), "Connection timed out");
|
||||
goto fail;
|
||||
}
|
||||
@@ -823,9 +969,7 @@ ESL_DECLARE(esl_status_t) esl_disconnect(esl_handle_t *handle)
|
||||
|
||||
ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms, int check_q, esl_event_t **save_event)
|
||||
{
|
||||
fd_set rfds, efds;
|
||||
struct timeval tv = { 0 };
|
||||
int max, activity;
|
||||
int activity;
|
||||
esl_status_t status = ESL_SUCCESS;
|
||||
|
||||
if (!ms) {
|
||||
@@ -845,55 +989,24 @@ ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms
|
||||
esl_mutex_unlock(handle->mutex);
|
||||
}
|
||||
|
||||
tv.tv_usec = ms * 1000;
|
||||
|
||||
FD_ZERO(&rfds);
|
||||
FD_ZERO(&efds);
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4127 )
|
||||
FD_SET(handle->sock, &rfds);
|
||||
FD_SET(handle->sock, &efds);
|
||||
#pragma warning( pop )
|
||||
#else
|
||||
FD_SET(handle->sock, &rfds);
|
||||
FD_SET(handle->sock, &efds);
|
||||
#endif
|
||||
|
||||
max = handle->sock + 1;
|
||||
activity = esl_wait_sock(handle->sock, ms, ESL_POLL_READ|ESL_POLL_ERROR);
|
||||
|
||||
if ((activity = select(max, &rfds, NULL, &efds, &tv)) < 0) {
|
||||
if (activity < 0) {
|
||||
handle->connected = 0;
|
||||
return ESL_FAIL;
|
||||
}
|
||||
|
||||
if (activity == 0 || !FD_ISSET(handle->sock, &rfds) || (esl_mutex_trylock(handle->mutex) != ESL_SUCCESS)) {
|
||||
if (activity == 0 || !(activity & ESL_POLL_READ) || (esl_mutex_trylock(handle->mutex) != ESL_SUCCESS)) {
|
||||
return ESL_BREAK;
|
||||
}
|
||||
|
||||
tv.tv_usec = 0;
|
||||
activity = esl_wait_sock(handle->sock, ms, ESL_POLL_READ|ESL_POLL_ERROR);
|
||||
|
||||
FD_ZERO(&rfds);
|
||||
FD_ZERO(&efds);
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4127 )
|
||||
FD_SET(handle->sock, &rfds);
|
||||
FD_SET(handle->sock, &efds);
|
||||
#pragma warning( pop )
|
||||
#else
|
||||
FD_SET(handle->sock, &rfds);
|
||||
FD_SET(handle->sock, &efds);
|
||||
#endif
|
||||
|
||||
activity = select(max, &rfds, NULL, &efds, &tv);
|
||||
|
||||
if (activity < 0) {
|
||||
handle->connected = 0;
|
||||
status = ESL_FAIL;
|
||||
} else if (activity > 0 && FD_ISSET(handle->sock, &rfds)) {
|
||||
} else if (activity > 0 && (activity & ESL_POLL_READ)) {
|
||||
if (esl_recv_event(handle, check_q, save_event)) {
|
||||
status = ESL_FAIL;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,11 @@ extern "C" {
|
||||
typedef struct esl_event_header esl_event_header_t;
|
||||
typedef struct esl_event esl_event_t;
|
||||
|
||||
typedef enum {
|
||||
ESL_POLL_READ = (1 << 0),
|
||||
ESL_POLL_WRITE = (1 << 1),
|
||||
ESL_POLL_ERROR = (1 << 2)
|
||||
} esl_poll_t;
|
||||
|
||||
typedef enum {
|
||||
ESL_EVENT_TYPE_PLAIN,
|
||||
@@ -446,6 +451,8 @@ ESL_DECLARE(esl_status_t) esl_filter(esl_handle_t *handle, const char *header, c
|
||||
*/
|
||||
ESL_DECLARE(esl_status_t) esl_events(esl_handle_t *handle, esl_event_type_t etype, const char *value);
|
||||
|
||||
ESL_DECLARE(int) esl_wait_sock(esl_socket_t sock, uint32_t ms, esl_poll_t flags);
|
||||
|
||||
#define esl_recv(_h) esl_recv_event(_h, 0, NULL)
|
||||
#define esl_recv_timed(_h, _ms) esl_recv_event_timed(_h, _ms, 0, NULL)
|
||||
|
||||
|
||||
@@ -3615,7 +3615,7 @@ void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *
|
||||
"--------------------------------------------------------------------------------\n" \
|
||||
"ftdm list\n" \
|
||||
"ftdm start|stop <span_name|span_id>\n" \
|
||||
"ftdm restart <span_id|span_name> <chan_id>\n" \
|
||||
"ftdm restart <span_id|span_name> [<chan_id>]\n" \
|
||||
"ftdm dump <span_id|span_name> [<chan_id>]\n" \
|
||||
"ftdm sigstatus get|set [<span_id|span_name>] [<channel>] [<sigstatus>]\n" \
|
||||
"ftdm trace <path> <span_id|span_name> [<chan_id>]\n" \
|
||||
@@ -3818,7 +3818,7 @@ SWITCH_STANDARD_API(ft_function)
|
||||
"dial_regex: %s\n"
|
||||
"fail_dial_regex: %s\n"
|
||||
"hold_music: %s\n"
|
||||
"analog_options %s\n",
|
||||
"analog_options: %s\n",
|
||||
j,
|
||||
ftdm_span_get_name(SPAN_CONFIG[j].span),
|
||||
SPAN_CONFIG[j].type,
|
||||
@@ -3844,7 +3844,7 @@ SWITCH_STANDARD_API(ft_function)
|
||||
"dial_regex: %s\n"
|
||||
"fail_dial_regex: %s\n"
|
||||
"hold_music: %s\n"
|
||||
"analog_options %s\n",
|
||||
"analog_options: %s\n",
|
||||
j,
|
||||
ftdm_span_get_name(SPAN_CONFIG[j].span),
|
||||
SPAN_CONFIG[j].type,
|
||||
@@ -4141,10 +4141,11 @@ SWITCH_STANDARD_API(ft_function)
|
||||
stream->write_function(stream, "+OK queue sizes set to Rx %d and Tx %d\n", rxsize, txsize);
|
||||
} else if (!strcasecmp(argv[0], "restart")) {
|
||||
uint32_t chan_id = 0;
|
||||
uint32_t ccount = 0;
|
||||
ftdm_channel_t *chan;
|
||||
ftdm_span_t *span = NULL;
|
||||
if (argc < 3) {
|
||||
stream->write_function(stream, "-ERR Usage: ftdm restart <span_id> <chan_id>\n");
|
||||
if (argc < 2) {
|
||||
stream->write_function(stream, "-ERR Usage: ftdm restart <span_id> [<chan_id>]\n");
|
||||
goto end;
|
||||
}
|
||||
ftdm_span_find_by_name(argv[1], &span);
|
||||
@@ -4152,15 +4153,32 @@ SWITCH_STANDARD_API(ft_function)
|
||||
stream->write_function(stream, "-ERR invalid span\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
chan_id = atoi(argv[2]);
|
||||
chan = ftdm_span_get_channel(span, chan_id);
|
||||
if (!chan) {
|
||||
stream->write_function(stream, "-ERR Could not find chan\n");
|
||||
goto end;
|
||||
|
||||
if (argc > 2) {
|
||||
chan_id = atoi(argv[2]);
|
||||
if (chan_id > ftdm_span_get_chan_count(span)) {
|
||||
stream->write_function(stream, "-ERR invalid chan\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
stream->write_function(stream, "Resetting channel %s:%s\n", argv[2], argv[3]);
|
||||
ftdm_channel_reset(chan);
|
||||
if (chan_id) {
|
||||
chan = ftdm_span_get_channel(span, chan_id);
|
||||
if (!chan) {
|
||||
stream->write_function(stream, "-ERR Could not find chan\n");
|
||||
goto end;
|
||||
}
|
||||
stream->write_function(stream, "Resetting channel %s:%s\n", argv[1], argv[2]);
|
||||
ftdm_channel_reset(chan);
|
||||
} else {
|
||||
uint32_t i = 0;
|
||||
ccount = ftdm_span_get_chan_count(span);
|
||||
for (i = 1; i < ccount; i++) {
|
||||
chan = ftdm_span_get_channel(span, i);
|
||||
stream->write_function(stream, "Resetting channel %s:%d\n", argv[1], i);
|
||||
ftdm_channel_reset(chan);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
char *rply = ftdm_api_execute(cmd);
|
||||
@@ -4280,7 +4298,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load)
|
||||
SWITCH_ADD_API(commands_api_interface, "ftdm", "FreeTDM commands", ft_function, FT_SYNTAX);
|
||||
switch_console_set_complete("add ftdm start");
|
||||
switch_console_set_complete("add ftdm stop");
|
||||
switch_console_set_complete("add ftdm retart");
|
||||
switch_console_set_complete("add ftdm restart");
|
||||
switch_console_set_complete("add ftdm dump");
|
||||
switch_console_set_complete("add ftdm sigstatus get");
|
||||
switch_console_set_complete("add ftdm sigstatus set");
|
||||
|
||||
@@ -662,7 +662,7 @@ void sngisdn_process_rel_ind (sngisdn_event_data_t *sngisdn_event)
|
||||
}
|
||||
break;
|
||||
case FTDM_CHANNEL_STATE_RESET:
|
||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Processing SETUP but channel in RESET state, ignoring\n");
|
||||
ftdm_log_chan_msg(ftdmchan, FTDM_LOG_DEBUG, "Processing RELEASE but channel in RESET state, ignoring\n");
|
||||
break;
|
||||
default:
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_CRIT, "Received RELEASE in an invalid state (%s)\n",
|
||||
|
||||
@@ -60,7 +60,7 @@ void sngisdn_snd_setup(ftdm_channel_t *ftdmchan)
|
||||
}
|
||||
ftdm_log_chan(sngisdn_info->ftdmchan, FTDM_LOG_INFO, "Outgoing call: Called No:[%s] Calling No:[%s]\n", ftdmchan->caller_data.dnis.digits, ftdmchan->caller_data.cid_num.digits);
|
||||
|
||||
set_chan_id_ie(ftdmchan, &conEvnt.chanId);
|
||||
set_chan_id_ie(ftdmchan, &conEvnt.chanId);
|
||||
set_bear_cap_ie(ftdmchan, &conEvnt.bearCap[0]);
|
||||
set_called_num(ftdmchan, &conEvnt.cdPtyNmb);
|
||||
set_calling_num(ftdmchan, &conEvnt.cgPtyNmb);
|
||||
@@ -125,8 +125,11 @@ void sngisdn_snd_con_complete(ftdm_channel_t *ftdmchan)
|
||||
}
|
||||
|
||||
memset(&cnStEvnt, 0, sizeof(cnStEvnt));
|
||||
|
||||
set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
|
||||
|
||||
/* Indicate channel ID only in first response */
|
||||
if (!ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) {
|
||||
set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
|
||||
}
|
||||
|
||||
ftdm_log_chan(ftdmchan, FTDM_LOG_INFO, "Sending CONNECT COMPL (suId:%d suInstId:%u spInstId:%u dchan:%d ces:%d)\n", signal_data->cc_id, sngisdn_info->suInstId, sngisdn_info->spInstId, signal_data->dchan_id, sngisdn_info->ces);
|
||||
|
||||
@@ -152,7 +155,10 @@ void sngisdn_snd_proceed(ftdm_channel_t *ftdmchan, ftdm_sngisdn_progind_t prog_i
|
||||
|
||||
memset(&cnStEvnt, 0, sizeof(cnStEvnt));
|
||||
|
||||
set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
|
||||
/* Indicate channel ID only in first response */
|
||||
if (!ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) {
|
||||
set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
|
||||
}
|
||||
set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind);
|
||||
set_facility_ie(ftdmchan, &cnStEvnt.facilityStr);
|
||||
|
||||
@@ -238,7 +244,10 @@ void sngisdn_snd_connect(ftdm_channel_t *ftdmchan)
|
||||
|
||||
memset(&cnStEvnt, 0, sizeof(cnStEvnt));
|
||||
|
||||
set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
|
||||
/* Indicate channel ID only in first response */
|
||||
if (!ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) {
|
||||
set_chan_id_ie(ftdmchan, &cnStEvnt.chanId);
|
||||
}
|
||||
set_prog_ind_ie(ftdmchan, &cnStEvnt.progInd, prog_ind);
|
||||
set_facility_ie(ftdmchan, &cnStEvnt.facilityStr);
|
||||
|
||||
|
||||
@@ -830,10 +830,6 @@ ftdm_status_t set_chan_id_ie(ftdm_channel_t *ftdmchan, ChanId *chanId)
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
if (ftdm_test_flag(sngisdn_info, FLAG_SENT_CHAN_ID)) {
|
||||
/* Indicate channel ID only in first response */
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
ftdm_set_flag(sngisdn_info, FLAG_SENT_CHAN_ID);
|
||||
|
||||
chanId->eh.pres = PRSNT_NODEF;
|
||||
|
||||
@@ -207,9 +207,10 @@ int ft_to_sngss7_cfg_all(void)
|
||||
|
||||
/* go through all the relays channels and configure it */
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) {
|
||||
while (x < (MAX_RELAY_CHANNELS)) {
|
||||
/* check if this relay channel has been configured already */
|
||||
if (!(g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.relay[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED))) {
|
||||
|
||||
/* send the specific configuration */
|
||||
if (ftmod_ss7_relay_chan_config(x)) {
|
||||
@@ -223,13 +224,13 @@ int ft_to_sngss7_cfg_all(void)
|
||||
g_ftdm_sngss7_data.cfg.relay[x].flags |= SNGSS7_CONFIGURED;
|
||||
} /* if !SNGSS7_CONFIGURED */
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) */
|
||||
} /* while (x < (MAX_RELAY_CHANNELS)) */
|
||||
|
||||
x = 1;
|
||||
while (x < (MAX_MTP_LINKS + 1)) {
|
||||
while (x < (MAX_MTP_LINKS)) {
|
||||
/* check if this link has been configured already */
|
||||
if (!(g_ftdm_sngss7_data.cfg.mtp1Link[x].flags & SNGSS7_CONFIGURED) &&
|
||||
(g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.mtp1Link[x].flags & SNGSS7_CONFIGURED))) {
|
||||
|
||||
/* configure mtp1 */
|
||||
if (ftmod_ss7_mtp1_psap_config(x)) {
|
||||
@@ -243,13 +244,13 @@ int ft_to_sngss7_cfg_all(void)
|
||||
g_ftdm_sngss7_data.cfg.mtp1Link[x].flags |= SNGSS7_CONFIGURED;
|
||||
}
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.mtp1Link[x].id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
x = 1;
|
||||
while (x < (MAX_MTP_LINKS + 1)) {
|
||||
while (x < (MAX_MTP_LINKS)) {
|
||||
/* check if this link has been configured already */
|
||||
if (!(g_ftdm_sngss7_data.cfg.mtp2Link[x].flags & SNGSS7_CONFIGURED) &&
|
||||
(g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.mtp2Link[x].flags & SNGSS7_CONFIGURED))) {
|
||||
|
||||
/* configure mtp2 */
|
||||
if (ftmod_ss7_mtp2_dlsap_config(x)) {
|
||||
@@ -263,13 +264,13 @@ int ft_to_sngss7_cfg_all(void)
|
||||
g_ftdm_sngss7_data.cfg.mtp2Link[x].flags |= SNGSS7_CONFIGURED;
|
||||
}
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
x = 1;
|
||||
while (x < (MAX_MTP_LINKS + 1)) {
|
||||
while (x < (MAX_MTP_LINKS)) {
|
||||
/* check if this link has been configured already */
|
||||
if (!(g_ftdm_sngss7_data.cfg.mtp3Link[x].flags & SNGSS7_CONFIGURED) &&
|
||||
(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.mtp3Link[x].flags & SNGSS7_CONFIGURED))) {
|
||||
|
||||
/* configure mtp3 */
|
||||
if (ftmod_ss7_mtp3_dlsap_config(x)) {
|
||||
@@ -284,12 +285,13 @@ int ft_to_sngss7_cfg_all(void)
|
||||
}
|
||||
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) {
|
||||
while (x < (MAX_NSAPS)) {
|
||||
/* check if this link has been configured already */
|
||||
if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_CONFIGURED)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.nsap[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_CONFIGURED))) {
|
||||
|
||||
ret = ftmod_ss7_mtp3_nsap_config(x);
|
||||
if (ret) {
|
||||
@@ -312,12 +314,13 @@ int ft_to_sngss7_cfg_all(void)
|
||||
} /* if !SNGSS7_CONFIGURED */
|
||||
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) */
|
||||
} /* while (x < (MAX_NSAPS)) */
|
||||
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
|
||||
while (x < (MAX_MTP_LINKSETS+1)) {
|
||||
/* check if this link has been configured already */
|
||||
if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_CONFIGURED)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_CONFIGURED))) {
|
||||
|
||||
if (ftmod_ss7_mtp3_linkset_config(x)) {
|
||||
SS7_CRITICAL("MTP3 LINKSET %d configuration FAILED!\n", x);
|
||||
@@ -331,12 +334,13 @@ int ft_to_sngss7_cfg_all(void)
|
||||
} /* if !SNGSS7_CONFIGURED */
|
||||
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKSETS+1)) */
|
||||
|
||||
x = 1;
|
||||
while ((g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0)) {
|
||||
while (x < (MAX_MTP_ROUTES+1)) {
|
||||
/* check if this link has been configured already */
|
||||
if (!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags & SNGSS7_CONFIGURED)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.mtpRoute[x].flags & SNGSS7_CONFIGURED))) {
|
||||
|
||||
if (ftmod_ss7_mtp3_route_config(x)) {
|
||||
SS7_CRITICAL("MTP3 ROUTE %d configuration FAILED!\n", x);
|
||||
@@ -350,12 +354,13 @@ int ft_to_sngss7_cfg_all(void)
|
||||
} /* if !SNGSS7_CONFIGURED */
|
||||
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.mtpRoute[x].id != 0) */
|
||||
} /* while (x < (MAX_MTP_ROUTES+1)) */
|
||||
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) {
|
||||
while (x < (MAX_ISAPS)) {
|
||||
/* check if this link has been configured already */
|
||||
if (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_CONFIGURED)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.isap[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_CONFIGURED))) {
|
||||
|
||||
if (ftmod_ss7_isup_isap_config(x)) {
|
||||
SS7_CRITICAL("ISUP ISAP %d configuration FAILED!\n", x);
|
||||
@@ -369,13 +374,14 @@ int ft_to_sngss7_cfg_all(void)
|
||||
} /* if !SNGSS7_CONFIGURED */
|
||||
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) */
|
||||
} /* while (x < (MAX_ISAPS)) */
|
||||
|
||||
if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) {
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) {
|
||||
while (x < (MAX_ISUP_INFS)) {
|
||||
/* check if this link has been configured already */
|
||||
if (!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags & SNGSS7_CONFIGURED)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.isupIntf[x].flags & SNGSS7_CONFIGURED))) {
|
||||
|
||||
if (ftmod_ss7_isup_intf_config(x)) {
|
||||
SS7_CRITICAL("ISUP INTF %d configuration FAILED!\n", x);
|
||||
@@ -391,21 +397,25 @@ int ft_to_sngss7_cfg_all(void)
|
||||
} /* if !SNGSS7_CONFIGURED */
|
||||
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.isupIntf[x].id != 0) */
|
||||
} /* while (x < (MAX_ISUP_INFS)) */
|
||||
} /* if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_ISUP)) */
|
||||
|
||||
x = (g_ftdm_sngss7_data.cfg.procId * 1000) + 1;
|
||||
while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) {
|
||||
/* check if this link has been configured already */
|
||||
if ((g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.isupCkt[x].flags & SNGSS7_CONFIGURED))) {
|
||||
|
||||
if (ftmod_ss7_isup_ckt_config(x)) {
|
||||
SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", x);
|
||||
return 1;
|
||||
} else {
|
||||
SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
|
||||
}
|
||||
if (ftmod_ss7_isup_ckt_config(x)) {
|
||||
SS7_CRITICAL("ISUP CKT %d configuration FAILED!\n", x);
|
||||
return 1;
|
||||
} else {
|
||||
SS7_INFO("ISUP CKT %d configuration DONE!\n", x);
|
||||
}
|
||||
|
||||
/* set the SNGSS7_CONFIGURED flag */
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
|
||||
/* set the SNGSS7_CONFIGURED flag */
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[x].flags |= SNGSS7_CONFIGURED;
|
||||
} /* if !SNGSS7_CONFIGURED */
|
||||
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.isupCkt[x].id != 0) */
|
||||
|
||||
@@ -724,6 +724,9 @@ static ftdm_status_t handle_print_usuage(ftdm_stream_handle_t *stream)
|
||||
stream->write_function(stream, "ftdm ss7 lpo link X\n");
|
||||
stream->write_function(stream, "ftdm ss7 lpr link X\n");
|
||||
stream->write_function(stream, "\n");
|
||||
stream->write_function(stream, "Ftmod_sangoma_ss7 Relay status:\n");
|
||||
stream->write_function(stream, "ftdm ss7 show status relay X\n");
|
||||
stream->write_function(stream, "\n");
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
@@ -1207,8 +1210,8 @@ static ftdm_status_t handle_show_status(ftdm_stream_handle_t *stream, int span,
|
||||
stream->write_function(stream, "r_hw=N|");
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_flag(ss7_info, FLAG_RELAY_DOWN)) {
|
||||
stream->write_function(stream, "relay=Y");
|
||||
if (sngss7_test_ckt_blk_flag(ss7_info, FLAG_RELAY_DOWN)) {
|
||||
stream->write_function(stream, "relay=Y|");
|
||||
}else {
|
||||
stream->write_function(stream, "relay=N");
|
||||
}
|
||||
@@ -1366,7 +1369,7 @@ static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char *
|
||||
|
||||
/* find the link request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
|
||||
|
||||
/* send the status request */
|
||||
@@ -1392,7 +1395,7 @@ static ftdm_status_t handle_status_mtp3link(ftdm_stream_handle_t *stream, char *
|
||||
|
||||
/* move to the next link */
|
||||
x++;
|
||||
} /* while (id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
stream->write_function(stream, "Failed to find link=\"%s\"\n", name);
|
||||
|
||||
@@ -1408,7 +1411,7 @@ static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char *
|
||||
|
||||
/* find the link request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp2Link[x].name, name)) {
|
||||
|
||||
/* send the status request */
|
||||
@@ -1436,7 +1439,7 @@ static ftdm_status_t handle_status_mtp2link(ftdm_stream_handle_t *stream, char *
|
||||
|
||||
/* move to the next link */
|
||||
x++;
|
||||
} /* while (id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
stream->write_function(stream, "Failed to find link=\"%s\"\n", name);
|
||||
|
||||
@@ -1452,7 +1455,7 @@ static ftdm_status_t handle_status_linkset(ftdm_stream_handle_t *stream, char *n
|
||||
|
||||
/* find the linkset request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKSETS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) {
|
||||
|
||||
/* send the status request */
|
||||
@@ -1487,7 +1490,7 @@ static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name
|
||||
|
||||
/* find the link request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
|
||||
|
||||
/* send the inhibit request */
|
||||
@@ -1504,7 +1507,7 @@ static ftdm_status_t handle_set_inhibit(ftdm_stream_handle_t *stream, char *name
|
||||
|
||||
/* move to the next linkset */
|
||||
x++;
|
||||
} /* while (id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
stream->write_function(stream, "Failed to find link=\"%s\"\n", name);
|
||||
|
||||
@@ -1519,7 +1522,7 @@ static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *na
|
||||
|
||||
/* find the link request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
|
||||
|
||||
/* send the uninhibit request */
|
||||
@@ -1536,7 +1539,7 @@ static ftdm_status_t handle_set_uninhibit(ftdm_stream_handle_t *stream, char *na
|
||||
|
||||
/* move to the next linkset */
|
||||
x++;
|
||||
} /* while (id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
stream->write_function(stream, "Failed to find link=\"%s\"\n", name);
|
||||
|
||||
@@ -1891,7 +1894,7 @@ static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name)
|
||||
|
||||
/* find the link request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
|
||||
|
||||
/* send the uninhibit request */
|
||||
@@ -1907,7 +1910,7 @@ static ftdm_status_t handle_bind_link(ftdm_stream_handle_t *stream, char *name)
|
||||
|
||||
/* move to the next link */
|
||||
x++;
|
||||
} /* while (id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
stream->write_function(stream, "Could not find link=%s\n", name);
|
||||
|
||||
@@ -1922,7 +1925,7 @@ static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name
|
||||
|
||||
/* find the link request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
|
||||
|
||||
/* send the uninhibit request */
|
||||
@@ -1938,7 +1941,7 @@ static ftdm_status_t handle_unbind_link(ftdm_stream_handle_t *stream, char *name
|
||||
|
||||
/* move to the next link */
|
||||
x++;
|
||||
} /* while (id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
stream->write_function(stream, "Could not find link=%s\n", name);
|
||||
|
||||
@@ -1953,7 +1956,7 @@ static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *na
|
||||
|
||||
/* find the link request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
|
||||
|
||||
/* send the uninhibit request */
|
||||
@@ -1969,7 +1972,7 @@ static ftdm_status_t handle_activate_link(ftdm_stream_handle_t *stream, char *na
|
||||
|
||||
/* move to the next link */
|
||||
x++;
|
||||
} /* while (id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
stream->write_function(stream, "Could not find link=%s\n", name);
|
||||
|
||||
@@ -1984,7 +1987,7 @@ static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char *
|
||||
|
||||
/* find the link request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
|
||||
|
||||
/* send the deactivate request */
|
||||
@@ -2000,7 +2003,7 @@ static ftdm_status_t handle_deactivate_link(ftdm_stream_handle_t *stream, char *
|
||||
|
||||
/* move to the next link */
|
||||
x++;
|
||||
} /* while (id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
stream->write_function(stream, "Could not find link=%s\n", name);
|
||||
|
||||
@@ -2015,7 +2018,7 @@ static ftdm_status_t handle_activate_linkset(ftdm_stream_handle_t *stream, char
|
||||
|
||||
/* find the linkset request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKSETS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) {
|
||||
|
||||
/* send the activate request */
|
||||
@@ -2046,7 +2049,7 @@ static ftdm_status_t handle_deactivate_linkset(ftdm_stream_handle_t *stream, cha
|
||||
|
||||
/* find the linkset request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKSETS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name, name)) {
|
||||
|
||||
/* send the deactivate request */
|
||||
@@ -2078,7 +2081,7 @@ static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name)
|
||||
|
||||
/* find the link request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
|
||||
|
||||
/* send the uninhibit request */
|
||||
@@ -2094,7 +2097,7 @@ static ftdm_status_t handle_tx_lpo(ftdm_stream_handle_t *stream, char *name)
|
||||
|
||||
/* move to the next link */
|
||||
x++;
|
||||
} /* while (id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
stream->write_function(stream, "Could not find link=%s\n", name);
|
||||
|
||||
@@ -2109,7 +2112,7 @@ static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name)
|
||||
|
||||
/* find the link request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
|
||||
while(x < (MAX_MTP_LINKS+1)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.mtp3Link[x].name, name)) {
|
||||
|
||||
/* send the uninhibit request */
|
||||
@@ -2125,7 +2128,7 @@ static ftdm_status_t handle_tx_lpr(ftdm_stream_handle_t *stream, char *name)
|
||||
|
||||
/* move to the next link */
|
||||
x++;
|
||||
} /* while (id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKS+1)) */
|
||||
|
||||
stream->write_function(stream, "Could not find link=%s\n", name);
|
||||
|
||||
@@ -2144,7 +2147,7 @@ static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *nam
|
||||
|
||||
/* find the channel request by it's name */
|
||||
x = 1;
|
||||
while(g_ftdm_sngss7_data.cfg.relay[x].id != 0) {
|
||||
while(x < (MAX_RELAY_CHANNELS)) {
|
||||
if (!strcasecmp(g_ftdm_sngss7_data.cfg.relay[x].name, name)) {
|
||||
|
||||
if (ftmod_ss7_relay_status(g_ftdm_sngss7_data.cfg.relay[x].id, &sta)) {
|
||||
@@ -2168,7 +2171,7 @@ static ftdm_status_t handle_status_relay(ftdm_stream_handle_t *stream, char *nam
|
||||
/* move to the next link */
|
||||
x++;
|
||||
|
||||
} /* g_ftdm_sngss7_data.cfg.relay[x].id */
|
||||
} /* x < (MAX_RELAY_CHANNELS) */
|
||||
|
||||
success:
|
||||
return FTDM_SUCCESS;
|
||||
|
||||
@@ -85,9 +85,10 @@ int ft_to_sngss7_activate_all(void)
|
||||
int x;
|
||||
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) {
|
||||
while (x < (MAX_ISAPS)) {
|
||||
/* check if this link has already been actived */
|
||||
if (!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_ACTIVE)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.isap[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.isap[x].flags & SNGSS7_ACTIVE))) {
|
||||
|
||||
if (ftmod_ss7_enable_isap(x)) {
|
||||
SS7_CRITICAL("ISAP %d Enable: NOT OK\n", x);
|
||||
@@ -101,12 +102,13 @@ int ft_to_sngss7_activate_all(void)
|
||||
} /* if !SNGSS7_ACTIVE */
|
||||
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) */
|
||||
} /* while (x < (MAX_ISAPS)) */
|
||||
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) {
|
||||
while (x < (MAX_NSAPS)) {
|
||||
/* check if this link has already been actived */
|
||||
if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_ACTIVE)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.nsap[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.nsap[x].flags & SNGSS7_ACTIVE))) {
|
||||
|
||||
if (ftmod_ss7_enable_nsap(x)) {
|
||||
SS7_CRITICAL("NSAP %d Enable: NOT OK\n", x);
|
||||
@@ -120,13 +122,14 @@ int ft_to_sngss7_activate_all(void)
|
||||
} /* if !SNGSS7_ACTIVE */
|
||||
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) */
|
||||
} /* while (x < (MAX_NSAPS)) */
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.mtpRoute[1].id != 0) {
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
|
||||
while (x < (MAX_MTP_LINKSETS+1)) {
|
||||
/* check if this link has already been actived */
|
||||
if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_ACTIVE)) {
|
||||
if ((g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) &&
|
||||
(!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & SNGSS7_ACTIVE))) {
|
||||
|
||||
if (ftmod_ss7_enable_mtpLinkSet(x)) {
|
||||
SS7_CRITICAL("LinkSet \"%s\" Enable: NOT OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);
|
||||
@@ -140,7 +143,7 @@ int ft_to_sngss7_activate_all(void)
|
||||
} /* if !SNGSS7_ACTIVE */
|
||||
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */
|
||||
} /* while (x < (MAX_MTP_LINKSETS+1)) */
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1565,6 +1565,9 @@ ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
|
||||
/* throw the unblock flag */
|
||||
sngss7_set_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_UNBLK_RX);
|
||||
|
||||
/* clear the block flag */
|
||||
sngss7_clear_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX);
|
||||
|
||||
/* set the channel to suspended state */
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
|
||||
|
||||
|
||||
@@ -466,13 +466,7 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
|
||||
uint32_t intfId;
|
||||
int x;
|
||||
|
||||
/* confirm that the circuit is active on our side otherwise move to the next circuit */
|
||||
if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[circuit], SNGSS7_ACTIVE)) {
|
||||
SS7_ERROR("[CIC:%d]Rx %s but circuit is not active yet, skipping!\n",
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
|
||||
DECODE_LCC_EVENT(evntType));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* check if the eventType is a pause/resume */
|
||||
switch (evntType) {
|
||||
@@ -503,6 +497,14 @@ void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint
|
||||
if (g_ftdm_sngss7_data.cfg.isupCkt[x].infId == intfId) {
|
||||
/* we have a match, setup the pointers to the correct values */
|
||||
circuit = x;
|
||||
|
||||
/* confirm that the circuit is active on our side otherwise move to the next circuit */
|
||||
if (!sngss7_test_flag(&g_ftdm_sngss7_data.cfg.isupCkt[circuit], SNGSS7_ACTIVE)) {
|
||||
SS7_DEBUG("[CIC:%d]Rx %s but circuit is not active yet, skipping!\n",
|
||||
g_ftdm_sngss7_data.cfg.isupCkt[circuit].cic,
|
||||
DECODE_LCC_EVENT(evntType));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
|
||||
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
|
||||
|
||||
@@ -134,7 +134,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
|
||||
|
||||
/* find the name for the sap in question */
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
|
||||
while (x < (MAX_MTP_LINKS+1)) {
|
||||
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
|
||||
break;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
|
||||
|
||||
/* find the name for the sap in question */
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
|
||||
while (x < (MAX_MTP_LINKS+1)) {
|
||||
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
|
||||
break;
|
||||
}
|
||||
@@ -198,7 +198,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
|
||||
|
||||
/* find the name for the sap in question */
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
|
||||
while (x < (MAX_MTP_LINKS+1)) {
|
||||
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
|
||||
break;
|
||||
}
|
||||
@@ -222,7 +222,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
|
||||
|
||||
/* find the name for the sap in question */
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
|
||||
while (x < (MAX_MTP_LINKS+1)) {
|
||||
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
|
||||
break;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
|
||||
|
||||
/* find the name for the sap in question */
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
|
||||
while (x < (MAX_MTP_LINKS+1)) {
|
||||
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
|
||||
break;
|
||||
}
|
||||
@@ -271,7 +271,7 @@ void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
|
||||
|
||||
/* find the name for the sap in question */
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.mtp2Link[x].id != 0) {
|
||||
while (x < (MAX_MTP_LINKS+1)) {
|
||||
if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
|
||||
break;
|
||||
}
|
||||
@@ -366,7 +366,7 @@ void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)
|
||||
|
||||
/* find the name for the sap in question */
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.mtp3Link[x].id != 0) {
|
||||
while (x < (MAX_MTP_LINKS+1)) {
|
||||
if (g_ftdm_sngss7_data.cfg.mtp3Link[x].id == sta->hdr.elmId.elmntInst1) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,15 @@ ftdm_state_map_t sangoma_ss7_state_map = {
|
||||
{FTDM_CHANNEL_STATE_RING, FTDM_END},
|
||||
{FTDM_CHANNEL_STATE_SUSPENDED, FTDM_CHANNEL_STATE_RESTART,
|
||||
FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP,
|
||||
FTDM_CHANNEL_STATE_PROGRESS, FTDM_END}
|
||||
FTDM_CHANNEL_STATE_RINGING, FTDM_CHANNEL_STATE_PROGRESS, FTDM_END}
|
||||
},
|
||||
{
|
||||
ZSD_INBOUND,
|
||||
ZSM_UNACCEPTABLE,
|
||||
{FTDM_CHANNEL_STATE_RINGING, FTDM_END},
|
||||
{FTDM_CHANNEL_STATE_TERMINATING, FTDM_CHANNEL_STATE_HANGUP,
|
||||
FTDM_CHANNEL_STATE_PROGRESS, FTDM_CHANNEL_STATE_PROGRESS_MEDIA,
|
||||
FTDM_CHANNEL_STATE_UP, FTDM_END},
|
||||
},
|
||||
{
|
||||
ZSD_INBOUND,
|
||||
@@ -609,6 +617,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
|
||||
break;
|
||||
/**************************************************************************/
|
||||
/* We handle RING indication the same way we would indicate PROGRESS */
|
||||
case FTDM_CHANNEL_STATE_RINGING:
|
||||
case FTDM_CHANNEL_STATE_PROGRESS:
|
||||
|
||||
if (ftdmchan->last_state == FTDM_CHANNEL_STATE_SUSPENDED) {
|
||||
@@ -626,7 +636,10 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
ftdm_set_state(ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
|
||||
} else {
|
||||
/* inbound call so we need to send out ACM */
|
||||
ft_to_sngss7_acm(ftdmchan);
|
||||
if (!sngss7_test_ckt_flag(sngss7_info, FLAG_SENT_ACM)) {
|
||||
sngss7_set_ckt_flag(sngss7_info, FLAG_SENT_ACM);
|
||||
ft_to_sngss7_acm(ftdmchan);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -877,6 +890,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
/* clear any call related flags */
|
||||
sngss7_clear_ckt_flag (sngss7_info, FLAG_REMOTE_REL);
|
||||
sngss7_clear_ckt_flag (sngss7_info, FLAG_LOCAL_REL);
|
||||
sngss7_clear_ckt_flag (sngss7_info, FLAG_SENT_ACM);
|
||||
|
||||
|
||||
if (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_OPEN)) {
|
||||
@@ -1049,18 +1063,20 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
}
|
||||
} /* if (sngss7_test_flag(sngss7_info, FLAG_INFID_RESUME)) */
|
||||
|
||||
if ((sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) &&
|
||||
(ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP))) {
|
||||
if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) {
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing PAUSE%s\n", "");
|
||||
|
||||
/* bring the sig status down */
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
|
||||
if (ftdm_test_flag(ftdmchan, FTDM_CHANNEL_SIG_UP)) {
|
||||
/* bring the sig status down */
|
||||
sngss7_set_sig_status(sngss7_info, FTDM_SIG_STATE_DOWN);
|
||||
}
|
||||
} /* if (sngss7_test_ckt_flag(sngss7_info, FLAG_INFID_PAUSED)) { */
|
||||
|
||||
/**********************************************************************/
|
||||
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX) &&
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_BLOCK_RX) &&
|
||||
!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_RX_DN)) {
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_RX flag %s\n", "");
|
||||
|
||||
/* bring the sig status down */
|
||||
@@ -1076,8 +1092,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
goto suspend_goto_last;
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX) &&
|
||||
!sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX_DN)){
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_RX)){
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_RX flag %s\n", "");
|
||||
|
||||
/* clear the block flags */
|
||||
@@ -1100,6 +1115,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
/**********************************************************************/
|
||||
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX) &&
|
||||
!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_MN_BLOCK_TX_DN)) {
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_BLOCK_TX flag %s\n", "");
|
||||
|
||||
/* bring the sig status down */
|
||||
@@ -1115,8 +1131,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
goto suspend_goto_last;
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX) &&
|
||||
!sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX_DN)){
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_MN_UNBLK_TX)) {
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_MN_UNBLK_TX flag %s\n", "");
|
||||
|
||||
/* clear the block flags */
|
||||
@@ -1139,6 +1155,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
/**********************************************************************/
|
||||
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX) &&
|
||||
!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_BLOCK_RX_DN)) {
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_BLOCK_RX flag %s\n", "");
|
||||
|
||||
/* send a BLA */
|
||||
@@ -1151,8 +1168,8 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
goto suspend_goto_last;
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX) &&
|
||||
!sngss7_test_ckt_blk_flag(sngss7_info, FLAG_CKT_LC_UNBLK_RX_DN)) {
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_LC_UNBLK_RX)) {
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_LC_UNBLK_RX flag %s\n", "");
|
||||
|
||||
/* clear the block flags */
|
||||
@@ -1172,6 +1189,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
/**********************************************************************/
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK) &&
|
||||
!sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_BLOCK_DN)) {
|
||||
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_BLOCK flag %s\n", "");
|
||||
|
||||
/* bring the channel signaling status to down */
|
||||
@@ -1192,8 +1210,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
goto suspend_goto_last;
|
||||
}
|
||||
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK) &&
|
||||
!sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK_DN)) {
|
||||
if (sngss7_test_ckt_blk_flag (sngss7_info, FLAG_CKT_UCIC_UNBLK)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "Processing CKT_UCIC_UNBLK flag %s\n", "");
|
||||
|
||||
/* remove the UCIC block flag */
|
||||
@@ -1210,7 +1227,7 @@ ftdm_status_t ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
|
||||
goto suspend_goto_restart;
|
||||
}
|
||||
|
||||
SS7_ERROR_CHAN(ftdmchan,"No block flag processed!%s\n", "");
|
||||
SS7_DEBUG_CHAN(ftdmchan,"No block flag processed!%s\n", "");
|
||||
|
||||
suspend_goto_last:
|
||||
state_flag = 0;
|
||||
@@ -1370,19 +1387,7 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
|
||||
ftdm_clear_flag (span, FTDM_SPAN_STOP_THREAD);
|
||||
ftdm_clear_flag (span, FTDM_SPAN_IN_THREAD);
|
||||
|
||||
/* activate all the configured ss7 links */
|
||||
if (ft_to_sngss7_activate_all()) {
|
||||
SS7_CRITICAL ("Failed to activate LibSngSS7!\n");
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
/*start the span monitor thread */
|
||||
if (ftdm_thread_create_detached (ftdm_sangoma_ss7_run, span) != FTDM_SUCCESS) {
|
||||
SS7_CRITICAL ("Failed to start Span Monitor Thread!\n");
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
/* confirm the state of all isup interfaces*/
|
||||
/* check the status of all isup interfaces */
|
||||
check_status_of_all_isup_intf();
|
||||
|
||||
/* throw the channels in pause */
|
||||
@@ -1397,15 +1402,15 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
|
||||
sngss7_span = ftdmchan->span->signal_data;
|
||||
sngss7_intf = &g_ftdm_sngss7_data.cfg.isupIntf[sngss7_info->circuit->infId];
|
||||
|
||||
/* if this is a non-voice channel, move along */
|
||||
/* flag the circuit as active so we can receieve events on it */
|
||||
sngss7_set_flag(sngss7_info->circuit, SNGSS7_ACTIVE);
|
||||
|
||||
/* if this is a non-voice channel, move along cause we're done with it */
|
||||
if (sngss7_info->circuit->type != VOICE) continue;
|
||||
|
||||
/* lock the channel */
|
||||
ftdm_mutex_lock(ftdmchan->mutex);
|
||||
|
||||
/* flag the circuit as active */
|
||||
sngss7_set_flag(sngss7_info->circuit, SNGSS7_ACTIVE);
|
||||
|
||||
/* check if the interface is paused or resumed */
|
||||
if (sngss7_test_flag(sngss7_intf, SNGSS7_PAUSED)) {
|
||||
SS7_DEBUG_CHAN(ftdmchan, "ISUP intf %d is PAUSED\n", sngss7_intf->id);
|
||||
@@ -1437,6 +1442,18 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
|
||||
ftdm_mutex_unlock(ftdmchan->mutex);
|
||||
}
|
||||
|
||||
/* activate all the configured ss7 links */
|
||||
if (ft_to_sngss7_activate_all()) {
|
||||
SS7_CRITICAL ("Failed to activate LibSngSS7!\n");
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
/*start the span monitor thread */
|
||||
if (ftdm_thread_create_detached (ftdm_sangoma_ss7_run, span) != FTDM_SUCCESS) {
|
||||
SS7_CRITICAL ("Failed to start Span Monitor Thread!\n");
|
||||
return FTDM_FAIL;
|
||||
}
|
||||
|
||||
SS7_DEBUG ("Finished starting span %s:%u.\n", span->name, span->span_id);
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
@@ -1635,7 +1652,7 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)
|
||||
if (sngss7_test_flag(&g_ftdm_sngss7_data.cfg, SNGSS7_RY)) {
|
||||
/* go through all the relays channels and configure it */
|
||||
x = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) {
|
||||
while (x < (MAX_RELAY_CHANNELS)) {
|
||||
/* check if this relay channel has been configured already */
|
||||
if ((g_ftdm_sngss7_data.cfg.relay[x].flags & SNGSS7_CONFIGURED)) {
|
||||
|
||||
@@ -1651,7 +1668,7 @@ static FIO_SIG_UNLOAD_FUNCTION(ftdm_sangoma_ss7_unload)
|
||||
g_ftdm_sngss7_data.cfg.relay[x].flags &= !SNGSS7_CONFIGURED;
|
||||
} /* if !SNGSS7_CONFIGURED */
|
||||
x++;
|
||||
} /* while (g_ftdm_sngss7_data.cfg.relay[x].id != 0) */
|
||||
} /* while (x < (MAX_RELAY_CHANNELS)) */
|
||||
|
||||
ftmod_ss7_shutdown_relay();
|
||||
sng_isup_free_relay();
|
||||
|
||||
@@ -503,6 +503,7 @@ typedef enum {
|
||||
FLAG_GLARE = (1 << 13),
|
||||
FLAG_INFID_RESUME = (1 << 14),
|
||||
FLAG_INFID_PAUSED = (1 << 15),
|
||||
FLAG_SENT_ACM = (1 << 16),
|
||||
FLAG_RELAY_DOWN = (1 << 30),
|
||||
FLAG_CKT_RECONFIG = (1 << 31)
|
||||
} sng_ckt_flag_t;
|
||||
@@ -524,6 +525,7 @@ typedef enum {
|
||||
"GLARE", \
|
||||
"INF_RESUME", \
|
||||
"INF_PAUSED", \
|
||||
"TX_ACM_SENT" \
|
||||
"RELAY_DOWN", \
|
||||
"CKT_RECONFIG"
|
||||
FTDM_STR2ENUM_P(ftmod_ss7_ckt_state2flag, ftmod_ss7_ckt_flag2str, sng_ckt_flag_t)
|
||||
|
||||
@@ -1319,7 +1319,7 @@ ftdm_status_t check_status_of_all_isup_intf(void)
|
||||
|
||||
/* go through all the isupIntfs and ask the stack to give their current state */
|
||||
x = 1;
|
||||
for (x = 1; x < (MAX_ISUP_INFS + 1); x++) {
|
||||
for (x = 1; x < (MAX_ISUP_INFS); x++) {
|
||||
/**************************************************************************/
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.isupIntf[x].id == 0) continue;
|
||||
@@ -1376,7 +1376,7 @@ ftdm_status_t check_status_of_all_isup_intf(void)
|
||||
} /* switch (status) */
|
||||
|
||||
/**************************************************************************/
|
||||
} /* for (x = 1; x < MAX_ISUP_INFS + 1); i++) */
|
||||
} /* for (x = 1; x < MAX_ISUP_INFS); i++) */
|
||||
|
||||
return FTDM_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1215,7 +1215,7 @@ static int ftmod_ss7_parse_mtp_linkset(ftdm_conf_node_t *mtp_linkset)
|
||||
|
||||
/* go through all the mtp3 links and fill in the apc */
|
||||
i = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) {
|
||||
while (i < (MAX_MTP_LINKS)) {
|
||||
if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == mtpLinkSet.id) {
|
||||
g_ftdm_sngss7_data.cfg.mtp3Link[i].apc = mtpLinkSet.apc;
|
||||
}
|
||||
@@ -1757,7 +1757,7 @@ static int ftmod_ss7_parse_isup_interface(ftdm_conf_node_t *isup_interface)
|
||||
/**************************************************************************/
|
||||
/* go through all the links and check if they belong to this linkset*/
|
||||
i = 1;
|
||||
while (g_ftdm_sngss7_data.cfg.mtp3Link[i].id != 0) {
|
||||
while (i < (MAX_MTP_LINKS)) {
|
||||
/* check if this link is in the linkset */
|
||||
if (g_ftdm_sngss7_data.cfg.mtp3Link[i].linkSetId == lnkSet->lsId) {
|
||||
/* fill in the spc */
|
||||
@@ -1891,28 +1891,6 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span)
|
||||
SS7_DEBUG("Found an ccSpan typeCntrl = %s\n", sng_cic_cntrl_type_map[ret].sng_type);
|
||||
}
|
||||
/**********************************************************************/
|
||||
} else if (!strcasecmp(parm->var, "ssf")) {
|
||||
/**********************************************************************/
|
||||
ret = find_ssf_type_in_map(parm->val);
|
||||
if (ret == -1) {
|
||||
SS7_ERROR("Found an invalid ccSpan ssf = %s\n", parm->var);
|
||||
return FTDM_FAIL;
|
||||
} else {
|
||||
sng_ccSpan.ssf = sng_ssf_type_map[ret].tril_type;
|
||||
SS7_DEBUG("Found an ccSpan ssf = %s\n", sng_ssf_type_map[ret].sng_type);
|
||||
}
|
||||
/**********************************************************************/
|
||||
} else if (!strcasecmp(parm->var, "switchType")) {
|
||||
/**********************************************************************/
|
||||
ret = find_switch_type_in_map(parm->val);
|
||||
if (ret == -1) {
|
||||
SS7_ERROR("Found an invalid ccSpan switchType = %s\n", parm->var);
|
||||
return FTDM_FAIL;
|
||||
} else {
|
||||
sng_ccSpan.switchType = sng_switch_type_map[ret].tril_isup_type;
|
||||
SS7_DEBUG("Found an ccSpan switchType = %s\n", sng_switch_type_map[ret].sng_type);
|
||||
}
|
||||
/**********************************************************************/
|
||||
} else if (!strcasecmp(parm->var, "cicbase")) {
|
||||
/**********************************************************************/
|
||||
sng_ccSpan.cicbase = atoi(parm->val);
|
||||
@@ -2034,6 +2012,10 @@ static int ftmod_ss7_parse_cc_span(ftdm_conf_node_t *cc_span)
|
||||
sng_ccSpan.clg_nadi = 0x03;
|
||||
}
|
||||
|
||||
/* pull up the SSF and Switchtype from the isup interface */
|
||||
sng_ccSpan.ssf = g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].ssf;
|
||||
sng_ccSpan.switchType = g_ftdm_sngss7_data.cfg.isupIntf[sng_ccSpan.isupInf].switchType;
|
||||
|
||||
/* add this span to our global listing */
|
||||
ftmod_ss7_fill_in_ccSpan(&sng_ccSpan);
|
||||
|
||||
@@ -2461,7 +2443,7 @@ static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, i
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
while (g_ftdm_sngss7_data.cfg.mtpRoute[i].id != 0) {
|
||||
while (i < (MAX_MTP_ROUTES)) {
|
||||
if (g_ftdm_sngss7_data.cfg.mtpRoute[i].dpc == spc) {
|
||||
/* we have a match so break out of this loop */
|
||||
break;
|
||||
@@ -2471,6 +2453,16 @@ static int ftmod_ss7_fill_in_self_route(int spc, int linkType, int switchType, i
|
||||
}
|
||||
|
||||
if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) {
|
||||
/* this is a new route...find the first free spot */
|
||||
i = 1;
|
||||
while (i < (MAX_MTP_ROUTES)) {
|
||||
if (g_ftdm_sngss7_data.cfg.mtpRoute[i].id == 0) {
|
||||
/* we have a match so break out of this loop */
|
||||
break;
|
||||
}
|
||||
/* move on to the next one */
|
||||
i++;
|
||||
}
|
||||
g_ftdm_sngss7_data.cfg.mtpRoute[i].id = i;
|
||||
SS7_DEBUG("found new mtp3 self route\n");
|
||||
} else {
|
||||
|
||||
@@ -291,7 +291,7 @@ typedef enum {
|
||||
FTDM_USER_LAYER1_PROT_ALAW = 0x03,
|
||||
FTDM_USER_LAYER1_PROT_INVALID
|
||||
} ftdm_user_layer1_prot_t;
|
||||
#define USER_LAYER1_PROT_STRINGS "V.110", "u-law", "a-law", "Invalid"
|
||||
#define USER_LAYER1_PROT_STRINGS "V.110", "ulaw", "alaw", "Invalid"
|
||||
FTDM_STR2ENUM_P(ftdm_str2ftdm_usr_layer1_prot, ftdm_user_layer1_prot2str, ftdm_user_layer1_prot_t)
|
||||
|
||||
/*! Calling Party Category */
|
||||
|
||||
@@ -0,0 +1,584 @@
|
||||
1.6.9 2011-03-16
|
||||
* Fix creating NSEC(3) bitmaps: make array size 65536,
|
||||
don't add doubles.
|
||||
* Fix printout of escaped binary in TXT records.
|
||||
* Parsing TXT records: don't skip starting whitespace that is quoted.
|
||||
* bugfix #358: Check if memory was successfully allocated in
|
||||
ldns_rdf2str().
|
||||
* Added more memory allocation checks in host2str.c
|
||||
* python wrapper for ldns_fetch_valid_domain_keys by Bedrich Kosata.
|
||||
* fix to compile python wrapper with swig 2.0.2.
|
||||
* Don't fallback to SHA-1 when creating NSEC3 hash with another
|
||||
algorithm identifier, fail instead (no other algorithm identifiers
|
||||
are assigned yet).
|
||||
|
||||
1.6.8 2011-01-24
|
||||
* Fix ldns zone, so that $TTL definition match RFC 2308.
|
||||
* Fix lots of missing checks on allocation failures and parse of
|
||||
NSEC with many types and max parse length in hosts_frm_fp routine
|
||||
and off by one in read_anchor_file routine (thanks Dan Kaminsky and
|
||||
Justin Ferguson).
|
||||
* bugfix #335: Drill: Print both SHA-1 and SHA-256 corresponding DS
|
||||
records.
|
||||
* Print correct WHEN in query packet (is not always 1-1-1970)
|
||||
* ldns-test-edns: new example tool that detects EDNS support.
|
||||
* fix ldns_resolver_send without openssl.
|
||||
* bugfix #342: patch for support for more CERT key types (RFC4398).
|
||||
* bugfix #351: fix udp_send hang if UDP checksum error.
|
||||
* fix set_bit (from NSEC3 sign) patch from Jan Komissar.
|
||||
|
||||
1.6.7 2010-11-08
|
||||
* EXPERIMENTAL ecdsa implementation, please do not enable on real
|
||||
servers.
|
||||
* GOST code enabled by default (RFC 5933).
|
||||
* bugfix #326: ignore whitespace between directives and their values.
|
||||
* Header comment to advertise ldns_axfr_complete to check for
|
||||
successfully completed zone transfers.
|
||||
* read resolv.conf skips interface labels, e.g. %eth0.
|
||||
* Fix drill verify NSEC3 denials.
|
||||
* Use closesocket() on windows.
|
||||
* Add ldns_get_signing_algorithm_by_name that understand aliases,
|
||||
names changed to RFC names and aliases for compatibility added.
|
||||
* bugfix: don't print final dot if the domain is relative.
|
||||
* bugfix: resolver search continue when packet rcode != NOERROR.
|
||||
* bugfix: resolver push all domains in search directive to list.
|
||||
* bugfix: resolver search by default includes the root domain.
|
||||
* bugfix: tcp read could fail on single octet recv.
|
||||
* bugfix: read of RR in unknown syntax with missing fields.
|
||||
* added ldns_pkt_tsig_sign_next() and ldns_pkt_tsig_verify_next()
|
||||
to sign and verify TSIG RRs on subsequent messages
|
||||
(section 4.4, RFC 2845, thanks to Michael Sheldon).
|
||||
* bugfix: signer sigs nsecs with zsks only.
|
||||
* bugfix #333: fix ldns_dname_absolute for name ending with backslash.
|
||||
|
||||
1.6.6 2010-08-09
|
||||
* Fix ldns_rr_clone to copy question rrs properly.
|
||||
* Fix ldns_sign_zone(_nsec3) to clone the soa for the new zone.
|
||||
* Fix ldns_wire2dname size check from reading 1 byte beyond buffer end.
|
||||
* Fix ldns_wire2dname from reading 1 byte beyond end for pointer.
|
||||
* Fix crash using GOST for particular platform configurations.
|
||||
* extern C declarations used in the header file.
|
||||
* Removed debug fprintf from resolver.c.
|
||||
* ldns-signzone checks if public key file is for the right zone.
|
||||
* NETLDNS, .NET port of ldns functionality, by Alex Nicoll, in contrib.
|
||||
* Fix handling of comments in resolv.conf parse.
|
||||
* GOST code enabled if SSL recent, RFC 5933.
|
||||
* bugfix #317: segfault util.c ldns_init_random() fixed.
|
||||
* Fix ldns_tsig_mac_new: allocate enough memory for the hash, fix use of
|
||||
b64_pton_calculate_size.
|
||||
* Fix ldns_dname_cat: size calculation and handling of realloc().
|
||||
* Fix ldns_rr_pop_rdf: fix handling of realloc().
|
||||
* Fix ldns-signzone for single type key scheme: sign whole zone if there
|
||||
are only KSKs.
|
||||
* Fix ldns_resolver: also close socket if AXFR failed (if you don't,
|
||||
it would block subsequent transfers (thanks Roland van Rijswijk).
|
||||
* Fix drill: allow for a secure trace if you use DS records as trust
|
||||
anchors (thanks Jan Komissar).
|
||||
|
||||
1.6.5 2010-06-15
|
||||
* Catch \X where X is a digit as an error.
|
||||
* Fix segfault when ip6 ldns resolver only has ip4 servers.
|
||||
* Fix NSEC record after DNSKEY at zone apex not properly signed.
|
||||
* Fix syntax error if last label too long and no dot at end of domain.
|
||||
* Fix parse of \# syntax with space for type LOC.
|
||||
* Fix ldns_dname_absolute for escape sequences, fixes some parse errs.
|
||||
* bugfix #297: linking ssl, bug due to patch submitted as #296.
|
||||
* bugfix #299: added missing declarations to host2str.h
|
||||
* ldns-compare-zones -s to not exclude SOA record from comparison.
|
||||
* --disable-rpath fix
|
||||
* fix ldns_pkt_empty(), reported by Alex Nicoll.
|
||||
* fix ldns_resolver_new_frm_fp not ignore lines after a comment.
|
||||
* python code for ldns_rr.new_question_frm_str()
|
||||
* Fix ldns_dnssec_verify_denial: the signature selection routine.
|
||||
* Type TALINK parsed (draft-ietf-dnsop-trust-history).
|
||||
* bugfix #304: fixed dead loop in ldns_tcp_read_wire() and
|
||||
ldns_tcp_read_wire_timeout().
|
||||
* GOST support with correct algorithm numbers. The plan is to make it
|
||||
enabled if openssl support is detected, but it is disabled by
|
||||
default in this release because the RFC is not ready.
|
||||
* Fixed comment in rbtree.h about being first member and data ptr.
|
||||
* Fixed possibly leak in case of out of memory in ldns_native2rdf...
|
||||
* ldns_dname_is_wildcard added.
|
||||
* Fixed: signatures over wildcards had the wrong labelcount.
|
||||
* Fixed ldns_verify() inconsistent return values.
|
||||
* Fixed ldns_resolver to copy and free tsig name, data and algorithm.
|
||||
* Fixed ldns_resolver to push search onto searchlist.
|
||||
* A ldns resolver now defaults to a non-recursive resolver that handles
|
||||
the TC bit.
|
||||
* ldns_resolver_print() prints more details.
|
||||
* Fixed ldns_rdf2buffer_str_time(), which did not print timestamps
|
||||
on 64bit systems.
|
||||
* Make ldns_resolver_nameservers_randomize() more random.
|
||||
* bugfix #310: POSIX specifies NULL second argument of gettimeofday.
|
||||
* fix compiler warnings from llvm clang compiler.
|
||||
* bugfix #309: ldns_pkt_clone did not clone the tsig_rr.
|
||||
* Fix gentoo ebuild for drill, 'no m4 directory'.
|
||||
* bugfix #313: drill trace on an empty nonterminal continuation.
|
||||
|
||||
1.6.4 2010-01-20
|
||||
* Imported pyldns contribution by Zdenek Vasicek and Karel Slany.
|
||||
Changed its configure and Makefile to fit into ldns.
|
||||
Added its dname_* methods to the rdf_* class (as is the ldns API).
|
||||
Changed swig destroy of ldns_buffer class to ldns_buffer_free.
|
||||
Declared ldns_pkt_all and ldns_pkt_all_noquestion so swig sees them.
|
||||
* Bugfix: parse PTR target of .tomhendrikx.nl with error not crash.
|
||||
* Bugfix: handle escaped characters in TXT rdata.
|
||||
* bug292: no longer crash on malformed domain names where a label is
|
||||
on position 255, which was a buffer overflow by one.
|
||||
* Fix ldns_get_rr_list_hosts_frm_fp_l (strncpy to strlcpy change),
|
||||
which fixes resolv.conf reading badly terminated string buffers.
|
||||
* Fix ldns_pkt_set_random_id to be more random, and a little faster,
|
||||
it did not do value 0 statistically correctly.
|
||||
* Fix ldns_rdf2native_sockaddr_storage to set sockaddr type to zeroes,
|
||||
for portability.
|
||||
* bug295: nsec3-hash routine no longer case sensitive.
|
||||
* bug298: drill failed nsec3 denial of existence proof.
|
||||
|
||||
1.6.3 2009-12-04
|
||||
* Bugfix: allow for unknown resource records in zonefile with rdlen=0.
|
||||
* Bugfix: also mark an RR as question if it comes from the wire
|
||||
* Bugfix: NSEC3 bitmap contained NSEC
|
||||
* Bugfix: Inherit class when creating signatures
|
||||
|
||||
1.6.2 2009-11-12
|
||||
* Fix Makefile patch from Havard Eidnes, better install.sh usage.
|
||||
* Fix parse error on SOA serial of 2910532839.
|
||||
Fix print of ';' and readback of '\;' in names, also for '\\'.
|
||||
Fix parse of '\(' and '\)' in names. Also for file read. Also '\.'
|
||||
* Fix signature creation when TTLs are different for RRs in RRset.
|
||||
* bug273: fix so EDNS rdata is included in pkt to wire conversion.
|
||||
* bug274: fix use of c++ keyword 'class' for RR class in the code.
|
||||
* bug275: fix memory leak of packet edns rdata.
|
||||
* Fix timeout procedure for TCP and AXFR on Solaris.
|
||||
* Fix occasional NSEC bitmap bogus
|
||||
* Fix rr comparing (was in reversed order since 1.6.0)
|
||||
* bug278: fix parsing HINFO rdata (and other cases).
|
||||
* Fix previous owner name: also pick up if owner name is @.
|
||||
* RFC5702: enabled sha2 functions by default. This requires OpenSSL 0.9.8 or higher.
|
||||
Reason for this default is the root to be signed with RSASHA256.
|
||||
* Fix various LDNS RR parsing issues: IPSECKEY, WKS, NSAP, very long lines
|
||||
* Fix: Make ldns_dname_is_subdomain case insensitive.
|
||||
* Fix ldns-verify-zone so that address records at zone NS set are not considered glue
|
||||
(Or glue records fall below delegation)
|
||||
* Fix LOC RR altitude printing.
|
||||
* Feature: Added period (e.g. '3m6d') support at explicit TTLs.
|
||||
* Feature: DNSKEY rrset by default signed with minimal signatures
|
||||
but -A option for ldns-signzone to sign it with all keys.
|
||||
This makes the DNSKEY responses smaller for signed domains.
|
||||
|
||||
1.6.1 2009-09-14
|
||||
* --enable-gost : use the GOST algorithm (experimental).
|
||||
* Added some missing options to drill manpage
|
||||
* Some fixes to --without-ssl option
|
||||
* Fixed quote parsing withing strings
|
||||
* Bitmask fix in EDNS handling
|
||||
* Fixed non-fqdn domain name completion for rdata field domain
|
||||
names of length 1
|
||||
* Fixed chain validation with SHA256 DS records
|
||||
|
||||
1.6.0
|
||||
Additions:
|
||||
* Addition of an ldns-config script which gives cflags and libs
|
||||
values, for use in configure scripts for applications that use
|
||||
use ldns. Can be disabled with ./configure --disable-ldns-config
|
||||
* Added direct sha1, sha256, and sha512 support in ldns.
|
||||
With these functions, all NSEC3 functionality can still be
|
||||
used, even if ldns is built without OpenSSL. Thanks to OpenBSD,
|
||||
Steve Reid, and Aaron D. Gifford for the code.
|
||||
* Added reading/writing support for the SPF Resource Record
|
||||
* Base32 functions are now exported
|
||||
Bugfixes:
|
||||
* ldns_is_rrset did not go through the complete rrset, but
|
||||
only compared the first two records. Thanks to Olafur
|
||||
Gudmundsson for report and patch
|
||||
* Fixed a small memory bug in ldns_rr_list_subtype_by_rdf(),
|
||||
thanks to Marius Rieder for finding an patching this.
|
||||
* --without-ssl should now work. Make sure that examples/ and
|
||||
drill also get the --without-ssl flag on their configure, if
|
||||
this is used.
|
||||
* Some malloc() return value checks have been added
|
||||
* NSEC3 creation has been improved wrt to empty nonterminals,
|
||||
and opt-out.
|
||||
* Fixed a bug in the parser when reading large NSEC3 salt
|
||||
values.
|
||||
* Made the allowed length for domain names on wire
|
||||
and presentation format the same.
|
||||
Example tools:
|
||||
* ldns-key2ds can now also generate DS records for keys without
|
||||
the SEP flag
|
||||
* ldns-signzone now equalizes the TTL of the DNSKEY RRset (to
|
||||
the first non-default DNSKEY TTL value it sees)
|
||||
|
||||
1.5.1
|
||||
Example tools:
|
||||
* ldns-signzone was broken in 1.5.0 for multiple keys, this
|
||||
has been repaired
|
||||
|
||||
Build system:
|
||||
* Removed a small erroneous output warning in
|
||||
examples/configure and drill/configure
|
||||
|
||||
1.5.0
|
||||
Bug fixes:
|
||||
* fixed a possible memory overflow in the RR parser
|
||||
* build flag fix for Sun Studio
|
||||
* fixed a building race condition in the copying of header
|
||||
files
|
||||
* EDNS0 extended rcode; the correct assembled code number
|
||||
is now printed (still in the EDNS0 field, though)
|
||||
* ldns_pkt_rr no longer leaks memory (in fact, it no longer
|
||||
copies anything all)
|
||||
|
||||
API addition:
|
||||
* ldns_key now has support for 'external' data, in which
|
||||
case the OpenSSL EVP structures are not used;
|
||||
ldns_key_set_external_key() and ldns_key_external_key()
|
||||
* added ldns_key_get_file_base_name() which creates a
|
||||
'default' filename base string for key storage, of the
|
||||
form "K<zone>+<algorithm>+<keytag>"
|
||||
* the ldns_dnssec_* family of structures now have deep_free()
|
||||
functions, which also free the ldns_rr's contained in them
|
||||
* there is now an ldns_match_wildcard() function, which checks
|
||||
whether a domain name matches a wildcard name
|
||||
* ldns_sign_public has been split up; this resulted in the
|
||||
addition of ldns_create_empty_rrsig() and
|
||||
ldns_sign_public_buffer()
|
||||
|
||||
Examples:
|
||||
* ldns-signzone can now automatically add DNSKEY records when
|
||||
using an OpenSSL engine, as it already did when using key
|
||||
files
|
||||
* added new example tool: ldns-nsec3-hash
|
||||
* ldns-dpa can now filter on specific query name and types
|
||||
* ldnsd has fixes for the zone name, a fix for the return
|
||||
value of recvfrom(), and an memory initialization fix
|
||||
(Thanks to Colm MacCárthaigh for the patch)
|
||||
* Fixed memory leaks in ldnsd
|
||||
|
||||
|
||||
|
||||
1.4.1
|
||||
Bug fixes:
|
||||
* fixed a build issue where ldns lib existence was done too early
|
||||
* removed unnecessary check for pcap.h
|
||||
* NSEC3 optout flag now correctly printed in string output
|
||||
* inttypes.h moved to configured inclusion
|
||||
* fixed NSEC3 type bitmaps for empty nonterminals and unsigned
|
||||
delegations
|
||||
|
||||
API addition:
|
||||
* for that last fix, we added a new function
|
||||
ldns_dname_add_from() that can clone parts of a dname
|
||||
|
||||
1.4.0
|
||||
Bug fixes:
|
||||
* sig chase return code fix (patch from Rafael Justo, bug id 189)
|
||||
* rdata.c memory leaks on error and allocation checks fixed (patch
|
||||
from Shane Kerr, bug id 188)
|
||||
* zone.c memory leaks on error and allocation checks fixed (patch
|
||||
from Shane Kerr, bug id 189)
|
||||
* ldns-zplit output and error messages fixed (patch from Shane Kerr,
|
||||
bug id 190)
|
||||
* Fixed potential buffer overflow in ldns_str2rdf_dname
|
||||
* Signing code no longer signs delegation NS rrsets
|
||||
* Some minor configure/makefile updates
|
||||
* Fixed a bug in the randomness initialization
|
||||
* Fixed a bug in the reading of resolv.conf
|
||||
* Fixed a bug concerning whitespace in zone data (with patch from Ondrej
|
||||
Sury, bug 213)
|
||||
* Fixed a small fallback problem in axfr client code
|
||||
|
||||
API CHANGES:
|
||||
* added 2str convenience functions:
|
||||
- ldns_rr_type2str
|
||||
- ldns_rr_class2str
|
||||
- ldns_rr_type2buffer_str
|
||||
- ldns_rr_class2buffer_str
|
||||
* buffer2str() is now called ldns_buffer2str
|
||||
* base32 and base64 function names are now also prepended with ldns_
|
||||
* ldns_rr_new_frm_str() now returns an error on missing RDATA fields.
|
||||
Since you cannot read QUESTION section RRs with this anymore,
|
||||
there is now a function called ldns_rr_new_question_frm_str()
|
||||
|
||||
LIBRARY FEATURES:
|
||||
* DS RRs string representation now add bubblebabble in a comment
|
||||
(patch from Jakob Schlyter)
|
||||
* DLV RR type added
|
||||
* TCP fallback system has been improved
|
||||
* HMAC-SHA256 TSIG support has been added.
|
||||
* TTLS are now correcly set in NSEC(3) records when signing zones
|
||||
|
||||
EXAMPLE TOOLS:
|
||||
* New example: ldns-revoke to revoke DNSKEYs according to RFC5011
|
||||
* ldns-testpkts has been fixed and updated
|
||||
* ldns-signzone now has the option to not add the DNSKEY
|
||||
* ldns-signzone now has an (full zone only) opt-out option for
|
||||
NSEC3
|
||||
* ldns-keygen can create HMAC-SHA1 and HMAC-SHA256 symmetric keys
|
||||
* ldns-walk output has been fixed
|
||||
* ldns-compare-zones has been fixed, and now has an option
|
||||
to show all differences (-a)
|
||||
* ldns-read-zone now has an option to print DNSSEC records only
|
||||
|
||||
1.3
|
||||
Base library:
|
||||
|
||||
* Added a new family of functions based around ldns_dnssec_zone,
|
||||
which is a new structure that keeps a zone sorted through an
|
||||
rbtree and links signatures and NSEC(3) records directly to their
|
||||
RRset. These functions all start with ldns_dnssec_
|
||||
|
||||
* ldns_zone_sign and ldns_zone_sign_nsec3 are now deprecated, but
|
||||
have been changed to internally use the new
|
||||
ldns_dnssec_zone_sign(_nsec3)
|
||||
|
||||
* Moved some ldns_buffer functions inline, so a clean rebuild of
|
||||
applications relying on those is needed (otherwise you'll get
|
||||
linker errors)
|
||||
* ldns_dname_label now returns one extra (zero)
|
||||
byte, so it can be seen as an fqdn.
|
||||
* NSEC3 type code update for signing algorithms.
|
||||
* DSA key generation of DNSKEY RRs fixed (one byte too small).
|
||||
|
||||
* Added support for RSA/SHA256 and RSA/SHA512, as specified in
|
||||
draft-ietf-dnsext-dnssec-rsasha256-04. The typecodes are not
|
||||
final, and this feature is not enabled by default. It can be
|
||||
enabled at compilation time with the flag --with-sha2
|
||||
|
||||
* Added 2wire_canonical family of functions that lowercase dnames
|
||||
in rdata fields in resource records of the types in the list in
|
||||
rfc3597
|
||||
|
||||
* Added base32 conversion functions.
|
||||
|
||||
* Fixed DSA RRSIG conversion when calling OpenSSL
|
||||
|
||||
Drill:
|
||||
|
||||
* Chase output is completely different, it shows, in ascii, the
|
||||
relations in the trust hierarchy.
|
||||
|
||||
Examples:
|
||||
* Added ldns-verify-zone, that can verify the internal DNSSEC records
|
||||
of a signed BIND-style zone file
|
||||
|
||||
* ldns-keygen now takes an -a argument specifying the algorithm,
|
||||
instead of -R or -D. -a list show a list of supported algorithms
|
||||
|
||||
* ldns-keygen now defaults to the exponent RSA_F4 instead of RSA_3
|
||||
for RSA key generation
|
||||
|
||||
* ldns-signzone now has support for HSMs
|
||||
* ldns-signzone uses the new ldns_dnssec_ structures and functions
|
||||
which improves its speed, and output; RRSIGS are now placed
|
||||
directly after their RRset, NSEC(3) records directly after the
|
||||
name they handle
|
||||
|
||||
Contrib:
|
||||
* new contrib/ dir with user contributions
|
||||
* added compilation script for solaris (thanks to Jakob Schlyter)
|
||||
|
||||
28 Nov 2007 1.2.2:
|
||||
* Added support for HMAC-MD5 keys in generator
|
||||
* Added a new example tool (written by Ondrej Sury): ldns-compare-zones
|
||||
* ldns-keygen now checks key sizes for rfc conformancy
|
||||
* ldns-signzone outputs SSL error if present
|
||||
* Fixed manpages (thanks to Ondrej Sury)
|
||||
* Fixed Makefile for -j <x>
|
||||
* Fixed a $ORIGIN error when reading zones
|
||||
* Fixed another off-by-one error
|
||||
|
||||
03 Oct 2007 1.2.1:
|
||||
* Fixed an offset error in rr comparison
|
||||
* Fixed ldns-read-zone exit code
|
||||
* Added check for availability of SHA256 hashing algorithm
|
||||
* Fixed ldns-key2ds -2 argument
|
||||
* Fixed $ORIGIN bug in .key files
|
||||
* Output algorithms as an integer instead of their mnemonic
|
||||
* Fixed a memory leak in dnssec code when SHA256 is not available
|
||||
* Updated fedora .spec file
|
||||
|
||||
11 Apr 2007 1.2.0:
|
||||
* canonicalization of rdata in DNSSEC functions now adheres to the
|
||||
rr type list in rfc3597, not rfc4035, which will be updated
|
||||
(see http://www.ops.ietf.org/lists/namedroppers/namedroppers.2007/msg00183.html)
|
||||
* ldns-walk now support dnames with maximum label length
|
||||
* ldnsd now takes an extra argument containing the address to listen on
|
||||
* signing no longer signs every rrset with KSK's, but only the DNSKEY rrset
|
||||
* ported to Solaris 10
|
||||
* added ldns_send_buffer() function
|
||||
* added ldns-testpkts fake packet server
|
||||
* added ldns-notify to send NOTIFY packets
|
||||
* ldns-dpa can now accurately calculate the number of matches per
|
||||
second
|
||||
* libtool is now used for compilation too (still gcc, but not directly)
|
||||
* Bugfixes:
|
||||
- TSIG signing buffer size
|
||||
- resolv.conf reading (comments)
|
||||
- dname comparison off by one error
|
||||
- typo in keyfetchers output file name fixed (a . too much)
|
||||
- fixed zone file parser when comments contain ( or )
|
||||
- fixed LOC RR type
|
||||
- fixed CERT RR type
|
||||
|
||||
Drill:
|
||||
* drill prints error on failed axfr.
|
||||
* drill now accepts mangled packets with -f
|
||||
* old -c option (use tcp) changed to -t
|
||||
* -c option to specify alternative resolv.conf file added
|
||||
* feedback of signature chase improved
|
||||
* chaser now stops at root when no trusted keys are found
|
||||
instead of looping forever trying to find the DS for .
|
||||
* Fixed bugs:
|
||||
- wildcard on multiple labels signature verification
|
||||
- error in -f packet writing for malformed packets
|
||||
- made KSK check more resilient
|
||||
|
||||
7 Jul 2006: 1.1.0: ldns-team
|
||||
* Added tutorials and an introduction to the documentation
|
||||
* Added include/ and lib/ dirs so that you can compile against ldns
|
||||
without installing ldns on your system
|
||||
* Makefile updates
|
||||
* Starting usage of assert throughout the library to catch illegal calls
|
||||
* Solaris 9 testing was carried out. Ldns now compiles on that
|
||||
platform; some gnuism were identified and fixed.
|
||||
* The ldns_zone structure was stress tested. The current setup
|
||||
(ie. just a list of rrs) can scale to zone file in order of
|
||||
megabytes. Sorting such zone is still difficult.
|
||||
* Reading multiline b64 encoded rdata works.
|
||||
* OpenSSL was made optional, configure --without-ssl.
|
||||
Ofcourse all dnssec/tsig related functions are disabled
|
||||
* Building of examples and drill now happens with the same
|
||||
defines as the building of ldns itself.
|
||||
* Preliminary sha-256 support was added. Currently is your
|
||||
OpenSSL supports it, it is supported in the DS creation.
|
||||
* ldns_resolver_search was implemented
|
||||
* Fixed a lot of bugs
|
||||
|
||||
Drill:
|
||||
* -r was killed in favor of -o <header bit mnemonic> which
|
||||
allows for a header bits setting (and maybe more in the
|
||||
future)
|
||||
* DNSSEC is never automaticaly set, even when you query
|
||||
for DNSKEY/RRSIG or DS.
|
||||
* Implement a crude RTT check, it now distinguishes between
|
||||
reachable and unreachable.
|
||||
* A form of secure tracing was added
|
||||
* Secure Chasing has been improved
|
||||
* -x does a reverse lookup for the given IP address
|
||||
|
||||
Examples:
|
||||
* ldns-dpa was added to the examples - this is the Dns Packet
|
||||
Analyzer tool.
|
||||
* ldnsd - as very, very simple nameserver impl.
|
||||
* ldns-zsplit - split zones for parrallel signing
|
||||
* ldns-zcat - cat split zones back together
|
||||
* ldns-keyfetcher - Fetches DNSKEY records with a few (non-strong,
|
||||
non-DNSSEC) anti-spoofing techniques.
|
||||
* ldns-walk - 'Walks' a DNSSEC signed zone
|
||||
* Added an all-static target to the makefile so you can use examples
|
||||
without installing the library
|
||||
* When building in the source tree or in a direct subdirectory of
|
||||
the build dir, configure does not need --with-ldns=../ anymore
|
||||
|
||||
Code:
|
||||
* All networking code was moved to net.c
|
||||
* rdata.c: added asserts to the rdf set/get functions
|
||||
* const keyword was added to pointer arguments that
|
||||
aren't changed
|
||||
|
||||
API:
|
||||
Changed:
|
||||
* renamed ldns/dns.h to ldns/ldns.h
|
||||
* ldns_rr_new_frm_str() is extented with an extra variable which
|
||||
in common use may be NULL. This trickles through to:
|
||||
o ldns_rr_new_frm_fp
|
||||
o ldns_rr_new_frm_fp_l
|
||||
Which also get an extra variable
|
||||
Also the function has been changed to return a status message.
|
||||
The compiled RR is returned in the first argument.
|
||||
* ldns_zone_new_frm_fp_l() and ldns_zone_new_frm_fp() are
|
||||
changed to return a status msg.
|
||||
* ldns_key_new_frm_fp is changed to return ldns_status and
|
||||
the actual key list in the first argument
|
||||
* ldns_rdata_new_frm_fp[_l]() are changed to return a status.
|
||||
the rdf is return in the first argument
|
||||
* ldns_resolver_new_frm_fp: same treatment: return status and
|
||||
the new resolver in the first argument
|
||||
* ldns_pkt_query_new_frm_str(): same: return status and the
|
||||
packet in the first arg
|
||||
* tsig.h: internal used functions are now static:
|
||||
ldns_digest_name and ldns_tsig_mac_new
|
||||
* ldns_key_rr2ds has an extra argument to specify the hash to
|
||||
use.
|
||||
* ldns_pkt_rcode() is renamed to ldns_pkt_get_rcode, ldns_pkt_rcode
|
||||
is now the rcode type, like ldns_pkt_opcode
|
||||
New:
|
||||
* ldns_resolver_searchlist_count: return the searchlist counter
|
||||
* ldns_zone_sort: Sort a zone
|
||||
* ldns_bgsend(): background send, returns a socket.
|
||||
* ldns_pkt_empty(): check is a packet is empty
|
||||
* ldns_rr_list_pop_rr_list(): pop multiple rr's from another rr_list
|
||||
* ldns_rr_list_push_rr_list(): push multiple rr's to an rr_list
|
||||
* ldns_rr_list_compare(): compare 2 ldns_rr_lists
|
||||
* ldns_pkt_push_rr_list: rr_list equiv for rr
|
||||
* ldns_pkt_safe_push_rr_list: rr_list equiv for rr
|
||||
Removed:
|
||||
* ldns_resolver_bgsend(): was not used in 1.0.0 and is not used now
|
||||
* ldns_udp_server_connect(): was faulty and isn't really part of
|
||||
the core ldns idea any how.
|
||||
* ldns_rr_list_insert_rr(): obsoleted, because not used.
|
||||
* char *_when was removed from the ldns_pkt structure
|
||||
|
||||
18 Oct 2005: 1.0.0: ldns-team
|
||||
* Commited a patch from Håkan Olsson
|
||||
* Added UPDATE support (Jakob Schlyter and Håkan Olsson)
|
||||
* License change: ldns is now BSD licensed
|
||||
* ldns now depends on SSL
|
||||
* Networking code cleanup, added (some) server udp/tcp support
|
||||
* A zone type is introduced. Currently this is a list
|
||||
of RRs, so it will not scale well.
|
||||
* [beta] Zonefile parsing was added
|
||||
* [tools] Drill was added to ldns - see drill/
|
||||
* [tools] experimental signer was added
|
||||
* [building] better check for ssl
|
||||
* [building] major revision of build system
|
||||
* [building] added rpm .spec in packaging/ (thanks to Paul Wouters)
|
||||
* [building] A lot of cleanup in the build scripts (thanks to Jakob Schlyter
|
||||
and Paul Wouters)
|
||||
|
||||
28 Jul 2005: 0.70: ldns-team
|
||||
* [func] ldns_pkt_get_section now returns copies from the rrlists
|
||||
in the packet. This can be freed by the user program
|
||||
* [code] added ldns_ prefixes to function from util.h
|
||||
* [inst] removed documentation from default make install
|
||||
* Usual fixes in documentation and code
|
||||
|
||||
20 Jun 2005: 0.66: ldns-team
|
||||
Rel. Focus: drill-pre2 uses some functions which are
|
||||
not in 0.65
|
||||
* dnssec_cd bit function was added
|
||||
* Zone infrastructure was added
|
||||
* Usual fixes in documentation and code
|
||||
|
||||
13 Jun 2005: 0.65: ldns-team
|
||||
* Repository is online at:
|
||||
http://www.nlnetlabs.nl/ldns/svn/
|
||||
* Apply reference copying throuhgout ldns, except in 2
|
||||
places in the ldns_resolver structure (._domain and
|
||||
._nameservers)
|
||||
* Usual array of bugfixes
|
||||
* Documentation added
|
||||
* keygen.c added as an example for DNSSEC programming
|
||||
|
||||
23 May 2005: 0.60: ldns-team
|
||||
* Removed config.h from the header installed files
|
||||
(you're not supposed to include that in a libary)
|
||||
* Further tweaking
|
||||
- DNSSEC signing/verification works
|
||||
- Assorted bug fixes and tweaks (memory management)
|
||||
|
||||
May 2005: 0.50: ldns-team
|
||||
* First usable release
|
||||
* Basic DNS functionality works
|
||||
* DNSSEC validation works
|
||||
@@ -0,0 +1,26 @@
|
||||
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.
|
||||
@@ -0,0 +1,368 @@
|
||||
# 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@
|
||||
pywrapdir = ${srcdir}/contrib/python
|
||||
swig = @swig@
|
||||
python_site =@PYTHON_SITE_PKG@
|
||||
pyldns_inst =@PYLDNS@
|
||||
pyldns_uninst =@PYLDNS@
|
||||
ifeq "$(pyldns_inst)" "pyldns"
|
||||
pyldns_inst=install-@PYLDNS@
|
||||
pyldns_uninst=uninstall-@PYLDNS@
|
||||
else
|
||||
pyldns_inst=
|
||||
pyldns_uninst=
|
||||
endif
|
||||
glibtool = @libtool@
|
||||
libtool = ./libtool
|
||||
ifdef glibtool
|
||||
libtool = $(glibtool)
|
||||
endif
|
||||
|
||||
CC = @CC@
|
||||
ifeq "$(srcdir)" "."
|
||||
CPPFLAGS = $(strip -I. @CPPFLAGS@ @DEFS@)
|
||||
else
|
||||
CPPFLAGS = $(strip -I. -I$(srcdir) @CPPFLAGS@ @DEFS@)
|
||||
endif
|
||||
CFLAGS = $(strip @CFLAGS@)
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
|
||||
PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
|
||||
LIBSSL_CPPFLAGS = @LIBSSL_CPPFLAGS@
|
||||
LIBSSL_LDFLAGS = @LIBSSL_LDFLAGS@
|
||||
LIBSSL_LIBS = @LIBSSL_LIBS@
|
||||
RUNTIME_PATH = @RUNTIME_PATH@
|
||||
DATE = $(shell date +%Y%m%d)
|
||||
LIBTOOL = $(libtool) --tag=CC --quiet
|
||||
INSTALL_LDNS_CONFIG = @INSTALL_LDNS_CONFIG@
|
||||
|
||||
LINT = splint
|
||||
LINTFLAGS=+quiet -weak -warnposix -unrecog -Din_addr_t=uint32_t -Du_int=unsigned -Du_char=uint8_t -preproc -Drlimit=rlimit64 -D__gnuc_va_list=va_list
|
||||
#-Dglob64=glob -Dglobfree64=globfree
|
||||
# compat with openssl linux edition.
|
||||
LINTFLAGS+="-DBN_ULONG=unsigned long" -Dkrb5_int32=int "-Dkrb5_ui_4=unsigned int" -DPQ_64BIT=uint64_t -DRC4_INT=unsigned -fixedformalarray -D"ENGINE=unsigned" -D"RSA=unsigned" -D"DSA=unsigned" -D"EVP_PKEY=unsigned" -D"EVP_MD=unsigned" -D"SSL=unsigned" -D"SSL_CTX=unsigned" -D"X509=unsigned" -D"RC4_KEY=unsigned" -D"EVP_MD_CTX=unsigned" -D"EC_KEY=unsigned" -D"EC_POINT=unsigned" -D"EC_GROUP=unsigned"
|
||||
# compat with NetBSD
|
||||
ifeq "$(shell uname)" "NetBSD"
|
||||
LINTFLAGS+="-D__RENAME(x)=" -D_NETINET_IN_H_
|
||||
endif
|
||||
# compat with OpenBSD
|
||||
LINTFLAGS+="-Dsigset_t=long"
|
||||
# FreeBSD8
|
||||
LINTFLAGS+="-D__uint16_t=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 \
|
||||
sha1.c sha2.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/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 \
|
||||
$(srcdir)/ldns/sha1.h \
|
||||
$(srcdir)/ldns/sha2.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) $(strip $(CFLAGS) $(LDFLAGS) $(LIBS))
|
||||
LINK_LIB = $(LIBTOOL) --mode=link $(CC) $(strip $(CFLAGS) $(LDFLAGS) $(LIBS) -version-number $(version_info) -no-undefined)
|
||||
|
||||
%.o: $(srcdir)/%.c $(LIBDNS_HEADERS) ldns/net.h ldns/util.h ldns/config.h
|
||||
$(COMP_LIB) $(LIBSSL_CPPFLAGS) -c $<
|
||||
|
||||
.PHONY: clean realclean docclean manpages doc lint all lib pyldns test
|
||||
.PHONY: install uninstall install-doc uninstall-doc uninstall-pyldns
|
||||
.PHONY: install-h uninstall-h install-lib uninstall-lib install-pyldns
|
||||
|
||||
all: copy-headers lib linktest manpages @PYLDNS@
|
||||
|
||||
linktest: $(srcdir)/linktest.c $(LIBDNS_HEADERS) ldns/net.h ldns/util.h ldns/config.h libldns.la
|
||||
$(LIBTOOL) --mode=link $(CC) $(srcdir)/linktest.c $(CPPFLAGS) $(LIBSSL_CPPFLAGS) $(CFLAGS) -lldns $(LIBS) -o linktest
|
||||
|
||||
lib: libldns.la
|
||||
if [ ! -d lib ] ; then ln -s .libs lib ; fi ;
|
||||
|
||||
lib-export-all: libldns.la-export-all
|
||||
if [ ! -d lib ] ; then ln -s .libs lib ; fi ;
|
||||
|
||||
libldns.la: $(LIBDNS_OBJECTS)
|
||||
$(LINK_LIB) $(LIBSSL_LDFLAGS) $(LIBSSL_LIBS) --export-symbols $(srcdir)/ldns_symbols.def -o libldns.la $(LIBDNS_LOBJECTS) -rpath $(libdir) $(RUNTIME_PATH)
|
||||
|
||||
libldns.la-export-all: $(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 ;
|
||||
$(INSTALL) -c -m 644 $< ./include/ldns/
|
||||
|
||||
include/ldns/util.h include/ldns/net.h include/ldns/config.h: include/ldns/%.h: ./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 ;
|
||||
$(INSTALL) -c -m 644 $< ./include/ldns/
|
||||
|
||||
copy-headers: $(addprefix include/ldns/, $(notdir $(LIBDNS_HEADERS))) include/ldns/util.h include/ldns/net.h include/ldns/config.h
|
||||
|
||||
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 \
|
||||
$(INSTALL) -c -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
|
||||
|
||||
pyldns: _ldns.la
|
||||
|
||||
$(pywrapdir)/ldns_wrapper.c: $(pywrapdir)/ldns.i $(wildcard $(pywrapdir)/*.i) $(LIBDNS_HEADERS) ldns/util.h ldns/config.h
|
||||
$(swig) -python -o $@ $(CPPFLAGS) $(PYTHON_CPPFLAGS) $<
|
||||
|
||||
ldns_wrapper.lo: $(pywrapdir)/ldns_wrapper.c $(LIBDNS_HEADERS) ldns/util.h ldns/config.h
|
||||
$(COMP_LIB) -I./include/ldns $(PYTHON_CPPFLAGS) -c $< -o $@
|
||||
|
||||
_ldns.la: ldns_wrapper.lo libldns.la
|
||||
$(LIBTOOL) --tag=CC --mode=link $(CC) $(strip $(CFLAGS) $(PYTHON_CFLAGS) $(LDFLAGS) $(PYTHON_LDFLAGS) -module -version-number $(version_info) -no-undefined -o $@ $< -rpath $(python_site) -L. -L.libs -lldns $(LIBS))
|
||||
|
||||
install: install-h install-lib install-config install-manpages $(pyldns_inst)
|
||||
|
||||
uninstall: uninstall-manpages uninstall-h uninstall-lib $(pyldns_uninst)
|
||||
|
||||
destclean: uninstall
|
||||
|
||||
install-config:
|
||||
if [ $(INSTALL_LDNS_CONFIG) = "yes" ] ; then \
|
||||
$(INSTALL) -d $(DESTDIR)$(bindir); \
|
||||
$(INSTALL) -c -m 755 packaging/ldns-config $(DESTDIR)$(bindir)/; \
|
||||
fi
|
||||
|
||||
install-manpages: manpages
|
||||
${INSTALL} -d $(DESTDIR)$(mandir)/man3
|
||||
for f in doc/man/man3/*; do \
|
||||
${INSTALL} -c -m 444 $$f $(DESTDIR)$(mandir)/man3/; \
|
||||
done
|
||||
|
||||
uninstall-manpages:
|
||||
for i in `cat doc/ldns_manpages`; do \
|
||||
rm -f $(DESTDIR)$(mandir)/man3/$$i.3 ; done
|
||||
rmdir -p $(DESTDIR)$(mandir)/man3 || echo "ok, dir already gone"
|
||||
|
||||
install-h: lib
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(includedir)/ldns
|
||||
for i in $(LIBDNS_HEADERS); do \
|
||||
$(INSTALL) -c -m 644 $$i $(DESTDIR)$(includedir)/ldns/; done
|
||||
$(INSTALL) -c -m 644 include/ldns/util.h $(DESTDIR)$(includedir)/ldns/
|
||||
$(INSTALL) -c -m 644 include/ldns/net.h $(DESTDIR)$(includedir)/ldns/
|
||||
|
||||
uninstall-h:
|
||||
for i in $(LIBDNS_HEADERS); do \
|
||||
rm -f $(DESTDIR)$(includedir)/$$i; done
|
||||
[ ! -d $(DESTDIR)$(includedir)/ldns ] || rmdir -p $(DESTDI)$(includedir)/ldns || echo "ok, dir already gone"
|
||||
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) || echo "ok, dir already gone"
|
||||
|
||||
install-pyldns: @PYLDNS@
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(python_site)/ldns
|
||||
$(INSTALL) -c -m 644 $(pywrapdir)/ldns.py $(DESTDIR)$(python_site)/ldns.py
|
||||
$(LIBTOOL) --mode=install cp _ldns.la $(DESTDIR)$(python_site)
|
||||
$(LIBTOOL) --mode=finish $(DESTDIR)$(python_site)
|
||||
|
||||
uninstall-pyldns:
|
||||
rm -f $(DESTDIR)$(python_site)/ldns/*
|
||||
rmdir -p $(DESTDIR)$(python_site)/ldns
|
||||
|
||||
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 -rf lib
|
||||
rm -rf .libs
|
||||
rm -f linktest
|
||||
rm -f $(pywrapdir)/ldns_wrapper.c $(pywrapdir)/ldns.py
|
||||
|
||||
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.*
|
||||
$(LIBTOOL) --mode clean rm -f _ldns.la
|
||||
rm -rf ldns/net.h ldns/util.h ldns/config.h
|
||||
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 $@
|
||||
|
||||
isasciik$U.o: $(srcdir)/compat/isascii.c
|
||||
$(COMP_LIB) -c $(srcdir)/compat/isascii.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
|
||||
|
||||
test:
|
||||
if test -x "`which bash`"; then bash test/test_all.sh; else sh test/test_all.sh; fi
|
||||
|
||||
#-include $(ALL_SOURCES:.c=.d)
|
||||
|
||||
# Recreate symbols file, only needed when API changes
|
||||
# make clean first (and after this make clean; make again)
|
||||
symbols: lib-export-all
|
||||
nm -g lib/libldns.so | cut -d " " -f 3 | grep ldns | sort > $(srcdir)/ldns_symbols.def
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
|
||||
Contents:
|
||||
REQUIREMENTS
|
||||
INSTALLATION
|
||||
libdns
|
||||
examples
|
||||
drill
|
||||
INFORMATION FOR SPECIFIC OPERATING SYSTEMS
|
||||
Mac OS X
|
||||
Solaris
|
||||
Your Support
|
||||
|
||||
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. ./configure [--with-ldns=<path to ldns installation or build>]
|
||||
3. gmake
|
||||
|
||||
* Drill
|
||||
Drill can be built with:
|
||||
1. cd drill/
|
||||
2. ./configure [--with-ldns=<path to ldns installation or build>]
|
||||
3. 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 Wouter Wijngaards
|
||||
o Matthijs Mekking
|
||||
|
||||
Former main developers:
|
||||
o Jelte Jansen
|
||||
o Miek Gieben
|
||||
|
||||
* 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
|
||||
|
||||
|
||||
Your Support
|
||||
NLnet Labs offers all of its software products as open source, most are
|
||||
published under a BDS license. You can download them, not only from the
|
||||
NLnet Labs website but also through the various OS distributions for
|
||||
which NSD, ldns, and Unbound are packaged. We therefore have little idea
|
||||
who uses our software in production environments and have no direct ties
|
||||
with 'our customers'.
|
||||
|
||||
Therefore, we ask you to contact us at users@NLnetLabs.nl and tell us
|
||||
whether you use one of our products in your production environment,
|
||||
what that environment looks like, and maybe even share some praise.
|
||||
We would like to refer to the fact that your organization is using our
|
||||
products. We will only do that if you explicitly allow us. In all other
|
||||
cases we will keep the information you share with us to ourselves.
|
||||
|
||||
In addition to the moral support you can also support us
|
||||
financially. NLnet Labs is a recognized not-for-profit charity foundation
|
||||
that is chartered to develop open-source software and open-standards
|
||||
for the Internet. If you use our software to satisfaction please express
|
||||
that by giving us a donation. For small donations PayPal can be used. For
|
||||
larger and regular donations please contact us at users@NLnetLabs.nl. Also
|
||||
see http://www.nlnetlabs.nl/labs/contributors/.
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
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.
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
# 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
|
||||
|
||||
# on Solaris, and other systems that may not have
|
||||
# the default 'automake' and 'aclocal' script aliases,
|
||||
# the correct versions may need to be set. On those
|
||||
# systems, the 'autoreconf' line should be changed to:
|
||||
# AUTOMAKE=automake-1.10 ACLOCAL=aclocal-1.10 autoreconf
|
||||
# (and these systems probably need gmake instead of make)
|
||||
|
||||
# older versions of libtoolize do not support --install
|
||||
# so you might need to remove that (with newer versions
|
||||
# it is needed)
|
||||
libtoolize -c --install
|
||||
autoreconf --install
|
||||
./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)
|
||||
@@ -0,0 +1,122 @@
|
||||
# ===========================================================================
|
||||
# http://autoconf-archive.cryp.to/ac_pkg_swig.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AC_PROG_SWIG([major.minor.micro])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro searches for a SWIG installation on your system. If found you
|
||||
# should call SWIG via $(SWIG). You can use the optional first argument to
|
||||
# check if the version of the available SWIG is greater than or equal to
|
||||
# the value of the argument. It should have the format: N[.N[.N]] (N is a
|
||||
# number between 0 and 999. Only the first N is mandatory.)
|
||||
#
|
||||
# If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks that
|
||||
# the swig package is this version number or higher.
|
||||
#
|
||||
# In configure.in, use as:
|
||||
#
|
||||
# AC_PROG_SWIG(1.3.17)
|
||||
# SWIG_ENABLE_CXX
|
||||
# SWIG_MULTI_MODULE_SUPPORT
|
||||
# SWIG_PYTHON
|
||||
#
|
||||
# LAST MODIFICATION
|
||||
#
|
||||
# 2008-04-12
|
||||
#
|
||||
# COPYLEFT
|
||||
#
|
||||
# Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de>
|
||||
# Copyright (c) 2008 Alan W. Irwin <irwin@beluga.phys.uvic.ca>
|
||||
# Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net>
|
||||
# Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation; either version 2 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||
# gives unlimited permission to copy, distribute and modify the configure
|
||||
# scripts that are the output of Autoconf when processing the Macro. You
|
||||
# need not follow the terms of the GNU General Public License when using
|
||||
# or distributing such scripts, even though portions of the text of the
|
||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
# all other use of the material that constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the Autoconf
|
||||
# Macro released by the Autoconf Macro Archive. When you make and
|
||||
# distribute a modified version of the Autoconf Macro, you may extend this
|
||||
# special exception to the GPL to apply to your modified version as well.
|
||||
|
||||
AC_DEFUN([AC_PROG_SWIG],[
|
||||
AC_PATH_PROG([SWIG],[swig])
|
||||
if test -z "$SWIG" ; then
|
||||
AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org])
|
||||
SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false'
|
||||
elif test -n "$1" ; then
|
||||
AC_MSG_CHECKING([for SWIG version])
|
||||
[swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`]
|
||||
AC_MSG_RESULT([$swig_version])
|
||||
if test -n "$swig_version" ; then
|
||||
# Calculate the required version number components
|
||||
[required=$1]
|
||||
[required_major=`echo $required | sed 's/[^0-9].*//'`]
|
||||
if test -z "$required_major" ; then
|
||||
[required_major=0]
|
||||
fi
|
||||
[required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
|
||||
[required_minor=`echo $required | sed 's/[^0-9].*//'`]
|
||||
if test -z "$required_minor" ; then
|
||||
[required_minor=0]
|
||||
fi
|
||||
[required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
|
||||
[required_patch=`echo $required | sed 's/[^0-9].*//'`]
|
||||
if test -z "$required_patch" ; then
|
||||
[required_patch=0]
|
||||
fi
|
||||
# Calculate the available version number components
|
||||
[available=$swig_version]
|
||||
[available_major=`echo $available | sed 's/[^0-9].*//'`]
|
||||
if test -z "$available_major" ; then
|
||||
[available_major=0]
|
||||
fi
|
||||
[available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
|
||||
[available_minor=`echo $available | sed 's/[^0-9].*//'`]
|
||||
if test -z "$available_minor" ; then
|
||||
[available_minor=0]
|
||||
fi
|
||||
[available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
|
||||
[available_patch=`echo $available | sed 's/[^0-9].*//'`]
|
||||
if test -z "$available_patch" ; then
|
||||
[available_patch=0]
|
||||
fi
|
||||
if test $available_major -ne $required_major \
|
||||
-o $available_minor -ne $required_minor \
|
||||
-o $available_patch -lt $required_patch ; then
|
||||
AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version. You should look at http://www.swig.org])
|
||||
SWIG='echo "Error: SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org" ; false'
|
||||
else
|
||||
AC_MSG_NOTICE([SWIG executable is '$SWIG'])
|
||||
SWIG_LIB=`$SWIG -swiglib`
|
||||
AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB'])
|
||||
fi
|
||||
else
|
||||
AC_MSG_WARN([cannot determine SWIG version])
|
||||
SWIG='echo "Error: Cannot determine SWIG version. You should look at http://www.swig.org" ; false'
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([SWIG_LIB])
|
||||
])
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,200 @@
|
||||
AC_DEFUN([AC_PYTHON_DEVEL],[
|
||||
#
|
||||
# Allow the use of a (user set) custom python version
|
||||
#
|
||||
AC_ARG_VAR([PYTHON_VERSION],[The installed Python
|
||||
version to use, for example '2.3'. This string
|
||||
will be appended to the Python interpreter
|
||||
canonical name.])
|
||||
|
||||
AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
|
||||
if test -z "$PYTHON"; then
|
||||
AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path])
|
||||
PYTHON_VERSION=""
|
||||
fi
|
||||
|
||||
if test -z "$PYTHON_VERSION"; then
|
||||
PYTHON_VERSION=`$PYTHON -c "import sys, string; \
|
||||
print string.split(sys.version)[[0]]"`
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for a version of Python >= 2.1.0
|
||||
#
|
||||
AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
|
||||
ac_supports_python_ver=`$PYTHON -c "import sys, string; \
|
||||
ver = string.split(sys.version)[[0]]; \
|
||||
print ver >= '2.1.0'"`
|
||||
if test "$ac_supports_python_ver" != "True"; then
|
||||
if test -z "$PYTHON_NOVERSIONCHECK"; then
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_FAILURE([
|
||||
This version of the AC@&t@_PYTHON_DEVEL macro
|
||||
doesn't work properly with versions of Python before
|
||||
2.1.0. You may need to re-run configure, setting the
|
||||
variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
|
||||
PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
|
||||
Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
|
||||
to something else than an empty string.
|
||||
])
|
||||
else
|
||||
AC_MSG_RESULT([skip at user request])
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
fi
|
||||
|
||||
#
|
||||
# if the macro parameter ``version'' is set, honour it
|
||||
#
|
||||
if test -n "$1"; then
|
||||
AC_MSG_CHECKING([for a version of Python $1])
|
||||
ac_supports_python_ver=`$PYTHON -c "import sys, string; \
|
||||
ver = string.split(sys.version)[[0]]; \
|
||||
print ver $1"`
|
||||
if test "$ac_supports_python_ver" = "True"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([this package requires Python $1.
|
||||
If you have it installed, but it isn't the default Python
|
||||
interpreter in your system path, please pass the PYTHON_VERSION
|
||||
variable to configure. See ``configure --help'' for reference.
|
||||
])
|
||||
PYTHON_VERSION=""
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Check if you have distutils, else fail
|
||||
#
|
||||
AC_MSG_CHECKING([for the distutils Python package])
|
||||
ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
|
||||
if test -z "$ac_distutils_result"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([cannot import Python module "distutils".
|
||||
Please check your Python installation. The error was:
|
||||
$ac_distutils_result])
|
||||
PYTHON_VERSION=""
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for Python include path
|
||||
#
|
||||
AC_MSG_CHECKING([for Python include path])
|
||||
if test -z "$PYTHON_CPPFLAGS"; then
|
||||
python_path=`$PYTHON -c "import distutils.sysconfig; \
|
||||
print distutils.sysconfig.get_python_inc();"`
|
||||
if test -n "${python_path}"; then
|
||||
python_path="-I$python_path"
|
||||
fi
|
||||
PYTHON_CPPFLAGS=$python_path
|
||||
fi
|
||||
AC_MSG_RESULT([$PYTHON_CPPFLAGS])
|
||||
AC_SUBST([PYTHON_CPPFLAGS])
|
||||
|
||||
#
|
||||
# Check for Python library path
|
||||
#
|
||||
AC_MSG_CHECKING([for Python library path])
|
||||
if test -z "$PYTHON_LDFLAGS"; then
|
||||
# (makes two attempts to ensure we've got a version number
|
||||
# from the interpreter)
|
||||
py_version=`$PYTHON -c "from distutils.sysconfig import *; \
|
||||
from string import join; \
|
||||
print join(get_config_vars('VERSION'))"`
|
||||
if test "$py_version" = "[None]"; then
|
||||
if test -n "$PYTHON_VERSION"; then
|
||||
py_version=$PYTHON_VERSION
|
||||
else
|
||||
py_version=`$PYTHON -c "import sys; \
|
||||
print sys.version[[:3]]"`
|
||||
fi
|
||||
fi
|
||||
|
||||
PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
|
||||
from string import join; \
|
||||
print '-L' + get_python_lib(0,1), \
|
||||
'-L' + os.path.dirname(get_python_lib(0,1)), \
|
||||
'-lpython';"`$py_version
|
||||
fi
|
||||
AC_MSG_RESULT([$PYTHON_LDFLAGS])
|
||||
AC_SUBST([PYTHON_LDFLAGS])
|
||||
|
||||
#
|
||||
# Check for site packages
|
||||
#
|
||||
AC_MSG_CHECKING([for Python site-packages path])
|
||||
if test -z "$PYTHON_SITE_PKG"; then
|
||||
PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
|
||||
print distutils.sysconfig.get_python_lib(0,0);"`
|
||||
fi
|
||||
AC_MSG_RESULT([$PYTHON_SITE_PKG])
|
||||
AC_SUBST([PYTHON_SITE_PKG])
|
||||
|
||||
#
|
||||
# libraries which must be linked in when embedding
|
||||
#
|
||||
AC_MSG_CHECKING(python extra libraries)
|
||||
if test -z "$PYTHON_EXTRA_LIBS"; then
|
||||
PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
|
||||
conf = distutils.sysconfig.get_config_var; \
|
||||
print conf('LOCALMODLIBS'), conf('LIBS')"`
|
||||
fi
|
||||
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
|
||||
AC_SUBST(PYTHON_EXTRA_LIBS)
|
||||
|
||||
#
|
||||
# linking flags needed when embedding
|
||||
#
|
||||
AC_MSG_CHECKING(python extra linking flags)
|
||||
if test -z "$PYTHON_EXTRA_LDFLAGS"; then
|
||||
PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
|
||||
conf = distutils.sysconfig.get_config_var; \
|
||||
print conf('LINKFORSHARED')"`
|
||||
fi
|
||||
AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
|
||||
AC_SUBST(PYTHON_EXTRA_LDFLAGS)
|
||||
|
||||
#
|
||||
# final check to see if everything compiles alright
|
||||
#
|
||||
AC_MSG_CHECKING([consistency of all components of python development environment])
|
||||
AC_LANG_PUSH([C])
|
||||
# save current global flags
|
||||
LIBS="$ac_save_LIBS $PYTHON_LDFLAGS"
|
||||
CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
|
||||
AC_TRY_LINK([
|
||||
#include <Python.h>
|
||||
],[
|
||||
Py_Initialize();
|
||||
],[pythonexists=yes],[pythonexists=no])
|
||||
|
||||
AC_MSG_RESULT([$pythonexists])
|
||||
|
||||
if test ! "$pythonexists" = "yes"; then
|
||||
AC_MSG_ERROR([
|
||||
Could not link test program to Python. Maybe the main Python library has been
|
||||
installed in some non-standard library path. If so, pass it to configure,
|
||||
via the LDFLAGS environment variable.
|
||||
Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
|
||||
============================================================================
|
||||
ERROR!
|
||||
You probably have to install the development version of the Python package
|
||||
for your distribution. The exact name of this package varies among them.
|
||||
============================================================================
|
||||
])
|
||||
PYTHON_VERSION=""
|
||||
fi
|
||||
AC_LANG_POP
|
||||
# turn back to default flags
|
||||
CPPFLAGS="$ac_save_CPPFLAGS"
|
||||
LIBS="$ac_save_LIBS"
|
||||
|
||||
#
|
||||
# all done!
|
||||
#
|
||||
])
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* 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->_fixed = 0;
|
||||
buffer->_data = LDNS_XMALLOC(uint8_t, size);
|
||||
if(!buffer->_data) {
|
||||
buffer->_status = LDNS_STATUS_MEM_ERR;
|
||||
return;
|
||||
}
|
||||
memcpy(buffer->_data, data, size);
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,335 @@
|
||||
/*
|
||||
* 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 <sys/types.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#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>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
static const char Base32[] =
|
||||
"abcdefghijklmnopqrstuvwxyz234567";
|
||||
/* "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";*/
|
||||
/* 00000000001111111111222222222233
|
||||
01234567890123456789012345678901*/
|
||||
static const char Base32_extended_hex[] =
|
||||
/* "0123456789ABCDEFGHIJKLMNOPQRSTUV";*/
|
||||
"0123456789abcdefghijklmnopqrstuv";
|
||||
static const char Pad32 = '=';
|
||||
|
||||
/* (From RFC3548 and draft-josefsson-rfc3548bis-00.txt)
|
||||
5. Base 32 Encoding
|
||||
|
||||
The Base 32 encoding is designed to represent arbitrary sequences of
|
||||
octets in a form that needs to be case insensitive but need not be
|
||||
humanly readable.
|
||||
|
||||
A 33-character subset of US-ASCII is used, enabling 5 bits to be
|
||||
represented per printable character. (The extra 33rd character, "=",
|
||||
is used to signify a special processing function.)
|
||||
|
||||
The encoding process represents 40-bit groups of input bits as output
|
||||
strings of 8 encoded characters. Proceeding from left to right, a
|
||||
40-bit input group is formed by concatenating 5 8bit input groups.
|
||||
These 40 bits are then treated as 8 concatenated 5-bit groups, each
|
||||
of which is translated into a single digit in the base 32 alphabet.
|
||||
When encoding a bit stream via the base 32 encoding, the bit stream
|
||||
must be presumed to be ordered with the most-significant-bit first.
|
||||
That is, the first bit in the stream will be the high-order bit in
|
||||
the first 8bit byte, and the eighth bit will be the low-order bit in
|
||||
the first 8bit byte, and so on.
|
||||
|
||||
Each 5-bit group is used as an index into an array of 32 printable
|
||||
characters. The character referenced by the index is placed in the
|
||||
output string. These characters, identified in Table 3, below, are
|
||||
selected from US-ASCII digits and uppercase letters.
|
||||
|
||||
Table 3: The Base 32 Alphabet
|
||||
|
||||
Value Encoding Value Encoding Value Encoding Value Encoding
|
||||
0 A 9 J 18 S 27 3
|
||||
1 B 10 K 19 T 28 4
|
||||
2 C 11 L 20 U 29 5
|
||||
3 D 12 M 21 V 30 6
|
||||
4 E 13 N 22 W 31 7
|
||||
5 F 14 O 23 X
|
||||
6 G 15 P 24 Y (pad) =
|
||||
7 H 16 Q 25 Z
|
||||
8 I 17 R 26 2
|
||||
|
||||
|
||||
Special processing is performed if fewer than 40 bits are available
|
||||
at the end of the data being encoded. A full encoding quantum is
|
||||
always completed at the end of a body. When fewer than 40 input bits
|
||||
are available in an input group, zero bits are added (on the right)
|
||||
to form an integral number of 5-bit groups. Padding at the end of
|
||||
the data is performed using the "=" character. Since all base 32
|
||||
input is an integral number of octets, only the following cases can
|
||||
arise:
|
||||
|
||||
(1) the final quantum of encoding input is an integral multiple of 40
|
||||
bits; here, the final unit of encoded output will be an integral
|
||||
multiple of 8 characters with no "=" padding,
|
||||
|
||||
(2) the final quantum of encoding input is exactly 8 bits; here, the
|
||||
final unit of encoded output will be two characters followed by six
|
||||
"=" padding characters,
|
||||
|
||||
(3) the final quantum of encoding input is exactly 16 bits; here, the
|
||||
final unit of encoded output will be four characters followed by four
|
||||
"=" padding characters,
|
||||
|
||||
(4) the final quantum of encoding input is exactly 24 bits; here, the
|
||||
final unit of encoded output will be five characters followed by
|
||||
three "=" padding characters, or
|
||||
|
||||
(5) the final quantum of encoding input is exactly 32 bits; here, the
|
||||
final unit of encoded output will be seven characters followed by one
|
||||
"=" padding character.
|
||||
|
||||
|
||||
6. Base 32 Encoding with Extended Hex Alphabet
|
||||
|
||||
The following description of base 32 is due to [7]. This encoding
|
||||
should not be regarded as the same as the "base32" encoding, and
|
||||
should not be referred to as only "base32".
|
||||
|
||||
One property with this alphabet, that the base64 and base32 alphabet
|
||||
lack, is that encoded data maintain its sort order when the encoded
|
||||
data is compared bit-wise.
|
||||
|
||||
This encoding is identical to the previous one, except for the
|
||||
alphabet. The new alphabet is found in table 4.
|
||||
|
||||
Table 4: The "Extended Hex" Base 32 Alphabet
|
||||
|
||||
Value Encoding Value Encoding Value Encoding Value Encoding
|
||||
0 0 9 9 18 I 27 R
|
||||
1 1 10 A 19 J 28 S
|
||||
2 2 11 B 20 K 29 T
|
||||
3 3 12 C 21 L 30 U
|
||||
4 4 13 D 22 M 31 V
|
||||
5 5 14 E 23 N
|
||||
6 6 15 F 24 O (pad) =
|
||||
7 7 16 G 25 P
|
||||
8 8 17 H 26 Q
|
||||
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
ldns_b32_ntop_ar(uint8_t const *src, size_t srclength, char *target, size_t targsize, const char B32_ar[]) {
|
||||
size_t datalength = 0;
|
||||
uint8_t input[5];
|
||||
uint8_t output[8];
|
||||
size_t i;
|
||||
memset(output, 0, 8);
|
||||
|
||||
while (4 < srclength) {
|
||||
input[0] = *src++;
|
||||
input[1] = *src++;
|
||||
input[2] = *src++;
|
||||
input[3] = *src++;
|
||||
input[4] = *src++;
|
||||
srclength -= 5;
|
||||
|
||||
output[0] = (input[0] & 0xf8) >> 3;
|
||||
output[1] = ((input[0] & 0x07) << 2) + ((input[1] & 0xc0) >> 6);
|
||||
output[2] = (input[1] & 0x3e) >> 1;
|
||||
output[3] = ((input[1] & 0x01) << 4) + ((input[2] & 0xf0) >> 4);
|
||||
output[4] = ((input[2] & 0x0f) << 1) + ((input[3] & 0x80) >> 7);
|
||||
output[5] = (input[3] & 0x7c) >> 2;
|
||||
output[6] = ((input[3] & 0x03) << 3) + ((input[4] & 0xe0) >> 5);
|
||||
output[7] = (input[4] & 0x1f);
|
||||
|
||||
assert(output[0] < 32);
|
||||
assert(output[1] < 32);
|
||||
assert(output[2] < 32);
|
||||
assert(output[3] < 32);
|
||||
assert(output[4] < 32);
|
||||
assert(output[5] < 32);
|
||||
assert(output[6] < 32);
|
||||
assert(output[7] < 32);
|
||||
|
||||
if (datalength + 8 > targsize) {
|
||||
return (-1);
|
||||
}
|
||||
target[datalength++] = B32_ar[output[0]];
|
||||
target[datalength++] = B32_ar[output[1]];
|
||||
target[datalength++] = B32_ar[output[2]];
|
||||
target[datalength++] = B32_ar[output[3]];
|
||||
target[datalength++] = B32_ar[output[4]];
|
||||
target[datalength++] = B32_ar[output[5]];
|
||||
target[datalength++] = B32_ar[output[6]];
|
||||
target[datalength++] = B32_ar[output[7]];
|
||||
}
|
||||
|
||||
/* Now we worry about padding. */
|
||||
if (0 != srclength) {
|
||||
/* Get what's left. */
|
||||
input[0] = input[1] = input[2] = input[3] = input[4] = (uint8_t) '\0';
|
||||
for (i = 0; i < srclength; i++)
|
||||
input[i] = *src++;
|
||||
|
||||
output[0] = (input[0] & 0xf8) >> 3;
|
||||
assert(output[0] < 32);
|
||||
if (srclength >= 1) {
|
||||
output[1] = ((input[0] & 0x07) << 2) + ((input[1] & 0xc0) >> 6);
|
||||
assert(output[1] < 32);
|
||||
output[2] = (input[1] & 0x3e) >> 1;
|
||||
assert(output[2] < 32);
|
||||
}
|
||||
if (srclength >= 2) {
|
||||
output[3] = ((input[1] & 0x01) << 4) + ((input[2] & 0xf0) >> 4);
|
||||
assert(output[3] < 32);
|
||||
}
|
||||
if (srclength >= 3) {
|
||||
output[4] = ((input[2] & 0x0f) << 1) + ((input[3] & 0x80) >> 7);
|
||||
assert(output[4] < 32);
|
||||
output[5] = (input[3] & 0x7c) >> 2;
|
||||
assert(output[5] < 32);
|
||||
}
|
||||
if (srclength >= 4) {
|
||||
output[6] = ((input[3] & 0x03) << 3) + ((input[4] & 0xe0) >> 5);
|
||||
assert(output[6] < 32);
|
||||
}
|
||||
|
||||
|
||||
if (datalength + 1 > targsize) {
|
||||
return (-2);
|
||||
}
|
||||
target[datalength++] = B32_ar[output[0]];
|
||||
if (srclength >= 1) {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = B32_ar[output[1]];
|
||||
if (srclength == 1 && output[2] == 0) {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = Pad32;
|
||||
} else {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = B32_ar[output[2]];
|
||||
}
|
||||
} else {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = Pad32;
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = Pad32;
|
||||
}
|
||||
if (srclength >= 2) {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = B32_ar[output[3]];
|
||||
} else {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = Pad32;
|
||||
}
|
||||
if (srclength >= 3) {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = B32_ar[output[4]];
|
||||
if (srclength == 3 && output[5] == 0) {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = Pad32;
|
||||
} else {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = B32_ar[output[5]];
|
||||
}
|
||||
} else {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = Pad32;
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = Pad32;
|
||||
}
|
||||
if (srclength >= 4) {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = B32_ar[output[6]];
|
||||
} else {
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = Pad32;
|
||||
}
|
||||
if (datalength + 1 > targsize) { return (-2); }
|
||||
target[datalength++] = Pad32;
|
||||
}
|
||||
if (datalength+1 > targsize) {
|
||||
return (int) (datalength);
|
||||
}
|
||||
target[datalength] = '\0'; /* Returned value doesn't count \0. */
|
||||
return (int) (datalength);
|
||||
}
|
||||
|
||||
int
|
||||
ldns_b32_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
|
||||
return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32);
|
||||
}
|
||||
|
||||
/* deprecated, here for backwards compatibility */
|
||||
int
|
||||
b32_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
|
||||
return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32);
|
||||
}
|
||||
|
||||
int
|
||||
ldns_b32_ntop_extended_hex(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
|
||||
return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32_extended_hex);
|
||||
}
|
||||
|
||||
/* deprecated, here for backwards compatibility */
|
||||
int
|
||||
b32_ntop_extended_hex(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
|
||||
return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32_extended_hex);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,389 @@
|
||||
/*
|
||||
* 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 <sys/types.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#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>
|
||||
|
||||
/* "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";*/
|
||||
static const char Base32[] =
|
||||
"abcdefghijklmnopqrstuvwxyz234567";
|
||||
/* "0123456789ABCDEFGHIJKLMNOPQRSTUV";*/
|
||||
static const char Base32_extended_hex[] =
|
||||
"0123456789abcdefghijklmnopqrstuv";
|
||||
static const char Pad32 = '=';
|
||||
|
||||
/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
|
||||
5. Base 32 Encoding
|
||||
|
||||
The Base 32 encoding is designed to represent arbitrary sequences of
|
||||
octets in a form that needs to be case insensitive but need not be
|
||||
humanly readable.
|
||||
|
||||
A 33-character subset of US-ASCII is used, enabling 5 bits to be
|
||||
represented per printable character. (The extra 33rd character, "=",
|
||||
is used to signify a special processing function.)
|
||||
|
||||
The encoding process represents 40-bit groups of input bits as output
|
||||
strings of 8 encoded characters. Proceeding from left to right, a
|
||||
40-bit input group is formed by concatenating 5 8bit input groups.
|
||||
These 40 bits are then treated as 8 concatenated 5-bit groups, each
|
||||
of which is translated into a single digit in the base 32 alphabet.
|
||||
When encoding a bit stream via the base 32 encoding, the bit stream
|
||||
must be presumed to be ordered with the most-significant-bit first.
|
||||
That is, the first bit in the stream will be the high-order bit in
|
||||
the first 8bit byte, and the eighth bit will be the low-order bit in
|
||||
the first 8bit byte, and so on.
|
||||
|
||||
Each 5-bit group is used as an index into an array of 32 printable
|
||||
characters. The character referenced by the index is placed in the
|
||||
output string. These characters, identified in Table 3, below, are
|
||||
selected from US-ASCII digits and uppercase letters.
|
||||
|
||||
Table 3: The Base 32 Alphabet
|
||||
|
||||
Value Encoding Value Encoding Value Encoding Value Encoding
|
||||
0 A 9 J 18 S 27 3
|
||||
1 B 10 K 19 T 28 4
|
||||
2 C 11 L 20 U 29 5
|
||||
3 D 12 M 21 V 30 6
|
||||
4 E 13 N 22 W 31 7
|
||||
5 F 14 O 23 X
|
||||
6 G 15 P 24 Y (pad) =
|
||||
7 H 16 Q 25 Z
|
||||
8 I 17 R 26 2
|
||||
|
||||
|
||||
Special processing is performed if fewer than 40 bits are available
|
||||
at the end of the data being encoded. A full encoding quantum is
|
||||
always completed at the end of a body. When fewer than 40 input bits
|
||||
are available in an input group, zero bits are added (on the right)
|
||||
to form an integral number of 5-bit groups. Padding at the end of
|
||||
the data is performed using the "=" character. Since all base 32
|
||||
input is an integral number of octets, only the following cases can
|
||||
arise:
|
||||
|
||||
(1) the final quantum of encoding input is an integral multiple of 40
|
||||
bits; here, the final unit of encoded output will be an integral
|
||||
multiple of 8 characters with no "=" padding,
|
||||
|
||||
(2) the final quantum of encoding input is exactly 8 bits; here, the
|
||||
final unit of encoded output will be two characters followed by six
|
||||
"=" padding characters,
|
||||
|
||||
(3) the final quantum of encoding input is exactly 16 bits; here, the
|
||||
final unit of encoded output will be four characters followed by four
|
||||
"=" padding characters,
|
||||
|
||||
(4) the final quantum of encoding input is exactly 24 bits; here, the
|
||||
final unit of encoded output will be five characters followed by
|
||||
three "=" padding characters, or
|
||||
|
||||
(5) the final quantum of encoding input is exactly 32 bits; here, the
|
||||
final unit of encoded output will be seven characters followed by one
|
||||
"=" padding character.
|
||||
|
||||
|
||||
6. Base 32 Encoding with Extended Hex Alphabet
|
||||
|
||||
The following description of base 32 is due to [7]. This encoding
|
||||
should not be regarded as the same as the "base32" encoding, and
|
||||
should not be referred to as only "base32".
|
||||
|
||||
One property with this alphabet, that the base32 and base32 alphabet
|
||||
lack, is that encoded data maintain its sort order when the encoded
|
||||
data is compared bit-wise.
|
||||
|
||||
This encoding is identical to the previous one, except for the
|
||||
alphabet. The new alphabet is found in table 4.
|
||||
|
||||
Table 4: The "Extended Hex" Base 32 Alphabet
|
||||
|
||||
Value Encoding Value Encoding Value Encoding Value Encoding
|
||||
0 0 9 9 18 I 27 R
|
||||
1 1 10 A 19 J 28 S
|
||||
2 2 11 B 20 K 29 T
|
||||
3 3 12 C 21 L 30 U
|
||||
4 4 13 D 22 M 31 V
|
||||
5 5 14 E 23 N
|
||||
6 6 15 F 24 O (pad) =
|
||||
7 7 16 G 25 P
|
||||
8 8 17 H 26 Q
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
/* skips all whitespace anywhere.
|
||||
converts characters, four at a time, starting at (or after)
|
||||
src from base - 32 numbers into three 8 bit bytes in the target area.
|
||||
it returns the number of data bytes stored at the target, or -1 on error.
|
||||
*/
|
||||
|
||||
int
|
||||
ldns_b32_pton_ar(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize, const char B32_ar[])
|
||||
{
|
||||
int tarindex, state, ch;
|
||||
char *pos;
|
||||
int i = 0;
|
||||
|
||||
state = 0;
|
||||
tarindex = 0;
|
||||
|
||||
while ((ch = *src++) != '\0' && (i == 0 || i < (int) hashed_owner_str_len)) {
|
||||
i++;
|
||||
ch = tolower(ch);
|
||||
if (isspace((unsigned char)ch)) /* Skip whitespace anywhere. */
|
||||
continue;
|
||||
|
||||
if (ch == Pad32)
|
||||
break;
|
||||
|
||||
pos = strchr(B32_ar, ch);
|
||||
if (pos == 0) {
|
||||
/* A non-base32 character. */
|
||||
return (-ch);
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (target) {
|
||||
if ((size_t)tarindex >= targsize) {
|
||||
return (-2);
|
||||
}
|
||||
target[tarindex] = (pos - B32_ar) << 3;
|
||||
}
|
||||
state = 1;
|
||||
break;
|
||||
case 1:
|
||||
if (target) {
|
||||
if ((size_t)tarindex + 1 >= targsize) {
|
||||
return (-3);
|
||||
}
|
||||
target[tarindex] |= (pos - B32_ar) >> 2;
|
||||
target[tarindex+1] = ((pos - B32_ar) & 0x03)
|
||||
<< 6 ;
|
||||
}
|
||||
tarindex++;
|
||||
state = 2;
|
||||
break;
|
||||
case 2:
|
||||
if (target) {
|
||||
if ((size_t)tarindex + 1 >= targsize) {
|
||||
return (-4);
|
||||
}
|
||||
target[tarindex] |= (pos - B32_ar) << 1;
|
||||
}
|
||||
/*tarindex++;*/
|
||||
state = 3;
|
||||
break;
|
||||
case 3:
|
||||
if (target) {
|
||||
if ((size_t)tarindex + 1 >= targsize) {
|
||||
return (-5);
|
||||
}
|
||||
target[tarindex] |= (pos - B32_ar) >> 4;
|
||||
target[tarindex+1] = ((pos - B32_ar) & 0x0f) << 4 ;
|
||||
}
|
||||
tarindex++;
|
||||
state = 4;
|
||||
break;
|
||||
case 4:
|
||||
if (target) {
|
||||
if ((size_t)tarindex + 1 >= targsize) {
|
||||
return (-6);
|
||||
}
|
||||
target[tarindex] |= (pos - B32_ar) >> 1;
|
||||
target[tarindex+1] = ((pos - B32_ar) & 0x01)
|
||||
<< 7 ;
|
||||
}
|
||||
tarindex++;
|
||||
state = 5;
|
||||
break;
|
||||
case 5:
|
||||
if (target) {
|
||||
if ((size_t)tarindex + 1 >= targsize) {
|
||||
return (-7);
|
||||
}
|
||||
target[tarindex] |= (pos - B32_ar) << 2;
|
||||
}
|
||||
state = 6;
|
||||
break;
|
||||
case 6:
|
||||
if (target) {
|
||||
if ((size_t)tarindex + 1 >= targsize) {
|
||||
return (-8);
|
||||
}
|
||||
target[tarindex] |= (pos - B32_ar) >> 3;
|
||||
target[tarindex+1] = ((pos - B32_ar) & 0x07)
|
||||
<< 5 ;
|
||||
}
|
||||
tarindex++;
|
||||
state = 7;
|
||||
break;
|
||||
case 7:
|
||||
if (target) {
|
||||
if ((size_t)tarindex + 1 >= targsize) {
|
||||
return (-9);
|
||||
}
|
||||
target[tarindex] |= (pos - B32_ar);
|
||||
}
|
||||
tarindex++;
|
||||
state = 0;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We are done decoding Base-32 chars. Let's see if we ended
|
||||
* on a byte boundary, and/or with erroneous trailing characters.
|
||||
*/
|
||||
|
||||
if (ch == Pad32) { /* We got a pad char. */
|
||||
ch = *src++; /* Skip it, get next. */
|
||||
switch (state) {
|
||||
case 0: /* Invalid = in first position */
|
||||
case 1: /* Invalid = in second position */
|
||||
return (-10);
|
||||
|
||||
case 2: /* Valid, means one byte of info */
|
||||
case 3:
|
||||
/* Skip any number of spaces. */
|
||||
for ((void)NULL; ch != '\0'; ch = *src++)
|
||||
if (!isspace((unsigned char)ch))
|
||||
break;
|
||||
/* Make sure there is another trailing = sign. */
|
||||
if (ch != Pad32) {
|
||||
return (-11);
|
||||
}
|
||||
ch = *src++; /* Skip the = */
|
||||
/* Fall through to "single trailing =" case. */
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 4: /* Valid, means two bytes of info */
|
||||
case 5:
|
||||
case 6:
|
||||
/*
|
||||
* We know this char is an =. Is there anything but
|
||||
* whitespace after it?
|
||||
*/
|
||||
for ((void)NULL; ch != '\0'; ch = *src++)
|
||||
if (!(isspace((unsigned char)ch) || ch == '=')) {
|
||||
return (-12);
|
||||
}
|
||||
|
||||
case 7: /* Valid, means three bytes of info */
|
||||
/*
|
||||
* We know this char is an =. Is there anything but
|
||||
* whitespace after it?
|
||||
*/
|
||||
for ((void)NULL; ch != '\0'; ch = *src++)
|
||||
if (!isspace((unsigned char)ch)) {
|
||||
return (-13);
|
||||
}
|
||||
|
||||
/*
|
||||
* Now make sure for cases 2 and 3 that the "extra"
|
||||
* bits that slopped past the last full byte were
|
||||
* zeros. If we don't check them, they become a
|
||||
* subliminal channel.
|
||||
*/
|
||||
if (target && target[tarindex] != 0) {
|
||||
return (-14);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* We ended by seeing the end of the string. Make sure we
|
||||
* have no partial bytes lying around.
|
||||
*/
|
||||
if (state != 0)
|
||||
return (-15);
|
||||
}
|
||||
|
||||
return (tarindex);
|
||||
}
|
||||
|
||||
int
|
||||
ldns_b32_pton(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
|
||||
{
|
||||
return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32);
|
||||
}
|
||||
|
||||
/* deprecated, here for backwards compatibility */
|
||||
int
|
||||
b32_pton(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
|
||||
{
|
||||
return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32);
|
||||
}
|
||||
|
||||
int
|
||||
ldns_b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
|
||||
{
|
||||
return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32_extended_hex);
|
||||
}
|
||||
|
||||
/* deprecated, here for backwards compatibility */
|
||||
int
|
||||
b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
|
||||
{
|
||||
return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32_extended_hex);
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* 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 <sys/types.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#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.
|
||||
|
||||
Table 1: The Base64 Alphabet
|
||||
|
||||
Value Encoding Value Encoding Value Encoding Value Encoding
|
||||
0 A 17 R 34 i 51 z
|
||||
1 B 18 S 35 j 52 0
|
||||
2 C 19 T 36 k 53 1
|
||||
3 D 20 U 37 l 54 2
|
||||
4 E 21 V 38 m 55 3
|
||||
5 F 22 W 39 n 56 4
|
||||
6 G 23 X 40 o 57 5
|
||||
7 H 24 Y 41 p 58 6
|
||||
8 I 25 Z 42 q 59 7
|
||||
9 J 26 a 43 r 60 8
|
||||
10 K 27 b 44 s 61 9
|
||||
11 L 28 c 45 t 62 +
|
||||
12 M 29 d 46 u 63 /
|
||||
13 N 30 e 47 v
|
||||
14 O 31 f 48 w (pad) =
|
||||
15 P 32 g 49 x
|
||||
16 Q 33 h 50 y
|
||||
|
||||
Special processing is performed if fewer than 24 bits are available
|
||||
at the end of the data being encoded. A full encoding quantum is
|
||||
always completed at the end of a quantity. When fewer than 24 input
|
||||
bits are available in an input group, zero bits are added (on the
|
||||
right) to form an integral number of 6-bit groups. Padding at the
|
||||
end of the data is performed using the '=' character.
|
||||
|
||||
Since all base64 input is an integral number of octets, only the
|
||||
-------------------------------------------------
|
||||
following cases can arise:
|
||||
|
||||
(1) the final quantum of encoding input is an integral
|
||||
multiple of 24 bits; here, the final unit of encoded
|
||||
output will be an integral multiple of 4 characters
|
||||
with no "=" padding,
|
||||
(2) the final quantum of encoding input is exactly 8 bits;
|
||||
here, the final unit of encoded output will be two
|
||||
characters followed by two "=" padding characters, or
|
||||
(3) the final quantum of encoding input is exactly 16 bits;
|
||||
here, the final unit of encoded output will be three
|
||||
characters followed by one "=" padding character.
|
||||
*/
|
||||
|
||||
int
|
||||
ldns_b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
|
||||
size_t datalength = 0;
|
||||
uint8_t input[3];
|
||||
uint8_t output[4];
|
||||
size_t i;
|
||||
|
||||
if (srclength == 0) {
|
||||
if (targsize > 0) {
|
||||
target[0] = '\0';
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
while (2 < srclength) {
|
||||
input[0] = *src++;
|
||||
input[1] = *src++;
|
||||
input[2] = *src++;
|
||||
srclength -= 3;
|
||||
|
||||
output[0] = input[0] >> 2;
|
||||
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
|
||||
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|
||||
output[3] = input[2] & 0x3f;
|
||||
Assert(output[0] < 64);
|
||||
Assert(output[1] < 64);
|
||||
Assert(output[2] < 64);
|
||||
Assert(output[3] < 64);
|
||||
|
||||
if (datalength + 4 > targsize) {
|
||||
return (-1);
|
||||
}
|
||||
target[datalength++] = Base64[output[0]];
|
||||
target[datalength++] = Base64[output[1]];
|
||||
target[datalength++] = Base64[output[2]];
|
||||
target[datalength++] = Base64[output[3]];
|
||||
}
|
||||
|
||||
/* Now we worry about padding. */
|
||||
if (0 != srclength) {
|
||||
/* Get what's left. */
|
||||
input[0] = input[1] = input[2] = (uint8_t) '\0';
|
||||
for (i = 0; i < srclength; i++)
|
||||
input[i] = *src++;
|
||||
|
||||
output[0] = input[0] >> 2;
|
||||
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
|
||||
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|
||||
Assert(output[0] < 64);
|
||||
Assert(output[1] < 64);
|
||||
Assert(output[2] < 64);
|
||||
|
||||
if (datalength + 4 > targsize) {
|
||||
return (-2);
|
||||
}
|
||||
target[datalength++] = Base64[output[0]];
|
||||
target[datalength++] = Base64[output[1]];
|
||||
if (srclength == 1) {
|
||||
target[datalength++] = Pad64;
|
||||
} else {
|
||||
target[datalength++] = Base64[output[2]];
|
||||
}
|
||||
target[datalength++] = Pad64;
|
||||
}
|
||||
if (datalength >= targsize) {
|
||||
return (-3);
|
||||
}
|
||||
target[datalength] = '\0'; /* Returned value doesn't count \0. */
|
||||
return (int) (datalength);
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
* 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 <sys/types.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#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.
|
||||
|
||||
Table 1: The Base64 Alphabet
|
||||
|
||||
Value Encoding Value Encoding Value Encoding Value Encoding
|
||||
0 A 17 R 34 i 51 z
|
||||
1 B 18 S 35 j 52 0
|
||||
2 C 19 T 36 k 53 1
|
||||
3 D 20 U 37 l 54 2
|
||||
4 E 21 V 38 m 55 3
|
||||
5 F 22 W 39 n 56 4
|
||||
6 G 23 X 40 o 57 5
|
||||
7 H 24 Y 41 p 58 6
|
||||
8 I 25 Z 42 q 59 7
|
||||
9 J 26 a 43 r 60 8
|
||||
10 K 27 b 44 s 61 9
|
||||
11 L 28 c 45 t 62 +
|
||||
12 M 29 d 46 u 63 /
|
||||
13 N 30 e 47 v
|
||||
14 O 31 f 48 w (pad) =
|
||||
15 P 32 g 49 x
|
||||
16 Q 33 h 50 y
|
||||
|
||||
Special processing is performed if fewer than 24 bits are available
|
||||
at the end of the data being encoded. A full encoding quantum is
|
||||
always completed at the end of a quantity. When fewer than 24 input
|
||||
bits are available in an input group, zero bits are added (on the
|
||||
right) to form an integral number of 6-bit groups. Padding at the
|
||||
end of the data is performed using the '=' character.
|
||||
|
||||
Since all base64 input is an integral number of octets, only the
|
||||
-------------------------------------------------
|
||||
following cases can arise:
|
||||
|
||||
(1) the final quantum of encoding input is an integral
|
||||
multiple of 24 bits; here, the final unit of encoded
|
||||
output will be an integral multiple of 4 characters
|
||||
with no "=" padding,
|
||||
(2) the final quantum of encoding input is exactly 8 bits;
|
||||
here, the final unit of encoded output will be two
|
||||
characters followed by two "=" padding characters, or
|
||||
(3) the final quantum of encoding input is exactly 16 bits;
|
||||
here, the final unit of encoded output will be three
|
||||
characters followed by one "=" padding character.
|
||||
*/
|
||||
|
||||
/* skips all whitespace anywhere.
|
||||
converts characters, four at a time, starting at (or after)
|
||||
src from base - 64 numbers into three 8 bit bytes in the target area.
|
||||
it returns the number of data bytes stored at the target, or -1 on error.
|
||||
*/
|
||||
|
||||
int
|
||||
ldns_b64_pton(char const *src, uint8_t *target, size_t targsize)
|
||||
{
|
||||
int tarindex, state, ch;
|
||||
char *pos;
|
||||
|
||||
state = 0;
|
||||
tarindex = 0;
|
||||
|
||||
if (strlen(src) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ((ch = *src++) != '\0') {
|
||||
if (isspace((unsigned char)ch)) /* Skip whitespace anywhere. */
|
||||
continue;
|
||||
|
||||
if (ch == Pad64)
|
||||
break;
|
||||
|
||||
pos = strchr(Base64, ch);
|
||||
if (pos == 0) {
|
||||
/* A non-base64 character. */
|
||||
return (-1);
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (target) {
|
||||
if ((size_t)tarindex >= targsize)
|
||||
return (-1);
|
||||
target[tarindex] = (pos - Base64) << 2;
|
||||
}
|
||||
state = 1;
|
||||
break;
|
||||
case 1:
|
||||
if (target) {
|
||||
if ((size_t)tarindex + 1 >= targsize)
|
||||
return (-1);
|
||||
target[tarindex] |= (pos - Base64) >> 4;
|
||||
target[tarindex+1] = ((pos - Base64) & 0x0f)
|
||||
<< 4 ;
|
||||
}
|
||||
tarindex++;
|
||||
state = 2;
|
||||
break;
|
||||
case 2:
|
||||
if (target) {
|
||||
if ((size_t)tarindex + 1 >= targsize)
|
||||
return (-1);
|
||||
target[tarindex] |= (pos - Base64) >> 2;
|
||||
target[tarindex+1] = ((pos - Base64) & 0x03)
|
||||
<< 6;
|
||||
}
|
||||
tarindex++;
|
||||
state = 3;
|
||||
break;
|
||||
case 3:
|
||||
if (target) {
|
||||
if ((size_t)tarindex >= targsize)
|
||||
return (-1);
|
||||
target[tarindex] |= (pos - Base64);
|
||||
}
|
||||
tarindex++;
|
||||
state = 0;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We are done decoding Base-64 chars. Let's see if we ended
|
||||
* on a byte boundary, and/or with erroneous trailing characters.
|
||||
*/
|
||||
|
||||
if (ch == Pad64) { /* We got a pad char. */
|
||||
ch = *src++; /* Skip it, get next. */
|
||||
switch (state) {
|
||||
case 0: /* Invalid = in first position */
|
||||
case 1: /* Invalid = in second position */
|
||||
return (-1);
|
||||
|
||||
case 2: /* Valid, means one byte of info */
|
||||
/* Skip any number of spaces. */
|
||||
for ((void)NULL; ch != '\0'; ch = *src++)
|
||||
if (!isspace((unsigned char)ch))
|
||||
break;
|
||||
/* Make sure there is another trailing = sign. */
|
||||
if (ch != Pad64)
|
||||
return (-1);
|
||||
ch = *src++; /* Skip the = */
|
||||
/* Fall through to "single trailing =" case. */
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 3: /* Valid, means two bytes of info */
|
||||
/*
|
||||
* We know this char is an =. Is there anything but
|
||||
* whitespace after it?
|
||||
*/
|
||||
for ((void)NULL; ch != '\0'; ch = *src++)
|
||||
if (!isspace((unsigned char)ch))
|
||||
return (-1);
|
||||
|
||||
/*
|
||||
* Now make sure for cases 2 and 3 that the "extra"
|
||||
* bits that slopped past the last full byte were
|
||||
* zeros. If we don't check them, they become a
|
||||
* subliminal channel.
|
||||
*/
|
||||
if (target && target[tarindex] != 0)
|
||||
return (-1);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* We ended by seeing the end of the string. Make sure we
|
||||
* have no partial bytes lying around.
|
||||
*/
|
||||
if (state != 0)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (tarindex);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <ldns/config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
char *ctime_r(const time_t *timep, char *buf)
|
||||
{
|
||||
/* no thread safety. */
|
||||
char* result = ctime(timep);
|
||||
if(buf && result)
|
||||
strcpy(buf, result);
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
/* From openssh 4.3p2 filename openbsd-compat/fake-rfc2553.h */
|
||||
/*
|
||||
* Copyright (C) 2000-2003 Damien Miller. All rights reserved.
|
||||
* Copyright (C) 1999 WIDE Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the project 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 PROJECT 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 PROJECT 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pseudo-implementation of RFC2553 name / address resolution functions
|
||||
*
|
||||
* But these functions are not implemented correctly. The minimum subset
|
||||
* is implemented for ssh use only. For example, this routine assumes
|
||||
* that ai_family is AF_INET. Don't use it for another purpose.
|
||||
*/
|
||||
|
||||
#include <ldns/config.h>
|
||||
#include <ldns/common.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "compat/fake-rfc2553.h"
|
||||
|
||||
#ifndef HAVE_GETNAMEINFO
|
||||
int getnameinfo(const struct sockaddr *sa, size_t ATTR_UNUSED(salen), char *host,
|
||||
size_t hostlen, char *serv, size_t servlen, int flags)
|
||||
{
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
|
||||
struct hostent *hp;
|
||||
char tmpserv[16];
|
||||
|
||||
if (serv != NULL) {
|
||||
snprintf(tmpserv, sizeof(tmpserv), "%d", ntohs(sin->sin_port));
|
||||
if (strlcpy(serv, tmpserv, servlen) >= servlen)
|
||||
return (EAI_MEMORY);
|
||||
}
|
||||
|
||||
if (host != NULL) {
|
||||
if (flags & NI_NUMERICHOST) {
|
||||
if (strlcpy(host, inet_ntoa(sin->sin_addr),
|
||||
hostlen) >= hostlen)
|
||||
return (EAI_MEMORY);
|
||||
else
|
||||
return (0);
|
||||
} else {
|
||||
hp = gethostbyaddr((char *)&sin->sin_addr,
|
||||
sizeof(struct in_addr), AF_INET);
|
||||
if (hp == NULL)
|
||||
return (EAI_NODATA);
|
||||
|
||||
if (strlcpy(host, hp->h_name, hostlen) >= hostlen)
|
||||
return (EAI_MEMORY);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif /* !HAVE_GETNAMEINFO */
|
||||
|
||||
#ifndef HAVE_GAI_STRERROR
|
||||
#ifdef HAVE_CONST_GAI_STRERROR_PROTO
|
||||
const char *
|
||||
#else
|
||||
char *
|
||||
#endif
|
||||
gai_strerror(int err)
|
||||
{
|
||||
switch (err) {
|
||||
case EAI_NODATA:
|
||||
return ("no address associated with name");
|
||||
case EAI_MEMORY:
|
||||
return ("memory allocation failure.");
|
||||
case EAI_NONAME:
|
||||
return ("nodename nor servname provided, or not known");
|
||||
default:
|
||||
return ("unknown/invalid error.");
|
||||
}
|
||||
}
|
||||
#endif /* !HAVE_GAI_STRERROR */
|
||||
|
||||
#ifndef HAVE_FREEADDRINFO
|
||||
void
|
||||
freeaddrinfo(struct addrinfo *ai)
|
||||
{
|
||||
struct addrinfo *next;
|
||||
|
||||
for(; ai != NULL;) {
|
||||
next = ai->ai_next;
|
||||
free(ai);
|
||||
ai = next;
|
||||
}
|
||||
}
|
||||
#endif /* !HAVE_FREEADDRINFO */
|
||||
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
static struct
|
||||
addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints)
|
||||
{
|
||||
struct addrinfo *ai;
|
||||
|
||||
ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in));
|
||||
if (ai == NULL)
|
||||
return (NULL);
|
||||
|
||||
memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in));
|
||||
|
||||
ai->ai_addr = (struct sockaddr *)(ai + 1);
|
||||
/* XXX -- ssh doesn't use sa_len */
|
||||
ai->ai_addrlen = sizeof(struct sockaddr_in);
|
||||
ai->ai_addr->sa_family = ai->ai_family = AF_INET;
|
||||
|
||||
((struct sockaddr_in *)(ai)->ai_addr)->sin_port = port;
|
||||
((struct sockaddr_in *)(ai)->ai_addr)->sin_addr.s_addr = addr;
|
||||
|
||||
/* XXX: the following is not generally correct, but does what we want */
|
||||
if (hints->ai_socktype)
|
||||
ai->ai_socktype = hints->ai_socktype;
|
||||
else
|
||||
ai->ai_socktype = SOCK_STREAM;
|
||||
|
||||
if (hints->ai_protocol)
|
||||
ai->ai_protocol = hints->ai_protocol;
|
||||
|
||||
return (ai);
|
||||
}
|
||||
|
||||
int
|
||||
getaddrinfo(const char *hostname, const char *servname,
|
||||
const struct addrinfo *hints, struct addrinfo **res)
|
||||
{
|
||||
struct hostent *hp;
|
||||
struct servent *sp;
|
||||
struct in_addr in;
|
||||
int i;
|
||||
long int port;
|
||||
u_long addr;
|
||||
|
||||
port = 0;
|
||||
if (servname != NULL) {
|
||||
char *cp;
|
||||
|
||||
port = strtol(servname, &cp, 10);
|
||||
if (port > 0 && port <= 65535 && *cp == '\0')
|
||||
port = htons(port);
|
||||
else if ((sp = getservbyname(servname, NULL)) != NULL)
|
||||
port = sp->s_port;
|
||||
else
|
||||
port = 0;
|
||||
}
|
||||
|
||||
if (hints && hints->ai_flags & AI_PASSIVE) {
|
||||
addr = htonl(0x00000000);
|
||||
if (hostname && inet_aton(hostname, &in) != 0)
|
||||
addr = in.s_addr;
|
||||
*res = malloc_ai(port, addr, hints);
|
||||
if (*res == NULL)
|
||||
return (EAI_MEMORY);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (!hostname) {
|
||||
*res = malloc_ai(port, htonl(0x7f000001), hints);
|
||||
if (*res == NULL)
|
||||
return (EAI_MEMORY);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (inet_aton(hostname, &in)) {
|
||||
*res = malloc_ai(port, in.s_addr, hints);
|
||||
if (*res == NULL)
|
||||
return (EAI_MEMORY);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Don't try DNS if AI_NUMERICHOST is set */
|
||||
if (hints && hints->ai_flags & AI_NUMERICHOST)
|
||||
return (EAI_NONAME);
|
||||
|
||||
hp = gethostbyname(hostname);
|
||||
if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
|
||||
struct addrinfo *cur, *prev;
|
||||
|
||||
cur = prev = *res = NULL;
|
||||
for (i = 0; hp->h_addr_list[i]; i++) {
|
||||
struct in_addr *in = (struct in_addr *)hp->h_addr_list[i];
|
||||
|
||||
cur = malloc_ai(port, in->s_addr, hints);
|
||||
if (cur == NULL) {
|
||||
if (*res != NULL)
|
||||
freeaddrinfo(*res);
|
||||
return (EAI_MEMORY);
|
||||
}
|
||||
if (prev)
|
||||
prev->ai_next = cur;
|
||||
else
|
||||
*res = cur;
|
||||
|
||||
prev = cur;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (EAI_NODATA);
|
||||
}
|
||||
#endif /* !HAVE_GETADDRINFO */
|
||||
@@ -0,0 +1,187 @@
|
||||
/* From openssh 4.3p2 filename openbsd-compat/fake-rfc2553.h */
|
||||
/*
|
||||
* Copyright (C) 2000-2003 Damien Miller. All rights reserved.
|
||||
* Copyright (C) 1999 WIDE Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the project 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 PROJECT 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 PROJECT 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pseudo-implementation of RFC2553 name / address resolution functions
|
||||
*
|
||||
* But these functions are not implemented correctly. The minimum subset
|
||||
* is implemented for ssh use only. For example, this routine assumes
|
||||
* that ai_family is AF_INET. Don't use it for another purpose.
|
||||
*/
|
||||
|
||||
#ifndef _FAKE_RFC2553_H
|
||||
#define _FAKE_RFC2553_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* First, socket and INET6 related definitions
|
||||
*/
|
||||
#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
|
||||
#ifndef _SS_MAXSIZE
|
||||
# define _SS_MAXSIZE 128 /* Implementation specific max size */
|
||||
# define _SS_PADSIZE (_SS_MAXSIZE - sizeof (struct sockaddr))
|
||||
struct sockaddr_storage {
|
||||
struct sockaddr ss_sa;
|
||||
char __ss_pad2[_SS_PADSIZE];
|
||||
};
|
||||
# define ss_family ss_sa.sa_family
|
||||
#endif /* _SS_MAXSIZE */
|
||||
#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
|
||||
|
||||
#ifndef IN6_IS_ADDR_LOOPBACK
|
||||
# define IN6_IS_ADDR_LOOPBACK(a) \
|
||||
(((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \
|
||||
((uint32_t *)(a))[2] == 0 && ((uint32_t *)(a))[3] == htonl(1))
|
||||
#endif /* !IN6_IS_ADDR_LOOPBACK */
|
||||
|
||||
#ifndef HAVE_STRUCT_IN6_ADDR
|
||||
struct in6_addr {
|
||||
uint8_t s6_addr[16];
|
||||
};
|
||||
#endif /* !HAVE_STRUCT_IN6_ADDR */
|
||||
|
||||
#ifndef HAVE_STRUCT_SOCKADDR_IN6
|
||||
struct sockaddr_in6 {
|
||||
unsigned short sin6_family;
|
||||
uint16_t sin6_port;
|
||||
uint32_t sin6_flowinfo;
|
||||
struct in6_addr sin6_addr;
|
||||
};
|
||||
#endif /* !HAVE_STRUCT_SOCKADDR_IN6 */
|
||||
|
||||
#ifndef AF_INET6
|
||||
/* Define it to something that should never appear */
|
||||
#define AF_INET6 AF_MAX
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Next, RFC2553 name / address resolution API
|
||||
*/
|
||||
|
||||
#ifndef NI_NUMERICHOST
|
||||
# define NI_NUMERICHOST (1)
|
||||
#endif
|
||||
#ifndef NI_NAMEREQD
|
||||
# define NI_NAMEREQD (1<<1)
|
||||
#endif
|
||||
#ifndef NI_NUMERICSERV
|
||||
# define NI_NUMERICSERV (1<<2)
|
||||
#endif
|
||||
|
||||
#ifndef AI_PASSIVE
|
||||
# define AI_PASSIVE (1)
|
||||
#endif
|
||||
#ifndef AI_CANONNAME
|
||||
# define AI_CANONNAME (1<<1)
|
||||
#endif
|
||||
#ifndef AI_NUMERICHOST
|
||||
# define AI_NUMERICHOST (1<<2)
|
||||
#endif
|
||||
|
||||
#ifndef NI_MAXSERV
|
||||
# define NI_MAXSERV 32
|
||||
#endif /* !NI_MAXSERV */
|
||||
#ifndef NI_MAXHOST
|
||||
# define NI_MAXHOST 1025
|
||||
#endif /* !NI_MAXHOST */
|
||||
|
||||
#ifndef INT_MAX
|
||||
#define INT_MAX 0xffffffff
|
||||
#endif
|
||||
|
||||
#ifndef EAI_NODATA
|
||||
# define EAI_NODATA (INT_MAX - 1)
|
||||
#endif
|
||||
#ifndef EAI_MEMORY
|
||||
# define EAI_MEMORY (INT_MAX - 2)
|
||||
#endif
|
||||
#ifndef EAI_NONAME
|
||||
# define EAI_NONAME (INT_MAX - 3)
|
||||
#endif
|
||||
#ifndef EAI_SYSTEM
|
||||
# define EAI_SYSTEM (INT_MAX - 4)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRUCT_ADDRINFO
|
||||
struct addrinfo {
|
||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
|
||||
int ai_family; /* PF_xxx */
|
||||
int ai_socktype; /* SOCK_xxx */
|
||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
||||
size_t ai_addrlen; /* length of ai_addr */
|
||||
char *ai_canonname; /* canonical name for hostname */
|
||||
struct sockaddr *ai_addr; /* binary address */
|
||||
struct addrinfo *ai_next; /* next structure in linked list */
|
||||
};
|
||||
#endif /* !HAVE_STRUCT_ADDRINFO */
|
||||
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
#ifdef getaddrinfo
|
||||
# undef getaddrinfo
|
||||
#endif
|
||||
#define getaddrinfo(a,b,c,d) (ssh_getaddrinfo(a,b,c,d))
|
||||
int getaddrinfo(const char *, const char *,
|
||||
const struct addrinfo *, struct addrinfo **);
|
||||
#endif /* !HAVE_GETADDRINFO */
|
||||
|
||||
#if !defined(HAVE_GAI_STRERROR) && !defined(HAVE_CONST_GAI_STRERROR_PROTO)
|
||||
#define gai_strerror(a) (ssh_gai_strerror(a))
|
||||
char *gai_strerror(int);
|
||||
#endif /* !HAVE_GAI_STRERROR */
|
||||
|
||||
#ifndef HAVE_FREEADDRINFO
|
||||
#define freeaddrinfo(a) (ssh_freeaddrinfo(a))
|
||||
void freeaddrinfo(struct addrinfo *);
|
||||
#endif /* !HAVE_FREEADDRINFO */
|
||||
|
||||
#ifndef HAVE_GETNAMEINFO
|
||||
#define getnameinfo(a,b,c,d,e,f,g) (ssh_getnameinfo(a,b,c,d,e,f,g))
|
||||
int getnameinfo(const struct sockaddr *, size_t, char *, size_t,
|
||||
char *, size_t, int);
|
||||
#endif /* !HAVE_GETNAMEINFO */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_FAKE_RFC2553_H */
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#include <ldns/config.h>
|
||||
|
||||
#ifndef HAVE_GETTIMEOFDAY
|
||||
|
||||
#include < time.h >
|
||||
#include < windows.h>
|
||||
#include <compat/gettimeofday.h>
|
||||
|
||||
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
|
||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
|
||||
#else
|
||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
|
||||
#endif
|
||||
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
FILETIME ft;
|
||||
unsigned __int64 tmpres = 0;
|
||||
static int tzflag;
|
||||
|
||||
if (NULL != tv)
|
||||
{
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
|
||||
tmpres |= ft.dwHighDateTime;
|
||||
tmpres <<= 32;
|
||||
tmpres |= ft.dwLowDateTime;
|
||||
|
||||
/*converting file time to unix epoch*/
|
||||
tmpres /= 10; /*convert into microseconds*/
|
||||
tmpres -= DELTA_EPOCH_IN_MICROSECS;
|
||||
tv->tv_sec = (long)(tmpres / 1000000UL);
|
||||
tv->tv_usec = (long)(tmpres % 1000000UL);
|
||||
}
|
||||
|
||||
if (NULL != tz)
|
||||
{
|
||||
if (!tzflag)
|
||||
{
|
||||
_tzset();
|
||||
tzflag++;
|
||||
}
|
||||
tz->tz_minuteswest = _timezone / 60;
|
||||
tz->tz_dsttime = _daylight;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef HAVE_GETTIMEOFDAY
|
||||
|
||||
struct timezone
|
||||
{
|
||||
int tz_minuteswest; /* minutes W of Greenwich */
|
||||
int tz_dsttime; /* type of dst correction */
|
||||
};
|
||||
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <ldns/config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
struct tm *gmtime_r(const time_t *timep, struct tm *result)
|
||||
{
|
||||
/* no thread safety. */
|
||||
*result = *gmtime(timep);
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/* From openssh4.3p2 compat/inet_aton.c */
|
||||
/*
|
||||
* Copyright (c) 1983, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
* -
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
* -
|
||||
* --Copyright--
|
||||
*/
|
||||
|
||||
/* OPENBSD ORIGINAL: lib/libc/net/inet_addr.c */
|
||||
|
||||
#include <ldns/config.h>
|
||||
|
||||
#if !defined(HAVE_INET_ATON)
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <sys/param.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>
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Ascii internet address interpretation routine.
|
||||
* The value returned is in network order.
|
||||
*/
|
||||
in_addr_t
|
||||
inet_addr(const char *cp)
|
||||
{
|
||||
struct in_addr val;
|
||||
|
||||
if (inet_aton(cp, &val))
|
||||
return (val.s_addr);
|
||||
return (INADDR_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check whether "cp" is a valid ascii representation
|
||||
* of an Internet address and convert to a binary address.
|
||||
* Returns 1 if the address is valid, 0 if not.
|
||||
* This replaces inet_addr, the return value from which
|
||||
* cannot distinguish between failure and a local broadcast address.
|
||||
*/
|
||||
int
|
||||
inet_aton(const char *cp, struct in_addr *addr)
|
||||
{
|
||||
uint32_t val;
|
||||
int base, n;
|
||||
char c;
|
||||
unsigned int parts[4];
|
||||
unsigned int *pp = parts;
|
||||
|
||||
c = *cp;
|
||||
for (;;) {
|
||||
/*
|
||||
* Collect number up to ``.''.
|
||||
* Values are specified as for C:
|
||||
* 0x=hex, 0=octal, isdigit=decimal.
|
||||
*/
|
||||
if (!isdigit((int) c))
|
||||
return (0);
|
||||
val = 0; base = 10;
|
||||
if (c == '0') {
|
||||
c = *++cp;
|
||||
if (c == 'x' || c == 'X')
|
||||
base = 16, c = *++cp;
|
||||
else
|
||||
base = 8;
|
||||
}
|
||||
for (;;) {
|
||||
if (isascii((int) c) && isdigit((int) c)) {
|
||||
val = (val * base) + (c - '0');
|
||||
c = *++cp;
|
||||
} else if (base == 16 && isascii((int) c) && isxdigit((int) c)) {
|
||||
val = (val << 4) |
|
||||
(c + 10 - (islower((int) c) ? 'a' : 'A'));
|
||||
c = *++cp;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
if (c == '.') {
|
||||
/*
|
||||
* Internet format:
|
||||
* a.b.c.d
|
||||
* a.b.c (with c treated as 16 bits)
|
||||
* a.b (with b treated as 24 bits)
|
||||
*/
|
||||
if (pp >= parts + 3)
|
||||
return (0);
|
||||
*pp++ = val;
|
||||
c = *++cp;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Check for trailing characters.
|
||||
*/
|
||||
if (c != '\0' && (!isascii((int) c) || !isspace((int) c)))
|
||||
return (0);
|
||||
/*
|
||||
* Concoct the address according to
|
||||
* the number of parts specified.
|
||||
*/
|
||||
n = pp - parts + 1;
|
||||
switch (n) {
|
||||
|
||||
case 0:
|
||||
return (0); /* initial nondigit */
|
||||
|
||||
case 1: /* a -- 32 bits */
|
||||
break;
|
||||
|
||||
case 2: /* a.b -- 8.24 bits */
|
||||
if ((val > 0xffffff) || (parts[0] > 0xff))
|
||||
return (0);
|
||||
val |= parts[0] << 24;
|
||||
break;
|
||||
|
||||
case 3: /* a.b.c -- 8.8.16 bits */
|
||||
if ((val > 0xffff) || (parts[0] > 0xff) || (parts[1] > 0xff))
|
||||
return (0);
|
||||
val |= (parts[0] << 24) | (parts[1] << 16);
|
||||
break;
|
||||
|
||||
case 4: /* a.b.c.d -- 8.8.8.8 bits */
|
||||
if ((val > 0xff) || (parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff))
|
||||
return (0);
|
||||
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
|
||||
break;
|
||||
}
|
||||
if (addr)
|
||||
addr->s_addr = htonl(val);
|
||||
return (1);
|
||||
}
|
||||
|
||||
#endif /* !defined(HAVE_INET_ATON) */
|
||||
@@ -0,0 +1,218 @@
|
||||
/* From openssh 4.3p2 compat/inet_ntop.c */
|
||||
/* Copyright (c) 1996 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.
|
||||
*/
|
||||
|
||||
/* OPENBSD ORIGINAL: lib/libc/net/inet_ntop.c */
|
||||
|
||||
#include <ldns/config.h>
|
||||
|
||||
#ifndef HAVE_INET_NTOP
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef IN6ADDRSZ
|
||||
#define IN6ADDRSZ 16 /* IPv6 T_AAAA */
|
||||
#endif
|
||||
|
||||
#ifndef INT16SZ
|
||||
#define INT16SZ 2 /* for systems without 16-bit ints */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* WARNING: Don't even consider trying to compile this on a system where
|
||||
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
|
||||
*/
|
||||
|
||||
static const char *inet_ntop4(const u_char *src, char *dst, size_t size);
|
||||
static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
|
||||
|
||||
/* char *
|
||||
* inet_ntop(af, src, dst, size)
|
||||
* convert a network format address to presentation format.
|
||||
* return:
|
||||
* pointer to presentation format address (`dst'), or NULL (see errno).
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
const char *
|
||||
inet_ntop(int af, const void *src, char *dst, size_t size)
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return (inet_ntop4(src, dst, size));
|
||||
case AF_INET6:
|
||||
return (inet_ntop6(src, dst, size));
|
||||
default:
|
||||
#ifdef EAFNOSUPPORT
|
||||
errno = EAFNOSUPPORT;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
#endif
|
||||
return (NULL);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* const char *
|
||||
* inet_ntop4(src, dst, size)
|
||||
* format an IPv4 address, more or less like inet_ntoa()
|
||||
* return:
|
||||
* `dst' (as a const)
|
||||
* notes:
|
||||
* (1) uses no statics
|
||||
* (2) takes a u_char* not an in_addr as input
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
inet_ntop4(const u_char *src, char *dst, size_t size)
|
||||
{
|
||||
static const char fmt[] = "%u.%u.%u.%u";
|
||||
char tmp[sizeof "255.255.255.255"];
|
||||
int l;
|
||||
|
||||
l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]);
|
||||
if (l <= 0 || l >= (int)size) {
|
||||
errno = ENOSPC;
|
||||
return (NULL);
|
||||
}
|
||||
strlcpy(dst, tmp, size);
|
||||
return (dst);
|
||||
}
|
||||
|
||||
/* const char *
|
||||
* inet_ntop6(src, dst, size)
|
||||
* convert IPv6 binary address into presentation (printable) format
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
inet_ntop6(const u_char *src, char *dst, size_t size)
|
||||
{
|
||||
/*
|
||||
* Note that int32_t and int16_t need only be "at least" large enough
|
||||
* to contain a value of the specified size. On some systems, like
|
||||
* Crays, there is no such thing as an integer variable with 16 bits.
|
||||
* Keep this in mind if you think this function should have been coded
|
||||
* to use pointer overlays. All the world's not a VAX.
|
||||
*/
|
||||
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
|
||||
char *tp, *ep;
|
||||
struct { int base, len; } best, cur;
|
||||
u_int words[IN6ADDRSZ / INT16SZ];
|
||||
int i;
|
||||
int advance;
|
||||
|
||||
/*
|
||||
* Preprocess:
|
||||
* Copy the input (bytewise) array into a wordwise array.
|
||||
* Find the longest run of 0x00's in src[] for :: shorthanding.
|
||||
*/
|
||||
memset(words, '\0', sizeof words);
|
||||
for (i = 0; i < IN6ADDRSZ; i++)
|
||||
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
|
||||
best.base = -1;
|
||||
cur.base = -1;
|
||||
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
|
||||
if (words[i] == 0) {
|
||||
if (cur.base == -1)
|
||||
cur.base = i, cur.len = 1;
|
||||
else
|
||||
cur.len++;
|
||||
} else {
|
||||
if (cur.base != -1) {
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
cur.base = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cur.base != -1) {
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
}
|
||||
if (best.base != -1 && best.len < 2)
|
||||
best.base = -1;
|
||||
|
||||
/*
|
||||
* Format the result.
|
||||
*/
|
||||
tp = tmp;
|
||||
ep = tmp + sizeof(tmp);
|
||||
for (i = 0; i < (IN6ADDRSZ / INT16SZ) && tp < ep; i++) {
|
||||
/* Are we inside the best run of 0x00's? */
|
||||
if (best.base != -1 && i >= best.base &&
|
||||
i < (best.base + best.len)) {
|
||||
if (i == best.base) {
|
||||
if (tp + 1 >= ep)
|
||||
return (NULL);
|
||||
*tp++ = ':';
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/* Are we following an initial run of 0x00s or any real hex? */
|
||||
if (i != 0) {
|
||||
if (tp + 1 >= ep)
|
||||
return (NULL);
|
||||
*tp++ = ':';
|
||||
}
|
||||
/* Is this address an encapsulated IPv4? */
|
||||
if (i == 6 && best.base == 0 &&
|
||||
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
|
||||
if (!inet_ntop4(src+12, tp, (size_t)(ep - tp)))
|
||||
return (NULL);
|
||||
tp += strlen(tp);
|
||||
break;
|
||||
}
|
||||
advance = snprintf(tp, ep - tp, "%x", words[i]);
|
||||
if (advance <= 0 || advance >= ep - tp)
|
||||
return (NULL);
|
||||
tp += advance;
|
||||
}
|
||||
/* Was it a trailing run of 0x00's? */
|
||||
if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) {
|
||||
if (tp + 1 >= ep)
|
||||
return (NULL);
|
||||
*tp++ = ':';
|
||||
}
|
||||
if (tp + 1 >= ep)
|
||||
return (NULL);
|
||||
*tp++ = '\0';
|
||||
|
||||
/*
|
||||
* Check for overflow, copy, and we're done.
|
||||
*/
|
||||
if ((size_t)(tp - tmp) > size) {
|
||||
errno = ENOSPC;
|
||||
return (NULL);
|
||||
}
|
||||
strlcpy(dst, tmp, size);
|
||||
return (dst);
|
||||
}
|
||||
|
||||
#endif /* !HAVE_INET_NTOP */
|
||||
@@ -0,0 +1,230 @@
|
||||
/* $KAME: inet_pton.c,v 1.5 2001/08/20 02:32:40 itojun Exp $ */
|
||||
|
||||
/* Copyright (c) 1996 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.
|
||||
*/
|
||||
|
||||
#include <ldns/config.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
/*
|
||||
* WARNING: Don't even consider trying to compile this on a system where
|
||||
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
|
||||
*/
|
||||
|
||||
static int inet_pton4 (const char *src, uint8_t *dst);
|
||||
static int inet_pton6 (const char *src, uint8_t *dst);
|
||||
|
||||
/*
|
||||
*
|
||||
* The definitions we might miss.
|
||||
*
|
||||
*/
|
||||
#ifndef NS_INT16SZ
|
||||
#define NS_INT16SZ 2
|
||||
#endif
|
||||
|
||||
#ifndef NS_IN6ADDRSZ
|
||||
#define NS_IN6ADDRSZ 16
|
||||
#endif
|
||||
|
||||
#ifndef NS_INADDRSZ
|
||||
#define NS_INADDRSZ 4
|
||||
#endif
|
||||
|
||||
/* int
|
||||
* inet_pton(af, src, dst)
|
||||
* convert from presentation format (which usually means ASCII printable)
|
||||
* to network format (which is usually some kind of binary format).
|
||||
* return:
|
||||
* 1 if the address was valid for the specified address family
|
||||
* 0 if the address wasn't valid (`dst' is untouched in this case)
|
||||
* -1 if some other error occurred (`dst' is untouched in this case, too)
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
int
|
||||
inet_pton(af, src, dst)
|
||||
int af;
|
||||
const char *src;
|
||||
void *dst;
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return (inet_pton4(src, dst));
|
||||
case AF_INET6:
|
||||
return (inet_pton6(src, dst));
|
||||
default:
|
||||
#ifdef EAFNOSUPPORT
|
||||
errno = EAFNOSUPPORT;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
#endif
|
||||
return (-1);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* int
|
||||
* inet_pton4(src, dst)
|
||||
* like inet_aton() but without all the hexadecimal and shorthand.
|
||||
* return:
|
||||
* 1 if `src' is a valid dotted quad, else 0.
|
||||
* notice:
|
||||
* does not touch `dst' unless it's returning 1.
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static int
|
||||
inet_pton4(src, dst)
|
||||
const char *src;
|
||||
uint8_t *dst;
|
||||
{
|
||||
static const char digits[] = "0123456789";
|
||||
int saw_digit, octets, ch;
|
||||
uint8_t tmp[NS_INADDRSZ], *tp;
|
||||
|
||||
saw_digit = 0;
|
||||
octets = 0;
|
||||
*(tp = tmp) = 0;
|
||||
while ((ch = *src++) != '\0') {
|
||||
const char *pch;
|
||||
|
||||
if ((pch = strchr(digits, ch)) != NULL) {
|
||||
uint32_t new = *tp * 10 + (pch - digits);
|
||||
|
||||
if (new > 255)
|
||||
return (0);
|
||||
*tp = new;
|
||||
if (! saw_digit) {
|
||||
if (++octets > 4)
|
||||
return (0);
|
||||
saw_digit = 1;
|
||||
}
|
||||
} else if (ch == '.' && saw_digit) {
|
||||
if (octets == 4)
|
||||
return (0);
|
||||
*++tp = 0;
|
||||
saw_digit = 0;
|
||||
} else
|
||||
return (0);
|
||||
}
|
||||
if (octets < 4)
|
||||
return (0);
|
||||
|
||||
memcpy(dst, tmp, NS_INADDRSZ);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* int
|
||||
* inet_pton6(src, dst)
|
||||
* convert presentation level address to network order binary form.
|
||||
* return:
|
||||
* 1 if `src' is a valid [RFC1884 2.2] address, else 0.
|
||||
* notice:
|
||||
* (1) does not touch `dst' unless it's returning 1.
|
||||
* (2) :: in a full address is silently ignored.
|
||||
* credit:
|
||||
* inspired by Mark Andrews.
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static int
|
||||
inet_pton6(src, dst)
|
||||
const char *src;
|
||||
uint8_t *dst;
|
||||
{
|
||||
static const char xdigits_l[] = "0123456789abcdef",
|
||||
xdigits_u[] = "0123456789ABCDEF";
|
||||
uint8_t tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
|
||||
const char *xdigits, *curtok;
|
||||
int ch, saw_xdigit;
|
||||
uint32_t val;
|
||||
|
||||
memset((tp = tmp), '\0', NS_IN6ADDRSZ);
|
||||
endp = tp + NS_IN6ADDRSZ;
|
||||
colonp = NULL;
|
||||
/* Leading :: requires some special handling. */
|
||||
if (*src == ':')
|
||||
if (*++src != ':')
|
||||
return (0);
|
||||
curtok = src;
|
||||
saw_xdigit = 0;
|
||||
val = 0;
|
||||
while ((ch = *src++) != '\0') {
|
||||
const char *pch;
|
||||
|
||||
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
|
||||
pch = strchr((xdigits = xdigits_u), ch);
|
||||
if (pch != NULL) {
|
||||
val <<= 4;
|
||||
val |= (pch - xdigits);
|
||||
if (val > 0xffff)
|
||||
return (0);
|
||||
saw_xdigit = 1;
|
||||
continue;
|
||||
}
|
||||
if (ch == ':') {
|
||||
curtok = src;
|
||||
if (!saw_xdigit) {
|
||||
if (colonp)
|
||||
return (0);
|
||||
colonp = tp;
|
||||
continue;
|
||||
}
|
||||
if (tp + NS_INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (uint8_t) (val >> 8) & 0xff;
|
||||
*tp++ = (uint8_t) val & 0xff;
|
||||
saw_xdigit = 0;
|
||||
val = 0;
|
||||
continue;
|
||||
}
|
||||
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
|
||||
inet_pton4(curtok, tp) > 0) {
|
||||
tp += NS_INADDRSZ;
|
||||
saw_xdigit = 0;
|
||||
break; /* '\0' was seen by inet_pton4(). */
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
if (saw_xdigit) {
|
||||
if (tp + NS_INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (uint8_t) (val >> 8) & 0xff;
|
||||
*tp++ = (uint8_t) val & 0xff;
|
||||
}
|
||||
if (colonp != NULL) {
|
||||
/*
|
||||
* Since some memmove()'s erroneously fail to handle
|
||||
* overlapping regions, we'll do the shift by hand.
|
||||
*/
|
||||
const int n = tp - colonp;
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= n; i++) {
|
||||
endp[- i] = colonp[n - i];
|
||||
colonp[n - i] = 0;
|
||||
}
|
||||
tp = endp;
|
||||
}
|
||||
if (tp != endp)
|
||||
return (0);
|
||||
memcpy(dst, tmp, NS_IN6ADDRSZ);
|
||||
return (1);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/* Just a replacement, if the original isascii is not
|
||||
present */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include <ldns/config.h>
|
||||
#endif
|
||||
|
||||
int isascii(int c);
|
||||
|
||||
/* true if character is ascii. */
|
||||
int
|
||||
isascii(int c)
|
||||
{
|
||||
return c >= 0 && c < 128;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/* Just a replacement, if the original isblank is not
|
||||
present */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include <ldns/config.h>
|
||||
#endif
|
||||
|
||||
int isblank(int c);
|
||||
|
||||
/* true if character is a blank (space or tab). C99. */
|
||||
int
|
||||
isblank(int c)
|
||||
{
|
||||
return (c == ' ') || (c == '\t');
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/* Just a replacement, if the original malloc is not
|
||||
GNU-compliant. See autoconf documentation. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include <ldns/config.h>
|
||||
#endif
|
||||
#undef malloc
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
void *malloc ();
|
||||
#endif
|
||||
|
||||
/* Allocate an N-byte block of memory from the heap.
|
||||
If N is zero, allocate a 1-byte block. */
|
||||
|
||||
void *
|
||||
rpl_malloc (size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
return malloc (n);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* memmove.c: memmove compat implementation.
|
||||
*
|
||||
* Copyright (c) 2001-2008, NLnet Labs. All rights reserved.
|
||||
*
|
||||
* See LICENSE for the license.
|
||||
*/
|
||||
|
||||
#include <ldns/config.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
void *memmove(void *dest, const void *src, size_t n);
|
||||
|
||||
void *memmove(void *dest, const void *src, size_t n)
|
||||
{
|
||||
uint8_t* from = (uint8_t*) src;
|
||||
uint8_t* to = (uint8_t*) dest;
|
||||
|
||||
if (from == to || n == 0)
|
||||
return dest;
|
||||
if (to > from && to-from < (int)n) {
|
||||
/* to overlaps with from */
|
||||
/* <from......> */
|
||||
/* <to........> */
|
||||
/* copy in reverse, to avoid overwriting from */
|
||||
int i;
|
||||
for(i=n-1; i>=0; i--)
|
||||
to[i] = from[i];
|
||||
return dest;
|
||||
}
|
||||
if (from > to && from-to < (int)n) {
|
||||
/* to overlaps with from */
|
||||
/* <from......> */
|
||||
/* <to........> */
|
||||
/* copy forwards, to avoid overwriting from */
|
||||
size_t i;
|
||||
for(i=0; i<n; i++)
|
||||
to[i] = from[i];
|
||||
return dest;
|
||||
}
|
||||
memcpy(dest, src, n);
|
||||
return dest;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
/* Just a replacement, if the original malloc is not
|
||||
GNU-compliant. Based on malloc.c */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include <ldns/config.h>
|
||||
#endif
|
||||
#undef realloc
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
void *realloc (void*, size_t);
|
||||
void *malloc (size_t);
|
||||
#endif
|
||||
|
||||
/* Changes allocation to new sizes, copies over old data.
|
||||
* if oldptr is NULL, does a malloc.
|
||||
* if size is zero, allocate 1-byte block....
|
||||
* (does not return NULL and free block)
|
||||
*/
|
||||
|
||||
void *
|
||||
rpl_realloc (void* ptr, size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
n = 1;
|
||||
if(ptr == 0) {
|
||||
return malloc(n);
|
||||
}
|
||||
return realloc(ptr, n);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,770 @@
|
||||
#include <ldns/config.h>
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Define this as a fall through, HAVE_STDARG_H is probably already set */
|
||||
|
||||
#define HAVE_VARARGS_H
|
||||
|
||||
/**************************************************************
|
||||
* Original:
|
||||
* Patrick Powell Tue Apr 11 09:48:21 PDT 1995
|
||||
* A bombproof version of doprnt (dopr) included.
|
||||
* Sigh. This sort of thing is always nasty do deal with. Note that
|
||||
* the version here does not include floating point...
|
||||
*
|
||||
* snprintf() is used instead of sprintf() as it does limit checks
|
||||
* for string length. This covers a nasty loophole.
|
||||
*
|
||||
* The other functions are there to prevent NULL pointers from
|
||||
* causing nast effects.
|
||||
*
|
||||
* More Recently:
|
||||
* Brandon Long (blong@fiction.net) 9/15/96 for mutt 0.43
|
||||
* This was ugly. It is still ugly. I opted out of floating point
|
||||
* numbers, but the formatter understands just about everything
|
||||
* from the normal C string format, at least as far as I can tell from
|
||||
* the Solaris 2.5 printf(3S) man page.
|
||||
*
|
||||
* Brandon Long (blong@fiction.net) 10/22/97 for mutt 0.87.1
|
||||
* Ok, added some minimal floating point support, which means this
|
||||
* probably requires libm on most operating systems. Don't yet
|
||||
* support the exponent (e,E) and sigfig (g,G). Also, fmtint()
|
||||
* was pretty badly broken, it just wasn't being exercised in ways
|
||||
* which showed it, so that's been fixed. Also, formated the code
|
||||
* to mutt conventions, and removed dead code left over from the
|
||||
* original. Also, there is now a builtin-test, just compile with:
|
||||
* gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
|
||||
* and run snprintf for results.
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
|
||||
/* varargs declarations: */
|
||||
|
||||
#if defined(HAVE_STDARG_H)
|
||||
# include <stdarg.h>
|
||||
# define HAVE_STDARGS /* let's hope that works everywhere (mj) */
|
||||
# define VA_LOCAL_DECL va_list ap
|
||||
# define VA_START(f) va_start(ap, f)
|
||||
# define VA_SHIFT(v,t) ; /* no-op for ANSI */
|
||||
# define VA_END va_end(ap)
|
||||
#else
|
||||
# if defined(HAVE_VARARGS_H)
|
||||
# include <varargs.h>
|
||||
# undef HAVE_STDARGS
|
||||
# define VA_LOCAL_DECL va_list ap
|
||||
# define VA_START(f) va_start(ap) /* f is ignored! */
|
||||
# define VA_SHIFT(v,t) v = va_arg(ap,t)
|
||||
# define VA_END va_end(ap)
|
||||
# else
|
||||
/*XX ** NO VARARGS ** XX*/
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int snprintf (char *str, size_t count, const char *fmt, ...);
|
||||
int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
|
||||
|
||||
static void dopr (char *buffer, size_t maxlen, const char *format,
|
||||
va_list args);
|
||||
static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
||||
char *value, int flags, int min, int max);
|
||||
static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
||||
long value, int base, int min, int max, int flags);
|
||||
static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
||||
long double fvalue, int min, int max, int flags);
|
||||
static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
|
||||
|
||||
int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
|
||||
{
|
||||
str[0] = 0;
|
||||
dopr(str, count, fmt, args);
|
||||
return(strlen(str));
|
||||
}
|
||||
|
||||
/* VARARGS3 */
|
||||
#ifdef HAVE_STDARGS
|
||||
int snprintf (char *str,size_t count,const char *fmt,...)
|
||||
#else
|
||||
int snprintf (va_alist) va_dcl
|
||||
#endif
|
||||
{
|
||||
#ifndef HAVE_STDARGS
|
||||
char *str;
|
||||
size_t count;
|
||||
char *fmt;
|
||||
#endif
|
||||
VA_LOCAL_DECL;
|
||||
|
||||
VA_START (fmt);
|
||||
VA_SHIFT (str, char *);
|
||||
VA_SHIFT (count, size_t );
|
||||
VA_SHIFT (fmt, char *);
|
||||
(void) vsnprintf(str, count, fmt, ap);
|
||||
VA_END;
|
||||
return(strlen(str));
|
||||
}
|
||||
|
||||
/*
|
||||
* dopr(): poor man's version of doprintf
|
||||
*/
|
||||
|
||||
/* format read states */
|
||||
#define DP_S_DEFAULT 0
|
||||
#define DP_S_FLAGS 1
|
||||
#define DP_S_MIN 2
|
||||
#define DP_S_DOT 3
|
||||
#define DP_S_MAX 4
|
||||
#define DP_S_MOD 5
|
||||
#define DP_S_CONV 6
|
||||
#define DP_S_DONE 7
|
||||
|
||||
/* format flags - Bits */
|
||||
#define DP_F_MINUS 1
|
||||
#define DP_F_PLUS 2
|
||||
#define DP_F_SPACE 4
|
||||
#define DP_F_NUM 8
|
||||
#define DP_F_ZERO 16
|
||||
#define DP_F_UP 32
|
||||
|
||||
/* Conversion Flags */
|
||||
#define DP_C_SHORT 1
|
||||
#define DP_C_LONG 2
|
||||
#define DP_C_LDOUBLE 3
|
||||
|
||||
#define char_to_int(p) (p - '0')
|
||||
#define MAX(p,q) ((p >= q) ? p : q)
|
||||
|
||||
static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
|
||||
{
|
||||
char ch;
|
||||
long value;
|
||||
long double fvalue;
|
||||
char *strvalue;
|
||||
int min;
|
||||
int max;
|
||||
int state;
|
||||
int flags;
|
||||
int cflags;
|
||||
size_t currlen;
|
||||
|
||||
state = DP_S_DEFAULT;
|
||||
currlen = flags = cflags = min = 0;
|
||||
max = -1;
|
||||
ch = *format++;
|
||||
|
||||
while (state != DP_S_DONE)
|
||||
{
|
||||
if ((ch == '\0') || (currlen >= maxlen))
|
||||
state = DP_S_DONE;
|
||||
|
||||
switch(state)
|
||||
{
|
||||
case DP_S_DEFAULT:
|
||||
if (ch == '%')
|
||||
state = DP_S_FLAGS;
|
||||
else
|
||||
dopr_outch (buffer, &currlen, maxlen, ch);
|
||||
ch = *format++;
|
||||
break;
|
||||
case DP_S_FLAGS:
|
||||
switch (ch)
|
||||
{
|
||||
case '-':
|
||||
flags |= DP_F_MINUS;
|
||||
ch = *format++;
|
||||
break;
|
||||
case '+':
|
||||
flags |= DP_F_PLUS;
|
||||
ch = *format++;
|
||||
break;
|
||||
case ' ':
|
||||
flags |= DP_F_SPACE;
|
||||
ch = *format++;
|
||||
break;
|
||||
case '#':
|
||||
flags |= DP_F_NUM;
|
||||
ch = *format++;
|
||||
break;
|
||||
case '0':
|
||||
flags |= DP_F_ZERO;
|
||||
ch = *format++;
|
||||
break;
|
||||
default:
|
||||
state = DP_S_MIN;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DP_S_MIN:
|
||||
if (isdigit((int) ch))
|
||||
{
|
||||
min = 10*min + char_to_int (ch);
|
||||
ch = *format++;
|
||||
}
|
||||
else if (ch == '*')
|
||||
{
|
||||
min = va_arg (args, int);
|
||||
ch = *format++;
|
||||
state = DP_S_DOT;
|
||||
}
|
||||
else
|
||||
state = DP_S_DOT;
|
||||
break;
|
||||
case DP_S_DOT:
|
||||
if (ch == '.')
|
||||
{
|
||||
state = DP_S_MAX;
|
||||
ch = *format++;
|
||||
}
|
||||
else
|
||||
state = DP_S_MOD;
|
||||
break;
|
||||
case DP_S_MAX:
|
||||
if (isdigit((int) ch))
|
||||
{
|
||||
if (max < 0)
|
||||
max = 0;
|
||||
max = 10*max + char_to_int (ch);
|
||||
ch = *format++;
|
||||
}
|
||||
else if (ch == '*')
|
||||
{
|
||||
max = va_arg (args, int);
|
||||
ch = *format++;
|
||||
state = DP_S_MOD;
|
||||
}
|
||||
else
|
||||
state = DP_S_MOD;
|
||||
break;
|
||||
case DP_S_MOD:
|
||||
/* Currently, we don't support Long Long, bummer */
|
||||
switch (ch)
|
||||
{
|
||||
case 'h':
|
||||
cflags = DP_C_SHORT;
|
||||
ch = *format++;
|
||||
break;
|
||||
case 'l':
|
||||
cflags = DP_C_LONG;
|
||||
ch = *format++;
|
||||
break;
|
||||
case 'L':
|
||||
cflags = DP_C_LDOUBLE;
|
||||
ch = *format++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
state = DP_S_CONV;
|
||||
break;
|
||||
case DP_S_CONV:
|
||||
switch (ch)
|
||||
{
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (cflags == DP_C_SHORT)
|
||||
value = va_arg (args, int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, long int);
|
||||
else
|
||||
value = va_arg (args, int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
|
||||
break;
|
||||
case 'o':
|
||||
flags &= ~DP_F_PLUS;
|
||||
if (cflags == DP_C_SHORT)
|
||||
value = va_arg (args, unsigned int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, unsigned long int);
|
||||
else
|
||||
value = va_arg (args, unsigned int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
|
||||
break;
|
||||
case 'u':
|
||||
flags &= ~DP_F_PLUS;
|
||||
if (cflags == DP_C_SHORT)
|
||||
value = va_arg (args, unsigned int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, unsigned long int);
|
||||
else
|
||||
value = va_arg (args, unsigned int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
|
||||
break;
|
||||
case 'X':
|
||||
flags |= DP_F_UP;
|
||||
case 'x':
|
||||
flags &= ~DP_F_PLUS;
|
||||
if (cflags == DP_C_SHORT)
|
||||
value = va_arg (args, unsigned int);
|
||||
else if (cflags == DP_C_LONG)
|
||||
value = va_arg (args, unsigned long int);
|
||||
else
|
||||
value = va_arg (args, unsigned int);
|
||||
fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
|
||||
break;
|
||||
case 'f':
|
||||
if (cflags == DP_C_LDOUBLE)
|
||||
fvalue = va_arg (args, long double);
|
||||
else
|
||||
fvalue = va_arg (args, double);
|
||||
/* um, floating point? */
|
||||
fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
|
||||
break;
|
||||
case 'E':
|
||||
flags |= DP_F_UP;
|
||||
case 'e':
|
||||
if (cflags == DP_C_LDOUBLE)
|
||||
fvalue = va_arg (args, long double);
|
||||
else
|
||||
fvalue = va_arg (args, double);
|
||||
break;
|
||||
case 'G':
|
||||
flags |= DP_F_UP;
|
||||
case 'g':
|
||||
if (cflags == DP_C_LDOUBLE)
|
||||
fvalue = va_arg (args, long double);
|
||||
else
|
||||
fvalue = va_arg (args, double);
|
||||
break;
|
||||
case 'c':
|
||||
dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
|
||||
break;
|
||||
case 's':
|
||||
strvalue = va_arg (args, char *);
|
||||
if (max < 0)
|
||||
max = maxlen; /* ie, no max */
|
||||
fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
|
||||
break;
|
||||
case 'p':
|
||||
strvalue = va_arg (args, void *);
|
||||
fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
|
||||
break;
|
||||
case 'n':
|
||||
if (cflags == DP_C_SHORT)
|
||||
{
|
||||
short int *num;
|
||||
num = va_arg (args, short int *);
|
||||
*num = currlen;
|
||||
}
|
||||
else if (cflags == DP_C_LONG)
|
||||
{
|
||||
long int *num;
|
||||
num = va_arg (args, long int *);
|
||||
*num = currlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
int *num;
|
||||
num = va_arg (args, int *);
|
||||
*num = currlen;
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
dopr_outch (buffer, &currlen, maxlen, ch);
|
||||
break;
|
||||
case 'w':
|
||||
/* not supported yet, treat as next char */
|
||||
ch = *format++;
|
||||
break;
|
||||
default:
|
||||
/* Unknown, skip */
|
||||
break;
|
||||
}
|
||||
ch = *format++;
|
||||
state = DP_S_DEFAULT;
|
||||
flags = cflags = min = 0;
|
||||
max = -1;
|
||||
break;
|
||||
case DP_S_DONE:
|
||||
break;
|
||||
default:
|
||||
/* hmm? */
|
||||
break; /* some picky compilers need this */
|
||||
}
|
||||
}
|
||||
if (currlen < maxlen - 1)
|
||||
buffer[currlen] = '\0';
|
||||
else
|
||||
buffer[maxlen - 1] = '\0';
|
||||
}
|
||||
|
||||
static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
|
||||
char *value, int flags, int min, int max)
|
||||
{
|
||||
int padlen, strln; /* amount to pad */
|
||||
int cnt = 0;
|
||||
|
||||
if (value == 0)
|
||||
{
|
||||
value = (char *) "<NULL>";
|
||||
}
|
||||
|
||||
for (strln = 0; value[strln]; ++strln); /* strlen */
|
||||
padlen = min - strln;
|
||||
if (padlen < 0)
|
||||
padlen = 0;
|
||||
if (flags & DP_F_MINUS)
|
||||
padlen = -padlen; /* Left Justify */
|
||||
|
||||
while ((padlen > 0) && (cnt < max))
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
--padlen;
|
||||
++cnt;
|
||||
}
|
||||
while (*value && (cnt < max))
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, *value++);
|
||||
++cnt;
|
||||
}
|
||||
while ((padlen < 0) && (cnt < max))
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
++padlen;
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
|
||||
/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
|
||||
|
||||
static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
|
||||
long value, int base, int min, int max, int flags)
|
||||
{
|
||||
int signvalue = 0;
|
||||
unsigned long uvalue;
|
||||
char convert[20];
|
||||
int place = 0;
|
||||
int spadlen = 0; /* amount to space pad */
|
||||
int zpadlen = 0; /* amount to zero pad */
|
||||
int caps = 0;
|
||||
|
||||
if (max < 0)
|
||||
max = 0;
|
||||
|
||||
uvalue = value;
|
||||
if( value < 0 ) {
|
||||
signvalue = '-';
|
||||
uvalue = -value;
|
||||
}
|
||||
else
|
||||
if (flags & DP_F_PLUS) /* Do a sign (+/i) */
|
||||
signvalue = '+';
|
||||
else
|
||||
if (flags & DP_F_SPACE)
|
||||
signvalue = ' ';
|
||||
|
||||
if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
|
||||
|
||||
do {
|
||||
convert[place++] =
|
||||
(caps? "0123456789ABCDEF":"0123456789abcdef")
|
||||
[uvalue % (unsigned)base ];
|
||||
uvalue = (uvalue / (unsigned)base );
|
||||
} while(uvalue && (place < 20));
|
||||
if (place == 20) place--;
|
||||
convert[place] = 0;
|
||||
|
||||
zpadlen = max - place;
|
||||
spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
|
||||
if (zpadlen < 0) zpadlen = 0;
|
||||
if (spadlen < 0) spadlen = 0;
|
||||
if (flags & DP_F_ZERO)
|
||||
{
|
||||
zpadlen = MAX(zpadlen, spadlen);
|
||||
spadlen = 0;
|
||||
}
|
||||
if (flags & DP_F_MINUS)
|
||||
spadlen = -spadlen; /* Left Justifty */
|
||||
|
||||
#ifdef DEBUG_SNPRINTF
|
||||
dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
|
||||
zpadlen, spadlen, min, max, place));
|
||||
#endif
|
||||
|
||||
/* Spaces */
|
||||
while (spadlen > 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
--spadlen;
|
||||
}
|
||||
|
||||
/* Sign */
|
||||
if (signvalue)
|
||||
dopr_outch (buffer, currlen, maxlen, signvalue);
|
||||
|
||||
/* Zeros */
|
||||
if (zpadlen > 0)
|
||||
{
|
||||
while (zpadlen > 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, '0');
|
||||
--zpadlen;
|
||||
}
|
||||
}
|
||||
|
||||
/* Digits */
|
||||
while (place > 0)
|
||||
dopr_outch (buffer, currlen, maxlen, convert[--place]);
|
||||
|
||||
/* Left Justified spaces */
|
||||
while (spadlen < 0) {
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
++spadlen;
|
||||
}
|
||||
}
|
||||
|
||||
static long double abs_val (long double value)
|
||||
{
|
||||
long double result = value;
|
||||
|
||||
if (value < 0)
|
||||
result = -value;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static double pow10 (double exp)
|
||||
{
|
||||
long double result = 1;
|
||||
|
||||
while (exp)
|
||||
{
|
||||
result *= 10;
|
||||
exp--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static double round (double value)
|
||||
{
|
||||
long intpart;
|
||||
|
||||
intpart = value;
|
||||
value = value - intpart;
|
||||
if (value >= 0.5)
|
||||
intpart++;
|
||||
|
||||
return intpart;
|
||||
}
|
||||
|
||||
static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
|
||||
long double fvalue, int min, int max, int flags)
|
||||
{
|
||||
int signvalue = 0;
|
||||
long double ufvalue;
|
||||
char iconvert[20];
|
||||
char fconvert[20];
|
||||
int iplace = 0;
|
||||
int fplace = 0;
|
||||
int padlen = 0; /* amount to pad */
|
||||
int zpadlen = 0;
|
||||
int caps = 0;
|
||||
long intpart;
|
||||
long fracpart;
|
||||
|
||||
/*
|
||||
* AIX manpage says the default is 0, but Solaris says the default
|
||||
* is 6, and sprintf on AIX defaults to 6
|
||||
*/
|
||||
if (max < 0)
|
||||
max = 6;
|
||||
|
||||
ufvalue = abs_val (fvalue);
|
||||
|
||||
if (fvalue < 0)
|
||||
signvalue = '-';
|
||||
else
|
||||
if (flags & DP_F_PLUS) /* Do a sign (+/i) */
|
||||
signvalue = '+';
|
||||
else
|
||||
if (flags & DP_F_SPACE)
|
||||
signvalue = ' ';
|
||||
|
||||
#if 0
|
||||
if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
|
||||
#endif
|
||||
|
||||
intpart = ufvalue;
|
||||
|
||||
/*
|
||||
* Sorry, we only support 9 digits past the decimal because of our
|
||||
* conversion method
|
||||
*/
|
||||
if (max > 9)
|
||||
max = 9;
|
||||
|
||||
/* We "cheat" by converting the fractional part to integer by
|
||||
* multiplying by a factor of 10
|
||||
*/
|
||||
fracpart = round ((pow10 (max)) * (ufvalue - intpart));
|
||||
|
||||
if (fracpart >= pow10 (max))
|
||||
{
|
||||
intpart++;
|
||||
fracpart -= pow10 (max);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SNPRINTF
|
||||
dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
|
||||
#endif
|
||||
|
||||
/* Convert integer part */
|
||||
do {
|
||||
iconvert[iplace++] =
|
||||
(caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10];
|
||||
intpart = (intpart / 10);
|
||||
} while(intpart && (iplace < 20));
|
||||
if (iplace == 20) iplace--;
|
||||
iconvert[iplace] = 0;
|
||||
|
||||
/* Convert fractional part */
|
||||
do {
|
||||
fconvert[fplace++] =
|
||||
(caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10];
|
||||
fracpart = (fracpart / 10);
|
||||
} while(fracpart && (fplace < 20));
|
||||
if (fplace == 20) fplace--;
|
||||
fconvert[fplace] = 0;
|
||||
|
||||
/* -1 for decimal point, another -1 if we are printing a sign */
|
||||
padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
|
||||
zpadlen = max - fplace;
|
||||
if (zpadlen < 0)
|
||||
zpadlen = 0;
|
||||
if (padlen < 0)
|
||||
padlen = 0;
|
||||
if (flags & DP_F_MINUS)
|
||||
padlen = -padlen; /* Left Justifty */
|
||||
|
||||
if ((flags & DP_F_ZERO) && (padlen > 0))
|
||||
{
|
||||
if (signvalue)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, signvalue);
|
||||
--padlen;
|
||||
signvalue = 0;
|
||||
}
|
||||
while (padlen > 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, '0');
|
||||
--padlen;
|
||||
}
|
||||
}
|
||||
while (padlen > 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
--padlen;
|
||||
}
|
||||
if (signvalue)
|
||||
dopr_outch (buffer, currlen, maxlen, signvalue);
|
||||
|
||||
while (iplace > 0)
|
||||
dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
|
||||
|
||||
/*
|
||||
* Decimal point. This should probably use locale to find the correct
|
||||
* char to print out.
|
||||
*/
|
||||
dopr_outch (buffer, currlen, maxlen, '.');
|
||||
|
||||
while (zpadlen > 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, '0');
|
||||
--zpadlen;
|
||||
}
|
||||
|
||||
while (fplace > 0)
|
||||
dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
|
||||
|
||||
while (padlen < 0)
|
||||
{
|
||||
dopr_outch (buffer, currlen, maxlen, ' ');
|
||||
++padlen;
|
||||
}
|
||||
}
|
||||
|
||||
static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c)
|
||||
{
|
||||
if (*currlen < maxlen)
|
||||
buffer[(*currlen)++] = c;
|
||||
}
|
||||
|
||||
#ifdef TEST_SNPRINTF
|
||||
#ifndef LONG_STRING
|
||||
#define LONG_STRING 1024
|
||||
#endif
|
||||
int main (void)
|
||||
{
|
||||
char buf1[LONG_STRING];
|
||||
char buf2[LONG_STRING];
|
||||
char *fp_fmt[] = {
|
||||
"%-1.5f",
|
||||
"%1.5f",
|
||||
"%123.9f",
|
||||
"%10.5f",
|
||||
"% 10.5f",
|
||||
"%+22.9f",
|
||||
"%+4.9f",
|
||||
"%01.3f",
|
||||
"%4f",
|
||||
"%3.1f",
|
||||
"%3.2f",
|
||||
NULL
|
||||
};
|
||||
double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
|
||||
0.9996, 1.996, 4.136, 0};
|
||||
char *int_fmt[] = {
|
||||
"%-1.5d",
|
||||
"%1.5d",
|
||||
"%123.9d",
|
||||
"%5.5d",
|
||||
"%10.5d",
|
||||
"% 10.5d",
|
||||
"%+22.33d",
|
||||
"%01.3d",
|
||||
"%4d",
|
||||
NULL
|
||||
};
|
||||
long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
|
||||
int x, y;
|
||||
int fail = 0;
|
||||
int num = 0;
|
||||
|
||||
printf ("Testing snprintf format codes against system sprintf...\n");
|
||||
|
||||
for (x = 0; fp_fmt[x] != NULL ; x++)
|
||||
for (y = 0; fp_nums[y] != 0 ; y++)
|
||||
{
|
||||
snprintf (buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]);
|
||||
sprintf (buf2, fp_fmt[x], fp_nums[y]);
|
||||
if (strcmp (buf1, buf2))
|
||||
{
|
||||
printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
|
||||
fp_fmt[x], buf1, buf2);
|
||||
fail++;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
|
||||
for (x = 0; int_fmt[x] != NULL ; x++)
|
||||
for (y = 0; int_nums[y] != 0 ; y++)
|
||||
{
|
||||
snprintf (buf1, sizeof (buf1), int_fmt[x], int_nums[y]);
|
||||
sprintf (buf2, int_fmt[x], int_nums[y]);
|
||||
if (strcmp (buf1, buf2))
|
||||
{
|
||||
printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
|
||||
int_fmt[x], buf1, buf2);
|
||||
fail++;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
printf ("%d tests failed out of %d.\n", fail, num);
|
||||
}
|
||||
#endif /* SNPRINTF_TEST */
|
||||
|
||||
#endif /* !HAVE_SNPRINTF */
|
||||
@@ -0,0 +1,57 @@
|
||||
/* from openssh 4.3p2 compat/strlcpy.c */
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* 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 THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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.
|
||||
*/
|
||||
|
||||
/* OPENBSD ORIGINAL: lib/libc/string/strlcpy.c */
|
||||
|
||||
#include <ldns/config.h>
|
||||
#ifndef HAVE_STRLCPY
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Copy src to string dst of size siz. At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz == 0).
|
||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
strlcpy(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
size_t n = siz;
|
||||
|
||||
/* Copy as many bytes as will fit */
|
||||
if (n != 0 && --n != 0) {
|
||||
do {
|
||||
if ((*d++ = *s++) == 0)
|
||||
break;
|
||||
} while (--n != 0);
|
||||
}
|
||||
|
||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
||||
if (n == 0) {
|
||||
if (siz != 0)
|
||||
*d = '\0'; /* NUL-terminate dst */
|
||||
while (*s++)
|
||||
;
|
||||
}
|
||||
|
||||
return(s - src - 1); /* count does not include NUL */
|
||||
}
|
||||
|
||||
#endif /* !HAVE_STRLCPY */
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <ldns/config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
time_t
|
||||
timegm (struct tm *tm) {
|
||||
time_t ret;
|
||||
char *tz;
|
||||
|
||||
tz = getenv("TZ");
|
||||
putenv((char*)"TZ=");
|
||||
tzset();
|
||||
ret = mktime(tm);
|
||||
if (tz) {
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "TZ=%s", tz);
|
||||
putenv(tz);
|
||||
}
|
||||
else
|
||||
putenv((char*)"TZ");
|
||||
tzset();
|
||||
return ret;
|
||||
}
|
||||
Vendored
+1407
File diff suppressed because it is too large
Load Diff
Vendored
+1504
File diff suppressed because it is too large
Load Diff
+17354
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,488 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
AC_PREREQ(2.56)
|
||||
sinclude(acx_nlnetlabs.m4)
|
||||
|
||||
# must be numbers. ac_defun because of later processing.
|
||||
m4_define([VERSION_MAJOR],[1])
|
||||
m4_define([VERSION_MINOR],[6])
|
||||
m4_define([VERSION_MICRO],[9])
|
||||
AC_INIT(ldns, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), libdns@nlnetlabs.nl, libdns)
|
||||
AC_CONFIG_SRCDIR([packet.c])
|
||||
# needed to build correct soname
|
||||
AC_SUBST(LIBTOOL_VERSION_INFO, VERSION_MAJOR:VERSION_MINOR:VERSION_MICRO)
|
||||
AC_SUBST(LDNS_VERSION_MAJOR, [VERSION_MAJOR])
|
||||
AC_SUBST(LDNS_VERSION_MINOR, [VERSION_MINOR])
|
||||
AC_SUBST(LDNS_VERSION_MICRO, [VERSION_MICRO])
|
||||
|
||||
OURCPPFLAGS=''
|
||||
CPPFLAGS=${CPPFLAGS:-${OURCPPFLAGS}}
|
||||
CFLAGS="$CFLAGS"
|
||||
|
||||
AC_AIX
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_MAKE_SET
|
||||
|
||||
AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
|
||||
|
||||
ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
|
||||
ACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"])
|
||||
|
||||
# routine to copy files
|
||||
# argument 1 is a list of files (relative to the source dir)
|
||||
# argument 2 is a destination directory (relative to the current
|
||||
# working directory
|
||||
AC_DEFUN([COPY_FILES],
|
||||
[
|
||||
for file in $1; do
|
||||
sh $srcdir/install-sh -m 644 $file $2
|
||||
done
|
||||
])
|
||||
|
||||
# copy all .h files in the dir at argument 1
|
||||
# (relative to source) to the dir at argument 2
|
||||
# (relative to current dir)
|
||||
AC_DEFUN([COPY_HEADER_FILES],
|
||||
[
|
||||
echo "copying header files"
|
||||
COPY_FILES($srcdir/$1/*.h, $2)
|
||||
])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_LANG_C
|
||||
ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="-g $CFLAGS"])
|
||||
ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="-O2 $CFLAGS"])
|
||||
ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="-Wall $CFLAGS"])
|
||||
ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="-W $CFLAGS"])
|
||||
ACX_CHECK_COMPILER_FLAG(Wwrite-strings, [CFLAGS="-Wwrite-strings $CFLAGS"])
|
||||
|
||||
AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
|
||||
|
||||
# MinGW32 tests
|
||||
AC_CHECK_HEADERS([winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT])
|
||||
# end mingw32 tests
|
||||
|
||||
ACX_DETERMINE_EXT_FLAGS_UNBOUND
|
||||
|
||||
AC_C_INLINE
|
||||
AC_CHECK_TYPE(int8_t, char)
|
||||
AC_CHECK_TYPE(int16_t, short)
|
||||
AC_CHECK_TYPE(int32_t, int)
|
||||
AC_CHECK_TYPE(int64_t, long long)
|
||||
AC_CHECK_TYPE(uint8_t, unsigned char)
|
||||
AC_CHECK_TYPE(uint16_t, unsigned short)
|
||||
AC_CHECK_TYPE(uint32_t, unsigned int)
|
||||
AC_CHECK_TYPE(uint64_t, unsigned long long)
|
||||
|
||||
# my own checks
|
||||
AC_CHECK_PROG(doxygen, doxygen, doxygen)
|
||||
|
||||
# check to see if libraries are needed for these functions.
|
||||
AC_SEARCH_LIBS([socket], [socket])
|
||||
AC_SEARCH_LIBS([inet_pton], [nsl])
|
||||
|
||||
# check for python
|
||||
AC_ARG_WITH(pyldns, AC_HELP_STRING([--with-pyldns],
|
||||
[generate python library, or --without-pyldns to disable Python support.]),
|
||||
[],[ withval="no" ])
|
||||
ldns_have_python=no
|
||||
if test x_$withval != x_no; then
|
||||
sinclude(acx_python.m4)
|
||||
ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
|
||||
AC_PYTHON_DEVEL
|
||||
if test ! -z "$PYTHON_VERSION"; then
|
||||
if test `$PYTHON -c "print '$PYTHON_VERSION' >= '2.4.0'"` = "False"; then
|
||||
AC_ERROR([Python version >= 2.4.0 is required])
|
||||
fi
|
||||
# Have Python
|
||||
AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
|
||||
ldns_have_python=yes
|
||||
fi
|
||||
|
||||
# check for swig
|
||||
if test x_$ldns_have_python != x_no; then
|
||||
sinclude(ac_pkg_swig.m4)
|
||||
AC_PROG_SWIG
|
||||
if test ! -x "$SWIG"; then
|
||||
AC_ERROR([failed to find swig tool, install it, or do not build pyldns])
|
||||
else
|
||||
AC_DEFINE(HAVE_SWIG,1,[Define if you have Swig libraries and header files.])
|
||||
AC_SUBST(PYLDNS, "pyldns")
|
||||
AC_SUBST(swig, "$SWIG")
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([*** don't have Python, skipping Swig, no pyldns ***])
|
||||
fi
|
||||
fi
|
||||
|
||||
# Use libtool
|
||||
ACX_LIBTOOL_C_ONLY
|
||||
|
||||
tmp_CPPFLAGS=$CPPFLAGS
|
||||
tmp_LDFLAGS=$LDFLAGS
|
||||
tmp_LIBS=$LIBS
|
||||
|
||||
ACX_WITH_SSL_OPTIONAL
|
||||
|
||||
AC_CHECK_FUNCS([EVP_sha256])
|
||||
|
||||
# for macosx, see if glibtool exists and use that
|
||||
# BSD's need to know the version...
|
||||
#AC_CHECK_PROG(glibtool, glibtool, [glibtool], )
|
||||
#AC_CHECK_PROGS(libtool, [libtool15 libtool], [./libtool])
|
||||
|
||||
AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
|
||||
case "$enable_sha2" in
|
||||
no)
|
||||
;;
|
||||
yes|*)
|
||||
if test "x$HAVE_SSL" != "xyes"; then
|
||||
AC_MSG_ERROR([SHA2 enabled, but no SSL support])
|
||||
fi
|
||||
AC_MSG_CHECKING(for SHA256 and SHA512)
|
||||
AC_CHECK_FUNC(SHA256_Init, [], [
|
||||
AC_MSG_ERROR([No SHA2 functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-sha2])
|
||||
])
|
||||
AC_DEFINE_UNQUOTED([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
|
||||
case "$enable_gost" in
|
||||
no)
|
||||
;;
|
||||
*) dnl default
|
||||
if test "x$HAVE_SSL" != "xyes"; then
|
||||
AC_MSG_ERROR([GOST enabled, but no SSL support])
|
||||
fi
|
||||
AC_MSG_CHECKING(for GOST)
|
||||
AC_CHECK_FUNC(EVP_PKEY_set_type_str, [],[AC_MSG_ERROR([OpenSSL >= 1.0.0 is needed for GOST support or rerun with --disable-gost])])
|
||||
AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([No ECC functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-gost])])
|
||||
AC_DEFINE_UNQUOTED([USE_GOST], [1], [Define this to enable GOST support.])
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--enable-ecdsa], [Enable ECDSA support, experimental]))
|
||||
case "$enable_ecdsa" in
|
||||
yes)
|
||||
if test "x$HAVE_SSL" != "xyes"; then
|
||||
AC_MSG_ERROR([ECDSA enabled, but no SSL support])
|
||||
fi
|
||||
AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA])])
|
||||
AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384])])
|
||||
AC_CHECK_DECLS([NID_X9_62_prime256v1, NID_secp384r1], [], [AC_MSG_ERROR([OpenSSL does not support the ECDSA curve])], [AC_INCLUDES_DEFAULT
|
||||
#include <openssl/evp.h>
|
||||
])
|
||||
# we now know we have ECDSA and the required curves.
|
||||
AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
|
||||
AC_WARN([
|
||||
*****************************************************************
|
||||
*** YOU HAVE ENABLED ECDSA WHICH IS EXPERIMENTAL AT THIS TIME ***
|
||||
*** PLEASE DO NOT USE THIS ON THE PUBLIC INTERNET ***
|
||||
*****************************************************************])
|
||||
;;
|
||||
no)
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(LIBSSL_CPPFLAGS)
|
||||
AC_SUBST(LIBSSL_LDFLAGS)
|
||||
AC_SUBST(LIBSSL_LIBS)
|
||||
CPPFLAGS=$tmp_CPPFLAGS
|
||||
LDFLAGS=$tmp_LDFLAGS
|
||||
LIBS=$tmp_LIBS
|
||||
|
||||
# add option to disable installation of ldns-config script
|
||||
AC_ARG_ENABLE(ldns-config, [ --disable-ldns-config disable installation of ldns-config (default=enabled)],
|
||||
enable_ldns_config=$enableval, enable_ldns_config=yes)
|
||||
if test "x$enable_ldns_config" = xyes; then
|
||||
INSTALL_LDNS_CONFIG="yes"
|
||||
else
|
||||
INSTALL_LDNS_CONFIG="no"
|
||||
fi
|
||||
AC_SUBST(INSTALL_LDNS_CONFIG)
|
||||
|
||||
# add option to disable the evil rpath
|
||||
ACX_ARG_RPATH
|
||||
|
||||
#AC_TRY_RUN(
|
||||
#[
|
||||
#int main()
|
||||
#{
|
||||
#short one = 1;
|
||||
#char *cp = (char*)&one;
|
||||
#if ( *cp == 0 )
|
||||
#return(0);
|
||||
#else
|
||||
#return(1);
|
||||
#}
|
||||
#], [],[
|
||||
#AC_DEFINE(CONFCHECK_LITTLE_ENDIAN, 1, [system appears to be little-endian])
|
||||
#],[])
|
||||
|
||||
# should define WORDS_BIGENDIAN if the system is big-endian
|
||||
AC_C_BIGENDIAN
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
#AC_HEADER_SYS_WAIT
|
||||
#AC_CHECK_HEADERS([getopt.h fcntl.h stdlib.h string.h strings.h unistd.h])
|
||||
# do the very minimum - we can always extend this
|
||||
AC_CHECK_HEADERS([getopt.h stdarg.h stdbool.h openssl/ssl.h netinet/in.h time.h arpa/inet.h netdb.h],,, [AC_INCLUDES_DEFAULT])
|
||||
AC_CHECK_HEADERS(sys/param.h sys/mount.h,,,
|
||||
[AC_INCLUDES_DEFAULT
|
||||
[
|
||||
#if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
]
|
||||
])
|
||||
AC_CHECK_HEADER(sys/socket.h,
|
||||
[
|
||||
include_sys_socket_h='#include <sys/socket.h>'
|
||||
AC_DEFINE(HAVE_SYS_SOCKET_H, 1, [define if you have sys/socket.h])
|
||||
],[
|
||||
include_sys_socket_h=''
|
||||
],[AC_INCLUDES_DEFAULT
|
||||
[
|
||||
#if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
]
|
||||
])
|
||||
AC_SUBST(include_sys_socket_h)
|
||||
AC_CHECK_HEADER(inttypes.h,
|
||||
[
|
||||
include_inttypes_h='#include <inttypes.h>'
|
||||
AC_DEFINE(HAVE_INTTYPES_H, 1, [define if you have inttypes.h])
|
||||
],[
|
||||
include_inttypes_h=''
|
||||
],[AC_INCLUDES_DEFAULT
|
||||
])
|
||||
AC_SUBST(include_inttypes_h)
|
||||
AC_CHECK_HEADER(sys/types.h,
|
||||
[
|
||||
include_systypes_h='#include <sys/types.h>'
|
||||
AC_DEFINE(HAVE_SYS_TYPES_H, 1, [define if you have sys/types.h])
|
||||
],[
|
||||
include_systypes_h=''
|
||||
],[AC_INCLUDES_DEFAULT
|
||||
])
|
||||
AC_SUBST(include_systypes_h)
|
||||
AC_CHECK_HEADER(unistd.h,
|
||||
[
|
||||
include_unistd_h='#include <unistd.h>'
|
||||
AC_DEFINE(HAVE_UNISTD_H, 1, [define if you have unistd.h])
|
||||
],[
|
||||
include_unistd_h=''
|
||||
],[AC_INCLUDES_DEFAULT
|
||||
])
|
||||
AC_SUBST(include_unistd_h)
|
||||
|
||||
ACX_TYPE_SOCKLEN_T
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
|
||||
#if HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#if HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif])
|
||||
AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
|
||||
#if HAVE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#if HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif])
|
||||
ACX_CHECK_SS_FAMILY
|
||||
|
||||
AC_FUNC_MALLOC
|
||||
AC_FUNC_REALLOC
|
||||
|
||||
AC_REPLACE_FUNCS(b64_pton)
|
||||
AC_REPLACE_FUNCS(b64_ntop)
|
||||
AC_REPLACE_FUNCS(b32_pton)
|
||||
AC_REPLACE_FUNCS(b32_ntop)
|
||||
AC_REPLACE_FUNCS(timegm)
|
||||
AC_REPLACE_FUNCS(gmtime_r)
|
||||
AC_REPLACE_FUNCS(ctime_r)
|
||||
AC_REPLACE_FUNCS(isblank)
|
||||
AC_REPLACE_FUNCS(isascii)
|
||||
AC_REPLACE_FUNCS(inet_aton)
|
||||
AC_REPLACE_FUNCS(inet_pton)
|
||||
AC_REPLACE_FUNCS(inet_ntop)
|
||||
AC_REPLACE_FUNCS(snprintf)
|
||||
AC_REPLACE_FUNCS(strlcpy)
|
||||
AC_REPLACE_FUNCS(memmove)
|
||||
AC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul])
|
||||
|
||||
ACX_CHECK_GETADDRINFO_WITH_INCLUDES
|
||||
if test $ac_cv_func_getaddrinfo = no; then
|
||||
AC_LIBOBJ([fake-rfc2553])
|
||||
fi
|
||||
if test "$USE_WINSOCK" = 1; then
|
||||
AC_CHECK_TOOL(WINDRES, windres)
|
||||
fi
|
||||
ACX_FUNC_IOCTLSOCKET
|
||||
|
||||
#AC_SEARCH_LIBS(RSA_new, [crypto])
|
||||
|
||||
ACX_CHECK_FORMAT_ATTRIBUTE
|
||||
ACX_CHECK_UNUSED_ATTRIBUTE
|
||||
|
||||
# check OSX deployment target which is needed
|
||||
if echo $build_os | grep darwin > /dev/null; then
|
||||
export MACOSX_DEPLOYMENT_TARGET="10.4"
|
||||
fi
|
||||
|
||||
AC_DEFINE([SYSCONFDIR], [sysconfdir], [System configuration dir])
|
||||
|
||||
AH_BOTTOM([
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef LITTLE_ENDIAN
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#endif
|
||||
|
||||
#ifndef BIG_ENDIAN
|
||||
#define BIG_ENDIAN 4321
|
||||
#endif
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define BYTE_ORDER BIG_ENDIAN
|
||||
#else
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
#endif /* WORDS_BIGENDIAN */
|
||||
#endif /* BYTE_ORDER */
|
||||
|
||||
#if STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
]
|
||||
AHX_CONFIG_W32_FD_SET_T
|
||||
)
|
||||
|
||||
AH_BOTTOM([
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef B64_PTON
|
||||
int ldns_b64_ntop(uint8_t const *src, size_t srclength,
|
||||
char *target, size_t targsize);
|
||||
/**
|
||||
* calculates the size needed to store the result of b64_ntop
|
||||
*/
|
||||
/*@unused@*/
|
||||
static inline size_t ldns_b64_ntop_calculate_size(size_t srcsize)
|
||||
{
|
||||
return ((((srcsize + 2) / 3) * 4) + 1);
|
||||
}
|
||||
#endif /* !B64_PTON */
|
||||
#ifndef B64_NTOP
|
||||
int ldns_b64_pton(char const *src, uint8_t *target, size_t targsize);
|
||||
/**
|
||||
* calculates the size needed to store the result of ldns_b64_pton
|
||||
*/
|
||||
/*@unused@*/
|
||||
static inline size_t ldns_b64_pton_calculate_size(size_t srcsize)
|
||||
{
|
||||
return (((((srcsize + 3) / 4) * 3)) + 1);
|
||||
}
|
||||
#endif /* !B64_NTOP */
|
||||
|
||||
#ifndef HAVE_SLEEP
|
||||
/* use windows sleep, in millisecs, instead */
|
||||
#define sleep(x) Sleep((x)*1000)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_RANDOM
|
||||
#define srandom(x) srand(x)
|
||||
#define random(x) rand(x)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_TIMEGM
|
||||
#include <time.h>
|
||||
time_t timegm (struct tm *tm);
|
||||
#endif /* !TIMEGM */
|
||||
#ifndef HAVE_GMTIME_R
|
||||
struct tm *gmtime_r(const time_t *timep, struct tm *result);
|
||||
#endif
|
||||
#ifndef HAVE_ISBLANK
|
||||
int isblank(int c);
|
||||
#endif /* !HAVE_ISBLANK */
|
||||
#ifndef HAVE_ISASCII
|
||||
int isascii(int c);
|
||||
#endif /* !HAVE_ISASCII */
|
||||
#ifndef HAVE_SNPRINTF
|
||||
#include <stdarg.h>
|
||||
int snprintf (char *str, size_t count, const char *fmt, ...);
|
||||
int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
|
||||
#endif /* HAVE_SNPRINTF */
|
||||
#ifndef HAVE_INET_PTON
|
||||
int inet_pton(int af, const char* src, void* dst);
|
||||
#endif /* HAVE_INET_PTON */
|
||||
#ifndef HAVE_INET_NTOP
|
||||
const char *inet_ntop(int af, const void *src, char *dst, size_t size);
|
||||
#endif
|
||||
#ifndef HAVE_INET_ATON
|
||||
int inet_aton(const char *cp, struct in_addr *addr);
|
||||
#endif
|
||||
#ifndef HAVE_MEMMOVE
|
||||
void *memmove(void *dest, const void *src, size_t n);
|
||||
#endif
|
||||
#ifndef HAVE_STRLCPY
|
||||
size_t strlcpy(char *dst, const char *src, size_t siz);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#ifndef HAVE_GETADDRINFO
|
||||
#include "compat/fake-rfc2553.h"
|
||||
#endif
|
||||
#ifndef HAVE_STRTOUL
|
||||
#define strtoul (unsigned long)strtol
|
||||
#endif
|
||||
])
|
||||
|
||||
AC_CONFIG_FILES([Makefile ldns/net.h ldns/util.h packaging/libldns.pc packaging/ldns-config])
|
||||
|
||||
AC_CONFIG_HEADER([ldns/config.h])
|
||||
AC_OUTPUT
|
||||
COPY_HEADER_FILES(ldns/, ldns/)
|
||||
|
||||
AC_CONFIG_SUBDIRS([drill])
|
||||
@@ -0,0 +1,10 @@
|
||||
NETLDNS is a functionality port of NLnet Labs' LDNS to the .NET
|
||||
2.0 framework, contributed by Alex Nicoll of the Carnegie Mellon
|
||||
University Software Engineering Institute. NETLDNS is released
|
||||
under the BSD license. NETLDNS uses Mihnea Radulescu's BigInteger
|
||||
Library (http://www.codeproject.com/KB/cs/BigInteger_Library.aspx)
|
||||
from CodeProject to help with key manipulation. Please contact Alex at
|
||||
anicoll@cert.org with inquiries or requests for newer versions.
|
||||
|
||||
This project is not supported by NLnet Labs.
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# $Id: build-solaris.sh 2597 2008-04-15 08:39:58Z jelte $
|
||||
|
||||
|
||||
PREFIX=/opt/ldns
|
||||
OPENSSL=/usr/sfw
|
||||
SUDO=sudo
|
||||
|
||||
MAKE_PROGRAM=gmake
|
||||
MAKE_ARGS="-j 4"
|
||||
|
||||
OBJ32=obj32
|
||||
OBJ64=obj64
|
||||
|
||||
SRCDIR=`pwd`
|
||||
|
||||
|
||||
test -d $OBJ32 && $SUDO rm -fr $OBJ32
|
||||
mkdir $OBJ32
|
||||
|
||||
export CFLAGS=""
|
||||
export LDFLAGS="-L${OPENSSL}/lib -R${OPENSSL}/lib"
|
||||
|
||||
(cd $OBJ32; \
|
||||
${SRCDIR}/configure --with-ssl=${OPENSSL} --prefix=${PREFIX} --libdir=${PREFIX}/lib; \
|
||||
$MAKE_PROGRAM $MAKE_ARGS)
|
||||
|
||||
if [ `isainfo -k` = amd64 ]; then
|
||||
test -d $OBJ64 && $SUDO rm -fr $OBJ64
|
||||
mkdir $OBJ64
|
||||
|
||||
export CFLAGS="-m64"
|
||||
export LDFLAGS="-L${OPENSSL}/lib/amd64 -R${OPENSSL}/lib/amd64"
|
||||
|
||||
(cd $OBJ64; \
|
||||
${SRCDIR}/configure --with-ssl=${OPENSSL} --prefix=${PREFIX} --libdir=${PREFIX}/lib/amd64; \
|
||||
$MAKE_PROGRAM $MAKE_ARGS)
|
||||
fi
|
||||
|
||||
# optionally install
|
||||
#
|
||||
if [ x$1 = xinstall ]; then
|
||||
(cd $OBJ32; $SUDO $MAKE_PROGRAM install-h)
|
||||
(cd $OBJ32; $SUDO $MAKE_PROGRAM install-doc)
|
||||
(cd $OBJ32; $SUDO $MAKE_PROGRAM install-lib)
|
||||
if [ `isainfo -k` = amd64 ]; then
|
||||
(cd $OBJ64; $SUDO $MAKE_PROGRAM install-lib)
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
|
||||
Karel Slany (slany AT fit.vutbr.cz)
|
||||
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 the organization 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.
|
||||
@@ -0,0 +1,67 @@
|
||||
# Makefile: compilation of sources and documentation, test environment
|
||||
#
|
||||
# Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
|
||||
# Karel Slany (slany AT fit.vutbr.cz)
|
||||
# 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 the organization 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.
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " testenv to make test environment and run bash "
|
||||
@echo " usefull in case you don't want to install ldns but want to test examples"
|
||||
@echo " doc to make documentation"
|
||||
@echo " clean clean all"
|
||||
|
||||
../../Makefile: ../../configure
|
||||
cd ../.. && ./configure --with-python
|
||||
|
||||
_ldns.so: ../../Makefile
|
||||
$(MAKE) -C ../..
|
||||
|
||||
../../.libs/ldns.so.1: ../../Makefile
|
||||
$(MAKE) -C ../..
|
||||
|
||||
clean:
|
||||
rm -rdf examples/ldns
|
||||
rm -f _ldns.so ldns_wrapper.o
|
||||
$(MAKE) -C ../.. clean
|
||||
|
||||
testenv: ../../.libs/libldns.so.1 _ldns.so
|
||||
rm -rdf examples/ldns
|
||||
cd examples && mkdir ldns && ln -s ../../ldns.py ldns/__init__.py && ln -s ../../_ldns.so ldns/_ldns.so && ln -s ../../../../.libs/libldns.so.1 ldns/libldns.so.1 && ls -la
|
||||
@echo "Run a script by typing ./script_name.py"
|
||||
cd examples && LD_LIBRARY_PATH=ldns bash
|
||||
rm -rdf examples/ldns
|
||||
|
||||
doc: ../../.libs/ldns.so.1 _ldns.so
|
||||
$(MAKE) -C docs html
|
||||
|
||||
#for development only
|
||||
swig: ldns.i
|
||||
swig -python -o ldns_wrapper.c -I../.. ldns.i
|
||||
gcc -c ldns_wrapper.c -O9 -fPIC -I../.. -I../../ldns -I/usr/include/python2.5 -I. -o ldns_wrapper.o
|
||||
ld -shared ldns_wrapper.o -L../../.libs -lldns -o _ldns.so
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
|
||||
|
||||
.PHONY: help clean html web pickle htmlhelp latex changes linkcheck
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " pickle to make pickle files (usable by e.g. sphinx-web)"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " changes to make an overview over all changed/added/deprecated items"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
|
||||
clean:
|
||||
-rm -rf build/*
|
||||
|
||||
html:
|
||||
mkdir -p build/html build/doctrees
|
||||
LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in build/html."
|
||||
|
||||
pickle:
|
||||
mkdir -p build/pickle build/doctrees
|
||||
LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files or run"
|
||||
@echo " sphinx-web build/pickle"
|
||||
@echo "to start the sphinx-web server."
|
||||
|
||||
web: pickle
|
||||
|
||||
htmlhelp:
|
||||
mkdir -p build/htmlhelp build/doctrees
|
||||
LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in build/htmlhelp."
|
||||
|
||||
latex:
|
||||
mkdir -p build/latex build/doctrees
|
||||
LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in build/latex."
|
||||
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
|
||||
"run these through (pdf)latex."
|
||||
|
||||
changes:
|
||||
mkdir -p build/changes build/doctrees
|
||||
LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
|
||||
@echo
|
||||
@echo "The overview file is in build/changes."
|
||||
|
||||
linkcheck:
|
||||
mkdir -p build/linkcheck build/doctrees
|
||||
LD_LIBRARY_PATH=../../../.libs $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in build/linkcheck/output.txt."
|
||||
@@ -0,0 +1,180 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Unbound documentation build configuration file, created by
|
||||
# sphinx-quickstart on Fri Jan 2 19:14:13 2009.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
#
|
||||
# The contents of this file are pickled, so don't put values in the namespace
|
||||
# that aren't pickleable (module imports are okay, they're removed automatically).
|
||||
#
|
||||
# All configuration values have a default value; values that are commented out
|
||||
# serve to show the default value.
|
||||
|
||||
import sys, os
|
||||
|
||||
# If your extensions are in another directory, add it here. If the directory
|
||||
# is relative to the documentation root, use os.path.abspath to make it
|
||||
# absolute, like shown here.
|
||||
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),'../../')))
|
||||
#print sys.path
|
||||
|
||||
# General configuration
|
||||
# ---------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General substitutions.
|
||||
project = 'pyLDNS'
|
||||
copyright = '2009, Karel Slany, Zdenek Vasicek'
|
||||
|
||||
# The default replacements for |version| and |release|, also used in various
|
||||
# other places throughout the built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '1.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '1.0.0'
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of documents that shouldn't be included in the build.
|
||||
#unused_docs = []
|
||||
|
||||
# List of directories, relative to source directories, that shouldn't be searched
|
||||
# for source files.
|
||||
#exclude_dirs = []
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
|
||||
# Options for HTML output
|
||||
# -----------------------
|
||||
|
||||
# The style sheet to use for HTML and HTML Help pages. A file of that name
|
||||
# must exist either in Sphinx' static/ path, or in one of the custom paths
|
||||
# given in html_static_path.
|
||||
html_style = 'default.css'
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (within the static path) to place at the top of
|
||||
# the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
html_use_modindex = False
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
html_split_index = False
|
||||
|
||||
# If true, the reST sources are included in the HTML build as _sources/<name>.
|
||||
html_copy_source = False
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = ''
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'ldnsdoc'
|
||||
|
||||
|
||||
# Options for LaTeX output
|
||||
# ------------------------
|
||||
|
||||
# The paper size ('letter' or 'a4').
|
||||
#latex_paper_size = 'letter'
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#latex_font_size = '10pt'
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, document class [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'ldns-doc.tex', 'LDNS Documentation',
|
||||
'Karel Slany, Zdenek Vasicek', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#latex_preamble = ''
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_use_modindex = True
|
||||
@@ -0,0 +1,68 @@
|
||||
Resolving the MX records
|
||||
==============================
|
||||
|
||||
This basic example shows how to create a resolver which asks for MX records which contain the information about mail servers.
|
||||
|
||||
::
|
||||
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# MX is a small program that prints out the mx records for a particular domain
|
||||
#
|
||||
import ldns
|
||||
|
||||
resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
|
||||
|
||||
dname = ldns.ldns_dname("nic.cz")
|
||||
|
||||
pkt = resolver.query(dname, ldns.LDNS_RR_TYPE_MX, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
|
||||
if (pkt):
|
||||
mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER)
|
||||
if (mx):
|
||||
mx.sort()
|
||||
print mx
|
||||
|
||||
Resolving step by step
|
||||
------------------------
|
||||
|
||||
First of all we import :mod:`ldns` extension module which make LDNS functions and classes accessible::
|
||||
|
||||
import ldns
|
||||
|
||||
If importing fails, it means that Python cannot find the module or ldns library.
|
||||
|
||||
Then we create the resolver by :meth:`ldns.ldns_resolver.new_frm_file` constructor ::
|
||||
|
||||
resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
|
||||
|
||||
and domain name variable dname::
|
||||
|
||||
dname = ldns.ldns_dname("nic.cz")
|
||||
|
||||
To create a resolver you may also use::
|
||||
|
||||
resolver = ldns.ldns_resolver.new_frm_file(None)
|
||||
|
||||
which behaves in the same manner as the command above.
|
||||
|
||||
In the third step we tell the resolver to query for our domain, type MX, of class IN::
|
||||
|
||||
pkt = resolver.query(dname, ldns.LDNS_RR_TYPE_MX, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
|
||||
|
||||
The function should return a packet if everything goes well and this packet will contain resource records we asked for.
|
||||
Note that there exists a simplier way. Instead of using a dname variable, we can use a string which will be automatically converted.
|
||||
::
|
||||
|
||||
pkt = resolver.query("fit.vutbr.cz", ldns.LDNS_RR_TYPE_MX, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
|
||||
|
||||
Now, we test whether the resolver returns a packet and then get all RRs of type MX from the answer packet and store them in list mx::
|
||||
|
||||
if (pkt):
|
||||
mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER)
|
||||
|
||||
If this list is not empty, we sort and print the content to stdout::
|
||||
|
||||
if (mx):
|
||||
mx.sort()
|
||||
print mx
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
import ldns
|
||||
import sys
|
||||
|
||||
debug = True
|
||||
|
||||
# Check args
|
||||
argc = len(sys.argv)
|
||||
name = "www.nic.cz"
|
||||
if argc < 2:
|
||||
print "Usage:", sys.argv[0], "domain [resolver_addr]"
|
||||
sys.exit(1)
|
||||
else:
|
||||
name = sys.argv[1]
|
||||
|
||||
# Create resolver
|
||||
resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
|
||||
resolver.set_dnssec(True)
|
||||
|
||||
# Custom resolver
|
||||
if argc > 2:
|
||||
# Clear previous nameservers
|
||||
ns = resolver.pop_nameserver()
|
||||
while ns != None:
|
||||
ns = resolver.pop_nameserver()
|
||||
ip = ldns.ldns_rdf.new_frm_str(sys.argv[2], ldns.LDNS_RDF_TYPE_A)
|
||||
resolver.push_nameserver(ip)
|
||||
|
||||
# Resolve DNS name
|
||||
pkt = resolver.query(name, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN)
|
||||
if pkt and pkt.answer():
|
||||
|
||||
# Debug
|
||||
if debug:
|
||||
print "NS returned:", pkt.get_rcode(), "(AA: %d AD: %d)" % ( pkt.ad(), pkt.ad() )
|
||||
|
||||
# SERVFAIL indicated bogus name
|
||||
if pkt.get_rcode() is ldns.LDNS_RCODE_SERVFAIL:
|
||||
print name, "is bogus"
|
||||
|
||||
# Check AD (Authenticated) bit
|
||||
if pkt.get_rcode() is ldns.LDNS_RCODE_NOERROR:
|
||||
if pkt.ad(): print name, "is secure"
|
||||
else: print name, "is insecure"
|
||||
@@ -0,0 +1,100 @@
|
||||
.. _ex_dnssec:
|
||||
|
||||
Querying DNS-SEC validators
|
||||
===========================
|
||||
|
||||
This basic example shows how to query validating resolver and
|
||||
evaluate answer.
|
||||
|
||||
Resolving step by step
|
||||
------------------------
|
||||
|
||||
For DNS queries, we need to initialize ldns resolver (covered in previous example).
|
||||
|
||||
::
|
||||
|
||||
# Create resolver
|
||||
resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
|
||||
resolver.set_dnssec(True)
|
||||
|
||||
# Custom resolver
|
||||
if argc > 2:
|
||||
# Clear previous nameservers
|
||||
ns = resolver.pop_nameserver()
|
||||
while ns != None:
|
||||
ns = resolver.pop_nameserver()
|
||||
ip = ldns.ldns_rdf.new_frm_str(sys.argv[2], ldns.LDNS_RDF_TYPE_A)
|
||||
resolver.push_nameserver(ip)
|
||||
|
||||
Note the second line :meth:`resolver.set_dnssec`, which enables DNSSEC OK bit
|
||||
in queries in order to get meaningful results.
|
||||
|
||||
As we have resolver initialized, we can start querying for domain names :
|
||||
|
||||
::
|
||||
|
||||
# Resolve DNS name
|
||||
pkt = resolver.query(name, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN)
|
||||
if pkt and pkt.answer():
|
||||
|
||||
Now we evaluate result, where two flags are crucial :
|
||||
|
||||
* Return code
|
||||
* AD flag (authenticated)
|
||||
|
||||
When return code is `SERVFAIL`, it means that validating resolver marked requested
|
||||
name as **bogus** (or bad configuration).
|
||||
|
||||
**AD** flag is set if domain name is authenticated **(secure)** or false if
|
||||
it's insecure.
|
||||
|
||||
Complete source code
|
||||
--------------------
|
||||
|
||||
.. literalinclude:: ../../../examples/ldns-dnssec.py
|
||||
:language: python
|
||||
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
In order to get meaningful results, you have to enter IP address of validating
|
||||
resolver or setup your own (see howto).
|
||||
|
||||
Execute `./example2.py` with options `domain name` and `resolver IP`,
|
||||
example:
|
||||
|
||||
::
|
||||
|
||||
user@localhost# ./example2.py www.dnssec.cz 127.0.0.1 # Secure (Configured Unbound running on localhost)
|
||||
user@localhost# ./example2.py www.rhybar.cz 127.0.0.1 # Bogus
|
||||
|
||||
Howto setup Unbound as validating resolver
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Install Unbound according to instructions.
|
||||
Modify following options in `unbound.conf` (located in `/etc` or `/usr/local/etc`)/
|
||||
|
||||
|
||||
Uncomment `module-config` and set `validator` before iterator.
|
||||
|
||||
::
|
||||
|
||||
module-config: "validator iterator"
|
||||
|
||||
Download DLV keys and update path in `unbound.conf`::
|
||||
|
||||
# DLV keys
|
||||
# Download from http://ftp.isc.org/www/dlv/dlv.isc.org.key
|
||||
dlv-anchor-file: "/usr/local/etc/unbound/dlv.isc.org.key"
|
||||
|
||||
Update trusted keys (`.cz` for example)::
|
||||
|
||||
# Trusted keys
|
||||
# For current key, see www.dnssec.cz
|
||||
trusted-keys-file: "/usr/local/etc/unbound/trusted.key"
|
||||
|
||||
Now you should have well configured Unbound, so run it::
|
||||
|
||||
user@localhost# unbound -dv
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
High-level functions
|
||||
===========================
|
||||
|
||||
This basic example shows how to get name by addr and vice versa.
|
||||
|
||||
.. literalinclude:: ../../../examples/ldns-higher.py
|
||||
:language: python
|
||||
@@ -0,0 +1,7 @@
|
||||
AXFR client with IDN support
|
||||
===============================
|
||||
|
||||
This example shows how to get AXFR working and how to get involved Internationalized Domain Names (IDN)
|
||||
|
||||
.. literalinclude:: ../../../examples/ldns-axfr.py
|
||||
:language: python
|
||||
@@ -0,0 +1,14 @@
|
||||
Examine the results
|
||||
===============================
|
||||
|
||||
This example shows how to go through the obtained results
|
||||
|
||||
.. literalinclude:: ../../../examples/ldns-mx2.py
|
||||
:language: python
|
||||
|
||||
This snippet of code prints::
|
||||
|
||||
nic.cz. 1761 IN MX 20 mx.cznic.org.
|
||||
nic.cz. 1761 IN MX 10 mail.nic.cz.
|
||||
nic.cz. 1761 IN MX 15 mail4.nic.cz.
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
Read zone file
|
||||
===============================
|
||||
|
||||
This example shows how to read the content of a zone file
|
||||
|
||||
.. literalinclude:: ../../../examples/ldns-zone.py
|
||||
:language: python
|
||||
|
||||
Zone file ``zone.txt``:
|
||||
|
||||
.. literalinclude:: ../../../examples/zone.txt
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
Generate public/private key pair
|
||||
=======================================
|
||||
|
||||
This example shows how generate keys for DNSSEC (i.e. for signing a zone file according DNSSECbis).
|
||||
|
||||
.. literalinclude:: ../../../examples/ldns-keygen.py
|
||||
:language: python
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
Signing of a zone file
|
||||
===============================
|
||||
|
||||
This example shows how to sign the content of the given zone file
|
||||
|
||||
.. literalinclude:: ../../../examples/ldns-signzone.py
|
||||
:language: python
|
||||
|
||||
In order to be able sign a zone file, you have to generate a key-pair using ``ldns-keygen.py``. Don't forget to modify tag number.
|
||||
|
||||
Signing consists of three steps
|
||||
|
||||
1. In the first step, the content of a zone file is readed and parsed. This can be done using :class:`ldns.ldns_zone` class.
|
||||
|
||||
2. In the second step, the private and public key is readed and public key is inserted into zone (as DNSKEY).
|
||||
|
||||
3. In the last step, the DNSSEC zone instace is created and all the RRs from zone file are copied here. Then, all the records are signed using :meth:`ldns.ldns_zone.sign` method. If the signing was successfull, the content of DNSSEC zone is written to a file.
|
||||
@@ -0,0 +1,12 @@
|
||||
Tutorials
|
||||
==============================
|
||||
|
||||
Here you can find a set of simple applications which utilizes the ldns library in Python environment.
|
||||
|
||||
`Tutorials`
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
example*
|
||||
@@ -0,0 +1,22 @@
|
||||
PyLDNS documentation
|
||||
=======================================
|
||||
|
||||
PyLDNS provides an `LDNS`_ wrapper (Python extension module) - the thinnest layer over the library possible. Everything you can do from the C API, you can do from Python, but with less effort. The purpose of porting LDNS library to Python is to simplify DNS programming and usage of LDNS, however, still preserve the performance of this library as the speed represents the main benefit of LDNS. The proposed object approach allows the users to be concentrated at the essential part of application only and don't bother with deallocation of objects and so on.
|
||||
|
||||
.. _LDNS: http://www.nlnetlabs.nl/projects/ldns/
|
||||
|
||||
Contents
|
||||
----------
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
install.rst
|
||||
examples/index.rst
|
||||
modules/ldns
|
||||
|
||||
Indices and tables
|
||||
-------------------
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`search`
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
Installation
|
||||
===================================
|
||||
|
||||
**Prerequisites**
|
||||
|
||||
Python 2.4 or higher, SWIG 1.3 or higher, GNU make
|
||||
|
||||
**Download**
|
||||
|
||||
You can download the source codes `here`_.
|
||||
The latest release is 1.4.1, Jan 15, 2009.
|
||||
|
||||
.. _here: ldns-1.4.1-py.tar.gz
|
||||
|
||||
**Compiling**
|
||||
|
||||
After downloading, you can compile the library by doing::
|
||||
|
||||
> tar -xzf ldns-1.4.1-py.tar.gz
|
||||
> cd ldns-1.4.1
|
||||
> ./configure --with-pyldns
|
||||
> make
|
||||
|
||||
You need GNU make to compile pyLDNS; SWIG and Python development libraries to compile extension module.
|
||||
|
||||
|
||||
**Testing**
|
||||
|
||||
If the compilation is successfull, you can test the python LDNS extension module by::
|
||||
|
||||
> cd contrib/python
|
||||
> make testenv
|
||||
> ./ldns-mx.py
|
||||
|
||||
This will start a new shell, during which the symbolic links will be working.
|
||||
When you exit the shell, then symbolic links will be deleted.
|
||||
|
||||
In ``contrib/examples`` you can find many simple applications in python which demostrates the capabilities of LDNS library.
|
||||
|
||||
**Installation**
|
||||
|
||||
To install libraries and extension type::
|
||||
|
||||
> cd ldns-1.4.1
|
||||
> make install
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
LDNS module documentation
|
||||
================================
|
||||
|
||||
Here you can find the documentation of pyLDNS extension module. This module consists of several classes and a couple of functions.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:glob:
|
||||
|
||||
ldns_resolver
|
||||
ldns_pkt
|
||||
ldns_rr
|
||||
ldns_rdf
|
||||
ldns_dname
|
||||
ldns_rr_list
|
||||
ldns_zone
|
||||
ldns_key
|
||||
ldns_key_list
|
||||
ldns_buffer
|
||||
ldns_dnssec
|
||||
ldns_func
|
||||
|
||||
|
||||
|
||||
|
||||
**Differences against libLDNS**
|
||||
|
||||
* You don't need to use ldns-compare functions, instances can be compared using standard operators <, >, = ::
|
||||
|
||||
if (some_rr.owner() == another_rr.rdf(1)):
|
||||
pass
|
||||
|
||||
* Classes contain static methods that create new instances, the name of these methods starts with the new\_ prefix (e.g. :meth:`ldns.ldns_pkt.new_frm_file`).
|
||||
|
||||
* Is it possible to print the content of an object using ``print objinst`` (see :meth:`ldns.ldns_resolver.get_addr_by_name`).
|
||||
|
||||
* Classes contain write_to_buffer method that writes the content into buffer.
|
||||
|
||||
* All the methods that consume parameter of (const ldns_rdf) type allows to use string instead (see :meth:`ldns.ldns_resolver.query`).
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
Class ldns_buffer
|
||||
================================
|
||||
|
||||
|
||||
.. automodule:: ldns
|
||||
|
||||
Class ldns_buffer
|
||||
------------------------------
|
||||
.. autoclass:: ldns_buffer
|
||||
:members:
|
||||
:undoc-members:
|
||||
@@ -0,0 +1,11 @@
|
||||
Class ldns_dname
|
||||
================================
|
||||
|
||||
|
||||
.. automodule:: ldns
|
||||
|
||||
Class ldns_dname
|
||||
------------------------------
|
||||
.. autoclass:: ldns_dname
|
||||
:members:
|
||||
:undoc-members:
|
||||
@@ -0,0 +1,28 @@
|
||||
Class ldns_dnssec_zone
|
||||
================================
|
||||
|
||||
.. automodule:: ldns
|
||||
|
||||
Class ldns_dnssec_zone
|
||||
------------------------------
|
||||
.. autoclass:: ldns_dnssec_zone
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
Class ldns_dnssec_name
|
||||
------------------------------
|
||||
.. autoclass:: ldns_dnssec_name
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
Class ldns_dnssec_rrsets
|
||||
------------------------------
|
||||
.. autoclass:: ldns_dnssec_rrsets
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
Class ldns_dnssec_rrs
|
||||
------------------------------
|
||||
.. autoclass:: ldns_dnssec_rrs
|
||||
:members:
|
||||
:undoc-members:
|
||||
@@ -0,0 +1,253 @@
|
||||
Various functions
|
||||
================================
|
||||
|
||||
Here you can find list of functions that are not assigned to the classes.
|
||||
These functions have the same parameters as LDNS functions of the same name.
|
||||
You are encouraged to read the LDNS documentation.
|
||||
|
||||
**List of functions**
|
||||
|
||||
* ldns_algorithm2buffer_str
|
||||
* ldns_bget_keyword_data
|
||||
* ldns_bget_token
|
||||
* ldns_bgetc
|
||||
* ldns_bskipcs
|
||||
* ldns_bubblebabble
|
||||
* ldns_buffer2pkt_wire
|
||||
* ldns_buffer2str
|
||||
* ldns_calc_keytag
|
||||
* ldns_calc_keytag_raw
|
||||
* ldns_cert_algorithm2buffer_str
|
||||
* ldns_convert_dsa_rrsig_asn12rdf
|
||||
* ldns_convert_dsa_rrsig_rdf2asn1
|
||||
* ldns_create_nsec
|
||||
* ldns_create_nsec3
|
||||
* ldns_dname2buffer_wire
|
||||
* ldns_dname2canonical
|
||||
* ldns_dnssec_build_data_chain
|
||||
* ldns_dnssec_chain_nsec3_list
|
||||
* ldns_dnssec_create_nsec
|
||||
* ldns_dnssec_create_nsec3
|
||||
* ldns_dnssec_create_nsec_bitmap
|
||||
* ldns_dnssec_data_chain_deep_free
|
||||
* ldns_dnssec_data_chain_free
|
||||
* ldns_dnssec_data_chain_new
|
||||
* ldns_dnssec_data_chain_print
|
||||
* ldns_dnssec_default_add_to_signatures
|
||||
* ldns_dnssec_default_delete_signatures
|
||||
* ldns_dnssec_default_leave_signatures
|
||||
* ldns_dnssec_default_replace_signatures
|
||||
* ldns_dnssec_derive_trust_tree
|
||||
* ldns_dnssec_derive_trust_tree_dnskey_rrset
|
||||
* ldns_dnssec_derive_trust_tree_ds_rrset
|
||||
* ldns_dnssec_derive_trust_tree_no_sig
|
||||
* ldns_dnssec_derive_trust_tree_normal_rrset
|
||||
* ldns_dnssec_get_dnskey_for_rrsig
|
||||
* ldns_dnssec_get_rrsig_for_name_and_type
|
||||
* ldns_dnssec_nsec3_closest_encloser
|
||||
* ldns_dnssec_pkt_get_rrsigs_for_name_and_type
|
||||
* ldns_dnssec_pkt_get_rrsigs_for_type
|
||||
* ldns_dnssec_pkt_has_rrsigs
|
||||
* ldns_dnssec_remove_signatures
|
||||
* ldns_dnssec_trust_tree_add_parent
|
||||
* ldns_dnssec_trust_tree_contains_keys
|
||||
* ldns_dnssec_trust_tree_depth
|
||||
* ldns_dnssec_trust_tree_free
|
||||
* ldns_dnssec_trust_tree_new
|
||||
* ldns_dnssec_trust_tree_print
|
||||
* ldns_dnssec_verify_denial
|
||||
* ldns_dnssec_verify_denial_nsec3
|
||||
* ldns_fetch_valid_domain_keys
|
||||
* ldns_fget_keyword_data
|
||||
* ldns_fget_keyword_data_l
|
||||
* ldns_fget_token
|
||||
* ldns_fget_token_l
|
||||
* ldns_fskipcs
|
||||
* ldns_fskipcs_l
|
||||
* ldns_get_bit
|
||||
* ldns_get_bit_r
|
||||
* ldns_get_errorstr_by_id
|
||||
* ldns_get_rr_class_by_name
|
||||
* ldns_get_rr_list_addr_by_name
|
||||
* ldns_get_rr_list_hosts_frm_file
|
||||
* ldns_get_rr_list_hosts_frm_fp
|
||||
* ldns_get_rr_list_hosts_frm_fp_l
|
||||
* ldns_get_rr_list_name_by_addr
|
||||
* ldns_get_rr_type_by_name
|
||||
* ldns_getaddrinfo
|
||||
* ldns_hexdigit_to_int
|
||||
* ldns_hexstring_to_data
|
||||
* ldns_init_random
|
||||
* ldns_int_to_hexdigit
|
||||
* ldns_is_rrset
|
||||
* ldns_key2buffer_str
|
||||
* ldns_key2rr
|
||||
* ldns_key2str
|
||||
* ldns_lookup_by_id
|
||||
* ldns_lookup_by_name
|
||||
* ldns_native2rdf_int16
|
||||
* ldns_native2rdf_int16_data
|
||||
* ldns_native2rdf_int32
|
||||
* ldns_native2rdf_int8
|
||||
* ldns_nsec3_add_param_rdfs
|
||||
* ldns_nsec3_algorithm
|
||||
* ldns_nsec3_bitmap
|
||||
* ldns_nsec3_flags
|
||||
* ldns_nsec3_hash_name
|
||||
* ldns_nsec3_hash_name_frm_nsec3
|
||||
* ldns_nsec3_iterations
|
||||
* ldns_nsec3_next_owner
|
||||
* ldns_nsec3_optout
|
||||
* ldns_nsec3_salt
|
||||
* ldns_nsec3_salt_data
|
||||
* ldns_nsec3_salt_length
|
||||
* ldns_nsec_bitmap_covers_type
|
||||
* ldns_nsec_covers_name
|
||||
* ldns_nsec_get_bitmap
|
||||
* ldns_nsec_type_check
|
||||
* ldns_octet
|
||||
* ldns_pkt2buffer_str
|
||||
* ldns_pkt2buffer_wire
|
||||
* ldns_pkt2str
|
||||
* ldns_pkt2wire
|
||||
* ldns_pktheader2buffer_str
|
||||
* ldns_power
|
||||
* ldns_print_rr_rdf
|
||||
* ldns_rbtree_create
|
||||
* ldns_rbtree_delete
|
||||
* ldns_rbtree_find_less_equal
|
||||
* ldns_rbtree_first
|
||||
* ldns_rbtree_free
|
||||
* ldns_rbtree_init
|
||||
* ldns_rbtree_insert
|
||||
* ldns_rbtree_insert_vref
|
||||
* ldns_rbtree_last
|
||||
* ldns_rbtree_next
|
||||
* ldns_rbtree_previous
|
||||
* ldns_rbtree_search
|
||||
* ldns_rdf2buffer_str
|
||||
* ldns_rdf2buffer_str_a
|
||||
* ldns_rdf2buffer_str_aaaa
|
||||
* ldns_rdf2buffer_str_alg
|
||||
* ldns_rdf2buffer_str_apl
|
||||
* ldns_rdf2buffer_str_b64
|
||||
* ldns_rdf2buffer_str_cert_alg
|
||||
* ldns_rdf2buffer_str_class
|
||||
* ldns_rdf2buffer_str_dname
|
||||
* ldns_rdf2buffer_str_hex
|
||||
* ldns_rdf2buffer_str_int16
|
||||
* ldns_rdf2buffer_str_int16_data
|
||||
* ldns_rdf2buffer_str_ipseckey
|
||||
* ldns_rdf2buffer_str_loc
|
||||
* ldns_rdf2buffer_str_nsap
|
||||
* ldns_rdf2buffer_str_nsec
|
||||
* ldns_rdf2buffer_str_period
|
||||
* ldns_rdf2buffer_str_str
|
||||
* ldns_rdf2buffer_str_tsig
|
||||
* ldns_rdf2buffer_str_tsigtime
|
||||
* ldns_rdf2buffer_str_type
|
||||
* ldns_rdf2buffer_str_unknown
|
||||
* ldns_rdf2buffer_str_wks
|
||||
* ldns_rdf2buffer_wire
|
||||
* ldns_rdf2buffer_wire_canonical
|
||||
* ldns_rdf2native_int16
|
||||
* ldns_rdf2native_int32
|
||||
* ldns_rdf2native_int8
|
||||
* ldns_rdf2native_sockaddr_storage
|
||||
* ldns_rdf2native_time_t
|
||||
* ldns_rdf2rr_type
|
||||
* ldns_rdf2str
|
||||
* ldns_rdf2wire
|
||||
* ldns_read_anchor_file
|
||||
* ldns_read_uint16
|
||||
* ldns_read_uint32
|
||||
* ldns_rr2buffer_str
|
||||
* ldns_rr2buffer_wire
|
||||
* ldns_rr2buffer_wire_canonical
|
||||
* ldns_rr2canonical
|
||||
* ldns_rr2str
|
||||
* ldns_rr2wire
|
||||
* ldns_rrsig2buffer_wire
|
||||
* ldns_send
|
||||
* ldns_send_buffer
|
||||
* ldns_set_bit
|
||||
* ldns_sign_public
|
||||
* ldns_sockaddr_storage2rdf
|
||||
* ldns_str2period
|
||||
* ldns_str2rdf_a
|
||||
* ldns_str2rdf_aaaa
|
||||
* ldns_str2rdf_alg
|
||||
* ldns_str2rdf_apl
|
||||
* ldns_str2rdf_b32_ext
|
||||
* ldns_str2rdf_b64
|
||||
* ldns_str2rdf_cert_alg
|
||||
* ldns_str2rdf_class
|
||||
* ldns_str2rdf_dname
|
||||
* ldns_str2rdf_hex
|
||||
* ldns_str2rdf_int16
|
||||
* ldns_str2rdf_int32
|
||||
* ldns_str2rdf_int8
|
||||
* ldns_str2rdf_loc
|
||||
* ldns_str2rdf_nsap
|
||||
* ldns_str2rdf_nsec
|
||||
* ldns_str2rdf_nsec3_salt
|
||||
* ldns_str2rdf_period
|
||||
* ldns_str2rdf_service
|
||||
* ldns_str2rdf_str
|
||||
* ldns_str2rdf_time
|
||||
* ldns_str2rdf_tsig
|
||||
* ldns_str2rdf_type
|
||||
* ldns_str2rdf_unknown
|
||||
* ldns_str2rdf_wks
|
||||
* ldns_tcp_bgsend
|
||||
* ldns_tcp_connect
|
||||
* ldns_tcp_read_wire
|
||||
* ldns_tcp_send
|
||||
* ldns_tcp_send_query
|
||||
* ldns_traverse_postorder
|
||||
* ldns_tsig_algorithm
|
||||
* ldns_tsig_keydata
|
||||
* ldns_tsig_keydata_clone
|
||||
* ldns_tsig_keyname
|
||||
* ldns_tsig_keyname_clone
|
||||
* ldns_udp_bgsend
|
||||
* ldns_udp_connect
|
||||
* ldns_udp_read_wire
|
||||
* ldns_udp_send
|
||||
* ldns_udp_send_query
|
||||
* ldns_update_pkt_new
|
||||
* ldns_update_pkt_tsig_add
|
||||
* ldns_update_prcount
|
||||
* ldns_update_set_adcount
|
||||
* ldns_update_set_prcount
|
||||
* ldns_update_set_upcount
|
||||
* ldns_update_soa_mname
|
||||
* ldns_update_soa_zone_mname
|
||||
* ldns_update_upcount
|
||||
* ldns_update_zocount
|
||||
* ldns_validate_domain_dnskey
|
||||
* ldns_validate_domain_ds
|
||||
* ldns_verify
|
||||
* ldns_verify_rrsig
|
||||
* ldns_verify_rrsig_buffers
|
||||
* ldns_verify_rrsig_buffers_raw
|
||||
* ldns_verify_rrsig_dsa
|
||||
* ldns_verify_rrsig_dsa_raw
|
||||
* ldns_verify_rrsig_keylist
|
||||
* ldns_verify_rrsig_rsamd5
|
||||
* ldns_verify_rrsig_rsamd5_raw
|
||||
* ldns_verify_rrsig_rsasha1
|
||||
* ldns_verify_rrsig_rsasha1_raw
|
||||
* ldns_verify_rrsig_rsasha256_raw
|
||||
* ldns_verify_rrsig_rsasha512_raw
|
||||
* ldns_verify_trusted
|
||||
* ldns_version
|
||||
* ldns_wire2dname
|
||||
* ldns_wire2pkt
|
||||
* ldns_wire2rdf
|
||||
* ldns_wire2rr
|
||||
* ldns_write_uint16
|
||||
* ldns_write_uint32
|
||||
* ldns_write_uint64_as_uint48
|
||||
* mktime_from_utc
|
||||
* qsort_rr_compare_nsec3
|
||||
@@ -0,0 +1,11 @@
|
||||
Class ldns_key
|
||||
================================
|
||||
|
||||
|
||||
.. automodule:: ldns
|
||||
|
||||
Class ldns_key
|
||||
------------------------------
|
||||
.. autoclass:: ldns_key
|
||||
:members:
|
||||
:undoc-members:
|
||||
@@ -0,0 +1,11 @@
|
||||
Class ldns_key_list
|
||||
================================
|
||||
|
||||
|
||||
.. automodule:: ldns
|
||||
|
||||
Class ldns_key_list
|
||||
------------------------------
|
||||
.. autoclass:: ldns_key_list
|
||||
:members:
|
||||
:undoc-members:
|
||||
@@ -0,0 +1,11 @@
|
||||
Class ldns_pkt
|
||||
================================
|
||||
|
||||
|
||||
.. automodule:: ldns
|
||||
|
||||
Class ldns_pkt
|
||||
------------------------------
|
||||
.. autoclass:: ldns_pkt
|
||||
:members:
|
||||
:undoc-members:
|
||||
@@ -0,0 +1,47 @@
|
||||
Class ldns_rdf
|
||||
================================
|
||||
|
||||
|
||||
.. automodule:: ldns
|
||||
|
||||
Class ldns_rdf
|
||||
------------------------------
|
||||
.. autoclass:: ldns_rdf
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
Predefined constants
|
||||
------------------------------
|
||||
|
||||
**RDF TYPE**
|
||||
* LDNS_RDF_TYPE_NONE,
|
||||
* LDNS_RDF_TYPE_DNAME,
|
||||
* LDNS_RDF_TYPE_INT8,
|
||||
* LDNS_RDF_TYPE_INT16,
|
||||
* LDNS_RDF_TYPE_INT32,
|
||||
* LDNS_RDF_TYPE_A,
|
||||
* LDNS_RDF_TYPE_AAAA,
|
||||
* LDNS_RDF_TYPE_STR,
|
||||
* LDNS_RDF_TYPE_APL,
|
||||
* LDNS_RDF_TYPE_B32_EXT,
|
||||
* LDNS_RDF_TYPE_B64,
|
||||
* LDNS_RDF_TYPE_HEX,
|
||||
* LDNS_RDF_TYPE_NSEC,
|
||||
* LDNS_RDF_TYPE_TYPE,
|
||||
* LDNS_RDF_TYPE_CLASS,
|
||||
* LDNS_RDF_TYPE_CERT_ALG,
|
||||
* LDNS_RDF_TYPE_ALG,
|
||||
* LDNS_RDF_TYPE_UNKNOWN,
|
||||
* LDNS_RDF_TYPE_TIME,
|
||||
* LDNS_RDF_TYPE_PERIOD,
|
||||
* LDNS_RDF_TYPE_TSIGTIME,
|
||||
* LDNS_RDF_TYPE_TSIG,
|
||||
* LDNS_RDF_TYPE_INT16_DATA,
|
||||
* LDNS_RDF_TYPE_SERVICE,
|
||||
* LDNS_RDF_TYPE_LOC,
|
||||
* LDNS_RDF_TYPE_WKS,
|
||||
* LDNS_RDF_TYPE_NSAP,
|
||||
* LDNS_RDF_TYPE_IPSECKEY,
|
||||
* LDNS_RDF_TYPE_NSEC3_SALT,
|
||||
* LDNS_RDF_TYPE_NSEC3_NEXT_OWNER
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
Class ldns_resolver
|
||||
================================
|
||||
|
||||
.. automodule:: ldns
|
||||
|
||||
Class ldns_resolver
|
||||
------------------------------
|
||||
.. autoclass:: ldns_resolver
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
Class ldns_rr
|
||||
================================
|
||||
|
||||
|
||||
.. automodule:: ldns
|
||||
|
||||
Class ldns_rr
|
||||
------------------------------
|
||||
.. autoclass:: ldns_rr
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
Class ldns_rr_descriptor
|
||||
------------------------------
|
||||
.. autoclass:: ldns_rr_descriptor
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
Class ldns_rr_list
|
||||
================================
|
||||
|
||||
|
||||
.. automodule:: ldns
|
||||
|
||||
Class ldns_rr_list
|
||||
------------------------------
|
||||
.. autoclass:: ldns_rr_list
|
||||
:members:
|
||||
:undoc-members:
|
||||
@@ -0,0 +1,11 @@
|
||||
Class ldns_zone
|
||||
================================
|
||||
|
||||
|
||||
.. automodule:: ldns
|
||||
|
||||
Class ldns_zone
|
||||
------------------------------
|
||||
.. autoclass:: ldns_zone
|
||||
:members:
|
||||
:undoc-members:
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/python
|
||||
# vim:fileencoding=utf-8
|
||||
#
|
||||
# AXFR client with IDN (Internationalized Domain Names) support
|
||||
#
|
||||
|
||||
import ldns
|
||||
import encodings.idna
|
||||
|
||||
def utf2name(name):
|
||||
return '.'.join([encodings.idna.ToASCII(a) for a in name.split('.')])
|
||||
def name2utf(name):
|
||||
return '.'.join([encodings.idna.ToUnicode(a) for a in name.split('.')])
|
||||
|
||||
|
||||
resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
|
||||
|
||||
#addr = ldns.ldns_get_rr_list_addr_by_name(resolver, "zone.nic.cz", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD);
|
||||
addr = resolver.get_addr_by_name("zone.nic.cz", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD);
|
||||
if (not addr):
|
||||
raise Exception("Can't retrieve server address")
|
||||
|
||||
print "Addr_by_name:",str(addr).replace("\n","; ")
|
||||
|
||||
#remove all nameservers
|
||||
while resolver.pop_nameserver():
|
||||
pass
|
||||
|
||||
#insert server addr
|
||||
for rr in addr.rrs():
|
||||
resolver.push_nameserver_rr(rr)
|
||||
|
||||
#AXFR transfer
|
||||
status = resolver.axfr_start(utf2name(u"háčkyčárky.cz"), ldns.LDNS_RR_CLASS_IN)
|
||||
if status != ldns.LDNS_STATUS_OK:
|
||||
raise Exception("Can't start AXFR. Error: %s" % ldns.ldns_get_errorstr_by_id(status))
|
||||
|
||||
#Print results
|
||||
while True:
|
||||
rr = resolver.axfr_next()
|
||||
if not rr:
|
||||
break
|
||||
|
||||
rdf = rr.owner()
|
||||
if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME):
|
||||
print "RDF owner: type=",rdf.get_type_str(),"data=",name2utf(str(rdf))
|
||||
else:
|
||||
print "RDF owner: type=",rdf.get_type_str(),"data=",str(rdf)
|
||||
print " RR type=", rr.get_type_str()," ttl=",rr.ttl()
|
||||
for rdf in rr.rdfs():
|
||||
if (rdf.get_type() == ldns.LDNS_RDF_TYPE_DNAME):
|
||||
print " RDF: type=",rdf.get_type_str(),"data=",name2utf(str(rdf))
|
||||
else:
|
||||
print " RDF: type=",rdf.get_type_str(),"data=",str(rdf)
|
||||
|
||||
print
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import ldns
|
||||
|
||||
buf = ldns.ldns_buffer(1024)
|
||||
buf.printf("Test buffer")
|
||||
print buf
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
import ldns
|
||||
import sys
|
||||
|
||||
debug = True
|
||||
|
||||
# Check args
|
||||
argc = len(sys.argv)
|
||||
name = "www.nic.cz"
|
||||
if argc < 2:
|
||||
print "Usage:", sys.argv[0], "domain [resolver_addr]"
|
||||
sys.exit(1)
|
||||
else:
|
||||
name = sys.argv[1]
|
||||
|
||||
# Create resolver
|
||||
resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
|
||||
resolver.set_dnssec(True)
|
||||
|
||||
# Custom resolver
|
||||
if argc > 2:
|
||||
# Clear previous nameservers
|
||||
ns = resolver.pop_nameserver()
|
||||
while ns != None:
|
||||
ns = resolver.pop_nameserver()
|
||||
ip = ldns.ldns_rdf.new_frm_str(sys.argv[2], ldns.LDNS_RDF_TYPE_A)
|
||||
resolver.push_nameserver(ip)
|
||||
|
||||
# Resolve DNS name
|
||||
pkt = resolver.query(name, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN)
|
||||
if pkt and pkt.answer():
|
||||
|
||||
# Debug
|
||||
if debug:
|
||||
print "NS returned:", pkt.get_rcode(), "(AA: %d AD: %d)" % ( pkt.ad(), pkt.ad() )
|
||||
|
||||
# SERVFAIL indicated bogus name
|
||||
if pkt.get_rcode() is ldns.LDNS_RCODE_SERVFAIL:
|
||||
print name, "is bogus"
|
||||
|
||||
# Check AD (Authenticated) bit
|
||||
if pkt.get_rcode() is ldns.LDNS_RCODE_NOERROR:
|
||||
if pkt.ad(): print name, "is secure"
|
||||
else: print name, "is insecure"
|
||||
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/python
|
||||
import ldns
|
||||
|
||||
resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
|
||||
|
||||
dnn = ldns.ldns_dname("www.google.com")
|
||||
print dnn.get_type_str(), dnn
|
||||
|
||||
dna = ldns.ldns_rdf.new_frm_str("74.125.43.99",ldns.LDNS_RDF_TYPE_A)
|
||||
print dna.get_type_str(), dna
|
||||
|
||||
name = resolver.get_name_by_addr(dna)
|
||||
if (not name): raise Exception("Can't retrieve server name")
|
||||
for rr in name.rrs():
|
||||
print rr
|
||||
|
||||
name = resolver.get_name_by_addr("74.125.43.99")
|
||||
if (not name): raise Exception("Can't retrieve server name")
|
||||
for rr in name.rrs():
|
||||
print rr
|
||||
|
||||
addr = resolver.get_addr_by_name(dnn)
|
||||
if (not addr): raise Exception("Can't retrieve server address")
|
||||
for rr in addr.rrs():
|
||||
print rr
|
||||
|
||||
addr = resolver.get_addr_by_name("www.google.com")
|
||||
if (not addr): raise Exception("Can't retrieve server address")
|
||||
for rr in addr.rrs():
|
||||
print rr
|
||||
|
||||
hosts = ldns.ldns_rr_list.new_frm_file("/etc/hosts")
|
||||
if (not hosts): raise Exception("Can't retrieve the content of file")
|
||||
for rr in hosts.rrs():
|
||||
print rr
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# This example shows how to generate public/private key pair
|
||||
#
|
||||
import ldns
|
||||
|
||||
algorithm = ldns.LDNS_SIGN_DSA
|
||||
bits = 512
|
||||
|
||||
ldns.ldns_init_random(open("/dev/random","rb"), (bits+7)//8)
|
||||
|
||||
domain = ldns.ldns_dname("example.")
|
||||
|
||||
#generate a new key
|
||||
key = ldns.ldns_key.new_frm_algorithm(algorithm, bits);
|
||||
print key
|
||||
|
||||
#set owner
|
||||
key.set_pubkey_owner(domain)
|
||||
|
||||
#create the public from the ldns_key
|
||||
pubkey = key.key_to_rr()
|
||||
#previous command is equivalent to
|
||||
# pubkey = ldns.ldns_key2rr(key)
|
||||
print pubkey
|
||||
|
||||
#calculate and set the keytag
|
||||
key.set_keytag(ldns.ldns_calc_keytag(pubkey))
|
||||
|
||||
#build the DS record
|
||||
ds = ldns.ldns_key_rr2ds(pubkey, ldns.LDNS_SHA1)
|
||||
print ds
|
||||
|
||||
owner, tag = pubkey.owner(), key.keytag()
|
||||
|
||||
#write public key to .key file
|
||||
fw = open("key-%s-%d.key" % (owner,tag), "wb")
|
||||
pubkey.print_to_file(fw)
|
||||
|
||||
#write private key to .priv file
|
||||
fw = open("key-%s-%d.private" % (owner,tag), "wb")
|
||||
key.print_to_file(fw)
|
||||
|
||||
#write DS to .ds file
|
||||
fw = open("key-%s-%d.ds" % (owner,tag), "wb")
|
||||
ds.print_to_file(fw)
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# MX is a small program that prints out the mx records for a particular domain
|
||||
#
|
||||
import ldns
|
||||
|
||||
resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
|
||||
|
||||
pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN)
|
||||
|
||||
if (pkt):
|
||||
mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER)
|
||||
if (mx):
|
||||
mx.sort()
|
||||
print mx
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# MX is a small program that prints out the mx records for a particular domain
|
||||
#
|
||||
import ldns
|
||||
|
||||
dname = ldns.ldns_dname("nic.cz")
|
||||
print dname
|
||||
|
||||
resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
|
||||
|
||||
pkt = resolver.query(dname, ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN)
|
||||
|
||||
if (pkt):
|
||||
mx = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_MX, ldns.LDNS_SECTION_ANSWER)
|
||||
if (mx):
|
||||
mx.sort()
|
||||
print mx
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# MX is a small program that prints out the mx records for a particular domain
|
||||
#
|
||||
import ldns
|
||||
|
||||
resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
|
||||
|
||||
pkt = resolver.query("nic.cz", ldns.LDNS_RR_TYPE_MX,ldns.LDNS_RR_CLASS_IN)
|
||||
if (pkt) and (pkt.answer()):
|
||||
|
||||
for rr in pkt.answer().rrs():
|
||||
if (rr.get_type() != ldns.LDNS_RR_TYPE_MX):
|
||||
continue
|
||||
|
||||
rdf = rr.owner()
|
||||
print rdf," ",rr.ttl()," ",rr.get_class_str()," ",rr.get_type_str()," ",
|
||||
print " ".join(str(rdf) for rdf in rr.rdfs())
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import ldns
|
||||
|
||||
pkt = ldns.ldns_pkt.new_query_frm_str("www.google.com",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA)
|
||||
|
||||
rra = ldns.ldns_rr.new_frm_str("www.google.com. IN A 192.168.1.1",300)
|
||||
rrb = ldns.ldns_rr.new_frm_str("www.google.com. IN TXT Some\ Description",300)
|
||||
|
||||
list = ldns.ldns_rr_list()
|
||||
if (rra): list.push_rr(rra)
|
||||
if (rrb): list.push_rr(rrb)
|
||||
|
||||
pkt.push_rr_list(ldns.LDNS_SECTION_ANSWER, list)
|
||||
|
||||
print "Packet:"
|
||||
print pkt
|
||||
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/python
|
||||
# This example shows how to sign a given zone file with private key
|
||||
|
||||
import ldns
|
||||
import sys, os, time
|
||||
|
||||
#private key TAG which identifies the private key
|
||||
#use ldns-keygen.py in order to obtain private key
|
||||
keytag = 30761
|
||||
|
||||
# Read zone file
|
||||
#-------------------------------------------------------------
|
||||
|
||||
zone = ldns.ldns_zone.new_frm_fp(open("zone.txt","r"), None, 0, ldns.LDNS_RR_CLASS_IN)
|
||||
soa = zone.soa()
|
||||
origin = soa.owner()
|
||||
|
||||
# Prepare keys
|
||||
#-------------------------------------------------------------
|
||||
|
||||
#Read private key from file
|
||||
keyfile = open("key-%s-%d.private" % (origin, keytag), "r");
|
||||
key = ldns.ldns_key.new_frm_fp(keyfile)
|
||||
|
||||
#Read public key from file
|
||||
pubfname = "key-%s-%d.key" % (origin, keytag)
|
||||
pubkey = None
|
||||
if os.path.isfile(pubfname):
|
||||
pubkeyfile = open(pubfname, "r");
|
||||
pubkey,_,_,_ = ldns.ldns_rr.new_frm_fp(pubkeyfile)
|
||||
|
||||
if not pubkey:
|
||||
#Create new public key
|
||||
pubkey = key.key_to_rr()
|
||||
|
||||
#Set key expiration
|
||||
key.set_expiration(int(time.time()) + 365*60*60*24) #365 days
|
||||
|
||||
#Set key owner (important step)
|
||||
key.set_pubkey_owner(origin)
|
||||
|
||||
#Insert DNSKEY RR
|
||||
zone.push_rr(pubkey)
|
||||
|
||||
# Sign zone
|
||||
#-------------------------------------------------------------
|
||||
|
||||
#Create keylist and push private key
|
||||
keys = ldns.ldns_key_list()
|
||||
keys.push_key(key)
|
||||
|
||||
#Add SOA
|
||||
signed_zone = ldns.ldns_dnssec_zone()
|
||||
signed_zone.add_rr(soa)
|
||||
|
||||
#Add RRs
|
||||
for rr in zone.rrs().rrs():
|
||||
print "RR:",str(rr),
|
||||
signed_zone.add_rr(rr)
|
||||
|
||||
added_rrs = ldns.ldns_rr_list()
|
||||
status = signed_zone.sign(added_rrs, keys)
|
||||
if (status == ldns.LDNS_STATUS_OK):
|
||||
signed_zone.print_to_file(open("zone_signed.txt","w"))
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/python
|
||||
import ldns
|
||||
|
||||
#Read zone from file
|
||||
zone = ldns.ldns_zone.new_frm_fp(open("zone.txt","r"), None, 0, ldns.LDNS_RR_CLASS_IN)
|
||||
print zone
|
||||
|
||||
print "SOA:", zone.soa()
|
||||
for r in zone.rrs().rrs():
|
||||
print "RR:", r
|
||||
|
||||
|
||||
zone = ldns.ldns_zone()
|
||||
#print zone
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
$ORIGIN example.
|
||||
$TTL 600
|
||||
|
||||
example. IN SOA example. admin.example. (
|
||||
2008022501 ; serial
|
||||
28800 ; refresh (8 hours)
|
||||
7200 ; retry (2 hours)
|
||||
604800 ; expire (1 week)
|
||||
18000 ; minimum (5 hours)
|
||||
)
|
||||
|
||||
@ IN MX 10 mail.example.
|
||||
@ IN NS ns1
|
||||
@ IN NS ns2
|
||||
@ IN A 192.168.1.1
|
||||
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
* ldns.i: LDNS interface file
|
||||
*
|
||||
* Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
|
||||
* Karel Slany (slany AT fit.vutbr.cz)
|
||||
* 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 the organization 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.
|
||||
*/
|
||||
|
||||
%module ldns
|
||||
%{
|
||||
|
||||
#include "ldns.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <ldns/util.h>
|
||||
#include <ldns/buffer.h>
|
||||
#include <ldns/common.h>
|
||||
#include <ldns/dname.h>
|
||||
#include <ldns/dnssec.h>
|
||||
#include <ldns/dnssec_verify.h>
|
||||
#include <ldns/dnssec_sign.h>
|
||||
#include <ldns/error.h>
|
||||
#include <ldns/higher.h>
|
||||
#include <ldns/host2str.h>
|
||||
#include <ldns/host2wire.h>
|
||||
#include <ldns/net.h>
|
||||
#include <ldns/packet.h>
|
||||
#include <ldns/rdata.h>
|
||||
#include <ldns/resolver.h>
|
||||
#include <ldns/rr.h>
|
||||
#include <ldns/str2host.h>
|
||||
#include <ldns/tsig.h>
|
||||
#include <ldns/update.h>
|
||||
#include <ldns/wire2host.h>
|
||||
#include <ldns/rr_functions.h>
|
||||
#include <ldns/keys.h>
|
||||
#include <ldns/parse.h>
|
||||
#include <ldns/zone.h>
|
||||
#include <ldns/dnssec_zone.h>
|
||||
#include <ldns/rbtree.h>
|
||||
%}
|
||||
|
||||
//#define LDNS_DEBUG
|
||||
|
||||
%include "stdint.i" // uint_16_t is known type now
|
||||
%include "file.i" // FILE *
|
||||
%include "typemaps.i"
|
||||
|
||||
%inline %{
|
||||
struct timeval* ldns_make_timeval(uint32_t sec, uint32_t usec)
|
||||
{
|
||||
struct timeval* res = (struct timeval*)malloc(sizeof(*res));
|
||||
res->tv_sec = sec;
|
||||
res->tv_usec = usec;
|
||||
return res;
|
||||
}
|
||||
uint32_t ldns_read_timeval_sec(struct timeval* t) {
|
||||
return (uint32_t)t->tv_sec; }
|
||||
uint32_t ldns_read_timeval_usec(struct timeval* t) {
|
||||
return (uint32_t)t->tv_usec; }
|
||||
%}
|
||||
|
||||
%immutable ldns_struct_lookup_table::name;
|
||||
%immutable ldns_struct_rr_descriptor::_name;
|
||||
%immutable ldns_error_str;
|
||||
%immutable ldns_signing_algorithms;
|
||||
|
||||
//new_frm_fp_l
|
||||
%apply int *OUTPUT { int *line_nr};
|
||||
%apply uint32_t *OUTPUT { uint32_t *default_ttl};
|
||||
|
||||
%include "ldns_packet.i"
|
||||
%include "ldns_resolver.i"
|
||||
%include "ldns_rr.i"
|
||||
%include "ldns_rdf.i"
|
||||
%include "ldns_zone.i"
|
||||
%include "ldns_key.i"
|
||||
%include "ldns_buffer.i"
|
||||
%include "ldns_dnssec.i"
|
||||
|
||||
%include <ldns/util.h>
|
||||
%include <ldns/buffer.h>
|
||||
%include <ldns/dnssec.h>
|
||||
%include <ldns/dnssec_verify.h>
|
||||
%include <ldns/dnssec_sign.h>
|
||||
%include <ldns/error.h>
|
||||
%include <ldns/higher.h>
|
||||
%include <ldns/host2str.h>
|
||||
%include <ldns/host2wire.h>
|
||||
%include <ldns/net.h>
|
||||
%include <ldns/packet.h>
|
||||
%include <ldns/rdata.h>
|
||||
%include <ldns/resolver.h>
|
||||
%include <ldns/rr.h>
|
||||
%include <ldns/str2host.h>
|
||||
%include <ldns/tsig.h>
|
||||
%include <ldns/update.h>
|
||||
%include <ldns/wire2host.h>
|
||||
%include <ldns/rr_functions.h>
|
||||
%include <ldns/keys.h>
|
||||
%include <ldns/parse.h>
|
||||
%include <ldns/zone.h>
|
||||
%include <ldns/dnssec_zone.h>
|
||||
%include <ldns/rbtree.h>
|
||||
%include <ldns/dname.h>
|
||||
|
||||
typedef struct ldns_dnssec_name { };
|
||||
typedef struct ldns_dnssec_rrs { };
|
||||
typedef struct ldns_dnssec_rrsets { };
|
||||
typedef struct ldns_dnssec_zone { };
|
||||
// ================================================================================
|
||||
|
||||
%include "ldns_dname.i"
|
||||
|
||||
%inline %{
|
||||
PyObject* ldns_rr_new_frm_str_(const char *str, uint32_t default_ttl, ldns_rdf* origin, ldns_rdf* prev)
|
||||
//returns tuple (status, ldns_rr, prev)
|
||||
{
|
||||
PyObject* tuple;
|
||||
|
||||
ldns_rdf *p_prev = prev;
|
||||
ldns_rdf **pp_prev = &p_prev;
|
||||
if (p_prev == 0) pp_prev = 0;
|
||||
|
||||
ldns_rr *p_rr = 0;
|
||||
ldns_rr **pp_rr = &p_rr;
|
||||
|
||||
ldns_status st = ldns_rr_new_frm_str(pp_rr, str, default_ttl, origin, pp_prev);
|
||||
|
||||
tuple = PyTuple_New(3);
|
||||
PyTuple_SetItem(tuple, 0, SWIG_From_int(st));
|
||||
PyTuple_SetItem(tuple, 1, (st == LDNS_STATUS_OK) ?
|
||||
SWIG_NewPointerObj(SWIG_as_voidptr(p_rr), SWIGTYPE_p_ldns_struct_rr, SWIG_POINTER_OWN | 0 ) :
|
||||
Py_None);
|
||||
PyTuple_SetItem(tuple, 2, (p_prev != prev) ?
|
||||
SWIG_NewPointerObj(SWIG_as_voidptr(p_prev), SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0 ) :
|
||||
Py_None);
|
||||
return tuple;
|
||||
}
|
||||
|
||||
PyObject* ldns_rr_new_frm_fp_l_(FILE *fp, uint32_t default_ttl, ldns_rdf* origin, ldns_rdf* prev, int ret_linenr)
|
||||
//returns tuple (status, ldns_rr, [line if ret_linenr], ttl, origin, prev)
|
||||
{
|
||||
int linenr = 0;
|
||||
int *p_linenr = &linenr;
|
||||
|
||||
uint32_t defttl = default_ttl;
|
||||
uint32_t *p_defttl = &defttl;
|
||||
if (defttl == 0) p_defttl = 0;
|
||||
|
||||
ldns_rdf *p_origin = origin;
|
||||
ldns_rdf **pp_origin = &p_origin;
|
||||
if (p_origin == 0) pp_origin = 0;
|
||||
|
||||
ldns_rdf *p_prev = prev;
|
||||
ldns_rdf **pp_prev = &p_prev;
|
||||
if (p_prev == 0) pp_prev = 0;
|
||||
|
||||
ldns_rr *p_rr = 0;
|
||||
ldns_rr **pp_rr = &p_rr;
|
||||
|
||||
ldns_status st = ldns_rr_new_frm_fp_l(pp_rr, fp, p_defttl, pp_origin, pp_prev, p_linenr);
|
||||
|
||||
PyObject* tuple;
|
||||
tuple = PyTuple_New(ret_linenr ? 6 : 5);
|
||||
int idx = 0;
|
||||
PyTuple_SetItem(tuple, idx, SWIG_From_int(st));
|
||||
idx++;
|
||||
PyTuple_SetItem(tuple, idx, (st == LDNS_STATUS_OK) ?
|
||||
SWIG_NewPointerObj(SWIG_as_voidptr(p_rr), SWIGTYPE_p_ldns_struct_rr, SWIG_POINTER_OWN | 0 ) :
|
||||
Py_None);
|
||||
idx++;
|
||||
if (ret_linenr) {
|
||||
PyTuple_SetItem(tuple, idx, SWIG_From_int(linenr));
|
||||
idx++;
|
||||
}
|
||||
PyTuple_SetItem(tuple, idx, (defttl != default_ttl) ? SWIG_From_int(defttl) : Py_None);
|
||||
idx++;
|
||||
PyTuple_SetItem(tuple, idx, (p_origin != origin) ?
|
||||
SWIG_NewPointerObj(SWIG_as_voidptr(p_origin), SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0 ) :
|
||||
Py_None);
|
||||
idx++;
|
||||
PyTuple_SetItem(tuple, idx, (p_prev != prev) ?
|
||||
SWIG_NewPointerObj(SWIG_as_voidptr(p_prev), SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0 ) :
|
||||
Py_None);
|
||||
return tuple;
|
||||
}
|
||||
|
||||
PyObject* ldns_rr_new_question_frm_str_(const char *str, ldns_rdf* origin, ldns_rdf* prev)
|
||||
//returns tuple (status, ldns_rr, prev)
|
||||
{
|
||||
PyObject* tuple;
|
||||
|
||||
ldns_rdf *p_prev = prev;
|
||||
ldns_rdf **pp_prev = &p_prev;
|
||||
if (p_prev == 0) pp_prev = 0;
|
||||
|
||||
ldns_rr *p_rr = 0;
|
||||
ldns_rr **pp_rr = &p_rr;
|
||||
|
||||
ldns_status st = ldns_rr_new_question_frm_str(pp_rr, str, origin, pp_prev);
|
||||
|
||||
tuple = PyTuple_New(3);
|
||||
PyTuple_SetItem(tuple, 0, SWIG_From_int(st));
|
||||
PyTuple_SetItem(tuple, 1, (st == LDNS_STATUS_OK) ?
|
||||
SWIG_NewPointerObj(SWIG_as_voidptr(p_rr), SWIGTYPE_p_ldns_struct_rr, SWIG_POINTER_OWN | 0 ) :
|
||||
Py_None);
|
||||
PyTuple_SetItem(tuple, 2, (p_prev != prev) ?
|
||||
SWIG_NewPointerObj(SWIG_as_voidptr(p_prev), SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0 ) :
|
||||
Py_None);
|
||||
return tuple;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PyObject* ldns_fetch_valid_domain_keys_(const ldns_resolver * res, const ldns_rdf * domain,
|
||||
const ldns_rr_list * keys)
|
||||
//returns tuple (status, result)
|
||||
{
|
||||
PyObject* tuple;
|
||||
|
||||
ldns_rr_list *rrl = 0;
|
||||
ldns_status st = 0;
|
||||
rrl = ldns_fetch_valid_domain_keys(res, domain, keys, &st);
|
||||
|
||||
|
||||
tuple = PyTuple_New(2);
|
||||
PyTuple_SetItem(tuple, 0, SWIG_From_int(st));
|
||||
PyTuple_SetItem(tuple, 1, (st == LDNS_STATUS_OK) ?
|
||||
SWIG_NewPointerObj(SWIG_as_voidptr(rrl), SWIGTYPE_p_ldns_struct_rr_list, SWIG_POINTER_OWN | 0 ) :
|
||||
Py_None);
|
||||
return tuple;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%pythoncode %{
|
||||
def ldns_fetch_valid_domain_keys(res, domain, keys):
|
||||
return _ldns.ldns_fetch_valid_domain_keys_(res, domain, keys)
|
||||
%}
|
||||
|
||||
@@ -0,0 +1,560 @@
|
||||
/******************************************************************************
|
||||
* ldns_buffer.i: LDNS buffer class
|
||||
*
|
||||
* Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
|
||||
* Karel Slany (slany AT fit.vutbr.cz)
|
||||
* 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 the organization 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.
|
||||
******************************************************************************/
|
||||
|
||||
%typemap(in,numinputs=0,noblock=1) (ldns_buffer **)
|
||||
{
|
||||
ldns_buffer *$1_buf;
|
||||
$1 = &$1_buf;
|
||||
}
|
||||
|
||||
/* result generation */
|
||||
%typemap(argout,noblock=1) (ldns_buffer **)
|
||||
{
|
||||
$result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_buf), SWIGTYPE_p_ldns_struct_buffer, SWIG_POINTER_OWN | 0 ));
|
||||
}
|
||||
|
||||
%nodefaultctor ldns_struct_buffer; //no default constructor & destructor
|
||||
%nodefaultdtor ldns_struct_buffer;
|
||||
|
||||
%delobject ldns_buffer_free;
|
||||
%newobject ldns_buffer_new;
|
||||
%newobject ldns_dname_new;
|
||||
%newobject ldns_dname_new_frm_data;
|
||||
%newobject ldns_dname_label;
|
||||
|
||||
%rename(ldns_buffer) ldns_struct_buffer;
|
||||
|
||||
#ifdef LDNS_DEBUG
|
||||
%rename(__ldns_buffer_free) ldns_buffer_free;
|
||||
%inline %{
|
||||
void _ldns_buffer_free (ldns_buffer* b) {
|
||||
printf("******** LDNS_BUFFER free 0x%lX ************\n", (long unsigned int)b);
|
||||
ldns_buffer_free(b);
|
||||
}
|
||||
%}
|
||||
#else
|
||||
%rename(_ldns_buffer_free) ldns_buffer_free;
|
||||
#endif
|
||||
|
||||
%ignore ldns_struct_buffer::_position;
|
||||
%ignore ldns_struct_buffer::_limit;
|
||||
%ignore ldns_struct_buffer::_capacity;
|
||||
%ignore ldns_struct_buffer::_data;
|
||||
%ignore ldns_struct_buffer::_fixed;
|
||||
%ignore ldns_struct_buffer::_status;
|
||||
|
||||
%extend ldns_struct_buffer {
|
||||
|
||||
%pythoncode %{
|
||||
def __init__(self, capacity):
|
||||
"""Creates a new buffer with the specified capacity.
|
||||
|
||||
:param capacity: the size (in bytes) to allocate for the buffer
|
||||
"""
|
||||
self.this = _ldns.ldns_buffer_new(capacity)
|
||||
|
||||
__swig_destroy__ = _ldns._ldns_buffer_free
|
||||
|
||||
def __str__(self):
|
||||
"""Returns the data in the buffer as a string. Buffer data must be char * type."""
|
||||
return _ldns.ldns_buffer2str(self)
|
||||
|
||||
def getc(self):
|
||||
"""returns the next character from a buffer.
|
||||
|
||||
Advances the position pointer with 1. When end of buffer is reached returns EOF. This is the buffer's equivalent for getc().
|
||||
|
||||
:returns: (int) EOF on failure otherwise return the character
|
||||
"""
|
||||
return _ldns.ldns_bgetc(self)
|
||||
|
||||
#LDNS_BUFFER_METHODS_#
|
||||
def at(self,at):
|
||||
"""returns a pointer to the data at the indicated position.
|
||||
|
||||
:param at:
|
||||
position
|
||||
:returns: (uint8_t \*) the pointer to the data
|
||||
"""
|
||||
return _ldns.ldns_buffer_at(self,at)
|
||||
#parameters: const ldns_buffer *,size_t,
|
||||
#retvals: uint8_t *
|
||||
|
||||
def available(self,count):
|
||||
"""checks if the buffer has count bytes available at the current position
|
||||
|
||||
:param count:
|
||||
how much is available
|
||||
:returns: (int) true or false
|
||||
"""
|
||||
return _ldns.ldns_buffer_available(self,count)
|
||||
#parameters: ldns_buffer *,size_t,
|
||||
#retvals: int
|
||||
|
||||
def available_at(self,at,count):
|
||||
"""checks if the buffer has at least COUNT more bytes available.
|
||||
|
||||
Before reading or writing the caller needs to ensure enough space is available!
|
||||
|
||||
:param at:
|
||||
indicated position
|
||||
:param count:
|
||||
how much is available
|
||||
:returns: (int) true or false
|
||||
"""
|
||||
return _ldns.ldns_buffer_available_at(self,at,count)
|
||||
#parameters: ldns_buffer *,size_t,size_t,
|
||||
#retvals: int
|
||||
|
||||
def begin(self):
|
||||
"""returns a pointer to the beginning of the buffer (the data at position 0).
|
||||
|
||||
:returns: (uint8_t \*) the pointer
|
||||
"""
|
||||
return _ldns.ldns_buffer_begin(self)
|
||||
#parameters: const ldns_buffer *,
|
||||
#retvals: uint8_t *
|
||||
|
||||
def capacity(self):
|
||||
"""returns the number of bytes the buffer can hold.
|
||||
|
||||
:returns: (size_t) the number of bytes
|
||||
"""
|
||||
return _ldns.ldns_buffer_capacity(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: size_t
|
||||
|
||||
def clear(self):
|
||||
"""clears the buffer and make it ready for writing.
|
||||
|
||||
The buffer's limit is set to the capacity and the position is set to 0.
|
||||
"""
|
||||
_ldns.ldns_buffer_clear(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals:
|
||||
|
||||
def copy(self,bfrom):
|
||||
"""Copy contents of the other buffer to this buffer.
|
||||
|
||||
Silently truncated if this buffer is too small.
|
||||
|
||||
:param bfrom: other buffer
|
||||
"""
|
||||
_ldns.ldns_buffer_copy(self,bfrom)
|
||||
#parameters: ldns_buffer *,ldns_buffer *,
|
||||
#retvals:
|
||||
|
||||
def current(self):
|
||||
"""returns a pointer to the data at the buffer's current position.
|
||||
|
||||
:returns: (uint8_t \*) the pointer
|
||||
"""
|
||||
return _ldns.ldns_buffer_current(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: uint8_t *
|
||||
|
||||
def end(self):
|
||||
"""returns a pointer to the end of the buffer (the data at the buffer's limit).
|
||||
|
||||
:returns: (uint8_t \*) the pointer
|
||||
"""
|
||||
return _ldns.ldns_buffer_end(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: uint8_t *
|
||||
|
||||
def export(self):
|
||||
"""Makes the buffer fixed and returns a pointer to the data.
|
||||
|
||||
The caller is responsible for free'ing the result.
|
||||
|
||||
:returns: (void \*) void
|
||||
"""
|
||||
return _ldns.ldns_buffer_export(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: void *
|
||||
|
||||
def flip(self):
|
||||
"""makes the buffer ready for reading the data that has been written to the buffer.
|
||||
|
||||
The buffer's limit is set to the current position and the position is set to 0.
|
||||
"""
|
||||
_ldns.ldns_buffer_flip(self)
|
||||
#parameters: ldns_buffer *,
|
||||
|
||||
def invariant(self):
|
||||
_ldns.ldns_buffer_invariant(self)
|
||||
#parameters: ldns_buffer *,
|
||||
|
||||
def limit(self):
|
||||
"""returns the maximum size of the buffer
|
||||
|
||||
:returns: (size_t) the size
|
||||
"""
|
||||
return _ldns.ldns_buffer_limit(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: size_t
|
||||
|
||||
def position(self):
|
||||
"""returns the current position in the buffer (as a number of bytes)
|
||||
|
||||
:returns: (size_t) the current position
|
||||
"""
|
||||
return _ldns.ldns_buffer_position(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: size_t
|
||||
|
||||
def printf(self,*str):
|
||||
"""Prints to the buffer, increasing the capacity if required using buffer_reserve().
|
||||
|
||||
The buffer's position is set to the terminating '\0'. Returns the number of characters written (not including the terminating '\0') or -1 on failure.
|
||||
:param str: a string
|
||||
:returns: (int)
|
||||
"""
|
||||
return _ldns.ldns_buffer_printf(self,*str)
|
||||
#parameters: ldns_buffer *,const char *,...
|
||||
#retvals: int
|
||||
|
||||
def read(self,data,count):
|
||||
"""copies count bytes of data at the current position to the given data-array
|
||||
|
||||
:param data:
|
||||
buffer to copy to
|
||||
:param count:
|
||||
the length of the data to copy
|
||||
"""
|
||||
_ldns.ldns_buffer_read(self,data,count)
|
||||
#parameters: ldns_buffer *,void *,size_t,
|
||||
#retvals:
|
||||
|
||||
def read_at(self,at,data,count):
|
||||
"""copies count bytes of data at the given position to the given data-array
|
||||
|
||||
:param at:
|
||||
the position in the buffer to start
|
||||
:param data:
|
||||
buffer to copy to
|
||||
:param count:
|
||||
the length of the data to copy
|
||||
"""
|
||||
_ldns.ldns_buffer_read_at(self,at,data,count)
|
||||
#parameters: ldns_buffer *,size_t,void *,size_t,
|
||||
#retvals:
|
||||
|
||||
def read_u16(self):
|
||||
"""returns the 2-byte integer value at the current position in the buffer
|
||||
|
||||
:returns: (uint16_t) 2 byte integer
|
||||
"""
|
||||
return _ldns.ldns_buffer_read_u16(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: uint16_t
|
||||
|
||||
def read_u16_at(self,at):
|
||||
"""returns the 2-byte integer value at the given position in the buffer
|
||||
|
||||
:param at:
|
||||
position in the buffer
|
||||
:returns: (uint16_t) 2 byte integer
|
||||
"""
|
||||
return _ldns.ldns_buffer_read_u16_at(self,at)
|
||||
#parameters: ldns_buffer *,size_t,
|
||||
#retvals: uint16_t
|
||||
|
||||
def read_u32(self):
|
||||
"""returns the 4-byte integer value at the current position in the buffer
|
||||
|
||||
:returns: (uint32_t) 4 byte integer
|
||||
"""
|
||||
return _ldns.ldns_buffer_read_u32(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: uint32_t
|
||||
|
||||
def read_u32_at(self,at):
|
||||
"""returns the 4-byte integer value at the given position in the buffer
|
||||
|
||||
:param at:
|
||||
position in the buffer
|
||||
:returns: (uint32_t) 4 byte integer
|
||||
"""
|
||||
return _ldns.ldns_buffer_read_u32_at(self,at)
|
||||
#parameters: ldns_buffer *,size_t,
|
||||
#retvals: uint32_t
|
||||
|
||||
def read_u8(self):
|
||||
"""returns the byte value at the current position in the buffer
|
||||
|
||||
:returns: (uint8_t) 1 byte integer
|
||||
"""
|
||||
return _ldns.ldns_buffer_read_u8(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: uint8_t
|
||||
|
||||
def read_u8_at(self,at):
|
||||
"""returns the byte value at the given position in the buffer
|
||||
|
||||
:param at:
|
||||
the position in the buffer
|
||||
:returns: (uint8_t) 1 byte integer
|
||||
"""
|
||||
return _ldns.ldns_buffer_read_u8_at(self,at)
|
||||
#parameters: ldns_buffer *,size_t,
|
||||
#retvals: uint8_t
|
||||
|
||||
def remaining(self):
|
||||
"""returns the number of bytes remaining between the buffer's position and limit.
|
||||
|
||||
:returns: (size_t) the number of bytes
|
||||
"""
|
||||
return _ldns.ldns_buffer_remaining(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: size_t
|
||||
|
||||
def remaining_at(self,at):
|
||||
"""returns the number of bytes remaining between the indicated position and the limit.
|
||||
|
||||
:param at:
|
||||
indicated position
|
||||
:returns: (size_t) number of bytes
|
||||
"""
|
||||
return _ldns.ldns_buffer_remaining_at(self,at)
|
||||
#parameters: ldns_buffer *,size_t,
|
||||
#retvals: size_t
|
||||
|
||||
def reserve(self,amount):
|
||||
"""ensures BUFFER can contain at least AMOUNT more bytes.
|
||||
|
||||
The buffer's capacity is increased if necessary using buffer_set_capacity().
|
||||
|
||||
The buffer's limit is always set to the (possibly increased) capacity.
|
||||
|
||||
:param amount:
|
||||
amount to use
|
||||
:returns: (bool) whether this failed or succeeded
|
||||
"""
|
||||
return _ldns.ldns_buffer_reserve(self,amount)
|
||||
#parameters: ldns_buffer *,size_t,
|
||||
#retvals: bool
|
||||
|
||||
def rewind(self):
|
||||
"""make the buffer ready for re-reading the data.
|
||||
|
||||
The buffer's position is reset to 0.
|
||||
"""
|
||||
_ldns.ldns_buffer_rewind(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals:
|
||||
|
||||
def set_capacity(self,capacity):
|
||||
"""changes the buffer's capacity.
|
||||
|
||||
The data is reallocated so any pointers to the data may become invalid. The buffer's limit is set to the buffer's new capacity.
|
||||
|
||||
:param capacity:
|
||||
the capacity to use
|
||||
:returns: (bool) whether this failed or succeeded
|
||||
"""
|
||||
return _ldns.ldns_buffer_set_capacity(self,capacity)
|
||||
#parameters: ldns_buffer *,size_t,
|
||||
#retvals: bool
|
||||
|
||||
def set_limit(self,limit):
|
||||
"""changes the buffer's limit.
|
||||
|
||||
If the buffer's position is greater than the new limit the position is set to the limit.
|
||||
|
||||
:param limit:
|
||||
the new limit
|
||||
"""
|
||||
_ldns.ldns_buffer_set_limit(self,limit)
|
||||
#parameters: ldns_buffer *,size_t,
|
||||
#retvals:
|
||||
|
||||
def set_position(self,mark):
|
||||
"""sets the buffer's position to MARK.
|
||||
|
||||
The position must be less than or equal to the buffer's limit.
|
||||
|
||||
:param mark:
|
||||
the mark to use
|
||||
"""
|
||||
_ldns.ldns_buffer_set_position(self,mark)
|
||||
#parameters: ldns_buffer *,size_t,
|
||||
#retvals:
|
||||
|
||||
def skip(self,count):
|
||||
"""changes the buffer's position by COUNT bytes.
|
||||
|
||||
The position must not be moved behind the buffer's limit or before the beginning of the buffer.
|
||||
|
||||
:param count:
|
||||
the count to use
|
||||
"""
|
||||
_ldns.ldns_buffer_skip(self,count)
|
||||
#parameters: ldns_buffer *,ssize_t,
|
||||
#retvals:
|
||||
|
||||
def status(self):
|
||||
"""returns the status of the buffer
|
||||
|
||||
:returns: (ldns_status) the status
|
||||
"""
|
||||
return _ldns.ldns_buffer_status(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: ldns_status
|
||||
|
||||
def status_ok(self):
|
||||
"""returns true if the status of the buffer is LDNS_STATUS_OK, false otherwise
|
||||
|
||||
:returns: (bool) true or false
|
||||
"""
|
||||
return _ldns.ldns_buffer_status_ok(self)
|
||||
#parameters: ldns_buffer *,
|
||||
#retvals: bool
|
||||
|
||||
def write(self,data,count):
|
||||
"""writes count bytes of data to the current position of the buffer
|
||||
|
||||
:param data:
|
||||
the data to write
|
||||
:param count:
|
||||
the lenght of the data to write
|
||||
"""
|
||||
_ldns.ldns_buffer_write(self,data,count)
|
||||
#parameters: ldns_buffer *,const void *,size_t,
|
||||
#retvals:
|
||||
|
||||
def write_at(self,at,data,count):
|
||||
"""writes the given data to the buffer at the specified position
|
||||
|
||||
:param at:
|
||||
the position (in number of bytes) to write the data at
|
||||
:param data:
|
||||
pointer to the data to write to the buffer
|
||||
:param count:
|
||||
the number of bytes of data to write
|
||||
"""
|
||||
_ldns.ldns_buffer_write_at(self,at,data,count)
|
||||
#parameters: ldns_buffer *,size_t,const void *,size_t,
|
||||
#retvals:
|
||||
|
||||
def write_string(self,str):
|
||||
"""copies the given (null-delimited) string to the current position at the buffer
|
||||
|
||||
:param str:
|
||||
the string to write
|
||||
"""
|
||||
_ldns.ldns_buffer_write_string(self,str)
|
||||
#parameters: ldns_buffer *,const char *,
|
||||
#retvals:
|
||||
|
||||
def write_string_at(self,at,str):
|
||||
"""copies the given (null-delimited) string to the specified position at the buffer
|
||||
|
||||
:param at:
|
||||
the position in the buffer
|
||||
:param str:
|
||||
the string to write
|
||||
"""
|
||||
_ldns.ldns_buffer_write_string_at(self,at,str)
|
||||
#parameters: ldns_buffer *,size_t,const char *,
|
||||
#retvals:
|
||||
|
||||
def write_u16(self,data):
|
||||
"""writes the given 2 byte integer at the current position in the buffer
|
||||
|
||||
:param data:
|
||||
the 16 bits to write
|
||||
"""
|
||||
_ldns.ldns_buffer_write_u16(self,data)
|
||||
#parameters: ldns_buffer *,uint16_t,
|
||||
#retvals:
|
||||
|
||||
def write_u16_at(self,at,data):
|
||||
"""writes the given 2 byte integer at the given position in the buffer
|
||||
|
||||
:param at:
|
||||
the position in the buffer
|
||||
:param data:
|
||||
the 16 bits to write
|
||||
"""
|
||||
_ldns.ldns_buffer_write_u16_at(self,at,data)
|
||||
#parameters: ldns_buffer *,size_t,uint16_t,
|
||||
#retvals:
|
||||
|
||||
def write_u32(self,data):
|
||||
"""writes the given 4 byte integer at the current position in the buffer
|
||||
|
||||
:param data:
|
||||
the 32 bits to write
|
||||
"""
|
||||
_ldns.ldns_buffer_write_u32(self,data)
|
||||
#parameters: ldns_buffer *,uint32_t,
|
||||
#retvals:
|
||||
|
||||
def write_u32_at(self,at,data):
|
||||
"""writes the given 4 byte integer at the given position in the buffer
|
||||
|
||||
:param at:
|
||||
the position in the buffer
|
||||
:param data:
|
||||
the 32 bits to write
|
||||
"""
|
||||
_ldns.ldns_buffer_write_u32_at(self,at,data)
|
||||
#parameters: ldns_buffer *,size_t,uint32_t,
|
||||
#retvals:
|
||||
|
||||
def write_u8(self,data):
|
||||
"""writes the given byte of data at the current position in the buffer
|
||||
|
||||
:param data:
|
||||
the 8 bits to write
|
||||
"""
|
||||
_ldns.ldns_buffer_write_u8(self,data)
|
||||
#parameters: ldns_buffer *,uint8_t,
|
||||
#retvals:
|
||||
|
||||
def write_u8_at(self,at,data):
|
||||
"""writes the given byte of data at the given position in the buffer
|
||||
|
||||
:param at:
|
||||
the position in the buffer
|
||||
:param data:
|
||||
the 8 bits to write
|
||||
"""
|
||||
_ldns.ldns_buffer_write_u8_at(self,at,data)
|
||||
#parameters: ldns_buffer *,size_t,uint8_t,
|
||||
#retvals:
|
||||
|
||||
#_LDNS_BUFFER_METHODS#
|
||||
%}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
/******************************************************************************
|
||||
* ldns_dname.i: LDNS domain name class
|
||||
*
|
||||
* Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
|
||||
* Karel Slany (slany AT fit.vutbr.cz)
|
||||
* 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 the organization 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.
|
||||
******************************************************************************/
|
||||
%pythoncode %{
|
||||
class ldns_dname(ldns_rdf):
|
||||
"""Domain name
|
||||
|
||||
This class contains methods to read and manipulate domain names.
|
||||
Domain names are stored in ldns_rdf structures, with the type LDNS_RDF_TYPE_DNAME
|
||||
|
||||
**Usage**
|
||||
|
||||
>>> import ldns
|
||||
>>> resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
|
||||
>>> dn1 = ldns.ldns_dname("test.nic.cz")
|
||||
>>> print dn1
|
||||
test.nic.cz.
|
||||
>>> dn2 = ldns.ldns_dname("nic.cz")
|
||||
>>> if dn2.is_subdomain(dn1): print dn2,"is subdomain of",dn1
|
||||
>>> if dn1.is_subdomain(dn2): print dn1,"is subdomain of",dn2
|
||||
test.nic.cz. is subdomain of nic.cz.
|
||||
"""
|
||||
def __init__(self, str):
|
||||
"""Creates a new dname rdf from a string.
|
||||
|
||||
:parameter str: str string to use
|
||||
"""
|
||||
self.this = _ldns.ldns_dname_new_frm_str(str)
|
||||
|
||||
@staticmethod
|
||||
def new_frm_str(str):
|
||||
"""Creates a new dname rdf instance from a string.
|
||||
|
||||
This static method is equivalent to using of default class constructor.
|
||||
|
||||
:parameter str: str string to use
|
||||
"""
|
||||
return ldns_dname(str)
|
||||
|
||||
def absolute(self):
|
||||
"""Checks whether the given dname string is absolute (i.e. ends with a '.')
|
||||
|
||||
:returns: (bool) True or False
|
||||
"""
|
||||
return self.endswith(".")
|
||||
|
||||
|
||||
def make_canonical(self):
|
||||
"""Put a dname into canonical fmt - ie. lowercase it
|
||||
"""
|
||||
_ldns.ldns_dname2canonical(self)
|
||||
|
||||
def __cmp__(self,other):
|
||||
"""Compares the two dname rdf's according to the algorithm for ordering in RFC4034 Section 6.
|
||||
|
||||
:param other:
|
||||
the second dname rdf to compare
|
||||
:returns: (int) -1 if dname comes before other, 1 if dname comes after other, and 0 if they are equal.
|
||||
"""
|
||||
return _ldns.ldns_dname_compare(self,other)
|
||||
|
||||
def write_to_buffer(self,buffer):
|
||||
"""Copies the dname data to the buffer in wire format.
|
||||
|
||||
:param buffer: buffer to append the result to
|
||||
:returns: (ldns_status) ldns_status
|
||||
"""
|
||||
return _ldns.ldns_dname2buffer_wire(buffer,self)
|
||||
#parameters: ldns_buffer *,const ldns_rdf *,
|
||||
#retvals: ldns_status
|
||||
|
||||
#LDNS_DNAME_METHODS_#
|
||||
|
||||
def cat(self,rd2):
|
||||
"""concatenates rd2 after this dname (rd2 is copied, this dname is modified)
|
||||
|
||||
:param rd2:
|
||||
the rightside
|
||||
:returns: (ldns_status) LDNS_STATUS_OK on success
|
||||
"""
|
||||
return _ldns.ldns_dname_cat(self,rd2)
|
||||
#parameters: ldns_rdf *,ldns_rdf *,
|
||||
#retvals: ldns_status
|
||||
|
||||
def cat_clone(self,rd2):
|
||||
"""concatenates two dnames together
|
||||
|
||||
:param rd2:
|
||||
the rightside
|
||||
:returns: (ldns_rdf \*) a new rdf with leftside/rightside
|
||||
"""
|
||||
return _ldns.ldns_dname_cat_clone(self,rd2)
|
||||
#parameters: const ldns_rdf *,const ldns_rdf *,
|
||||
#retvals: ldns_rdf *
|
||||
|
||||
def interval(self,middle,next):
|
||||
"""check if middle lays in the interval defined by prev and next prev <= middle < next.
|
||||
|
||||
This is usefull for nsec checking
|
||||
|
||||
:param middle:
|
||||
the dname to check
|
||||
:param next:
|
||||
the next dname return 0 on error or unknown, -1 when middle is in the interval, +1 when not
|
||||
:returns: (int)
|
||||
"""
|
||||
return _ldns.ldns_dname_interval(self,middle,next)
|
||||
#parameters: const ldns_rdf *,const ldns_rdf *,const ldns_rdf *,
|
||||
#retvals: int
|
||||
|
||||
def is_subdomain(self,parent):
|
||||
"""Tests wether the name sub falls under parent (i.e. is a subdomain of parent).
|
||||
|
||||
This function will return false if the given dnames are equal.
|
||||
|
||||
:param parent:
|
||||
(ldns_rdf) the parent's name
|
||||
:returns: (bool) true if sub falls under parent, otherwise false
|
||||
"""
|
||||
return _ldns.ldns_dname_is_subdomain(self,parent)
|
||||
#parameters: const ldns_rdf *,const ldns_rdf *,
|
||||
#retvals: bool
|
||||
|
||||
def label(self,labelpos):
|
||||
"""look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME try and retrieve a specific label.
|
||||
|
||||
The labels are numbered starting from 0 (left most).
|
||||
|
||||
:param labelpos:
|
||||
return the label with this number
|
||||
:returns: (ldns_rdf \*) a ldns_rdf* with the label as name or NULL on error
|
||||
"""
|
||||
return _ldns.ldns_dname_label(self,labelpos)
|
||||
#parameters: const ldns_rdf *,uint8_t,
|
||||
#retvals: ldns_rdf *
|
||||
|
||||
def label_count(self):
|
||||
"""count the number of labels inside a LDNS_RDF_DNAME type rdf.
|
||||
|
||||
:returns: (uint8_t) the number of labels
|
||||
"""
|
||||
return _ldns.ldns_dname_label_count(self)
|
||||
#parameters: const ldns_rdf *,
|
||||
#retvals: uint8_t
|
||||
|
||||
def left_chop(self):
|
||||
"""chop one label off the left side of a dname.
|
||||
|
||||
so wwww.nlnetlabs.nl, becomes nlnetlabs.nl
|
||||
|
||||
:returns: (ldns_rdf \*) the remaining dname
|
||||
"""
|
||||
return _ldns.ldns_dname_left_chop(self)
|
||||
#parameters: const ldns_rdf *,
|
||||
#retvals: ldns_rdf *
|
||||
|
||||
def reverse(self):
|
||||
"""Returns a clone of the given dname with the labels reversed.
|
||||
|
||||
:returns: (ldns_rdf \*) clone of the dname with the labels reversed.
|
||||
"""
|
||||
return _ldns.ldns_dname_reverse(self)
|
||||
#parameters: const ldns_rdf *,
|
||||
#retvals: ldns_rdf *
|
||||
|
||||
#_LDNS_DNAME_METHODS#
|
||||
%}
|
||||
|
||||
@@ -0,0 +1,434 @@
|
||||
/******************************************************************************
|
||||
* ldns_dnssec.i: DNSSEC zone, name, rrs
|
||||
*
|
||||
* Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
|
||||
* Karel Slany (slany AT fit.vutbr.cz)
|
||||
* 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 the organization 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.
|
||||
******************************************************************************/
|
||||
%nodefaultctor ldns_dnssec_rrs; //no default constructor & destructor
|
||||
%nodefaultdtor ldns_dnssec_rrs;
|
||||
|
||||
%newobject ldns_dnssec_rrs_new;
|
||||
%delobject ldns_dnssec_rrs_free;
|
||||
|
||||
%extend ldns_dnssec_rrs {
|
||||
%pythoncode %{
|
||||
|
||||
def __init__(self):
|
||||
"""Creates a new entry for 1 pointer to an rr and 1 pointer to the next rrs.
|
||||
|
||||
:returns: (ldns_dnssec_rrs) the allocated data
|
||||
"""
|
||||
self.this = _ldns.ldns_dnssec_rrs_new()
|
||||
if not self.this:
|
||||
raise Exception("Can't create rrs instance")
|
||||
|
||||
__swig_destroy__ = _ldns.ldns_dnssec_rrs_free
|
||||
|
||||
#LDNS_DNSSEC_RRS_METHODS_#
|
||||
def add_rr(self,rr):
|
||||
"""Adds an RR to the list of RRs.
|
||||
|
||||
The list will remain ordered
|
||||
|
||||
:param rr:
|
||||
the RR to add
|
||||
:returns: (ldns_status) LDNS_STATUS_OK on success
|
||||
"""
|
||||
return _ldns.ldns_dnssec_rrs_add_rr(self,rr)
|
||||
#parameters: ldns_dnssec_rrs *,ldns_rr *,
|
||||
#retvals: ldns_status
|
||||
#_LDNS_DNSSEC_RRS_METHODS#
|
||||
%}
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
// DNNSEC RRS
|
||||
// ================================================================================
|
||||
%nodefaultctor ldns_dnssec_rrsets; //no default constructor & destructor
|
||||
%nodefaultdtor ldns_dnssec_rrsets;
|
||||
|
||||
%newobject ldns_dnssec_rrsets_new;
|
||||
%delobject ldns_dnssec_rrsets_free;
|
||||
|
||||
%extend ldns_dnssec_rrsets {
|
||||
%pythoncode %{
|
||||
def __init__(self):
|
||||
"""Creates a new list (entry) of RRsets.
|
||||
|
||||
:returns: (ldns_dnssec_rrsets \*) instance
|
||||
"""
|
||||
self.this = _ldns.ldns_dnssec_rrsets_new()
|
||||
if not self.this:
|
||||
raise Exception("Can't create rrsets instance")
|
||||
|
||||
__swig_destroy__ = _ldns.ldns_dnssec_rrsets_free
|
||||
|
||||
def print_to_file(self, file, follow):
|
||||
"""Print the given list of rrsets to the given file descriptor.
|
||||
|
||||
:param file: file pointer
|
||||
:param follow: if set to false, only print the first RRset
|
||||
"""
|
||||
_ldns.ldns_dnssec_rrsets_print(file,self,follow)
|
||||
#parameters: FILE *,ldns_dnssec_rrsets *,bool,
|
||||
#retvals:
|
||||
|
||||
#LDNS_DNSSEC_RRSETS_METHODS_#
|
||||
def add_rr(self,rr):
|
||||
"""Add an ldns_rr to the corresponding RRset in the given list of RRsets.
|
||||
|
||||
If it is not present, add it as a new RRset with 1 record.
|
||||
|
||||
:param rr:
|
||||
the rr to add to the list of rrsets
|
||||
:returns: (ldns_status) LDNS_STATUS_OK on success
|
||||
"""
|
||||
return _ldns.ldns_dnssec_rrsets_add_rr(self,rr)
|
||||
#parameters: ldns_dnssec_rrsets *,ldns_rr *,
|
||||
#retvals: ldns_status
|
||||
|
||||
def set_type(self,atype):
|
||||
"""Sets the RR type of the rrset (that is head of the given list).
|
||||
|
||||
:param atype:
|
||||
:returns: (ldns_status) LDNS_STATUS_OK on success
|
||||
"""
|
||||
return _ldns.ldns_dnssec_rrsets_set_type(self,atype)
|
||||
#parameters: ldns_dnssec_rrsets *,ldns_rr_type,
|
||||
#retvals: ldns_status
|
||||
|
||||
def type(self):
|
||||
"""Returns the rr type of the rrset (that is head of the given list).
|
||||
|
||||
:returns: (ldns_rr_type) the rr type
|
||||
"""
|
||||
return _ldns.ldns_dnssec_rrsets_type(self)
|
||||
#parameters: ldns_dnssec_rrsets *,
|
||||
#retvals: ldns_rr_type
|
||||
#_LDNS_DNSSEC_RRSETS_METHODS#
|
||||
%}
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
// DNNSEC NAME
|
||||
// ================================================================================
|
||||
%nodefaultctor ldns_dnssec_name; //no default constructor & destructor
|
||||
%nodefaultdtor ldns_dnssec_name;
|
||||
|
||||
%newobject ldns_dnssec_name_new;
|
||||
%delobject ldns_dnssec_name_free;
|
||||
|
||||
%extend ldns_dnssec_name {
|
||||
%pythoncode %{
|
||||
def __init__(self):
|
||||
"""Create a new instance of dnssec name."""
|
||||
self.this = _ldns.ldns_dnssec_name_new()
|
||||
if not self.this:
|
||||
raise Exception("Can't create dnssec name instance")
|
||||
|
||||
__swig_destroy__ = _ldns.ldns_dnssec_name_free
|
||||
|
||||
def print_to_file(self,file):
|
||||
"""Prints the RRs in the dnssec name structure to the given file descriptor.
|
||||
|
||||
:param file: file pointer
|
||||
"""
|
||||
_ldns.ldns_dnssec_name_print(file, self)
|
||||
#parameters: FILE *,ldns_dnssec_name *,
|
||||
|
||||
@staticmethod
|
||||
def new_frm_rr(raiseException=True):
|
||||
"""Create a new instace of dnssec name for the given RR.
|
||||
|
||||
:returns: (ldns_dnssec_name) instance
|
||||
"""
|
||||
name = _ldns.ldns_dnssec_name_new_frm_rr(self)
|
||||
if (not name) and (raiseException):
|
||||
raise Exception("Can't create dnssec name")
|
||||
return name
|
||||
|
||||
#LDNS_DNSSEC_NAME_METHODS_#
|
||||
def add_rr(self,rr):
|
||||
"""Inserts the given rr at the right place in the current dnssec_name No checking is done whether the name matches.
|
||||
|
||||
:param rr:
|
||||
The RR to add
|
||||
:returns: (ldns_status) LDNS_STATUS_OK on success, error code otherwise
|
||||
"""
|
||||
return _ldns.ldns_dnssec_name_add_rr(self,rr)
|
||||
#parameters: ldns_dnssec_name *,ldns_rr *,
|
||||
#retvals: ldns_status
|
||||
|
||||
def find_rrset(self,atype):
|
||||
"""Find the RRset with the given type in within this name structure.
|
||||
|
||||
:param atype:
|
||||
:returns: (ldns_dnssec_rrsets \*) the RRset, or NULL if not present
|
||||
"""
|
||||
return _ldns.ldns_dnssec_name_find_rrset(self,atype)
|
||||
#parameters: ldns_dnssec_name *,ldns_rr_type,
|
||||
#retvals: ldns_dnssec_rrsets *
|
||||
|
||||
def name(self):
|
||||
"""Returns the domain name of the given dnssec_name structure.
|
||||
|
||||
:returns: (ldns_rdf \*) the domain name
|
||||
"""
|
||||
return _ldns.ldns_dnssec_name_name(self)
|
||||
#parameters: ldns_dnssec_name *,
|
||||
#retvals: ldns_rdf *
|
||||
|
||||
def set_name(self,dname):
|
||||
"""Sets the domain name of the given dnssec_name structure.
|
||||
|
||||
:param dname:
|
||||
the domain name to set it to. This data is *not* copied.
|
||||
"""
|
||||
_ldns.ldns_dnssec_name_set_name(self,dname)
|
||||
#parameters: ldns_dnssec_name *,ldns_rdf *,
|
||||
#retvals:
|
||||
|
||||
def set_nsec(self,nsec):
|
||||
"""Sets the NSEC(3) RR of the given dnssec_name structure.
|
||||
|
||||
:param nsec:
|
||||
the nsec rr to set it to. This data is *not* copied.
|
||||
"""
|
||||
_ldns.ldns_dnssec_name_set_nsec(self,nsec)
|
||||
#parameters: ldns_dnssec_name *,ldns_rr *,
|
||||
#retvals:
|
||||
#_LDNS_DNSSEC_NAME_METHODS#
|
||||
%}
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
// DNNSEC ZONE
|
||||
// ================================================================================
|
||||
%nodefaultctor ldns_dnssec_zone; //no default constructor & destructor
|
||||
%nodefaultdtor ldns_dnssec_zone;
|
||||
|
||||
%newobject ldns_dnssec_zone_new;
|
||||
%delobject ldns_dnssec_zone_free;
|
||||
|
||||
%inline %{
|
||||
ldns_status ldns_dnssec_zone_sign_defcb(ldns_dnssec_zone *zone, ldns_rr_list *new_rrs, ldns_key_list *key_list, int cbtype)
|
||||
{
|
||||
if (cbtype == 0)
|
||||
return ldns_dnssec_zone_sign(zone, new_rrs, key_list, ldns_dnssec_default_add_to_signatures, NULL);
|
||||
if (cbtype == 1)
|
||||
return ldns_dnssec_zone_sign(zone, new_rrs, key_list, ldns_dnssec_default_leave_signatures, NULL);
|
||||
if (cbtype == 2)
|
||||
return ldns_dnssec_zone_sign(zone, new_rrs, key_list, ldns_dnssec_default_delete_signatures, NULL);
|
||||
|
||||
return ldns_dnssec_zone_sign(zone, new_rrs, key_list, ldns_dnssec_default_replace_signatures, NULL);
|
||||
}
|
||||
%}
|
||||
|
||||
%extend ldns_dnssec_zone {
|
||||
%pythoncode %{
|
||||
|
||||
def __init__(self):
|
||||
"""Creates a new dnssec_zone instance"""
|
||||
self.this = _ldns.ldns_dnssec_zone_new()
|
||||
if not self.this:
|
||||
raise Exception("Can't create dnssec zone instance")
|
||||
|
||||
__swig_destroy__ = _ldns.ldns_dnssec_zone_free
|
||||
|
||||
def print_to_file(self,file):
|
||||
"""Prints the complete zone to the given file descriptor.
|
||||
|
||||
:param file: file pointer
|
||||
"""
|
||||
_ldns.ldns_dnssec_zone_print(file, self)
|
||||
#parameters: FILE *, ldns_dnssec_zone *,
|
||||
#retvals:
|
||||
|
||||
def create_nsec3s(self,new_rrs,algorithm,flags,iterations,salt_length,salt):
|
||||
"""Adds NSEC3 records to the zone.
|
||||
|
||||
:param new_rrs:
|
||||
:param algorithm:
|
||||
:param flags:
|
||||
:param iterations:
|
||||
:param salt_length:
|
||||
:param salt:
|
||||
:returns: (ldns_status)
|
||||
"""
|
||||
return _ldns.ldns_dnssec_zone_create_nsec3s(self,new_rrs,algorithm,flags,iterations,salt_length,salt)
|
||||
#parameters: ldns_dnssec_zone *,ldns_rr_list *,uint8_t,uint8_t,uint16_t,uint8_t,uint8_t *,
|
||||
#retvals: ldns_status
|
||||
|
||||
def create_nsecs(self,new_rrs):
|
||||
"""Adds NSEC records to the given dnssec_zone.
|
||||
|
||||
:param new_rrs:
|
||||
ldns_rr's created by this function are added to this rr list, so the caller can free them later
|
||||
:returns: (ldns_status) LDNS_STATUS_OK on success, an error code otherwise
|
||||
"""
|
||||
return _ldns.ldns_dnssec_zone_create_nsecs(self,new_rrs)
|
||||
#parameters: ldns_dnssec_zone *,ldns_rr_list *,
|
||||
#retvals: ldns_status
|
||||
|
||||
def create_rrsigs(self,new_rrs,key_list,func,arg):
|
||||
"""Adds signatures to the zone.
|
||||
|
||||
:param new_rrs:
|
||||
the RRSIG RRs that are created are also added to this list, so the caller can free them later
|
||||
:param key_list:
|
||||
list of keys to sign with.
|
||||
:param func:
|
||||
Callback function to decide what keys to use and what to do with old signatures
|
||||
:param arg:
|
||||
Optional argument for the callback function
|
||||
:returns: (ldns_status) LDNS_STATUS_OK on success, error otherwise
|
||||
"""
|
||||
return _ldns.ldns_dnssec_zone_create_rrsigs(self,new_rrs,key_list,func,arg)
|
||||
#parameters: ldns_dnssec_zone *,ldns_rr_list *,ldns_key_list *,int(*)(ldns_rr *, void *),void *,
|
||||
#retvals: ldns_status
|
||||
|
||||
def sign_cb(self,new_rrs,key_list,func,arg):
|
||||
"""signs the given zone with the given keys (with callback function)
|
||||
|
||||
:param new_rrs:
|
||||
newly created resource records are added to this list, to free them later
|
||||
:param key_list:
|
||||
the list of keys to sign the zone with
|
||||
:param func:
|
||||
callback function that decides what to do with old signatures.
|
||||
This function takes an ldns_rr and an optional arg argument, and returns one of four values:
|
||||
|
||||
* LDNS_SIGNATURE_LEAVE_ADD_NEW - leave the signature and add a new one for the corresponding key
|
||||
|
||||
* LDNS_SIGNATURE_REMOVE_ADD_NEW - remove the signature and replace is with a new one from the same key
|
||||
|
||||
* LDNS_SIGNATURE_LEAVE_NO_ADD - leave the signature and do not add a new one with the corresponding key
|
||||
|
||||
* LDNS_SIGNATURE_REMOVE_NO_ADD - remove the signature and do not replace
|
||||
|
||||
:param arg:
|
||||
optional argument for the callback function
|
||||
:returns: (ldns_status) LDNS_STATUS_OK on success, an error code otherwise
|
||||
"""
|
||||
return _ldns.ldns_dnssec_zone_sign(self,new_rrs,key_list,func,arg)
|
||||
#parameters: ldns_dnssec_zone *,ldns_rr_list *,ldns_key_list *,int(*)(ldns_rr *, void *),void *,
|
||||
#retvals: ldns_status
|
||||
|
||||
def sign(self,new_rrs,key_list, cbtype=3):
|
||||
"""signs the given zone with the given keys
|
||||
|
||||
:param new_rrs:
|
||||
newly created resource records are added to this list, to free them later
|
||||
:param key_list:
|
||||
the list of keys to sign the zone with
|
||||
:param cb_type:
|
||||
specifies how to deal with old signatures, possible values:
|
||||
|
||||
* 0 - ldns_dnssec_default_add_to_signatures,
|
||||
|
||||
* 1 - ldns_dnssec_default_leave_signatures,
|
||||
|
||||
* 2 - ldns_dnssec_default_delete_signatures,
|
||||
|
||||
* 3 - ldns_dnssec_default_replace_signatures
|
||||
|
||||
:returns: (ldns_status) LDNS_STATUS_OK on success, an error code otherwise
|
||||
"""
|
||||
return _ldns.ldns_dnssec_zone_sign_defcb(self,new_rrs,key_list, cbtype)
|
||||
#parameters: ldns_dnssec_zone *,ldns_rr_list *,ldns_key_list *,
|
||||
#retvals: ldns_status
|
||||
|
||||
def sign_nsec3(self,new_rrs,key_list,func,arg,algorithm,flags,iterations,salt_length,salt):
|
||||
"""signs the given zone with the given new zone, with NSEC3
|
||||
|
||||
:param new_rrs:
|
||||
newly created resource records are added to this list, to free them later
|
||||
:param key_list:
|
||||
the list of keys to sign the zone with
|
||||
:param func:
|
||||
callback function that decides what to do with old signatures
|
||||
:param arg:
|
||||
optional argument for the callback function
|
||||
:param algorithm:
|
||||
the NSEC3 hashing algorithm to use
|
||||
:param flags:
|
||||
NSEC3 flags
|
||||
:param iterations:
|
||||
the number of NSEC3 hash iterations to use
|
||||
:param salt_length:
|
||||
the length (in octets) of the NSEC3 salt
|
||||
:param salt:
|
||||
the NSEC3 salt data
|
||||
:returns: (ldns_status) LDNS_STATUS_OK on success, an error code otherwise
|
||||
"""
|
||||
return _ldns.ldns_dnssec_zone_sign_nsec3(self,new_rrs,key_list,func,arg,algorithm,flags,iterations,salt_length,salt)
|
||||
#parameters: ldns_dnssec_zone *,ldns_rr_list *,ldns_key_list *,int(*)(ldns_rr *, void *),void *,uint8_t,uint8_t,uint16_t,uint8_t,uint8_t *,
|
||||
#retvals: ldns_status
|
||||
|
||||
#LDNS_DNSSEC_ZONE_METHODS_#
|
||||
def add_empty_nonterminals(self):
|
||||
"""Adds explicit dnssec_name structures for the empty nonterminals in this zone.
|
||||
|
||||
(this is needed for NSEC3 generation)
|
||||
|
||||
:returns: (ldns_status)
|
||||
"""
|
||||
return _ldns.ldns_dnssec_zone_add_empty_nonterminals(self)
|
||||
#parameters: ldns_dnssec_zone *,
|
||||
#retvals: ldns_status
|
||||
|
||||
def add_rr(self,rr):
|
||||
"""Adds the given RR to the zone.
|
||||
|
||||
It find whether there is a dnssec_name with that name present.
|
||||
If so, add it to that, if not create a new one.
|
||||
Special handling of NSEC and RRSIG provided.
|
||||
|
||||
:param rr:
|
||||
The RR to add
|
||||
:returns: (ldns_status) LDNS_STATUS_OK on success, an error code otherwise
|
||||
"""
|
||||
return _ldns.ldns_dnssec_zone_add_rr(self,rr)
|
||||
#parameters: ldns_dnssec_zone *,ldns_rr *,
|
||||
#retvals: ldns_status
|
||||
|
||||
def find_rrset(self,dname,atype):
|
||||
"""Find the RRset with the given name and type in the zone.
|
||||
|
||||
:param dname:
|
||||
the domain name of the RRset to find
|
||||
:param atype:
|
||||
:returns: (ldns_dnssec_rrsets \*) the RRset, or NULL if not present
|
||||
"""
|
||||
return _ldns.ldns_dnssec_zone_find_rrset(self,dname,atype)
|
||||
#parameters: ldns_dnssec_zone *,ldns_rdf *,ldns_rr_type,
|
||||
#retvals: ldns_dnssec_rrsets *
|
||||
|
||||
#_LDNS_DNSSEC_ZONE_METHODS#
|
||||
%}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user