diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2014-04-08 20:35:02 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2014-04-08 20:35:02 +1200 |
commit | 15beffad2c83f6e5014e3a9a44692769d45b211d (patch) | |
tree | 4c6585c44f5830fd7f4cb4b1b008405b19dadc41 | |
parent | 54bc7a8f1dae8c5f8e2652d42c63211e2d3f16ff (diff) | |
download | trackermap-server-15beffad2c83f6e5014e3a9a44692769d45b211d.tar.gz trackermap-server-15beffad2c83f6e5014e3a9a44692769d45b211d.tar.bz2 trackermap-server-15beffad2c83f6e5014e3a9a44692769d45b211d.zip |
Ignore GT06 unknown header
-rw-r--r-- | src/org/traccar/protocol/Gt06ProtocolDecoder.java | 6 | ||||
-rw-r--r-- | test/org/traccar/protocol/Gt06ProtocolDecoderTest.java | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java index 7bc0923cd..b3a69c274 100644 --- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java +++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java @@ -83,7 +83,11 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder { ChannelBuffer buf = (ChannelBuffer) msg; - buf.skipBytes(2); // header + // Check header + if (buf.readByte() != 0x78 || buf.readByte() != 0x78) { + return null; + } + int length = buf.readByte(); // size int dataLength = length - 5; diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java index 85e4859cf..ac353c34a 100644 --- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -33,7 +33,7 @@ public class Gt06ProtocolDecoderTest { int[] buf6 = {0x78,0x78,0x19,0x10,0x0B,0x03,0x1A,0x0B,0x1B,0x31,0xCC,0x02,0x7A,0xC7,0xFD,0x0C,0x46,0x57,0xBF,0x01,0x15,0x21,0x00,0x01,0x00,0x1C,0xC6,0x07,0x0D,0x0A}; verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf6)))); - int[] buf7 = {78,0x78,0x21,0x12,0x0C,0x01,0x0C,0x0F,0x15,0x1F,0xCF,0x02,0x7A,0xC8,0x84,0x0C,0x46,0x57,0xEC,0x00,0x14,0x00,0x01,0xCC,0x00,0x28,0x7D,0x00,0x1F,0x72,0x00,0x01,0x00,0x0F,0x53,0xA0,0x0D,0x0A}; + int[] buf7 = {0x78,0x78,0x21,0x12,0x0C,0x01,0x0C,0x0F,0x15,0x1F,0xCF,0x02,0x7A,0xC8,0x84,0x0C,0x46,0x57,0xEC,0x00,0x14,0x00,0x01,0xCC,0x00,0x28,0x7D,0x00,0x1F,0x72,0x00,0x01,0x00,0x0F,0x53,0xA0,0x0D,0x0A}; verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf7)))); int[] buf8 = {0x78,0x78,0x25,0x16,0x0B,0x05,0x1B,0x09,0x35,0x23,0xCF,0x02,0x7A,0xC8,0x36,0x0C,0x46,0x57,0xB3,0x00,0x14,0x00,0x09,0x01,0xCC,0x00,0x26,0x6A,0x00,0x1E,0x17,0x40,0x05,0x04,0x00,0x02,0x00,0x08,0xD7,0xB1,0x0D,0x0A}; @@ -47,6 +47,9 @@ public class Gt06ProtocolDecoderTest { int[] buf11 = {0x78,0x78,0x47,0x1e,0x0e,0x03,0x11,0x0b,0x05,0x11,0xc5,0x01,0xc6,0x64,0xfd,0x07,0x4d,0xb7,0x3f,0x02,0x18,0xa6,0x02,0xe0,0x03,0x43,0x3a,0x00,0x2f,0xed,0x40,0x43,0x3a,0x00,0x56,0xe1,0x4e,0x43,0x3a,0x00,0x56,0x10,0x4e,0x43,0x3a,0x00,0x56,0xfd,0x53,0x43,0x3a,0x00,0x2e,0xed,0x55,0x43,0x3a,0x00,0x7e,0x4b,0x57,0x43,0x3a,0x00,0x2e,0xe2,0x5a,0xff,0x00,0x02,0x01,0x20,0xf6,0x72,0x0d,0x0a}; verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf11)))); + + int[] buf12 = {0x79,0x79,0x00,0x5b,0xfd,0x03,0x58,0x89,0x90,0x50,0x92,0x77,0x25,0x00,0x4c,0x00,0x20,0xbf,0x98,0x43,0x58,0xdf,0x60,0x3b,0x2e,0xa3,0xa3,0x39,0xe5,0x43,0x35,0x01,0x3a,0x5b,0x56,0x45,0x52,0x53,0x49,0x4f,0x4e,0x5d,0x47,0x54,0x30,0x36,0x44,0x5f,0x32,0x30,0x5f,0x36,0x30,0x44,0x4d,0x32,0x5f,0x42,0x32,0x35,0x45,0x5f,0x56,0x31,0x35,0x5f,0x57,0x4d,0x5b,0x42,0x55,0x49,0x4c,0x44,0x5d,0x32,0x30,0x31,0x33,0x2f,0x31,0x32,0x2f,0x32,0x38,0x20,0x31,0x35,0x3a,0x32,0x34,0x00,0x2a,0x3b,0x24,0x0d,0x0a,0x79,0x79,0x00,0x5b,0xfd,0x03,0x58,0x89,0x90,0x50,0x92,0x77,0x25,0x00,0x4c,0x00,0x20,0xbf,0x98,0x43,0x58,0xdf,0x60,0x3b,0x2e,0xa3,0xa3,0x39,0xe5,0x43,0x35,0x01,0x3a,0x5b,0x56,0x45,0x52,0x53,0x49,0x4f,0x4e,0x5d,0x47,0x54,0x30,0x36,0x44,0x5f,0x32,0x30,0x5f,0x36,0x30,0x44,0x4d,0x32,0x5f,0x42,0x32,0x35,0x45,0x5f,0x56,0x31,0x35,0x5f,0x57,0x4d,0x5b,0x42,0x55,0x49,0x4c,0x44,0x5d,0x32,0x30,0x31,0x33,0x2f,0x31,0x32,0x2f,0x32,0x38,0x20,0x31,0x35,0x3a,0x32,0x34,0x00,0x2d,0x4f,0x9b,0x0d,0x0a,0x79,0x79,0x00,0x5b,0xfd,0x03,0x58,0x89,0x90,0x50,0x92,0x77,0x25,0x00,0x4c,0x00,0x20,0xbf,0x98,0x43,0x58,0xdf,0x60,0x3b,0x2e,0xa3,0xa3,0x39,0xe5,0x43,0x35,0x01,0x3a,0x5b,0x56,0x45,0x52,0x53,0x49,0x4f,0x4e,0x5d,0x47,0x54,0x30,0x36,0x44,0x5f,0x32,0x30,0x5f,0x36,0x30,0x44,0x4d,0x32,0x5f,0x42,0x32,0x35,0x45,0x5f,0x56,0x31,0x35,0x5f,0x57,0x4d,0x5b,0x42,0x55,0x49,0x4c,0x44,0x5d,0x32,0x30,0x31,0x33,0x2f,0x31,0x32,0x2f,0x32,0x38,0x20,0x31,0x35,0x3a,0x32,0x34,0x00,0x30,0x84,0xff,0x0d,0x0a}; + assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray(buf12)))); } |