Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
Using reader instead of getter
Browse files Browse the repository at this point in the history
  • Loading branch information
ardikars committed Apr 27, 2019
1 parent d8b6d5c commit 8f08deb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle/configure.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8f08deb

Please sign in to comment.