summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Šimerda <psimerda@redhat.com>2016-03-30 16:35:15 +0200
committerPavel Šimerda <psimerda@redhat.com>2016-03-30 16:39:20 +0200
commit43e883346005b327ba39d4b01ed3a436be7f0d34 (patch)
tree4936ce98e8bb0813bea310125b7add73aa91bebe
parent5562b6f958ffab476148df58857fae54e299d1c2 (diff)
downloadiputils-43e883346005b327ba39d4b01ed3a436be7f0d34.tar.gz
tracepath: switch to dual-stack operation
-rw-r--r--tracepath.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/tracepath.c b/tracepath.c
index 8cc63a7..74a829d 100644
--- a/tracepath.c
+++ b/tracepath.c
@@ -374,7 +374,7 @@ static void usage(void)
int main(int argc, char **argv)
{
struct addrinfo hints = {
- .ai_family = AF_INET,
+ .ai_family = AF_UNSPEC,
.ai_socktype = SOCK_DGRAM,
.ai_protocol = IPPROTO_UDP,
#ifdef USE_IDN
@@ -394,8 +394,22 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
#endif
- while ((ch = getopt(argc, argv, "nbh?l:m:p:")) != EOF) {
+ while ((ch = getopt(argc, argv, "46nbh?l:m:p:")) != EOF) {
switch(ch) {
+ case '4':
+ if (hints.ai_family != AF_UNSPEC) {
+ fprintf(stderr, "tracepath: Only one -4 or -6 option may be specified\n");
+ exit(2);
+ }
+ hints.ai_family = AF_INET;
+ break;
+ case '6':
+ if (hints.ai_family != AF_UNSPEC) {
+ fprintf(stderr, "tracepath: Only one -4 or -6 option may be specified\n");
+ exit(2);
+ }
+ hints.ai_family = AF_INET6;
+ break;
case 'n':
no_resolve = 1;
break;