aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/helper/Checksum.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/helper/Checksum.java')
-rw-r--r--src/main/java/org/traccar/helper/Checksum.java8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/helper/Checksum.java b/src/main/java/org/traccar/helper/Checksum.java
index e660790ef..db5817275 100644
--- a/src/main/java/org/traccar/helper/Checksum.java
+++ b/src/main/java/org/traccar/helper/Checksum.java
@@ -200,18 +200,14 @@ public final class Checksum {
return (10 - (checksum % 10)) % 10;
}
- public static int udp(ByteBuffer data) {
+ public static int ip(ByteBuffer data) {
int sum = 0;
- int len = data.capacity();
- for (int j = 0; len > 1; len--) {
+ while (data.remaining() > 0) {
sum += data.get() & 0xff;
if ((sum & 0x80000000) > 0) {
sum = (sum & 0xffff) + (sum >> 16);
}
}
- if (len == 1) {
- sum += data.get() & 0xff;
- }
while ((sum >> 16) > 0) {
sum = (sum & 0xffff) + sum >> 16;
}