]> git.ipfire.org Git - thirdparty/mtr.git/log
thirdparty/mtr.git
8 years agoinclude <sys/select.h> for fd_set 195/head
David Hill [Fri, 14 Apr 2017 22:08:56 +0000 (18:08 -0400)] 
include <sys/select.h> for fd_set

8 years agoMerge pull request #192 from jwilk/spelling
Roger Wolff [Tue, 28 Feb 2017 08:11:12 +0000 (09:11 +0100)] 
Merge pull request #192 from jwilk/spelling

Fix typos

8 years agoFix typos 192/head
Jakub Wilk [Mon, 27 Feb 2017 22:52:08 +0000 (23:52 +0100)] 
Fix typos

8 years agoMerge pull request #189 from matt-kimball/reindent
Roger Wolff [Sun, 5 Feb 2017 07:11:21 +0000 (08:11 +0100)] 
Merge pull request #189 from matt-kimball/reindent

Reindent source using GNU indent

8 years agocleanup: reindented C source with GNU indent 189/head
Matt Kimball [Sat, 4 Feb 2017 21:25:23 +0000 (13:25 -0800)] 
cleanup: reindented C source with GNU indent

Ran the C source through:

    indent --k-and-r-style --no-tabs --break-function-decl-args

8 years agocleanup: Fix #ifdef structure which confuses 'ident'
Matt Kimball [Sat, 4 Feb 2017 21:18:13 +0000 (13:18 -0800)] 
cleanup: Fix #ifdef structure which confuses 'ident'

The 'indent' tool is confused by some strange #ifdef structure
around HAVE_IPINFO in report.c.  Cleaned up that structure
so 'indent' can be used successfully.

8 years agoMore whitespace mangling for consistency in net.c
R.E. Wolff [Fri, 27 Jan 2017 08:40:49 +0000 (09:40 +0100)] 
More whitespace mangling for consistency in net.c

8 years agoMerge pull request #188 from jbruggeman/master
Roger Wolff [Fri, 27 Jan 2017 08:36:34 +0000 (09:36 +0100)] 
Merge pull request #188 from jbruggeman/master

Improve readability of net.c

8 years agocleanup the if blocks in net.c to improve readability 188/head
Joe Bruggeman [Thu, 26 Jan 2017 21:40:53 +0000 (16:40 -0500)] 
cleanup the if blocks in net.c to improve readability

8 years agoReplace all tabs tabs in net.c with spaces
Joe Bruggeman [Thu, 26 Jan 2017 21:31:32 +0000 (16:31 -0500)] 
Replace all tabs tabs in net.c with spaces

Partial fix for #187

8 years agoput ifdefs around IPV6 only part. Fixes #184
R.E. Wolff [Tue, 17 Jan 2017 23:04:26 +0000 (00:04 +0100)] 
put ifdefs around IPV6 only part. Fixes #184

8 years agoasn fix from meingtsla, fixes #163. Pong!
R.E. Wolff [Sat, 14 Jan 2017 23:51:47 +0000 (00:51 +0100)] 
asn fix from meingtsla, fixes #163. Pong!

8 years agoMerge pull request #181 from matt-kimball/cygwin-host-unreach
Roger Wolff [Sun, 8 Jan 2017 16:17:30 +0000 (17:17 +0100)] 
Merge pull request #181 from matt-kimball/cygwin-host-unreach

mtr-packet: Report probe status on host unreachable (Cygwin)

8 years agomtr-packet: Report probe status on host unreachable (Cygwin) 181/head
Matt Kimball [Sat, 7 Jan 2017 17:01:30 +0000 (09:01 -0800)] 
mtr-packet: Report probe status on host unreachable (Cygwin)

When IcmpParseReplies returned with a probe completion, but the
probe's status was IP_DEST_HOST_UNREACHABLE, mtr-packet was failing
to report the probe result, and was instead printing an unhelpful
error message without any reference to a particular probe.  Now
it will report a "no-route" result with the token associated with
the probe.

This fixes issue #179.

8 years agoMerge pull request #180 from kerolasa/pedantry
Roger Wolff [Sat, 7 Jan 2017 12:01:13 +0000 (13:01 +0100)] 
Merge pull request #180 from kerolasa/pedantry

couple maintenance changes

8 years agodocs: FSF moved back in 2005 180/head
Sami Kerola [Fri, 6 Jan 2017 22:04:18 +0000 (22:04 +0000)] 
docs: FSF moved back in 2005

Update license file from the source.

