summaryrefslogtreecommitdiffstats
path: root/src/tests/resolve
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2005-09-09 21:30:38 +0000
committerKen Raeburn <raeburn@mit.edu>2005-09-09 21:30:38 +0000
commitde6ce224dbda9480f4cbed14f2ce8f5e9f3028a7 (patch)
tree77b3a7832d4f69ccb9fc3e54b0bed96846f98dd3 /src/tests/resolve
parentd284fca175e5aa23d8aadffd0150470acd21a2e4 (diff)
downloadkrb5-de6ce224dbda9480f4cbed14f2ce8f5e9f3028a7.tar.gz
krb5-de6ce224dbda9480f4cbed14f2ce8f5e9f3028a7.tar.xz
krb5-de6ce224dbda9480f4cbed14f2ce8f5e9f3028a7.zip
mine:
* fake-addrinfo-test.c: New file. * Makefile.in (check): Do pass arguments to addrinfo-test invocation added by Marc's patch. (fake-addrinfo-test): New target. (all): Depend on it. (SRCS): Fix typo in last change. Add fake-addrinfo-test.c. (OBJS): Add fake-addrinfo-test.o. from Marc Aurele La France: * Makefile.in: Build addrinfo-test. * addrinfo-test.c (main): 'numeric' -> 'numerichost'; Add -n option to set AI_NUMERICSERV (if available); print usage message when no arguments are given. ticket: 3176 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17379 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/tests/resolve')
-rw-r--r--src/tests/resolve/ChangeLog17
-rw-r--r--src/tests/resolve/Makefile.in29
-rw-r--r--src/tests/resolve/addrinfo-test.c33
-rw-r--r--src/tests/resolve/fake-addrinfo-test.c2
4 files changed, 67 insertions, 14 deletions
diff --git a/src/tests/resolve/ChangeLog b/src/tests/resolve/ChangeLog
index b19b33e23..f84ca064b 100644
--- a/src/tests/resolve/ChangeLog
+++ b/src/tests/resolve/ChangeLog
@@ -1,3 +1,20 @@
+2005-09-07 Ken Raeburn <raeburn@mit.edu>
+
+ * fake-addrinfo-test.c: New file.
+ * Makefile.in (check): Do pass arguments to addrinfo-test
+ invocation added by Marc's patch.
+ (fake-addrinfo-test): New target.
+ (all): Depend on it.
+ (SRCS): Fix typo in last change. Add fake-addrinfo-test.c.
+ (OBJS): Add fake-addrinfo-test.o.
+
+2005-09-01 Marc Aurele La France <tsi@ualberta.ca>
+
+ * Makefile.in: Build addrinfo-test.
+ * addrinfo-test.c (main): 'numeric' -> 'numerichost'; Add -n option
+ to set AI_NUMERICSERV (if available); print usage message when no
+ arguments are given.
+
2004-08-23 Ken Raeburn <raeburn@mit.edu>
* addrinfo-test.c: New file.
diff --git a/src/tests/resolve/Makefile.in b/src/tests/resolve/Makefile.in
index 712cfa440..653b587f7 100644
--- a/src/tests/resolve/Makefile.in
+++ b/src/tests/resolve/Makefile.in
@@ -6,21 +6,30 @@ RUN_SETUP = @KRB5_RUN_ENV@
PROG_LIBPATH=-L$(TOPLIBD)
PROG_RPATH=$(KRB5_LIBDIR)
-OBJS=resolve.o
-SRCS=$(srcdir)/resolve.c
+OBJS=resolve.o addrinfo-test.o fake-addrinfo-test.o
+SRCS=$(srcdir)/resolve.c $(srcdir)/addrinfo-test.c \
+ $(srcdir)/fake-addrinfo-test.c
-all:: resolve
+all:: resolve addrinfo-test fake-addrinfo-test
-resolve: $(OBJS)
- $(CC_LINK) -o resolve $(OBJS) $(LIBS)
+resolve: resolve.o
+ $(CC_LINK) -o $@ $< $(LIBS)
-check:: resolve
+addrinfo-test: addrinfo-test.o
+ $(CC_LINK) -o $@ $< $(LIBS)
+
+fake-addrinfo-test: fake-addrinfo-test.o
+ $(CC_LINK) -o $@ $< $(SUPPORT_LIB) $(LIBS)
+
+check:: resolve addrinfo-test
$(RUN_SETUP) ./resolve
+ $(RUN_SETUP) ./addrinfo-test -p telnet
+ $(RUN_SETUP) ./fake-addrinfo-test -p telnet
install::
clean::
- $(RM) resolve
+ $(RM) resolve addrinfo-test
# +++ Dependency line eater +++
#
@@ -28,3 +37,9 @@ clean::
# the Makefile.in file
#
$(OUTPRE)resolve.$(OBJEXT): resolve.c
+$(OUTPRE)addrinfo-test.$(OBJEXT): addrinfo-test.c
+$(OUTPRE)fake-addrinfo-test.$(OBJEXT): fake-addrinfo-test.c \
+ addrinfo-test.c $(SRCTOP)/include/fake-addrinfo.h $(SRCTOP)/include/port-sockets.h \
+ $(BUILDTOP)/include/krb5/autoconf.h $(SRCTOP)/include/socket-utils.h \
+ $(SRCTOP)/include/k5-platform.h $(BUILDTOP)/include/krb5/autoconf.h \
+ $(SRCTOP)/include/k5-thread.h
diff --git a/src/tests/resolve/addrinfo-test.c b/src/tests/resolve/addrinfo-test.c
index f2bc0c8f3..1aa30602c 100644
--- a/src/tests/resolve/addrinfo-test.c
+++ b/src/tests/resolve/addrinfo-test.c
@@ -37,6 +37,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
@@ -84,7 +85,7 @@ static const char *socktypename (int t) {
static char *whoami;
-void usage () {
+static void usage () {
fprintf(stderr,
"usage:\n"
"\t%s [ options ] [host]\n"
@@ -103,6 +104,7 @@ void usage () {
"\n"
"\t-p P\tspecify port P (service name or port number)\n"
"\t-N\thostname is numeric, skip DNS query\n"
+ "\t-n\tservice/port is numeric (sets AI_NUMERICSERV)\n"
"\t-P\tset AI_PASSIVE\n"
"\n"
"default: protocol 0, socket type 0, address family 0, null port\n"
@@ -128,7 +130,7 @@ static const char *familyname (int f) {
int main (int argc, char *argv[])
{
struct addrinfo *ap, *ap2;
- int err, numeric = 0;
+ int err, numerichost = 0, numericserv = 0;
char *hname, *port = 0, *sep;
struct addrinfo hints;
@@ -145,6 +147,9 @@ int main (int argc, char *argv[])
hname = 0;
hints.ai_family = 0;
+ if (argc == 1)
+ usage ();
+
while (++argv, --argc > 0) {
char *arg;
arg = *argv;
@@ -189,7 +194,10 @@ int main (int argc, char *argv[])
hints.ai_family = AF_INET6;
break;
case 'N':
- numeric = 1;
+ numerichost = 1;
+ break;
+ case 'n':
+ numericserv = 1;
break;
case 'P':
hints.ai_flags |= AI_PASSIVE;
@@ -199,9 +207,9 @@ int main (int argc, char *argv[])
}
}
- if (hname && !numeric)
+ if (hname && !numerichost)
hints.ai_flags |= AI_CANONNAME;
- if (numeric) {
+ if (numerichost) {
#ifdef AI_NUMERICHOST
hints.ai_flags |= AI_NUMERICHOST;
#else
@@ -209,6 +217,14 @@ int main (int argc, char *argv[])
exit(1);
#endif
}
+ if (numericserv) {
+#ifdef AI_NUMERICSERV
+ hints.ai_flags |= AI_NUMERICSERV;
+#else
+ fprintf(stderr, "AI_NUMERICSERV not defined on this platform\n");
+ exit(1);
+#endif
+ }
printf("getaddrinfo(hostname %s, service %s,\n"
" hints { ",
@@ -220,6 +236,9 @@ int main (int argc, char *argv[])
#ifdef AI_NUMERICHOST
Z(NUMERICHOST);
#endif
+#ifdef AI_NUMERICSERV
+ Z(NUMERICSERV);
+#endif
if (sep[0] == 0)
printf ("no-flags");
if (hints.ai_family)
@@ -273,11 +292,11 @@ int main (int argc, char *argv[])
printf("\taddr = %-28s\tport = %s\n", hbuf, pbuf);
err = getnameinfo(ap2->ai_addr, ap2->ai_addrlen, hbuf, sizeof (hbuf),
- 0, 0, NI_NAMEREQD);
+ pbuf, sizeof(pbuf), NI_NAMEREQD);
if (err)
printf("\tgetnameinfo(NI_NAMEREQD): %s\n", eaistr(err));
else
- printf("\tgetnameinfo => %s\n", hbuf);
+ printf("\tgetnameinfo => %s, %s\n", hbuf, pbuf);
}
return 0;
}
diff --git a/src/tests/resolve/fake-addrinfo-test.c b/src/tests/resolve/fake-addrinfo-test.c
new file mode 100644
index 000000000..f04024d73
--- /dev/null
+++ b/src/tests/resolve/fake-addrinfo-test.c
@@ -0,0 +1,2 @@
+#define USE_FAKE_ADDRINFO
+#include "addrinfo-test.c"