diff options
| author | eric <> | 2013-03-28 09:36:03 +0000 |
|---|---|---|
| committer | eric <> | 2013-03-28 09:36:03 +0000 |
| commit | eb83684f4cf605110b51e4f93283d71a7c555523 (patch) | |
| tree | b08c95a54d60ce4230e6540d9add290c976472f0 /src/regress/lib/libc/asr/bin/common.c | |
| parent | 5d7a61f2e3d41f6fb2ec23249869cb430c508a4c (diff) | |
| download | openbsd-eb83684f4cf605110b51e4f93283d71a7c555523.tar.gz openbsd-eb83684f4cf605110b51e4f93283d71a7c555523.tar.bz2 openbsd-eb83684f4cf605110b51e4f93283d71a7c555523.zip | |
add a test case for the icmpv6 issue spotted by naddy
Diffstat (limited to 'src/regress/lib/libc/asr/bin/common.c')
| -rw-r--r-- | src/regress/lib/libc/asr/bin/common.c | 17 |
1 files changed, 10 insertions, 7 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[] = { | |||
| 69 | struct kv kv_protocol[] = { | 69 | struct 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 | ||
| 75 | static const char * | 77 | static const char * |
| 76 | kv_lookup_name(struct kv *kv, int code) | 78 | kv_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 | ||
| 86 | struct keyval { | 89 | struct keyval { |
| @@ -243,12 +246,12 @@ print_netent(struct netent *e) | |||
| 243 | void | 246 | void |
| 244 | print_addrinfo(struct addrinfo *ai) | 247 | print_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 | } |
