List of usage examples for io.netty.buffer ByteBuf readUnsignedInt
public abstract long readUnsignedInt();
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.ExperimenterActionDeserializer.java
License:Open Source License
@Override public Action deserializeHeader(ByteBuf input) { ActionBuilder builder = new ActionBuilder(); input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); builder.setType(Experimenter.class); input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); expBuilder.setExperimenter(input.readUnsignedInt()); builder.addAugmentation(ExperimenterAction.class, expBuilder.build()); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.ExperimenterActionDeserializer.java
License:Open Source License
@Override public Action deserialize(ByteBuf input) { ActionBuilder builder = new ActionBuilder(); input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); builder.setType(Experimenter.class); int length = input.readUnsignedShort(); // subtract experimenter header length length -= EncodeConstants.EXPERIMENTER_IDS_LENGTH; ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); expBuilder.setExperimenter(input.readUnsignedInt()); if (length > 0) { byte[] data = new byte[length]; input.readBytes(data);//from w w w .jav a 2 s.co m expBuilder.setData(data); } builder.addAugmentation(ExperimenterAction.class, expBuilder.build()); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.OF13ExperimenterInstructionDeserializer.java
License:Open Source License
@Override public Instruction deserializeHeader(ByteBuf input) { InstructionBuilder builder = new InstructionBuilder(); input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); builder.setType(Experimenter.class); input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); expBuilder.setExperimenter(input.readUnsignedInt()); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.experimenters.OF13ExperimenterInstructionDeserializer.java
License:Open Source License
@Override public Instruction deserialize(ByteBuf input) { InstructionBuilder builder = new InstructionBuilder(); input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); builder.setType(Experimenter.class); input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); ExperimenterInstructionBuilder expBuilder = new ExperimenterInstructionBuilder(); expBuilder.setExperimenter(input.readUnsignedInt()); if (input.readableBytes() > 0) { byte[] data = new byte[input.readableBytes()]; input.readBytes(data);//from w w w .ja v a 2s. c om expBuilder.setData(data); } builder.addAugmentation(ExperimenterInstruction.class, expBuilder.build()); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierInputMessageFactory.java
License:Open Source License
@Override public BarrierInput deserialize(ByteBuf rawMessage) { BarrierInputBuilder builder = new BarrierInputBuilder(); builder.setVersion(getVersion());/*from ww w. java2 s .co m*/ builder.setXid(rawMessage.readUnsignedInt()); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.BarrierReplyMessageFactory.java
License:Open Source License
@Override public BarrierOutput bufferToMessage(ByteBuf rawMessage, short version) { BarrierOutputBuilder builder = new BarrierOutputBuilder(); builder.setVersion(version);/* ww w .ja v a 2 s . c om*/ builder.setXid(rawMessage.readUnsignedInt()); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoReplyMessageFactory.java
License:Open Source License
@Override public EchoOutput bufferToMessage(ByteBuf rawMessage, short version) { EchoOutputBuilder builder = new EchoOutputBuilder(); builder.setVersion(version);/*from w w w.jav a 2 s .c om*/ builder.setXid(rawMessage.readUnsignedInt()); int remainingBytes = rawMessage.readableBytes(); if (remainingBytes > 0) { builder.setData(rawMessage.readBytes(remainingBytes).array()); } return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.EchoRequestMessageFactory.java
License:Open Source License
@Override public EchoRequestMessage bufferToMessage(ByteBuf rawMessage, short version) { EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder(); builder.setVersion(version);//from ww w .j a v a2 s .com builder.setXid(rawMessage.readUnsignedInt()); builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory.java
License:Open Source License
@Override public ErrorMessage bufferToMessage(ByteBuf rawMessage, short version) { ErrorMessageBuilder builder = new ErrorMessageBuilder(); builder.setVersion(version);/* w w w . ja v a2 s . c om*/ builder.setXid(rawMessage.readUnsignedInt()); int type = rawMessage.readUnsignedShort(); ErrorType errorType = ErrorType.forValue(type); decodeType(builder, errorType, type); decodeCode(rawMessage, builder, errorType); if (rawMessage.readableBytes() > 0) { builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); } return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.ErrorMessageFactory.java
License:Open Source License
private static void decodeCode(ByteBuf rawMessage, ErrorMessageBuilder builder, ErrorType type) { int code = rawMessage.readUnsignedShort(); if (type != null) { switch (type) { case HELLOFAILED: { HelloFailedCode errorCode = HelloFailedCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); }//from ww w . java2s. com break; } case BADREQUEST: { BadRequestCode errorCode = BadRequestCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case BADACTION: { BadActionCode errorCode = BadActionCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case BADINSTRUCTION: { BadInstructionCode errorCode = BadInstructionCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case BADMATCH: { BadMatchCode errorCode = BadMatchCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case FLOWMODFAILED: { FlowModFailedCode errorCode = FlowModFailedCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case GROUPMODFAILED: { GroupModFailedCode errorCode = GroupModFailedCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case PORTMODFAILED: { PortModFailedCode errorCode = PortModFailedCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case TABLEMODFAILED: { TableModFailedCode errorCode = TableModFailedCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case QUEUEOPFAILED: { QueueOpFailedCode errorCode = QueueOpFailedCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case SWITCHCONFIGFAILED: { SwitchConfigFailedCode errorCode = SwitchConfigFailedCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case ROLEREQUESTFAILED: { RoleRequestFailedCode errorCode = RoleRequestFailedCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case METERMODFAILED: { MeterModFailedCode errorCode = MeterModFailedCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case TABLEFEATURESFAILED: { TableFeaturesFailedCode errorCode = TableFeaturesFailedCode.forValue(code); if (errorCode != null) { setCode(builder, errorCode.getIntValue(), errorCode.name()); } else { setUnknownCode(builder, code); } break; } case EXPERIMENTER: ExperimenterErrorBuilder expBuilder = new ExperimenterErrorBuilder(); expBuilder.setExpType(code); expBuilder.setExperimenter(rawMessage.readUnsignedInt()); builder.addAugmentation(ExperimenterError.class, expBuilder.build()); break; default: setUnknownCode(builder, code); break; } } else { setUnknownCode(builder, code); } }