Roger Wolff [Sun, 26 Apr 2026 13:38:30 +0000 (15:38 +0200)]
Merge pull request #568 from mayconrcmello/fix/cygwin-braille
ui: fix braille display mode on Cygwin
I would find it neater to add a check for the header that cygwin uses, instead of checking for cygwin and just including that. This involves messing with the autoconf stuff which I'm not familiar with. So that's an item for the "todo list".
Three issues prevented the braille display from rendering correctly
when mtr is built with Cygwin:
1. Wrong ncurses header: Cygwin ships <ncurses.h> as the non-wide
variant, which does not declare addwstr() or add_wch(). Include
<ncursesw/ncurses.h> instead when building with braille support.
2. Wrong output function: printw("%ls", wstr) relies on the C library
wide-to-multibyte conversion path, which can misbehave when the
locale is not fully set up before ncurses initialises. Use
addwstr(), the proper ncursesw API, instead.
3. Locale and console codepage: setlocale(LC_ALL, "") on Cygwin
inherits the Windows ANSI codepage (e.g. CP1252), breaking UTF-8
output. Explicitly request C.UTF-8 and set the Windows console
output codepage to 65001 (UTF-8) before initscr().
ui: replace non-BMP braille char U+1FB10 with U+28FF
🮐 (U+1FB10) lives outside the Basic Multilingual Plane and requires
a UTF-16 surrogate pair when wchar_t is 16 bits (Windows, Cygwin).
Passing a surrogate pair to wide-char ncurses functions produces
corrupted output on those platforms.
Replace all three uses with ⣿ (U+28FF), the filled braille pattern,
which is the visually closest BMP character and avoids the issue on
any platform where sizeof(wchar_t) == 2.
Petr Sumbera [Thu, 19 Mar 2026 09:34:32 +0000 (10:34 +0100)]
packet: skip bind() on Solaris raw ICMPv4 sockets
Commit d529dbeefc6d ("Change UDP and ICMP sockets binding to accept a
source IP from the -a CLI option") started binding the shared IPv4 raw
ICMP send socket in construct_ip4_packet().
On Solaris/illumos this breaks default ICMP probes: bind() on that raw
socket can fail with EINVAL, and mtr exits with:
mtr: mtr-packet reported invalid argument
This does not affect TCP or UDP probes, and mtr 0.95 worked because the
raw ICMPv4 path did not bind the socket.
Keep the pre-0.96 behavior on __sun by skipping bind() for raw ICMPv4
sockets. This restores default ICMP probing on Solaris/illumos without
changing Linux behavior.
Note that -a source address selection is not enforced for raw ICMPv4 on
Solaris/illumos, since those platforms cannot reliably use bind() on the
shared raw ICMP socket in this code path.
bluPhy [Sat, 24 Jan 2026 05:10:35 +0000 (00:10 -0500)]
Fix typos in comments and docstrings across codebase
Corrected several spelling errors such as 'unparseable' to 'unparsable', 'paramters' to 'parameters', 'virutal' to 'virtual', 'withing' to 'within', and 'non-existant' to 'non-existent' in both source and test files to improve code clarity and documentation accuracy.
- numhosts did not take fstTTL into account when calculating the number of hosts in a batch.
- maxUnknown or maxTTL values are now taken into account after the set TTL value is reached,
when the -D (--due-ttl) option is enabled.
Before OS X 10.6, defining BIND_8_COMPAT included arpa/nameser8_compat.h
which was removed in 10.6 and from then on included arpa/nameser_compat.h
until BIND_8_COMPAT was removed somewhere between macOS 10.13 & 10.15.
On systems before 10.6 this causes the build to break due to conflicts.
Raw pings output time in usec. Correct args and docs.
(An alternate solution is to correct https://github.com/traviscross/mtr/blob/master/ui/net.c#L319, but that would potentially break workflows for users, so this is likely a more acceptable fix)
James Lu [Sat, 14 Jun 2025 02:06:21 +0000 (19:06 -0700)]
net: implement addrcmp for AF_UNSPEC
When mtr is compiled with IPv6 enabled, the GTK frontend sets the address family to AF_UNSPEC when changing destinations. However, addrcomp does not support this AF type, which causes all comparisons to not match. For the GTK frontend, this leads to a cascading failure when setting the destination to a host that does not resolve:
1. Upon setting ctl->af = AF_UNSPEC, net_max() will report that all hops have data, as no hops can match the previous remote address.
2. The GTK frontend tries to render a row for every hop, including its IP / hostname.
3. The guard in the GTK frontend to avoid looking up unknown addresses also fails, causing mtr to flood DNS packets and effectively hang.
Marek Küthe [Sat, 15 Feb 2025 22:21:13 +0000 (22:21 +0000)]
Fix https://github.com/traviscross/mtr/issues/475
With an input of `-28` the expression `(-ctl->cpacketsize - MINPACKET)` became 0, which triggered a zero division. This error is fixed by introducing a check to see if there is any room for randomness. Furthermore, a check of the input arguments in the command line and in curses is performed.
Marek Küthe [Sat, 15 Feb 2025 21:35:41 +0000 (21:35 +0000)]
Remove redundant code
As @yvs2014 noted in https://github.com/traviscross/mtr/issues/523#issuecomment-2660970185, it is unnecessary to check whether an int is larger than the maximum int value. An int cannot be greater than the maximum int value.
Matt Kimball [Tue, 24 Oct 2023 02:02:43 +0000 (03:02 +0100)]
Update Cygwin ICMP service thread for asynchronous pipes
Recent versions of Cygwin implement pipe() using Windows' named
pipes, and put the read end of the pipe in FILE_PIPE_COMPLETE_OPERATION
mode, which doesn't allow overlapped I/O operations.
The solution here is to maintain a Windows event object which is
set only when any ICMP requests are pending. We can do an alertable
wait on that event object, which will allow us to complete ICMP
requests.
Thanks to Adam Schultz for research into this issue and a first
attempt at a fix.