@Override public int readInt() { return buffer.readInt(); }
@Override public int readInt() { return buffer.readInt(); }
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception { return buffer.readBytes(buffer.readInt()); } }
public int readInt() throws IOException { checkAvailable(4); return buffer.readInt(); }
private boolean decodePackHeader(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { if (buffer.readableBytes()<8) { return false; } int serial = buffer.readInt(); int listSize = buffer.readInt(); // Sanity check to reduce likelihood of invalid requests being honored. // Only allow 10% of available memory to go towards this list (too much!) if (listSize * SIZEOF_REF > 0.1 * maxMem) { channel.close().await(); throw new AvroRuntimeException("Excessively large list allocation " + "request detected: " + listSize + " items! Connection closed."); } this.listSize = listSize; dataPack = new NettyDataPack(serial, new ArrayList<>(listSize)); return true; }
public int readInt() { checkReadableBytes(4); return buf().readInt(); }
/** * Read a socket address from a buffer. The socket address will be provided * as two strings containing host and port. * * @param buffer * The buffer containing the host and port as string. * @return The InetSocketAddress object created from host and port or null * in case the strings are not there. */ public static InetSocketAddress readSocketAddress(ChannelBuffer buffer) { String remoteHost = NettyUtils.readString(buffer); int remotePort = 0; if (buffer.readableBytes() >= 4) { remotePort = buffer.readInt(); } else { return null; } InetSocketAddress remoteAddress = null; if (null != remoteHost) { remoteAddress = new InetSocketAddress(remoteHost, remotePort); } return remoteAddress; }
/** * Read a socket address from a buffer. The socket address will be provided * as two strings containing host and port. * * @param buffer * The buffer containing the host and port as string. * @return The InetSocketAddress object created from host and port or null * in case the strings are not there. */ public static InetSocketAddress readSocketAddress(ChannelBuffer buffer) throws Exception { String remoteHost = NettyUtils.readString(buffer); int remotePort = 0; if (buffer.readableBytes() >= 4) { remotePort = buffer.readInt(); } else { return null; } InetSocketAddress remoteAddress = null; if (null != remoteHost) { remoteAddress = new InetSocketAddress(remoteHost, remotePort); } return remoteAddress; }
private boolean decodePackBody(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { if (buffer.readableBytes() < 4) { return false; } buffer.markReaderIndex(); int length = buffer.readInt(); if (buffer.readableBytes() < length) { buffer.resetReaderIndex(); return false; } ByteBuffer bb = ByteBuffer.allocate(length); buffer.readBytes(bb); bb.flip(); dataPack.getDatas().add(bb); return dataPack.getDatas().size()==listSize; }
private Object decodeV1(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { buffer.resetReaderIndex(); buffer.skipBytes(2);// skip magic num byte messageType = (byte) buffer.readShort(); long requestId = buffer.readLong(); int dataLength = buffer.readInt(); // FIXME 如果dataLength过大,可能导致问题 if (buffer.readableBytes() < dataLength) { buffer.resetReaderIndex(); return null; } checkMaxContext(dataLength, ctx, channel, messageType == MotanConstants.FLAG_REQUEST, requestId); byte[] data = new byte[dataLength]; buffer.readBytes(data); return decode(data, channel, messageType == MotanConstants.FLAG_REQUEST, requestId); }
switch (addressType) { case IPv4: { host = SocksCommonUtils.intToIp(buffer.readInt()); port = buffer.readUnsignedShort(); msg = new SocksCmdRequest(cmdType, addressType, host, port);
switch (addressType) { case IPv4: { host = SocksCommonUtils.intToIp(buffer.readInt()); port = buffer.readUnsignedShort(); msg = new SocksCmdResponse(cmdStatus, addressType);
/** * Reads the channel buffer and returns object of NexthopUnnumberedIPv4IDTlv. * * @param cb type of channel buffer * @return object of NexthopUnnumberedIPv4IDTlv */ public static NexthopUnnumberedIPv4IDTlv read(ChannelBuffer cb) { int nodeID = cb.readInt(); int interfaceID = cb.readInt(); return new NexthopUnnumberedIPv4IDTlv(nodeID, interfaceID); }
/** * Reads the channel buffer and returns object of LinkLocalRemoteIdentifiersTlv. * * @param cb channelBuffer * @return object of LinkLocalRemoteIdentifiersTlv */ public static LinkLocalRemoteIdentifiersTlv read(ChannelBuffer cb) { int linkLocalIdentifer = cb.readInt(); int linkRemoteIdentifer = cb.readInt(); return LinkLocalRemoteIdentifiersTlv.of(linkLocalIdentifer, linkRemoteIdentifer); }
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception { return buffer.readBytes(buffer.readInt()); } }
/** * Reads the channel buffer and returns object of IPv4RouterIdOfLocalNodeTlv. * * @param c input channel buffer * @return object of IPv4RouterIdOfLocalNodeTlv */ public static IPv4RouterIdOfLocalNodeSubTlv read(ChannelBuffer c) { return IPv4RouterIdOfLocalNodeSubTlv.of(c.readInt()); }
/** * Reads the channel buffer and returns object of NexthopIPv4addressTlv. * * @param c type of channel buffer * @return object of NexthopIPv4addressTlv */ public static NexthopIPv4addressTlv read(ChannelBuffer c) { return NexthopIPv4addressTlv.of(c.readInt()); }
/** * Reads the channel buffer and parses BGPLS Identifier TLV. * * @param cb ChannelBuffer * @return object of BGPLSIdentifierTlv */ public static BgpLSIdentifierTlv read(ChannelBuffer cb) { return BgpLSIdentifierTlv.of(cb.readInt()); }