Reference: https://www.fsf.org/news/fsf-moving.html
Source: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agobuild-sys: update .gitignore file
Sami Kerola [Sun, 1 Jan 2017 19:29:59 +0000 (19:29 +0000)] 
build-sys: update .gitignore file

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agosmatch: fix couple warnings
Sami Kerola [Sun, 1 Jan 2017 19:25:24 +0000 (19:25 +0000)] 
smatch: fix couple warnings

ui/mtr.c:616:21: warning: Using plain integer as NULL pointer
packet/cmdparse.c:80:18: warning: Variable length array is used.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agosmatch: extern keyword is needed only in header
Sami Kerola [Sun, 1 Jan 2017 19:19:22 +0000 (19:19 +0000)] 
smatch: extern keyword is needed only in header

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agoMerge pull request #178 from kasper93/errno
Roger Wolff [Thu, 5 Jan 2017 15:09:01 +0000 (16:09 +0100)] 
Merge pull request #178 from kasper93/errno

Add missing errno.h include.

8 years agoMerge pull request #177 from kasper93/master
Roger Wolff [Thu, 5 Jan 2017 15:07:57 +0000 (16:07 +0100)] 
Merge pull request #177 from kasper93/master

Change finding of mtr-packet a bit to make things more convenient for developers/hackers.

8 years agoAdd missing errno.h include. 178/head
Kacper Michajłow [Wed, 4 Jan 2017 16:53:18 +0000 (17:53 +0100)] 
Add missing errno.h include.

This fixes compilation with Clang on Cygwin.

8 years agoRelax mtr-packet search rules. 177/head
Kacper Michajłow [Tue, 3 Jan 2017 22:28:45 +0000 (23:28 +0100)] 
Relax mtr-packet search rules.

First, mtr-packet or override path taken from MTR_PACKET env variable will be search in PATH if not found we falllback to current directory search. This way we can use mtr without installing or setting any additional env variables.

Also fix batch file to support paths with spaces on Windows.

8 years agoMerge pull request #175 from matt-kimball/portability-fixes
Roger Wolff [Sat, 31 Dec 2016 18:04:59 +0000 (19:04 +0100)] 
Merge pull request #175 from matt-kimball/portability-fixes

Portability fixes - Solaris, NetBSD and OpenBSD

8 years agobuild: fix compiler warnings when for OpenBSD, NetBSD and Solaris 175/head
Matt Kimball [Fri, 30 Dec 2016 16:32:45 +0000 (16:32 +0000)] 
build: fix compiler warnings when for OpenBSD, NetBSD and Solaris

When building for NetBSD, the compiler was warning about
index into an array with a character when using isspace() and
similar macros.

IPPROTO_SCTP is also not defined by NetBSD, so there were
warnings about unused SCTP related variables.

OpenBSD complains about using sprintf rather than snprintf.
It's a good idea to use snprintf, anyway, to avoid buffer overruns,
though I believe in these particular cases sprintf was safe.
Nevertheless, snprintf is now used instead.

Solaris requires strings.h to find index().

Solaris complaints about a missing sentinel pointer unless
the terminating NULL in execl is cast to a "char *".

8 years agobuild: Fix Solaris build issues
Matt Kimball [Fri, 30 Dec 2016 19:44:32 +0000 (11:44 -0800)] 
build: Fix Solaris build issues

Prefer ncurses over curses, since curses on Solaris is lacking
wattr_on and wattr_off, but ncurses has them.

Check if sys/ctypes.h exists, since Solaris lacks it.

When sending an IPv6 probe, check if the send socket is already
bound to the intended source address, and if so, avoid rebinding.
Rebinding return an error on Solaris.

8 years agobuild: if linking with ncurses fails, try curses (for NetBSD)
Matt Kimball [Fri, 30 Dec 2016 16:22:32 +0000 (16:22 +0000)] 
build: if linking with ncurses fails, try curses  (for NetBSD)

NetBSD doesn't use ncurses, but instead has its own version of curses.
So, if we don't find ncurses during configure, try linking against
curses.

On NetBSD, we must include limits.h to find CHAR_MAX.

On OpenBSD, we must include sys/socket.h to get sockaddr_storage.

8 years agoMerge pull request #174 from matt-kimball/ipv6-disabled-fallback
Roger Wolff [Thu, 29 Dec 2016 07:05:13 +0000 (08:05 +0100)] 
Merge pull request #174 from matt-kimball/ipv6-disabled-fallback

mtr-packet: Fall back to IPv4 only support if IPv6 sockets fail to open

