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.deserialization.factories.PortStatusMessageFactory.java

License:Open Source License

@Override
public PortStatusMessage bufferToMessage(ByteBuf rawMessage, short version) {
    PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
    builder.setVersion(version);/*from  w w  w  .  j  a  v a 2s.co m*/
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
    rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);
    builder.setPortNo(rawMessage.readUnsignedInt());
    rawMessage.skipBytes(PADDING_IN_OFP_PORT_HEADER_1);
    byte[] hwAddress = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
    rawMessage.readBytes(hwAddress);
    builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(hwAddress)));
    rawMessage.skipBytes(PADDING_IN_OFP_PORT_HEADER_2);
    builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH));
    builder.setConfig(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setState(createPortState(rawMessage.readUnsignedInt()));
    builder.setCurrentFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
    builder.setAdvertisedFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
    builder.setSupportedFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
    builder.setPeerFeatures(createPortFeatures(rawMessage.readUnsignedInt()));
    builder.setCurrSpeed(rawMessage.readUnsignedInt());
    builder.setMaxSpeed(rawMessage.readUnsignedInt());
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.GoToTableInstructionDeserializer.java

License:Open Source License

@Override
public Instruction deserialize(ByteBuf input) {
    InstructionBuilder builder = new InstructionBuilder();
    GotoTableCaseBuilder caseBuilder = new GotoTableCaseBuilder();
    GotoTableBuilder instructionBuilder = new GotoTableBuilder();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    instructionBuilder.setTableId(input.readUnsignedByte());
    caseBuilder.setGotoTable(instructionBuilder.build());
    builder.setInstructionChoice(caseBuilder.build());
    input.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE);
    return builder.build();
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.AbstractOxmIpv4AddressDeserializer.java

License:Open Source License

private static void addIpv4AddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) {
    Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder();
    List<String> groups = new ArrayList<>();
    for (int i = 0; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {
        groups.add(Short.toString(input.readUnsignedByte()));
    }//w  ww .  j a  v  a2s  .co  m
    Joiner joiner = Joiner.on(".");
    ipv4AddressBuilder.setIpv4Address(new Ipv4Address(joiner.join(groups)));
    builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build());
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.AbstractOxmMatchEntryDeserializer.java

License:Open Source License

/**
 * Prepares match entry header - sets oxm_class, oxm_field, hasMask
 *  + sets the buffer.readerIndex() to the end of match entry
 *  - where augmentation starts//  w w w.j  av  a2 s .  co  m
 * @param oxmClass oxm class type
 * @param oxmField oxm field type
 * @param input input bytebuf
 * @return MatchEntriesBuilder which can be filled with MatchEntry augmentation
 */
protected MatchEntryBuilder processHeader(Class<? extends OxmClassBase> oxmClass,
        Class<? extends MatchField> oxmField, ByteBuf input) {
    MatchEntryBuilder builder = new MatchEntryBuilder();
    builder.setOxmClass(oxmClass);
    // skip oxm_class (provided)
    input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    builder.setOxmMatchField(oxmField);
    boolean hasMask = (input.readUnsignedByte() & 1) != 0;
    builder.setHasMask(hasMask);
    // skip match entry length - not needed
    input.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
    return builder;
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4CodeDeserializer.java

License:Open Source License

private static void addIcmpv4CodeValue(ByteBuf input, MatchEntryBuilder builder) {
    Icmpv4CodeCaseBuilder caseBuilder = new Icmpv4CodeCaseBuilder();
    Icmpv4CodeBuilder icmpBuilder = new Icmpv4CodeBuilder();
    icmpBuilder.setIcmpv4Code(input.readUnsignedByte());
    caseBuilder.setIcmpv4Code(icmpBuilder.build());
    builder.setMatchEntryValue(caseBuilder.build());
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4TypeDeserializer.java

License:Open Source License

private static void addIcmpv4TypeValue(ByteBuf input, MatchEntryBuilder builder) {
    Icmpv4TypeCaseBuilder caseBuilder = new Icmpv4TypeCaseBuilder();
    Icmpv4TypeBuilder icmpBuilder = new Icmpv4TypeBuilder();
    icmpBuilder.setIcmpv4Type(input.readUnsignedByte());
    caseBuilder.setIcmpv4Type(icmpBuilder.build());
    builder.setMatchEntryValue(caseBuilder.build());
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6CodeDeserializer.java

License:Open Source License

private static void addIcmpv6CodeValue(ByteBuf input, MatchEntryBuilder builder) {
    Icmpv6CodeCaseBuilder caseBuilder = new Icmpv6CodeCaseBuilder();
    Icmpv6CodeBuilder icmpBuilder = new Icmpv6CodeBuilder();
    icmpBuilder.setIcmpv6Code(input.readUnsignedByte());
    caseBuilder.setIcmpv6Code(icmpBuilder.build());
    builder.setMatchEntryValue(caseBuilder.build());
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6TypeDeserializer.java

License:Open Source License

private static void addIcmpv6TypeValue(ByteBuf input, MatchEntryBuilder builder) {
    Icmpv6TypeCaseBuilder caseBuilder = new Icmpv6TypeCaseBuilder();
    Icmpv6TypeBuilder icmpBuilder = new Icmpv6TypeBuilder();
    icmpBuilder.setIcmpv6Type(input.readUnsignedByte());
    caseBuilder.setIcmpv6Type(icmpBuilder.build());
    builder.setMatchEntryValue(caseBuilder.build());
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpDscpDeserializer.java

License:Open Source License

private static void addIpDscpValue(ByteBuf input, MatchEntryBuilder builder) {
    IpDscpCaseBuilder caseBuilder = new IpDscpCaseBuilder();
    IpDscpBuilder dscpBuilder = new IpDscpBuilder();
    dscpBuilder.setDscp(new Dscp(input.readUnsignedByte()));
    caseBuilder.setIpDscp(dscpBuilder.build());
    builder.setMatchEntryValue(caseBuilder.build());
}

From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpEcnDeserializer.java

License:Open Source License

private static void addIpEcnValue(ByteBuf input, MatchEntryBuilder builder) {
    IpEcnCaseBuilder caseBuilder = new IpEcnCaseBuilder();
    IpEcnBuilder ecnBuilder = new IpEcnBuilder();
    ecnBuilder.setEcn(input.readUnsignedByte());
    caseBuilder.setIpEcn(ecnBuilder.build());
    builder.setMatchEntryValue(caseBuilder.build());
}