summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/asr/bin
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress/lib/libc/asr/bin')
-rw-r--r--src/regress/lib/libc/asr/bin/common.c17
-rw-r--r--src/regress/lib/libc/asr/bin/getaddrinfo.c6
2 files changed, 15 insertions, 8 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 @@
1/* $OpenBSD: common.c,v 1.1.1.1 2012/07/13 17:49:53 eric Exp $ */ 1/* $OpenBSD: common.c,v 1.2 2013/03/28 09:36:03 eric Exp $ */
2/* 2/*
3 * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> 3 * Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
4 * 4 *
@@ -69,18 +69,21 @@ struct kv kv_socktype[] = {
69struct kv kv_protocol[] = { 69struct kv kv_protocol[] = {
70 { IPPROTO_UDP, "udp" }, 70 { IPPROTO_UDP, "udp" },
71 { IPPROTO_TCP, "tcp" }, 71 { IPPROTO_TCP, "tcp" },
72 { IPPROTO_ICMP, "icmp" },
73 { IPPROTO_ICMPV6, "icmpv6" },
72 { 0, NULL, } 74 { 0, NULL, }
73}; 75};
74 76
75static const char * 77static const char *
76kv_lookup_name(struct kv *kv, int code) 78kv_lookup_name(struct kv *kv, int code, char *buf, size_t sz)
77{ 79{
78 while (kv->name) { 80 while (kv->name) {
79 if (kv->code == code) 81 if (kv->code == code)
80 return (kv->name); 82 return (kv->name);
81 kv++; 83 kv++;
82 } 84 }
83 return "???"; 85 snprintf(buf, sz, "%i", code);
86 return (buf);
84} 87}
85 88
86struct keyval { 89struct keyval {
@@ -243,12 +246,12 @@ print_netent(struct netent *e)
243void 246void
244print_addrinfo(struct addrinfo *ai) 247print_addrinfo(struct addrinfo *ai)
245{ 248{
246 char buf[256]; 249 char buf[256], bf[64], bt[64], bp[64];
247 250
248 printf("family=%s socktype=%s protocol=%s addr=%s canonname=%s\n", 251 printf("family=%s socktype=%s protocol=%s addr=%s canonname=%s\n",
249 kv_lookup_name(kv_family, ai->ai_family), 252 kv_lookup_name(kv_family, ai->ai_family, bf, sizeof bf),
250 kv_lookup_name(kv_socktype, ai->ai_socktype), 253 kv_lookup_name(kv_socktype, ai->ai_socktype, bt, sizeof bt),
251 kv_lookup_name(kv_protocol, ai->ai_protocol), 254 kv_lookup_name(kv_protocol, ai->ai_protocol, bp, sizeof bp),
252 print_addr(ai->ai_addr, buf, sizeof buf), 255 print_addr(ai->ai_addr, buf, sizeof buf),
253 ai->ai_canonname); 256 ai->ai_canonname);
254} 257}
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 @@
1/* $OpenBSD: getaddrinfo.c,v 1.1.1.1 2012/07/13 17:49:54 eric Exp $ */ 1/* $OpenBSD: getaddrinfo.c,v 1.2 2013/03/28 09:36:03 eric Exp $ */
2/* 2/*
3 * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> 3 * Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
4 * 4 *
@@ -81,6 +81,10 @@ main(int argc, char *argv[])
81 hints.ai_protocol = IPPROTO_UDP; 81 hints.ai_protocol = IPPROTO_UDP;
82 else if (!strcmp(optarg, "tcp")) 82 else if (!strcmp(optarg, "tcp"))
83 hints.ai_protocol = IPPROTO_TCP; 83 hints.ai_protocol = IPPROTO_TCP;
84 else if (!strcmp(optarg, "icmp"))
85 hints.ai_protocol = IPPROTO_ICMP;
86 else if (!strcmp(optarg, "icmpv6"))
87 hints.ai_protocol = IPPROTO_ICMPV6;
84 else 88 else
85 usage(); 89 usage();
86 break; 90 break;