From 98308a23e2b72a634f2c4b30c44f20e836aedd01 Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 23 Apr 2014 08:58:26 +0000 Subject: [PATCH] Prepare for merge: s/icmp_code/icmp4_code/ and use icmp_code for the AF switch. OK benno@ --- usr.sbin/traceroute/traceroute.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c index 25f2dbafbe8..fd023ef45ed 100644 --- a/usr.sbin/traceroute/traceroute.c +++ b/usr.sbin/traceroute/traceroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traceroute.c,v 1.116 2014/04/23 08:55:42 florian Exp $ */ +/* $OpenBSD: traceroute.c,v 1.117 2014/04/23 08:58:26 florian Exp $ */ /* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */ /*- @@ -263,7 +263,8 @@ void build_probe4(int, u_int8_t, int); void send_probe(int, u_int8_t, int, struct sockaddr *); int packet_ok(int, struct msghdr *, int, int, int); int packet_ok4(struct msghdr *, int, int, int); -void icmp_code(int, int *, int *); +void icmp_code(int, int, int *, int *); +void icmp4_code(int, int *, int *); void dump_packet(void); void print_exthdr(u_char *, int); void print(struct sockaddr *, int, const char *); @@ -701,7 +702,8 @@ main(int argc, char *argv[]) /* time exceeded in transit */ if (i == -1) break; - icmp_code(i - 1, &got_there, &unreachable); + icmp_code(to->sa_family, i - 1, &got_there, + &unreachable); break; } if (cc == 0) { @@ -1112,8 +1114,20 @@ 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_INET: + return icmp4_code(code, got_there, unreachable); + break; + default: + errx(1, "unsupported AF: %d", af); + break; + } +} + void -icmp_code(int code, int *got_there, int *unreachable) +icmp4_code(int code, int *got_there, int *unreachable) { struct ip *ip = (struct ip *)packet; -- 2.20.1