]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
mtr-packet: Report probe status on host unreachable (Cygwin) 181/head
authorMatt Kimball <matt.kimball@gmail.com>
Sat, 7 Jan 2017 17:01:30 +0000 (09:01 -0800)
committerMatt Kimball <matt.kimball@gmail.com>
Sun, 8 Jan 2017 15:36:27 +0000 (07:36 -0800)
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.

packet/probe_cygwin.c

index ae1b2ccef073cc6b61c3c8c584132644e0c5742a..ae221d00d79c8bdf8f77255807ade549cf6cbaa2 100644 (file)
@@ -101,12 +101,17 @@ void report_win_error(
     int err)
 {
     /*  It could be that we got no reply because of timeout  */
-    if (err == IP_REQ_TIMED_OUT) {
+    if (err == IP_REQ_TIMED_OUT
+            || err == IP_SOURCE_QUENCH) {
         printf("%d no-reply\n", command_token);
     } else if (err == IP_DEST_HOST_UNREACHABLE
+            || err == IP_DEST_PORT_UNREACHABLE
+            || err == IP_DEST_PROT_UNREACHABLE
             || err == IP_DEST_NET_UNREACHABLE
             || err == IP_DEST_UNREACHABLE
-            || err == IP_DEST_NO_ROUTE) {
+            || err == IP_DEST_NO_ROUTE
+            || err == IP_BAD_ROUTE
+            || err == IP_BAD_DESTINATION) {
         printf("%d no-route\n", command_token);
     } else if (err == ERROR_INVALID_NETNAME) {
         printf("%d address-not-available\n", command_token);
@@ -134,7 +139,6 @@ void WINAPI on_icmp_reply(
     int round_trip_us = 0;
     int reply_count;
     int reply_status = 0;
-    int err;
     struct sockaddr_storage remote_addr;
     struct sockaddr_in *remote_addr4;
     struct sockaddr_in6 *remote_addr6;
@@ -178,18 +182,14 @@ void WINAPI on_icmp_reply(
     }
 
     if (reply_count == 0) {
-        err = GetLastError();
-
-        report_win_error(probe->token, err);
-        free_probe(net_state, probe);
-        return;
+        reply_status = GetLastError();
     }
 
-
     icmp_type = -1;
     if (reply_status == IP_SUCCESS) {
         icmp_type = ICMP_ECHOREPLY;
-    } else if (reply_status == IP_TTL_EXPIRED_TRANSIT) {
+    } else if (reply_status == IP_TTL_EXPIRED_TRANSIT
+            || reply_status == IP_TTL_EXPIRED_REASSEM) {
         icmp_type = ICMP_TIME_EXCEEDED;
     }
 
@@ -199,7 +199,8 @@ void WINAPI on_icmp_reply(
             net_state, probe, icmp_type,
             &remote_addr, round_trip_us, 0, NULL);
     } else {
-        fprintf(stderr, "Unexpected ICMP result %d\n", icmp_type);
+        report_win_error(probe->token, reply_status);
+        free_probe(net_state, probe);
     }
 }