8 years agomtr-packet: Fall back to IPv4 only support if IPv6 sockets fail to open 174/head
Matt Kimball [Wed, 28 Dec 2016 01:09:49 +0000 (17:09 -0800)] 
mtr-packet: Fall back to IPv4 only support if IPv6 sockets fail to open

If we fail to open any IPv6 sockets, rather than aborting with an
unrecoverable error, fall back to IPv4 only support.  Socket
creation might fail, for example, when Linux is booted with
the kernel command-line "ipv6.disable=1".

In the case where opening IPv6 sockets fail,
'check-support feature ip-6' will indicate there is no support
for sending IPv6 probes.

Stricter error reporting revealed that test for protocols other
than ICMP were running on Cygwin.  Modified the tests such that
they won't run if the protocol isn't supported.

8 years agoMerge pull request #172 from matt-kimball/ncurses-check
Roger Wolff [Mon, 26 Dec 2016 21:34:46 +0000 (22:34 +0100)] 
Merge pull request #172 from matt-kimball/ncurses-check

build: use AC_CHECK_LIB for ncurses, rather than pkg-tool

8 years agobuild: use AC_CHECK_LIB for ncurses, rather than pkg-tool 172/head
Matt Kimball [Mon, 26 Dec 2016 09:26:01 +0000 (01:26 -0800)] 
build: use AC_CHECK_LIB for ncurses, rather than pkg-tool

pkg-tool is indeed an elegant way to check for the presence
of libraries.  When using pkg-config to check for ncurses, this
works great... for Linux.  Unfortunately, on FreeBSD and MacOS,
ncurses is installed by default, but pkg-config is not.  When
pkg-config is installed on these systems, it doesn't know about
the system installed ncurses.

Therefore, somewhat counterintuitively, it is better for portability
to just us AC_CHECK_LIB instead of PKG_CHECK_MODULES to find
ncurses.

8 years agoMerge pull request #171 from matt-kimball/master
Roger Wolff [Sun, 25 Dec 2016 22:14:11 +0000 (23:14 +0100)] 
Merge pull request #171 from matt-kimball/master

split raw socket access into mtr-packet subprocess

8 years agobuild: moved front-end source into ui subdir 171/head
Matt Kimball [Sun, 25 Dec 2016 17:45:52 +0000 (09:45 -0800)] 
build: moved front-end source into ui subdir

Cleaned up the directory structure.

Moved the source to the main mtr executable into the ui/ subdirectory.

Moved mtr.bat and mangen.sh into build-aux/

Moved the man pages into man/

Fixed a few omissions in Makefile.am for 'make dist'

8 years agomtr-packet: drop capabilities + using BSD's linked lists for probes
Matt Kimball [Sun, 25 Dec 2016 17:26:34 +0000 (09:26 -0800)] 
mtr-packet: drop capabilities + using BSD's linked lists for probes

At startup, we now use cap_set_proc to drop all privileged
capabilities for the mtr-packet process.  This means that
capabilities granted through the commandline setcap to the
mtr-packet executable will only be in effect while the necessary
raw sockets are opened, and will be dropped before any command
requests are read.

Now we use BSD's queue.h linked list support for storing outstanding
probes.  This makes iterating through in-flight probes more efficient,
as we don't need to loop through many unused probe entires when only
a few probes are outstanding.

Changed mtr-packet's default probe size to 64 bytes, to match
mainline mtr's default.

The code consistently uses 'exit(EXIT_FAILURE)' instead of 'exit(1)'.
The effect is the same, but the intent is clearer.

8 years agoMerge branch mtr-packet into 'master'
Matt Kimball [Fri, 23 Dec 2016 17:56:58 +0000 (09:56 -0800)] 
Merge branch mtr-packet into 'master'

8 years agomtr-packet: allow local address binding
Matt Kimball [Fri, 23 Dec 2016 17:37:47 +0000 (09:37 -0800)] 
mtr-packet: allow local address binding

A probe can be bound to a local address with the 'local-ip-4' or
'local-ip-6' arguments to 'send-probe'.  The '-a' commandline
argument to mtr will cause sent probes to be bound to the specified
address.

Changed argument names for consistency:

    'localport' is now 'local-port'
    'bitpattern' is now 'bit-pattern'

mtr now opens and connects a UDP socket at startup to determine the
local address for display in the UI.

Windows error codes resulting from send-probe are now using the
same error strings which are used to report errors in the
Unix implementation.

We now use the mtr commandline timeout value for sent probes.
Edited the help and man page to reflect that the timeout value
no longer applies to only TCP probes, but now all probes.

