Java Code Examples for org.jboss.netty.buffer.ChannelBuffer.readerIndex()

The following are Jave code examples for showing how to use readerIndex() of the org.jboss.netty.buffer.ChannelBuffer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: traccar-service   File: MeitrackFrameDecoder.java   Source Code and License Vote up 6 votes
@Override
protected Object decode(
        ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {

    if (buf.readableBytes() < 10) {
        return null;
    }

    int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ',');
    if (index != -1) {
        int length = index - buf.readerIndex() + Integer.parseInt(
                buf.toString(buf.readerIndex() + 3, index - buf.readerIndex() - 3, StandardCharsets.US_ASCII));
        if (buf.readableBytes() >= length) {
            return buf.readBytes(length);
        }
    }

    return null;
}
 
Example 2
Project: traccar-service   File: UlbotechProtocolDecoder.java   Source Code and License Vote up 6 votes
private void decodeJ1708(Position position, ChannelBuffer buf, int length) {

        int end = buf.readerIndex() + length;

        while (buf.readerIndex() < end) {
            int mark = buf.readUnsignedByte();
            int len = BitUtil.between(mark, 0, 6);
            int type = BitUtil.between(mark, 6, 8);
            int id = buf.readUnsignedByte();
            if (type == 3) {
                id += 256;
            }
            String value = ChannelBuffers.hexDump(buf.readBytes(len - 1));
            if (type == 2 || type == 3) {
                position.set("pid" + id, value);
            }
        }
    }
 
Example 3
Project: traccar-service   File: Vt200FrameDecoder.java   Source Code and License Vote up 6 votes
@Override
protected Object decode(
        ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {

    int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ')') + 1;
    if (endIndex > 0) {

        ChannelBuffer frame = ChannelBuffers.dynamicBuffer();

        while (buf.readerIndex() < endIndex) {
            int b = buf.readByte();
            if (b == '=') {
                frame.writeByte(buf.readByte() ^ '=');
            } else {
                frame.writeByte(b);
            }
        }

        return frame;

    }

    return null;
}
 
Example 4
Project: traccar-service   File: L100FrameDecoder.java   Source Code and License Vote up 6 votes
@Override
protected Object decode(
        ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {

    if (buf.readableBytes() < 80) {
        return null;
    }

    int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x02);
    if (index == -1) {
        index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x04);
        if (index == -1) {
            return null;
        }
    }

    index += 2; // checksum

    if (buf.readableBytes() >= index - buf.readerIndex()) {
        return buf.readBytes(index - buf.readerIndex());
    }

    return null;
}
 
Example 5
Project: traccar-service   File: AtrackProtocolDecoder.java   Source Code and License Vote up 5 votes
private static String readString(ChannelBuffer buf) {
    String result = null;
    int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0);
    if (index > buf.readerIndex()) {
        result = buf.readBytes(index - buf.readerIndex()).toString(StandardCharsets.US_ASCII);
    }
    buf.readByte();
    return result;
}
 
