Skip to content

Commit 29e9f17

Browse files
bwssytemsa1aw
authored andcommitted
More debug
1 parent 99e6e9a commit 29e9f17

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/main/java/com/github/mob41/blapi/pkt/CmdPacket.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public class CmdPacket implements Packet {
5050

5151
private static final int DEFAULT_BYTES_SIZE = 0x38; // 56-bytes
5252

53-
private final byte[] headerdata;
5453
private final byte[] data;
5554

5655
/**
@@ -78,6 +77,7 @@ public CmdPacket(Mac targetMac, int count, byte[] id, byte[] iv, byte[] key, Cmd
7877

7978
byte cmd = cmdPayload.getCommand();
8079
byte[] payload = cmdPayload.getPayload().getData();
80+
byte[] headerdata;
8181

8282
log.debug("Constructor CmdPacket starts");
8383
log.debug("count=" + count + " cmdPayload.cmd=" + Integer.toHexString(cmd) + " payload.len=" + payload.length);
@@ -139,16 +139,16 @@ public CmdPacket(Mac targetMac, int count, byte[] id, byte[] iv, byte[] key, Cmd
139139

140140
log.debug("Running checksum for un-encrypted payload");
141141

142-
int checksum = 0xbeaf;
142+
int checksumpayload = 0xbeaf;
143143
for (int i = 0; i < payloadPad.length; i++) {
144-
checksum = checksum + (int) payloadPad[i];
145-
checksum = checksum & 0xffff;
144+
checksumpayload = checksumpayload + (int) payloadPad[i];
145+
checksumpayload = checksumpayload & 0xffff;
146146
}
147147

148-
headerdata[0x34] = (byte) (checksum & 0xff);
149-
headerdata[0x35] = (byte) (checksum >> 8);
148+
headerdata[0x34] = (byte) (checksumpayload & 0xff);
149+
headerdata[0x35] = (byte) (checksumpayload >> 8);
150150

151-
log.debug("Un-encrypted payload checksum: " + Integer.toHexString(checksum));
151+
log.debug("Un-encrypted payload checksum: " + Integer.toHexString(checksumpayload));
152152
log.debug("Creating AES instance with provided key {}, iv {}", key, iv);
153153

154154
AES aes = new AES(iv, key);
@@ -177,17 +177,17 @@ public CmdPacket(Mac targetMac, int count, byte[] id, byte[] iv, byte[] key, Cmd
177177

178178
log.debug("Running whole packet checksum");
179179

180-
checksum = 0xbeaf;
180+
int checksumpkt = 0xbeaf;
181181
for (int i = 0; i < data.length; i++) {
182-
checksum = checksum + (int) data[i];
183-
checksum = checksum & 0xffff;
184-
log.debug("index: " + i + ", checksum: " + checksum);
182+
checksumpkt = checksumpkt + (int) data[i];
183+
checksumpkt = checksumpkt & 0xffff;
184+
log.debug("index: " + i + ", data byte: " + (byte) data[i] + ", checksum: " + checksumpkt);
185185
}
186186

187-
log.debug("Whole packet checksum: " + Integer.toHexString(checksum));
187+
log.debug("Whole packet checksum: " + Integer.toHexString(checksumpkt));
188188

189-
data[0x20] = (byte) (checksum & 0xff);
190-
data[0x21] = (byte) (checksum >> 8);
189+
data[0x20] = (byte) (checksumpkt & 0xff);
190+
data[0x21] = (byte) (checksumpkt >> 8);
191191

192192
log.debug("End of CmdPacket constructor");
193193
}

0 commit comments

Comments
 (0)