Example usage for io.netty.buffer ByteBuf readUnsignedByte

List of usage examples for io.netty.buffer ByteBuf readUnsignedByte

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf readUnsignedByte.

Prototype

public abstract short readUnsignedByte();

Source Link

Document

Gets an unsigned byte at the current readerIndex and increases the readerIndex by 1 in this buffer.

Usage

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsLabelSerializerTest.java

License:Open Source License

private static void checkHeader(ByteBuf buffer, boolean hasMask) {
    assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort());
    short fieldAndMask = buffer.readUnsignedByte();
    assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_LABEL, fieldAndMask >>> 1);
    assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0);
    assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte());
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsTcSerializerTest.java

License:Open Source License

/**
 * Test correct serialization//from w w w . jav a2  s  . co  m
 */
@Test
public void testSerialize() {
    MatchEntryBuilder builder = prepareMplsTcMatchEntry((short) 16);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);

    checkHeader(buffer, false);
    assertEquals("Wrong value", 16, buffer.readUnsignedByte());
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsTcSerializerTest.java

License:Open Source License

private static void checkHeader(ByteBuf buffer, boolean hasMask) {
    assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort());
    short fieldAndMask = buffer.readUnsignedByte();
    assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_TC, fieldAndMask >>> 1);
    assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0);
    assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte());
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmPbbIsidSerializerTest.java

License:Open Source License

private static void checkHeader(ByteBuf buffer, boolean hasMask) {
    assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort());
    short fieldAndMask = buffer.readUnsignedByte();
    assertEquals("Wrong oxm-field", OxmMatchConstants.PBB_ISID, fieldAndMask >>> 1);
    assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0);
    if (hasMask) {
        assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte());
    } else {/*from   w  ww  .  ja va2  s  . com*/
        assertEquals("Wrong length", EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte());
    }
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmSctpDstSerializerTest.java

License:Open Source License

private static void checkHeader(ByteBuf buffer, boolean hasMask) {
    assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort());
    short fieldAndMask = buffer.readUnsignedByte();
    assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_DST, fieldAndMask >>> 1);
    assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0);
    assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte());
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmSctpSrcSerializerTest.java

License:Open Source License

private static void checkHeader(ByteBuf buffer, boolean hasMask) {
    assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort());
    short fieldAndMask = buffer.readUnsignedByte();
    assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_SRC, fieldAndMask >>> 1);
    assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0);
    assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte());
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTcpDstSerializerTest.java

License:Open Source License

private static void checkHeader(ByteBuf buffer, boolean hasMask) {
    assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort());
    short fieldAndMask = buffer.readUnsignedByte();
    assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_DST, fieldAndMask >>> 1);
    assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0);
    assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte());
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTcpSrcSerializerTest.java

License:Open Source License

private static void checkHeader(ByteBuf buffer, boolean hasMask) {
    assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort());
    short fieldAndMask = buffer.readUnsignedByte();
    assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_SRC, fieldAndMask >>> 1);
    assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0);
    assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte());
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTunnelIdSerializerTest.java

License:Open Source License

private static void checkHeader(ByteBuf buffer, boolean hasMask) {
    assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort());
    short fieldAndMask = buffer.readUnsignedByte();
    assertEquals("Wrong oxm-field", OxmMatchConstants.TUNNEL_ID, fieldAndMask >>> 1);
    assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0);
    if (hasMask) {
        assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte());
    } else {//from ww  w  .j  a va2 s. co m
        assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte());
    }
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpDstSerializerTest.java

License:Open Source License

private static void checkHeader(ByteBuf buffer, boolean hasMask) {
    assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort());
    short fieldAndMask = buffer.readUnsignedByte();
    assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_DST, fieldAndMask >>> 1);
    assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0);
    assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte());
}