-/* $OpenBSD: traceroute.c,v 1.106 2014/04/18 16:46:18 florian Exp $ */
+/* $OpenBSD: traceroute.c,v 1.107 2014/04/18 16:58:02 florian Exp $ */
/* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */
/*-
long l;
uid_t uid;
u_int rtableid;
+ socklen_t len;
if ((rcvsock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
err(5, "icmp socket");
} else {
struct sockaddr_in nxt;
int dummy;
- socklen_t len;
nxt = to;
nxt.sin_port = htons(DUMMY_PORT);
if (bind(sndsock, (struct sockaddr *)&from, sizeof(from)) < 0)
err(1, "bind sndsock");
- {
- socklen_t len;
+ len = sizeof(from);
+ if (getsockname(sndsock, (struct sockaddr *)&from, &len) < 0)
+ err(1, "getsockname");
+ srcport = ntohs(from.sin_port);
- len = sizeof(from);
- if (getsockname(sndsock, (struct sockaddr *)&from, &len) < 0)
- err(1, "getsockname");
- srcport = ntohs(from.sin_port);
- }
fprintf(stderr, "traceroute to %s (%s)", hostname,
inet_ntoa(to.sin_addr));
if (source)
-/* $OpenBSD: traceroute6.c,v 1.81 2014/04/18 16:56:25 florian Exp $ */
+/* $OpenBSD: traceroute6.c,v 1.82 2014/04/18 16:58:02 florian Exp $ */
/* $KAME: traceroute6.c,v 1.63 2002/10/24 12:53:25 itojun Exp $ */
/*
uid_t uid;
int rtableid = -1;
const char *errstr;
+ socklen_t len;
/*
* Receive ICMP
} else {
struct sockaddr_in6 Nxt;
int dummy;
- socklen_t len;
Nxt = to;
Nxt.sin6_port = htons(DUMMY_PORT);
if (bind(sndsock, (struct sockaddr *)&from, from.sin6_len) < 0)
err(1, "bind sndsock");
- {
- socklen_t len;
-
- len = sizeof(from);
- if (getsockname(sndsock, (struct sockaddr *)&from, &len) < 0)
- err(1, "getsockname");
- srcport = ntohs(from.sin6_port);
- }
+ len = sizeof(from);
+ if (getsockname(sndsock, (struct sockaddr *)&from, &len) < 0)
+ err(1, "getsockname");
+ srcport = ntohs(from.sin6_port);
/*
* Message to users