summaryrefslogtreecommitdiffstats
path: root/regress/lib/libc/asr/bin/common.c
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2013-03-28 09:36:03 +0000
committereric <eric@openbsd.org>2013-03-28 09:36:03 +0000
commitf2033d2fa87cb38cd8d8382bb8e32deb69b9682e (patch)
treeed6bf91ded36e6f1887216816ce0ff7a81b26541 /regress/lib/libc/asr/bin/common.c
parentMore tests for negative seeks, prodded by matthew@ (diff)
downloadwireguard-openbsd-f2033d2fa87cb38cd8d8382bb8e32deb69b9682e.tar.xz
wireguard-openbsd-f2033d2fa87cb38cd8d8382bb8e32deb69b9682e.zip
add a test case for the icmpv6 issue spotted by naddy
Diffstat (limited to 'regress/lib/libc/asr/bin/common.c')
-rw-r--r--regress/lib/libc/asr/bin/common.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/regress/lib/libc/asr/bin/common.c b/regress/lib/libc/asr/bin/common.c
index 4402d083738..8f2f4515b3f 100644
--- a/regress/lib/libc/asr/bin/common.c
+++ b/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 <eric@openbsd.org>
*
@@ -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);
}