aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/helper
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2022-09-21 09:57:52 -0700
committerGitHub <noreply@github.com>2022-09-21 09:57:52 -0700
commitd5b1385596f79da2514ea7cccf27e9bdeebcacae (patch)
treef7b2d44f09dee52c09c2c7e2384f0c27f1e65fa1 /src/main/java/org/traccar/helper
parent561647947118a86256dbb584f6da450334462739 (diff)
parent7aa230b9ddcd5540e7ff9c9b3d9bcf5119175c46 (diff)
downloadtrackermap-server-d5b1385596f79da2514ea7cccf27e9bdeebcacae.tar.gz
trackermap-server-d5b1385596f79da2514ea7cccf27e9bdeebcacae.tar.bz2
trackermap-server-d5b1385596f79da2514ea7cccf27e9bdeebcacae.zip
Merge pull request #4912 from stefanclark/Xexun2Encoder
Implement Xexun2 encoder
Diffstat (limited to 'src/main/java/org/traccar/helper')
-rw-r--r--src/main/java/org/traccar/helper/Checksum.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/helper/Checksum.java b/src/main/java/org/traccar/helper/Checksum.java
index 8c3d0063a..db5817275 100644
--- a/src/main/java/org/traccar/helper/Checksum.java
+++ b/src/main/java/org/traccar/helper/Checksum.java
@@ -200,4 +200,19 @@ public final class Checksum {
return (10 - (checksum % 10)) % 10;
}
+ public static int ip(ByteBuffer data) {
+ int sum = 0;
+ while (data.remaining() > 0) {
+ sum += data.get() & 0xff;
+ if ((sum & 0x80000000) > 0) {
+ sum = (sum & 0xffff) + (sum >> 16);
+ }
+ }
+ while ((sum >> 16) > 0) {
+ sum = (sum & 0xffff) + sum >> 16;
+ }
+ sum = (sum == 0xffff) ? sum & 0xffff : (~sum) & 0xffff;
+ return sum;
+ }
+
}