From ff0d1de40e1753f3ad3f490475d4624605ee6d92 Mon Sep 17 00:00:00 2001 From: eric <> Date: Thu, 28 Mar 2013 09:36:03 +0000 Subject: add a test case for the icmpv6 issue spotted by naddy --- src/regress/lib/libc/asr/bin/common.c | 17 ++++++++++------- src/regress/lib/libc/asr/bin/getaddrinfo.c | 6 +++++- src/regress/lib/libc/asr/regress.sh | 10 +++++++++- src/regress/lib/libc/asr/regress.subr | 3 ++- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/regress/lib/libc/asr/bin/common.c b/src/regress/lib/libc/asr/bin/common.c index 4402d08373..8f2f4515b3 100644 --- a/src/regress/lib/libc/asr/bin/common.c +++ b/src/regress/lib/libc/asr/bin/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.1.1.1 2012/07/13 17:49:53 eric Exp $ */ +/* $OpenBSD: common.c,v 1.2 2013/03/28 09:36:03 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -69,18 +69,21 @@ struct kv kv_socktype[] = { struct kv kv_protocol[] = { { IPPROTO_UDP, "udp" }, { IPPROTO_TCP, "tcp" }, + { IPPROTO_ICMP, "icmp" }, + { IPPROTO_ICMPV6, "icmpv6" }, { 0, NULL, } }; static const char * -kv_lookup_name(struct kv *kv, int code) +kv_lookup_name(struct kv *kv, int code, char *buf, size_t sz) { while (kv->name) { if (kv->code == code) return (kv->name); kv++; } - return "???"; + snprintf(buf, sz, "%i", code); + return (buf); } struct keyval { @@ -243,12 +246,12 @@ print_netent(struct netent *e) void print_addrinfo(struct addrinfo *ai) { - char buf[256]; + char buf[256], bf[64], bt[64], bp[64]; printf("family=%s socktype=%s protocol=%s addr=%s canonname=%s\n", - kv_lookup_name(kv_family, ai->ai_family), - kv_lookup_name(kv_socktype, ai->ai_socktype), - kv_lookup_name(kv_protocol, ai->ai_protocol), + kv_lookup_name(kv_family, ai->ai_family, bf, sizeof bf), + kv_lookup_name(kv_socktype, ai->ai_socktype, bt, sizeof bt), + kv_lookup_name(kv_protocol, ai->ai_protocol, bp, sizeof bp), print_addr(ai->ai_addr, buf, sizeof buf), ai->ai_canonname); } diff --git a/src/regress/lib/libc/asr/bin/getaddrinfo.c b/src/regress/lib/libc/asr/bin/getaddrinfo.c index 8c4abf361e..7b8674aea9 100644 --- a/src/regress/lib/libc/asr/bin/getaddrinfo.c +++ b/src/regress/lib/libc/asr/bin/getaddrinfo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getaddrinfo.c,v 1.1.1.1 2012/07/13 17:49:54 eric Exp $ */ +/* $OpenBSD: getaddrinfo.c,v 1.2 2013/03/28 09:36:03 eric Exp $ */ /* * Copyright (c) 2012 Eric Faurot * @@ -81,6 +81,10 @@ main(int argc, char *argv[]) hints.ai_protocol = IPPROTO_UDP; else if (!strcmp(optarg, "tcp")) hints.ai_protocol = IPPROTO_TCP; + else if (!strcmp(optarg, "icmp")) + hints.ai_protocol = IPPROTO_ICMP; + else if (!strcmp(optarg, "icmpv6")) + hints.ai_protocol = IPPROTO_ICMPV6; else usage(); break; diff --git a/src/regress/lib/libc/asr/regress.sh b/src/regress/lib/libc/asr/regress.sh index 6e41a90d12..b1bbabc1f8 100644 --- a/src/regress/lib/libc/asr/regress.sh +++ b/src/regress/lib/libc/asr/regress.sh @@ -1,4 +1,4 @@ -# $OpenBSD: regress.sh,v 1.4 2012/12/17 21:15:33 eric Exp $ +# $OpenBSD: regress.sh,v 1.5 2013/03/28 09:36:03 eric Exp $ . regress.subr @@ -67,6 +67,13 @@ test_getaddrinfo() done } +test_getaddrinfo2() +{ + for i in $@; do + regress getaddrinfo -f inet6 -t raw -p icmpv6 $i + done +} + test_getnameinfo() { for i in $@; do @@ -98,6 +105,7 @@ for e in file bind local; do test_gethostbyname $WEIRD $BASIC $EXTRA test_gethostbyaddr $ADDRS test_getaddrinfo NULL $WEIRD $BASIC $EXTRA + test_getaddrinfo2 undeadly.org www.kame.net test_getnameinfo $ADDRS test_gethostbyname $ADDRS done diff --git a/src/regress/lib/libc/asr/regress.subr b/src/regress/lib/libc/asr/regress.subr index dafb7ddf75..3e8cc0ebd5 100644 --- a/src/regress/lib/libc/asr/regress.subr +++ b/src/regress/lib/libc/asr/regress.subr @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: regress.subr,v 1.1.1.1 2012/07/13 17:49:53 eric Exp $ +# $OpenBSD: regress.subr,v 1.2 2013/03/28 09:36:03 eric Exp $ TOTAL=0 FAIL=0 @@ -109,6 +109,7 @@ test "$_RUNDIR" == / && fail RUNDIR is root dir: $RUNDIR OUT=$_RUNDIR/output.log REG=$_RUNDIR/regress.log +ETC=$_RUNDIR/etc echo -n > $REG echo -n > $OUT -- cgit v1.2.3-55-g6feb