diff --git a/gradle/configure.gradle b/gradle/configure.gradle index 5db3e21..cac4a30 100644 --- a/gradle/configure.gradle +++ b/gradle/configure.gradle @@ -7,7 +7,7 @@ ext { NAME = 'Jxpacket' GROUP = 'com.ardikars.jxpacket' - VERSION = '1.2.3.RC2' + VERSION = '1.2.3.RC4' DESCRIPTION = 'Jxpacket is a network packet crafting library for java.' MAVEN_LOCAL_REPOSITORY = "${System.env.HOME}/.m2/repository" diff --git a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/Ip4.java b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/Ip4.java index 2bc8972..c958b18 100644 --- a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/Ip4.java +++ b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/ip/Ip4.java @@ -154,7 +154,7 @@ public byte[] getOptions() { public boolean isValidChecksum() { int accumulation = 0; for (int i = 0; i < headerLength * 2; ++i) { - accumulation += 0xffff & buffer.getShort(0); + accumulation += 0xffff & buffer.getShort(i + 2); } accumulation = (accumulation >> 16 & 0xffff) + (accumulation & 0xffff); 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 3f0bd8c..b77d1e4 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 @@ -272,23 +272,23 @@ public Packet build() { @Override public Packet build(Memory buffer) { - this.sourcePort = buffer.getShort(0); - this.destinationPort = buffer.getShort(2); - this.sequence = buffer.getInt(4); - this.acknowledge = buffer.getInt(8); - short flags = buffer.getShort(12); + this.sourcePort = buffer.readShort(); + this.destinationPort = buffer.readShort(); + this.sequence = buffer.readInt(); + this.acknowledge = buffer.readInt(); + short flags = buffer.readShort(); this.dataOffset = (byte) (flags >> 12 & 0xf); this.flags = new TcpFlags.Builder().build((short) (flags & 0x1ff)); - this.windowSize = buffer.getShort(14); - this.checksum = buffer.getShort(16); - this.urgentPointer = buffer.getShort(18); + this.windowSize = buffer.readShort(); + this.checksum = buffer.readShort(); + this.urgentPointer = buffer.readShort(); if (this.dataOffset > 5) { int optionLength = (this.dataOffset << 2) - Header.TCP_HEADER_LENGTH; if (buffer.capacity() < Header.TCP_HEADER_LENGTH + optionLength) { optionLength = buffer.capacity() - Header.TCP_HEADER_LENGTH; } this.options = new byte[optionLength]; - buffer.getBytes(20, options); + buffer.readBytes(options); int length = 20 + optionLength; this.payloadBuffer = buffer.copy(length, buffer.capacity() - length); } diff --git a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/udp/Udp.java b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/udp/Udp.java index 420f7f1..3fdc75a 100644 --- a/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/udp/Udp.java +++ b/jxpacket-core/src/main/java/com/ardikars/jxpacket/core/udp/Udp.java @@ -165,10 +165,10 @@ public Packet build() { @Override public Packet build(Memory buffer) { - this.sourcePort = buffer.getShort(0); - this.destinationPort = buffer.getShort(2); - this.length = buffer.getShort(4); - this.checksum = buffer.getShort(6); + this.sourcePort = buffer.readShort(); + this.destinationPort = buffer.readShort(); + this.length = buffer.readShort(); + this.checksum = buffer.readShort(); this.buffer = buffer; this.payloadBuffer = buffer.slice(); return new Udp(this);