From e1425e5897b411b38615d65fe806caf6df90e3f7 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Fri, 24 Feb 2017 01:03:07 +0000 Subject: [PATCH] 24-02-2017 01:03:06 UTC --- jxnet-core/java/src/com/ardikars/jxnet/Inet4Address.java | 4 ++++ jxnet-core/java/src/com/ardikars/jxnet/Inet6Address.java | 4 ++++ jxnet-core/java/src/com/ardikars/jxnet/Jxnet.java | 2 +- jxnet-test/src/test/java/com/ardikars/test/AllTests.java | 2 +- jxnet-test/src/test/java/com/ardikars/test/PcapLookupNet.java | 4 ++-- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/jxnet-core/java/src/com/ardikars/jxnet/Inet4Address.java b/jxnet-core/java/src/com/ardikars/jxnet/Inet4Address.java index b288888a..4c97319c 100644 --- a/jxnet-core/java/src/com/ardikars/jxnet/Inet4Address.java +++ b/jxnet-core/java/src/com/ardikars/jxnet/Inet4Address.java @@ -120,6 +120,10 @@ public byte[] toBytes() { return Arrays.copyOf(this.address, this.address.length); } + public void update(Inet4Address inet4address) { + this.address = inet4address.toBytes(); + } + @Override public boolean equals(Object obj) { if (obj == this) diff --git a/jxnet-core/java/src/com/ardikars/jxnet/Inet6Address.java b/jxnet-core/java/src/com/ardikars/jxnet/Inet6Address.java index 838de8ca..6c437f1b 100644 --- a/jxnet-core/java/src/com/ardikars/jxnet/Inet6Address.java +++ b/jxnet-core/java/src/com/ardikars/jxnet/Inet6Address.java @@ -182,6 +182,10 @@ private static short parseHextet(String ipPart) { return (short) hextet; } + public void update(Inet6Address inet6address) { + this.address = inet6address.toBytes(); + } + @Override public boolean equals(Object obj) { if (obj == this) diff --git a/jxnet-core/java/src/com/ardikars/jxnet/Jxnet.java b/jxnet-core/java/src/com/ardikars/jxnet/Jxnet.java index 019c23f8..e37b96cb 100644 --- a/jxnet-core/java/src/com/ardikars/jxnet/Jxnet.java +++ b/jxnet-core/java/src/com/ardikars/jxnet/Jxnet.java @@ -353,7 +353,7 @@ private Jxnet() { * @return -1 on error, 0 otherwise. */ @Deprecated - public static native int PcapLookupNet(String device, InetAddress netp, InetAddress maskp, StringBuilder errbuf); + public static native int PcapLookupNet(String device, Inet4Address netp, Inet4Address maskp, StringBuilder errbuf); /** * Compile a packet filter without the need of opening an adapter. diff --git a/jxnet-test/src/test/java/com/ardikars/test/AllTests.java b/jxnet-test/src/test/java/com/ardikars/test/AllTests.java index 55fc9872..1e532e51 100644 --- a/jxnet-test/src/test/java/com/ardikars/test/AllTests.java +++ b/jxnet-test/src/test/java/com/ardikars/test/AllTests.java @@ -11,7 +11,7 @@ PcapOpenOffline.class }) public class AllTests { - public static final String deviceName = "wlan0"; + public static final String deviceName = "eth0"; public static final int snaplen = 1500; public static final int promisc = 1; public static final int to_ms = 2000; diff --git a/jxnet-test/src/test/java/com/ardikars/test/PcapLookupNet.java b/jxnet-test/src/test/java/com/ardikars/test/PcapLookupNet.java index 939a8b54..a1529684 100644 --- a/jxnet-test/src/test/java/com/ardikars/test/PcapLookupNet.java +++ b/jxnet-test/src/test/java/com/ardikars/test/PcapLookupNet.java @@ -12,8 +12,8 @@ public class PcapLookupNet { public void run() { StringBuilder errbuf = new StringBuilder(); String source = AllTests.deviceName; - InetAddress netp = Inet4Address.valueOf(0); - InetAddress nmask = Inet4Address.valueOf(0); + Inet4Address netp = Inet4Address.valueOf(0); + Inet4Address nmask = Inet4Address.valueOf(0); int res = PcapLookupNet(source, netp, nmask, errbuf); if (res != OK) { System.err.println(errbuf.toString());