Skip to content

Commit 43e8833

Browse files
author
Pavel Šimerda
committed
tracepath: switch to dual-stack operation
1 parent 5562b6f commit 43e8833

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tracepath.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static void usage(void)
374374
int main(int argc, char **argv)
375375
{
376376
struct addrinfo hints = {
377-
.ai_family = AF_INET,
377+
.ai_family = AF_UNSPEC,
378378
.ai_socktype = SOCK_DGRAM,
379379
.ai_protocol = IPPROTO_UDP,
380380
#ifdef USE_IDN
@@ -394,8 +394,22 @@ int main(int argc, char **argv)
394394
setlocale(LC_ALL, "");
395395
#endif
396396

397-
while ((ch = getopt(argc, argv, "nbh?l:m:p:")) != EOF) {
397+
while ((ch = getopt(argc, argv, "46nbh?l:m:p:")) != EOF) {
398398
switch(ch) {
399+
case '4':
400+
if (hints.ai_family != AF_UNSPEC) {
401+
fprintf(stderr, "tracepath: Only one -4 or -6 option may be specified\n");
402+
exit(2);
403+
}
404+
hints.ai_family = AF_INET;
405+
break;
406+
case '6':
407+
if (hints.ai_family != AF_UNSPEC) {
408+
fprintf(stderr, "tracepath: Only one -4 or -6 option may be specified\n");
409+
exit(2);
410+
}
411+
hints.ai_family = AF_INET6;
412+
break;
399413
case 'n':
400414
no_resolve = 1;
401415
break;

0 commit comments

Comments
 (0)