org.graylog2.inputs.syslog.tcp.SyslogOctetCountFrameDecoder Maven / Gradle / Ivy
/**
* This file is part of Graylog.
*
* Graylog is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Graylog is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Graylog. If not, see .
*/
package org.graylog2.inputs.syslog.tcp;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.util.ByteProcessor;
import java.nio.charset.StandardCharsets;
import java.util.List;
/**
* Implements a Netty {@link ByteToMessageDecoder} for the Syslog octet counting framing. (RFC6587)
*
* @see RFC6587 Octet Counting
*/
public class SyslogOctetCountFrameDecoder extends ByteToMessageDecoder {
private static final ByteProcessor BYTE_PROCESSOR = value -> value != ' ';
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List