From: florian Date: Wed, 23 Apr 2014 08:59:35 +0000 (+0000) Subject: Prepare for merge: introduce icmp_code for the AF switch. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a3e23d1d16501a983195f552798abf32612214bb;p=openbsd Prepare for merge: introduce icmp_code for the AF switch. OK benno@ --- diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c index fdfe180cd69..a8309a23571 100644 --- a/usr.sbin/traceroute6/traceroute6.c +++ b/usr.sbin/traceroute6/traceroute6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traceroute6.c,v 1.86 2014/04/23 08:56:31 florian Exp $ */ +/* $OpenBSD: traceroute6.c,v 1.87 2014/04/23 08:59:35 florian Exp $ */ /* $KAME: traceroute6.c,v 1.63 2002/10/24 12:53:25 itojun Exp $ */ /* @@ -293,6 +293,7 @@ double deltaT(struct timeval *, struct timeval *); char *pr_type(int); int packet_ok(int, struct msghdr *, int, int, int); int packet_ok6(struct msghdr *, int, int, int); +void icmp_code(int, int, int *, int *); void icmp6_code(int, int *, int *); void print(struct sockaddr *, int, const char *); const char *inetname(struct sockaddr *); @@ -653,7 +654,8 @@ main(int argc, char *argv[]) /* time exceeded in transit */ if (i == -1) break; - icmp6_code(i - 1, &got_there, &unreachable); + icmp_code(to->sa_family, i - 1, &got_there, + &unreachable); break; } if (cc == 0) { @@ -1026,6 +1028,18 @@ print(struct sockaddr *from, int cc, const char *to) printf(" %d bytes to %s", cc, to); } +void icmp_code(int af, int code, int *got_there, int *unreachable) +{ + switch (af) { + case AF_INET6: + return icmp6_code(code, got_there, unreachable); + break; + default: + errx(1, "unsupported AF: %d", af); + break; + } +} + void icmp6_code(int code, int *got_there, int *unreachable) {