With this change, I believe the mtr-packet implementation is at
feature parity with mainline mtr.

8 years agomtr-packet: MPLS decoding and local UDP port usage
Matt Kimball [Thu, 22 Dec 2016 15:28:29 +0000 (07:28 -0800)] 
mtr-packet: MPLS decoding and local UDP port usage

mtr-packet will decode any MPLS labels embedded in an
ICMP reply which results from a probe, and report those
labels with the probe reply.

When sending a UDP probe, a local port can be specified
for probe origination.  In the same way that the legacy mtr
code found a location to store a unique identifier for the probe,
we'll use the destination port, the local port or the checksum
field, depending on what probe arguments have been specified.

Both MPLS and local UDP port options have been documented in the
mtr-packet man page.

Update the SECURITY documentation to reflect mtr-packet, and did
minor copyediting in the README.  Also, update my email address
in AUTHORS.

8 years agomtr-packet: TCP and SCTP probes
Matt Kimball [Tue, 20 Dec 2016 18:09:29 +0000 (10:09 -0800)] 
mtr-packet: TCP and SCTP probes

Added support for generating probes using TCP or SCTP, for both
IPv4 and IPv6.  These protocols require that we create a unique
socket for each probe and watch for either a TTL expiration of
the initial packet sent during a connection attempt from that
socket or for socket connection success.

We now allocate a unique port number or ICMP sequence ID when
a probe is created, rather than using the command token for this
purpose.  This relieves the calling application of the burden
of picking sensible command token values, and allows command
tokens values greater than 16 bits.  However, the existing mtr
code continues to use the same command tokens values it has
previously used as port numbers, so there is no difference when
the calling program is mtr.

Split mtr's command pipe handling out from net.c and into cmdpipe.c
in the interest of future maintainability.

Split probe.py's simple probes out from the individual protocol
test cases and into common code which can be used by many
protocol tests.

8 years agoMerge pull request #165 from kerolasa/2016-10-29
Roger Wolff [Mon, 19 Dec 2016 09:15:12 +0000 (10:15 +0100)] 
Merge pull request #165 from kerolasa/2016-10-29

2016-10-29 usage improvements

8 years agomtr-packet: packet customization options (size, fill, mark, tos)
Matt Kimball [Sat, 17 Dec 2016 15:24:07 +0000 (07:24 -0800)] 
mtr-packet: packet customization options (size, fill, mark, tos)

Added send-probe arguments to customize the packet size,
the bitpattern which fills the packet, the IP "type of service"
and the Linux routing mark.  These arguments are documented
in the mtr-packet man page, and have been hooked up to mtr's
commandline parameters.

Internally to mtr-packet, the code is now more consistent about
using errno to return error codes.

Added instrutions for building on Windows to the README.

Fixed the Makefile to build the man pages with BSD make, for FreeBSD.
BSD make lacks the GNU make extension for '%' wildcard matching.

Added a helper program for testing which listens for an ICMP
packet with a particular sequence and prints information about
that packet.

8 years agomtr-packet: UDP probe support
Matt Kimball [Wed, 14 Dec 2016 17:18:42 +0000 (09:18 -0800)] 
mtr-packet: UDP probe support

Added support send using UDP as the protocol for sending probes,
rather than ICMP.  Both IPv4 and IPv6 UDP probes are supported.
We are using the source port in the UDP packet for identifying
the particular probe transmitted.  This is a bit less reliable
than ICMP, where we are also able to store our PID for verifying
the probe has been transmitted by this instance of mtr-packet,
but space is limited, and it is what the pre-existing mtr
implementation does.

We report no-route and network-down errors in response to errors
from sendto(), in addition to reporting them from errors in
the connect() used to determine the source address of an outgoing
probe.

The mtr-packet tests now properly parse the replies from
mtr-packet, as opposed to simply matching regular expressions
against the output.  This is better because it give us future
compatibility with additional reply arguments from mtr-packet.

A better introduction to mtr-packet is now included in the
mtr-packet man page.

The dual code paths for sending IPv6 probes between Linux
and non-Linux Unix-likes has been eliminated.  The Linux path
gave us direct control over the IP header, but wasn't necessary
and would make maintainence more difficult, so now Linux uses
the more indirect setsockopt() method of setting IPv6 header
fields.

8 years agomtr-packet: IPv6 support
Matt Kimball [Fri, 9 Dec 2016 19:14:06 +0000 (11:14 -0800)] 
mtr-packet: IPv6 support

mtr-packet can now send and receive ICMPv6 probes.