Example 6
Project: traccar-service   File: Gt06FrameDecoder.java   Source Code and License Vote up 5 votes
@Override
protected Object decode(
        ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {

    if (buf.readableBytes() < 5) {
        return null;
    }

    int length = 2 + 2; // head and tail

    if (buf.getByte(buf.readerIndex()) == 0x78) {
        length += 1 + buf.getUnsignedByte(buf.readerIndex() + 2);
    } else {
        length += 2 + buf.getUnsignedShort(buf.readerIndex() + 2);
    }

    if (buf.readableBytes() >= length && buf.getUnsignedShort(buf.readerIndex() + length - 2) == 0x0d0a) {
        return buf.readBytes(length);
    }

    int endIndex = buf.readerIndex() - 1;
    do {
        endIndex = buf.indexOf(endIndex + 1, buf.writerIndex(), (byte) 0x0d);
        if (endIndex > 0 && buf.writerIndex() > endIndex + 1 && buf.getByte(endIndex + 1) == 0x0a) {
            return buf.readBytes(endIndex + 2 - buf.readerIndex());
        }
    } while (endIndex > 0);

    return null;
}
 
Example 7
Project: traccar-service   File: TotemFrameDecoder.java   Source Code and License Vote up 5 votes
@Override
protected Object decode(
        ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {

    if (buf.readableBytes() < 10) {
        return null;
    }

    int beginIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("$$"));
    if (beginIndex == -1) {
        return null;
    } else if (beginIndex > buf.readerIndex()) {
        buf.readerIndex(beginIndex);
    }

    int length;

    int flagIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("AA"));
    if (flagIndex != -1 && flagIndex - beginIndex == 6) {
        length = Integer.parseInt(buf.toString(buf.readerIndex() + 2, 4, StandardCharsets.US_ASCII));
    } else {
        length = Integer.parseInt(buf.toString(buf.readerIndex() + 2, 2, StandardCharsets.US_ASCII), 16);
    }

    if (length <= buf.readableBytes()) {
        return buf.readBytes(length);
    }

    return null;
}
 
Example 8
Project: Elasticsearch   File: LZFCompressor.java   Source Code and License Vote up 5 votes
@Override
public boolean isCompressed(ChannelBuffer buffer) {
    int offset = buffer.readerIndex();
    return buffer.readableBytes() >= 3 &&
            buffer.getByte(offset) == LZFChunk.BYTE_Z &&
            buffer.getByte(offset + 1) == LZFChunk.BYTE_V &&
            (buffer.getByte(offset + 2) == LZFChunk.BLOCK_TYPE_COMPRESSED || buffer.getByte(offset + 2) == LZFChunk.BLOCK_TYPE_NON_COMPRESSED);
}
 
Example 9
Project: traccar-service   File: EskyFrameDecoder.java   Source Code and License Vote up 5 votes
@Override
protected Object decode(
        ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {

    buf.readerIndex(buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 'E'));

    int endIndex = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 'E');
    if (endIndex > 0) {
        return buf.readBytes(endIndex - buf.readerIndex());
    } else {
        return buf.readBytes(buf.readableBytes()); // assume full frame
    }
}
 
Example 10
Project: traccar-service   File: MxtFrameDecoder.java   Source Code and License Vote up 5 votes
@Override
protected Object decode(
        ChannelHandlerContext ctx,
        Channel channel,
        ChannelBuffer buf) throws Exception {

    if (buf.readableBytes() < 2) {
        return null;
    }

    int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0x04);
    if (index != -1) {
        ChannelBuffer result = ChannelBuffers.buffer(ByteOrder.LITTLE_ENDIAN, index + 1 - buf.readerIndex());

        while (buf.readerIndex() <= index) {
            int b = buf.readUnsignedByte();
            if (b == 0x10) {
                result.writeByte(buf.readUnsignedByte() - 0x20);
            } else {
                result.writeByte(b);
            }
        }

        return result;
    }

    return null;
}
 
Example 11
Project: traccar-service   File: HuabaoFrameDecoder.java   Source Code and License Vote up 5 votes
@Override
protected Object decode(
        ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {

    if (buf.readableBytes() < 2) {
        return null;
    }

    int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0x7e);
    if (index != -1) {
        ChannelBuffer result = ChannelBuffers.buffer(index + 1 - buf.readerIndex());

        while (buf.readerIndex() <= index) {
            int b = buf.readUnsignedByte();
            if (b == 0x7d) {
                int ext = buf.readUnsignedByte();
                if (ext == 0x01) {
                    result.writeByte(0x7d);
                } else if (ext == 0x02) {
                    result.writeByte(0x7e);
                }
            } else {
                result.writeByte(b);
            }
        }

        return result;
    }

    return null;
}
 
