AROS changes
This commit is contained in:
parent
42c7b62b68
commit
8d0262b446
|
@ -0,0 +1,3 @@
|
|||
Makefile
|
||||
*.o
|
||||
*.kdev4
|
26
Makefile
26
Makefile
|
@ -1,26 +0,0 @@
|
|||
# Portable Makefile generated by configure
|
||||
|
||||
all: dnstracer
|
||||
|
||||
CC = m68k-amigaos-gcc
|
||||
CFLAGS = -O2 -noixemul -DAOS3 -I. -I.. -Iinclude -Wall -Werror
|
||||
LDLIBS = -liberty -lm
|
||||
|
||||
config.h: inet_getaddrinfo.h
|
||||
touch config.h
|
||||
|
||||
dnstracer.o: dnstracer.c config.h dnstracer_broken.h
|
||||
|
||||
dnstracer_amiga.o: dnstracer_amiga.c config.h
|
||||
|
||||
inet_getaddrinfo.o: inet_getaddrinfo.c config.h inet_getaddrinfo.h
|
||||
|
||||
|
||||
dnstracer: dnstracer.o dnstracer_amiga.o inet_getaddrinfo.o
|
||||
${CC} ${CFLAGS} -s -o dnstracer dnstracer.o dnstracer_amiga.o inet_getaddrinfo.o ${LDLIBS}
|
||||
|
||||
clean:
|
||||
rm -f dnstracer.o dnstracer_amiga.o inet_getaddrinfo.o dnstracer
|
||||
|
||||
depend:
|
||||
@echo Dependencies already done
|
|
@ -0,0 +1,35 @@
|
|||
# Portable Makefile generated by configure
|
||||
|
||||
all: dnstracer
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -O2 -DAROS -I. -Iinclude -Wall -Werror
|
||||
LDLIBS = -lm
|
||||
|
||||
dnstracer.h: mem.h
|
||||
touch dnstracer.h
|
||||
|
||||
getaddrinfo.h: dnstracer.h
|
||||
touch getaddrinfo.h
|
||||
|
||||
dnstracer.o: dnstracer.c dnstracer_broken.h dnstracer.h getaddrinfo.h mem.h
|
||||
|
||||
dnstracer_amiga.o: dnstracer_amiga.c dnstracer.h getaddrinfo.h
|
||||
|
||||
getaddrinfo.o: getaddrinfo.c dnstracer.h getaddrinfo.h
|
||||
|
||||
getopt.o: getopt.c getopt.h
|
||||
|
||||
rand.o: rand.c
|
||||
|
||||
mem.o: mem.c mem.h
|
||||
|
||||
|
||||
dnstracer: dnstracer.o dnstracer_amiga.o getaddrinfo.o getopt.o rand.o mem.o
|
||||
${CC} ${CFLAGS} -s -o dnstracer dnstracer.o dnstracer_amiga.o getaddrinfo.o getopt.o rand.o mem.o ${LDLIBS}
|
||||
|
||||
clean:
|
||||
rm -f dnstracer.o dnstracer_amiga.o getaddrinfo.o getopt.o rand.o mem.o dnstracer
|
||||
|
||||
depend:
|
||||
@echo Dependencies already done
|
|
@ -0,0 +1,35 @@
|
|||
# Portable Makefile generated by configure
|
||||
|
||||
all: dnstracer
|
||||
|
||||
CC = m68k-amigaos-gcc
|
||||
CFLAGS = -O2 -noixemul -DAOS3 -D_DEBUG -I. -I.. -Iinclude -Wall -Werror
|
||||
LDLIBS = -lm
|
||||
|
||||
dnstracer.h: mem.h
|
||||
touch dnstracer.h
|
||||
|
||||
getaddrinfo.h: dnstracer.h
|
||||
touch getaddrinfo.h
|
||||
|
||||
dnstracer.o: dnstracer.c dnstracer_broken.h dnstracer.h getaddrinfo.h mem.h
|
||||
|
||||
dnstracer_amiga.o: dnstracer_amiga.c dnstracer.h getaddrinfo.h
|
||||
|
||||
getaddrinfo.o: getaddrinfo.c dnstracer.h getaddrinfo.h
|
||||
|
||||
getopt.o: getopt.c getopt.h
|
||||
|
||||
rand.o: rand.c
|
||||
|
||||
mem.o: mem.c mem.h
|
||||
|
||||
|
||||
dnstracer: dnstracer.o dnstracer_amiga.o getaddrinfo.o getopt.o rand.o mem.o
|
||||
${CC} ${CFLAGS} -s -o dnstracer dnstracer.o dnstracer_amiga.o getaddrinfo.o getopt.o rand.o mem.o ${LDLIBS}
|
||||
|
||||
clean:
|
||||
rm -f dnstracer.o dnstracer_amiga.o getaddrinfo.o getopt.o rand.o mem.o dnstracer
|
||||
|
||||
depend:
|
||||
@echo Dependencies already done
|
100
config.h
100
config.h
|
@ -1,100 +0,0 @@
|
|||
/* config.h. Generated by configure. */
|
||||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the `gethostbyname' function. */
|
||||
#define HAVE_GETHOSTBYNAME 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#define HAVE_NETDB_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <resolv.h> header file. */
|
||||
#define HAVE_RESOLV_H 1
|
||||
|
||||
/* Define to 1 if you have the `select' function. */
|
||||
#define HAVE_SELECT 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#define HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#define HAVE_STRCHR 1
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#define HAVE_SYS_PARAM_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "DNS Tracer"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.9"
|
||||
|
||||
/* Define to 1 if your processor stores words with the most significant byte
|
||||
first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
#define WORDS_BIGENDIAN 1
|
||||
|
||||
#define NOIPV6 1
|
||||
struct sockaddr_in6;
|
||||
|
||||
#ifndef PF_INET6
|
||||
#define PF_INET6 10 /* IP version 6. */
|
||||
#endif
|
||||
|
||||
#ifndef AF_INET6
|
||||
#define AF_INET6 PF_INET6
|
||||
#endif
|
||||
|
||||
int open_libs();
|
||||
extern struct Library *SocketBase;
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#ifdef AOS3
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/amitcp_protos.h>
|
||||
#endif
|
||||
|
||||
#include "inet_getaddrinfo.h"
|
|
@ -29,14 +29,19 @@
|
|||
set -e
|
||||
|
||||
HDRS='
|
||||
config.h
|
||||
inet_getaddrinfo.h
|
||||
dnstracer.h
|
||||
getaddrinfo.h
|
||||
getopt.h
|
||||
mem.h
|
||||
'
|
||||
|
||||
SRCS='
|
||||
dnstracer.c
|
||||
dnstracer_amiga.c
|
||||
inet_getaddrinfo.c
|
||||
getaddrinfo.c
|
||||
getopt.c
|
||||
rand.c
|
||||
mem.c
|
||||
'
|
||||
|
||||
if make -v 2>&1 | grep GNU > /dev/null 2>&1 ; then
|
||||
|
@ -53,10 +58,13 @@ if $VALID ; then
|
|||
echo ''
|
||||
echo 'all: dnstracer'
|
||||
echo ''
|
||||
if [ -n "$2" ] && [ $2 = "DEBUG" ] ; then
|
||||
DEBUG="-D_DEBUG "
|
||||
fi
|
||||
if [ -n "$1" ] && [ $1 = "AMIGA" ] ; then
|
||||
echo 'CC = m68k-amigaos-gcc'
|
||||
echo "CFLAGS = -O2 -noixemul -DAOS3 -I. -I.. -Iinclude -Wall -Werror"
|
||||
echo "LDLIBS = -liberty -lm"
|
||||
echo "CFLAGS = -O2 -noixemul -DAOS3 ${DEBUG}-I. -I.. -Iinclude -Wall -Werror"
|
||||
echo "LDLIBS = -lm"
|
||||
elif [ -n "$1" ] && [ $1 = "AROS" ] ; then
|
||||
echo 'CC = gcc'
|
||||
echo "CFLAGS = -O2 -DAROS -I. -Iinclude -Wall -Werror"
|
||||
|
|
125
dnstracer.c
125
dnstracer.c
|
@ -1,8 +1,5 @@
|
|||
//
|
||||
// $Id: dnstracer.c, v 1.48 2004/07/08 11:15:17 mavetju Exp $
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (c) 2016 by Carsten Larsen
|
||||
// Copyright (c) 2002 by Edwin Groothuis, edwin@mavetju.org.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -29,6 +26,11 @@
|
|||
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
//
|
||||
// Original file version:
|
||||
// $Id: dnstracer.c, v 1.48 2004/07/08 11:15:17 mavetju Exp $
|
||||
//
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/param.h>
|
||||
|
@ -37,7 +39,6 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
@ -45,15 +46,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "dnstracer.h"
|
||||
#include "dnstracer_broken.h"
|
||||
#include "config.h"
|
||||
|
||||
#define DEFAULT_RETRIES 3
|
||||
#define DEFAULT_CACHING 1
|
||||
#define DEFAULT_NEGATIVE_CACHING 0
|
||||
#define DEFAULT_OVERVIEW 0
|
||||
#define DEFAULT_QUERYTYPE ns_t_a
|
||||
#define DEFAULT_NOIPV6 0
|
||||
#include "getaddrinfo.h"
|
||||
#include "mem.h"
|
||||
|
||||
#ifdef NOIPV6
|
||||
#define gethostbyname2(a, b) gethostbyname(a)
|
||||
|
@ -206,6 +202,8 @@ char *rr_types[256] = {
|
|||
char *get_resource(int type, struct dnssession *session, char *buffer, int dots);
|
||||
char *printablename(char *name, int withdots);
|
||||
|
||||
unsigned int debugging = 0;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
//
|
||||
|
@ -231,15 +229,17 @@ strnrcasecmp(const char *big, const char *little, size_t len)
|
|||
}
|
||||
|
||||
unsigned int
|
||||
getlong(unsigned char *s)
|
||||
getlong(char *s)
|
||||
{
|
||||
return 256*256*256*s[0] + 256*256*s[1] + 256*s[2] + s[3];
|
||||
unsigned char *t = (unsigned char*)s;
|
||||
return 256*256*256*t[0] + 256*256*t[1] + 256*t[2] + t[3];
|
||||
}
|
||||
|
||||
unsigned short
|
||||
getshort(unsigned char *s)
|
||||
getshort(char *s)
|
||||
{
|
||||
return 256*s[0] + s[1];
|
||||
unsigned char *t = (unsigned char*)s;
|
||||
return 256*t[0] + t[1];
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -321,8 +321,8 @@ extract_rr(struct dnssession *session, char *thisrr, struct dnsrr **rr)
|
|||
// into data_string.
|
||||
//
|
||||
domainname = getname(session, &thisrr);
|
||||
RR->domainname = strdup(domainname);
|
||||
RR->domainname_string = strdup(printablename(domainname, 1));
|
||||
RR->domainname = (unsigned char*)strdup(domainname);
|
||||
RR->domainname_string = (unsigned char*)strdup(printablename(domainname, 1));
|
||||
RR->type = getshort(thisrr);
|
||||
RR->class = getshort(thisrr + 2);
|
||||
RR->ttl = getlong(thisrr + 4);
|
||||
|
@ -331,7 +331,7 @@ extract_rr(struct dnssession *session, char *thisrr, struct dnsrr **rr)
|
|||
memcpy(RR->data, thisrr + 10, RR->datalength);
|
||||
|
||||
p = thisrr + 10;
|
||||
RR->data_string = strdup(get_resource(RR->type, session, p, 1));
|
||||
RR->data_string = (unsigned char*)strdup(get_resource(RR->type, session, p, 1));
|
||||
thisrr += 10 + RR->datalength;
|
||||
|
||||
*rr = RR;
|
||||
|
@ -347,7 +347,6 @@ extract_data(struct dnssession *session)
|
|||
struct dnsrr * authority = NULL;
|
||||
struct dnsrr * additional = NULL;
|
||||
|
||||
char * pheader;
|
||||
char * pquestion;
|
||||
char * panswer;
|
||||
char * pauthority;
|
||||
|
@ -362,7 +361,6 @@ extract_data(struct dnssession *session)
|
|||
// Extract the header.
|
||||
//
|
||||
session->recv_pkt_header = pbuffer;
|
||||
pheader = pbuffer;
|
||||
header = (struct dnsheader *)calloc(1, sizeof(struct dnsheader));
|
||||
memcpy(header, session->recv_pkt, sizeof(struct dnsheader));
|
||||
header->identification = ntohs(header->identification);
|
||||
|
@ -379,7 +377,7 @@ extract_data(struct dnssession *session)
|
|||
session->recv_pkt_question = pbuffer;
|
||||
pquestion = pbuffer;
|
||||
question = (struct dnsquestion *)calloc(1, sizeof(struct dnsquestion));
|
||||
question->query = strdup(getname(session, &pquestion));
|
||||
question->query = (unsigned char*)strdup(getname(session, &pquestion));
|
||||
question->type = getshort(pquestion);
|
||||
question->class = getshort(pquestion + 2);
|
||||
pbuffer = pquestion + 4;
|
||||
|
@ -621,7 +619,7 @@ get_resource(int type, struct dnssession *session, char *buffer, int dots)
|
|||
void
|
||||
dump_question(struct dnsquestion *question)
|
||||
{
|
||||
printf("- Queryname: %s\n", printablename(question->query, 0));
|
||||
printf("- Queryname: %s\n", printablename((char*)question->query, 0));
|
||||
printf("- Type: %hu (%s)\n",
|
||||
question->type, get_type(question->type));
|
||||
printf("- Class: %hu (%s)\n",
|
||||
|
@ -718,7 +716,7 @@ dump_header(struct dnsheader *header)
|
|||
void
|
||||
dump_rr(struct dnsrr *rr, struct dnssession *session)
|
||||
{
|
||||
printf("- Domainname: %s\n", printablename(rr->domainname, 0));
|
||||
printf("- Domainname: %s\n", printablename((char*)rr->domainname, 0));
|
||||
printf("- Type: %hu (%s)\n",
|
||||
rr->type, get_type(rr->type));
|
||||
printf("- Class: %hu (%s)\n",
|
||||
|
@ -727,7 +725,7 @@ dump_rr(struct dnsrr *rr, struct dnssession *session)
|
|||
rr->ttl, get_ttl(rr->ttl));
|
||||
printf("- Resource length: %hu\n", rr->datalength);
|
||||
printf("- Resource data: %s\n",
|
||||
get_resource(rr->type, session, rr->data, 0));
|
||||
get_resource(rr->type, session, (char*)rr->data, 0));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -846,7 +844,7 @@ create_socket(int PF)
|
|||
{
|
||||
int s;
|
||||
|
||||
if ((s = socket(PF, SOCK_DGRAM, 0)) < 0) {
|
||||
if ((s = Socket(PF, SOCK_DGRAM, 0)) < 0) {
|
||||
perror("create_socket/socket");
|
||||
//printf("If this is an IPv6 problem, run configure with --disable-ipv6\n");
|
||||
exit(1);
|
||||
|
@ -873,7 +871,7 @@ create_socket(int PF)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
if (bind(s, src_res->ai_addr, src_res->ai_addrlen) < 0) {
|
||||
if (Bind(s, src_res->ai_addr, src_res->ai_addrlen) < 0) {
|
||||
perror("create_socket/bind");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -915,8 +913,8 @@ send_data(char *server, struct dnssession *session)
|
|||
dump_data(&dest4, NULL, session);
|
||||
}
|
||||
|
||||
pkt = create_packet(session);
|
||||
if ((cc = sendto(session->socket, pkt, len, 0,
|
||||
pkt = (char*)create_packet(session);
|
||||
if ((cc = SendTo(session->socket, pkt, len, 0,
|
||||
//#ifndef NOIPV6
|
||||
// session->ipv6 ? (struct sockaddr *)&dest6 : (struct sockaddr *)&dest4,
|
||||
// session->ipv6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)
|
||||
|
@ -947,11 +945,11 @@ receive_data(struct dnssession *session, int retry)
|
|||
FD_ZERO(&in_set);
|
||||
FD_SET(session->socket, &in_set);
|
||||
|
||||
if (select(session->socket + 1, &in_set, NULL, NULL, &timeout) < 0)
|
||||
if (WaitSelect(session->socket + 1, &in_set, NULL, NULL, &timeout, NULL) < 0)
|
||||
return 2;
|
||||
if (!FD_ISSET(session->socket, &in_set))
|
||||
return 3;
|
||||
if ((len = recv(session->socket, buffer, sizeof(buffer), 0)) == -1)
|
||||
if ((len = Recv(session->socket, buffer, sizeof(buffer), 0)) == -1)
|
||||
return 1;
|
||||
|
||||
if (getshort(buffer) != session->send_header->identification) {
|
||||
|
@ -993,15 +991,15 @@ create_header(struct dnssession *session)
|
|||
void
|
||||
create_question(struct dnssession *session, char *name)
|
||||
{
|
||||
char *p, *q;
|
||||
unsigned char *p, *q;
|
||||
|
||||
session->send_question =
|
||||
(struct dnsquestion *)calloc(1, sizeof(struct dnsquestion));
|
||||
|
||||
session->send_question->querylength = strlen(name) + 2;
|
||||
session->send_question->query =
|
||||
(unsigned char *)calloc(1, session->send_question->querylength + 2);
|
||||
strcpy(session->send_question->query + 1, name);
|
||||
(unsigned char*)calloc(1, session->send_question->querylength + 2);
|
||||
strcpy((char*)session->send_question->query + 1, name);
|
||||
|
||||
p = session->send_question->query + 1;
|
||||
q = session->send_question->query;
|
||||
|
@ -1036,12 +1034,12 @@ add_arecord(struct dnssession *session, struct dnsrr *rr, char *server_name, cha
|
|||
arecord = (struct arecord *)calloc(1, sizeof(struct arecord));
|
||||
arecord->server_name = strdup(server_name);
|
||||
arecord->server_ip = strdup(server_ip);
|
||||
arecord->rr_name = strdup(printablename(rr->domainname, 1));
|
||||
arecord->rr_name = strdup(printablename((char*)rr->domainname, 1));
|
||||
|
||||
if (rr->data_string == NULL)
|
||||
arecord->rr_data = NULL;
|
||||
else
|
||||
arecord->rr_data = strdup(rr->data_string);
|
||||
arecord->rr_data = strdup((char*)rr->data_string);
|
||||
|
||||
arecord->next = arecords;
|
||||
arecords = arecord;
|
||||
|
@ -1298,7 +1296,7 @@ create_session(char *host, char *server_ip, int ipv6, char *server_name,
|
|||
if (session->authority != NULL && server_authfor != NULL) {
|
||||
if (session->recv_header->flags.bit.aa == 0 &&
|
||||
strcasecmp(server_authfor,
|
||||
session->authority->domainname_string) == 0) {
|
||||
(char*)session->authority->domainname_string) == 0) {
|
||||
printf("Lame server ");
|
||||
remove_busy(server_ip);
|
||||
return 0;
|
||||
|
@ -1342,7 +1340,7 @@ create_session(char *host, char *server_ip, int ipv6, char *server_name,
|
|||
// of what we have, don't go there. This might happen if we are
|
||||
// looking through cnames from different domains.
|
||||
//
|
||||
if (strcmp(rrauth->domainname_string, ".") == 0) {
|
||||
if (strcmp((char*)rrauth->domainname_string, ".") == 0) {
|
||||
rrauth = rrauth->next;
|
||||
if (!refersbackwards++)
|
||||
printf("Refers backwards ");
|
||||
|
@ -1350,7 +1348,7 @@ create_session(char *host, char *server_ip, int ipv6, char *server_name,
|
|||
}
|
||||
|
||||
if (server_authfor != NULL && strcmp(server_authfor, ".") != 0 &&
|
||||
strnrcasecmp(rrauth->domainname_string, server_authfor,
|
||||
strnrcasecmp((char*)rrauth->domainname_string, server_authfor,
|
||||
strlen(server_authfor)) != 0) {
|
||||
if (!refersbackwards++)
|
||||
printf("Refers backwards ");
|
||||
|
@ -1364,8 +1362,8 @@ create_session(char *host, char *server_ip, int ipv6, char *server_name,
|
|||
//
|
||||
rradd = session->additional;
|
||||
while (rradd != NULL) {
|
||||
if (strcmp(printablename(rradd->domainname, 1),
|
||||
rrauth->data_string) == 0)
|
||||
if (strcmp(printablename((char*)rradd->domainname, 1),
|
||||
(char*)rrauth->data_string) == 0)
|
||||
found++;
|
||||
rradd = rradd->next;
|
||||
}
|
||||
|
@ -1376,8 +1374,8 @@ create_session(char *host, char *server_ip, int ipv6, char *server_name,
|
|||
// Find the first IP address
|
||||
//
|
||||
while (rradd != NULL) {
|
||||
if (strcmp(printablename(rradd->domainname, 1),
|
||||
rrauth->data_string) == 0)
|
||||
if ((char*)strcmp(printablename((char*)rradd->domainname, 1),
|
||||
(char*)rrauth->data_string) == 0)
|
||||
break;
|
||||
rradd = rradd->next;
|
||||
}
|
||||
|
@ -1398,17 +1396,17 @@ create_session(char *host, char *server_ip, int ipv6, char *server_name,
|
|||
|
||||
printf("\n");
|
||||
|
||||
strcpy(nextserver_name, printablename(rradd->domainname, 1));
|
||||
strcpy(nextserver_ip, rradd->data_string);
|
||||
strcpy(nextserver_name, printablename((char*)rradd->domainname, 1));
|
||||
strcpy(nextserver_ip, (char*)rradd->data_string);
|
||||
retval += create_session(host,
|
||||
nextserver_ip, (rradd->type == ns_t_aaaa) ? 1 : 0,
|
||||
nextserver_name, rrauth->domainname_string,
|
||||
nextserver_name, (char*)rrauth->domainname_string,
|
||||
depth + 1, s,
|
||||
(rrauth->next == NULL && found <= 1) ? 1 : 0);
|
||||
} else {
|
||||
int ip, ipfound = 0;
|
||||
|
||||
strcpy(nextserver_name, rrauth->data_string);
|
||||
strcpy(nextserver_name, (char*)rrauth->data_string);
|
||||
|
||||
#ifdef NOIPV6
|
||||
for (ip = 0; ip < 1; ip++) {
|
||||
|
@ -1438,12 +1436,12 @@ create_session(char *host, char *server_ip, int ipv6, char *server_name,
|
|||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (ip == 0) {
|
||||
unsigned char *s = addr_list[i];
|
||||
unsigned char *s = (unsigned char*)addr_list[i];
|
||||
sprintf(nextserver_ip,
|
||||
"%hu.%hu.%hu.%hu", s[0], s[1], s[2], s[3]);
|
||||
ipv6 = 0;
|
||||
} else {
|
||||
unsigned char *s = addr_list[i];
|
||||
unsigned char *s = (unsigned char*)addr_list[i];
|
||||
sprintf(nextserver_ip,
|
||||
"%02hx%02hx:%02hx%02hx:%02hx%02hx:%02hx%02hx:"
|
||||
"%02hx%02hx:%02hx%02hx:%02hx%02hx:%02hx%02hx",
|
||||
|
@ -1455,7 +1453,7 @@ create_session(char *host, char *server_ip, int ipv6, char *server_name,
|
|||
|
||||
retval += create_session(host,
|
||||
nextserver_ip, ip == 1,
|
||||
nextserver_name, rrauth->domainname_string,
|
||||
nextserver_name, (char*)rrauth->domainname_string,
|
||||
depth + 1, s,
|
||||
(rrauth->next == NULL && found <= 1) ? 1 : 0);
|
||||
ipfound++;
|
||||
|
@ -1472,7 +1470,7 @@ create_session(char *host, char *server_ip, int ipv6, char *server_name,
|
|||
nextserver_ip[0] = 0;
|
||||
retval += create_session(host,
|
||||
nextserver_ip, 0,
|
||||
nextserver_name, rrauth->domainname_string,
|
||||
nextserver_name, (char*)rrauth->domainname_string,
|
||||
depth + 1, s,
|
||||
(rrauth->next == NULL && found <= 1) ? 1 : 0);
|
||||
}
|
||||
|
@ -1511,7 +1509,11 @@ void
|
|||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"\33[33mDNSTRACER version 1.9 (c) Edwin Groothuis - http://www.mavetju.org\33[31m\n"
|
||||
#ifdef ANSI_CONSOLE
|
||||
"\33[33mDNSTRACER version " PACKAGE_VERSION DEBUG_TEXT " (c) Edwin Groothuis - http://www.mavetju.org\33[31m\n"
|
||||
#else
|
||||
"DNSTRACER version " PACKAGE_VERSION DEBUG_TEXT " (c) Edwin Groothuis - http://www.mavetju.org\n"
|
||||
#endif
|
||||
"Usage: dnstracer [options] [host]\n"
|
||||
"\t-c: disable local caching, default enabled\n"
|
||||
"\t-C: enable negative caching, default disabled\n"
|
||||
|
@ -1545,11 +1547,13 @@ main(int argc, char **argv)
|
|||
int ipv6 = 0;
|
||||
int init;
|
||||
|
||||
prog = argv[0];
|
||||
|
||||
init = open_libs();
|
||||
if (init != 0)
|
||||
return init;
|
||||
|
||||
while ((ch = getopt(argc, argv, "4cCoq:r:S:s:t:v")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "4cCoqz:r:S:s:t:v")) != -1) {
|
||||
switch (ch) {
|
||||
case '4':
|
||||
#ifndef NOIPV6
|
||||
|
@ -1622,7 +1626,12 @@ main(int argc, char **argv)
|
|||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
|
||||
#if defined( DEBUG ) || defined( _DEBUG )
|
||||
case 'z':
|
||||
if( ! ( debugging = ( unsigned int )atoi( optarg ) ) )
|
||||
usage();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
@ -1639,8 +1648,6 @@ main(int argc, char **argv)
|
|||
printf("Tracing to %s[%s] via %s, maximum of %d retries\n",
|
||||
argv0, rr_types[global_querytype], server_name, global_retries);
|
||||
|
||||
srandom(time(NULL));
|
||||
|
||||
{
|
||||
struct hostent *h = NULL;
|
||||
|
||||
|
@ -1654,11 +1661,11 @@ main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
if (h->h_addrtype == AF_INET) {
|
||||
unsigned char *s = h->h_addr_list[0];
|
||||
unsigned char *s = (unsigned char*)h->h_addr_list[0];
|
||||
sprintf(ipaddress, "%hu.%hu.%hu.%hu", s[0], s[1], s[2], s[3]);
|
||||
ipv6 = 0;
|
||||
} else {
|
||||
unsigned char *s = h->h_addr_list[0];
|
||||
unsigned char *s = (unsigned char*)h->h_addr_list[0];
|
||||
sprintf(ipaddress,
|
||||
"%02hx%02hx:%02hx%02hx:%02hx%02hx:%02hx%02hx:"
|
||||
"%02hx%02hx:%02hx%02hx:%02hx%02hx:%02hx%02hx",
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* Written by Carsten Larsen.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#ifndef _DNSTRACER_H
|
||||
#define _DNSTRACER_H
|
||||
|
||||
#include <clib/dos_protos.h>
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/alib_protos.h>
|
||||
#include <clib/timer_protos.h>
|
||||
#include <clib/utility_protos.h>
|
||||
#include <utility/date.h>
|
||||
#include <devices/timer.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "mem.h"
|
||||
#define calloc(x, y) allocmem(x*y)
|
||||
#define malloc(x) allocmem(x)
|
||||
#define free(x) freemem(x)
|
||||
|
||||
unsigned int debugging;
|
||||
|
||||
#ifdef AOS3
|
||||
# include <clib/amitcp_protos.h>
|
||||
# include <amitcp/socketbasetags.h>
|
||||
# include <machine/types.h>
|
||||
# define uint16_t u_int16_t
|
||||
# define gettimeofday(x, y) getsystime(x)
|
||||
# define srandom(x) srand(x)
|
||||
# define random() rand()
|
||||
# define ANSI_CONSOLE 1
|
||||
# define IPTR ULONG
|
||||
typedef unsigned int socklen_t;
|
||||
typedef unsigned int sa_family_t;
|
||||
#endif
|
||||
|
||||
typedef u_int16_t in_port_t;
|
||||
|
||||
#ifdef AROS
|
||||
# include <inttypes.h>
|
||||
# include <sys/time.h>
|
||||
# define Socket(a,b,c) socket(a,b,c)
|
||||
# define Bind(a,b,c) bind(a,b,c)
|
||||
# define Recv(a,b,c,d) recv(a,b,c,d)
|
||||
# define RecvFrom(a,b,c,d,e,f) recvfrom(a,b,c,d,e,f)
|
||||
# define SendTo(a,b,c,d,e,f) sendto(a,b,c,d,e,f)
|
||||
#endif
|
||||
|
||||
#ifdef AOS3
|
||||
/*
|
||||
* struct addrinfo.
|
||||
*/
|
||||
struct addrinfo {
|
||||
int ai_flags;
|
||||
int ai_family;
|
||||
int ai_socktype;
|
||||
int ai_protocol;
|
||||
socklen_t ai_addrlen;
|
||||
char *ai_canonname;
|
||||
struct sockaddr *ai_addr;
|
||||
struct addrinfo *ai_next;
|
||||
};
|
||||
#endif
|
||||
|
||||
#define PACKAGE_NAME "DNS Tracer"
|
||||
#define PACKAGE_VERSION "1.9"
|
||||
#define PACKAGE_DATE "21.02.2016"
|
||||
|
||||
#define WORDS_BIGENDIAN 1
|
||||
#define NOIPV6 1
|
||||
struct sockaddr_in6;
|
||||
|
||||
#ifndef PF_INET6
|
||||
#define PF_INET6 10
|
||||
#endif
|
||||
|
||||
#ifndef AF_INET6
|
||||
#define AF_INET6 PF_INET6
|
||||
#endif
|
||||
|
||||
#define DEFAULT_RETRIES 3
|
||||
#define DEFAULT_CACHING 1
|
||||
#define DEFAULT_NEGATIVE_CACHING 0
|
||||
#define DEFAULT_OVERVIEW 0
|
||||
#define DEFAULT_QUERYTYPE ns_t_a
|
||||
#define DEFAULT_NOIPV6 0
|
||||
|
||||
#if defined( DEBUG ) || defined( _DEBUG )
|
||||
# define DEBUG_TEXT "b"
|
||||
#else
|
||||
# define DEBUG_TEXT ""
|
||||
#endif
|
||||
|
||||
/* dnstracer.c */
|
||||
char *prog;
|
||||
|
||||
/* dnstracer_amiga.c */
|
||||
int open_libs();
|
||||
int getsystime(struct timeval *tv);
|
||||
|
||||
extern struct Library *SocketBase;
|
||||
extern int errno;
|
||||
|
||||
#endif
|
|
@ -3,10 +3,8 @@
|
|||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <clib/dos_protos.h>
|
||||
#include <clib/exec_protos.h>
|
||||
#include "dnstracer.h"
|
||||
#include "getaddrinfo.h"
|
||||
|
||||
#define OPEN_ERROR "Cannot open %s.\n"
|
||||
#define OPEN_VER_ERROR "Cannot open %s (%d.0)\n"
|
||||
|
@ -14,16 +12,25 @@
|
|||
#define DOSLIB_REV 37L
|
||||
#define BSDLIB_NAME "bsdsocket.library"
|
||||
#define BSDLIB_REV 03L
|
||||
#define UTILLIB_NAME "utility.library"
|
||||
#define UTILLIB_REV 37L
|
||||
#define TIMER_NAME TIMERNAME
|
||||
#define LIB_ERROR 5
|
||||
|
||||
#include "config.h"
|
||||
const char *vers = "\0$VER: " PACKAGE_NAME " " PACKAGE_VERSION " (18.02.2016)";
|
||||
const char *vers = "\0$VER: " PACKAGE_NAME " " PACKAGE_VERSION " (21.02.2016)";
|
||||
|
||||
#ifdef AOS3
|
||||
int h_errno;
|
||||
#endif
|
||||
|
||||
struct Library *DOSBase = NULL;
|
||||
struct Library *SocketBase = NULL;
|
||||
struct Library* DOSBase = NULL;
|
||||
struct Library* SocketBase = NULL;
|
||||
struct Library* UtilityBase = NULL;
|
||||
struct Device* TimerBase = NULL;
|
||||
struct timerequest* TimeRequest = NULL;
|
||||
|
||||
int create_timer();
|
||||
void delete_timer();
|
||||
|
||||
void amiga_open_error(char *name)
|
||||
{
|
||||
|
@ -37,31 +44,123 @@ void amiga_open_lib_error(char *name, int version)
|
|||
|
||||
void close_libs()
|
||||
{
|
||||
if (DOSBase != NULL) {
|
||||
CloseLibrary(DOSBase);
|
||||
DOSBase = NULL;
|
||||
if (TimerBase != NULL) {
|
||||
delete_timer();
|
||||
}
|
||||
|
||||
if (UtilityBase != NULL) {
|
||||
CloseLibrary(UtilityBase);
|
||||
UtilityBase = NULL;
|
||||
}
|
||||
|
||||
if (SocketBase != NULL) {
|
||||
CloseLibrary(SocketBase);
|
||||
SocketBase = NULL;
|
||||
}
|
||||
|
||||
freeall();
|
||||
|
||||
if (DOSBase != NULL) {
|
||||
CloseLibrary(DOSBase);
|
||||
DOSBase = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int open_libs()
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
atexit(close_libs);
|
||||
InitSemaphore(&GetaddrinfoSemaphore);
|
||||
|
||||
if(!(DOSBase = OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV))) {
|
||||
amiga_open_lib_error(DOSLIB_NAME, DOSLIB_REV);
|
||||
return 5;
|
||||
return LIB_ERROR;
|
||||
}
|
||||
|
||||
if(!(SocketBase = OpenLibrary((STRPTR)BSDLIB_NAME, BSDLIB_REV))) {
|
||||
amiga_open_lib_error(BSDLIB_NAME, BSDLIB_REV);
|
||||
return 5;
|
||||
return LIB_ERROR;
|
||||
} else {
|
||||
SocketBaseTags(
|
||||
SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (IPTR) &errno,
|
||||
SBTM_SETVAL(SBTC_HERRNOLONGPTR), (IPTR) &h_errno,
|
||||
SBTM_SETVAL(SBTC_LOGTAGPTR), (IPTR) &prog,
|
||||
TAG_DONE );
|
||||
}
|
||||
|
||||
if(!(UtilityBase = OpenLibrary((STRPTR)UTILLIB_NAME, UTILLIB_REV))) {
|
||||
amiga_open_lib_error(UTILLIB_NAME, UTILLIB_REV);
|
||||
return LIB_ERROR;
|
||||
}
|
||||
|
||||
if (create_timer() != 0) {
|
||||
amiga_open_error(TIMER_NAME);
|
||||
return LIB_ERROR;
|
||||
}
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
srand(tv.tv_usec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef AOS3
|
||||
int create_timer()
|
||||
{
|
||||
LONG error;
|
||||
struct MsgPort *port = CreatePort(0, 0);
|
||||
if (port == NULL)
|
||||
return 1;
|
||||
|
||||
TimeRequest = (struct timerequest*)CreateExtIO(port, sizeof(struct timerequest));
|
||||
if (TimeRequest == NULL)
|
||||
{
|
||||
DeletePort(port);
|
||||
return 1;
|
||||
}
|
||||
|
||||
error = OpenDevice(
|
||||
(STRPTR)TIMER_NAME, UNIT_MICROHZ,
|
||||
(struct IORequest*)TimeRequest, 0L
|
||||
);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
delete_timer(TimeRequest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
TimerBase = (struct Device*)TimeRequest->tr_node.io_Device;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void delete_timer()
|
||||
{
|
||||
struct MsgPort *port;
|
||||
if (TimeRequest == NULL)
|
||||
return;
|
||||
|
||||
port = TimeRequest->tr_node.io_Message.mn_ReplyPort;
|
||||
|
||||
if (port != 0)
|
||||
DeletePort(port);
|
||||
|
||||
CloseDevice((struct IORequest*)TimeRequest);
|
||||
DeleteExtIO((struct IORequest*)TimeRequest);
|
||||
}
|
||||
|
||||
int getsystime(struct timeval *tv)
|
||||
{
|
||||
struct timeval tv1;
|
||||
|
||||
GetSysTime(&tv1);
|
||||
*tv = tv1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int create_timer() { return 0; }
|
||||
void delete_timer() { }
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
/*
|
||||
* Written by Carsten Larsen.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <clib/exec_protos.h>
|
||||
#include <clib/timer_protos.h>
|
||||
#include <clib/utility_protos.h>
|
||||
#include <clib/alib_protos.h>
|
||||
#include <devices/timer.h>
|
||||
|
||||
#define OPEN_ERROR "Cannot open %s.\n"
|
||||
#define OPEN_VER_ERROR "Cannot open %s (%d.0)\n"
|
||||
#define DOSLIB_NAME "dos.library"
|
||||
#define DOSLIB_REV 37L
|
||||
#define BSDLIB_NAME "bsdsocket.library"
|
||||
#define BSDLIB_REV 03L
|
||||
#define UTILLIB_NAME "utility.library"
|
||||
#define UTILLIB_REV 37L
|
||||
#define TIMER_NAME TIMERNAME
|
||||
#define LIB_ERROR 4
|
||||
|
||||
#include "config.h"
|
||||
const char *vers = "\0$VER: " PACKAGE_NAME " " PACKAGE_VERSION " (21.02.2016)";
|
||||
|
||||
#include <unistd.h>
|
||||
#ifdef AOS3
|
||||
uid_t getuid () {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int setuid (uid_t id) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int h_errno;
|
||||
#endif
|
||||
|
||||
struct Library* DOSBase = NULL;
|
||||
struct Library* SocketBase = NULL;
|
||||
struct Library* UtilityBase = NULL;
|
||||
struct Device* TimerBase = NULL;
|
||||
struct timerequest* TimeRequest = NULL;
|
||||
|
||||
int create_timer();
|
||||
void delete_timer();
|
||||
|
||||
void amiga_open_error(char *name)
|
||||
{
|
||||
printf(OPEN_ERROR, name);
|
||||
}
|
||||
|
||||
void amiga_open_lib_error(char *name, int version)
|
||||
{
|
||||
printf(OPEN_VER_ERROR, name, version);
|
||||
}
|
||||
|
||||
void close_libs()
|
||||
{
|
||||
close_ping_socket();
|
||||
cleanup_ping_buffer();
|
||||
|
||||
if (TimerBase != NULL) {
|
||||
delete_timer();
|
||||
}
|
||||
|
||||
if (UtilityBase != NULL) {
|
||||
CloseLibrary(UtilityBase);
|
||||
UtilityBase = NULL;
|
||||
}
|
||||
|
||||
if (SocketBase != NULL) {
|
||||
CloseLibrary(SocketBase);
|
||||
SocketBase = NULL;
|
||||
}
|
||||
|
||||
if (DOSBase != NULL) {
|
||||
CloseLibrary(DOSBase);
|
||||
DOSBase = NULL;
|
||||
}
|
||||
|
||||
freeall();
|
||||
}
|
||||
|
||||
int open_libs()
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
atexit(close_libs);
|
||||
InitSemaphore(&GetaddrinfoSemaphore);
|
||||
|
||||
if(!(DOSBase = OpenLibrary((STRPTR)DOSLIB_NAME, DOSLIB_REV))) {
|
||||
amiga_open_lib_error(DOSLIB_NAME, DOSLIB_REV);
|
||||
return LIB_ERROR;
|
||||
}
|
||||
|
||||
if(!(SocketBase = OpenLibrary((STRPTR)BSDLIB_NAME, BSDLIB_REV))) {
|
||||
amiga_open_lib_error(BSDLIB_NAME, BSDLIB_REV);
|
||||
return LIB_ERROR;
|
||||
} else {
|
||||
SocketBaseTags(
|
||||
SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (IPTR) &errno,
|
||||
SBTM_SETVAL(SBTC_HERRNOLONGPTR), (IPTR) &h_errno,
|
||||
SBTM_SETVAL(SBTC_LOGTAGPTR), (IPTR) &prog,
|
||||
TAG_DONE );
|
||||
}
|
||||
|
||||
if(!(UtilityBase = OpenLibrary((STRPTR)UTILLIB_NAME, UTILLIB_REV))) {
|
||||
amiga_open_lib_error(UTILLIB_NAME, UTILLIB_REV);
|
||||
return LIB_ERROR;
|
||||
}
|
||||
|
||||
if (create_timer() != 0) {
|
||||
amiga_open_error(TIMER_NAME);
|
||||
return LIB_ERROR;
|
||||
}
|
||||
|
||||
getsystime(&tv);
|
||||
srand(tv.tv_usec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int create_timer()
|
||||
{
|
||||
LONG error;
|
||||
struct MsgPort *port = CreatePort(0, 0);
|
||||
if (port == NULL)
|
||||
return 1;
|
||||
|
||||
TimeRequest = (struct timerequest*)CreateExtIO(port, sizeof(struct timerequest));
|
||||
if (TimeRequest == NULL)
|
||||
{
|
||||
DeletePort(port);
|
||||
return 1;
|
||||
}
|
||||
|
||||
error = OpenDevice(
|
||||
(STRPTR)TIMER_NAME, UNIT_MICROHZ,
|
||||
(struct IORequest*)TimeRequest, 0L
|
||||
);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
delete_timer(TimeRequest);
|
||||
return 1;
|
||||
}
|
||||
|
||||
TimerBase = (struct Device*)TimeRequest->tr_node.io_Device;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void delete_timer()
|
||||
{
|
||||
struct MsgPort *port;
|
||||
if (TimeRequest == NULL)
|
||||
return;
|
||||
|
||||
port = TimeRequest->tr_node.io_Message.mn_ReplyPort;
|
||||
|
||||
if (port != 0)
|
||||
DeletePort(port);
|
||||
|
||||
CloseDevice((struct IORequest*)TimeRequest);
|
||||
DeleteExtIO((struct IORequest*)TimeRequest);
|
||||
}
|
||||
|
||||
int getsystime(struct timeval *tv)
|
||||
{
|
||||
struct timeval tv1;
|
||||
|
||||
GetSysTime(&tv1);
|
||||
*tv = tv1;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Carsten Larsen
|
||||
* Copyright (c) 2015, 16 Carsten Larsen
|
||||
* Copyright (c) 2001, 02 Motoyuki Kasahara
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -59,8 +59,8 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "inet_getaddrinfo.h"
|
||||
#include "dnstracer.h"
|
||||
#include "getaddrinfo.h"
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
#include <libintl.h>
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Carsten Larsen
|
||||
* Copyright (c) 2015, 16 Carsten Larsen
|
||||
* Copyright (c) 2001, 02 Motoyuki Kasahara
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -31,9 +31,10 @@
|
|||
#define INET_GETADDRINFO_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include "dnstracer.h"
|
||||
|
||||
/********************************************************************/
|
||||
/*
|
||||
* Undefine all the macros.
|
||||
|
@ -185,31 +186,13 @@
|
|||
/*
|
||||
* Address families and Protocol families.
|
||||
*/
|
||||
#if 0
|
||||
#ifndef AF_UNSPEC
|
||||
#define AF_UNSPEC AF_INET
|
||||
#endif
|
||||
#ifndef PF_UNSPEC
|
||||
#define PF_UNSPEC PF_INET
|
||||
#endif
|
||||
|
||||
typedef unsigned int socklen_t;
|
||||
typedef u_int16_t in_port_t;
|
||||
typedef unsigned int sa_family_t;
|
||||
|
||||
#ifdef AOS3
|
||||
/*
|
||||
* struct addrinfo.
|
||||
*/
|
||||
struct addrinfo {
|
||||
int ai_flags;
|
||||
int ai_family;
|
||||
int ai_socktype;
|
||||
int ai_protocol;
|
||||
socklen_t ai_addrlen;
|
||||
char *ai_canonname;
|
||||
struct sockaddr *ai_addr;
|
||||
struct addrinfo *ai_next;
|
||||
};
|
||||
#endif
|
||||
|
||||
#include <exec/types.h>
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* getopt.c --
|
||||
*
|
||||
* Standard UNIX getopt function. Code is from BSD.
|
||||
*
|
||||
* Copyright (c) 1987-2002 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:
|
||||
*
|
||||
* A. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* B. 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.
|
||||
* C. Neither the names of the copyright holders 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 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.
|
||||
*/
|
||||
|
||||
/* #if !defined(lint)
|
||||
* static char sccsid[] = "@(#)getopt.c 8.2 (Berkeley) 4/2/94";
|
||||
* #endif
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
int opterr = 1, /* if error message should be printed */
|
||||
optind = 1, /* index into parent argv vector */
|
||||
optopt, /* character checked for validity */
|
||||
optreset; /* reset getopt */
|
||||
char *optarg; /* argument associated with option */
|
||||
|
||||
#define BADCH (int)'?'
|
||||
#define BADARG (int)':'
|
||||
#define EMSG ""
|
||||
|
||||
/*
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int
|
||||
getopt( int nargc,
|
||||
char * const *nargv,
|
||||
const char *ostr)
|
||||
{
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli; /* option letter list index */
|
||||
|
||||
if (optreset || !*place) { /* update scanning pointer */
|
||||
optreset = 0;
|
||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||
place = EMSG;
|
||||
return (EOF);
|
||||
}
|
||||
if (place[1] && *++place == '-') { /* found "--" */
|
||||
++optind;
|
||||
place = EMSG;
|
||||
return (EOF);
|
||||
}
|
||||
} /* option letter okay? */
|
||||
if ((optopt = (int)*place++) == (int)':' ||
|
||||
!(oli = (char*) strchr(ostr, optopt))) {
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
* assume it means EOF.
|
||||
*/
|
||||
if (optopt == (int)'-')
|
||||
return (EOF);
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (opterr && *ostr != ':')
|
||||
(void)fprintf(stderr,
|
||||
"illegal option -- %c\n", optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
optarg = NULL;
|
||||
if (!*place)
|
||||
++optind;
|
||||
}
|
||||
else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
optarg = place;
|
||||
else if (nargc <= ++optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (*ostr == ':')
|
||||
return (BADARG);
|
||||
if (opterr)
|
||||
(void)fprintf(stderr,
|
||||
"option requires an argument -- %c\n",
|
||||
optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
else /* white space */
|
||||
optarg = nargv[optind];
|
||||
place = EMSG;
|
||||
++optind;
|
||||
}
|
||||
return (optopt); /* dump back option letter */
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef _HAD_GETOPT_H
|
||||
#define _HAD_GETOPT_H
|
||||
|
||||
/*
|
||||
getopt.h -- header for getopt() replacement function
|
||||
Copyright (C) 1999-2011 Dieter Baron and Thomas Klausner
|
||||
|
||||
This file is part of libzip, a library to manipulate ZIP archives.
|
||||
The authors can be contacted at <libzip@nih.at>
|
||||
|
||||
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. The names of the authors may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
extern int opterr;
|
||||
|
||||
extern int getopt(int, char * const *, const char *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _HAD_GETOPT_H */
|
|
@ -0,0 +1,253 @@
|
|||
//--------------------------------------------------------------------------//
|
||||
// This file is in the public domain. //
|
||||
//--------------------------------------------------------------------------//
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <exec/io.h>
|
||||
#include <exec/types.h>
|
||||
#include <exec/memory.h>
|
||||
#include <exec/semaphores.h>
|
||||
#include <clib/exec_protos.h>
|
||||
//--------------------------------------------------------------------------//
|
||||
#include "mem.h"
|
||||
//--------------------------------------------------------------------------//
|
||||
#if defined( DEBUG ) || defined( _DEBUG )
|
||||
# include <stdio.h>
|
||||
# define DBG_MEMORY 128
|
||||
# define DBG_MEMORY_ADDR 256
|
||||
#endif
|
||||
//--------------------------------------------------------------------------//
|
||||
struct MemoryBlock
|
||||
{
|
||||
struct MemoryBlock *next;
|
||||
size_t size;
|
||||
void *address;
|
||||
};
|
||||
//--------------------------------------------------------------------------//
|
||||
struct MemoryList
|
||||
{
|
||||
struct MemoryBlock *first;
|
||||
struct MemoryBlock *last;
|
||||
long size;
|
||||
long count;
|
||||
long opcount;
|
||||
};
|
||||
//--------------------------------------------------------------------------//
|
||||
static struct MemoryList *list = NULL;
|
||||
//--------------------------------------------------------------------------//
|
||||
void allocerror(char*, size_t);
|
||||
void deallocerror(char*, void*);
|
||||
//--------------------------------------------------------------------------//
|
||||
void* allocmem(size_t size)
|
||||
{
|
||||
struct MemoryBlock *newblock;
|
||||
size_t allocsize;
|
||||
|
||||
if (list == NULL) {
|
||||
list =
|
||||
(struct MemoryList*)
|
||||
AllocVec(sizeof(struct MemoryList), MEMF_ANY | MEMF_CLEAR);
|
||||
|
||||
if (!list) {
|
||||
allocerror("list", sizeof(struct MemoryList));
|
||||
return 0;
|
||||
}
|
||||
|
||||
list->first = NULL;
|
||||
list->last = NULL;
|
||||
list->size = 0;
|
||||
list->count = 0;
|
||||
}
|
||||
|
||||
// Align to bytes of 4
|
||||
allocsize = (size + 3) & ~0x03;
|
||||
|
||||
newblock =
|
||||
(struct MemoryBlock*)
|
||||
AllocVec(sizeof(struct MemoryBlock), MEMF_ANY | MEMF_CLEAR);
|
||||
|
||||
if (!newblock) {
|
||||
allocerror("block", sizeof(struct MemoryBlock));
|
||||
return 0;
|
||||
}
|
||||
|
||||
newblock->address =
|
||||
(struct MemoryBlock*)
|
||||
AllocVec(allocsize, MEMF_ANY | MEMF_CLEAR);
|
||||
|
||||
if (!newblock->address) {
|
||||
FreeVec(newblock);
|
||||
allocerror("memory", allocsize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
newblock->size = allocsize;
|
||||
newblock->next = NULL;
|
||||
|
||||
if(list->first == NULL) {
|
||||
list->first = newblock;
|
||||
list->last = newblock;
|
||||
} else {
|
||||
list->last->next = newblock;
|
||||
list->last = newblock;
|
||||
}
|
||||
|
||||
list->size += allocsize;
|
||||
list->count++;
|
||||
|
||||
list->opcount++;
|
||||
#if defined( DEBUG ) || defined( _DEBUG )
|
||||
if ( debugging & DBG_MEMORY_ADDR && list->opcount % 25 == 0) {
|
||||
fprintf(stderr,
|
||||
"Memory usage: %ld bytes allocated in %ld blocks.\n",
|
||||
list->size,
|
||||
list->count
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined( DEBUG ) || defined( _DEBUG )
|
||||
if( debugging & DBG_MEMORY_ADDR )
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Memory allocated at address (%X)\n",
|
||||
(unsigned int)newblock->address);
|
||||
}
|
||||
#endif
|
||||
|
||||
return newblock->address;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------//
|
||||
|
||||
void freemem(void* block)
|
||||
{
|
||||
struct MemoryBlock *current, *last;
|
||||
|
||||
if (list == NULL || block == NULL) {
|
||||
deallocerror("list", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (block == NULL) {
|
||||
deallocerror("memory", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
last = NULL;
|
||||
current = list->first;
|
||||
while (current != NULL && current->address != block) {
|
||||
last = current;
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
if (current == NULL) {
|
||||
deallocerror("address not found", block);
|
||||
return;
|
||||
}
|
||||
|
||||
list->size -= current->size;
|
||||
list->count--;
|
||||
|
||||
if (list->first == current) {
|
||||
list->first = NULL;
|
||||
list->last = NULL;
|
||||
} else if (list->last == current) {
|
||||
last->next = current->next;
|
||||
list->last = last;
|
||||
} else {
|
||||
last->next = current->next;
|
||||
}
|
||||
|
||||
FreeVec(current->address);
|
||||
FreeVec(current);
|
||||
|
||||
list->opcount++;
|
||||
|
||||
#if defined( DEBUG ) || defined( _DEBUG )
|
||||
if( debugging & DBG_MEMORY_ADDR )
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Memory deallocated at address (%X)\n",
|
||||
(unsigned int)block);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void freeall()
|
||||
{
|
||||
struct MemoryBlock *current, *next;
|
||||
|
||||
if (list == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined( DEBUG ) || defined( _DEBUG )
|
||||
if( debugging & DBG_MEMORY )
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Cleaning up (%ld) bytes in (%ld) blocks.\n",
|
||||
list->size,
|
||||
list->count
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
current = list->first;
|
||||
while (current != NULL) {
|
||||
next = current->next;
|
||||
FreeVec(current->address);
|
||||
FreeVec(current);
|
||||
current = next;
|
||||
}
|
||||
|
||||
FreeVec(list);
|
||||
list = NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------//
|
||||
|
||||
void allocerror(char *descr, size_t size)
|
||||
{
|
||||
#if defined( DEBUG ) || defined( _DEBUG )
|
||||
if( debugging & DBG_MEMORY_ADDR )
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Memory allocation error (%s) with size (%ld)\n",
|
||||
descr,
|
||||
size);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void deallocerror(char *descr, void *p)
|
||||
{
|
||||
#if defined( DEBUG ) || defined( _DEBUG )
|
||||
if( debugging & DBG_MEMORY_ADDR )
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Memory deallocation error (%s) address (%X)\n",
|
||||
descr,
|
||||
(unsigned int)p);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------//
|
||||
|
||||
char *strdup(const char *s1)
|
||||
{
|
||||
char *s2;
|
||||
size_t len = strlen(s1);
|
||||
s2 = allocmem(++len);
|
||||
|
||||
if(s2 == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(s2, s1, --len);
|
||||
return s2;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------//
|
|
@ -0,0 +1,18 @@
|
|||
//--------------------------------------------------------------------------//
|
||||
// This file is in the public domain. //
|
||||
//--------------------------------------------------------------------------//
|
||||
#ifndef AMIGA_MEM_H
|
||||
#define AMIGA_MEM_H
|
||||
//--------------------------------------------------------------------------//
|
||||
#include <stddef.h>
|
||||
//--------------------------------------------------------------------------//
|
||||
void* allocmem(size_t);
|
||||
void freemem(void*);
|
||||
void freeall();
|
||||
//--------------------------------------------------------------------------//
|
||||
#define strdup(s) managed_strdup(s)
|
||||
char *strdup(const char *s1);
|
||||
//--------------------------------------------------------------------------//
|
||||
extern unsigned int debugging;
|
||||
//--------------------------------------------------------------------------//
|
||||
#endif
|
|
@ -0,0 +1,61 @@
|
|||
/* $NetBSD: rand.c,v 1.12 2012/06/25 22:32:45 abs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 1
|
||||
static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: rand.c,v 1.12 2012/06/25 22:32:45 abs Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef RAND_MAX
|
||||
#define RAND_MAX 2147483647
|
||||
#endif
|
||||
|
||||
static u_long next = 1;
|
||||
|
||||
int
|
||||
rand(void)
|
||||
{
|
||||
/* LINTED integer overflow */
|
||||
return (int)((next = next * 1103515245 + 12345) % ((u_long)RAND_MAX + 1));
|
||||
}
|
||||
|
||||
void
|
||||
srand(u_int seed)
|
||||
{
|
||||
next = seed;
|
||||
}
|
Loading…
Reference in New Issue