Skip to content

Commit

Permalink
Changed how conflicitng first/max TTL works.
Browse files Browse the repository at this point in the history
  • Loading branch information
rewolff committed Feb 5, 2025
1 parent c68adc1 commit 7a8f545
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ stamp-h1*

/mtr-*.tar.gz
*.swp
*~
19 changes: 9 additions & 10 deletions ui/mtr.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,7 @@ static void parse_arg(
}
break;
case 'f':
ctl->fstTTL =
strtonum_or_err(optarg, "invalid argument", STRTO_INT);
if (ctl->fstTTL > ctl->maxTTL) {
ctl->fstTTL = ctl->maxTTL;
}
ctl->fstTTL = strtonum_or_err(optarg, "invalid argument", STRTO_INT);
if (ctl->fstTTL < 1) { /* prevent 0 hop */
ctl->fstTTL = 1;
}
Expand All @@ -489,17 +485,13 @@ static void parse_arg(
read_from_file(names, optarg);
break;
case 'm':
ctl->maxTTL =
strtonum_or_err(optarg, "invalid argument", STRTO_INT);
ctl->maxTTL = strtonum_or_err(optarg, "invalid argument", STRTO_INT);
if (ctl->maxTTL > (MaxHost - 1)) {
ctl->maxTTL = MaxHost - 1;
}
if (ctl->maxTTL < 1) { /* prevent 0 hop */
ctl->maxTTL = 1;
}
if (ctl->fstTTL > ctl->maxTTL) { /* don't know the pos of -m or -f */
ctl->fstTTL = ctl->maxTTL;
}
break;
case 'U':
ctl->maxUnknown =
Expand Down Expand Up @@ -650,6 +642,13 @@ static void parse_arg(
ctl->DisplayMode == DisplayRaw || ctl->DisplayMode == DisplayCSV)
ctl->Interactive = 0;

if (ctl->fstTTL > ctl->maxTTL) {
fprintf (stderr, "%s: firstTTL(%d) cannot be larger than maxTTL(%d). \n",
argv[0], ctl->fstTTL, ctl->maxTTL);
exit (1);
//ctl->fstTTL = ctl->maxTTL;
}

if (optind > argc - 1)
return;

Expand Down

0 comments on commit 7a8f545

Please sign in to comment.