Example 12
Project: traccar-service   File: UlbotechProtocolDecoder.java   Source Code and License Vote up 5 votes
private void decodeObd(Position position, ChannelBuffer buf, int length) {

        int end = buf.readerIndex() + length;

        while (buf.readerIndex() < end) {
            int parameterLength = buf.getUnsignedByte(buf.readerIndex()) >> 4;
            int mode = buf.readUnsignedByte() & 0x0F;
            position.add(ObdDecoder.decode(mode, ChannelBuffers.hexDump(buf.readBytes(parameterLength - 1))));
        }
    }
 
Example 13
Project: Elasticsearch   File: DeflateCompressor.java   Source Code and License Vote up 5 votes
@Override
public boolean isCompressed(ChannelBuffer buffer) {
    if (buffer.readableBytes() < HEADER.length) {
        return false;
    }
    final int offset = buffer.readerIndex();
    for (int i = 0; i < HEADER.length; ++i) {
        if (buffer.getByte(offset + i) != HEADER[i]) {
            return false;
        }
    }
    return true;
}
 
Example 14
Project: athena   File: BgpUpdate.java   Source Code and License Vote up 5 votes
/**
 * Parses a message that contains encoded IPv4 network prefixes.
 * <p>
 * The IPv4 prefixes are encoded in the form:
 * <Length, Prefix> where Length is the length in bits of the IPv4 prefix,
 * and Prefix is the IPv4 prefix (padded with trailing bits to the end
 * of an octet).
 *
 * @param totalLength the total length of the data to parse
 * @param message the message with data to parse
 * @return a collection of parsed IPv4 network prefixes
 * @throws BgpMessage.BgpParseException
 */
private static Collection<Ip4Prefix> parsePackedIp4Prefixes(
                                            int totalLength,
                                            ChannelBuffer message)
    throws BgpMessage.BgpParseException {
    Collection<Ip4Prefix> result = new ArrayList<>();

    if (totalLength == 0) {
        return result;
    }

    // Parse the data
    byte[] buffer = new byte[Ip4Address.BYTE_LENGTH];
    int dataEnd = message.readerIndex() + totalLength;
    while (message.readerIndex() < dataEnd) {
        int prefixBitlen = message.readUnsignedByte();
        int prefixBytelen = (prefixBitlen + 7) / 8;     // Round-up
        if (message.readerIndex() + prefixBytelen > dataEnd) {
            String errorMsg = "Malformed Network Prefixes";
            throw new BgpMessage.BgpParseException(errorMsg);
        }

        message.readBytes(buffer, 0, prefixBytelen);
        Ip4Prefix prefix = Ip4Prefix.valueOf(Ip4Address.valueOf(buffer),
                                             prefixBitlen);
        result.add(prefix);
    }

    return result;
}
 
