You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2018/04/09 08:42:52 UTC

[incubator-plc4x] 04/04: - Started working on making the RawSocket runnable on Linux - Increased the usefullness of some error messages

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git

commit 90f84f801b32dfb30e56a1dda04b5f5f5d27f497
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Mon Apr 9 10:42:43 2018 +0200

    - Started working on making the RawSocket runnable on Linux
    - Increased the usefullness of some error messages
---
 .../org/apache/plc4x/java/utils/rawsockets/RawIpSocket.java    | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/RawIpSocket.java b/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/RawIpSocket.java
index 62b5643..d6f1aeb 100644
--- a/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/RawIpSocket.java
+++ b/plc4j/utils/raw-sockets/src/main/java/org/apache/plc4x/java/utils/rawsockets/RawIpSocket.java
@@ -97,7 +97,7 @@ public class RawIpSocket {
                         throw new RawSocketException("Unable to connect to " + remoteAddress);
                     }
                 } else {
-                    throw new RawSocketException("Unable to connect to " + remoteAddress);
+                    throw new RawSocketException("Unable to connect to " + remoteAddress + " no default gateway");
                 }
             }
 
@@ -279,7 +279,8 @@ public class RawIpSocket {
                 }
             }
         } catch (PcapNativeException | InterruptedException | ExecutionException | NotOpenException e) {
-            throw new RawSocketException("Error looking up mac address.", e);
+            throw new RawSocketException("Error looking up MAC address for ip address " +
+                remoteIpAddress.getHostAddress() + " on device " + dev.getName(), e);
         }
     }
 
@@ -298,6 +299,11 @@ public class RawIpSocket {
             for (PcapNetworkInterface dev : Pcaps.findAllDevs()) {
                 // Iterate over all addresses configured for this interface.
                 for (PcapAddress localAddress : dev.getAddresses()) {
+                    if("255.255.255.255".equals(localAddress.getNetmask().getHostAddress())) {
+                        return new FirstHop(dev, localAddress.getAddress(),
+                            dev.getLinkLayerAddresses().iterator().next(),
+                            getMacAddress(dev, localAddress.getAddress(), remoteAddress));
+                    }
                     // Only check addresses matching the IP-version of the remote address.
                     if (remoteAddress.getClass().equals(localAddress.getAddress().getClass())) {
                         byte[] localIp = localAddress.getAddress().getAddress();

-- 
To stop receiving notification emails like this one, please contact
cdutz@apache.org.