diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-12 17:02:38 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-07-12 17:02:38 +1200 |
commit | 8d5b4ec5ec8e4aaa2c34793e3100a7782551afbd (patch) | |
tree | e9beaee9f915d936e3d05c43bef2f2f6be46c6ab /src/org | |
parent | 781f4b0a01dd8b16892b0bb907d43f9e0ca6f2ba (diff) | |
download | trackermap-server-8d5b4ec5ec8e4aaa2c34793e3100a7782551afbd.tar.gz trackermap-server-8d5b4ec5ec8e4aaa2c34793e3100a7782551afbd.tar.bz2 trackermap-server-8d5b4ec5ec8e4aaa2c34793e3100a7782551afbd.zip |
Fix issue in Hua Sheng frame decoder
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/protocol/HuaShengFrameDecoder.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/org/traccar/protocol/HuaShengFrameDecoder.java b/src/org/traccar/protocol/HuaShengFrameDecoder.java index 5d68fef9e..0e1becc30 100644 --- a/src/org/traccar/protocol/HuaShengFrameDecoder.java +++ b/src/org/traccar/protocol/HuaShengFrameDecoder.java @@ -16,6 +16,7 @@ package org.traccar.protocol; import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.frame.FrameDecoder; @@ -34,7 +35,23 @@ public class HuaShengFrameDecoder extends FrameDecoder { int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0xC0); if (index != -1) { - return buf.readBytes(index + 1 - buf.readerIndex()); + ChannelBuffer result = ChannelBuffers.buffer(index + 1 - buf.readerIndex()); + + while (buf.readerIndex() <= index) { + int b = buf.readUnsignedByte(); + if (b == 0xDB) { + int ext = buf.readUnsignedByte(); + if (ext == 0xDC) { + result.writeByte(0xC0); + } else if (ext == 0xDD) { + result.writeByte(0xDB); + } + } else { + result.writeByte(b); + } + } + + return result; } return null; |