Example 15
Project: traccar-service   File: WatchFrameDecoder.java   Source Code and License Vote up 4 votes
@Override
protected Object decode(
        ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {

    if (buf.readableBytes() >= MESSAGE_HEADER) {
        ChannelBuffer lengthBuffer = ChannelBuffers.dynamicBuffer();
        buf.getBytes(buf.readerIndex() + MESSAGE_HEADER - 4 - 1, lengthBuffer, 4);
        int length = Integer.parseInt(lengthBuffer.toString(StandardCharsets.US_ASCII), 16) + MESSAGE_HEADER + 1;
        if (buf.readableBytes() >= length) {
            ChannelBuffer frame = ChannelBuffers.dynamicBuffer();
            int endIndex = buf.readerIndex() + length;
            while (buf.readerIndex() < endIndex) {
                byte b = buf.readByte();
                if (b == 0x7D) {
                    switch (buf.readByte()) {
                        case 0x01:
                            frame.writeByte(0x7D);
                            break;
                        case 0x02:
                            frame.writeByte(0x5B);
                            break;
                        case 0x03:
                            frame.writeByte(0x5D);
                            break;
                        case 0x04:
                            frame.writeByte(0x2C);
                            break;
                        case 0x05:
                            frame.writeByte(0x2A);
                            break;
                        default:
                            throw new IllegalArgumentException();
                    }
                } else {
                    frame.writeByte(b);
                }
            }
            return frame;
        }
    }

    return null;
}
 
Example 16
Project: traccar-service   File: OrionFrameDecoder.java   Source Code and License Vote up 4 votes
@Override
protected Object decode(
        ChannelHandlerContext ctx,
        Channel channel,
        ChannelBuffer buf) throws Exception {

    int length = 6;

    if (buf.readableBytes() >= length) {

        int type = buf.getUnsignedByte(buf.readerIndex() + 2) & 0x0f;

        if (type == OrionProtocolDecoder.MSG_USERLOG && buf.readableBytes() >= length + 5) {

            int index = buf.readerIndex() + 3;
            int count = buf.getUnsignedByte(index) & 0x0f;
            index += 5;
            length += 5;

            for (int i = 0; i < count; i++) {
                if (buf.readableBytes() < length) {
                    return null;
                }
                int logLength = buf.getUnsignedByte(index + 1);
                index += logLength;
                length += logLength;
            }

            if (buf.readableBytes() >= length) {
                return buf.readBytes(length);
            }

        } else if (type == OrionProtocolDecoder.MSG_SYSLOG && buf.readableBytes() >= length + 12) {

            length += buf.getUnsignedShort(buf.readerIndex() + 8);
            if (buf.readableBytes() >= length) {
                return buf.readBytes(length);
            }

        }
    }

    return null;
}
 
Example 17
Project: Elasticsearch   File: SizeHeaderFrameDecoder.java   Source Code and License Vote up 4 votes
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
    if (buffer.readableBytes() < 6) {
        return null;
    }

    int readerIndex = buffer.readerIndex();
    if (buffer.getByte(readerIndex) != 'E' || buffer.getByte(readerIndex + 1) != 'S') {
        // special handling for what is probably HTTP
        if (bufferStartsWith(buffer, readerIndex, "GET ") ||
            bufferStartsWith(buffer, readerIndex, "POST ") ||
            bufferStartsWith(buffer, readerIndex, "PUT ") ||
            bufferStartsWith(buffer, readerIndex, "HEAD ") ||
            bufferStartsWith(buffer, readerIndex, "DELETE ") ||
            bufferStartsWith(buffer, readerIndex, "OPTIONS ") ||
            bufferStartsWith(buffer, readerIndex, "PATCH ") ||
            bufferStartsWith(buffer, readerIndex, "TRACE ")) {

            throw new HttpOnTransportException("This is not a HTTP port");
        }

        // we have 6 readable bytes, show 4 (should be enough)
        throw new StreamCorruptedException("invalid internal transport message format, got ("
                + Integer.toHexString(buffer.getByte(readerIndex) & 0xFF) + ","
                + Integer.toHexString(buffer.getByte(readerIndex + 1) & 0xFF) + ","
                + Integer.toHexString(buffer.getByte(readerIndex + 2) & 0xFF) + ","
                + Integer.toHexString(buffer.getByte(readerIndex + 3) & 0xFF) + ")");
    }

    int dataLen = buffer.getInt(buffer.readerIndex() + 2);
    if (dataLen == NettyHeader.PING_DATA_SIZE) {
        // discard the messages we read and continue, this is achieved by skipping the bytes
        // and returning null
        buffer.skipBytes(6);
        return null;
    }
    if (dataLen <= 0) {
        throw new StreamCorruptedException("invalid data length: " + dataLen);
    }
    // safety against too large frames being sent
    if (dataLen > NINETY_PER_HEAP_SIZE) {
        throw new TooLongFrameException(
                "transport content length received [" + new ByteSizeValue(dataLen) + "] exceeded [" + new ByteSizeValue(NINETY_PER_HEAP_SIZE) + "]");
    }

    if (buffer.readableBytes() < dataLen + 6) {
        return null;
    }
    buffer.skipBytes(6);
    return buffer;
}
 
