List of usage examples for io.netty.buffer ByteBuf readUnsignedShort
public abstract int readUnsignedShort();
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortModInputMessageFactory.java
License:Open Source License
@Override public PortModInput deserialize(final ByteBuf rawMessage) { PortModInputBuilder builder = new PortModInputBuilder(); builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); builder.setXid(rawMessage.readUnsignedInt()); builder.setPortNo(new PortNumber((long) rawMessage.readUnsignedShort())); builder.setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage)); builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt())); builder.setMaskV10(createPortConfig(rawMessage.readUnsignedInt())); builder.setAdvertiseV10(createPortFeatures(rawMessage.readUnsignedInt())); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10PortStatusMessageFactory.java
License:Open Source License
private static void deserializePort(ByteBuf rawMessage, PortStatusMessageBuilder builder) { builder.setPortNo((long) rawMessage.readUnsignedShort()); byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; rawMessage.readBytes(address);/*from w w w . j av a 2s. co m*/ builder.setHwAddr(new MacAddress(ByteBufUtils.macAddressToString(address))); builder.setName(ByteBufUtils.decodeNullTerminatedString(rawMessage, EncodeConstants.MAX_PORT_NAME_LENGTH)); builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt())); builder.setStateV10(createPortState(rawMessage.readUnsignedInt())); builder.setCurrentFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); builder.setAdvertisedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); builder.setSupportedFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); builder.setPeerFeaturesV10(createPortFeatures(rawMessage.readUnsignedInt())); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory.java
License:Open Source License
@Override public GetQueueConfigOutput bufferToMessage(ByteBuf rawMessage, short version) { GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder(); builder.setVersion(version);/* w w w . j a va2 s.c om*/ builder.setXid((rawMessage.readUnsignedInt())); builder.setPort(new PortNumber((long) rawMessage.readUnsignedShort())); rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER); builder.setQueues(createQueuesList(rawMessage)); return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory.java
License:Open Source License
private static List<Queues> createQueuesList(ByteBuf input) { List<Queues> queuesList = new ArrayList<>(); while (input.readableBytes() > 0) { QueuesBuilder queueBuilder = new QueuesBuilder(); queueBuilder.setQueueId(new QueueId(input.readUnsignedInt())); int length = input.readUnsignedShort(); input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER); queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_HEADER_LENGTH)); queuesList.add(queueBuilder.build()); }/*from w ww .j av a2 s . c o m*/ return queuesList; }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10QueueGetConfigReplyMessageFactory.java
License:Open Source License
private static List<QueueProperty> createPropertiesList(ByteBuf input, int length) { int propertiesLength = length; List<QueueProperty> propertiesList = new ArrayList<>(); while (propertiesLength > 0) { QueuePropertyBuilder propertiesBuilder = new QueuePropertyBuilder(); QueueProperties property = QueueProperties.forValue(input.readUnsignedShort()); propertiesBuilder.setProperty(property); propertiesLength -= input.readUnsignedShort(); input.skipBytes(PADDING_IN_QUEUE_PROPERTY_HEADER); if (property.equals(QueueProperties.OFPQTMINRATE)) { RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder(); rateBuilder.setRate(input.readUnsignedShort()); propertiesBuilder.addAugmentation(RateQueueProperty.class, rateBuilder.build()); input.skipBytes(PADDING_IN_RATE_QUEUE_PROPERTY); }/*from w w w . j a v a 2 s .c om*/ propertiesList.add(propertiesBuilder.build()); } return propertiesList; }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
@Override public MultipartReplyMessage bufferToMessage(ByteBuf rawMessage, short version) { MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); builder.setVersion(version);//ww w.j a v a2 s . c om builder.setXid(rawMessage.readUnsignedInt()); int type = rawMessage.readUnsignedShort(); builder.setType(MultipartType.forValue(type)); builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0)); switch (type) { case 0: builder.setMultipartReplyBody(setDesc(rawMessage)); break; case 1: builder.setMultipartReplyBody(setFlow(rawMessage)); break; case 2: builder.setMultipartReplyBody(setAggregate(rawMessage)); break; case 3: builder.setMultipartReplyBody(setTable(rawMessage)); break; case 4: builder.setMultipartReplyBody(setPortStats(rawMessage)); break; case 5: builder.setMultipartReplyBody(setQueue(rawMessage)); break; case 0xFFFF: builder.setMultipartReplyBody(setExperimenter(rawMessage)); break; default: break; } return builder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private static MultipartReplyFlowCase setFlow(ByteBuf input) { MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder(); MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder(); List<FlowStats> flowStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder(); int length = input.readUnsignedShort(); flowStatsBuilder.setTableId(input.readUnsignedByte()); input.skipBytes(PADDING_IN_FLOW_STATS_HEADER); flowStatsBuilder.setMatchV10(OF10MatchDeserializer.createMatchV10(input)); flowStatsBuilder.setDurationSec(input.readUnsignedInt()); flowStatsBuilder.setDurationNsec(input.readUnsignedInt()); flowStatsBuilder.setPriority(input.readUnsignedShort()); flowStatsBuilder.setIdleTimeout(input.readUnsignedShort()); flowStatsBuilder.setHardTimeout(input.readUnsignedShort()); input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02); byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(cookie);/* w w w . ja v a 2 s . c o m*/ flowStatsBuilder.setCookie(new BigInteger(1, cookie)); byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(packetCount); flowStatsBuilder.setPacketCount(new BigInteger(1, packetCount)); byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(byteCount); flowStatsBuilder.setByteCount(new BigInteger(1, byteCount)); flowStatsBuilder .setAction(OF10ActionsDeserializer.createActionsList(input, length - LENGTH_OF_FLOW_STATS)); flowStatsList.add(flowStatsBuilder.build()); } flowBuilder.setFlowStats(flowStatsList); caseBuilder.setMultipartReplyFlow(flowBuilder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private static MultipartReplyPortStatsCase setPortStats(ByteBuf input) { MultipartReplyPortStatsCaseBuilder caseBuilder = new MultipartReplyPortStatsCaseBuilder(); MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder(); List<PortStats> portStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { PortStatsBuilder portStatsBuilder = new PortStatsBuilder(); portStatsBuilder.setPortNo((long) input.readUnsignedShort()); input.skipBytes(PADDING_IN_PORT_STATS_HEADER); byte[] rxPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxPackets);//from www . ja v a 2 s. c o m portStatsBuilder.setRxPackets(new BigInteger(1, rxPackets)); byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txPackets); portStatsBuilder.setTxPackets(new BigInteger(1, txPackets)); byte[] rxBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxBytes); portStatsBuilder.setRxBytes(new BigInteger(1, rxBytes)); byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txBytes); portStatsBuilder.setTxBytes(new BigInteger(1, txBytes)); byte[] rxDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxDropped); portStatsBuilder.setRxDropped(new BigInteger(1, rxDropped)); byte[] txDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txDropped); portStatsBuilder.setTxDropped(new BigInteger(1, txDropped)); byte[] rxErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxErrors); portStatsBuilder.setRxErrors(new BigInteger(1, rxErrors)); byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txErrors); portStatsBuilder.setTxErrors(new BigInteger(1, txErrors)); byte[] rxFrameErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxFrameErr); portStatsBuilder.setRxFrameErr(new BigInteger(1, rxFrameErr)); byte[] rxOverErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxOverErr); portStatsBuilder.setRxOverErr(new BigInteger(1, rxOverErr)); byte[] rxCrcErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(rxCrcErr); portStatsBuilder.setRxCrcErr(new BigInteger(1, rxCrcErr)); byte[] collisions = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(collisions); portStatsBuilder.setCollisions(new BigInteger(1, collisions)); portStatsList.add(portStatsBuilder.build()); } builder.setPortStats(portStatsList); caseBuilder.setMultipartReplyPortStats(builder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory.java
License:Open Source License
private static MultipartReplyQueueCase setQueue(ByteBuf input) { MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder(); MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder(); List<QueueStats> queueStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder(); queueStatsBuilder.setPortNo((long) input.readUnsignedShort()); input.skipBytes(PADDING_IN_QUEUE_HEADER); queueStatsBuilder.setQueueId(input.readUnsignedInt()); byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txBytes);/*from www .j a va 2 s . com*/ queueStatsBuilder.setTxBytes(new BigInteger(1, txBytes)); byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txPackets); queueStatsBuilder.setTxPackets(new BigInteger(1, txPackets)); byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; input.readBytes(txErrors); queueStatsBuilder.setTxErrors(new BigInteger(1, txErrors)); queueStatsList.add(queueStatsBuilder.build()); } builder.setQueueStats(queueStatsList); caseBuilder.setMultipartReplyQueue(builder.build()); return caseBuilder.build(); }
From source file:org.opendaylight.openflowjava.protocol.impl.deserialization.factories.PacketInMessageFactory.java
License:Open Source License
@Override public PacketInMessage bufferToMessage(ByteBuf rawMessage, short version) { PacketInMessageBuilder builder = new PacketInMessageBuilder(); builder.setVersion(version);//w ww .j a v a 2 s . c om builder.setXid(rawMessage.readUnsignedInt()); builder.setBufferId(rawMessage.readUnsignedInt()); builder.setTotalLen(rawMessage.readUnsignedShort()); builder.setReason(PacketInReason.forValue(rawMessage.readUnsignedByte())); builder.setTableId(new TableId((long) rawMessage.readUnsignedByte())); byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; rawMessage.readBytes(cookie); builder.setCookie(new BigInteger(1, cookie)); builder.setMatch(MatchDeserializer.createMatch(rawMessage)); rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER); builder.setData(rawMessage.readBytes(rawMessage.readableBytes()).array()); return builder.build(); }