* 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
+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.
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 +++
#
# 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
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
static char *whoami;
-void usage () {
+static void usage () {
fprintf(stderr,
"usage:\n"
"\t%s [ options ] [host]\n"
"\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"
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;
hname = 0;
hints.ai_family = 0;
+ if (argc == 1)
+ usage ();
+
while (++argv, --argc > 0) {
char *arg;
arg = *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;
}
}
- if (hname && !numeric)
+ if (hname && !numerichost)
hints.ai_flags |= AI_CANONNAME;
- if (numeric) {
+ if (numerichost) {
#ifdef AI_NUMERICHOST
hints.ai_flags |= AI_NUMERICHOST;
#else
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 { ",
Z(PASSIVE);
#ifdef AI_NUMERICHOST
Z(NUMERICHOST);
+#endif
+#ifdef AI_NUMERICSERV
+ Z(NUMERICSERV);
#endif
if (sep[0] == 0)
printf ("no-flags");
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;
}
--- /dev/null
+#define USE_FAKE_ADDRINFO
+#include "addrinfo-test.c"