Example 18
Project: athena   File: PcepMessageVer1.java   Source Code and License Vote up 4 votes
@Override
public PcepMessage readFrom(ChannelBuffer cb) throws PcepParseException, PcepOutOfBoundMessageException {

    if (cb.readableBytes() < MINIMUM_LENGTH) {
        throw new PcepParseException("Packet should have minimum length: " + MINIMUM_LENGTH);
    }

    try {
        int start = cb.readerIndex();
        // fixed value property version == 1
        byte version = cb.readByte();
        version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
        if (version != (byte) PACKET_VERSION) {
            throw new PcepParseException("Wrong version. Expected=PcepVersion.Message_1(1), got=" + version);
        }

        byte type = cb.readByte();
        short length = cb.readShort();
        cb.readerIndex(start);

        // Check the out-of-bound message.
        // If the message is out-of-bound then throw PcepOutOfBoundException.
        if ((length - MINIMUM_COMMON_HEADER_LENGTH) > cb.readableBytes()) {
            throw new PcepOutOfBoundMessageException("Message is out-of-bound.");
        }

        if (type == (byte) PcepType.OPEN.getType()) {
            log.debug("OPEN MESSAGE is received");
            return PcepOpenMsgVer1.READER.readFrom(cb.readBytes(length));
        } else if (type == (byte) PcepType.KEEP_ALIVE.getType()) {
            log.debug("KEEPALIVE MESSAGE is received");
            return PcepKeepaliveMsgVer1.READER.readFrom(cb.readBytes(length));
        } else if (type == (byte) PcepType.ERROR.getType()) {
            log.debug("ERROR MESSAGE is received");
            return PcepErrorMsgVer1.READER.readFrom(cb.readBytes(length));
        } else if (type == (byte) PcepType.CLOSE.getType()) {
            log.debug("CLOSE MESSAGE is received");
            return PcepCloseMsgVer1.READER.readFrom(cb.readBytes(length));
        } else if (type == (byte) PcepType.REPORT.getType()) {
            log.debug("REPORT MESSAGE is received");
            return PcepReportMsgVer1.READER.readFrom(cb.readBytes(length));
        } else if (type == (byte) PcepType.UPDATE.getType()) {
            log.debug("UPDATE MESSAGE is received");
            return PcepUpdateMsgVer1.READER.readFrom(cb.readBytes(length));
        } else if (type == (byte) PcepType.INITIATE.getType()) {
            log.debug("INITIATE MESSAGE is received");
            return PcepInitiateMsgVer1.READER.readFrom(cb.readBytes(length));
        } else if (type == (byte) PcepType.LS_REPORT.getType()) {
            log.debug("LS REPORT MESSAGE is received");
            return PcepLSReportMsgVer1.READER.readFrom(cb.readBytes(length));
        } else if (type == (byte) PcepType.LABEL_RANGE_RESERV.getType()) {
            log.debug("LABEL RANGE RESERVE MESSAGE is received");
            return PcepLabelRangeResvMsgVer1.READER.readFrom(cb.readBytes(length));
        } else if (type == (byte) PcepType.LABEL_UPDATE.getType()) {
            log.debug("LABEL UPDATE MESSAGE is received");
            return PcepLabelUpdateMsgVer1.READER.readFrom(cb.readBytes(length));
        } else {
            throw new PcepParseException("ERROR: UNKNOWN MESSAGE is received. Msg Type: " + type);
        }
    } catch (IndexOutOfBoundsException e) {
        throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_1);
    }
}
 
Example 19
Project: athena   File: LinkTlv.java   Source Code and License Vote up 4 votes
/**
 * Reads bytes from channel buffer .
 *
 * @param channelBuffer channel buffer instance
 * @throws Exception might throws exception while parsing packet
 */
