From 8b7fc40e229150a1a8f06272e5e205e56d398d98 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Wed, 1 May 2019 21:38:10 +0700 Subject: [PATCH 1/3] Byte array to hex string --- .../main/java/com/ardikars/jxpacket/core/ip/ip6/Options.java | 5 ++--- .../main/java/com/ardikars/jxpacket/core/ip/ip6/Routing.java | 4 ++-- .../ardikars/jxpacket/core/ndp/NeighborDiscoveryOptions.java | 4 ++-- .../src/main/java/com/ardikars/jxpacket/core/tcp/Tcp.java | 5 ++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Options.java b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Options.java index 2a36841..912ef68 100644 --- a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Options.java +++ b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Options.java @@ -18,12 +18,11 @@ package com.ardikars.jxpacket.core.ip.ip6; import com.ardikars.common.memory.Memory; +import com.ardikars.common.util.Strings; import com.ardikars.jxpacket.common.AbstractPacket; import com.ardikars.jxpacket.common.layer.TransportLayer; import com.ardikars.jxpacket.core.ip.Ip6; -import java.util.Arrays; - public abstract class Options extends AbstractPacket { protected abstract static class Header extends Ip6.ExtensionHeader { @@ -86,7 +85,7 @@ public String toString() { return new StringBuilder() .append("\t\tnextHeader: ").append(nextHeader).append('\n') .append("\t\textensionLength: ").append(extensionLength).append('\n') - .append("\t\toptions: ").append(Arrays.toString(options)).append('\n') + .append("\t\toptions: ").append(Strings.toHexString(options)).append('\n') .toString(); } diff --git a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Routing.java b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Routing.java index 4b6cbb8..691fb5c 100644 --- a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Routing.java +++ b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Routing.java @@ -19,13 +19,13 @@ import com.ardikars.common.memory.Memory; import com.ardikars.common.util.NamedNumber; +import com.ardikars.common.util.Strings; import com.ardikars.common.util.Validate; import com.ardikars.jxpacket.common.AbstractPacket; import com.ardikars.jxpacket.common.Packet; import com.ardikars.jxpacket.common.layer.TransportLayer; import com.ardikars.jxpacket.core.ip.Ip6; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -133,7 +133,7 @@ public String toString() { .append("\t\textensionLength: ").append(extensionLength).append('\n') .append("\t\troutingType: ").append(routingType).append('\n') .append("\t\tsegmentLeft: ").append(segmentLeft).append('\n') - .append("\t\troutingData: ").append(Arrays.toString(routingData)).append('\n') + .append("\t\troutingData: ").append(Strings.toHexString(routingData)).append('\n') .toString(); } diff --git a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ndp/NeighborDiscoveryOptions.java b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ndp/NeighborDiscoveryOptions.java index b806ddc..87641af 100644 --- a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ndp/NeighborDiscoveryOptions.java +++ b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ndp/NeighborDiscoveryOptions.java @@ -19,6 +19,7 @@ import com.ardikars.common.memory.Memory; import com.ardikars.common.util.NamedNumber; +import com.ardikars.common.util.Strings; import com.ardikars.jxpacket.common.AbstractPacket; import com.ardikars.jxpacket.common.Packet; import com.ardikars.jxpacket.common.UnknownPacket; @@ -26,7 +27,6 @@ import java.io.Serializable; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -215,7 +215,7 @@ public String toString() { .append("Type: ") .append(this.getType()) .append(", Data: ") - .append(Arrays.toString(this.getData())) + .append(Strings.toHexString(this.getData())) .append("]").toString(); } diff --git a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/tcp/Tcp.java b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/tcp/Tcp.java index b77d1e4..4d0c6c8 100644 --- a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/tcp/Tcp.java +++ b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/tcp/Tcp.java @@ -18,13 +18,12 @@ package com.ardikars.jxpacket.core.tcp; import com.ardikars.common.memory.Memory; +import com.ardikars.common.util.Strings; import com.ardikars.common.util.Validate; import com.ardikars.jxpacket.common.AbstractPacket; import com.ardikars.jxpacket.common.Packet; import com.ardikars.jxpacket.common.layer.ApplicationLayer; -import java.util.Arrays; - public class Tcp extends AbstractPacket { private final Tcp.Header header; @@ -181,7 +180,7 @@ public String toString() { .append("\twindowSize: ").append(windowSize).append('\n') .append("\tchecksum: ").append(checksum).append('\n') .append("\turgentPointer: ").append(urgentPointer).append('\n') - .append("\toptions: ").append(Arrays.toString(options)).append('\n') + .append("\toptions: ").append(Strings.toHexString(options)).append('\n') .toString(); } From 90d8c2711d43a9060b05a225559c9a71a1c00b52 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Wed, 1 May 2019 21:38:29 +0700 Subject: [PATCH 2/3] Update lib version --- gradle/configure.gradle | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gradle/configure.gradle b/gradle/configure.gradle index f8204aa..492a3fa 100644 --- a/gradle/configure.gradle +++ b/gradle/configure.gradle @@ -7,7 +7,7 @@ ext { NAME = 'Jxpacket' GROUP = 'com.ardikars.jxpacket' - VERSION = '1.2.3.RELEASE' + VERSION = '1.2.4.RELEASE' DESCRIPTION = 'Jxpacket is a network packet crafting library for java.' MAVEN_LOCAL_REPOSITORY = "${System.env.HOME}/.m2/repository" @@ -24,9 +24,7 @@ ext { PMD_VERION = '6.5.0' JACOCO_VERSION = '0.8.2' - COMMON_VERSION = '1.2.7.RELEASE' - SPRING_BOOT_VERSION = '2.0.4.RELEASE' - PCAP4J_VERSION = '1.7.3' + COMMON_VERSION = '1.2.8.RELEASE' pom_project = { From 7cb1260e881ee6b33f272e8cf4c523445f479b8e Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Wed, 1 May 2019 21:39:04 +0700 Subject: [PATCH 3/3] Fix reserved 2 bytes in ipv6 authentication header --- .../com/ardikars/jxpacket/core/ip/ip6/Authentication.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Authentication.java b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Authentication.java index b28c029..ae87101 100644 --- a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Authentication.java +++ b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/ip6/Authentication.java @@ -18,13 +18,12 @@ package com.ardikars.jxpacket.core.ip.ip6; import com.ardikars.common.memory.Memory; +import com.ardikars.common.util.Strings; import com.ardikars.common.util.Validate; import com.ardikars.jxpacket.common.AbstractPacket; import com.ardikars.jxpacket.common.Packet; import com.ardikars.jxpacket.common.layer.TransportLayer; -import java.util.Arrays; - public class Authentication extends AbstractPacket { private final Authentication.Header header; @@ -136,7 +135,7 @@ public String toString() { .append("\t\tpayloadLength: ").append(payloadLength).append('\n') .append("\t\tsecurityParameterIndex: ").append(securityParameterIndex).append('\n') .append("\t\tsequenceNumber: ").append(sequenceNumber).append('\n') - .append("\t\tintegrityCheckValue: ").append(Arrays.toString(integrityCheckValue)).append('\n') + .append("\t\tintegrityCheckValue: ").append(Strings.toHexString(integrityCheckValue)).append('\n') .toString(); } @@ -200,6 +199,7 @@ public Packet build() { public Packet build(final Memory buffer) { this.nextHeader = TransportLayer.valueOf(buffer.readByte()); this.payloadLength = buffer.readByte(); + buffer.readShort(); // reserved this.securityParameterIndex = buffer.readInt(); this.sequenceNumber = buffer.readInt(); this.integrityCheckValue = new byte[(this.payloadLength + 2) * 4 - 12];