We now determine the source address for an outgoing probe by
opening a UDP socket to the destination, though no outgoing packets
are sent through this UDP socket.  IPv6 made this necessary, but
it now occurs for IPv4, too.

mtr-packet now uses sockaddr_storage for passing around addresses,
rather than sockaddr_in, as it can work for either IPv4 or IPv6.

To improve the maintainability of the code, the packet construction
and interpetation has been moved from probe_unix.c to construct_unix.c
and deconstruct_unix.c.

The way that Windows reads from the command stream has been changed to
avoid the possibility of hanging in a Sleep without an active read
of the command stream.

"send-probe" will now respond with "no-route" or "network-down"
when those conditions apply.

The test code has been moved to a test directory and split into
the following modules:

probe.py - tests for sending probes
cmdparse.py - tests for command parsing
mtrpacket.py - infrastructure for testing mtr-packet

The mtr-packet man page has been updated to describe ip-6 options
and now has an example of tracing a route to a remote host.

The mtr-packet network initialization has been split into two halves
to minimize the operations which occur with elevated privileges.

8 years agoMerge pull request #169 from matt-kimball/issue168-multihost
Roger Wolff [Wed, 7 Dec 2016 17:05:10 +0000 (18:05 +0100)] 
Merge pull request #169 from matt-kimball/issue168-multihost

cmdline: multiple host names dropped all but one host  (issue #168)

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 agotest: Fix mtr-packet tests for Python 3
Matt Kimball [Sun, 4 Dec 2016 18:03:44 +0000 (10:03 -0800)] 
test: Fix mtr-packet tests for Python 3

The mtr-packet test suite was written to run with Python 2, and lacked
the Unicode to bytes and bytes to Unicode conversions required to
run with Python 3.  This change adds those conversions, and the result
works with either Python 2 or Python 3.

Also, close the subprocess's stdin and stdout explicitly.  Python 3's
unittest complains about unclosed file descriptors otherwise.

8 years agobuild-sys: update .gitignore file
Sami Kerola [Sun, 4 Dec 2016 10:48:16 +0000 (10:48 +0000)] 
build-sys: update .gitignore file

8 years agodocs: improve mtr-packet(8) manual page
Sami Kerola [Sun, 4 Dec 2016 10:43:45 +0000 (10:43 +0000)] 
docs: improve mtr-packet(8) manual page

Indent argument descriptions, and groff_man(7) style.

8 years agoAdded mtr-packet subprocess
Matt Kimball [Thu, 1 Dec 2016 01:14:43 +0000 (17:14 -0800)] 
Added mtr-packet subprocess

The mtr-packet tool isolates the raw socket sending/receiving of
packets from the mtr user interface.  By isolating the socket
interactions to a separate process, we can be sure that any security
flaws in the user-interface code doesn't expose a raw socket
interface to an attacker attempting to escalate privileges.

This is a bare-bones implementation, only support ICMP,
only support IP version 4, and missing many of the probe customization
features available in mtr.  It will require some more work to reach
feature parity with the current mtr implementation.  But it's a start.

The include mtr-packet man page explains the protocol format
used to communicate with this new process.

Included is an automated test for mtr-packet, implemented using
Python's unittest module.  Though the code actually being tested
is implemented in C, Python make it easy to write test cases.
'make check' will test the current build.

An alternate code-path for Windows is included in the mtr-packet
tool.  The mechanism for sending and receiving network probes
is significantly different for Windows, as compared to Unix-like
operating systems, but the interface provided by mtr-packet is
the same.  'make dist-windows-bin' will make a Windows binary
distribution.  A Cygwin build environment is required, but the
resulting binary distribution doesn't require that Cygwin be
already installed.

Tested on:

Ubuntu 16.10, FreeBSD 11.0, MacOS 10.12.1 (Sierra), Windows 7

Since the code changes are significant, more esoteric operating
systems may require changes.

8 years agodocs: add very basic --sctp documentation to manual page 165/head
Sami Kerola [Sat, 29 Oct 2016 13:43:43 +0000 (14:43 +0100)] 
docs: add very basic --sctp documentation to manual page

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
8 years agocleanup: use single logic to handle conditional options
Sami Kerola [Sat, 29 Oct 2016 13:19:16 +0000 (14:19 +0100)] 
cleanup: use single logic to handle conditional options

Options that exist depending on compile time configuration are made
conditional in usage() and getopt_long().  Removing not-supported options
from manual per compile time configuration would be nice, but making that to
work is a bit tricky.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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.