public void readFrom(ChannelBuffer channelBuffer) throws Exception {
    while (channelBuffer.readableBytes() > 0) {
        TlvHeader tlvHeader = new TlvHeader();
        tlvHeader.setTlvType(channelBuffer.readUnsignedShort());
        tlvHeader.setTlvLength(channelBuffer.readUnsignedShort());

        if (LinkSubTypes.LINK_TYPE.value() == tlvHeader.tlvType()) {
            LinkType linktype = new LinkType(tlvHeader);
            linktype.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
            subTlv.add(linktype);
            if (tlvHeader.tlvLength() < OspfUtil.FOUR_BYTES) {
                int readerIndex = channelBuffer.readerIndex() + (OspfUtil.FOUR_BYTES - tlvHeader.tlvLength());
                channelBuffer.readerIndex(readerIndex);
            }
        } else if (LinkSubTypes.LINK_ID.value() == tlvHeader.tlvType()) {
            LinkId linkId = new LinkId(tlvHeader);
            linkId.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
            subTlv.add(linkId);
        } else if (LinkSubTypes.LOCAL_INTERFACE_IP_ADDRESS.value() == tlvHeader.tlvType()) {
            LocalInterfaceIpAddress localInterfaceIpAddress = new LocalInterfaceIpAddress(tlvHeader);
            localInterfaceIpAddress.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
            subTlv.add(localInterfaceIpAddress);
        } else if (LinkSubTypes.REMOTE_INTERFACE_IP_ADDRESS.value() == tlvHeader.tlvType()) {
            RemoteInterfaceIpAddress remoteInterfaceIpAddress = new RemoteInterfaceIpAddress(tlvHeader);
            remoteInterfaceIpAddress.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
            subTlv.add(remoteInterfaceIpAddress);
        } else if (LinkSubTypes.TRAFFIC_ENGINEERING_METRIC.value() == tlvHeader.tlvType()) {
            TrafficEngineeringMetric trafficEngineeringMetric = new TrafficEngineeringMetric(tlvHeader);
            trafficEngineeringMetric.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
            subTlv.add(trafficEngineeringMetric);
        } else if (LinkSubTypes.MAXIMUM_BANDWIDTH.value() == tlvHeader.tlvType()) {
            MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader);
            maximumBandwidth.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
            subTlv.add(maximumBandwidth);
        } else if (LinkSubTypes.MAXIMUM_RESERVABLE_BANDWIDTH.value() == tlvHeader.tlvType()) {
            MaximumReservableBandwidth maximumReservableBandwidth = new MaximumReservableBandwidth(tlvHeader);
            maximumReservableBandwidth.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
            subTlv.add(maximumReservableBandwidth);
        } else if (LinkSubTypes.UNRESERVED_BANDWIDTH.value() == tlvHeader.tlvType()) {
            UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader);
            unreservedBandwidth.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
            subTlv.add(unreservedBandwidth);
        } else if (LinkSubTypes.ADMINISTRATIVE_GROUP.value() == tlvHeader.tlvType()) {
            AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader);
            administrativeGroup.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
            subTlv.add(administrativeGroup);
        } else {
            UnknownLinkSubType unknownLinkSubType = new UnknownLinkSubType(tlvHeader);
            unknownLinkSubType.readFrom(channelBuffer.readBytes(tlvHeader.tlvLength()));
            subTlv.add(unknownLinkSubType);
        }
    }
}
 
Example 20
Project: traccar-service   File: TzoneProtocolDecoder.java   Source Code and License Vote up 3 votes
private void decodePassengers(Position position, ChannelBuffer buf) {

        int blockLength = buf.readUnsignedShort();
        int blockEnd = buf.readerIndex() + blockLength;

        if (blockLength > 0) {

            position.set("passengersOn", buf.readUnsignedMedium());
            position.set("passengersOff", buf.readUnsignedMedium());

        }

        buf.readerIndex(blockEnd);

    }