]> git.ipfire.org Git - thirdparty/mtr.git/log
thirdparty/mtr.git
8 years agocmdline: multiple host names dropped all but one host (issue #168) 169/head
Matt Kimball [Wed, 7 Dec 2016 15:43:08 +0000 (07:43 -0800)] 
cmdline: multiple host names dropped all but one host  (issue #168)

Change 1ed2bab broke multiple host names, either specified through
the --filename option, or listed on the commandline.  This was
due to well-intentioned refactoring of the hostname linked list
management which happened to lose all host names other than the
last name in the list.

I've fixed the append_to_names to walk the list of host names before
appending a new host name.  This does make the building of host names
O(n^2) rather than O(n), but I'm skeptical that will impact anyone's
life in a negative way, because it only happens at startup, and
it does simplify the code.

Also, multiple host names will now work in all non-interactive modes
(i.e. report, txt, json, xml, raw, csv) instead of just CSV mode.

8 years agoMerge branch 'master' of github.com:traviscross/mtr
R.E. Wolff [Sat, 29 Oct 2016 09:50:34 +0000 (11:50 +0200)] 
Merge branch 'master' of github.com:traviscross/mtr

8 years agoheader alignment issue found&fixed by meingtsla. Fixes #164
R.E. Wolff [Sat, 29 Oct 2016 09:50:13 +0000 (11:50 +0200)] 
header alignment issue found&fixed by meingtsla. Fixes #164

8 years agoMerge pull request #162 from vaygr/row-color-fix
rewolff [Thu, 27 Oct 2016 22:05:41 +0000 (00:05 +0200)] 
Merge pull request #162 from vaygr/row-color-fix

Respect theme foreground color

8 years agorespect theme foreground color 162/head
Vlad Glagolev [Thu, 27 Oct 2016 15:45:30 +0000 (11:45 -0400)] 
respect theme foreground color

8 years agofixed dynamic DNS on/off switch. Fixed #160
R.E. Wolff [Wed, 26 Oct 2016 06:52:49 +0000 (08:52 +0200)] 
fixed dynamic DNS on/off switch. Fixed #160

8 years agoMerge branch 'master' of github.com:traviscross/mtr
R.E. Wolff [Wed, 26 Oct 2016 06:44:44 +0000 (08:44 +0200)] 
Merge branch 'master' of github.com:traviscross/mtr

8 years agore-initialize ipinfo_no and -max. Fixes #161.
R.E. Wolff [Wed, 26 Oct 2016 06:44:35 +0000 (08:44 +0200)] 
re-initialize ipinfo_no and -max. Fixes #161.

8 years agoMerge pull request #159 from kerolasa/2016-10-11
rewolff [Tue, 11 Oct 2016 21:12:51 +0000 (23:12 +0200)] 
Merge pull request #159 from kerolasa/2016-10-11

2016-10-11 let the dust settle

8 years agouser interface: do not allow out of range --ipinfo arguments 159/head
Sami Kerola [Tue, 11 Oct 2016 20:20:50 +0000 (21:20 +0100)] 
user interface: do not allow out of range --ipinfo arguments

Likewise --displaymode and --port.

8 years agoregression: fix --displaymode=2 argument
Sami Kerola [Tue, 11 Oct 2016 18:53:01 +0000 (19:53 +0100)] 
regression: fix --displaymode=2 argument

Input validation needs fixing as well.  Breaking commit tat made storage too
narrow effectively disabled validation.

Broken-since: b72d62b4ac2831bbe200b5f8ac8aa3403079c0d9
Partially-fixed-in: 69f5195a92593c6baeb6f51c108c31c0bbe1642a
Reported-by: Narthorn <narthorn@gmail.com>
8 years agobuild-sys: enable all system extensions
Sami Kerola [Sun, 9 Oct 2016 21:38:01 +0000 (22:38 +0100)] 
build-sys: enable all system extensions

This directive ensures stuff like large file support works without anyone
even noticing.

Reference: https://www.gnu.org/software/autoconf/manual/autoconf-2.64/html_node/Posix-Variants.html

8 years agobuild-sys: use proper check to find if time_t is defined
Sami Kerola [Sun, 9 Oct 2016 21:21:34 +0000 (22:21 +0100)] 
build-sys: use proper check to find if time_t is defined

The time_t check feels unlikely to be necessary, but perhaps it is useful.
At least it used to be back in 2004.

Reference: 3210151c58dd98731816b57b0e375250aeb8fb6f

8 years agocleanup: clarify preprocessor nesting
Sami Kerola [Sun, 9 Oct 2016 20:32:59 +0000 (21:32 +0100)] 
cleanup: clarify preprocessor nesting

Indent declarations if they are nested, and add at the end of particularly
long #ifdef segments a marker telling where they started.

8 years agocleanup: move definitions and struct declarations to mtr.h
Sami Kerola [Sun, 9 Oct 2016 20:03:29 +0000 (21:03 +0100)] 
cleanup: move definitions and struct declarations to mtr.h

It is best to keep all of these in one location.

8 years agodata types: move names list away from global scope
Sami Kerola [Sun, 9 Oct 2016 13:30:51 +0000 (14:30 +0100)] 
data types: move names list away from global scope

This list can easily be moved to a narrow scope, so do that.

8 years agocleanup: move file scope variables to the beginning of file
Sami Kerola [Sun, 9 Oct 2016 10:27:07 +0000 (11:27 +0100)] 
cleanup: move file scope variables to the beginning of file

Writing file scope global variables in between function somewhere half way
down feels like an attempt to hide these variables.  This commit moves such
variables to beginning of file before functions.  From technical point of
view the change is unnecessary, but hope is to help to read the code.

8 years agodata types: move variables from a file to a function scope
Sami Kerola [Sun, 9 Oct 2016 10:02:38 +0000 (11:02 +0100)] 
data types: move variables from a file to a function scope

Use of static keyword, that ensures persistent variables within function
during different invocations, is the reason why these values can be moved
from global scope to a function scope.

8 years agocurses: convert magic numbers to an enum list
Sami Kerola [Sat, 8 Oct 2016 22:24:46 +0000 (23:24 +0100)] 
curses: convert magic numbers to an enum list

This improves readability.  It is eaasier to read what is the color rather
refer a lookup map near by.

8 years agodisplay: avoid unnecessary switch case clauses
Sami Kerola [Sat, 8 Oct 2016 10:28:57 +0000 (11:28 +0100)] 
display: avoid unnecessary switch case clauses

These functions are shorter, and more simple, with if clause.

8 years agostyle: convert c++ comment style to c style
Sami Kerola [Sat, 8 Oct 2016 10:11:48 +0000 (11:11 +0100)] 
style: convert c++ comment style to c style

// c++ style comments are not exactly forbid by standard, but
/* mixing two styles is worse than sticking to a one */

Reference: http://c0x.coding-guidelines.com/6.4.9.html

8 years agocleanup: remove dead code
Sami Kerola [Wed, 5 Oct 2016 20:48:18 +0000 (21:48 +0100)] 
cleanup: remove dead code

Mostly comments, and some code without effect.

Reference: bfcbfb9db72e88c8124ac5e181666b49d3716329

8 years agocurses: use switch case in mtr_curses_keyaction()
Sami Kerola [Tue, 4 Oct 2016 16:44:33 +0000 (17:44 +0100)] 
curses: use switch case in mtr_curses_keyaction()

Do tolower() call only once before switch case to remove boilerplateing.  In
same go clean up indentation style in this function.

8 years agocurses: simplify format_number()
Sami Kerola [Tue, 4 Oct 2016 16:28:56 +0000 (17:28 +0100)] 
curses: simplify format_number()

When sprintf() calls are closer to each other it is easier to see how they
differ.

8 years agowarnings: fix warnings when everything possible is turned on
Sami Kerola [Tue, 4 Oct 2016 16:00:34 +0000 (17:00 +0100)] 
warnings: fix warnings when everything possible is turned on

Tested with gcc (GCC) 6.2.1 20160830 and following options

CFLAGS="-O -fPIC -D_FORTIFY_SOURCE -W -Wabi -DANOTHER_BRICK_IN_THE -Wall
-Wattributes -Wbad-function-cast -Wbuiltin-macro-redefined -Wcast-align
-Wchar-subscripts -Wcoverage-mismatch -Wcpp -Wdeclaration-after-statement
-Wdeprecated -Wdeprecated-declarations -Wdisabled-optimization
-Wdiv-by-zero -Wendif-labels -Wextra -Wfloat-equal -Wformat-contains-nul
-Wformat-extra-args -Wformat-nonliteral -Wformat-security -Wformat-y2k
-Wformat-zero-length -Wformat=2 -Winit-self -Winvalid-pch -Wlogical-op
-Wmissing-declarations -Wmissing-include-dirs -Wmissing-noreturn
-Wmissing-prototypes -Wmultichar -Wnested-externs -Wno-format-nonliteral
-Wno-inline -Wno-logical-op -Wno-long-long -Wno-missing-field-initializers
-Wno-overlength-strings -Wno-sign-compare -Wno-unused-parameter
-Wno-unused-result -Wnormalized=nfc -Wold-style-definition -Woverflow
-Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpointer-arith
-Wpointer-to-int-cast -Wpragmas -Wredundant-decls -Wshadow -Wsign-compare
-Wstrict-aliasing -Wstrict-aliasing=2 -Wstrict-prototypes
-Wsuggest-attribute=noreturn -Wsync-nand -Wtrampolines -Wtype-limits
-Wundef -Wuninitialized -Wunknown-pragmas -Wunused -Wunused-local-typedefs
-Wvla -Wvolatile-register-var -Wwrite-strings -fdata-sections
-fdiagnostics-show-option -ffunction-sections -fno-common -funit-at-a-time
-fvisibility=hidden -pipe" ./configure && make

8 years agoMerge pull request #158 from Narthorn/displaymode
rewolff [Tue, 11 Oct 2016 09:00:54 +0000 (11:00 +0200)] 
Merge pull request #158 from Narthorn/displaymode

Add displaymode 2 back in

8 years agoMerge pull request #157 from Narthorn/master
rewolff [Tue, 11 Oct 2016 09:00:15 +0000 (11:00 +0200)] 
Merge pull request #157 from Narthorn/master

Initialize dns process before opening display

8 years agoAdd displaymode 2 back in 158/head
Narthorn [Sat, 8 Oct 2016 08:15:44 +0000 (10:15 +0200)] 
Add displaymode 2 back in

Enums are good, but don't forget to add them all

8 years agoInitialize dns process before opening display 157/head
Narthorn [Sat, 8 Oct 2016 06:38:10 +0000 (08:38 +0200)] 
Initialize dns process before opening display

By opening the display before the dns process is forked, the child
inherits things like ncurses's handler for SIGWINCH (window resize
event), which can cause it to crash and leave the parent process in
an infinite select() loop, freezing the display.

8 years agoMerge pull request #153 from kerolasa/2016-10-02
rewolff [Tue, 4 Oct 2016 12:06:36 +0000 (14:06 +0200)] 
Merge pull request #153 from kerolasa/2016-10-02

net: fix net_reopen() initialization

8 years agonet: fix net_reopen() initialization 153/head
Sami Kerola [Sun, 2 Oct 2016 21:17:39 +0000 (22:17 +0100)] 
net: fix net_reopen() initialization

Mantas Mikulenas reviewed recent pull reques that contained commit
b90a522f23167bd00062504803e94220937aba23 making a code path quicker.
Unfortunately initialization was incomplete, as demonstrated by R.E.
Wolff in same review.  Fix is to use GCC designated initializer.

Reference: https://github.com/traviscross/mtr/pull/151
Reference: https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html

Review update.  Replace following initializer with an iterative loop.

  .saved = { [0 ... SAVED_PINGS - 1] = -2 },

This is done to keep compatibility with non-gcc compilers.

Reference: https://github.com/traviscross/mtr/pull/153

8 years agoMerge pull request #151 from kerolasa/2016-09-29
rewolff [Fri, 30 Sep 2016 06:38:46 +0000 (08:38 +0200)] 
Merge pull request #151 from kerolasa/2016-09-29

2016-09-29 BSD build fix and minor improvements

8 years agomisc: improve random initialization 151/head
Sami Kerola [Thu, 29 Sep 2016 18:30:02 +0000 (19:30 +0100)] 
misc: improve random initialization

Typical linux pid range is 2^15, which is not a lot as a entropy sourcee.
This change uses full 32 bits when random is initialized.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agowarnings: ensure printf will not overflow
Sami Kerola [Thu, 29 Sep 2016 18:26:45 +0000 (19:26 +0100)] 
warnings: ensure printf will not overflow

Overflow in here should be only a theoretical possibility, but making even
such impossible cannot be a bad thing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoportability: fix bsd build
Sami Kerola [Thu, 29 Sep 2016 18:10:52 +0000 (19:10 +0100)] 
portability: fix bsd build

Thanks-to: Etienne Labaume
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoperformance: make reset in net.c more effective
Sami Kerola [Sun, 25 Sep 2016 21:09:09 +0000 (22:09 +0100)] 
performance: make reset in net.c more effective

Set all values in one go rather than each struct member separately.  Notice
that template initializer takes advantage of setting all missing values
using value of the last item that was set.  That makes them to be implicitly
zero.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoMerge pull request #149 from jnweiger/patch-1
rewolff [Sat, 17 Sep 2016 11:14:51 +0000 (13:14 +0200)] 
Merge pull request #149 from jnweiger/patch-1

Mention + and - keys in the man page

8 years agoMention + and - keys in the man page 149/head
Jürgen Weigert [Sat, 17 Sep 2016 10:46:01 +0000 (12:46 +0200)] 
Mention + and - keys in the man page

Found +. -. Ctrl-L keys and described their function under the --curses option.

8 years agoMerge pull request #147 from kerolasa/various
rewolff [Mon, 5 Sep 2016 07:49:25 +0000 (09:49 +0200)] 
Merge pull request #147 from kerolasa/various

data types, various cleanups, clarifications, corrections, and few fixes

8 years agodocs: add Sami Kerola to authors 147/head
Sami Kerola [Mon, 29 Aug 2016 12:45:40 +0000 (13:45 +0100)] 
docs: add Sami Kerola to authors

8 years agoperformance: set few variables read-only
Sami Kerola [Sun, 4 Sep 2016 20:04:02 +0000 (21:04 +0100)] 
performance: set few variables read-only

8 years agocleanup: remove message duplicate
Sami Kerola [Sun, 4 Sep 2016 20:02:23 +0000 (21:02 +0100)] 
cleanup: remove message duplicate

Commit 9a9003a436b19044abf35a73c9fc5bb5a271b7aa missed removing this line.

8 years agocleanup: correct display_offset variable usage
Sami Kerola [Sun, 4 Sep 2016 19:18:00 +0000 (20:18 +0100)] 
cleanup: correct display_offset variable usage

Variable display_offset was missed to move from local scope to control
structure in file it had it as local.

8 years agocleanup: set variable only if it is used
Sami Kerola [Sun, 4 Sep 2016 16:20:55 +0000 (17:20 +0100)] 
cleanup: set variable only if it is used

Variable introduction needs to be same way preprocessor conditional as the
related code.  This is a minor clean up, because modern compilers should
remove these types of variables automatically.

8 years agocleanup: remove more/bottom labels header separation from mpls
Sami Kerola [Sun, 4 Sep 2016 16:08:17 +0000 (17:08 +0100)] 
cleanup: remove more/bottom labels header separation from mpls

Commit a932cb2abc85651ca6f33a06d7b64448c1d27f65 added this separation, but
after five years and a bit the printouts has not become different.  It is
time to remove this todo item.

8 years agoperformance: make get_iiwidth() to be const function
Sami Kerola [Sun, 4 Sep 2016 08:46:52 +0000 (09:46 +0100)] 
performance: make get_iiwidth() to be const function

Change input argument to be a variable, so that optimizer can kick in and
take short cuts when possible.

Reference; https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes

8 years agocleanup: make unused and const attributes to look the same
Sami Kerola [Sun, 4 Sep 2016 08:30:25 +0000 (09:30 +0100)] 
cleanup: make unused and const attributes to look the same

Definition CONST was already reserved in net.h to mean 'const' as a variable
attribute, so function attribute got a ATTRIBUTE_ prefix to separate them.
This change unifies unused to look the same.

8 years agocrash fix: ctl->iiwidth_len was not initialized correctly
Sami Kerola [Sun, 4 Sep 2016 00:12:08 +0000 (01:12 +0100)] 
crash fix: ctl->iiwidth_len was not initialized correctly

It was a mistake to add iiwidth_len to struct mtr_ctl.  First of all the
value needed in that field was never set, and that resulted to crash when
running command with --csv option.

Secondly adding the field was bad idea to begin with.  Number of array
elements is known only within context of asn.c file, so it is better to add
interface to query it rather than try to set value to a structure.  Later
design is prone to cause futher bugs, if/when execution flow is not as one
might assume.

8 years agocrash fix: never return const string as address
Sami Kerola [Sat, 3 Sep 2016 23:49:06 +0000 (00:49 +0100)] 
crash fix: never return const string as address

String that comes from #define can cause SIGSEGV.

8 years agocrash fix: add ctl structure to gtk Pause_clicked() handler
Sami Kerola [Sat, 3 Sep 2016 22:25:17 +0000 (23:25 +0100)] 
crash fix: add ctl structure to gtk Pause_clicked() handler

Without this handler net_max() will crash with SIGSEGV at line 1209.  gdb
backtrace gave clear hint what was the problem, and where it needs to be
fixed.

  #0 0x4109db in net_max /home/src/mtr/net.c:1209
  #1 0x42478e in gtk_redraw /home/src/mtr/gtk.c:508
  #2 0x422fc7 in Pause_clicked /home/src/mtr/gtk.c:121

8 years agocleanup: merge two trim functions to one
Sami Kerola [Sat, 3 Sep 2016 07:02:09 +0000 (08:02 +0100)] 
cleanup: merge two trim functions to one

As a minor improvement make the trimmed string to stay at same start
address, so that trims can be safely done to pointers that are allocated and
need to be free'd later on.  There is no such case in this code, but it is
good idea to write functions the way they will not cause memory issues
if/when such use case happens.

8 years agoperformance: use fewer printw() calls to center text
Sami Kerola [Fri, 2 Sep 2016 21:05:53 +0000 (22:05 +0100)] 
performance: use fewer printw() calls to center text

Avoid printing white space one by one when variable length print out of
nothing can do the same thing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agobug fix: long option --gracetime is correct, --graceperiod is not
Sami Kerola [Sun, 4 Sep 2016 15:33:25 +0000 (16:33 +0100)] 
bug fix: long option --gracetime is correct, --graceperiod is not

Commit 5dbeb8f1b4084c38103e92dbd028da2762c1f0a9 introduced new long option
--gracetime, that was documented as --graceperiod.  Only one or the other
can be correct, so pick the --gracetime and update documentation to tell
this is, the expected long option.

8 years agousability: add bash-completion file
Sami Kerola [Wed, 31 Aug 2016 22:27:56 +0000 (23:27 +0100)] 
usability: add bash-completion file

8 years agoposix: do not use time(2) input argument
Sami Kerola [Mon, 29 Aug 2016 21:38:05 +0000 (22:38 +0100)] 
posix: do not use time(2) input argument

Function time(2) argument is obsolescent and should always be NULL in new
code.  When the argument is NULL, the call cannot fail.

Reference: http://man7.org/linux/man-pages/man2/time.2.html

8 years agousability: use ISO-8601 timestamp
Sami Kerola [Mon, 29 Aug 2016 18:45:36 +0000 (19:45 +0100)] 
usability: use ISO-8601 timestamp

The ISO timestamp has timezone information, and is easily parsable.

8 years agoreliability: check writing to stdout and stderr was successful
Sami Kerola [Mon, 29 Aug 2016 18:17:32 +0000 (19:17 +0100)] 
reliability: check writing to stdout and stderr was successful

This is expected behaviour.

$ mtr --help > /dev/full; echo $?
./mtr: write error: No space left on device
1

Earlier write errors returned successful zero.

Reference: https://www.irill.org/events/ghm-gnu-hackers-meeting/videos/jim-meyering-goodbye-world-the-perils-of-relying-on-output-streams-in-c

8 years agoreliability: always check strdup() return value
Sami Kerola [Mon, 29 Aug 2016 17:55:54 +0000 (18:55 +0100)] 
reliability: always check strdup() return value

Exit if allocation fails.

8 years agoreliability: always check malloc() return value
Sami Kerola [Mon, 29 Aug 2016 17:53:32 +0000 (18:53 +0100)] 
reliability: always check malloc() return value

Exit if allocation fails.

8 years agoreliability: further removal of unsave string operation
Sami Kerola [Mon, 29 Aug 2016 17:36:47 +0000 (18:36 +0100)] 
reliability: further removal of unsave string operation

Replace strcpy() + strcat() with a snprintf().  In same go name a magic
constant to a definition.

8 years agoreliability: ensure string copy results to a null determined string
Sami Kerola [Mon, 29 Aug 2016 17:25:27 +0000 (18:25 +0100)] 
reliability: ensure string copy results to a null determined string

Copying strings is much harder than it superficially looks, see reference
for further information,

Reference: http://meyering.net/crusade-to-eliminate-strncpy/

8 years agocleanup: move generic utility functions to a separate file
Sami Kerola [Mon, 29 Aug 2016 17:02:15 +0000 (18:02 +0100)] 
cleanup: move generic utility functions to a separate file

The utils.c is basically an internal general purpose function library.

8 years agocleanup: use ICMP definitions from linux/icmp.h when possible
Sami Kerola [Mon, 29 Aug 2016 16:46:36 +0000 (17:46 +0100)] 
cleanup: use ICMP definitions from linux/icmp.h when possible

8 years agocleanup: avoid duplicating stdint.h
Sami Kerola [Mon, 29 Aug 2016 12:05:01 +0000 (13:05 +0100)] 
cleanup: avoid duplicating stdint.h

Use exactly defined data types from stdint.h rather than defining own
similar types.

Reference: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdint.h.html

8 years agocleanup: remove commented out includes in dns.c
Sami Kerola [Mon, 29 Aug 2016 11:42:59 +0000 (12:42 +0100)] 
cleanup: remove commented out includes in dns.c

Thees have been two years commented out, and if someone really has to fiddle
around with comments that is a failure of autotools usage and needs to be
addressed by getting the autoconf to do the right things.

8 years agocleanup: use definition for a magic value appearing twice in code
Sami Kerola [Mon, 29 Aug 2016 10:54:36 +0000 (11:54 +0100)] 
cleanup: use definition for a magic value appearing twice in code

This improves readability, and makes it almost impossible to get these out
of sync.

8 years agousability: print usage() if unknown options are used
Sami Kerola [Mon, 29 Aug 2016 10:09:08 +0000 (11:09 +0100)] 
usability: print usage() if unknown options are used

It is better to burn and fail than allow recovery from unexpected user
interface usage.

8 years agowarnings: avoid vla when malloc() is more appropriate
Sami Kerola [Mon, 29 Aug 2016 09:54:55 +0000 (10:54 +0100)] 
warnings: avoid vla when malloc() is more appropriate

Assuming allocatin failure will happen use of vla will cause very strange
looking error.  In this occasion it is better to use malloc, and check it
was successful.  Found with smatch scan.

8 years agowarnings: do not use zero as NULL
Sami Kerola [Mon, 29 Aug 2016 09:52:44 +0000 (10:52 +0100)] 
warnings: do not use zero as NULL

Found with smatch scan.

8 years agowarnings: correct function pointer prototype argument
Sami Kerola [Mon, 29 Aug 2016 09:41:28 +0000 (10:41 +0100)] 
warnings: correct function pointer prototype argument

In struct fields the function pointer is getting assignments of functions
that take one int as input argument.

8 years agocrash fix: make --xml not to dump core 146/head
Sami Kerola [Sun, 28 Aug 2016 23:55:24 +0000 (00:55 +0100)] 
crash fix: make --xml not to dump core

This also makes --report option to print values rather than %5N.  And in
same go remove a floating point exception.

Crash these issues were introduced in caad4c42fb8ef0d830fd37608a96702d6774f93f

8 years agodata types: move rest of the global variables to control structures
Sami Kerola [Sun, 28 Aug 2016 19:12:58 +0000 (20:12 +0100)] 
data types: move rest of the global variables to control structures

Many of these variables seem to related to printing.  One can reasonably
assume the control structure will need to be split to a library and
none-library parts.

8 years agodata types: make control structure smaller
Sami Kerola [Sun, 28 Aug 2016 18:13:22 +0000 (19:13 +0100)] 
data types: make control structure smaller

Move boolean variables, and other variables that has well known small size,
to a named bit field.

8 years agodata types: move global data to control structures
Sami Kerola [Sun, 28 Aug 2016 09:51:33 +0000 (10:51 +0100)] 
data types: move global data to control structures

This is a big and pretty messy change, but unfortunately there is no nice
way to move variables from global scope to input argument scope.  But that
does not explain why this is needed, so let me try to do that.

Variables in global scope make lousy api.  In order to separate tracing
functionality from various display interfaces making api cleaner is a must.
Further goal of clean api with aim publishing it as libmtr library.  Such
library needs to be fully documented, and it can even provide python
bindings for people and organizations who happen to need such.  Please keep
this plan as a git commit log hush-hush secret.  It might take more than a
moment to get all the necessary changes done to reach fully working, decent,
understandable, documented library similar to libabc.

Reference: https://git.kernel.org/cgit/linux/kernel/git/kay/libabc.git

8 years agodocs: make manual page versioning automatic
Sami Kerola [Sat, 27 Aug 2016 11:11:57 +0000 (12:11 +0100)] 
docs: make manual page versioning automatic

In same go mark the manual page in System Administration selection.

8 years agousability: fix --mark documentation
Sami Kerola [Sat, 27 Aug 2016 10:50:23 +0000 (11:50 +0100)] 
usability: fix --mark documentation

And make the option argument to match with what is expected in kernel space,
that is u32int_t data type.

Reference: https://github.com/torvalds/linux/blob/master/include/net/sock.h#L419

8 years agodata types: get rid of all globals that are easy to remove
Sami Kerola [Sat, 27 Aug 2016 09:51:20 +0000 (10:51 +0100)] 
data types: get rid of all globals that are easy to remove

Some variables are unnecessary, others can be moved to a function or a file
scope.

8 years agowarnings: fix use of uninitialized warning
Sami Kerola [Mon, 22 Aug 2016 21:40:50 +0000 (22:40 +0100)] 
warnings: fix use of uninitialized warning

clang claims: variable 'port' is used uninitialized whenever switch default
is taken.  And that is a lie, but error() is not marked as function that
never returns, because it can also be used when printing warning.  So the
compiler is guessing wrong, but the easiest fix is to initialize the
variable rather than educate compiler.

8 years agodata types: check with smatch everything is in resonable scope
Sami Kerola [Mon, 22 Aug 2016 21:34:05 +0000 (22:34 +0100)] 
data types: check with smatch everything is in resonable scope

Now when extern variables, and functions are known one can start thinking
about how get rid of global variables.

8 years agodata types: move variable declaration from header to .c file
Sami Kerola [Mon, 22 Aug 2016 21:20:47 +0000 (22:20 +0100)] 
data types: move variable declaration from header to .c file

And make the variable shared.

8 years agocleanup: remove redundant redeclaration
Sami Kerola [Mon, 22 Aug 2016 21:06:25 +0000 (22:06 +0100)] 
cleanup: remove redundant redeclaration

8 years agodata types: set static strings to be read-only
Sami Kerola [Mon, 22 Aug 2016 21:04:13 +0000 (22:04 +0100)] 
data types: set static strings to be read-only

8 years agoMerge pull request #144 from kerolasa/mac
rewolff [Tue, 23 Aug 2016 21:45:42 +0000 (23:45 +0200)] 
Merge pull request #144 from kerolasa/mac

Mac/portability fixes

8 years agoportability: fix MacOS libresolv usage 144/head
Sami Kerola [Tue, 23 Aug 2016 19:21:58 +0000 (20:21 +0100)] 
portability: fix MacOS libresolv usage

MacOS has res_query in libc, but needs libresolv for dn_expand().

8 years agoportability: MacOS does not have error() function
Sami Kerola [Tue, 23 Aug 2016 11:49:05 +0000 (12:49 +0100)] 
portability: MacOS does not have error() function

Add portability fix by using err() function family.  This is a bit cheeky,
but should work relatively well.

8 years agoportability: fix float max check from values.h
Sami Kerola [Tue, 23 Aug 2016 18:25:40 +0000 (19:25 +0100)] 
portability: fix float max check from values.h

MacOS does not have values.h file.

8 years agofixed typo.
Rogier Wolff [Mon, 22 Aug 2016 06:37:51 +0000 (08:37 +0200)] 
fixed typo.

8 years agoMerge pull request #143 from kerolasa/2016-08-21
rewolff [Mon, 22 Aug 2016 06:36:42 +0000 (08:36 +0200)] 
Merge pull request #143 from kerolasa/2016-08-21

Cleanups: mark some functions as static. use GNU function "error" instead of perror/exit.

8 years agobuild-sys: tell function locality explicitly 143/head
Sami Kerola [Sun, 21 Aug 2016 19:33:43 +0000 (20:33 +0100)] 
build-sys: tell function locality explicitly

Most of the function prototypes in header files are indeed external, with
few exceptions that can be set to local scope with static key word.
Additionally get rid of net_duplicate() prototype that does not exist
anywhere.

8 years agobuild-sys: use system getopt_long() when it is available
Sami Kerola [Sun, 21 Aug 2016 18:32:38 +0000 (19:32 +0100)] 
build-sys: use system getopt_long() when it is available

And move the getopt sources to portability support directory.

8 years agocleanup: move max port number to be a define in net.h
Sami Kerola [Sun, 21 Aug 2016 17:32:16 +0000 (18:32 +0100)] 
cleanup: move max port number to be a define in net.h

8 years agousage: use error(3) error-reporting function
Sami Kerola [Sun, 21 Aug 2016 17:13:53 +0000 (18:13 +0100)] 
usage: use error(3) error-reporting function

There are two benefits of using error(3).  First of all this function
unifies error printing nice way, and when done this way a programmer cannot
accidentally mix stderr and stdout error print outs.  Secondly the error(3)
appends program name to errors, making it clear what printed an error.  To
demonstrate this see below for old and new output, in which the old error
could have in theory been reported by sudo(8).

$ sudo mtr -u -T # old
-u , -T and -S are mutually exclusive.

$ sudo ./mtr -u -T # new
./mtr: -u , -T and -S are mutually exclusive

8 years agousage: be careful when parsing numeric user input
Sami Kerola [Sun, 21 Aug 2016 10:49:49 +0000 (11:49 +0100)] 
usage: be careful when parsing numeric user input

Functions atoi(3) and atof(3) do not perform any error checking.  Use
strtol(3) function family, with alterations to fail if input is not
expected.

8 years agoMerge pull request #142 from kerolasa/pkg-config
rewolff [Sun, 21 Aug 2016 16:05:06 +0000 (18:05 +0200)] 
Merge pull request #142 from kerolasa/pkg-config

configuration cleanup, Pkg config.

8 years agocleanup: remove preprocessor missing functions go-arounds 142/head
Sami Kerola [Sun, 21 Aug 2016 09:53:16 +0000 (10:53 +0100)] 
cleanup: remove preprocessor missing functions go-arounds

Calling empty functions when there is no support is messy, and harder to
read than not calling at all functionality that is not present.

8 years agousage: reflect ./configure choices in available command line options
Sami Kerola [Sun, 21 Aug 2016 09:00:11 +0000 (10:00 +0100)] 
usage: reflect ./configure choices in available command line options

Features that are turned off should not be available to users as an options.
This commit also ensures matching long and short options, and makes the
long-only --displaymode option to be totally unreachable with short options.

8 years agocleanup: remove obsolete herror() function
Sami Kerola [Sat, 20 Aug 2016 08:17:06 +0000 (09:17 +0100)] 
cleanup: remove obsolete herror() function

Applications should use getaddrinfo(3), getnameinfo(3), and gai_strerror(3)
instead.  Systems without getaddrinfo() are from now on considered too
broken to be supported.  These include for example platforms: HP-UX 11.11,
IRIX 6.5, OSF/1 5.1, Solaris 7, Cygwin 1.5.x, mingw, MSVC 9, Interix 3.5,
and BeOS.

8 years agobuild-sys: remove unused autoconf check values
Sami Kerola [Sat, 20 Aug 2016 08:09:01 +0000 (09:09 +0100)] 
build-sys: remove unused autoconf check values

Return values from checks are not used anywhere in this project.

8 years agobuild-sys: simplify finding resolver library
Sami Kerola [Sat, 20 Aug 2016 08:06:28 +0000 (09:06 +0100)] 
build-sys: simplify finding resolver library

8 years agocleanup: remove NO_SPLIT preprocessor check
Sami Kerola [Thu, 18 Aug 2016 21:36:18 +0000 (22:36 +0100)] 
cleanup: remove NO_SPLIT preprocessor check

Apparently ./configure --without-split was planned to be added in commit
433bf6c22ce90e25f3ffb0b4852631e5724ac608 but that has not happen in 17
years.  Time has come to get rid of a half implemented idea.