1.0 IRIX 6.5 *not* with GCC [1], [2]
1.0 AIX 4.1.5
1.0 HP-UX 10.20, 11.00
+ 1.1 Darwin (kernel 7.5.1)
Later versions of the same OS should work too. Usually entries in
this table mean adns passes its own regression test, when compiled
with GCC, and appears to install and run correctly. If you have more
Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
adns is
- Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- Copyright (C) 1999-2000 Tony Finch <dot@dotat.at> [1]
+ Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+ Copyright (C) 1999-2004 Tony Finch <dot@dotat.at> [1]
Copyright (C) 1991 Massachusetts Institute of Technology [2]
adns is free software; you can redistribute it and/or modify it under
above or write to the Free Software Foundation, 59 Temple Place -
Suite 330, Boston, MA 02111-1307, USA.
-[1] Tony Finch holds the original copyright on client/adnslogres.c and
- client/fanftest.c, and some modifications to those files.
+[1] Tony Finch holds the original copyright on client/adnslogres.c,
+ client/adnsheloex.c and client/fanftest.c, and some modifications
+ to those files.
[2] MIT hold the original copyright on the included install-sh,
which came via GNU autoconf.
---------------
* Not all of the code in adns was written by me. The programs
- `fanftest' and `adnslogres' are (partially) copyright Tony Finch
- and to that extent are not covered by the waivers. I believe - but
- do not warrant - that the rest of adns is (at the time of writing,
- 4th May 2004) entirely my work, but please check the copyright
- notices on the individual files.
+ `fanftest', `adnslogres' and `adnsheloex' are (partially) copyright
+ Tony Finch and to that extent are not covered by the waivers. I
+ believe - but do not warrant - that the rest of adns is (at the
+ time of writing, 16th of March 2005) entirely my work, but please
+ check the copyright notices on the individual files.
* These waivers apply only in the specified circumstances.
# Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
#
# It is part of adns, which is
-# Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-# Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+# Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+# Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
#
# 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
TAGS info dvi:
# do nothing
+
+.PHONY: install #people with case-insensitive filesystems lose otherwise!
Copyright and licensing
- adns is Copyright 1997-2001 Ian Jackson, Copyright 1999-2000 Tony
+ adns is Copyright 1997-2005 Ian Jackson, Copyright 1999-2004 Tony
Finch, and Copyright (C) 1991 Massachusetts Institute of Technology.
adns is free software; you can redistribute it and/or modify it under
[23]GNU home page; [24]chiark home page; [25]site or mirror home page
- This web page is Copyright (C)1996-2001 Ian Jackson. See the
+ This web page is Copyright (C)1996-2005 Ian Jackson. See the
[26]Copyright/acknowledgements.
Use any browser - [27]Campaign for a non-browser-specific WWW
<h2>Copyright and licensing</h2>
-<kbd>adns</kbd> is Copyright 1997-2001 Ian Jackson, Copyright
-1999-2000 Tony Finch, and Copyright (C) 1991 Massachusetts Institute
+<kbd>adns</kbd> is Copyright 1997-2005 Ian Jackson, Copyright
+1999-2004 Tony Finch, and Copyright (C) 1991 Massachusetts Institute
of Technology.
<p>
<A href="/">site or mirror home page</A>
<p>
-This web page is Copyright (C)1996-2001 Ian Jackson. See the
+This web page is Copyright (C)1996-2005 Ian Jackson. See the
<A href="http://www.chiark.greenend.org.uk/~ian/sw-www-copy.html">Copyright/acknowledgements</A>.
<p>
* Caching in the library.
* SRV RRs.
* Make port configurable in config file.
+* `Nameserver sent bad response' should produce a hexdump in the log
+ (see eg mail to ian@davenant Mon, 25 Oct 2004 14:19:46 +0100 re
+ `compressed datagram contains loop')
* Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
*
* It is part of adns, which is
- * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- * Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ * Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+ * Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
*
* 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
# Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
#
# It is part of adns, which is
-# Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
-# Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+# Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+# Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
#
# This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson
#
-
-
-THIS BRANCH IS NOW CLOSED
-
- EVERYTHING HAS BEEN MERGED TO THE TRUNK
- (at CVS tag mergepoint-logcallbackfn)
-
- DO NOT EDIT
-
-
- * New adns_init_logfn etc. for having logging done with a callback
- function.
-
- --
-
-adns (1.2); urgency=medium
+adns (1.1.999.0.1); urgency=medium
* Fix error in prototype in definition of adns__parse_domain.
* New LICENCE.WAIVERS file for GPL-incompatility workarounds.
* Clarified GPL-vs-LGPL: a bit less hostile and a bit more mercenary.
* Allow `;'-comments in resolv.conf (report from Colin Charles).
+ * Added a TODO list item.
+ * Add .PHONY: install to Makefile, to help people with demented fs's.
+ * Darwin listed in INSTALL.
+ * New adnsheloex client courtesy of Tony Finch (and copyright notices
+ updated).
+ * Add documentation comment by definition of adns_r_ptr_raw type enum.
+ * Add -Wno-pointer-sign if GCC has that option.
+ * Call Tensurerecordfile in Hgettimeofday (Tensurerecordfile was
+ Tensureinputfile/Tensureoutputfile).
+ * Add bind(2) and listen(2) to test harness (for epithet's benefit, but
+ harmless in adns).
+ * Add missing ENOTSOCK to hcommon.c.m4 (was already in hcommon.c!)
+ * New adns_init_logfn etc. for having logging done with a callback
+ function.
--
adnstest_s
adnslogres
adnslogres_s
+adnsheloex
+adnsheloex_s
adnshost
adnshost_s
adnsresfilter
PROGS_SYSDEP= @PROGS_HAVE_TSEARCH@
ENABLE_DYNAMIC= @ENABLE_DYNAMIC@
-PROGRAMS= adnslogres adnshost $(PROGS_SYSDEP)
+PROGRAMS= adnslogres adnsheloex adnshost $(PROGS_SYSDEP)
PROGRAMS_LOCAL= fanftest adnstest
PROGRAMS_ALL= $(PROGRAMS) $(PROGRAMS_LOCAL)
--- /dev/null
+/*
+ * adnsheloex.c
+ * - look up the A record of hosts in an Exim log that failed HELO verification
+ */
+/*
+ * This file is
+ * Copyright (C) 2004 Tony Finch <dot@dotat.at>
+ *
+ * It is part of adns, which is
+ * Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
+ * Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
+ *
+ * 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, 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, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * This file is by Tony Finch, based on adnslogres.c.
+ */
+
+static const char * const cvsid =
+ "$Id$";
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdarg.h>
+
+#include "config.h"
+#include "adns.h"
+#include "client.h"
+
+#ifdef ADNS_REGRESS_TEST
+# include "hredirect.h"
+#endif
+
+/* maximum number of concurrent DNS queries */
+#define MAXMAXPENDING 64000
+#define DEFMAXPENDING 2000
+
+/* maximum length of a line */
+#define MAXLINE 1024
+
+/* option flags */
+#define OPT_DEBUG 1
+#define OPT_POLL 2
+
+static const char *const progname= "adnsheloex";
+static const char *config_text;
+
+#define guard_null(str) ((str) ? (str) : "")
+
+#define sensible_ctype(type,ch) (type((unsigned char)(ch)))
+ /* isfoo() functions from ctype.h can't safely be fed char - blech ! */
+
+static void msg(const char *fmt, ...) {
+ va_list al;
+
+ fprintf(stderr, "%s: ", progname);
+ va_start(al,fmt);
+ vfprintf(stderr, fmt, al);
+ va_end(al);
+ fputc('\n',stderr);
+}
+
+static void aargh(const char *cause) {
+ const char *why = strerror(errno);
+ if (!why) why = "Unknown error";
+ msg("%s: %s (%d)", cause, why, errno);
+ exit(1);
+}
+
+typedef struct logline {
+ struct logline *next;
+ char *start, *name, *rest, *addr;
+ adns_query query;
+} logline;
+
+static logline *readline(FILE *inf, adns_state adns, int opts) {
+ static char buf[MAXLINE];
+ char *str, *p, *q, *r;
+ logline *line;
+
+ if (fgets(buf, MAXLINE, inf)) {
+ str= malloc(sizeof(*line) + strlen(buf) + 1);
+ if (!str) aargh("malloc");
+ line= (logline*)str;
+ line->next= NULL;
+ line->start= str+sizeof(logline);
+ strcpy(line->start, buf);
+ line->name= line->rest= line->addr= NULL;
+ /* look for unverifiable HELO information matching the regex
+ H=[a-z0-9.- ]*[(][a-z0-9.-]*[)] [[][0-9.]*[]] */
+ for (p= strchr(line->start, ' '); p; p= strchr(p+1, ' ')) {
+ if (!strncmp(p, " H=", 3)) {
+ r= strchr(p, '[');
+ if (!r) break;
+ q= strchr(p, ')');
+ if (!q || q>r) break;
+ p= strchr(p, '(');
+ if (!p || p>q) break;
+ line->name= p+1;
+ line->rest= q;
+ line->addr= r+1;
+ break;
+ }
+ }
+ if (line->name) {
+ *line->rest= '\0';
+ if (opts & OPT_DEBUG)
+ msg("submitting %s", line->name);
+ if (adns_submit(adns, line->name, adns_r_a,
+ adns_qf_quoteok_query|adns_qf_quoteok_cname|adns_qf_cname_loose,
+ NULL, &line->query))
+ aargh("adns_submit");
+ *line->rest= ')';
+ } else {
+ if (opts & OPT_DEBUG)
+ msg("no query");
+ line->query= NULL;
+ }
+ return line;
+ }
+ if (!feof(inf))
+ aargh("fgets");
+ return NULL;
+}
+
+static void proclog(FILE *inf, FILE *outf, int maxpending, int opts) {
+ int eof, err, len;
+ adns_state adns;
+ adns_answer *answer;
+ logline *head, *tail, *line;
+ adns_initflags initflags;
+
+ initflags= (opts & OPT_DEBUG) ? adns_if_debug : 0;
+ if (config_text) {
+ errno= adns_init_strcfg(&adns, initflags, stderr, config_text);
+ } else {
+ errno= adns_init(&adns, initflags, 0);
+ }
+ if (errno) aargh("adns_init");
+ head= tail= readline(inf, adns, opts);
+ len= 1; eof= 0;
+ while (head) {
+ while (head) {
+ if (head->query) {
+ if (opts & OPT_DEBUG)
+ msg("%d in queue; checking %.*s", len,
+ head->rest-head->name, guard_null(head->name));
+ if (eof || len >= maxpending) {
+ if (opts & OPT_POLL)
+ err= adns_wait_poll(adns, &head->query, &answer, NULL);
+ else
+ err= adns_wait(adns, &head->query, &answer, NULL);
+ } else {
+ err= adns_check(adns, &head->query, &answer, NULL);
+ }
+ if (err == EAGAIN) break;
+ if (err) {
+ fprintf(stderr, "%s: adns_wait/check: %s", progname, strerror(err));
+ exit(1);
+ }
+ if (answer->status == adns_s_ok) {
+ const char *addr;
+ int ok = 0;
+ fprintf(outf, "%.*s", head->rest-head->start, head->start);
+ while(answer->nrrs--) {
+ addr= inet_ntoa(answer->rrs.inaddr[answer->nrrs]);
+ ok |= !strncmp(addr, head->addr, strlen(addr));
+ fprintf(outf, " [%s]", addr);
+ }
+ fprintf(outf, "%s%s", ok ? " OK" : "", head->rest);
+ } else {
+ if (opts & OPT_DEBUG)
+ msg("query failed");
+ fputs(head->start, outf);
+ }
+ free(answer);
+ len--;
+ } else {
+ if (opts & OPT_DEBUG)
+ msg("%d in queue; no query on this line", len);
+ fputs(head->start, outf);
+ }
+ line= head; head= head->next;
+ free(line);
+ }
+ if (!eof) {
+ line= readline(inf, adns, opts);
+ if (line) {
+ if (!head) head= line;
+ else tail->next= line;
+ tail= line;
+ if (line->query) len++;
+ } else {
+ eof= 1;
+ }
+ }
+ }
+ adns_finish(adns);
+}
+
+static void printhelp(FILE *file) {
+ fputs("usage: adnsheloex [<options>] [<logfile>]\n"
+ " adnsheloex --version|--help\n"
+ "options: -c <concurrency> set max number of outstanding queries\n"
+ " -p use poll(2) instead of select(2)\n"
+ " -d turn on debugging\n"
+ " -C <config> use instead of contents of resolv.conf\n",
+ stdout);
+}
+
+static void usage(void) {
+ printhelp(stderr);
+ exit(1);
+}
+
+int main(int argc, char *argv[]) {
+ int c, opts, maxpending;
+ extern char *optarg;
+ FILE *inf;
+
+ if (argv[1] && !strncmp(argv[1],"--",2)) {
+ if (!strcmp(argv[1],"--help")) {
+ printhelp(stdout);
+ } else if (!strcmp(argv[1],"--version")) {
+ fputs(VERSION_MESSAGE("adnsheloex"),stdout);
+ } else {
+ usage();
+ }
+ if (ferror(stdout) || fclose(stdout)) { perror("stdout"); exit(1); }
+ exit(0);
+ }
+
+ maxpending= DEFMAXPENDING;
+ opts= 0;
+ while ((c= getopt(argc, argv, "c:C:dp")) != -1)
+ switch (c) {
+ case 'c':
+ maxpending= atoi(optarg);
+ if (maxpending < 1 || maxpending > MAXMAXPENDING) {
+ fprintf(stderr, "%s: unfeasible concurrency %d\n", progname, maxpending);
+ exit(1);
+ }
+ break;
+ case 'C':
+ config_text= optarg;
+ break;
+ case 'd':
+ opts|= OPT_DEBUG;
+ break;
+ case 'p':
+ opts|= OPT_POLL;
+ break;
+ default:
+ usage();
+ }
+
+ argc-= optind;
+ argv+= optind;
+
+ inf= NULL;
+ if (argc == 0)
+ inf= stdin;
+ else if (argc == 1)
+ inf= fopen(*argv, "r");
+ else
+ usage();
+
+ if (!inf)
+ aargh("couldn't open input");
+
+ proclog(inf, stdout, maxpending, opts);
+
+ if (fclose(inf))
+ aargh("fclose input");
+ if (fclose(stdout))
+ aargh("fclose output");
+
+ return 0;
+}
+
+if test "${GCC-no}" = yes; then
+ WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
+ saved_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -Wno-pointer-sign"
+
+ echo $ac_n "checking -Wno-pointer-sign""... $ac_c" 1>&6
+echo "configure:1518: checking -Wno-pointer-sign" >&5
+ if eval "test \"`echo '$''{'adns_cv_c_wnoptrsign'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+ cat > conftest.$ac_ext <<EOF
+#line 1524 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1531: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ adns_cv_c_wnoptrsign=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ adns_cv_c_wnoptrsign=no
+fi
+rm -f conftest*
+
+fi
+
+ if test "x$adns_cv_c_wnoptrsign" = xyes; then
+ true
+ echo "$ac_t""yes" 1>&6
+ WARNS="$WARNS -Wno-pointer-sign"
+ else
+ true
+ echo "$ac_t""no" 1>&6
+ fi
+
+ CFLAGS="$saved_cflags"
+else
+ WARNS=
+fi
+
+
echo $ac_n "checking __attribute__((,,))""... $ac_c" 1>&6
-echo "configure:1513: checking __attribute__((,,))" >&5
+echo "configure:1561: checking __attribute__((,,))" >&5
if eval "test \"`echo '$''{'adns_cv_c_attribute_supported'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1519 "configure"
+#line 1567 "configure"
#include "confdefs.h"
int main() {
extern int testfunction(int x) __attribute__((,,))
; return 0; }
EOF
-if { (eval echo configure:1526: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1574: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
adns_cv_c_attribute_supported=yes
else
echo $ac_n "checking __attribute__((noreturn))""... $ac_c" 1>&6
-echo "configure:1548: checking __attribute__((noreturn))" >&5
+echo "configure:1596: checking __attribute__((noreturn))" >&5
if eval "test \"`echo '$''{'adns_cv_c_attribute_noreturn'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1554 "configure"
+#line 1602 "configure"
#include "confdefs.h"
int main() {
extern int testfunction(int x) __attribute__((noreturn))
; return 0; }
EOF
-if { (eval echo configure:1561: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1609: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
adns_cv_c_attribute_noreturn=yes
else
echo $ac_n "checking __attribute__((const))""... $ac_c" 1>&6
-echo "configure:1588: checking __attribute__((const))" >&5
+echo "configure:1636: checking __attribute__((const))" >&5
if eval "test \"`echo '$''{'adns_cv_c_attribute_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1594 "configure"
+#line 1642 "configure"
#include "confdefs.h"
int main() {
extern int testfunction(int x) __attribute__((const))
; return 0; }
EOF
-if { (eval echo configure:1601: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1649: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
adns_cv_c_attribute_const=yes
else
echo $ac_n "checking __attribute__((format...))""... $ac_c" 1>&6
-echo "configure:1628: checking __attribute__((format...))" >&5
+echo "configure:1676: checking __attribute__((format...))" >&5
if eval "test \"`echo '$''{'adns_cv_attribute_format'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1634 "configure"
+#line 1682 "configure"
#include "confdefs.h"
int main() {
extern int testfunction(char *y, ...) __attribute__((format(printf,1,2)))
; return 0; }
EOF
-if { (eval echo configure:1641: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1689: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
adns_cv_attribute_format=yes
else
-if test "${GCC-no}" = yes; then
- WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
-else
- WARNS=
-fi
-
-
-
# Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
#
# It is part of adns, which is
-# Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-# Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+# Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+# Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
#
# 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
AC_DEFINE(HAVE_INLINE),
AC_MSG_RESULT(no))
-ADNS_C_GCCATTRIB
-
AC_SUBST(WARNS)
if test "${GCC-no}" = yes; then
WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
+ saved_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -Wno-pointer-sign"
+ DPKG_CACHED_TRY_COMPILE(-Wno-pointer-sign,adns_cv_c_wnoptrsign,,
+ [],
+ AC_MSG_RESULT(yes)
+ WARNS="$WARNS -Wno-pointer-sign",
+ AC_MSG_RESULT(no))
+ CFLAGS="$saved_cflags"
else
WARNS=
fi
+ADNS_C_GCCATTRIB
+
AC_SUBST(SHLIBCC)
AC_SUBST(MKSHLIB_1)
AC_SUBST(MKSHLIB_2)
void Qsocket( int type );
void Qfcntl( int fd , int cmd , long arg );
void Qconnect( int fd , const struct sockaddr *addr , int addrlen );
+void Qbind( int fd , const struct sockaddr *addr , int addrlen );
+void Qlisten( int fd , int backlog );
void Qclose( int fd );
void Qsendto( int fd , const void *msg , int msglen , const struct sockaddr *addr , int addrlen );
void Qrecvfrom( int fd , int buflen , int addrlen );
void Toutputerr(void);
void Tnomem(void);
void Tfsyscallr(const char *fmt, ...) PRINTFFORMAT(1,2);
-void Tensureoutputfile(void);
+void Tensurerecordfile(void);
void Tmust(const char *call, const char *arg, int cond);
void Tvbf(const char *fmt, ...) PRINTFFORMAT(1,2);
void Tvbvf(const char *fmt, va_list al);
void Toutputerr(void);
void Tnomem(void);
void Tfsyscallr(const char *fmt, ...) PRINTFFORMAT(1,2);
-void Tensureoutputfile(void);
+void Tensurerecordfile(void);
void Tmust(const char *call, const char *arg, int cond);
void Tvbf(const char *fmt, ...) PRINTFFORMAT(1,2);
};
static vbuf vbw;
int Hgettimeofday(struct timeval *tv, struct timezone *tz) {
+ Tensurerecordfile();
Tmust("gettimeofday","tz",!tz);
*tv= currenttime;
return 0;
Tvba(" addr="); Tvbaddr(addr,addrlen);
Q_vb();
}
+void Qbind( int fd , const struct sockaddr *addr , int addrlen ) {
+ vb.used= 0;
+ Tvba("bind");
+ Tvbf(" fd=%d",fd);
+ Tvba(" addr="); Tvbaddr(addr,addrlen);
+ Q_vb();
+}
+void Qlisten( int fd , int backlog ) {
+ vb.used= 0;
+ Tvba("listen");
+ Tvbf(" fd=%d",fd);
+ Tvbf(" backlog=%d",backlog);
+ Q_vb();
+}
void Qclose( int fd ) {
vb.used= 0;
Tvba("close");
{ "ECONNRESET", ECONNRESET },
{ "ECONNREFUSED", ECONNREFUSED },
{ "EPIPE", EPIPE },
+ { "ENOTSOCK", ENOTSOCK },
{ 0, 0 }
};
static vbuf vbw;
int Hgettimeofday(struct timeval *tv, struct timezone *tz) {
+ Tensurerecordfile();
Tmust("gettimeofday","tz",!tz);
*tv= currenttime;
return 0;
if (ferror(Tinputfile)) Tfailed("read test log input file");
if (feof(Tinputfile)) Psyntax("eof at syscall reply");
}
-static void Tensureinputfile(void) {
+void Tensurerecordfile(void) {
const char *fdstr;
int fd;
int chars;
void Q_vb(void) {
int r;
const char *nl;
- Tensureinputfile();
+ Tensurerecordfile();
if (!adns__vbuf_ensure(&vb2,vb.used+2)) Tnomem();
r= fread(vb2.buf,1,vb.used+2,Tinputfile);
if (feof(Tinputfile)) {
P_updatetime();
return r;
}
+int Hbind( int fd , const struct sockaddr *addr , int addrlen ) {
+ int r, amtread;
+ Qbind( fd , addr , addrlen );
+ if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
+ fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
+ Tensurereportfile();
+ fprintf(Treportfile,"%s",vb2.buf);
+ amtread= strlen(vb2.buf);
+ if (amtread<=0 || vb2.buf[--amtread]!='\n')
+ Psyntax("badly formed line");
+ vb2.buf[amtread]= 0;
+ if (memcmp(vb2.buf," bind=",6)) Psyntax("syscall reply mismatch");
+ if (vb2.buf[6] == 'E') {
+ int e;
+ e= Perrno(vb2.buf+6);
+ P_updatetime();
+ errno= e;
+ return -1;
+ }
+ if (memcmp(vb2.buf+6,"OK",2)) Psyntax("success/fail not E* or OK");
+ vb2.used= 6+2;
+ r= 0;
+ assert(vb2.used <= amtread);
+ if (vb2.used != amtread) Psyntax("junk at end of line");
+ P_updatetime();
+ return r;
+}
+int Hlisten( int fd , int backlog ) {
+ int r, amtread;
+ Qlisten( fd , backlog );
+ if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
+ fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
+ Tensurereportfile();
+ fprintf(Treportfile,"%s",vb2.buf);
+ amtread= strlen(vb2.buf);
+ if (amtread<=0 || vb2.buf[--amtread]!='\n')
+ Psyntax("badly formed line");
+ vb2.buf[amtread]= 0;
+ if (memcmp(vb2.buf," listen=",8)) Psyntax("syscall reply mismatch");
+ if (vb2.buf[8] == 'E') {
+ int e;
+ e= Perrno(vb2.buf+8);
+ P_updatetime();
+ errno= e;
+ return -1;
+ }
+ if (memcmp(vb2.buf+8,"OK",2)) Psyntax("success/fail not E* or OK");
+ vb2.used= 8+2;
+ r= 0;
+ assert(vb2.used <= amtread);
+ if (vb2.used != amtread) Psyntax("junk at end of line");
+ P_updatetime();
+ return r;
+}
int Hclose( int fd ) {
int r, amtread;
Qclose( fd );
if (feof(Tinputfile)) Psyntax("eof at syscall reply");
}
-static void Tensureinputfile(void) {
+void Tensurerecordfile(void) {
const char *fdstr;
int fd;
int chars;
int r;
const char *nl;
- Tensureinputfile();
+ Tensurerecordfile();
if (!adns__vbuf_ensure(&vb2,vb.used+2)) Tnomem();
r= fread(vb2.buf,1,vb.used+2,Tinputfile);
if (feof(Tinputfile)) {
static void R_recordtime(void) {
int r;
struct timeval tv, tvrel;
- Tensureoutputfile();
+ Tensurerecordfile();
r= gettimeofday(&tv,0); if (r) Tfailed("gettimeofday syscallbegin");
tvrel.tv_sec= tv.tv_sec - currenttime.tv_sec;
tvrel.tv_usec= tv.tv_usec - currenttime.tv_usec;
Tvbf("\n +%ld.%06ld",(long)tvrel.tv_sec,(long)tvrel.tv_usec);
currenttime= tv;
}
-void Tensureoutputfile(void) {
+void Tensurerecordfile(void) {
const char *fdstr;
int fd, r;
if (Toutputfile) return;
}
void Q_vb(void) {
if (!adns__vbuf_append(&vb,"",1)) Tnomem();
- Tensureoutputfile();
+ Tensurerecordfile();
if (fprintf(Toutputfile," %s\n",vb.buf) == EOF) Toutputerr();
if (fflush(Toutputfile)) Toutputerr();
}
errno= e;
return r;
}
+int Hbind( int fd , const struct sockaddr *addr , int addrlen ) {
+ int r, e;
+ Qbind( fd , addr , addrlen );
+ r= bind( fd , addr , addrlen );
+ e= errno;
+ vb.used= 0;
+ Tvba("bind=");
+ if (r) { Tvberrno(e); goto x_error; }
+ Tvba("OK");
+ x_error:
+ R_recordtime();
+ R_vb();
+ errno= e;
+ return r;
+}
+int Hlisten( int fd , int backlog ) {
+ int r, e;
+ Qlisten( fd , backlog );
+ r= listen( fd , backlog );
+ e= errno;
+ vb.used= 0;
+ Tvba("listen=");
+ if (r) { Tvberrno(e); goto x_error; }
+ Tvba("OK");
+ x_error:
+ R_recordtime();
+ R_vb();
+ errno= e;
+ return r;
+}
int Hclose( int fd ) {
int r, e;
Qclose( fd );
int r;
struct timeval tv, tvrel;
- Tensureoutputfile();
+ Tensurerecordfile();
r= gettimeofday(&tv,0); if (r) Tfailed("gettimeofday syscallbegin");
tvrel.tv_sec= tv.tv_sec - currenttime.tv_sec;
tvrel.tv_usec= tv.tv_usec - currenttime.tv_usec;
currenttime= tv;
}
-void Tensureoutputfile(void) {
+void Tensurerecordfile(void) {
const char *fdstr;
int fd, r;
void Q_vb(void) {
if (!adns__vbuf_append(&vb,"",1)) Tnomem();
- Tensureoutputfile();
+ Tensurerecordfile();
if (fprintf(Toutputfile," %s\n",vb.buf) == EOF) Toutputerr();
if (fflush(Toutputfile)) Toutputerr();
}
#define fcntl Hfcntl
#undef connect
#define connect Hconnect
+#undef bind
+#define bind Hbind
+#undef listen
+#define listen Hlisten
#undef close
#define close Hclose
#undef sendto
int Hsocket( int domain , int type , int protocol );
int Hfcntl( int fd , int cmd , ... );
int Hconnect( int fd , const struct sockaddr *addr , int addrlen );
+int Hbind( int fd , const struct sockaddr *addr , int addrlen );
+int Hlisten( int fd , int backlog );
int Hclose( int fd );
int Hsendto( int fd , const void *msg , int msglen , unsigned int flags , const struct sockaddr *addr , int addrlen );
int Hrecvfrom( int fd , void *buf , int buflen , unsigned int flags , struct sockaddr *addr , int *addrlen );
hm_arg_addr_in(addr,addrlen) hm_na
')
+hm_syscall(
+ bind, `hm_rv_succfail', `
+ hm_arg_fd(fd) hm_na
+ hm_arg_addr_in(addr,addrlen) hm_na
+')
+
+hm_syscall(
+ listen, `hm_rv_succfail', `
+ hm_arg_fd(fd) hm_na
+ hm_arg_int(backlog) hm_na
+')
+
hm_syscall(
close, `hm_rv_succfail', `
hm_arg_fd(fd) hm_na
# Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
#
# It is part of adns, which is
-# Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-# Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+# Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+# Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
#
# 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
adns_r_soa_raw= 6,
adns_r_soa= adns_r_soa_raw|adns__qtf_mail822,
- adns_r_ptr_raw= 12,
+ adns_r_ptr_raw= 12, /* do not mind PTR with wrong or missing A */
adns_r_ptr= adns_r_ptr_raw|adns__qtf_deref,
adns_r_hinfo= 13,